|
@@ -45,10 +45,52 @@ void GraphManager::add_child(common::Model* child)
|
|
child->set_parent(_coordinator);
|
|
child->set_parent(_coordinator);
|
|
}
|
|
}
|
|
|
|
|
|
-void GraphManager::add_link(common::Model* out_model, const std::string& out_port_name,
|
|
|
|
- common::Model* in_model, const std::string& in_port_name)
|
|
|
|
|
|
+void GraphManager::add_link(common::Model* out_model,
|
|
|
|
+ const std::string& out_port_name,
|
|
|
|
+ common::Model* in_model,
|
|
|
|
+ const std::string& in_port_name)
|
|
{
|
|
{
|
|
_link_list.add(out_model, out_port_name, in_model, in_port_name);
|
|
_link_list.add(out_model, out_port_name, in_model, in_port_name);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void GraphManager::dispatch_events(common::Bag bag, common::Time t)
|
|
|
|
+{
|
|
|
|
+ for (auto & ymsg : bag) {
|
|
|
|
+ common::Links::Result result_model =
|
|
|
|
+ _link_list.find(ymsg.get_model(),
|
|
|
|
+ ymsg.get_port_name());
|
|
|
|
+
|
|
|
|
+ for (common::Links::const_iterator it = result_model.first;
|
|
|
|
+ it != result_model.second; ++it) {
|
|
|
|
+ // event on output port of coupled model
|
|
|
|
+ if (it->second.get_model() == _coordinator) {
|
|
|
|
+ common::Bag ymessages;
|
|
|
|
+
|
|
|
|
+ ymessages.push_back(
|
|
|
|
+ common::ExternalEvent(it->second, ymsg.get_content()));
|
|
|
|
+ dynamic_cast < common::Coordinator* >(
|
|
|
|
+ _coordinator->get_parent())->dispatch_events(ymessages, t);
|
|
|
|
+ } else { // event on input port of internal model
|
|
|
|
+ it->second.get_model()->post_event(
|
|
|
|
+ t, common::ExternalEvent(it->second,
|
|
|
|
+ ymsg.get_content()));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void GraphManager::post_event(common::Time t,
|
|
|
|
+ const common::ExternalEvent& event)
|
|
|
|
+{
|
|
|
|
+ common::Links::Result result =
|
|
|
|
+ _link_list.find(_coordinator, event.get_port_name());
|
|
|
|
+
|
|
|
|
+ for (common::Links::const_iterator it_r = result.first;
|
|
|
|
+ it_r != result.second; ++it_r) {
|
|
|
|
+ it_r->second.get_model()->post_event(
|
|
|
|
+ t, common::ExternalEvent(it_r->second,
|
|
|
|
+ event.get_content()));
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
} } // namespace paradevs pdevs
|
|
} } // namespace paradevs pdevs
|