48 Proc::Proc(
const std::string& name):
Bloc(name),_edition(false),_compoinstctr(0)
74 std::map<std::string, TypeCode *>::iterator pt;
76 ((*pt).second)->decrRef();
81 std::map<std::string, Logger*>::const_iterator lt;
89 os <<
"node [ style=\"filled\" ];\n" ;
90 os <<
"compound=true;";
91 os <<
"states [label=< <TABLE> <TR> <TD BGCOLOR=\"pink\" > Ready</TD> <TD BGCOLOR=\"magenta\" > Toload</TD> </TR> <TR> <TD BGCOLOR=\"magenta\" > Loaded</TD> <TD BGCOLOR=\"purple\" > Toactivate</TD> </TR> <TR> <TD BGCOLOR=\"blue\" > Activated</TD> <TD BGCOLOR=\"green\" > Done</TD> </TR> <TR> <TD BGCOLOR=\"red\" > Error</TD> <TD BGCOLOR=\"orange\" > Failed</TD> </TR> <TR> <TD BGCOLOR=\"grey\" > Disabled</TD> <TD BGCOLOR=\"white\" > Pause</TD> </TR> </TABLE>> \n shape = plaintext \n style = invis \n ];\n";
108 else if(kind==
"string")
112 else if(kind==
"bool")
133 std::list<TypeCodeObjref *> ltc)
181 std::stringstream msg;
182 msg <<
"Type " << name <<
" does not exist" ;
183 msg <<
" (" <<__FILE__ <<
":" << __LINE__ <<
")";
214 cerr <<
"Unknown node id " << numId << endl;
224 std::string progress =
"0";
227 cerr <<
"Unknown node id " << numId << endl;
230 progress = node->getProgress();
239 int progressPercent = 0;
240 for(list<ProgressWeight>::const_iterator iter=weightList.begin();iter!=weightList.end();iter++)
242 weightDone += (*iter).weightDone;
243 weightTotal += (*iter).weightTotal;
246 progressPercent = int(
float(weightDone) /
float(weightTotal) * 100);
247 return progressPercent;
254 cerr <<
"Unknown node id " << numId << endl;
255 return "<state>unknown</state>";
261 msg <<
"<id>" << numId <<
"</id>";
267 DEBTRACE(
"Proc::getInPortValue " << nodeNumId <<
" " << portName);
271 msg <<
"<value><error>unknown node id: " << nodeNumId <<
"</error></value>";
282 DEBTRACE(
"Proc::getInPortValue " <<
ex.what());
283 msg <<
"<value><error>" <<
ex.what() <<
"</error></value>";
290 DEBTRACE(
"Proc::setInPortValue " << nodeName <<
" " << portName <<
" " << value);
301 double val = atof(value.c_str());
307 int val = atoi(value.c_str());
312 inputPort->
edInit(value.c_str());
316 if((!value.compare(
"False")) || (!value.compare(
"false")))
318 else if ((!value.compare(
"True")) || (!value.compare(
"true")))
322 int val = atoi(value.c_str());
334 DEBTRACE(
"Proc::setInPortValue " <<
ex.what());
336 msg <<
"<value><error>" <<
ex.what() <<
"</error></value>";
343 DEBTRACE(
"Proc::getOutPortValue " << nodeNumId <<
" " << portName);
347 msg <<
"<value><error>unknown node id: " << nodeNumId <<
"</error></value>";
358 DEBTRACE(
"Proc::getOutPortValue " <<
ex.what());
359 msg <<
"<value><error>" <<
ex.what() <<
"</error></value>";
366 DEBTRACE(
"Proc::getNodeErrorDetails " << nodeNumId);
370 msg <<
"Unknown node id " << nodeNumId;
379 DEBTRACE(
"Proc::getNodeErrorReport " << nodeNumId);
383 msg <<
"Unknown node id " << nodeNumId;
392 DEBTRACE(
"Proc::getNodeContainerLog " << nodeNumId);
396 msg <<
"Unknown node id " << nodeNumId;
406 int len = nodes.size();
408 for( list<YACS::ENGINE::Node *>::const_iterator iter = nodes.begin();
409 iter != nodes.end(); iter++)
411 numids.push_back((*iter)->getNumId());
420 int len = nodes.size();
422 for( list<YACS::ENGINE::Node *>::const_iterator iter = nodes.begin();
423 iter != nodes.end(); iter++)
427 ids.push_back(
"_root_");
434 LoggerMap::const_iterator it =
_loggers.find(name);
442 logger =
new Logger(name);
450 DEBTRACE(
"Proc::setEdition: " << edition);
494 std::map<std::string, Container*>::const_iterator it;
496 ((*it).second)->decrRef();
540 std::string instname;
546 std::ostringstream buffer;
548 instname=componame+
"_"+buffer.str();
624 std::map<std::string, Container*> myContainerMap;
625 std::map<std::string, ComponentInstance*> myComponentInstanceMap;
628 for(vector<Container *>::const_iterator iterCt=conts.begin();iterCt!=conts.end();iterCt++)
633 if(myContainerMap.find(tmp->
getName())!=myContainerMap.end())
635 std::ostringstream oss; oss <<
"Proc::updateContainersAndComponents : more than one container instance with name \"" << tmp->
getName() <<
"\" !";
638 myContainerMap[tmp->
getName()]=tmp;
642 for(vector<ComponentInstance *>::iterator iterCp=comps.begin();iterCp!=comps.end();iterCp++)
647 if(myComponentInstanceMap.find(tmp2->
getCompoName())!=myComponentInstanceMap.end())
649 std::ostringstream oss; oss <<
"Proc::updateContainersAndComponents : more than one component instance with name \"" << tmp2->
getCompoName() <<
"\" !";
YACS::ENGINE::Runtime * theRuntime
Composed node to group elementary and composed nodes.
virtual void writeDot(std::ostream &os) const
Dump to the input stream a dot representation of the node.
Base class for all component instances.
void setName(const std::string &name)
virtual void setAnonymous(bool anon)
const std::string & getCompoName() const
const std::string & getInstanceName() const
Base class for all composed nodes.
std::string getChildName(const Node *node) const
std::list< ProgressWeight > getProgressWeight() const
Get the progress weight for all elementary nodes.
DeploymentTree getDeploymentTree() const
Essentially for test. Use checkDeploymentTree instead to be sure that returned DeploymentTree is cons...
virtual std::list< Node * > getAllRecursiveConstituents()
Idem getAllRecursiveNodes, but this node is NOT included.
virtual void edUpdateState()
update the status of the node
void setName(std::string name)
WARNING ! name is used in edition to identify different containers, it is not the runtime name of the...
virtual std::string getName() const
virtual std::string getAsString()
returns port value as a string that can be used in a GUI for example
TypeCode * edGetType() const
std::vector< ComponentInstance * > getComponentsLinkedToContainer(Container *cont) const
std::vector< Container * > getAllContainers() const
Class for logging error messages.
Base class for all nodes.
static std::map< int, Node * > idMap
std::string getQualifiedName() const
same as Node::getName() in most cases, but differs for children of switch
virtual std::string getContainerLog()
returns a string that contains the name of the container log file if it exists
static void checkValidityOfNodeName(const std::string &name)
virtual std::string getErrorReport()
returns a string that contains an error report if the node is in error
virtual std::string getErrorDetails() const
virtual InputPort * getInputPort(const std::string &name) const
virtual OutputPort * getOutputPort(const std::string &name) const =0
virtual YACS::StatesForNode getEffectiveState() const
Return the node state in the context of its father.
int getNumId()
return node instance identifiant, unique for each node instance
Base class for all schema objects.
std::string getNodeErrorReport(int nodeNumId)
virtual void saveSchema(const std::string &xmlSchemaFile)
Save Proc in XML schema file.
std::string getNodeErrorDetails(int nodeNumId)
std::string getInPortValue(int nodeNumId, std::string portName)
std::string setInPortValue(std::string nodeName, std::string portName, std::string value)
std::string getNodeProgress(int numId)
virtual TypeCode * getTypeCode(const std::string &name)
virtual void setTypeCode(const std::string &name, TypeCode *t)
virtual TypeCode * createSequenceTc(const std::string &id, const std::string &name, TypeCode *content)
Create a sequence TypeCode.
virtual void setEdition(bool edition)
virtual void modified()
Sets Proc in modified state and update state if in edition mode.
virtual Container * createContainer(const std::string &name, const std::string &kind="")
Create a new Container and store it in containerMap.
virtual Logger * getLogger(const std::string &name)
std::map< std::string, Node * > nodeMap
std::string getNodeContainerLog(int nodeNumId)
std::map< std::string, TypeCode * > typeMap
virtual void accept(Visitor *visitor)
std::list< int > getNumIds()
virtual void removeContainer(Container *cont)
Remove a container from the containerMap.
virtual TypeCode * createStructTc(const std::string &id, const std::string &name)
std::string getOutPortValue(int nodeNumId, std::string portName)
std::list< std::string > getIds()
virtual void removeComponentInstance(ComponentInstance *inst)
Remove a componentInstance from the componentInstanceMap.
virtual void writeDot(std::ostream &os) const
Dump to the input stream a dot representation of the node.
virtual TypeCode * createType(const std::string &name, const std::string &kind)
virtual TypeCode * createInterfaceTc(const std::string &id, const std::string &name, std::list< TypeCodeObjref * > ltc)
Create an object reference TypeCode.
int getGlobalProgressPercent()
virtual void updateContainersAndComponents()
std::string getXMLState(int numId)
std::map< std::string, Container * > containerMap
void setName(const std::string &name)
virtual void addComponentInstance(ComponentInstance *inst, const std::string &name="", bool resetCtr=false)
Add a ComponentInstance into componentInstanceMap.
virtual Proc * getProc()
Return the proc (this)
YACS::StatesForNode getNodeState(int numId)
std::map< std::string, ComponentInstance * > componentInstanceMap
virtual ComponentInstance * createComponentInstance(const std::string &componame, const std::string &name="", const std::string &kind="")
Create a new ComponentInstance and add it into componentInstanceMap.
virtual void saveState(const std::string &xmlStateFile)
Save Proc state in XML state file.
unsigned int getRefCnt() const
static YACS::ENGINE::TypeCode * _tc_double
static YACS::ENGINE::TypeCode * _tc_bool
virtual TypeCode * getTypeCode(const std::string &name)
Get a typecode by its name from runtime catalogs.
static YACS::ENGINE::TypeCode * _tc_file
virtual ComponentInstance * createComponentInstance(const std::string &name, const std::string &kind="")
static YACS::ENGINE::TypeCode * _tc_int
static YACS::ENGINE::TypeCode * _tc_string
Base class for all type objects.
static TypeCode * interfaceTc(const char *id, const char *name)
static factory of object reference type given an id and a name
static TypeCode * sequenceTc(const char *id, const char *name, TypeCode *content)
static factory of sequence type given an id, a name and a content type
static TypeCode * structTc(const char *id, const char *name)
static factory of struct type given an id and a name
Base class for all visitors that save a schema.
void openFileSchema(std::string xmlDump)
void openFileDump(const std::string &xmlDump)
virtual void visitProc(Proc *node)=0
ostream & operator<<(ostream &os, const OutputCorbaPort &p)
YACSLIBENGINE_EXPORT Runtime * getRuntime()