Correction TP1

Wtf ._.
This commit is contained in:
2025-10-06 13:22:33 +02:00
parent 7882056fbb
commit 8670376f1f
11 changed files with 28903 additions and 28875 deletions

View File

@@ -0,0 +1 @@
---

View File

@@ -0,0 +1,3 @@
Start testing: Oct 06 13:14 CEST
----------------------------------------------------------
End testing: Oct 06 13:14 CEST

View File

@@ -7,14 +7,9 @@
<Cursor1 position="0" topLine="116" /> <Cursor1 position="0" topLine="116" />
</Cursor> </Cursor>
</File> </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"> <File name="src/Processor.cpp" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor> <Cursor>
<Cursor1 position="2418" topLine="48" /> <Cursor1 position="2504" topLine="60" />
</Cursor> </Cursor>
</File> </File>
<File name="src/ProductionOrder.hpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> <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>
<File name="src/Processor.hpp" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="1" zoom_2="0"> <File name="src/Processor.hpp" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="1" zoom_2="0">
<Cursor> <Cursor>
<Cursor1 position="2316" topLine="58" /> <Cursor1 position="1175" topLine="15" />
</Cursor> </Cursor>
</File> </File>
<File name="src/Machine.hpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> <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" /> <Cursor1 position="0" topLine="6" />
</Cursor> </Cursor>
</File> </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> </CodeBlocks_layout_file>

View File

@@ -1008,5 +1008,4 @@ src/CMakeFiles/factory_core.dir/Processor.cpp.o: \
/usr/include/c++/13/cxxabi.h \ /usr/include/c++/13/cxxabi.h \
/usr/include/x86_64-linux-gnu/c++/13/bits/cxxabi_tweaks.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/Machine.hpp \
/home/lj50/Univ/M2/Modelisation_problemes/simulation/src/ProductionOrder.hpp \ /home/lj50/Univ/M2/Modelisation_problemes/simulation/src/ProductionOrder.hpp
/usr/include/c++/13/iostream

View File

@@ -25,48 +25,62 @@
*/ */
#include "Processor.hpp" #include "Processor.hpp"
#include <iostream> // TODO: Remove this when debug is over
namespace artis::factory { namespace artis::factory {
void Processor::dint(const Time & /* t */) { void Processor::dint(const Time & t) {
// Fonction que gère les évolutions internes de ce modèle switch (_phase) {
switch(this->currentState){ case Phase::INIT: {
_phase = Phase::WAIT;
case ProcessorState::LOADING:
//if ProcessorParameters.load_time > t
this->currentState = ProcessorState::PROCESSING;
break; break;
}
case ProcessorState::PROCESSING: case Phase::READY:
//if ProcessorParameters.processing_time > t _po.reset(nullptr);
this->currentState = ProcessorState::UNLOADING; _phase = Phase::WAIT;
break; break;
case Phase::WAIT:
case ProcessorState::UNLOADING: assert(false);
//if ProcessorParameters.unloading_time > t
this->currentState = ProcessorState::READY;
break; break;
case Phase::LOADING: {
case ProcessorState::READY: _phase = Phase::PROCESSING;
this->currentState = ProcessorState::WAIT;
break; break;
}
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: default:
break; 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()
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; uint8_t *data = nullptr;
event.data()(data);
this->currentPO = std::make_unique<ProductionOrder>(data, event.data().size());
this->currentState = this->ProcessorState::LOADING; // TODO
assert(_po == nullptr);
event.data()(data);
_po = std::make_unique<ProductionOrder>(data, event.data().size());
_phase = Phase::LOADING;
#ifdef WITH_TRACE #ifdef WITH_TRACE
Trace::trace() Trace::trace()
@@ -74,61 +88,49 @@ void Processor::dext(const Time &t, const Time &e, const Bag &bag) {
artis::common::FormalismType::PDEVS, artis::common::FormalismType::PDEVS,
artis::common::FunctionType::DELTA_EXT, artis::common::FunctionType::DELTA_EXT,
artis::common::LevelType::USER) artis::common::LevelType::USER)
<< "this->currentPO = " << this->currentPO->to_string(); << "START po = " << _po->to_string();
Trace::trace().flush(); Trace::trace().flush();
#endif #endif
}
}); });
} }
void Processor::start(const Time &t) { void Processor::start(const Time & /* t */) {
// Démarrage et initialisation // TODO
_phase = Phase::INIT;
this->currentState = this->ProcessorState::WAIT; // Prêt à recevoir un Production Order
this->startTime = t;
} }
Time Processor::ta(const Time &t) const { Time Processor::ta(const Time & /* t */) const {
// Temps passé dans l'état actuel // TODO
// Inspiré de Router switch (_phase) {
switch(this->currentState){ case Phase::INIT:
case Phase::READY:
case ProcessorState::WAIT: return 0;
case Phase::WAIT:
return artis::common::DoubleTime::infinity; return artis::common::DoubleTime::infinity;
case Phase::LOADING:
case ProcessorState::LOADING: return _parameters.load_time;
//return ProcessorParameters.load_time; // I can't understand how to find, use, get or do anything with this var... case Phase::PROCESSING:
return t+0; return _parameters.processing_time;
case Phase::UNLOADING:
case ProcessorState::PROCESSING: return _parameters.unload_time;
//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;
} }
return artis::common::DoubleTime::infinity;
} }
Bag Processor::lambda(const Time & /* t */) const { Bag Processor::lambda(const Time & /* t */) const {
Bag bag; Bag bag;
// L'ensemble des sorties de cet objet
// TODO // TODO
if (_phase == Phase::READY) {
bag.push_back(ExternalEvent(outputs::OUT, common::event::Value(_po->_buffer, _po->_size)));
}
return bag; return bag;
} }
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 ? return {};
return {"Hello World ?"};
} }
} // namespace artis::factory } // namespace artis::factory

View File

@@ -59,7 +59,7 @@ public:
}; };
Processor(const std::string &name, const Context<Processor, ProcessorParameters> &context) 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"}); input_port({inputs::IN, "in"});
output_port({outputs::OUT, "out"}); output_port({outputs::OUT, "out"});
} }
@@ -78,21 +78,43 @@ public:
artis::common::event::Value observe(const Time &t, unsigned int index) const override; artis::common::event::Value observe(const Time &t, unsigned int index) const override;
enum ProcessorState{ private:
struct Phase {
enum values {
INIT, INIT,
READY,
WAIT, WAIT,
LOADING, LOADING,
PROCESSING, PROCESSING,
UNLOADING, UNLOADING
READY
}; };
private: static std::string to_string(const values &value) {
// TODO (state) switch (value) {
ProcessorState currentState = ProcessorState::INIT; case INIT:
std::unique_ptr<ProductionOrder> currentPO; return "INIT";
Time startTime = 0; case READY:
Time stepTime = 0; 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 } // namespace artis::factory

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.