|
@@ -126,6 +126,12 @@ public:
|
|
|
GENERATOR, LINK_1_2, LINK_3_4, LINK_5_6, LINK_7_8, COUNTER
|
|
|
};
|
|
|
|
|
|
+ typedef artis::pdevs::multithreading::Coordinator<
|
|
|
+ artis::common::DoubleTime,
|
|
|
+ SimpleGraphManager,
|
|
|
+ GeneratorParameters,
|
|
|
+ artis::common::NoParameters> coordinator_type;
|
|
|
+
|
|
|
SimpleGraphManager(
|
|
|
artis::common::Coordinator<artis::common::DoubleTime> *coordinator,
|
|
|
const GeneratorParameters ¶meters,
|
|
@@ -198,83 +204,31 @@ public:
|
|
|
|
|
|
void init()
|
|
|
{
|
|
|
- _link_1_2.set_sender(
|
|
|
- (dynamic_cast< artis::pdevs::multithreading::Coordinator<
|
|
|
- artis::common::DoubleTime,
|
|
|
- SimpleGraphManager,
|
|
|
- GeneratorParameters,
|
|
|
- artis::common::NoParameters> *>(this->coordinator()))->get_sender());
|
|
|
- _link_3_4.set_sender(
|
|
|
- (dynamic_cast< artis::pdevs::multithreading::Coordinator<
|
|
|
- artis::common::DoubleTime,
|
|
|
- SimpleGraphManager,
|
|
|
- GeneratorParameters,
|
|
|
- artis::common::NoParameters> *>(this->coordinator()))->get_sender());
|
|
|
- _link_5_6.set_sender(
|
|
|
- (dynamic_cast< artis::pdevs::multithreading::Coordinator<
|
|
|
- artis::common::DoubleTime,
|
|
|
- SimpleGraphManager,
|
|
|
- GeneratorParameters,
|
|
|
- artis::common::NoParameters> *>(this->coordinator()))->get_sender());
|
|
|
- _link_7_8.set_sender(
|
|
|
- (dynamic_cast< artis::pdevs::multithreading::Coordinator<
|
|
|
- artis::common::DoubleTime,
|
|
|
- SimpleGraphManager,
|
|
|
- GeneratorParameters,
|
|
|
- artis::common::NoParameters> *>(this->coordinator()))->get_sender());
|
|
|
- }
|
|
|
+ dynamic_cast< coordinator_type *>(this->coordinator())
|
|
|
+ ->attach_child(&_link_1_2, _link_1_2.get_queue());
|
|
|
+ dynamic_cast< coordinator_type *>(this->coordinator())
|
|
|
+ ->attach_child(&_link_3_4, _link_3_4.get_queue());
|
|
|
+ dynamic_cast< coordinator_type *>(this->coordinator())
|
|
|
+ ->attach_child(&_link_5_6, _link_5_6.get_queue());
|
|
|
+ dynamic_cast< coordinator_type *>(this->coordinator())
|
|
|
+ ->attach_child(&_link_7_8, _link_7_8.get_queue());
|
|
|
|
|
|
- void start(common::DoubleTime::type t)
|
|
|
- {
|
|
|
- _link_1_2.get_sender().send(
|
|
|
- artis::pdevs::multithreading::start_message<
|
|
|
- artis::common::DoubleTime>(t));
|
|
|
- _link_3_4.get_sender().send(
|
|
|
- artis::pdevs::multithreading::start_message<
|
|
|
- artis::common::DoubleTime>(t));
|
|
|
- _link_5_6.get_sender().send(
|
|
|
- artis::pdevs::multithreading::start_message<
|
|
|
- artis::common::DoubleTime>(t));
|
|
|
- _link_7_8.get_sender().send(
|
|
|
- artis::pdevs::multithreading::start_message<
|
|
|
- artis::common::DoubleTime>(t));
|
|
|
- }
|
|
|
-
|
|
|
- void transition(const common::Models<common::DoubleTime> &receivers,
|
|
|
- artis::common::DoubleTime::type t)
|
|
|
- {
|
|
|
- std::for_each(receivers.begin(), receivers.end(),
|
|
|
- [this, t](const common::Model<common::DoubleTime> *model) {
|
|
|
- if (not model->is_atomic()) {
|
|
|
- if (model == &_link_1_2) {
|
|
|
- _link_1_2.get_sender().send(
|
|
|
- artis::pdevs::multithreading::transition_message<
|
|
|
- artis::common::DoubleTime>(t));
|
|
|
- } else if (model == &_link_3_4) {
|
|
|
- _link_3_4.get_sender().send(
|
|
|
- artis::pdevs::multithreading::transition_message<
|
|
|
- artis::common::DoubleTime>(t));
|
|
|
- } else if (model == &_link_5_6) {
|
|
|
- _link_5_6.get_sender().send(
|
|
|
- artis::pdevs::multithreading::transition_message<
|
|
|
- artis::common::DoubleTime>(t));
|
|
|
- } else if (model == &_link_7_8) {
|
|
|
- _link_7_8.get_sender().send(
|
|
|
- artis::pdevs::multithreading::transition_message<
|
|
|
- artis::common::DoubleTime>(t));
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
+ _link_1_2.attach_parent(dynamic_cast< coordinator_type *>(this->coordinator())->get_queue());
|
|
|
+ _link_3_4.attach_parent(dynamic_cast< coordinator_type *>(this->coordinator())->get_queue());
|
|
|
+ _link_5_6.attach_parent(dynamic_cast< coordinator_type *>(this->coordinator())->get_queue());
|
|
|
+ _link_7_8.attach_parent(dynamic_cast< coordinator_type *>(this->coordinator())->get_queue());
|
|
|
}
|
|
|
|
|
|
private:
|
|
|
artis::pdevs::Simulator<artis::common::DoubleTime, Generator, GeneratorParameters> _generator;
|
|
|
-/*
|
|
|
+
|
|
|
+ /*
|
|
|
artis::pdevs::Coordinator<artis::common::DoubleTime, LinksGraphManager, GeneratorParameters, artis::common::NoParameters> _link_1_2;
|
|
|
artis::pdevs::Coordinator<artis::common::DoubleTime, LinksGraphManager, GeneratorParameters, artis::common::NoParameters> _link_3_4;
|
|
|
artis::pdevs::Coordinator<artis::common::DoubleTime, LinksGraphManager, GeneratorParameters, artis::common::NoParameters> _link_5_6;
|
|
|
artis::pdevs::Coordinator<artis::common::DoubleTime, LinksGraphManager, GeneratorParameters, artis::common::NoParameters> _link_7_8;
|
|
|
*/
|
|
|
+
|
|
|
artis::pdevs::multithreading::Coordinator<artis::common::DoubleTime,
|
|
|
LinksGraphManager,
|
|
|
GeneratorParameters,
|