Template:CMI Example CMI initialize CXX: Difference between revisions
From CSDMS
Automated import of articles |
Automated import of articles *** existing text overwritten *** |
||
Line 15: | Line 15: | ||
::babel_cast<edu::csdms::ports::CMIPort>(*this); | ::babel_cast<edu::csdms::ports::CMIPort>(*this); | ||
this->ports = ::edu::csdms::tools:: | this->ports = ::edu::csdms::tools::IRFPortQueue::_create (); | ||
this->ports. | this->ports.initialize_cmi (this->d_services, port); | ||
this->ports.add_ports (CMI_PORT_NAMES); | this->ports.add_ports (CMI_PORT_NAMES); | ||
this->ports. | this->ports.connect_cmi_ports (); | ||
} | } | ||
Line 59: | Line 59: | ||
this->print_q = ::edu::csdms::tools::PrintQueue::_create (); | this->print_q = ::edu::csdms::tools::PrintQueue::_create (); | ||
this->print_q. | this->print_q.initialize_cmi (this->userinput, "/"CMI_COMPONENT_NAME, | ||
port); | port); | ||
this->print_q.add_files_from_list (CMI_OUTPUT_FILE_NS); | this->print_q.add_files_from_list (CMI_OUTPUT_FILE_NS); |
Revision as of 17:04, 1 February 2012
if (this->status >= CMI_STATUS_INITIALIZING)
return TRUE;
else
this->status = CMI_STATUS_INITIALIZING;
::std::cerr << CMI_COMPONENT_NAME ": Status is "
<< this->CMI_get_status () << ::std::endl;
fprintf (stderr, "%s: Create PortQueue.
", CMI_COMPONENT_NAME);
{ // Create port queue.
::edu::csdms::ports::CMIPort port =
::babel_cast<edu::csdms::ports::CMIPort>(*this);
this->ports = ::edu::csdms::tools::IRFPortQueue::_create ();
this->ports.initialize_cmi (this->d_services, port);
this->ports.add_ports (CMI_PORT_NAMES);
this->ports.connect_cmi_ports ();
}
fprintf (stderr, "%s: Read config dialog.
", CMI_COMPONENT_NAME);
{ // Read parameters from the config dialog.
::edu::csdms::tools::TemplateFiles tmpls;
const char *src_files = CMI_TEMPLATE_SOURCE_FILES;
const char *dest_files = CMI_TEMPLATE_DEST_FILES;
string val;
tmpls = ::edu::csdms::tools::TemplateFiles::_create ();
tmpls.add_files (CMI_TEMPLATE_SOURCE_FILES, CMI_TEMPLATE_DEST_FILES);
tmpls.substitute (this->userinput, "/"CMI_COMPONENT_NAME"/Input/Var/",
".");
val = this->userinput.getString (
"/"CMI_COMPONENT_NAME"/Input/Var/SimulationName",
CMI_COMPONENT_NAME);
this->userinput.putString (
"/"CMI_COMPONENT_NAME"/SimulationName",
val);
}
fprintf (stderr, "%s: Call BMI initialize.
", CMI_COMPONENT_NAME);
/* The contents of this file will be something like,
* Child Child.in
* */
this->state.initialize ("Child_command_line.txt");
fprintf (stderr, "%s: Create PrintQueue.
", CMI_COMPONENT_NAME);
{ // Set up the print queue.
::edu::csdms::ports::CMIPort port =
::babel_cast<edu::csdms::ports::CMIPort>(*this);
this->print_q = ::edu::csdms::tools::PrintQueue::_create ();
this->print_q.initialize_cmi (this->userinput, "/"CMI_COMPONENT_NAME,
port);
this->print_q.add_files_from_list (CMI_OUTPUT_FILE_NS);
}
#if CMI_TURN_OFF_PORTS
fprintf (stderr, "%s: Forgetting ports for now.
", CMI_COMPONENT_NAME);
#else
fprintf (stderr, "%s: Initialize ports.
", CMI_COMPONENT_NAME);
this->ports.initialize_ports (0);
#endif
#if CMI_TURN_OFF_MAPPING
fprintf (stderr, "%s: Mapping is turned off.
", CMI_COMPONENT_NAME);
#else
fprintf (stderr, "%s: Initialize mappers.
", CMI_COMPONENT_NAME);
this->ports.add_mappers (CMI_MAPPERS);
fprintf (stderr, "%s: Map initial values.
", CMI_COMPONENT_NAME);
this->ports.run_mappers ();
#endif
this->status = CMI_STATUS_INITIALIZED;
::std::cerr << CMI_COMPONENT_NAME ": Status is "
<< this->CMI_get_status () << ::std::endl;
return TRUE;