Tests passent
This commit is contained in:
@@ -1,5 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_layout_file>
|
||||
<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>
|
||||
|
||||
Binary file not shown.
@@ -30,22 +30,53 @@
|
||||
namespace artis::factory {
|
||||
|
||||
void Processor::dint(const Time & /* t */) {
|
||||
// TODO
|
||||
// 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) {
|
||||
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()
|
||||
|
||||
if(this->currentState == this->ProcessorState::WAIT){
|
||||
// We're waiting for a new event, and can work on this one !
|
||||
this->currentState = this->ProcessorState::LOADING; // New state, we're loading this PO
|
||||
std::cout << "PO loaded ! Time t : " << t << ", Time e : " << e << std::endl;
|
||||
}else{
|
||||
// Error, please wait, we're busy
|
||||
//TODO
|
||||
}
|
||||
uint8_t *data = nullptr;
|
||||
event.data()(data);
|
||||
this->currentPO = std::make_unique<ProductionOrder>(data, event.data().size());
|
||||
|
||||
this->currentState = this->ProcessorState::LOADING;
|
||||
|
||||
#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 {
|
||||
// TODO
|
||||
Time Processor::ta(const Time &t) const {
|
||||
// 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 {
|
||||
@@ -74,7 +128,7 @@ Bag Processor::lambda(const Time & /* t */) const {
|
||||
|
||||
artis::common::event::Value Processor::observe(const Time & /* t */, unsigned int /* index */) const {
|
||||
// Print de l'état actuel ?
|
||||
return {};
|
||||
return {"Hello World ?"};
|
||||
}
|
||||
|
||||
} // namespace artis::factory
|
||||
|
||||
@@ -90,7 +90,9 @@ public:
|
||||
private:
|
||||
// TODO (state)
|
||||
ProcessorState currentState = ProcessorState::INIT;
|
||||
std::unique_ptr<ProductionOrder> currentPO;
|
||||
Time startTime = 0;
|
||||
Time stepTime = 0;
|
||||
};
|
||||
|
||||
} // namespace artis::factory
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
57602
test/PoolRouter.csv
57602
test/PoolRouter.csv
File diff suppressed because it is too large
Load Diff
BIN
test/test_json
BIN
test/test_json
Binary file not shown.
@@ -34,7 +34,7 @@ public:
|
||||
|
||||
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) {
|
||||
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);
|
||||
} else {
|
||||
std::cout << "ERREUR : FICHIER JSON NON TROUVé" << std::endl;
|
||||
BOOST_CHECK(false);
|
||||
}
|
||||
}
|
||||
BIN
test/test_simple
BIN
test/test_simple
Binary file not shown.
Reference in New Issue
Block a user