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

@@ -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

View File

@@ -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.