Patch correctif TP2
This commit is contained in:
@@ -25,7 +25,6 @@
|
||||
*/
|
||||
|
||||
#include "PoolRouter.hpp"
|
||||
#include "Sink.hpp"
|
||||
|
||||
namespace artis::factory {
|
||||
|
||||
@@ -43,25 +42,13 @@ void PoolRouter::dint(const Time & /* t */) {
|
||||
|
||||
assert(it != _pending_po.cend());
|
||||
|
||||
if ((*it)->is_finish()) {
|
||||
_available_machines[(*it)->last_operation()->get_loc_index()] = true;
|
||||
} else if ((*it)->current_operation().get_type() == CHANGE_POOL_TYPE) {
|
||||
_available_machines[(*it)->previous_operation()->get_loc_index()] = true;
|
||||
} else {
|
||||
//_available_machines[(*it)->current_operation().get_loc_index()] = false;
|
||||
auto idx = (*it)->current_operation().get_loc_index();
|
||||
|
||||
// Modifié pour gérer le Sink
|
||||
if (idx == _available_machines.size()-1) {// Par simplicité, je considère que la dernière machine connectée est le Sink
|
||||
_available_machines[idx] = true;// Et si idx est le dernier index, alors cette "machine" reste disponible
|
||||
} else {
|
||||
_available_machines[idx] = false;
|
||||
}
|
||||
if (not (*it)->is_finish() and (*it)->current_operation().get_type() != CHANGE_POOL_TYPE) {
|
||||
_available_machines[(*it)->current_operation().get_loc_index()]--;
|
||||
}
|
||||
_pending_po.erase(it);
|
||||
if (std::find_if(_pending_po.cbegin(), _pending_po.cend(), [this](const auto &e) {
|
||||
return e->is_finish() or e->current_operation().get_type() == CHANGE_POOL_TYPE or
|
||||
_available_machines[e->current_operation().get_loc_index()];
|
||||
_available_machines[e->current_operation().get_loc_index()] > 0;
|
||||
}) != _pending_po.cend()) {
|
||||
_phase = Phase::SEND;
|
||||
} else {
|
||||
@@ -80,19 +67,24 @@ void PoolRouter::dext(const Time &t, const Time & /* e */, const Bag &bag) {
|
||||
event.data()(data);
|
||||
_pending_po.push_back(std::make_unique<ProductionOrder>(data, event.data().size()));
|
||||
_pending_po.back()->next();
|
||||
} else if (event.port_index() == inputs::FINISH) {
|
||||
unsigned int index;
|
||||
|
||||
event.data()(index);
|
||||
_available_machines[index]++;
|
||||
} else if (event.port_index() >= inputs::IN_M) {
|
||||
uint8_t *data = nullptr;
|
||||
|
||||
event.data()(data);
|
||||
_pending_po.push_back(std::make_unique<ProductionOrder>(data, event.data().size()));
|
||||
_available_machines[event.port_index() - inputs::IN_M] = true;
|
||||
_available_machines[event.port_index() - inputs::IN_M]++;
|
||||
_pending_po.back()->next();
|
||||
}
|
||||
}
|
||||
);
|
||||
if (std::find_if(_pending_po.cbegin(), _pending_po.cend(), [this](const auto &e) {
|
||||
return e->is_finish() or e->current_operation().get_type() == CHANGE_POOL_TYPE or
|
||||
_available_machines[e->current_operation().get_loc_index()];
|
||||
_available_machines[e->current_operation().get_loc_index()] > 0;
|
||||
}) != _pending_po.cend()) {
|
||||
_phase = Phase::SEND;
|
||||
} else {
|
||||
@@ -102,6 +94,9 @@ void PoolRouter::dext(const Time &t, const Time & /* e */, const Bag &bag) {
|
||||
|
||||
void PoolRouter::start(const Time & /* t */) {
|
||||
_phase = Phase::INIT;
|
||||
for (const auto &e: _parameters.capacities) {
|
||||
_available_machines[e.first] = e.second;
|
||||
}
|
||||
}
|
||||
|
||||
Time PoolRouter::ta(const Time & /* t */) const {
|
||||
@@ -155,8 +150,8 @@ PoolRouter::ProductionOrders::const_iterator PoolRouter::next_po() const {
|
||||
return it;
|
||||
} else {
|
||||
return std::find_if(_pending_po.cbegin(), _pending_po.cend(),
|
||||
[this](const auto &e) { return _available_machines[e->current_operation().get_loc_index()]; });
|
||||
[this](const auto &e) { return _available_machines.at(e->current_operation().get_loc_index()) > 0; });
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace artis::factory
|
||||
} // namespace artis::factory
|
||||
Reference in New Issue
Block a user