YARP
Yet Another Robot Platform
manager.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
9 #include <cstring>
10 #include <yarp/manager/manager.h>
20 #include <yarp/os/LogStream.h>
21 
23 
24 
25 #define RUN_TIMEOUT 10 // Run timeout in seconds
26 #define STOP_TIMEOUT 30 // Stop timeout in seconds
27 #define KILL_TIMEOUT 10 // kill timeout in seconds
28 
29 #define BROKER_LOCAL "local"
30 #define BROKER_YARPRUN "yarprun"
31 #define BROKER_YARPDEV "yarpdev"
32 
33 
34 using namespace yarp::manager;
35 using namespace std;
36 
37 
42 Manager::Manager(bool withWatchDog) : MEvent()
43 {
44  logger = ErrorLogger::Instance();
45  bWithWatchDog = withWatchDog;
46  bAutoDependancy = false;
47  bAutoConnect = false;
48  bRestricted = false;
49  strDefBroker = BROKER_YARPRUN;
50  knowledge.createFrom(nullptr, nullptr, nullptr);
51  connector.init();
52 }
53 
54 Manager::Manager(const char* szModPath, const char* szAppPath,
55  const char* szResPath, bool withWatchDog)
56 {
57  logger = ErrorLogger::Instance();
58  bWithWatchDog = withWatchDog;
59  bAutoDependancy = false;
60  bAutoConnect = false;
61  bRestricted = false;
62  strDefBroker = BROKER_YARPRUN;
63 
64  XmlModLoader modload(szModPath, nullptr);
65  XmlModLoader* pModLoad = &modload;
66  if(!modload.init())
67  pModLoad = nullptr;
68 
69  XmlAppLoader appload(szAppPath, nullptr);
70  XmlAppLoader* pAppLoad = &appload;
71  if(!appload.init())
72  pAppLoad = nullptr;
73 
74  XmlResLoader resload(szResPath, nullptr);
75  XmlResLoader* pResLoad = &resload;
76  if(!resload.init())
77  pResLoad = nullptr;
78 
79  knowledge.createFrom(pModLoad, pAppLoad, pResLoad);
80  connector.init();
81 }
82 
83 
85 {
86  // untopic persistent connections
87  rmconnect();
88  clearExecutables();
89 }
90 
91 bool Manager::addApplication(const char* szFileName, char** szAppName_, bool modifyName)
92 {
93  if(find(listOfXml.begin(), listOfXml.end(),szFileName) == listOfXml.end())
94  listOfXml.emplace_back(szFileName);
95  else
96  return true;//it means that the app exist already so it is safe to return true
97  XmlAppLoader appload(szFileName);
98  if(!appload.init())
99  return false;
100  Application* application = appload.getNextApplication();
101  if(!application)
102  return false;
103 
104  return knowledge.addApplication(application, szAppName_, modifyName);
105 }
106 
107 
108 bool Manager::addApplications(const char* szPath)
109 {
110  XmlAppLoader appload(szPath, nullptr);
111  if(!appload.init())
112  return false;
113  Application* application;
114  while((application = appload.getNextApplication()))
115  {
116  const char* currentFile = application->getXmlFile();
117  knowledge.addApplication(application);
118  listOfXml.emplace_back(currentFile);
119  }
120  return true;
121 }
122 
123 
124 bool Manager::addModule(const char* szFileName)
125 {
126  XmlModLoader modload(szFileName);
127  if(!modload.init())
128  return false;
129  Module* module = modload.getNextModule();
130  if(!module)
131  return false;
132  return knowledge.addModule(module);
133 }
134 
135 
136 bool Manager::addModules(const char* szPath)
137 {
138  XmlModLoader modload(szPath, nullptr);
139  if(!modload.init())
140  return false;
141  Module* module;
142  while((module = modload.getNextModule()))
143  knowledge.addModule(module);
144  return true;
145 }
146 
147 
148 bool Manager::addResource(const char* szFileName)
149 {
150  XmlResLoader resload(szFileName);
151  if(!resload.init())
152  return false;
153  GenericResource* resource;
154  bool bloaded = false;
155  while((resource = resload.getNextResource()))
156  bloaded |= knowledge.addResource(resource);
157  return bloaded;
158 }
159 
160 
161 bool Manager::addResources(const char* szPath)
162 {
163  XmlResLoader resload(szPath, nullptr);
164  if(!resload.init())
165  return false;
166  GenericResource* resource;
167  while((resource = resload.getNextResource()))
168  knowledge.addResource(resource);
169  return true;
170 }
171 
172 
173 bool Manager::removeApplication(const char *szFileName, const char* szAppName)
174 {
175  //Note: use it with care. it is better we first check that no application
176  //is loaded.
177  if(!runnables.empty())
178  {
179  logger->addError("Application cannot be removed if there is a loaded application");
180  return false;
181  }
182  listOfXml.erase(std::remove(listOfXml.begin(), listOfXml.end(), szFileName), listOfXml.end());
183  Application* app = knowledge.getApplication(szAppName);
184  if(!app)
185  return false;
186  return knowledge.removeApplication(app);
187 }
188 
189 
190 bool Manager::removeModule(const char* szModName)
191 {
192  //Note: use it with care. it is better we first check that no application
193  //is loaded.
194  if(!runnables.empty())
195  {
196  logger->addError("Module cannot be removed if there is a loaded application");
197  return false;
198  }
199 
200  Module* mod = knowledge.getModule(szModName);
201  if(!mod)
202  return false;
203 
204  return knowledge.removeModule(mod);
205 }
206 
207 bool Manager::removeResource(const char* szResName)
208 {
209  //Note: use it with care. it is better we first check that no application
210  //is loaded.
211  if(!runnables.empty())
212  {
213  logger->addError("Resource cannot be removed if there is a loaded application");
214  return false;
215  }
216 
217  GenericResource* res = knowledge.getResource(szResName);
218  if(!res)
219  return false;
220 
221  return knowledge.removeResource(res);
222 }
223 
224 
225 
226 bool Manager::loadApplication(const char* szAppName)
227 {
228  __CHECK_NULLPTR(szAppName);
229 
230  if(!allStopped())
231  {
232  logger->addError("Please stop current running application first.");
233  return false;
234  }
235 
236  strAppName = szAppName;
237 
238  // set all resources as unavailable
239  ResourcePContainer allresources = knowledge.getResources();
240  for(auto& allresource : allresources)
241  {
242  auto* comp = dynamic_cast<Computer*>(allresource);
243  if(comp)
244  comp->setAvailability(false);
245  }
246 
247  return prepare(true);
248 }
249 
250 
251 bool Manager::saveApplication(const char* szAppName, const char* fileName)
252 {
253  Application* pApp = knowledge.getApplication();
254  __CHECK_NULLPTR(pApp);
255 
256  XmlAppSaver appsaver(fileName);
257  return knowledge.saveApplication(&appsaver, pApp);
258 }
259 
260 
262 {
263  updateResources();
264  bool ret = prepare(false);
265  return ret;
266 }
267 
269 {
270  if (id < runnables.size())
271  {
272  return runnables[id];
273  }
274  else
275  {
276  return nullptr;
277  }
278 }
279 
280 bool Manager::switchBroker(size_t id)
281 {
282  Executable* exe = getExecutableById(id);
283  if (removeBroker(exe))
284  {
285  modules[id]->setHost(exe->getHost());
286  Broker* broker = createBroker(modules[id]);
287  if ( broker == nullptr)
288  {
289  return false;
290  }
291  broker->setDisplay(modules[id]->getDisplay());
292  exe->setAndInitializeBroker(broker);
293  }
294  else
295  {
296  return false;
297  }
298  return true;
299 }
300 
301 
302 bool Manager::prepare(bool silent)
303 {
304  knowledge.reasolveDependency(strAppName.c_str(), bAutoDependancy, silent);
305 
306  clearExecutables();
307  connections.clear();
308  modules.clear();
309  resources.clear();
310  connections = knowledge.getSelConnection();
311  modules = knowledge.getSelModules();
312  resources = knowledge.getSelResources();
313 
322  ModulePIterator itr;
323  int id = 0;
324  for(itr=modules.begin(); itr!=modules.end(); itr++)
325  {
326  Broker* broker = createBroker(*itr);
327  broker->setDisplay((*itr)->getDisplay());
328  auto* exe = new Executable(broker, (MEvent*)this, *itr, bWithWatchDog);
329  exe->setID(id++);
330  exe->setCommand((*itr)->getName());
331  exe->setParam((*itr)->getParam());
332  exe->setHost((*itr)->getHost());
333  exe->setStdio((*itr)->getStdio());
334  exe->setWorkDir((*itr)->getWorkDir());
335  exe->setPostExecWait((*itr)->getPostExecWait());
336  exe->setPostStopWait((*itr)->getPostStopWait());
337  exe->setOriginalPostExecWait((*itr)->getPostExecWait());
338  exe->setOriginalPostStopWait((*itr)->getPostStopWait());
339  string env;
340  if ((*itr)->getPrefix() && strlen((*itr)->getPrefix()))
341  env = string("YARP_PORT_PREFIX=") + string((*itr)->getPrefix());
342  if((*itr)->getEnvironment() && strlen((*itr)->getEnvironment()))
343  env += (env.length()) ? (string(";") + (*itr)->getEnvironment()) : (*itr)->getEnvironment();
344  exe->setEnv(env.c_str());
345 
351  //CnnIterator cnn;
352  //for(cnn=connections.begin(); cnn!=connections.end(); cnn++)
353  // if((*cnn).owner() == (*itr))
354  // exe->addConnection(*cnn);
355 
359  for(auto& resource : resources)
360  {
361  auto* res = dynamic_cast<ResYarpPort*>(resource);
362  if(res && (res->owner() == (*itr)))
363  exe->addResource(*res);
364  }
365 
366  runnables.push_back(exe);
367  }
368 
369  return true;
370 }
371 
372 Broker* Manager::createBroker(Module* module)
373 {
374  if(strlen(module->getBroker()) == 0)
375  {
376  if(compareString(module->getHost(), "localhost"))
377  return (new LocalBroker());
378  else
379  return (new YarpBroker());
380  }
381  else if(compareString(module->getBroker(), BROKER_YARPDEV))
382  {
383  if(compareString(module->getHost(), "localhost"))
384  return (new YarpdevLocalBroker());
385  else
386  return (new YarpdevYarprunBroker());
387  }
388  else if(compareString(module->getHost(), "localhost"))
389  return (new ScriptLocalBroker(module->getBroker()));
390 
391  return (new ScriptYarprunBroker(module->getBroker()));
392 }
393 
394 bool Manager::removeBroker(Executable* exe)
395 {
396  if (exe == nullptr)
397  {
398  return false;
399  }
400  else if(exe->state() == RUNNING)
401  {
402  exe->stop();
403  exe->stopWatchDog();
404  }
405 
406  exe->removeBroker(); //TODO possible race condition in case watchdog enabled.
407  return true;
408 }
409 
410 bool Manager::updateExecutable(unsigned int id, const char* szparam,
411  const char* szhost, const char* szstdio,
412  const char* szworkdir, const char* szenv )
413 {
414  if(runnables.empty())
415  {
416  logger->addError("Application is not loaded.");
417  return false;
418  }
419 
420  if(id>=runnables.size())
421  {
422  logger->addError("Module id is out of range.");
423  return false;
424  }
425 
426  Executable* exe = runnables[id];
427  exe->setParam(szparam);
428  exe->setHost(szhost);
429  exe->setStdio(szstdio);
430  exe->setWorkDir(szworkdir);
431  exe->setEnv(szenv);
432  return true;
433 }
434 
435 
436 bool Manager::updateConnection(unsigned int id, const char* from,
437  const char* to, const char* carrier)
438 {
439  if(id>=connections.size())
440  {
441  logger->addError("Connection id is out of range.");
442  return false;
443  }
444 
445  /*
446  if(connections[id].owner())
447  {
448  OSTRINGSTREAM msg;
449  msg<<"Connection ["<<connections[id].from()<<" -> ";
450  msg<<connections[id].to()<<"] cannot be updated.";
451  logger->addWarning(msg);
452  return false;
453  }
454  */
455 
456  connections[id].setFrom(from);
457  connections[id].setTo(to);
458  connections[id].setCarrier(carrier);
459 
460  return true;
461 }
462 
463 Node* Manager::getNode(string appName)
464 {
465  Node* node = knowledge.getNode(appName);
466  return node;
467 }
468 
469 bool Manager::exist(unsigned int id)
470 {
471  if(id>=resources.size())
472  {
473  logger->addError("Resource id is out of range.");
474  return false;
475  }
476 
477  GenericResource* res = resources[id];
478  if(compareString(res->getName(), "localhost"))
479  return true;
480 
481  if(dynamic_cast<Computer*>(res) || dynamic_cast<ResYarpPort*>(res))
482  {
483  if(res->getName())
484  {
485  //YarpBroker broker;
486  //broker.init();
487  string strPort = res->getName();
488  if(strPort[0] != '/')
489  strPort = string("/") + strPort;
490  if(dynamic_cast<ResYarpPort*>(res))
491  {
492  res->setAvailability(connector.exists(strPort.c_str()));
493  }
494  else //if it is a computer I have to be sure that the port has been opened through yarp runner
495  {
496  yarp::os::Bottle cmd, reply;
497  cmd.addString("get");
498  cmd.addString(strPort);
499  cmd.addString("yarprun");
501  if(!ret)
502  {
503  yError()<<"Manager::Cannot contact the NameClient";
504  return false;
505  }
506  if(reply.size()==6)
507  {
508  if(reply.get(5).asBool())
509  {
510  res->setAvailability(true);
511  }
512  else
513  {
514  res->setAvailability(false);
515  }
516 
517  }
518  else
519  {
520  res->setAvailability(false);
521  }
522 
523  }
524 
525  }
526  }
527  return res->getAvailability();
528 }
529 
530 
532 {
533  YarpBroker broker;
534  broker.init();
535 
536  // finding all available yarp ports
537  vector<string> ports;
538  broker.getAllPorts(ports);
539 
540  ResourcePContainer allresources = knowledge.getResources();
541  for(auto& allresource : allresources)
542  {
543  auto* comp = dynamic_cast<Computer*>(allresource);
544  if(comp && updateResource(comp))
545  {
546  //set all as unavailable
547  for(int i=0; i<comp->peripheralCount(); i++)
548  {
549  auto* res = dynamic_cast<ResYarpPort*>(&comp->getPeripheralAt(i));
550  if(res)
551  res->setAvailability(false);
552  }
553 
554  // adding all available yarp ports as peripherals
555  for(auto& port : ports)
556  {
557  ResYarpPort resport;
558  resport.setName(port.c_str());
559  resport.setPort(port.c_str());
560 
561  bool bfound = false;
562  for(int i=0; i<comp->peripheralCount(); i++)
563  {
564  auto* res = dynamic_cast<ResYarpPort*>(&comp->getPeripheralAt(i));
565  if(res && (string(res->getName()) == string(resport.getName())))
566  {
567  res->setAvailability(true);
568  bfound = true;
569  break;
570  }
571  }
572  if(!bfound)
573  comp->addPeripheral(resport);
574  }
575  }
576  } // end of for
577 
578  return true;
579 }
580 
581 
582 bool Manager::updateResource(const char* szName)
583 {
584  GenericResource* res = knowledge.getResource(szName);
585  if(!res)
586  return false;
587  return updateResource(res);
588 }
589 
591 {
592  YarpBroker broker;
593  broker.init();
594 
595  auto* comp = dynamic_cast<Computer*>(resource);
596  if(!comp || !strlen(comp->getName()))
597  return false;
598 
599  if(compareString(comp->getName(), "localhost"))
600  return false;
601 
603  string strServer = comp->getName();
604  if(strServer[0] != '/')
605  strServer = string("/") + strServer;
606  if(!broker.getSystemInfo(strServer.c_str(), info))
607  {
608  logger->addError(broker.error());
609  comp->setAvailability(false);
610  }
611  else
612  {
613  comp->setAvailability(true);
614 
615  comp->getMemory().setTotalSpace(info.memory.totalSpace*1024);
616  comp->getMemory().setFreeSpace(info.memory.freeSpace*1024);
617 
618  comp->getStorage().setTotalSpace(info.storage.totalSpace*1024);
619  comp->getStorage().setFreeSpace(info.storage.freeSpace*1024);
620 
621  //comp->getNetwork().setIP4(info.network.ip4.c_str());
622  //comp->getNetwork().setIP6(info.network.ip6.c_str());
623  //comp->getNetwork().setMAC(info.network.mac.c_str());
624 
625 
626  comp->getProcessor().setArchitecture(info.processor.architecture.c_str());
627  comp->getProcessor().setCores(info.processor.cores);
628  comp->getProcessor().setSiblings(info.processor.siblings);
629  comp->getProcessor().setFrequency(info.processor.frequency);
630  comp->getProcessor().setModel(info.processor.model.c_str());
631  LoadAvg load;
632  load.loadAverageInstant = (double)info.load.cpuLoadInstant;
633  load.loadAverage1 = info.load.cpuLoad1;
634  load.loadAverage5 = info.load.cpuLoad5;
635  load.loadAverage15 = info.load.cpuLoad15;
636  comp->getProcessor().setCPULoad(load);
637 
638  comp->getPlatform().setName(info.platform.name.c_str());
639  comp->getPlatform().setDistribution(info.platform.distribution.c_str());
640  comp->getPlatform().setRelease(info.platform.release.c_str());
641  }
642  return true;
643 }
644 
645 bool Manager::waitingModuleRun(unsigned int id)
646 {
647  double base = yarp::os::Time::now();
648  double wait = runnables[id]->getPostExecWait() + RUN_TIMEOUT;
649  while(!timeout(base, wait))
650  if(running(id)) return true;
651 
652  OSTRINGSTREAM msg;
653  msg<<"Failed to run "<<runnables[id]->getCommand();
654  msg<<" on "<<runnables[id]->getHost();
655  msg<<". (State: "<<runnables[id]->state();
656  msg<<", parameter: "<<runnables[id]->getParam()<<")";
657  logger->addError(msg);
658  return false;
659 
660 }
661 
662 bool Manager::waitingModuleStop(unsigned int id)
663 {
664  double base = yarp::os::Time::now();
665  while(!timeout(base, STOP_TIMEOUT))
666  if(!running(id)) return true;
667 
668  OSTRINGSTREAM msg;
669  msg<<"Failed to stop "<<runnables[id]->getCommand();
670  msg<<" on "<<runnables[id]->getHost();
671  msg<<". (State: "<<runnables[id]->state();
672  msg<<", paramete: "<<runnables[id]->getParam()<<")";
673  logger->addError(msg);
674  return false;
675 }
676 
677 bool Manager::waitingModuleKill(unsigned int id)
678 {
679  double base = yarp::os::Time::now();
680  while(!timeout(base, KILL_TIMEOUT))
681  if(!running(id)) return true;
682 
683  OSTRINGSTREAM msg;
684  msg<<"Failed to kill "<<runnables[id]->getCommand();
685  msg<<" on "<<runnables[id]->getHost();
686  msg<<". (State: "<<runnables[id]->state();
687  msg<<", paramete: "<<runnables[id]->getParam()<<")";
688  logger->addError(msg);
689  return false;
690 
691 }
692 
693 
694 bool Manager::existPortFrom(unsigned int id)
695 {
696  if(id>=connections.size())
697  {
698  logger->addError("Connection id is out of range.");
699  return false;
700  }
701 
702  bool exists = connector.exists(connections[id].from());
703  connections[id].setFromExists(exists);
704  return exists;
705 }
706 
707 
708 bool Manager::existPortTo(unsigned int id)
709 {
710  if(id>=connections.size())
711  {
712  logger->addError("Connection id is out of range.");
713  return false;
714  }
715 
716  bool exists = connector.exists(connections[id].to());
717  connections[id].setToExists(exists);
718  return exists;
719 }
720 
721 
723 {
729  bool ret = true;
730  ResourcePIterator itrRes;
731  for(itrRes=resources.begin(); itrRes!=resources.end(); itrRes++)
732  {
733  if(!(*itrRes)->getAvailability())
734  {
735  ret = false;
736  OSTRINGSTREAM err;
737  err<<"Resource "<<(*itrRes)->getName()<<" is not available!";
738  logger->addError(err);
739  }
740  }
741 
742  return ret;
743 }
744 
745 
746 
747 bool Manager::run(unsigned int id, bool async)
748 {
749  if(runnables.empty())
750  {
751  logger->addError("Application is not loaded.");
752  return false;
753  }
754 
755  if(id>=runnables.size())
756  {
757  logger->addError("Module id is out of range.");
758  return false;
759  }
760 
761  if (runnables[id]->shouldChangeBroker())
762  {
763  if (!switchBroker(id))
764  {
765  logger->addError("Failing to switch broker");
766  return false;
767  }
768  }
769 
770  runnables[id]->disableAutoConnect();
771  runnables[id]->start();
772  if(bWithWatchDog) {
774  runnables[id]->startWatchDog();
775  }
776  if(async)
777  return true;
778 
779  // waiting for running
780  return waitingModuleRun(id);
781 }
782 
784 {
785  if(runnables.empty())
786  {
787  logger->addError("Application is not loaded.");
788  return false;
789  }
790 
791  if(!checkDependency())
792  {
793  if(bRestricted)
794  {
795  logger->addError("Some of external ports dependency are not satisfied.");
796  return false;
797  }
798  else
799  logger->addWarning("Some of external ports dependency are not satisfied.");
800  }
801 
803  double wait = 0.0;
804  for(itr=runnables.begin(); itr!=runnables.end(); itr++)
805  {
806  if(bAutoConnect)
807  (*itr)->enableAutoConnect();
808  else
809  (*itr)->disableAutoConnect();
810  (*itr)->start();
812  wait = (wait > (*itr)->getPostExecWait()) ? wait : (*itr)->getPostExecWait();
813  }
814 
815  // waiting for running
816  double base = yarp::os::SystemClock::nowSystem();
817  while(!timeout(base, wait + RUN_TIMEOUT))
818  if(allRunning()) break;
819 
820  // starting the watchdog if needed
821  if(bWithWatchDog) {
822  for(itr=runnables.begin(); itr!=runnables.end(); itr++)
823  (*itr)->startWatchDog();
824  }
825 
826  if(!allRunning())
827  {
829  for(itr=runnables.begin(); itr!=runnables.end(); itr++)
830  if((*itr)->state() != RUNNING)
831  {
832  OSTRINGSTREAM msg;
833  msg<<"Failed to run "<<(*itr)->getCommand();
834  msg<<" on "<<(*itr)->getHost();
835  msg<<". (State: "<<(*itr)->state();
836  msg<<", parameter: "<<(*itr)->getParam()<<")";
837  logger->addError(msg);
838  }
839 
840  if(bRestricted)
841  {
842  kill();
843  return false;
844  }
845  }
846 
847  /* connecting extra ports*/
848  if(bAutoConnect)
849  if(!connectExtraPorts())
850  {
851  logger->addError("Failed to stablish some of connections.");
852  if(bRestricted)
853  return false;
854  }
855 
856  return true;
857 }
858 
859 bool Manager::stop(unsigned int id, bool async)
860 {
861  if(runnables.empty())
862  {
863  logger->addError("Application is not loaded.");
864  return false;
865  }
866 
867  if(id>=runnables.size())
868  {
869  logger->addError("Module id is out of range.");
870  return false;
871  }
872 
873  runnables[id]->stop();
874 
875  if(async)
876  return true;
877 
878  // waiting for stop
879  return waitingModuleStop(id);
880 }
881 
882 
884 {
885  if(runnables.empty())
886  return true;
887 
889  for(itr=runnables.begin(); itr!=runnables.end(); itr++)
890  {
891  (*itr)->stop();
893  }
894 
895  double base = yarp::os::SystemClock::nowSystem();
896  while(!timeout(base, STOP_TIMEOUT))
897  if(allStopped()) break;
898 
899  if(!allStopped())
900  {
902  for(itr=runnables.begin(); itr!=runnables.end(); itr++)
903  if( ((*itr)->state() != SUSPENDED) &&
904  ((*itr)->state() != DEAD))
905  {
906  OSTRINGSTREAM msg;
907  msg<<"Failed to stop "<<(*itr)->getCommand();
908  msg<<" on "<<(*itr)->getHost();
909  msg<<". (State: "<<(*itr)->state();
910  msg<<", paramete: "<<(*itr)->getParam()<<")";
911  logger->addError(msg);
912  }
913  return false;
914  }
915 
916  return true;
917 }
918 
919 bool Manager::kill(unsigned int id, bool async)
920 {
921  if(runnables.empty())
922  {
923  logger->addError("Application is not loaded.");
924  return false;
925  }
926 
927  if(id>=runnables.size())
928  {
929  logger->addError("Module id is out of range.");
930  return false;
931  }
932 
933  runnables[id]->kill();
934 
935  if(async)
936  return true;
937  return waitingModuleKill(id);
938 }
939 
940 
942 {
943  if(runnables.empty())
944  return true;
945 
947  for(itr=runnables.begin(); itr!=runnables.end(); itr++)
948  {
949  (*itr)->kill();
951  }
952 
953  double base = yarp::os::SystemClock::nowSystem();
954  while(!timeout(base, KILL_TIMEOUT))
955  if(allStopped()) break;
956 
957  if(!allStopped())
958  {
960  for(itr=runnables.begin(); itr!=runnables.end(); itr++)
961  if( ((*itr)->state() != SUSPENDED) &&
962  ((*itr)->state() != DEAD))
963  {
964  OSTRINGSTREAM msg;
965  msg<<"Failed to kill "<<(*itr)->getCommand();
966  msg<<" on "<<(*itr)->getHost();
967  msg<<". (State: "<<(*itr)->state();
968  msg<<", paramete: "<<(*itr)->getParam()<<")";
969  logger->addError(msg);
970  }
971  return false;
972  }
973 
974  return true;
975 }
976 
977 
978 void Manager::clearExecutables()
979 {
981  for(itr=runnables.begin(); itr!=runnables.end(); itr++)
982  {
983  // broker will be deleted by Executable
984  delete (*itr);
985  }
986  runnables.clear();
987 }
988 
989 
990 bool Manager::connect(unsigned int id)
991 {
992  if(id>=connections.size())
993  {
994  logger->addError("Connection id is out of range.");
995  return false;
996  }
997 
998  //YarpBroker connector;
999  //connector.init();
1000 
1001  if( !connector.connect(connections[id].from(),
1002  connections[id].to(),
1003  connections[id].carrier(),
1004  connections[id].isPersistent()) )
1005  {
1006  logger->addError(connector.error());
1007  //cout<<connector.error()<<endl;
1008  return false;
1009  }
1010 
1011  // setting the connection Qos if specified
1012  return connector.setQos(connections[id].from(),
1013  connections[id].to(),
1014  connections[id].qosFrom(),
1015  connections[id].qosTo());
1016 }
1017 
1019 {
1020  //YarpBroker connector;
1021  //connector.init();
1022  CnnIterator cnn;
1023  for(cnn=connections.begin(); cnn!=connections.end(); cnn++) {
1024  if( !(*cnn).getFromExists() ||
1025  !(*cnn).getToExists() ||
1026  !connector.connect((*cnn).from(), (*cnn).to(),
1027  (*cnn).carrier(), (*cnn).isPersistent()) )
1028  {
1029  logger->addError(connector.error());
1030  //cout<<connector.error()<<endl;
1031  if(bRestricted)
1032  return false;
1033  }
1034 
1035  // setting the connection Qos if specified
1036  if(! connector.setQos((*cnn).from(), (*cnn).to(),
1037  (*cnn).qosFrom(), (*cnn).qosTo())) {
1038  if(bRestricted)
1039  return false;
1040  }
1041  }
1042  return true;
1043 }
1044 
1045 bool Manager::disconnect(unsigned int id)
1046 {
1047  if(id>=connections.size())
1048  {
1049  logger->addError("Connection id is out of range.");
1050  return false;
1051  }
1052 
1053  //YarpBroker connector;
1054  //connector.init();
1055 
1056  if( !connector.disconnect(connections[id].from(),
1057  connections[id].to(),
1058  connections[id].carrier()) )
1059  {
1060  logger->addError(connector.error());
1061  //cout<<connector.error()<<endl;
1062  return false;
1063  }
1064 
1065  return true;
1066 }
1067 
1069 {
1070  //YarpBroker connector;
1071  //connector.init();
1072  CnnIterator cnn;
1073  for(cnn=connections.begin(); cnn!=connections.end(); cnn++)
1074  if( !connector.disconnect((*cnn).from(), (*cnn).to(), (*cnn).carrier()) )
1075  {
1076  logger->addError(connector.error());
1077  //cout<<connector.error()<<endl;
1078  return false;
1079  }
1080  return true;
1081 }
1082 
1083 
1084 bool Manager::rmconnect(unsigned int id)
1085 {
1086  if(id>=connections.size())
1087  {
1088  logger->addError("Connection id is out of range.");
1089  return false;
1090  }
1091 
1092  if(!connector.rmconnect(connections[id].from(),
1093  connections[id].to()) )
1094  {
1095  logger->addError(connector.error());
1096  return false;
1097  }
1098 
1099  return true;
1100 }
1101 
1102 
1104 {
1105  CnnIterator cnn;
1106  for(cnn=connections.begin(); cnn!=connections.end(); cnn++)
1107  if( !connector.rmconnect((*cnn).from(), (*cnn).to()) )
1108  {
1109  logger->addError(connector.error());
1110  return false;
1111  }
1112  return true;
1113 }
1114 
1115 
1116 bool Manager::connected(unsigned int id)
1117 {
1118  if(id>=connections.size())
1119  {
1120  logger->addError("Connection id is out of range.");
1121  return false;
1122  }
1123 
1124  return connections[id].getFromExists() &&
1125  connections[id].getToExists() &&
1126  connector.connected(connections[id].from(),
1127  connections[id].to(),
1128  connections[id].carrier());
1129 }
1130 
1131 
1133 {
1134  //YarpBroker connector;
1135  //connector.init();
1136  CnnIterator cnn;
1137  bool bConnected = true;
1138  for(cnn=connections.begin(); cnn!=connections.end(); cnn++)
1139  if( !(*cnn).getFromExists() ||
1140  !(*cnn).getToExists() ||
1141  !connector.connected((*cnn).from(), (*cnn).to(), (*cnn).carrier()) )
1142  bConnected = false;
1143  return bConnected;
1144 }
1145 
1146 bool Manager::checkPortsAvailable(Broker* broker)
1147 {
1148  CnnIterator itr;
1149  for(itr=connections.begin(); itr!=connections.end(); itr++)
1150  {
1151  //if(!(*itr).owner() )
1152  // {
1153  if(!broker->exists((*itr).to()) ||
1154  !broker->exists((*itr).from()))
1155  return false;
1156  // }
1157  }
1158  return true;
1159 }
1160 
1161 
1162 bool Manager::connectExtraPorts()
1163 {
1164  //YarpBroker connector;
1165  //connector.init();
1166 
1167  double base = yarp::os::SystemClock::nowSystem();
1168  while(!timeout(base, 10.0))
1169  if(checkPortsAvailable(&connector))
1170  break;
1171 
1172  CnnIterator cnn;
1173  for(cnn=connections.begin(); cnn!=connections.end(); cnn++)
1174  {
1175  //if(!(*cnn).owner() )
1176  //{
1177  if( !connector.connect((*cnn).from(), (*cnn).to(),
1178  (*cnn).carrier()) )
1179  {
1180  logger->addError(connector.error());
1181  //cout<<connector.error()<<endl;
1182  return false;
1183  }
1184  //}
1185  }
1186  return true;
1187 }
1188 
1189 bool Manager::running(unsigned int id)
1190 {
1191  if(id>=runnables.size())
1192  {
1193  logger->addError("Module id is out of range.");
1194  return false;
1195  }
1196 
1197  RSTATE st = runnables[id]->state();
1198  if((st == RUNNING) || (st == CONNECTING) || (st == DYING))
1199  return true;
1200  return false;
1201 }
1202 
1203 
1204 bool Manager::allRunning()
1205 {
1206  if(!runnables.size())
1207  return false;
1208  ExecutablePIterator itr;
1209  for(itr=runnables.begin(); itr!=runnables.end(); itr++)
1210  {
1211  RSTATE st = (*itr)->state();
1212  if((st != RUNNING) && (st != CONNECTING) && (st != DYING))
1213  return false;
1214  }
1215  return true;
1216 }
1217 
1218 
1219 bool Manager::suspended(unsigned int id)
1220 {
1221  if(id>=runnables.size())
1222  {
1223  logger->addError("Module id is out of range.");
1224  return false;
1225  }
1226  RSTATE st = runnables[id]->state();
1227  if((st == SUSPENDED) || (st == DEAD))
1228  return true;
1229  return false;
1230 }
1231 
1232 
1233 bool Manager::allStopped()
1234 {
1235  if(!runnables.size())
1236  return true;
1237  ExecutablePIterator itr;
1238  for(itr=runnables.begin(); itr!=runnables.end(); itr++)
1239  {
1240  RSTATE st = (*itr)->state();
1241  if( (st != SUSPENDED) && (st != DEAD))
1242  return false;
1243  }
1244  return true;
1245 }
1246 
1247 bool Manager::attachStdout(unsigned int id)
1248 {
1249  if(id>=runnables.size())
1250  {
1251  logger->addError("Module id is out of range.");
1252  return false;
1253  }
1254 
1255  if(!runnables[id]->getBroker()->attachStdout())
1256  {
1257  OSTRINGSTREAM msg;
1258  msg<<"Cannot attach to stdout of "<<runnables[id]->getCommand();
1259  msg<<" on "<<runnables[id]->getHost();
1260  msg<<". (State: "<<runnables[id]->state();
1261  msg<<", paramete: "<<runnables[id]->getParam()<<") ";
1262  msg<<"because "<<runnables[id]->getBroker()->error();
1263  logger->addError(msg);
1264  return false;
1265  }
1266  return true;
1267 }
1268 
1269 bool Manager::detachStdout(unsigned int id)
1270 {
1271  if(id>=runnables.size())
1272  {
1273  logger->addError("Module id is out of range.");
1274  return false;
1275  }
1276 
1277  runnables[id]->getBroker()->detachStdout();
1278  return true;
1279 }
1280 
1281 bool Manager::timeout(double base, double t)
1282 {
1284  if((yarp::os::SystemClock::nowSystem()-base) > t)
1285  return true;
1286  return false;
1287 }
1288 
1289 
1290 void Manager::onExecutableStart(void* which) {}
1291 void Manager::onExecutableStop(void* which) {}
1292 void Manager::onCnnStablished(void* which) {}
1293 void Manager::onExecutableDied(void* which) {}
1294 void Manager::onExecutableFailed(void* which) {}
1295 void Manager::onExecutableStdout(void* which, const char* msg) {}
1296 void Manager::onCnnFailed(void* which) {}
1297 void Manager::onError(void* which) {}
1298 
1299 
1300 /*
1301 bool Manager::loadModule(const char* szModule, const char* szHost)
1302 {
1303  __CHECK_NULLPTR(szModule);
1304  strAppName = szModule;
1305 
1306  SingleAppLoader appLoader(szModule, szHost);
1307  if(!appLoader.init())
1308  {
1309  logger->addError("Error initializing SingleAppLoader.");
1310  return false;
1311  }
1312 
1313  if(!createKnowledgeBase(appLoader))
1314  {
1315  logger->addError("Cannot create knowledge base");
1316  return false;
1317  }
1318 
1319  return prepare();
1320 
1321 }
1322 */
LogStream.h
yarp::manager::Application
Class Application.
Definition: application.h:292
yarp::manager::_LoadAvg::loadAverageInstant
double loadAverageInstant
Definition: primresource.h:101
yarp::os::Bottle
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:73
yarp::os::SystemInfo::LoadInfo::cpuLoadInstant
int cpuLoadInstant
Definition: SystemInfo.h:76
yarp::manager::DYING
@ DYING
Definition: executable.h:38
yarp::os::SystemInfo::ProcessorInfo::model
std::string model
Definition: SystemInfo.h:58
yarp::manager::Manager::loadBalance
bool loadBalance()
Definition: manager.cpp:261
yarp::manager::Broker::setDisplay
void setDisplay(const char *szDisplay)
Definition: broker.h:67
yarp::manager::KnowledgeBase::getSelModules
const ModulePContainer & getSelModules()
Definition: kbase.h:71
yarp::manager::Manager::removeModule
bool removeModule(const char *szModName)
Definition: manager.cpp:190
yarp::manager::Manager::~Manager
~Manager() override
Definition: manager.cpp:84
xmlapploader.h
yarp::manager::Manager::kill
bool kill()
Definition: manager.cpp:941
yarp::os::Bottle::size
size_type size() const
Gets the number of elements in the bottle.
Definition: Bottle.cpp:254
yarpdevbroker.h
yarp::manager::Manager::addApplication
bool addApplication(const char *szFileName, char **szAppName_=nullptr, bool modifyName=false)
Definition: manager.cpp:91
yarp::manager::XmlAppLoader::init
bool init() override
Definition: xmlapploader.cpp:74
t
float t
Definition: FfmpegWriter.cpp:74
yarp::manager::YarpBroker::rmconnect
bool rmconnect(const char *from, const char *to)
Definition: yarpbroker.cpp:688
yarp::manager::Manager::removeResource
bool removeResource(const char *szResName)
Definition: manager.cpp:207
yarp::manager::Manager::onExecutableDied
void onExecutableDied(void *which) override
Definition: manager.cpp:1293
yarp::os::impl::NameClient::send
std::string send(const std::string &cmd, bool multi=true, const ContactStyle &style=ContactStyle())
Send a text message to the nameserver, and return the result.
Definition: NameClient.cpp:302
yarp::manager::YarpBroker::getSystemInfo
bool getSystemInfo(const char *server, yarp::os::SystemInfoSerializer &info)
Definition: yarpbroker.cpp:555
yarp::manager::GenericResource::setAvailability
void setAvailability(bool flag)
Definition: resource.h:26
yarp::os::impl::NameClient::getNameClient
static NameClient & getNameClient()
Get an instance of the name client.
Definition: NameClient.cpp:128
yarp::manager::Manager::onExecutableStdout
void onExecutableStdout(void *which, const char *msg) override
Definition: manager.cpp:1295
yarp::manager::Manager::addModule
bool addModule(const char *szFileName)
Definition: manager.cpp:124
yarp::manager::Executable::getHost
const char * getHost()
Definition: executable.h:107
yarp::manager::KnowledgeBase::getSelConnection
const CnnContainer & getSelConnection()
Definition: kbase.h:72
yarp::manager::KnowledgeBase::addApplication
bool addApplication(Application *application, char **szAppName_=nullptr, bool modifyName=false)
Definition: kbase.cpp:77
yarp::os::SystemInfo::LoadInfo::cpuLoad5
double cpuLoad5
Definition: SystemInfo.h:74
yarp::manager::Manager::loadApplication
bool loadApplication(const char *szAppName)
Definition: manager.cpp:226
yarp::manager::Manager::Manager
Manager(bool withWatchDog=false)
Class Manager.
Definition: manager.cpp:42
yarp::manager::Manager::running
bool running()
Definition: manager.h:65
yarp::manager::OSTRINGSTREAM
std::stringstream OSTRINGSTREAM
Definition: utility.h:52
yarp::manager::Manager::onCnnFailed
void onCnnFailed(void *which) override
Definition: manager.cpp:1296
yarp::manager::Computer
Definition: primresource.h:155
yarp::manager::XmlAppLoader
Class XmlAppLoader.
Definition: xmlapploader.h:24
yarp::manager::YarpdevYarprunBroker
Definition: yarpdevbroker.h:45
STOP_TIMEOUT
#define STOP_TIMEOUT
Definition: manager.cpp:26
yarp::manager
Definition: application.h:24
yarp::manager::Manager::onExecutableStart
void onExecutableStart(void *which) override
Definition: manager.cpp:1290
yarp::manager::Manager::addResources
bool addResources(const char *szPath)
Definition: manager.cpp:161
yarp::manager::Manager::onExecutableStop
void onExecutableStop(void *which) override
Definition: manager.cpp:1291
yarp::manager::Broker
Class Broker.
Definition: broker.h:34
yarp::manager::Executable::setStdio
void setStdio(const char *val)
Definition: executable.h:88
yarp::manager::KnowledgeBase::addResource
bool addResource(GenericResource *resource)
Definition: kbase.cpp:144
yarp::manager::Manager::updateResources
bool updateResources()
Definition: manager.cpp:531
scriptbroker.h
yarp::manager::ResourcePContainer
std::vector< GenericResource * > ResourcePContainer
Definition: resource.h:62
yarp::os::SystemInfo::ProcessorInfo::frequency
double frequency
Definition: SystemInfo.h:64
singleapploader.h
yarp::manager::RSTATE
enum yarp::manager::__RSTATE RSTATE
ret
bool ret
Definition: ImplementAxisInfo.cpp:72
yarp::manager::Manager::switchBroker
bool switchBroker(size_t id)
Definition: manager.cpp:280
yarp::manager::KnowledgeBase::removeApplication
bool removeApplication(Application *application)
Definition: kbase.cpp:172
yarp::manager::CnnIterator
std::vector< Connection >::iterator CnnIterator
Definition: application.h:154
yarp::manager::YarpBroker::disconnect
bool disconnect(const char *from, const char *to, const char *carrier) override
Definition: yarpbroker.cpp:445
yarp::os::SystemInfoSerializer::processor
yarp::os::SystemInfo::ProcessorInfo processor
system processor type information
Definition: SystemInfoSerializer.h:63
yarp::manager::Manager::onExecutableFailed
void onExecutableFailed(void *which) override
Definition: manager.cpp:1294
yError
#define yError(...)
Definition: Log.h:282
localbroker.h
yarp::manager::compareString
bool compareString(const char *szFirst, const char *szSecond)
Definition: utility.cpp:305
yarp::manager::Manager::run
bool run()
Definition: manager.cpp:783
yarp::os::Time::now
double now()
Return the current time in seconds, relative to an arbitrary starting point.
Definition: Time.cpp:124
yarp::manager::XmlResLoader
Class XmlResLoader.
Definition: xmlresloader.h:25
yarp::manager::ModulePIterator
std::vector< Module * >::iterator ModulePIterator
Definition: module.h:235
BROKER_YARPDEV
#define BROKER_YARPDEV
Definition: manager.cpp:31
yarp::manager::Executable::stop
void stop()
Definition: executable.cpp:102
yarp::manager::Manager::addModules
bool addModules(const char *szPath)
Definition: manager.cpp:136
yarp::manager::SUSPENDED
@ SUSPENDED
Definition: executable.h:34
yarp::os::SystemClock::nowSystem
static double nowSystem()
Definition: SystemClock.cpp:37
yarp::os::SystemInfoSerializer::storage
yarp::os::SystemInfo::StorageInfo storage
system storage information
Definition: SystemInfoSerializer.h:58
yarp::manager::Module
Class Module.
Definition: module.h:103
yarp::manager::Manager::existPortFrom
bool existPortFrom(unsigned int id)
Definition: manager.cpp:694
yarp::manager::Manager::addResource
bool addResource(const char *szFileName)
Definition: manager.cpp:148
yarp::manager::Manager::connect
bool connect()
Definition: manager.cpp:1018
yarp::os::SystemInfo::StorageInfo::freeSpace
capacity_t freeSpace
Definition: SystemInfo.h:49
yarp::manager::YarpBroker::setQos
bool setQos(const char *from, const char *to, const char *qosFrom, const char *qosTo)
Definition: yarpbroker.cpp:702
yarp::manager::YarpdevLocalBroker
Definition: yarpdevbroker.h:22
yarp::manager::ErrorLogger::Instance
static ErrorLogger * Instance()
Singleton class ErrorLogger.
Definition: utility.cpp:102
yarp::manager::KnowledgeBase::saveApplication
bool saveApplication(AppSaver *appSaver, Application *application)
Definition: kbase.cpp:1263
yarp::manager::Manager::checkDependency
bool checkDependency()
Definition: manager.cpp:722
yarp::manager::KnowledgeBase::getNode
Node * getNode(std::string appName)
Definition: kbase.cpp:1607
yarp::manager::Manager::saveApplication
bool saveApplication(const char *szAppName, const char *fileName=nullptr)
Definition: manager.cpp:251
yarp::manager::_LoadAvg::loadAverage15
double loadAverage15
Definition: primresource.h:104
yarp::manager::YarpBroker::getAllPorts
bool getAllPorts(std::vector< std::string > &stingList)
Definition: yarpbroker.cpp:613
yarp::manager::Manager::exist
bool exist(unsigned int id)
Definition: manager.cpp:469
yarp::os::SystemInfoSerializer::memory
yarp::os::SystemInfo::MemoryInfo memory
system memory information
Definition: SystemInfoSerializer.h:53
yarp::manager::Manager::detachStdout
bool detachStdout(unsigned int id)
Definition: manager.cpp:1269
yarp::manager::Manager::updateConnection
bool updateConnection(unsigned int id, const char *from, const char *to, const char *carrier)
Definition: manager.cpp:436
yarp::os::Bottle::get
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
Definition: Bottle.cpp:249
yarp::manager::Manager::removeApplication
bool removeApplication(const char *szFileName, const char *szAppName)
Definition: manager.cpp:173
yarp::manager::Manager::disconnect
bool disconnect()
Definition: manager.cpp:1068
yarp::manager::Executable::stopWatchDog
void stopWatchDog()
Definition: executable.cpp:218
yarp::manager::Executable::setHost
void setHost(const char *val)
Definition: executable.h:87
yarp::manager::Manager::existPortTo
bool existPortTo(unsigned int id)
Definition: manager.cpp:708
yarp::os::SystemInfo::ProcessorInfo::cores
int cores
Definition: SystemInfo.h:62
yarp::manager::KnowledgeBase::getSelResources
const ResourcePContainer & getSelResources()
Definition: kbase.h:73
yarp::manager::XmlModLoader::init
bool init() override
Definition: xmlmodloader.cpp:70
yarp::os::SystemInfo::PlatformInfo::release
std::string release
Definition: SystemInfo.h:87
yarp::os::SystemClock::delaySystem
static void delaySystem(double seconds)
Definition: SystemClock.cpp:32
yarp::manager::Manager::stop
bool stop()
Definition: manager.cpp:883
yarp::os::SystemInfo::ProcessorInfo::siblings
int siblings
Definition: SystemInfo.h:63
yarp::manager::Node
a Node of a Graph
Definition: node.h:68
yarp::manager::KnowledgeBase::removeResource
bool removeResource(GenericResource *resource)
Definition: kbase.cpp:182
yarp::manager::Manager::attachStdout
bool attachStdout(unsigned int id)
Definition: manager.cpp:1247
yarp::manager::MEvent
Definition: executable.h:51
yarp::os::Value::asBool
virtual bool asBool() const
Get boolean value.
Definition: Value.cpp:189
yarp::manager::YarpBroker::connected
bool connected(const char *from, const char *to, const char *carrier) override
Definition: yarpbroker.cpp:544
yarp::manager::ErrorLogger::addError
void addError(const char *szError)
Definition: utility.cpp:121
yarp::manager::ExecutablePIterator
std::vector< Executable * >::iterator ExecutablePIterator
Definition: executable.h:171
yarp::manager::KnowledgeBase::getResources
const ResourcePContainer & getResources(Application *parent=nullptr)
Definition: kbase.cpp:256
yarp::manager::Manager::waitingModuleKill
bool waitingModuleKill(unsigned int id)
Definition: manager.cpp:677
xmlmodloader.h
yarp::manager::KnowledgeBase::addModule
bool addModule(Module *module)
Definition: kbase.cpp:120
yarp::os::SystemInfo::LoadInfo::cpuLoad15
double cpuLoad15
Definition: SystemInfo.h:75
yarp::manager::XmlResLoader::getNextResource
GenericResource * getNextResource() override
Definition: xmlresloader.cpp:134
yarp::os::SystemInfo::PlatformInfo::distribution
std::string distribution
Definition: SystemInfo.h:86
yarp::manager::ResYarpPort
Definition: logicresource.h:47
yarp::manager::Manager::addApplications
bool addApplications(const char *szPath)
Definition: manager.cpp:108
yarp::manager::RUNNING
@ RUNNING
Definition: executable.h:37
yarp::manager::Executable::setEnv
void setEnv(const char *val)
Definition: executable.h:90
yarp::manager::YarpBroker
Class Broker.
Definition: yarpbroker.h:37
yarp::manager::XmlResLoader::init
bool init() override
Definition: xmlresloader.cpp:65
module
static RFModule * module
Definition: RFModule.cpp:234
yarp::manager::_LoadAvg
Definition: primresource.h:100
yarp::manager::GenericResource::getAvailability
bool getAvailability()
Definition: resource.h:27
NameClient.h
yarp::manager::Manager::waitingModuleStop
bool waitingModuleStop(unsigned int id)
Definition: manager.cpp:662
yarp::manager::Manager::connected
bool connected()
Definition: manager.cpp:1132
yarp::manager::Manager::onError
void onError(void *which) override
Definition: manager.cpp:1297
yarp::manager::ErrorLogger::addWarning
void addWarning(const char *szWarning)
Definition: utility.cpp:108
yarp::os::Bottle::addString
void addString(const char *str)
Places a string in the bottle, at the end of the list.
Definition: Bottle.cpp:173
__CHECK_NULLPTR
#define __CHECK_NULLPTR(_ptr)
Definition: ymm-types.h:83
yarp::manager::Manager::waitingModuleRun
bool waitingModuleRun(unsigned int id)
Definition: manager.cpp:645
yarp::manager::YarpBroker::connect
bool connect(const char *from, const char *to, const char *carrier, bool persist=false) override
connection broker
Definition: yarpbroker.cpp:383
yarpbroker.h
yarp::manager::KnowledgeBase::createFrom
bool createFrom(ModuleLoader *_mloader, AppLoader *_apploader, ResourceLoader *_resloader)
Definition: kbase.cpp:23
yarp::manager::Manager::getExecutableById
Executable * getExecutableById(size_t id)
Definition: manager.cpp:268
yarp::manager::Manager::updateExecutable
bool updateExecutable(unsigned int id, const char *szparam, const char *szhost, const char *szstdio, const char *szworkdir, const char *szenv)
Definition: manager.cpp:410
yarp::manager::XmlModLoader
Class XmlModLoader.
Definition: xmlmodloader.h:24
yarp::manager::KnowledgeBase::getApplication
Application * getApplication()
Definition: kbase.h:88
yarp::os::SystemInfoSerializer::load
yarp::os::SystemInfo::LoadInfo load
current cpu load information
Definition: SystemInfoSerializer.h:73
yarp::manager::Manager::suspended
bool suspended()
Definition: manager.h:67
yarp::manager::ResYarpPort::setPort
void setPort(const char *szPort)
Definition: logicresource.h:52
yarp::manager::GenericResource
Definition: resource.h:21
KILL_TIMEOUT
#define KILL_TIMEOUT
Definition: manager.cpp:27
manager.h
yarp::manager::ScriptLocalBroker
Definition: scriptbroker.h:23
yarp::manager::XmlModLoader::getNextModule
Module * getNextModule() override
Definition: xmlmodloader.cpp:141
yarp::manager::XmlAppSaver
Class XmlAppSaver.
Definition: xmlappsaver.h:23
yarp::manager::CONNECTING
@ CONNECTING
Definition: executable.h:36
yarp::manager::Executable::setWorkDir
void setWorkDir(const char *val)
Definition: executable.h:89
yarp::os::SystemInfo::LoadInfo::cpuLoad1
double cpuLoad1
Definition: SystemInfo.h:73
yarp::os::SystemInfoSerializer
A helper class to pass the SystemInfo object around the YARP network.
Definition: SystemInfoSerializer.h:24
yarp::manager::KnowledgeBase::getModule
Module * getModule(const char *szName)
Definition: kbase.h:85
yarp::manager::YarpBroker::error
const char * error() override
Definition: yarpbroker.cpp:760
yarp::manager::ResourcePIterator
std::vector< GenericResource * >::iterator ResourcePIterator
Definition: resource.h:63
yarp::manager::KnowledgeBase::removeModule
bool removeModule(Module *module)
Definition: kbase.cpp:177
yarp::manager::Manager::updateResource
bool updateResource(const char *szName)
Definition: manager.cpp:582
yarp::manager::_LoadAvg::loadAverage5
double loadAverage5
Definition: primresource.h:103
yarp::os::SystemInfo::StorageInfo::totalSpace
capacity_t totalSpace
Definition: SystemInfo.h:48
yarp::manager::YarpBroker::init
bool init() override
Definition: yarpbroker.cpp:64
yarp::manager::KnowledgeBase::reasolveDependency
bool reasolveDependency(const char *szName, bool bAutoDependancy=false, bool bSilent=false)
Definition: kbase.cpp:868
yarp::manager::_LoadAvg::loadAverage1
double loadAverage1
Definition: primresource.h:102
yarp::manager::LocalBroker
Class LocalBroker.
Definition: localbroker.h:37
yarp::manager::Executable::setAndInitializeBroker
void setAndInitializeBroker(Broker *_broker)
Definition: executable.cpp:201
yarp::os::SystemInfo::MemoryInfo::totalSpace
capacity_t totalSpace
Definition: SystemInfo.h:38
RUN_TIMEOUT
#define RUN_TIMEOUT
Definition: manager.cpp:25
xmlappsaver.h
yarp::manager::Manager::rmconnect
bool rmconnect()
Definition: manager.cpp:1103
yarp::manager::ScriptYarprunBroker
Definition: scriptbroker.h:41
BROKER_YARPRUN
#define BROKER_YARPRUN
Definition: manager.cpp:30
yarp::os::SystemInfoSerializer::platform
yarp::os::SystemInfo::PlatformInfo platform
operating system information
Definition: SystemInfoSerializer.h:68
yarp::manager::Application::getXmlFile
const char * getXmlFile()
Definition: application.h:341
yarp::manager::Executable::state
RSTATE state()
Definition: executable.cpp:139
yarp::manager::GenericResource::setName
void setName(const char *szName)
Definition: resource.h:31
yarp::os::SystemInfo::ProcessorInfo::architecture
std::string architecture
Definition: SystemInfo.h:57
yarp::manager::GenericResource::getName
const char * getName()
Definition: resource.h:32
yarp::manager::Broker::exists
virtual bool exists(const char *port)=0
xmlresloader.h
yarp::manager::DEAD
@ DEAD
Definition: executable.h:39
yarp::os::SystemInfo::PlatformInfo::name
std::string name
Definition: SystemInfo.h:85
yarp::manager::Executable
Class Executable.
Definition: executable.h:75
yarp::manager::YarpBroker::exists
bool exists(const char *port) override
Definition: yarpbroker.cpp:494
yarp::manager::XmlAppLoader::getNextApplication
Application * getNextApplication() override
Definition: xmlapploader.cpp:143
yarp::manager::Executable::removeBroker
void removeBroker()
Definition: executable.h:102
yarp::os::SystemInfo::MemoryInfo::freeSpace
capacity_t freeSpace
Definition: SystemInfo.h:39
yarp::manager::KnowledgeBase::getResource
GenericResource * getResource(const char *szName)
Definition: kbase.h:93
yarp::manager::Manager::getNode
Node * getNode(std::string appName)
Definition: manager.cpp:463
yarp::manager::Manager::onCnnStablished
void onCnnStablished(void *which) override
Definition: manager.cpp:1292
yarp::manager::Executable::setParam
void setParam(const char *val)
Definition: executable.h:86