22 #include "dabc/Factory.h"
32 if ((ctrl==0) && (cfg.
NumNodes()>1)) ctrl = 1;
34 if ((ctrl > 0) || !master.empty()) {
35 DOUT2(
"Connecting control");
37 EOUT(
"Cannot establish connection to command system");
41 if (!master.empty()) {
43 cmd.
SetStr(
"Master", master);
44 cmd.
SetStr(
"NameSufix",
"DABC");
46 DOUT0(
"FAIL to activate connection to master %s", master.c_str());
68 int main(
int numc,
char* args[])
70 ::setlocale(LC_ALL,
"C");
78 if ((numc>1) and (strcmp(args[1],
"cmd")==0))
81 const char *cfgfile =
nullptr;
83 if(numc > 1) cfgfile = args[1];
85 unsigned nodeid = 1000000;
86 unsigned numnodes = 0;
91 DOUT3(
"Cannot read configuration from file %s - Exit", (cfgfile ? cfgfile :
"---") );
96 EOUT(
"Only dabc version 2 for xml files is supported - Exit");
103 const char* arg = args[cnt++];
105 if (strcmp(arg,
"-slow-time")==0) {
108 if (strcmp(arg,
"-nodeid")==0) {
110 nodeid = std::stoul(args[cnt++]);
112 if (strcmp(arg,
"-numnodes")==0) {
114 numnodes = std::stoul(args[cnt++]);
116 if (strcmp(arg,
"-run")==0) {
119 if (strcmp(arg,
"-norun")==0) {
122 const char* separ = strchr(arg,
'=');
123 if ((separ!=0) && (separ!=arg)) {
124 std::string argname, argvalue;
125 argname.append(arg, separ - arg);
129 if ((argvalue.length() > 1) && (argvalue[0] == argvalue[argvalue.length()-1]))
130 if ((argvalue[0] ==
'\'') || (argvalue[0] ==
'\"')) {
132 argvalue.resize(argvalue.length()-1);
140 if (numnodes==0) numnodes = cfg.
NumNodes();
141 if (nodeid>=numnodes) nodeid = 0;
143 DOUT2(
"Using config file: %s id: %u", cfgfile, nodeid);
146 EOUT(
"Did not found context");
154 std::string affinity = cfg.
Affinity();
155 if (!affinity.empty())
162 DOUT2(
"Process affinity %s", sbuf);
164 DOUT2(
"Create manager");
194 if (res==0) runfunc();
void * ExternalFunction()
Represents command with its arguments.
bool SetStr(const std::string &name, const char *value)
void AddCmdVariable(const char *name, const char *value)
Add variable from command line.
unsigned NumNodes()
returns number of nodes in xml file
Full-functional class to reading configuration from xml files.
bool SelectContext(unsigned nodeid, unsigned numnodes)
const char * MgrName() const
int UseControl()
Defines if control used in dabc node.
std::string RunFuncName()
std::string MasterName()
Defines master DABC process, to which application will be connected Master means all control and moni...
std::string Affinity()
Return default affinity of any newly created thread.
int WithPublisher()
Returns true when publisher should be created.
double GetRunTime()
Returns configured time to run DABC process.
std::string ConetextAppClass()
static void * FindSymbol(const std::string &symbol)
void RunMainLoop(double runtime=0.)
Run manager main loop.
ModuleRef CreateModule(const std::string &classname, const std::string &modulename, const std::string &thrdname="")
void RunCmdLoop(double runtime=0., const std::string &remnode="")
Run manager command loop.
void StartModule(const std::string &modulename)
bool CreatePublisher()
Create publisher, which manage all published hierarchies.
Manager of everything in DABC
static const char * MgrThrdName()
static void InspectGarbageCollector()
\ brief Methods to inspect how many objects pointers are remained
static unsigned NumInstances()
Static variable counts total number of objects instances.
static bool SetDfltAffinity(const char *aff=nullptr)
Sets default affinity for next threads to be created and for main process.
static bool GetDfltAffinity(char *buf, unsigned maxbuf)
Returns default affinity mask in form "xxxooosss".
void Destroy()
Release reference and starts destroyment of referenced object.
bool SyncWorker(double tmout=-1.)
Synchronize worker with caller thread.
bool Execute(Command cmd, double tmout=-1.)
int command_shell(const char *node)
bool CreateManagerControl(dabc::Configuration &cfg)
int main(int numc, char *args[])
bool InstallSignalHandlers()
Method is used to install DABC-specific Ctrl-C handler It allows to correctly stop program execution ...
bool CreateManager(const std::string &name, int cmd_port=-1)
Function should be used to create manager instance.
bool DestroyManager()
Function can be used to destroy manager.