Tests passent

This commit is contained in:
2025-10-02 10:42:33 +02:00
parent 715a448b80
commit 7882056fbb
11 changed files with 28905 additions and 28818 deletions

View File

@@ -1,5 +1,35 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file> <CodeBlocks_layout_file>
<FileVersion major="1" minor="0" /> <FileVersion major="1" minor="0" />
<ActiveTarget name="all" /> <ActiveTarget name="test_simple" />
<File name="src/PoolRouter.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="116" />
</Cursor>
</File>
<File name="src/ItemStock.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="24" />
</Cursor>
</File>
<File name="src/Processor.cpp" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2418" topLine="48" />
</Cursor>
</File>
<File name="src/ProductionOrder.hpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="60" />
</Cursor>
</File>
<File name="src/Processor.hpp" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="1" zoom_2="0">
<Cursor>
<Cursor1 position="2316" topLine="58" />
</Cursor>
</File>
<File name="src/Machine.hpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="6" />
</Cursor>
</File>
</CodeBlocks_layout_file> </CodeBlocks_layout_file>

View File

@@ -30,22 +30,53 @@
namespace artis::factory { namespace artis::factory {
void Processor::dint(const Time & /* t */) { void Processor::dint(const Time & /* t */) {
// TODO
// Fonction que gère les évolutions internes de ce modèle // Fonction que gère les évolutions internes de ce modèle
switch(this->currentState){
case ProcessorState::LOADING:
//if ProcessorParameters.load_time > t
this->currentState = ProcessorState::PROCESSING;
break;
case ProcessorState::PROCESSING:
//if ProcessorParameters.processing_time > t
this->currentState = ProcessorState::UNLOADING;
break;
case ProcessorState::UNLOADING:
//if ProcessorParameters.unloading_time > t
this->currentState = ProcessorState::READY;
break;
case ProcessorState::READY:
this->currentState = ProcessorState::WAIT;
break;
default:
break;
}
} }
void Processor::dext(const Time &t, const Time &e, const Bag &bag) { void Processor::dext(const Time &t, const Time &e, const Bag &bag) {
std::for_each(bag.begin(), bag.end(), [this, t, e](const ExternalEvent &/*event*/) { // [this] capture this et le remet dans la lambda std::for_each(bag.begin(), bag.end(), [this, t, e](const ExternalEvent &event) { // [this] capture this et le remet dans la lambda
// Fonction gérant les réponses du système aux évents passés via event() // Fonction gérant les réponses du système aux évents passés via event()
if(this->currentState == this->ProcessorState::WAIT){ uint8_t *data = nullptr;
// We're waiting for a new event, and can work on this one ! event.data()(data);
this->currentState = this->ProcessorState::LOADING; // New state, we're loading this PO this->currentPO = std::make_unique<ProductionOrder>(data, event.data().size());
std::cout << "PO loaded ! Time t : " << t << ", Time e : " << e << std::endl;
}else{ this->currentState = this->ProcessorState::LOADING;
// Error, please wait, we're busy
//TODO #ifdef WITH_TRACE
} Trace::trace()
<< TraceElement(get_name(), t,
artis::common::FormalismType::PDEVS,
artis::common::FunctionType::DELTA_EXT,
artis::common::LevelType::USER)
<< "this->currentPO = " << this->currentPO->to_string();
Trace::trace().flush();
#endif
}); });
} }
@@ -58,10 +89,33 @@ void Processor::start(const Time &t) {
} }
Time Processor::ta(const Time & /* t */) const { Time Processor::ta(const Time &t) const {
// TODO
// Temps passé dans l'état actuel // Temps passé dans l'état actuel
return artis::common::DoubleTime::infinity; // Inspiré de Router
switch(this->currentState){
case ProcessorState::WAIT:
return artis::common::DoubleTime::infinity;
case ProcessorState::LOADING:
//return ProcessorParameters.load_time; // I can't understand how to find, use, get or do anything with this var...
return t+0;
case ProcessorState::PROCESSING:
//return ProcessorParameters.processing_time;
return t+0;
case ProcessorState::UNLOADING:
//return ProcessorParameters.unload_time;
return t+0;
case ProcessorState::READY:
return artis::common::DoubleTime::infinity;
default:
return t+0;
}
} }
Bag Processor::lambda(const Time & /* t */) const { Bag Processor::lambda(const Time & /* t */) const {
@@ -74,7 +128,7 @@ Bag Processor::lambda(const Time & /* t */) const {
artis::common::event::Value Processor::observe(const Time & /* t */, unsigned int /* index */) const { artis::common::event::Value Processor::observe(const Time & /* t */, unsigned int /* index */) const {
// Print de l'état actuel ? // Print de l'état actuel ?
return {}; return {"Hello World ?"};
} }
} // namespace artis::factory } // namespace artis::factory

View File

@@ -90,7 +90,9 @@ public:
private: private:
// TODO (state) // TODO (state)
ProcessorState currentState = ProcessorState::INIT; ProcessorState currentState = ProcessorState::INIT;
std::unique_ptr<ProductionOrder> currentPO;
Time startTime = 0; Time startTime = 0;
Time stepTime = 0;
}; };
} // namespace artis::factory } // namespace artis::factory

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@@ -34,7 +34,7 @@ public:
BOOST_AUTO_TEST_CASE(TestCase_JSONPool) BOOST_AUTO_TEST_CASE(TestCase_JSONPool)
{ {
std::ifstream input("../../data/factory.json"); std::ifstream input("../data/factory.json"); // Fix : j'ai retiré un ../ pour que le test passe sous Codeblocks
if (input) { if (input) {
std::string str((std::istreambuf_iterator<char>(input)), std::istreambuf_iterator<char>()); std::string str((std::istreambuf_iterator<char>(input)), std::istreambuf_iterator<char>());
@@ -71,6 +71,7 @@ BOOST_AUTO_TEST_CASE(TestCase_JSONPool)
BOOST_CHECK(true); BOOST_CHECK(true);
} else { } else {
std::cout << "ERREUR : FICHIER JSON NON TROUVé" << std::endl;
BOOST_CHECK(false); BOOST_CHECK(false);
} }
} }

Binary file not shown.