Correction TP1
Wtf ._.
This commit is contained in:
1
Testing/Temporary/CTestCostData.txt
Normal file
1
Testing/Temporary/CTestCostData.txt
Normal file
@@ -0,0 +1 @@
|
||||
---
|
||||
3
Testing/Temporary/LastTest.log
Normal file
3
Testing/Temporary/LastTest.log
Normal file
@@ -0,0 +1,3 @@
|
||||
Start testing: Oct 06 13:14 CEST
|
||||
----------------------------------------------------------
|
||||
End testing: Oct 06 13:14 CEST
|
||||
@@ -7,14 +7,9 @@
|
||||
<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" />
|
||||
<Cursor1 position="2504" topLine="60" />
|
||||
</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">
|
||||
@@ -24,7 +19,7 @@
|
||||
</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" />
|
||||
<Cursor1 position="1175" topLine="15" />
|
||||
</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">
|
||||
@@ -32,4 +27,9 @@
|
||||
<Cursor1 position="0" topLine="6" />
|
||||
</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>
|
||||
</CodeBlocks_layout_file>
|
||||
|
||||
Binary file not shown.
@@ -1008,5 +1008,4 @@ src/CMakeFiles/factory_core.dir/Processor.cpp.o: \
|
||||
/usr/include/c++/13/cxxabi.h \
|
||||
/usr/include/x86_64-linux-gnu/c++/13/bits/cxxabi_tweaks.h \
|
||||
/home/lj50/Univ/M2/Modelisation_problemes/simulation/src/Machine.hpp \
|
||||
/home/lj50/Univ/M2/Modelisation_problemes/simulation/src/ProductionOrder.hpp \
|
||||
/usr/include/c++/13/iostream
|
||||
/home/lj50/Univ/M2/Modelisation_problemes/simulation/src/ProductionOrder.hpp
|
||||
|
||||
@@ -25,110 +25,112 @@
|
||||
*/
|
||||
|
||||
#include "Processor.hpp"
|
||||
#include <iostream> // TODO: Remove this when debug is over
|
||||
|
||||
namespace artis::factory {
|
||||
|
||||
void Processor::dint(const Time & /* t */) {
|
||||
// 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;
|
||||
void Processor::dint(const Time & t) {
|
||||
switch (_phase) {
|
||||
case Phase::INIT: {
|
||||
_phase = Phase::WAIT;
|
||||
break;
|
||||
|
||||
case ProcessorState::PROCESSING:
|
||||
//if ProcessorParameters.processing_time > t
|
||||
this->currentState = ProcessorState::UNLOADING;
|
||||
}
|
||||
case Phase::READY:
|
||||
_po.reset(nullptr);
|
||||
_phase = Phase::WAIT;
|
||||
break;
|
||||
|
||||
case ProcessorState::UNLOADING:
|
||||
//if ProcessorParameters.unloading_time > t
|
||||
this->currentState = ProcessorState::READY;
|
||||
case Phase::WAIT:
|
||||
assert(false);
|
||||
break;
|
||||
|
||||
case ProcessorState::READY:
|
||||
this->currentState = ProcessorState::WAIT;
|
||||
case Phase::LOADING: {
|
||||
_phase = Phase::PROCESSING;
|
||||
break;
|
||||
|
||||
default:
|
||||
}
|
||||
case Phase::PROCESSING: {
|
||||
_phase = Phase::UNLOADING;
|
||||
break;
|
||||
}
|
||||
case Phase::UNLOADING: {
|
||||
_phase = Phase::READY;
|
||||
|
||||
#ifdef WITH_TRACE
|
||||
Trace::trace()
|
||||
<< TraceElement(get_name(), t,
|
||||
artis::common::FormalismType::PDEVS,
|
||||
artis::common::FunctionType::DELTA_INT,
|
||||
artis::common::LevelType::USER)
|
||||
<< "FINISH po = " << _po->to_string();
|
||||
Trace::trace().flush();
|
||||
#endif
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
// Fonction gérant les réponses du système aux évents passés via event()
|
||||
|
||||
uint8_t *data = nullptr;
|
||||
event.data()(data);
|
||||
this->currentPO = std::make_unique<ProductionOrder>(data, event.data().size());
|
||||
void Processor::dext(const Time &t, const Time & /* e */, const Bag &bag) {
|
||||
std::for_each(bag.begin(), bag.end(), [this, t](const ExternalEvent &event) {
|
||||
if (event.port_index() == inputs::IN) {
|
||||
uint8_t *data = nullptr;
|
||||
|
||||
this->currentState = this->ProcessorState::LOADING;
|
||||
// TODO
|
||||
assert(_po == nullptr);
|
||||
|
||||
#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
|
||||
event.data()(data);
|
||||
_po = std::make_unique<ProductionOrder>(data, event.data().size());
|
||||
_phase = Phase::LOADING;
|
||||
|
||||
#ifdef WITH_TRACE
|
||||
Trace::trace()
|
||||
<< TraceElement(get_name(), t,
|
||||
artis::common::FormalismType::PDEVS,
|
||||
artis::common::FunctionType::DELTA_EXT,
|
||||
artis::common::LevelType::USER)
|
||||
<< "START po = " << _po->to_string();
|
||||
Trace::trace().flush();
|
||||
#endif
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void Processor::start(const Time &t) {
|
||||
// Démarrage et initialisation
|
||||
|
||||
this->currentState = this->ProcessorState::WAIT; // Prêt à recevoir un Production Order
|
||||
this->startTime = t;
|
||||
|
||||
void Processor::start(const Time & /* t */) {
|
||||
// TODO
|
||||
_phase = Phase::INIT;
|
||||
}
|
||||
|
||||
Time Processor::ta(const Time &t) const {
|
||||
// Temps passé dans l'état actuel
|
||||
// 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;
|
||||
|
||||
Time Processor::ta(const Time & /* t */) const {
|
||||
// TODO
|
||||
switch (_phase) {
|
||||
case Phase::INIT:
|
||||
case Phase::READY:
|
||||
return 0;
|
||||
case Phase::WAIT:
|
||||
return artis::common::DoubleTime::infinity;
|
||||
case Phase::LOADING:
|
||||
return _parameters.load_time;
|
||||
case Phase::PROCESSING:
|
||||
return _parameters.processing_time;
|
||||
case Phase::UNLOADING:
|
||||
return _parameters.unload_time;
|
||||
}
|
||||
return artis::common::DoubleTime::infinity;
|
||||
}
|
||||
|
||||
Bag Processor::lambda(const Time & /* t */) const {
|
||||
Bag bag;
|
||||
// L'ensemble des sorties de cet objet
|
||||
Bag bag;
|
||||
|
||||
// TODO
|
||||
if (_phase == Phase::READY) {
|
||||
bag.push_back(ExternalEvent(outputs::OUT, common::event::Value(_po->_buffer, _po->_size)));
|
||||
}
|
||||
return bag;
|
||||
}
|
||||
|
||||
artis::common::event::Value Processor::observe(const Time & /* t */, unsigned int /* index */) const {
|
||||
// Print de l'état actuel ?
|
||||
return {"Hello World ?"};
|
||||
return {};
|
||||
}
|
||||
|
||||
} // namespace artis::factory
|
||||
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
};
|
||||
|
||||
Processor(const std::string &name, const Context<Processor, ProcessorParameters> &context)
|
||||
: Dynamics<Processor, ProcessorParameters>(name, context) {
|
||||
: Dynamics<Processor, ProcessorParameters>(name, context), _parameters(context.parameters()) {
|
||||
input_port({inputs::IN, "in"});
|
||||
output_port({outputs::OUT, "out"});
|
||||
}
|
||||
@@ -78,21 +78,43 @@ public:
|
||||
|
||||
artis::common::event::Value observe(const Time &t, unsigned int index) const override;
|
||||
|
||||
enum ProcessorState{
|
||||
INIT,
|
||||
WAIT,
|
||||
LOADING,
|
||||
PROCESSING,
|
||||
UNLOADING,
|
||||
READY
|
||||
private:
|
||||
|
||||
struct Phase {
|
||||
enum values {
|
||||
INIT,
|
||||
READY,
|
||||
WAIT,
|
||||
LOADING,
|
||||
PROCESSING,
|
||||
UNLOADING
|
||||
};
|
||||
|
||||
private:
|
||||
// TODO (state)
|
||||
ProcessorState currentState = ProcessorState::INIT;
|
||||
std::unique_ptr<ProductionOrder> currentPO;
|
||||
Time startTime = 0;
|
||||
Time stepTime = 0;
|
||||
static std::string to_string(const values &value) {
|
||||
switch (value) {
|
||||
case INIT:
|
||||
return "INIT";
|
||||
case READY:
|
||||
return "READY";
|
||||
case WAIT:
|
||||
return "WAIT";
|
||||
case LOADING:
|
||||
return "LOADING";
|
||||
case PROCESSING:
|
||||
return "PROCESSING";
|
||||
case UNLOADING:
|
||||
return "UNLOADING";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
};
|
||||
|
||||
// parameters
|
||||
ProcessorParameters _parameters;
|
||||
|
||||
// state
|
||||
Phase::values _phase;
|
||||
std::unique_ptr<ProductionOrder> _po;
|
||||
};
|
||||
|
||||
} // namespace artis::factory
|
||||
|
||||
Binary file not shown.
Binary file not shown.
57557
test/PoolRouter.csv
57557
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.
Reference in New Issue
Block a user