Commit f48f2b58 authored by Pavel Vainerman's avatar Pavel Vainerman

Перевёл глобальный UniSetTypes::conf на использование shared_ptr + singleton

(заодно привёл форматирование к общему виду "пробелы вместо tab").
parent dab976bb
...@@ -56,13 +56,13 @@ string conffile("configure.xml"); ...@@ -56,13 +56,13 @@ string conffile("configure.xml");
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
static bool commandToAll( const string& section, ObjectRepository *rep, Command cmd ); static bool commandToAll( const string& section, ObjectRepository *rep, Command cmd );
static void createSections( UniSetTypes::Configuration* c ); static void createSections( const std::shared_ptr<UniSetTypes::Configuration> c );
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
int omap(); int omap();
int configure( const string& args, UInterface &ui ); int configure( const string& args, UInterface &ui );
int logRotate( const string& args, UInterface &ui ); int logRotate( const string& args, UInterface &ui );
int setValue( const string& args, UInterface &ui, Configuration* conf = UniSetTypes::conf ); int setValue( const string& args, UInterface &ui );
int getValue( const string& args, UInterface &ui, Configuration* conf = UniSetTypes::conf ); int getValue( const string& args, UInterface &ui );
int getRawValue( const string& args, UInterface &ui ); int getRawValue( const string& args, UInterface &ui );
int getState( const string& args, UInterface &ui ); int getState( const string& args, UInterface &ui );
int getCalibrate( const string& args, UInterface &ui ); int getCalibrate( const string& args, UInterface &ui );
...@@ -153,14 +153,14 @@ int main(int argc, char** argv) ...@@ -153,14 +153,14 @@ int main(int argc, char** argv)
case 'b': //--create case 'b': //--create
{ {
uniset_init(argc,argv,conffile); auto conf = uniset_init(argc,argv,conffile);
createSections(conf); createSections(conf);
} }
return 0; return 0;
case 'x': //--setValue case 'x': //--setValue
{ {
uniset_init(argc,argv,conffile); auto conf = uniset_init(argc,argv,conffile);
UInterface ui(conf); UInterface ui(conf);
return setValue(optarg,ui); return setValue(optarg,ui);
} }
...@@ -169,7 +169,7 @@ int main(int argc, char** argv) ...@@ -169,7 +169,7 @@ int main(int argc, char** argv)
case 'g': //--getValue case 'g': //--getValue
{ {
// cout<<"(main):received option --getValue='"<<optarg<<"'"<<endl; // cout<<"(main):received option --getValue='"<<optarg<<"'"<<endl;
uniset_init(argc,argv,conffile); auto conf = uniset_init(argc,argv,conffile);
UInterface ui(conf); UInterface ui(conf);
return getValue(optarg,ui); return getValue(optarg,ui);
} }
...@@ -178,7 +178,7 @@ int main(int argc, char** argv) ...@@ -178,7 +178,7 @@ int main(int argc, char** argv)
case 'w': //--getRawValue case 'w': //--getRawValue
{ {
// cout<<"(main):received option --getRawValue='"<<optarg<<"'"<<endl; // cout<<"(main):received option --getRawValue='"<<optarg<<"'"<<endl;
uniset_init(argc,argv,conffile); auto conf = uniset_init(argc,argv,conffile);
UInterface ui(conf); UInterface ui(conf);
return getRawValue(optarg,ui); return getRawValue(optarg,ui);
} }
...@@ -187,7 +187,7 @@ int main(int argc, char** argv) ...@@ -187,7 +187,7 @@ int main(int argc, char** argv)
case 'p': //--oinfo case 'p': //--oinfo
{ {
// cout<<"(main):received option --oinfo='"<<optarg<<"'"<<endl; // cout<<"(main):received option --oinfo='"<<optarg<<"'"<<endl;
uniset_init(argc,argv,conffile); auto conf = uniset_init(argc,argv,conffile);
UInterface ui(conf); UInterface ui(conf);
return oinfo(optarg,ui); return oinfo(optarg,ui);
} }
...@@ -196,10 +196,10 @@ int main(int argc, char** argv) ...@@ -196,10 +196,10 @@ int main(int argc, char** argv)
case 'e': //--exist case 'e': //--exist
{ {
// cout<<"(main):received option --exist"<<endl; // cout<<"(main):received option --exist"<<endl;
uniset_init(argc,argv,conffile); auto conf = uniset_init(argc,argv,conffile);
UInterface ui(conf); UInterface ui(conf);
verb = true; verb = true;
Command cmd=Exist; Command cmd=Exist;
ObjectRepository* rep = new ObjectRepository(conf); ObjectRepository* rep = new ObjectRepository(conf);
commandToAll(conf->getServicesSection(), rep, (Command)cmd); commandToAll(conf->getServicesSection(), rep, (Command)cmd);
...@@ -213,7 +213,7 @@ int main(int argc, char** argv) ...@@ -213,7 +213,7 @@ int main(int argc, char** argv)
case 's': //--start case 's': //--start
{ {
// cout<<"(main):received option --start"<<endl; // cout<<"(main):received option --start"<<endl;
uniset_init(argc,argv,conffile); auto conf = uniset_init(argc,argv,conffile);
UInterface ui(conf); UInterface ui(conf);
Command cmd=StartUp; Command cmd=StartUp;
...@@ -227,7 +227,7 @@ int main(int argc, char** argv) ...@@ -227,7 +227,7 @@ int main(int argc, char** argv)
case 'r': //--configure case 'r': //--configure
{ {
uniset_init(argc,argv,conffile); auto conf = uniset_init(argc,argv,conffile);
UInterface ui(conf); UInterface ui(conf);
return configure(optarg,ui); return configure(optarg,ui);
} }
...@@ -236,7 +236,7 @@ int main(int argc, char** argv) ...@@ -236,7 +236,7 @@ int main(int argc, char** argv)
case 'f': //--finish case 'f': //--finish
{ {
// cout<<"(main):received option --finish"<<endl; // cout<<"(main):received option --finish"<<endl;
uniset_init(argc,argv,conffile); auto conf = uniset_init(argc,argv,conffile);
UInterface ui(conf); UInterface ui(conf);
Command cmd=Finish; Command cmd=Finish;
...@@ -252,7 +252,7 @@ int main(int argc, char** argv) ...@@ -252,7 +252,7 @@ int main(int argc, char** argv)
case 'l': //--logrotate case 'l': //--logrotate
{ {
uniset_init(argc,argv,conffile); auto conf = uniset_init(argc,argv,conffile);
UInterface ui(conf); UInterface ui(conf);
return logRotate(optarg, ui); return logRotate(optarg, ui);
} }
...@@ -261,7 +261,7 @@ int main(int argc, char** argv) ...@@ -261,7 +261,7 @@ int main(int argc, char** argv)
case 'y': //--getCalibrate case 'y': //--getCalibrate
{ {
// cout<<"(main):received option --getCalibrate='"<<optarg<<"'"<<endl; // cout<<"(main):received option --getCalibrate='"<<optarg<<"'"<<endl;
uniset_init(argc,argv,conffile); auto conf = uniset_init(argc,argv,conffile);
UInterface ui(conf); UInterface ui(conf);
return getCalibrate(optarg, ui); return getCalibrate(optarg, ui);
} }
...@@ -270,7 +270,7 @@ int main(int argc, char** argv) ...@@ -270,7 +270,7 @@ int main(int argc, char** argv)
case 'u': //--foldUp case 'u': //--foldUp
{ {
// cout<<"(main):received option --foldUp"<<endl; // cout<<"(main):received option --foldUp"<<endl;
uniset_init(argc,argv,conffile); auto conf = uniset_init(argc,argv,conffile);
UInterface ui(conf); UInterface ui(conf);
Command cmd=FoldUp; Command cmd=FoldUp;
...@@ -449,7 +449,7 @@ static bool commandToAll(const string& section, ObjectRepository *rep, Command c ...@@ -449,7 +449,7 @@ static bool commandToAll(const string& section, ObjectRepository *rep, Command c
} }
// ============================================================================================== // ==============================================================================================
static void createSections( UniSetTypes::Configuration* rconf ) static void createSections( const std::shared_ptr<UniSetTypes::Configuration> rconf )
{ {
ObjectRepositoryFactory repf(rconf); ObjectRepositoryFactory repf(rconf);
...@@ -469,7 +469,7 @@ int omap() ...@@ -469,7 +469,7 @@ int omap()
{ {
cout.setf(ios::left, ios::adjustfield); cout.setf(ios::left, ios::adjustfield);
cout << "========================== ObjectsMap =================================\n"; cout << "========================== ObjectsMap =================================\n";
conf->oind->printMap(cout); uniset_conf()->oind->printMap(cout);
cout << "==========================================================================\n"; cout << "==========================================================================\n";
} }
catch( Exception& ex ) catch( Exception& ex )
...@@ -482,9 +482,10 @@ int omap() ...@@ -482,9 +482,10 @@ int omap()
} }
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
int setValue( const string& args, UInterface &ui, Configuration* conf ) int setValue( const string& args, UInterface &ui )
{ {
int err = 0; int err = 0;
auto conf = ui.getConf();
typedef std::list<UniSetTypes::ParamSInfo> SList; typedef std::list<UniSetTypes::ParamSInfo> SList;
SList sl = UniSetTypes::getSInfoList(args, conf); SList sl = UniSetTypes::getSInfoList(args, conf);
...@@ -536,12 +537,13 @@ int setValue( const string& args, UInterface &ui, Configuration* conf ) ...@@ -536,12 +537,13 @@ int setValue( const string& args, UInterface &ui, Configuration* conf )
} }
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
int getValue( const string& args, UInterface &ui, Configuration* conf ) int getValue( const string& args, UInterface &ui )
{ {
int err = 0; int err = 0;
auto conf = ui.getConf();
typedef std::list<UniSetTypes::ParamSInfo> SList; typedef std::list<UniSetTypes::ParamSInfo> SList;
SList sl = UniSetTypes::getSInfoList( args, UniSetTypes::conf ); SList sl = UniSetTypes::getSInfoList( args, conf );
if( verb ) if( verb )
cout << "====== getValue ======" << endl; cout << "====== getValue ======" << endl;
...@@ -594,8 +596,9 @@ int getValue( const string& args, UInterface &ui, Configuration* conf ) ...@@ -594,8 +596,9 @@ int getValue( const string& args, UInterface &ui, Configuration* conf )
int getCalibrate( const std::string& args, UInterface &ui ) int getCalibrate( const std::string& args, UInterface &ui )
{ {
int err = 0; int err = 0;
auto conf = ui.getConf();
typedef std::list<UniSetTypes::ParamSInfo> SList; typedef std::list<UniSetTypes::ParamSInfo> SList;
SList sl = UniSetTypes::getSInfoList( args, UniSetTypes::conf ); SList sl = UniSetTypes::getSInfoList( args, conf );
if( verb ) if( verb )
cout << "====== getCalibrate ======" << endl; cout << "====== getCalibrate ======" << endl;
...@@ -635,8 +638,9 @@ int getCalibrate( const std::string& args, UInterface &ui ) ...@@ -635,8 +638,9 @@ int getCalibrate( const std::string& args, UInterface &ui )
int getRawValue( const std::string& args, UInterface &ui ) int getRawValue( const std::string& args, UInterface &ui )
{ {
int err = 0; int err = 0;
auto conf = ui.getConf();
typedef std::list<UniSetTypes::ParamSInfo> SList; typedef std::list<UniSetTypes::ParamSInfo> SList;
SList sl = UniSetTypes::getSInfoList( args, UniSetTypes::conf ); SList sl = UniSetTypes::getSInfoList( args, conf );
if( verb ) if( verb )
cout << "====== getRawValue ======" << endl; cout << "====== getRawValue ======" << endl;
for( SList::iterator it=sl.begin(); it!=sl.end(); ++it ) for( SList::iterator it=sl.begin(); it!=sl.end(); ++it )
...@@ -668,6 +672,7 @@ int getRawValue( const std::string& args, UInterface &ui ) ...@@ -668,6 +672,7 @@ int getRawValue( const std::string& args, UInterface &ui )
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
int logRotate( const string& arg, UInterface &ui ) int logRotate( const string& arg, UInterface &ui )
{ {
auto conf = ui.getConf();
// посылка всем // посылка всем
if( arg.empty() || (arg.c_str())[0]!='-' ) if( arg.empty() || (arg.c_str())[0]!='-' )
{ {
...@@ -699,6 +704,7 @@ int logRotate( const string& arg, UInterface &ui ) ...@@ -699,6 +704,7 @@ int logRotate( const string& arg, UInterface &ui )
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
int configure( const string& arg, UInterface &ui ) int configure( const string& arg, UInterface &ui )
{ {
auto conf = ui.getConf();
// посылка всем // посылка всем
if( arg.empty() || (arg.c_str())[0]!='-' ) if( arg.empty() || (arg.c_str())[0]!='-' )
{ {
...@@ -732,7 +738,7 @@ int oinfo( const string& arg, UInterface &ui ) ...@@ -732,7 +738,7 @@ int oinfo( const string& arg, UInterface &ui )
UniSetTypes::ObjectId oid(uni_atoi(arg)); UniSetTypes::ObjectId oid(uni_atoi(arg));
if( oid==0 ) if( oid==0 )
{ {
if( verb ) if( verb )
cout << "(oinfo): Не задан OID!"<< endl; cout << "(oinfo): Не задан OID!"<< endl;
return 1; return 1;
} }
......
...@@ -36,7 +36,7 @@ int main(int argc, char** argv) ...@@ -36,7 +36,7 @@ int main(int argc, char** argv)
return 0; return 0;
} }
uniset_init(argc,argv,"configure.xml"); auto conf = uniset_init(argc,argv,"configure.xml");
// определяем ID объекта // определяем ID объекта
......
...@@ -36,8 +36,8 @@ int main( int argc, char **argv ) ...@@ -36,8 +36,8 @@ int main( int argc, char **argv )
} }
// ------------------------------------- // -------------------------------------
uniset_init(argc, argv, "configure.xml" ); auto conf = uniset_init(argc, argv, "configure.xml" );
UInterface ui; UInterface ui(conf);
string sid(conf->getArgParam("--sid")); string sid(conf->getArgParam("--sid"));
if( sid.empty() ) if( sid.empty() )
...@@ -46,7 +46,7 @@ int main( int argc, char **argv ) ...@@ -46,7 +46,7 @@ int main( int argc, char **argv )
return 1; return 1;
} }
std::list<UniSetTypes::ParamSInfo> lst = UniSetTypes::getSInfoList(sid,UniSetTypes::conf); std::list<UniSetTypes::ParamSInfo> lst = UniSetTypes::getSInfoList(sid,conf);
if( lst.empty() ) if( lst.empty() )
{ {
......
...@@ -19,7 +19,7 @@ int main( int argc, const char **argv ) ...@@ -19,7 +19,7 @@ int main( int argc, const char **argv )
return 0; return 0;
} }
uniset_init(argc,argv,"configure.xml"); auto conf = uniset_init(argc,argv,"configure.xml");
ObjectId ID(DefaultObjectId); ObjectId ID(DefaultObjectId);
string name = conf->getArgParam("--name", "TestProc"); string name = conf->getArgParam("--name", "TestProc");
......
...@@ -21,7 +21,7 @@ int main(int argc, const char **argv) ...@@ -21,7 +21,7 @@ int main(int argc, const char **argv)
return 0; return 0;
} }
uniset_init(argc,argv,"configure.xml"); auto conf = uniset_init(argc,argv,"configure.xml");
bool fullname = false; bool fullname = false;
if( findArgParam("--fullname",conf->getArgc(),conf->getArgv()) != -1 ) if( findArgParam("--fullname",conf->getArgc(),conf->getArgv()) != -1 )
......
...@@ -51,10 +51,10 @@ class <xsl:value-of select="$CLASSNAME"/>_SK: ...@@ -51,10 +51,10 @@ class <xsl:value-of select="$CLASSNAME"/>_SK:
{ {
public: public:
<xsl:if test="not(normalize-space($OID))=''"> <xsl:if test="not(normalize-space($OID))=''">
<xsl:value-of select="$CLASSNAME"/>_SK( UniSetTypes::ObjectId id = UniSetTypes::conf->getObjectID("<xsl:value-of select="$OID"/>"), xmlNode* node=UniSetTypes::conf->getNode("<xsl:value-of select="normalize-space($OID)"/>"), const string&amp; argprefix="" ); <xsl:value-of select="$CLASSNAME"/>_SK( UniSetTypes::ObjectId id = UniSetTypes::uniset_conf()->getObjectID("<xsl:value-of select="$OID"/>"), xmlNode* node=UniSetTypes::uniset_conf()->getNode("<xsl:value-of select="normalize-space($OID)"/>"), const string&amp; argprefix="" );
</xsl:if> </xsl:if>
<xsl:if test="normalize-space($OID)=''"> <xsl:if test="normalize-space($OID)=''">
<xsl:value-of select="$CLASSNAME"/>_SK( UniSetTypes::ObjectId id, xmlNode* node=UniSetTypes::conf->getNode("<xsl:value-of select="normalize-space($OID)"/>") ); <xsl:value-of select="$CLASSNAME"/>_SK( UniSetTypes::ObjectId id, xmlNode* node=UniSetTypes::uniset_conf()->getNode("<xsl:value-of select="normalize-space($OID)"/>") );
</xsl:if> </xsl:if>
<xsl:value-of select="$CLASSNAME"/>_SK(); <xsl:value-of select="$CLASSNAME"/>_SK();
......
...@@ -52,10 +52,10 @@ class <xsl:value-of select="$CLASSNAME"/>_SK: ...@@ -52,10 +52,10 @@ class <xsl:value-of select="$CLASSNAME"/>_SK:
{ {
public: public:
<xsl:if test="not(normalize-space($OID))=''"> <xsl:if test="not(normalize-space($OID))=''">
<xsl:value-of select="$CLASSNAME"/>_SK( UniSetTypes::ObjectId id = conf->getObjectID("<xsl:value-of select="$OID"/>"), xmlNode* node=UniSetTypes::conf->getNode("<xsl:value-of select="normalize-space($CNAME)"/>"), const std::string&amp; argprefix="<xsl:value-of select="normalize-space($ARGPREFIX)"/>" ); <xsl:value-of select="$CLASSNAME"/>_SK( UniSetTypes::ObjectId id = UniSetTypes::uniset_conf()->getObjectID("<xsl:value-of select="$OID"/>"), xmlNode* node=UniSetTypes::uniset_conf()->getNode("<xsl:value-of select="normalize-space($CNAME)"/>"), const std::string&amp; argprefix="<xsl:value-of select="normalize-space($ARGPREFIX)"/>" );
</xsl:if> </xsl:if>
<xsl:if test="normalize-space($OID)=''"> <xsl:if test="normalize-space($OID)=''">
<xsl:value-of select="$CLASSNAME"/>_SK( UniSetTypes::ObjectId id, xmlNode* node=UniSetTypes::conf->getNode("<xsl:value-of select="normalize-space($CNAME)"/>"), const std::string&amp; argprefix="<xsl:value-of select="normalize-space($ARGPREFIX)"/>" ); <xsl:value-of select="$CLASSNAME"/>_SK( UniSetTypes::ObjectId id, xmlNode* node=UniSetTypes::uniset_conf()->getNode("<xsl:value-of select="normalize-space($CNAME)"/>"), const std::string&amp; argprefix="<xsl:value-of select="normalize-space($ARGPREFIX)"/>" );
</xsl:if> </xsl:if>
<xsl:value-of select="$CLASSNAME"/>_SK(); <xsl:value-of select="$CLASSNAME"/>_SK();
virtual ~<xsl:value-of select="$CLASSNAME"/>_SK(); virtual ~<xsl:value-of select="$CLASSNAME"/>_SK();
......
...@@ -50,9 +50,7 @@ int main( int argc,char* argv[] ) ...@@ -50,9 +50,7 @@ int main( int argc,char* argv[] )
try try
{ {
string confile = UniSetTypes::getArgParam( "--confile", argc, argv, "configure.xml" ); auto conf = uniset_init(argc, argv);
conf = new Configuration(argc, argv,confile);
// определяем ID объекта // определяем ID объекта
ObjectId ID(DefaultObjectId); ObjectId ID(DefaultObjectId);
...@@ -74,7 +72,7 @@ int main( int argc,char* argv[] ) ...@@ -74,7 +72,7 @@ int main( int argc,char* argv[] )
string logname( conf->getLogDir() + logfilename ); string logname( conf->getLogDir() + logfilename );
obj.mylog.logFile( logname.c_str() ); obj.mylog.logFile( logname.c_str() );
UniSetActivator* act = UniSetActivator::Instance(); auto act = UniSetActivator::Instance();
act-&gt;addObject(static_cast&lt;class UniSetObject*&gt;(&amp;obj)); act-&gt;addObject(static_cast&lt;class UniSetObject*&gt;(&amp;obj));
SystemMessage sm(SystemMessage::StartUp); SystemMessage sm(SystemMessage::StartUp);
......
...@@ -52,9 +52,7 @@ int main( int argc, const char** argv ) ...@@ -52,9 +52,7 @@ int main( int argc, const char** argv )
try try
{ {
string confile = UniSetTypes::getArgParam( "--confile", argc, argv, "configure.xml" ); auto conf = uniset_init(argc, argv);
conf = new Configuration(argc, argv, confile);
<xsl:if test="not(normalize-space(//@OID))=''"> <xsl:if test="not(normalize-space(//@OID))=''">
<xsl:value-of select="$CLASSNAME"/> obj; <xsl:value-of select="$CLASSNAME"/> obj;
...@@ -82,7 +80,7 @@ int main( int argc, const char** argv ) ...@@ -82,7 +80,7 @@ int main( int argc, const char** argv )
</xsl:if> </xsl:if>
UniSetActivator* act = UniSetActivator::Instance(); auto act = UniSetActivator::Instance();
act-&gt;addObject(static_cast&lt;class UniSetObject*&gt;(&amp;obj)); act-&gt;addObject(static_cast&lt;class UniSetObject*&gt;(&amp;obj));
SystemMessage sm(SystemMessage::StartUp); SystemMessage sm(SystemMessage::StartUp);
......
...@@ -9,7 +9,7 @@ int main( int argc, const char **argv ) ...@@ -9,7 +9,7 @@ int main( int argc, const char **argv )
{ {
try try
{ {
uniset_init(argc, argv); auto conf = uniset_init(argc, argv);
string logfilename = conf->getArgParam("--logfile", "Skel.log"); string logfilename = conf->getArgParam("--logfile", "Skel.log");
string logname( conf->getLogDir() + logfilename ); string logname( conf->getLogDir() + logfilename );
...@@ -17,7 +17,7 @@ int main( int argc, const char **argv ) ...@@ -17,7 +17,7 @@ int main( int argc, const char **argv )
ulog.logFile( logname.c_str() ); ulog.logFile( logname.c_str() );
// conf->initDebug(dlog,"dlog"); // conf->initDebug(dlog,"dlog");
UniSetActivator act; auto act = UniSetActivator::Instance();
xmlNode* cnode = conf->getNode("Skel"); xmlNode* cnode = conf->getNode("Skel");
if( cnode == NULL ) if( cnode == NULL )
{ {
...@@ -35,7 +35,7 @@ int main( int argc, const char **argv ) ...@@ -35,7 +35,7 @@ int main( int argc, const char **argv )
ulog << "(Skel::main): -------------- Skel START -------------------------\n\n"; ulog << "(Skel::main): -------------- Skel START -------------------------\n\n";
dlog << "\n\n\n"; dlog << "\n\n\n";
dlog << "(Skel::main): -------------- Skel START -------------------------\n\n"; dlog << "(Skel::main): -------------- Skel START -------------------------\n\n";
act.run(false); act->run(false);
} }
catch(SystemError& err) catch(SystemError& err)
{ {
......
...@@ -8,7 +8,7 @@ class Skel: ...@@ -8,7 +8,7 @@ class Skel:
public Skel_SK public Skel_SK
{ {
public: public:
Skel( UniSetTypes::ObjectId id, xmlNode* confnode = UniSetTypes::conf->getNode("Skel") ); Skel( UniSetTypes::ObjectId id, xmlNode* confnode = UniSetTypes::uniset_conf()->getNode("Skel") );
virtual ~Skel(); virtual ~Skel();
protected: protected:
......
...@@ -8,7 +8,7 @@ class TestGen: ...@@ -8,7 +8,7 @@ class TestGen:
public TestGen_SK public TestGen_SK
{ {
public: public:
TestGen( UniSetTypes::ObjectId id, xmlNode* confnode = UniSetTypes::conf->getNode("TestGen") ); TestGen( UniSetTypes::ObjectId id, xmlNode* confnode = UniSetTypes::uniset_conf()->getNode("TestGen") );
virtual ~TestGen(); virtual ~TestGen();
......
...@@ -8,7 +8,7 @@ class TestGenAlone: ...@@ -8,7 +8,7 @@ class TestGenAlone:
public TestGenAlone_SK public TestGenAlone_SK
{ {
public: public:
TestGenAlone( UniSetTypes::ObjectId id, xmlNode* confnode = UniSetTypes::conf->getNode("TestGenAlone") ); TestGenAlone( UniSetTypes::ObjectId id, xmlNode* confnode = UniSetTypes::uniset_conf()->getNode("TestGenAlone") );
virtual ~TestGenAlone(); virtual ~TestGenAlone();
......
...@@ -59,7 +59,7 @@ DBServer_MySQL::DBServer_MySQL(ObjectId id): ...@@ -59,7 +59,7 @@ DBServer_MySQL::DBServer_MySQL(ObjectId id):
} }
DBServer_MySQL::DBServer_MySQL(): DBServer_MySQL::DBServer_MySQL():
DBServer(conf->getDBServer()), DBServer(uniset_conf()->getDBServer()),
db(new MySQLInterface()), db(new MySQLInterface()),
PingTime(300000), PingTime(300000),
ReconnectTime(180000), ReconnectTime(180000),
...@@ -261,11 +261,13 @@ void DBServer_MySQL::init_dbserver() ...@@ -261,11 +261,13 @@ void DBServer_MySQL::init_dbserver()
if( connect_ok ) if( connect_ok )
{ {
initDBTableMap(tblMap); initDBTableMap(tblMap);
initDB(db); initDB(db);
return; return;
} }
auto conf = uniset_conf();
if( conf->getDBServer() == UniSetTypes::DefaultObjectId ) if( conf->getDBServer() == UniSetTypes::DefaultObjectId )
{ {
ostringstream msg; ostringstream msg;
...@@ -335,6 +337,8 @@ void DBServer_MySQL::init_dbserver() ...@@ -335,6 +337,8 @@ void DBServer_MySQL::init_dbserver()
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
void DBServer_MySQL::createTables( MySQLInterface *db ) void DBServer_MySQL::createTables( MySQLInterface *db )
{ {
auto conf = uniset_conf();
UniXML::iterator it( conf->getNode("Tables") ); UniXML::iterator it( conf->getNode("Tables") );
if(!it) if(!it)
{ {
......
...@@ -106,8 +106,8 @@ bool MySQLInterface::query_ok( const string& q ) ...@@ -106,8 +106,8 @@ bool MySQLInterface::query_ok( const string& q )
MYSQL_RES* res = mysql_store_result(mysql); // _use_result - некорректно работает с _num_rows MYSQL_RES* res = mysql_store_result(mysql); // _use_result - некорректно работает с _num_rows
if( !res || mysql_num_rows(res)==0 ) if( !res || mysql_num_rows(res)==0 )
{ {
if( res ) if( res )
mysql_free_result(res); mysql_free_result(res);
return false; return false;
} }
......
...@@ -21,7 +21,7 @@ int main(int argc, char** argv) ...@@ -21,7 +21,7 @@ int main(int argc, char** argv)
return 0; return 0;
} }
uniset_init(argc,argv,"configure.xml"); auto conf = uniset_init(argc,argv,"configure.xml");
ObjectId ID = conf->getDBServer(); ObjectId ID = conf->getDBServer();
......
...@@ -8,9 +8,9 @@ using namespace std; ...@@ -8,9 +8,9 @@ using namespace std;
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
std::string dbname("test-db"); std::string dbname("test-db");
if( argc > 1 ) if( argc > 1 )
dbname = string(argv[1]); dbname = string(argv[1]);
try try
{ {
......
...@@ -57,7 +57,7 @@ DBServer_SQLite::DBServer_SQLite( ObjectId id ): ...@@ -57,7 +57,7 @@ DBServer_SQLite::DBServer_SQLite( ObjectId id ):
} }
DBServer_SQLite::DBServer_SQLite(): DBServer_SQLite::DBServer_SQLite():
DBServer(conf->getDBServer()), DBServer(uniset_conf()->getDBServer()),
db(new SQLiteInterface()), db(new SQLiteInterface()),
PingTime(300000), PingTime(300000),
ReconnectTime(180000), ReconnectTime(180000),
...@@ -251,6 +251,8 @@ void DBServer_SQLite::init_dbserver() ...@@ -251,6 +251,8 @@ void DBServer_SQLite::init_dbserver()
return; return;
} }
auto conf = uniset_conf();
if( conf->getDBServer() == UniSetTypes::DefaultObjectId ) if( conf->getDBServer() == UniSetTypes::DefaultObjectId )
{ {
ostringstream msg; ostringstream msg;
...@@ -313,6 +315,7 @@ void DBServer_SQLite::init_dbserver() ...@@ -313,6 +315,7 @@ void DBServer_SQLite::init_dbserver()
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
void DBServer_SQLite::createTables( SQLiteInterface *db ) void DBServer_SQLite::createTables( SQLiteInterface *db )
{ {
auto conf = uniset_conf();
UniXML::iterator it( conf->getNode("Tables") ); UniXML::iterator it( conf->getNode("Tables") );
if(!it) if(!it)
{ {
......
...@@ -254,11 +254,11 @@ SQLiteResult::SQLiteResult( sqlite3_stmt* s, bool finalize ) ...@@ -254,11 +254,11 @@ SQLiteResult::SQLiteResult( sqlite3_stmt* s, bool finalize )
int n = sqlite3_data_count(s); int n = sqlite3_data_count(s);
if( n<=0 ) if( n<=0 )
{ {
if( finalize ) if( finalize )
sqlite3_finalize(s); sqlite3_finalize(s);
return; return;
} }
COL c; COL c;
for( unsigned int i=0; i<n; i++ ) for( unsigned int i=0; i<n; i++ )
......
...@@ -21,7 +21,7 @@ int main(int argc, char** argv) ...@@ -21,7 +21,7 @@ int main(int argc, char** argv)
return 0; return 0;
} }
uniset_init(argc,argv,"configure.xml"); auto conf = uniset_init(argc,argv,"configure.xml");
ObjectId ID = conf->getDBServer(); ObjectId ID = conf->getDBServer();
......
...@@ -10,7 +10,7 @@ using namespace UniSetExtensions; ...@@ -10,7 +10,7 @@ using namespace UniSetExtensions;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
std::ostream& operator<<( std::ostream& os, IOControl::IOInfo& inf ) std::ostream& operator<<( std::ostream& os, IOControl::IOInfo& inf )
{ {
os << "(" << inf.si.id << ")" << conf->oind->getMapName(inf.si.id) os << "(" << inf.si.id << ")" << uniset_conf()->oind->getMapName(inf.si.id)
<< " card=" << inf.ncard << " channel=" << inf.channel << " subdev=" << inf.subdev << " card=" << inf.ncard << " channel=" << inf.channel << " subdev=" << inf.subdev
<< " aref=" << inf.aref << " range=" << inf.range << " aref=" << inf.aref << " range=" << inf.range
<< " default=" << inf.defval << " safety=" << inf.safety; << " default=" << inf.defval << " safety=" << inf.safety;
...@@ -50,6 +50,8 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID, ...@@ -50,6 +50,8 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID,
testmode(tmNone), testmode(tmNone),
prev_testmode(tmNone) prev_testmode(tmNone)
{ {
auto conf = uniset_conf();
string cname = conf->getArgParam("--"+prefix+"-confnode",myname); string cname = conf->getArgParam("--"+prefix+"-confnode",myname);
cnode = conf->getNode(cname); cnode = conf->getNode(cname);
if( cnode == NULL ) if( cnode == NULL )
...@@ -288,7 +290,7 @@ void IOControl::execute() ...@@ -288,7 +290,7 @@ void IOControl::execute()
// чтение параметров по входам-выходам // чтение параметров по входам-выходам
initIOCard(); initIOCard();
bool skip_iout = conf->getArgInt("--"+prefix+"-skip-init-output"); bool skip_iout = uniset_conf()->getArgInt("--"+prefix+"-skip-init-output");
if( !skip_iout ) if( !skip_iout )
initOutputs(); initOutputs();
...@@ -646,7 +648,7 @@ void IOControl::readConfiguration() ...@@ -646,7 +648,7 @@ void IOControl::readConfiguration()
{ {
readconf_ok = false; readconf_ok = false;
xmlNode* root = conf->getXMLSensorsSection(); xmlNode* root = uniset_conf()->getXMLSensorsSection();
if(!root) if(!root)
{ {
ostringstream err; ostringstream err;
...@@ -716,39 +718,39 @@ bool IOControl::initIOItem( UniXML::iterator& it ) ...@@ -716,39 +718,39 @@ bool IOControl::initIOItem( UniXML::iterator& it )
else else
inf.subdev = DefaultSubdev; inf.subdev = DefaultSubdev;
} }
std::string prop_prefix( prefix+"_" ); std::string prop_prefix( prefix+"_" );
if( !IOBase::initItem(&inf,it,shm,prop_prefix,false,&dlog,myname,filtersize,filterT) ) if( !IOBase::initItem(&inf,it,shm,prop_prefix,false,&dlog,myname,filtersize,filterT) )
return false; return false;
// если вектор уже заполнен // если вектор уже заполнен
// то увеличиваем его на 30 элементов (с запасом) // то увеличиваем его на 30 элементов (с запасом)
// после инициализации делается resize // после инициализации делается resize
// под реальное количество // под реальное количество
if( maxItem >= iomap.size() ) if( maxItem >= iomap.size() )
iomap.resize(maxItem+30); iomap.resize(maxItem+30);
int prior = IOBase::initIntProp(it,"iopriority",prop_prefix,false); int prior = IOBase::initIntProp(it,"iopriority",prop_prefix,false);
if( prior > 0 ) if( prior > 0 )
{ {
IOPriority p(prior,maxItem); IOPriority p(prior,maxItem);
pmap.push_back(p); pmap.push_back(p);
if( dlog.debugging(Debug::LEVEL3) ) if( dlog.debugging(Debug::LEVEL3) )
dlog[Debug::LEVEL3] << myname << "(readItem): add to priority list: " << dlog[Debug::LEVEL3] << myname << "(readItem): add to priority list: " <<
it.getProp("name") it.getProp("name")
<< " priority=" << prior << endl; << " priority=" << prior << endl;
} }
// значит это пороговый датчик.. // значит это пороговый датчик..
if( inf.t_ai != DefaultObjectId ) if( inf.t_ai != DefaultObjectId )
{ {
iomap[maxItem++] = std::move(inf); iomap[maxItem++] = std::move(inf);
if( dlog.debugging(Debug::LEVEL3) ) if( dlog.debugging(Debug::LEVEL3) )
dlog[Debug::LEVEL3] << myname << "(readItem): add threshold '" << it.getProp("name") dlog[Debug::LEVEL3] << myname << "(readItem): add threshold '" << it.getProp("name")
<< " for '" << conf->oind->getNameById(inf.t_ai) << endl; << " for '" << uniset_conf()->oind->getNameById(inf.t_ai) << endl;
return true; return true;
} }
inf.channel = IOBase::initIntProp(it,"channel",prop_prefix,false); inf.channel = IOBase::initIntProp(it,"channel",prop_prefix,false);
if( inf.channel < 0 || inf.channel > 32 ) if( inf.channel < 0 || inf.channel > 32 )
{ {
...@@ -1105,7 +1107,7 @@ void IOControl::check_testlamp() ...@@ -1105,7 +1107,7 @@ void IOControl::check_testlamp()
} }
catch(...) catch(...)
{ {
dcrit << myname << "(check_testlamp): catch ..." << endl; dcrit << myname << "(check_testlamp): catch ..." << endl;
} }
} }
...@@ -1114,6 +1116,7 @@ IOControl* IOControl::init_iocontrol( int argc, const char* const* argv, ...@@ -1114,6 +1116,7 @@ IOControl* IOControl::init_iocontrol( int argc, const char* const* argv,
UniSetTypes::ObjectId icID, SharedMemory* ic, UniSetTypes::ObjectId icID, SharedMemory* ic,
const std::string& prefix ) const std::string& prefix )
{ {
auto conf = uniset_conf();
string name = conf->getArgParam("--"+prefix+"-name","IOControl1"); string name = conf->getArgParam("--"+prefix+"-name","IOControl1");
if( name.empty() ) if( name.empty() )
{ {
...@@ -1474,6 +1477,8 @@ void IOControl::waitSM() ...@@ -1474,6 +1477,8 @@ void IOControl::waitSM()
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void IOControl::buildCardsList() void IOControl::buildCardsList()
{ {
auto conf = uniset_conf();
xmlNode* nnode = conf->getXMLNodesSection(); xmlNode* nnode = conf->getXMLNodesSection();
if( !nnode ) if( !nnode )
{ {
...@@ -1481,7 +1486,7 @@ void IOControl::buildCardsList() ...@@ -1481,7 +1486,7 @@ void IOControl::buildCardsList()
return; return;
} }
const std::shared_ptr<UniXML> xml = conf->getConfXML(); auto xml = conf->getConfXML();
if( !xml ) if( !xml )
{ {
dwarn << myname << "(buildCardsList): xml=NULL?!" << endl; dwarn << myname << "(buildCardsList): xml=NULL?!" << endl;
......
...@@ -21,8 +21,7 @@ int main(int argc, const char **argv) ...@@ -21,8 +21,7 @@ int main(int argc, const char **argv)
try try
{ {
string confile = UniSetTypes::getArgParam( "--confile", argc, argv, "configure.xml" ); auto conf = uniset_init(argc, argv);
conf = new Configuration(argc, argv, confile);
conf->initDebug(dlog,"dlog"); conf->initDebug(dlog,"dlog");
string logfilename = conf->getArgParam("--io-logfile","iocontrol.log"); string logfilename = conf->getArgParam("--io-logfile","iocontrol.log");
......
...@@ -11,6 +11,7 @@ using namespace UniSetExtensions; ...@@ -11,6 +11,7 @@ using namespace UniSetExtensions;
LProcessor::LProcessor( const std::string& name ): LProcessor::LProcessor( const std::string& name ):
logname(name) logname(name)
{ {
auto conf = uniset_conf();
sleepTime = conf->getArgPInt("--sleepTime", 200); sleepTime = conf->getArgPInt("--sleepTime", 200);
smReadyTimeout = conf->getArgInt("--sm-ready-timeout",""); smReadyTimeout = conf->getArgInt("--sm-ready-timeout","");
if( smReadyTimeout == 0 ) if( smReadyTimeout == 0 )
...@@ -58,6 +59,8 @@ void LProcessor::step() ...@@ -58,6 +59,8 @@ void LProcessor::step()
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void LProcessor::build( const string& lfile ) void LProcessor::build( const string& lfile )
{ {
auto conf = uniset_conf();
sch.read(lfile); sch.read(lfile);
// составляем карту внешних входов // составляем карту внешних входов
......
...@@ -11,6 +11,8 @@ PassiveLProcessor::PassiveLProcessor( std::string lfile, UniSetTypes::ObjectId o ...@@ -11,6 +11,8 @@ PassiveLProcessor::PassiveLProcessor( std::string lfile, UniSetTypes::ObjectId o
UniSetObject_LT(objId), UniSetObject_LT(objId),
shm(0) shm(0)
{ {
auto conf = uniset_conf();
logname = myname; logname = myname;
shm = new SMInterface(shmID,&(UniSetObject_LT::ui),objId,ic); shm = new SMInterface(shmID,&(UniSetObject_LT::ui),objId,ic);
build(lfile); build(lfile);
...@@ -28,7 +30,7 @@ PassiveLProcessor::PassiveLProcessor( std::string lfile, UniSetTypes::ObjectId o ...@@ -28,7 +30,7 @@ PassiveLProcessor::PassiveLProcessor( std::string lfile, UniSetTypes::ObjectId o
throw SystemError(err.str()); throw SystemError(err.str());
} }
int heartbeatTime = conf->getArgPInt("--" + prefix + "-heartbeat-time",conf->getHeartBeatTime()); int heartbeatTime = conf->getArgPInt("--" + prefix + "-heartbeat-time",conf->getHeartBeatTime());
if( heartbeatTime ) if( heartbeatTime )
ptHeartBeat.setTiming(heartbeatTime); ptHeartBeat.setTiming(heartbeatTime);
else else
......
...@@ -11,15 +11,14 @@ int main(int argc, const char **argv) ...@@ -11,15 +11,14 @@ int main(int argc, const char **argv)
{ {
try try
{ {
string confile=UniSetTypes::getArgParam("--confile",argc,argv,"configure.xml"); auto conf = uniset_init( argc, argv );
conf = new Configuration( argc, argv, confile );
string logfilename(conf->getArgParam("--logicproc-logfile")); string logfilename(conf->getArgParam("--logicproc-logfile"));
if( logfilename.empty() ) if( logfilename.empty() )
logfilename = "logicproc.log"; logfilename = "logicproc.log";
conf->initDebug(dlog,"dlog"); conf->initDebug(dlog,"dlog");
std::ostringstream logname; std::ostringstream logname;
string dir(conf->getLogDir()); string dir(conf->getLogDir());
logname << dir << logfilename; logname << dir << logfilename;
......
...@@ -13,8 +13,7 @@ int main(int argc, const char **argv) ...@@ -13,8 +13,7 @@ int main(int argc, const char **argv)
{ {
try try
{ {
string confile=UniSetTypes::getArgParam("--confile",argc,argv,"configure.xml"); auto conf = uniset_init( argc, argv );
conf = new Configuration( argc, argv, confile );
string logfilename(conf->getArgParam("--logicproc-logfile")); string logfilename(conf->getArgParam("--logicproc-logfile"));
if( logfilename.empty() ) if( logfilename.empty() )
......
...@@ -11,92 +11,92 @@ using namespace UniSetTypes; ...@@ -11,92 +11,92 @@ using namespace UniSetTypes;
TEST_CASE("Logic processor","[LogicProcessor]") TEST_CASE("Logic processor","[LogicProcessor]")
{ {
#if 0 #if 0
SECTION( "ShemaXML" ) SECTION( "ShemaXML" )
{ {
SchemaXML sch; SchemaXML sch;
sch.read("schema.xml"); sch.read("schema.xml");
CHECK( !sch.empty() ); CHECK( !sch.empty() );
} }
#endif #endif
SECTION( "TOR" ) SECTION( "TOR" )
{ {
TOR e("1",2); // элемент на два входа.. TOR e("1",2); // элемент на два входа..
REQUIRE( e.getOut() == 0 ); REQUIRE( e.getOut() == 0 );
e.setIn(1,true); e.setIn(1,true);
CHECK( e.getOut() ); CHECK( e.getOut() );
e.setIn(2,true); e.setIn(2,true);
CHECK( e.getOut() ); CHECK( e.getOut() );
e.setIn(1,false); e.setIn(1,false);
CHECK( e.getOut() ); CHECK( e.getOut() );
e.setIn(2,false); e.setIn(2,false);
CHECK_FALSE( e.getOut() ); CHECK_FALSE( e.getOut() );
e.setIn(3,true); // несуществующий вход.. e.setIn(3,true); // несуществующий вход..
CHECK_FALSE( e.getOut() ); CHECK_FALSE( e.getOut() );
} }
SECTION( "TAND" ) SECTION( "TAND" )
{ {
TAND e("1",2); // элемент на два входа.. TAND e("1",2); // элемент на два входа..
REQUIRE( e.getOut() == 0 ); REQUIRE( e.getOut() == 0 );
e.setIn(1,true); e.setIn(1,true);
CHECK_FALSE( e.getOut() ); CHECK_FALSE( e.getOut() );
e.setIn(2,true); e.setIn(2,true);
CHECK( e.getOut() ); CHECK( e.getOut() );
e.setIn(1,false); e.setIn(1,false);
CHECK_FALSE( e.getOut() ); CHECK_FALSE( e.getOut() );
e.setIn(2,false); e.setIn(2,false);
CHECK_FALSE( e.getOut() ); CHECK_FALSE( e.getOut() );
e.setIn(3,true); // несуществующий вход.. e.setIn(3,true); // несуществующий вход..
CHECK_FALSE( e.getOut() ); CHECK_FALSE( e.getOut() );
} }
SECTION( "TNOT" ) SECTION( "TNOT" )
{ {
TNOT e("1",false); TNOT e("1",false);
CHECK_FALSE( e.getOut() ); CHECK_FALSE( e.getOut() );
e.setIn(1,true); e.setIn(1,true);
CHECK_FALSE( e.getOut() ); CHECK_FALSE( e.getOut() );
e.setIn(1,false); e.setIn(1,false);
CHECK( e.getOut() ); CHECK( e.getOut() );
// other constructor // other constructor
TNOT e1("1",true); TNOT e1("1",true);
CHECK( e1.getOut() ); CHECK( e1.getOut() );
e1.setIn(1,true); e1.setIn(1,true);
CHECK_FALSE( e1.getOut() ); CHECK_FALSE( e1.getOut() );
e1.setIn(1,false); e1.setIn(1,false);
CHECK( e1.getOut() ); CHECK( e1.getOut() );
} }
SECTION( "TDelay" ) SECTION( "TDelay" )
{ {
TDelay e("1",50,1); TDelay e("1",50,1);
CHECK_FALSE( e.getOut() ); CHECK_FALSE( e.getOut() );
// ON DELAY // ON DELAY
e.setIn(1,true); e.setIn(1,true);
CHECK_FALSE( e.getOut() ); CHECK_FALSE( e.getOut() );
msleep(60); msleep(60);
e.tick(); e.tick();
CHECK( e.getOut() ); CHECK( e.getOut() );
msleep(60); msleep(60);
e.tick(); e.tick();
CHECK( e.getOut() ); CHECK( e.getOut() );
// OFF DELAY // OFF DELAY
e.setIn(1,false); e.setIn(1,false);
CHECK_FALSE( e.getOut() ); CHECK_FALSE( e.getOut() );
// delay 0 msek.. // delay 0 msek..
e.setDelay(0); e.setDelay(0);
e.setIn(1,true); e.setIn(1,true);
CHECK( e.getOut() ); CHECK( e.getOut() );
// delay < 0 === 0 // delay < 0 === 0
e.setIn(1,false); e.setIn(1,false);
e.setDelay(-10); e.setDelay(-10);
e.setIn(1,true); e.setIn(1,true);
CHECK( e.getOut() ); CHECK( e.getOut() );
} }
} }
...@@ -34,6 +34,7 @@ pollActivated(false) ...@@ -34,6 +34,7 @@ pollActivated(false)
if( objId == DefaultObjectId ) if( objId == DefaultObjectId )
throw UniSetTypes::SystemError("(MBExchange): objId=-1?!! Use --" + prefix + "-name" ); throw UniSetTypes::SystemError("(MBExchange): objId=-1?!! Use --" + prefix + "-name" );
auto conf = uniset_conf();
mutex_start.setName(myname + "_mutex_start"); mutex_start.setName(myname + "_mutex_start");
string conf_name(conf->getArgParam("--" + prefix + "-confnode",myname)); string conf_name(conf->getArgParam("--" + prefix + "-confnode",myname));
...@@ -188,7 +189,7 @@ MBExchange::~MBExchange() ...@@ -188,7 +189,7 @@ MBExchange::~MBExchange()
void MBExchange::waitSMReady() void MBExchange::waitSMReady()
{ {
// waiting for SM is ready... // waiting for SM is ready...
int ready_timeout = conf->getArgInt("--" + prefix +"-sm-ready-timeout","15000"); int ready_timeout = uniset_conf()->getArgInt("--" + prefix +"-sm-ready-timeout","15000");
if( ready_timeout == 0 ) if( ready_timeout == 0 )
ready_timeout = 15000; ready_timeout = 15000;
else if( ready_timeout < 0 ) else if( ready_timeout < 0 )
...@@ -254,7 +255,7 @@ void MBExchange::sigterm( int signo ) ...@@ -254,7 +255,7 @@ void MBExchange::sigterm( int signo )
void MBExchange::readConfiguration() void MBExchange::readConfiguration()
{ {
// readconf_ok = false; // readconf_ok = false;
xmlNode* root = conf->getXMLSensorsSection(); xmlNode* root = uniset_conf()->getXMLSensorsSection();
if(!root) if(!root)
{ {
ostringstream err; ostringstream err;
...@@ -527,6 +528,8 @@ void MBExchange::rtuQueryOptimization( RTUDeviceMap& m ) ...@@ -527,6 +528,8 @@ void MBExchange::rtuQueryOptimization( RTUDeviceMap& m )
//std::ostream& operator<<( std::ostream& os, MBExchange::PList& lst ) //std::ostream& operator<<( std::ostream& os, MBExchange::PList& lst )
std::ostream& MBExchange::print_plist( std::ostream& os, const MBExchange::PList& lst ) std::ostream& MBExchange::print_plist( std::ostream& os, const MBExchange::PList& lst )
{ {
auto conf = uniset_conf();
os << "[ "; os << "[ ";
for( auto it=lst.begin(); it!=lst.end(); ++it ) for( auto it=lst.begin(); it!=lst.end(); ++it )
os << "(" << it->si.id << ")" << conf->oind->getBaseName(conf->oind->getMapName(it->si.id)) << " "; os << "(" << it->si.id << ")" << conf->oind->getBaseName(conf->oind->getMapName(it->si.id)) << " ";
...@@ -1979,7 +1982,7 @@ bool MBExchange::initRegInfo( RegInfo* r, UniXML::iterator& it, MBExchange::RTU ...@@ -1979,7 +1982,7 @@ bool MBExchange::initRegInfo( RegInfo* r, UniXML::iterator& it, MBExchange::RTU
if( mbregFromID ) if( mbregFromID )
{ {
if( it.getProp("id").empty() ) if( it.getProp("id").empty() )
r->mbreg = conf->getSensorID(it.getProp("name")); r->mbreg = uniset_conf()->getSensorID(it.getProp("name"));
else else
r->mbreg = it.getIntProp("id"); r->mbreg = it.getIntProp("id");
} }
...@@ -2012,7 +2015,7 @@ bool MBExchange::initRegInfo( RegInfo* r, UniXML::iterator& it, MBExchange::RTU ...@@ -2012,7 +2015,7 @@ bool MBExchange::initRegInfo( RegInfo* r, UniXML::iterator& it, MBExchange::RTU
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
bool MBExchange::initRTUDevice( RTUDevice* d, UniXML::iterator& it ) bool MBExchange::initRTUDevice( RTUDevice* d, UniXML::iterator& it )
{ {
string mbtype(IOBase::initProp(it,"mbtype",prefix,false)); string mbtype(IOBase::initProp(it,"mbtype",prefix,false));
d->dtype = getDeviceType(mbtype); d->dtype = getDeviceType(mbtype);
if( d->dtype == dtUnknown ) if( d->dtype == dtUnknown )
...@@ -2370,6 +2373,7 @@ std::ostream& operator<<( std::ostream& os, const MBExchange::RSProperty& p ) ...@@ -2370,6 +2373,7 @@ std::ostream& operator<<( std::ostream& os, const MBExchange::RSProperty& p )
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void MBExchange::initDeviceList() void MBExchange::initDeviceList()
{ {
auto conf = uniset_conf();
xmlNode* respNode = 0; xmlNode* respNode = 0;
const std::shared_ptr<UniXML> xml = conf->getConfXML(); const std::shared_ptr<UniXML> xml = conf->getConfXML();
if( xml ) if( xml )
...@@ -2410,7 +2414,7 @@ bool MBExchange::initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniXM ...@@ -2410,7 +2414,7 @@ bool MBExchange::initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniXM
string s(it.getProp("respondSensor")); string s(it.getProp("respondSensor"));
if( !s.empty() ) if( !s.empty() )
{ {
d->second->resp_id = conf->getSensorID(s); d->second->resp_id = uniset_conf()->getSensorID(s);
if( d->second->resp_id == DefaultObjectId ) if( d->second->resp_id == DefaultObjectId )
{ {
dinfo << myname << "(initDeviceInfo): not found ID for respondSensor=" << s << endl; dinfo << myname << "(initDeviceInfo): not found ID for respondSensor=" << s << endl;
...@@ -2418,6 +2422,8 @@ bool MBExchange::initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniXM ...@@ -2418,6 +2422,8 @@ bool MBExchange::initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniXM
} }
} }
auto conf = uniset_conf();
string mod(it.getProp("modeSensor")); string mod(it.getProp("modeSensor"));
if( !mod.empty() ) if( !mod.empty() )
{ {
......
...@@ -20,6 +20,8 @@ pollThread(0) ...@@ -20,6 +20,8 @@ pollThread(0)
if( objId == DefaultObjectId ) if( objId == DefaultObjectId )
throw UniSetTypes::SystemError("(MBTCPMaster): objId=-1?!! Use --" + prefix + "-name" ); throw UniSetTypes::SystemError("(MBTCPMaster): objId=-1?!! Use --" + prefix + "-name" );
auto conf = uniset_conf();
// префикс для "свойств" - по умолчанию // префикс для "свойств" - по умолчанию
prop_prefix = "tcp_"; prop_prefix = "tcp_";
// если задано поле для "фильтрации" // если задано поле для "фильтрации"
...@@ -219,6 +221,7 @@ MBTCPMaster* MBTCPMaster::init_mbmaster( int argc, const char* const* argv, ...@@ -219,6 +221,7 @@ MBTCPMaster* MBTCPMaster::init_mbmaster( int argc, const char* const* argv,
UniSetTypes::ObjectId icID, SharedMemory* ic, UniSetTypes::ObjectId icID, SharedMemory* ic,
const std::string& prefix ) const std::string& prefix )
{ {
auto conf = uniset_conf();
string name = conf->getArgParam("--" + prefix + "-name","MBTCPMaster1"); string name = conf->getArgParam("--" + prefix + "-name","MBTCPMaster1");
if( name.empty() ) if( name.empty() )
{ {
......
...@@ -22,6 +22,8 @@ checkThread(0) ...@@ -22,6 +22,8 @@ checkThread(0)
if( objId == DefaultObjectId ) if( objId == DefaultObjectId )
throw UniSetTypes::SystemError("(MBTCPMultiMaster): objId=-1?!! Use --" + prefix + "-name" ); throw UniSetTypes::SystemError("(MBTCPMultiMaster): objId=-1?!! Use --" + prefix + "-name" );
auto conf = uniset_conf();
// префикс для "свойств" - по умолчанию // префикс для "свойств" - по умолчанию
prop_prefix = "tcp_"; prop_prefix = "tcp_";
// если задано поле для "фильтрации" // если задано поле для "фильтрации"
...@@ -365,6 +367,8 @@ MBTCPMultiMaster* MBTCPMultiMaster::init_mbmaster( int argc, const char* const* ...@@ -365,6 +367,8 @@ MBTCPMultiMaster* MBTCPMultiMaster::init_mbmaster( int argc, const char* const*
UniSetTypes::ObjectId icID, SharedMemory* ic, UniSetTypes::ObjectId icID, SharedMemory* ic,
const std::string& prefix ) const std::string& prefix )
{ {
auto conf = uniset_conf();
string name = conf->getArgParam("--" + prefix + "-name","MBTCPMultiMaster1"); string name = conf->getArgParam("--" + prefix + "-name","MBTCPMultiMaster1");
if( name.empty() ) if( name.empty() )
{ {
......
...@@ -20,6 +20,8 @@ rs_pre_clean(false) ...@@ -20,6 +20,8 @@ rs_pre_clean(false)
if( objId == DefaultObjectId ) if( objId == DefaultObjectId )
throw UniSetTypes::SystemError("(RTUExchange): objId=-1?!! Use --" + prefix + "-name" ); throw UniSetTypes::SystemError("(RTUExchange): objId=-1?!! Use --" + prefix + "-name" );
auto conf = uniset_conf();
// префикс для "свойств" - по умолчанию // префикс для "свойств" - по умолчанию
prop_prefix = ""; prop_prefix = "";
// если задано поле для "фильтрации" // если задано поле для "фильтрации"
...@@ -317,6 +319,8 @@ void RTUExchange::poll() ...@@ -317,6 +319,8 @@ void RTUExchange::poll()
RTUExchange* RTUExchange::init_rtuexchange( int argc, const char* const* argv, UniSetTypes::ObjectId icID, RTUExchange* RTUExchange::init_rtuexchange( int argc, const char* const* argv, UniSetTypes::ObjectId icID,
SharedMemory* ic, const std::string& prefix ) SharedMemory* ic, const std::string& prefix )
{ {
auto conf = uniset_conf();
string name = conf->getArgParam("--" + prefix + "-name","RTUExchange1"); string name = conf->getArgParam("--" + prefix + "-name","RTUExchange1");
if( name.empty() ) if( name.empty() )
{ {
......
...@@ -23,8 +23,7 @@ int main( int argc, const char** argv ) ...@@ -23,8 +23,7 @@ int main( int argc, const char** argv )
try try
{ {
string confile=UniSetTypes::getArgParam("--confile",argc, argv, "configure.xml"); auto conf = uniset_init( argc, argv );
conf = new Configuration( argc, argv, confile );
string logfilename(conf->getArgParam("--mbtcp-logfile")); string logfilename(conf->getArgParam("--mbtcp-logfile"));
if( logfilename.empty() ) if( logfilename.empty() )
......
...@@ -23,8 +23,7 @@ int main( int argc, const char** argv ) ...@@ -23,8 +23,7 @@ int main( int argc, const char** argv )
try try
{ {
string confile=UniSetTypes::getArgParam("--confile",argc, argv, "configure.xml"); auto conf = uniset_init( argc, argv );
conf = new Configuration( argc, argv, confile );
string logfilename(conf->getArgParam("--mbtcp-logfile")); string logfilename(conf->getArgParam("--mbtcp-logfile"));
if( logfilename.empty() ) if( logfilename.empty() )
......
...@@ -21,8 +21,7 @@ int main( int argc, char** argv ) ...@@ -21,8 +21,7 @@ int main( int argc, char** argv )
return 0; return 0;
} }
string confile=UniSetTypes::getArgParam("--confile", argc, argv, "configure.xml"); auto conf = uniset_init( argc, argv );
conf = new Configuration( argc, argv, confile );
string logfilename(conf->getArgParam("--rs-logfile")); string logfilename(conf->getArgParam("--rs-logfile"));
if( logfilename.empty() ) if( logfilename.empty() )
......
...@@ -15,6 +15,8 @@ MBTCPMultiSlave::MBTCPMultiSlave( UniSetTypes::ObjectId objId, UniSetTypes::Obje ...@@ -15,6 +15,8 @@ MBTCPMultiSlave::MBTCPMultiSlave( UniSetTypes::ObjectId objId, UniSetTypes::Obje
MBSlave(objId,shmId,ic,prefix), MBSlave(objId,shmId,ic,prefix),
sesscount_id(DefaultObjectId) sesscount_id(DefaultObjectId)
{ {
auto conf = uniset_conf();
cnode = conf->getNode(myname); cnode = conf->getNode(myname);
if( cnode == NULL ) if( cnode == NULL )
throw UniSetTypes::SystemError("(MBSlave): Not found conf-node for " + myname ); throw UniSetTypes::SystemError("(MBSlave): Not found conf-node for " + myname );
...@@ -111,6 +113,7 @@ void MBTCPMultiSlave::help_print( int argc, const char* const* argv ) ...@@ -111,6 +113,7 @@ void MBTCPMultiSlave::help_print( int argc, const char* const* argv )
MBTCPMultiSlave* MBTCPMultiSlave::init_mbslave( int argc, const char* const* argv, UniSetTypes::ObjectId icID, SharedMemory* ic, MBTCPMultiSlave* MBTCPMultiSlave::init_mbslave( int argc, const char* const* argv, UniSetTypes::ObjectId icID, SharedMemory* ic,
const string& prefix ) const string& prefix )
{ {
auto conf = uniset_conf();
string name = conf->getArgParam("--" + prefix + "-name","MBSlave1"); string name = conf->getArgParam("--" + prefix + "-name","MBSlave1");
if( name.empty() ) if( name.empty() )
{ {
......
...@@ -36,4 +36,4 @@ pkgconfig_DATA = libUniSet2MBSlave.pc ...@@ -36,4 +36,4 @@ pkgconfig_DATA = libUniSet2MBSlave.pc
all-local: all-local:
ln -sf ../ModbusSlave/$(devel_include_HEADERS) ../include ln -sf ../ModbusSlave/$(devel_include_HEADERS) ../include
#SUBDIRS=tests SUBDIRS=tests
...@@ -28,8 +28,7 @@ int main(int argc, const char **argv) ...@@ -28,8 +28,7 @@ int main(int argc, const char **argv)
try try
{ {
string confile = UniSetTypes::getArgParam( "--confile", argc, argv, "configure.xml" ); auto conf = uniset_init(argc, argv);
conf = new Configuration(argc, argv,confile);
string logfilename(conf->getArgParam("--mbs-logfile")); string logfilename(conf->getArgParam("--mbs-logfile"));
if( logfilename.empty() ) if( logfilename.empty() )
......
...@@ -28,8 +28,7 @@ int main(int argc, const char **argv) ...@@ -28,8 +28,7 @@ int main(int argc, const char **argv)
try try
{ {
string confile = UniSetTypes::getArgParam( "--confile", argc, argv, "configure.xml" ); auto conf = uniset_init(argc, argv);
conf = new Configuration(argc, argv,confile);
string logfilename(conf->getArgParam("--mbs-logfile")); string logfilename(conf->getArgParam("--mbs-logfile"));
if( logfilename.empty() ) if( logfilename.empty() )
......
...@@ -11,11 +11,11 @@ tests_with_sm_CPPFLAGS = -I$(top_builddir)/include -I$(top_builddir)/extensions ...@@ -11,11 +11,11 @@ tests_with_sm_CPPFLAGS = -I$(top_builddir)/include -I$(top_builddir)/extensions
-I$(top_builddir)/extensions/ModbusSlave \ -I$(top_builddir)/extensions/ModbusSlave \
-I$(top_builddir)/extensions/SharedMemory $(SIGC_CFLAGS) $(COMCPP_CFLAGS) -I$(top_builddir)/extensions/SharedMemory $(SIGC_CFLAGS) $(COMCPP_CFLAGS)
$(top_builddir)/extensions/lib/libUniSet2Extensions.la: #$(top_builddir)/extensions/lib/libUniSet2Extensions.la:
cd $(top_builddir)/extensions/lib/ && make # cd $(top_builddir)/extensions/lib/ && make
$(top_builddir)/extensions/ModbusSlave/libUniSet2MBSlave.la: #$(top_builddir)/extensions/ModbusSlave/libUniSet2MBSlave.la:
cd $(top_builddir)/extensions/ModbusSlave/ && make # cd $(top_builddir)/extensions/ModbusSlave/ && make
include $(top_builddir)/testsuite/testsuite-common.mk include $(top_builddir)/testsuite/testsuite-common.mk
......
...@@ -15,27 +15,27 @@ using namespace UniSetExtensions; ...@@ -15,27 +15,27 @@ using namespace UniSetExtensions;
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
int main(int argc, char* argv[] ) int main(int argc, char* argv[] )
{ {
Catch::Session session; Catch::Session session;
if( argc>1 && ( strcmp(argv[1],"--help")==0 || strcmp(argv[1],"-h")==0 ) ) if( argc>1 && ( strcmp(argv[1],"--help")==0 || strcmp(argv[1],"-h")==0 ) )
{ {
cout << "--confile - Использовать указанный конф. файл. По умолчанию configure.xml" << endl; cout << "--confile - Использовать указанный конф. файл. По умолчанию configure.xml" << endl;
SharedMemory::help_print(argc, argv); SharedMemory::help_print(argc, argv);
cout << endl << endl << "--------------- CATCH HELP --------------" << endl; cout << endl << endl << "--------------- CATCH HELP --------------" << endl;
session.showHelp("test_with_sm"); session.showHelp("test_with_sm");
return 0; return 0;
} }
int returnCode = session.applyCommandLine( argc, argv, Catch::Session::OnUnusedOptions::Ignore ); int returnCode = session.applyCommandLine( argc, argv, Catch::Session::OnUnusedOptions::Ignore );
if( returnCode != 0 ) // Indicates a command line error if( returnCode != 0 ) // Indicates a command line error
return returnCode; return returnCode;
try try
{ {
uniset_init(argc,argv); auto conf = uniset_init(argc,argv);
conf->initDebug(dlog,"dlog"); conf->initDebug(dlog,"dlog");
bool apart = findArgParam("--apart",argc,argv) != -1; bool apart = findArgParam("--apart",argc,argv) != -1;
SharedMemory* shm = SharedMemory::init_smemory(argc, argv); SharedMemory* shm = SharedMemory::init_smemory(argc, argv);
if( !shm ) if( !shm )
return 1; return 1;
...@@ -56,18 +56,18 @@ int main(int argc, char* argv[] ) ...@@ -56,18 +56,18 @@ int main(int argc, char* argv[] )
int tout = 6000; int tout = 6000;
PassiveTimer pt(tout); PassiveTimer pt(tout);
while( !pt.checkTime() && !act->exist() ) while( !pt.checkTime() && !act->exist() )
msleep(100); msleep(100);
if( !act->exist() ) if( !act->exist() )
{ {
cerr << "(tests_with_sm): SharedMemory not exist! (timeout=" << tout << ")" << endl; cerr << "(tests_with_sm): SharedMemory not exist! (timeout=" << tout << ")" << endl;
return 1; return 1;
} }
int ret = session.run(); int ret = session.run();
act->oaDestroy(); act->oaDestroy();
return ret; return ret;
} }
catch( SystemError& err ) catch( SystemError& err )
{ {
......
...@@ -98,6 +98,7 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID ) ...@@ -98,6 +98,7 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID )
// try // try
{ {
auto conf = uniset_conf();
xmlNode* snode = conf->getXMLSensorsSection(); xmlNode* snode = conf->getXMLSensorsSection();
if(!snode) if(!snode)
...@@ -225,6 +226,8 @@ RRDServer* RRDServer::init_rrdstorage( int argc, const char* const* argv, ...@@ -225,6 +226,8 @@ RRDServer* RRDServer::init_rrdstorage( int argc, const char* const* argv,
UniSetTypes::ObjectId icID, SharedMemory* ic, UniSetTypes::ObjectId icID, SharedMemory* ic,
const std::string& prefix ) const std::string& prefix )
{ {
auto conf = uniset_conf();
string name = conf->getArgParam("--" + prefix + "-name","RRDServer"); string name = conf->getArgParam("--" + prefix + "-name","RRDServer");
if( name.empty() ) if( name.empty() )
{ {
......
...@@ -23,8 +23,7 @@ int main( int argc, const char** argv ) ...@@ -23,8 +23,7 @@ int main( int argc, const char** argv )
try try
{ {
string confile=UniSetTypes::getArgParam("--confile",argc, argv, "configure.xml"); auto conf = uniset_init( argc, argv );
conf = new Configuration( argc, argv, confile );
string logfilename(conf->getArgParam("--rrdstorage-logfile")); string logfilename(conf->getArgParam("--rrdstorage-logfile"));
if( logfilename.empty() ) if( logfilename.empty() )
......
...@@ -7,7 +7,7 @@ using namespace UniSetTypes; ...@@ -7,7 +7,7 @@ using namespace UniSetTypes;
using namespace UniSetExtensions; using namespace UniSetExtensions;
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
SMViewer::SMViewer( UniSetTypes::ObjectId shmID ): SMViewer::SMViewer( UniSetTypes::ObjectId shmID ):
SViewer(conf->getControllersSection(),true) SViewer(uniset_conf()->getControllersSection(),true)
{ {
shm = new SMInterface(shmID,&ui,DefaultObjectId,0); shm = new SMInterface(shmID,&ui,DefaultObjectId,0);
} }
......
...@@ -18,8 +18,7 @@ int main( int argc, const char **argv ) ...@@ -18,8 +18,7 @@ int main( int argc, const char **argv )
return 0; return 0;
} }
string confile = UniSetTypes::getArgParam( "--confile", argc, argv, "configure.xml" ); auto conf = uniset_init( argc, argv );
conf = new Configuration( argc, argv, confile );
ObjectId shmID = DefaultObjectId; ObjectId shmID = DefaultObjectId;
string sID = conf->getArgParam("--smemory-id"); string sID = conf->getArgParam("--smemory-id");
......
...@@ -43,11 +43,13 @@ SharedMemory::SharedMemory( ObjectId id, const std::string& datafile, const std: ...@@ -43,11 +43,13 @@ SharedMemory::SharedMemory( ObjectId id, const std::string& datafile, const std:
{ {
mutex_start.setName(myname + "_mutex_start"); mutex_start.setName(myname + "_mutex_start");
auto conf = uniset_conf();
string cname(confname); string cname(confname);
if( cname.empty() ) if( cname.empty() )
cname = ORepHelpers::getShortName(conf->oind->getMapName(id)); cname = ORepHelpers::getShortName( conf->oind->getMapName(id));
xmlNode* cnode = conf->getNode(cname); xmlNode* cnode = conf->getNode(cname);
if( cnode == NULL ) if( cnode == NULL )
throw SystemError("Not found conf-node for " + cname ); throw SystemError("Not found conf-node for " + cname );
...@@ -71,9 +73,9 @@ SharedMemory::SharedMemory( ObjectId id, const std::string& datafile, const std: ...@@ -71,9 +73,9 @@ SharedMemory::SharedMemory( ObjectId id, const std::string& datafile, const std:
heartbeat_node = conf->getArgParam("--heartbeat-node"); heartbeat_node = conf->getArgParam("--heartbeat-node");
if( heartbeat_node.empty() ) if( heartbeat_node.empty() )
{ {
dwarn << myname << "(init): --heartbeat-node NULL ===> heartbeat NOT USED..." << endl; dwarn << myname << "(init): --heartbeat-node NULL ===> heartbeat NOT USED..." << endl;
} }
else else
dinfo << myname << "(init): heartbeat-node: " << heartbeat_node << endl; dinfo << myname << "(init): heartbeat-node: " << heartbeat_node << endl;
...@@ -267,7 +269,7 @@ void SharedMemory::sigterm( int signo ) ...@@ -267,7 +269,7 @@ void SharedMemory::sigterm( int signo )
if( signo == SIGTERM && wdt ) if( signo == SIGTERM && wdt )
wdt->stop(); wdt->stop();
// raise(SIGKILL); // raise(SIGKILL);
IONotifyController_LT::sigterm(signo); IONotifyController_LT::sigterm(signo);
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void SharedMemory::checkHeartBeat() void SharedMemory::checkHeartBeat()
...@@ -374,7 +376,7 @@ bool SharedMemory::readItem( const std::shared_ptr<UniXML>& xml, UniXML::iterato ...@@ -374,7 +376,7 @@ bool SharedMemory::readItem( const std::shared_ptr<UniXML>& xml, UniXML::iterato
} }
else else
{ {
hi.d_sid = conf->getSensorID(it.getProp("heartbeat_ds_name")); hi.d_sid = uniset_conf()->getSensorID(it.getProp("heartbeat_ds_name"));
if( hi.d_sid == DefaultObjectId ) if( hi.d_sid == DefaultObjectId )
{ {
ostringstream msg; ostringstream msg;
...@@ -410,6 +412,7 @@ bool SharedMemory::readItem( const std::shared_ptr<UniXML>& xml, UniXML::iterato ...@@ -410,6 +412,7 @@ bool SharedMemory::readItem( const std::shared_ptr<UniXML>& xml, UniXML::iterato
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
SharedMemory* SharedMemory::init_smemory( int argc, const char* const* argv ) SharedMemory* SharedMemory::init_smemory( int argc, const char* const* argv )
{ {
auto conf = uniset_conf();
string dfile = conf->getArgParam("--datfile", conf->getConfFileName()); string dfile = conf->getArgParam("--datfile", conf->getConfFileName());
if( dfile[0]!='.' && dfile[0]!='/' ) if( dfile[0]!='.' && dfile[0]!='/' )
...@@ -439,7 +442,7 @@ void SharedMemory::buildEventList( xmlNode* cnode ) ...@@ -439,7 +442,7 @@ void SharedMemory::buildEventList( xmlNode* cnode )
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void SharedMemory::readEventList( const std::string& oname ) void SharedMemory::readEventList( const std::string& oname )
{ {
xmlNode* enode = conf->getNode(oname); xmlNode* enode = uniset_conf()->getNode(oname);
if( enode == NULL ) if( enode == NULL )
{ {
dwarn << myname << "(readEventList): " << oname << " не найден..." << endl; dwarn << myname << "(readEventList): " << oname << " не найден..." << endl;
...@@ -508,7 +511,7 @@ void SharedMemory::buildHistoryList( xmlNode* cnode ) ...@@ -508,7 +511,7 @@ void SharedMemory::buildHistoryList( xmlNode* cnode )
{ {
dinfo << myname << "(buildHistoryList): ..." << endl; dinfo << myname << "(buildHistoryList): ..." << endl;
const std::shared_ptr<UniXML> xml = conf->getConfXML(); const std::shared_ptr<UniXML> xml = uniset_conf()->getConfXML();
if( !xml ) if( !xml )
{ {
dwarn << myname << "(buildHistoryList): xml=NULL?!" << endl; dwarn << myname << "(buildHistoryList): xml=NULL?!" << endl;
...@@ -525,7 +528,7 @@ void SharedMemory::buildHistoryList( xmlNode* cnode ) ...@@ -525,7 +528,7 @@ void SharedMemory::buildHistoryList( xmlNode* cnode )
UniXML::iterator it(n); UniXML::iterator it(n);
bool no_history = conf->getArgInt("--sm-no-history",it.getProp("no_history")); bool no_history = uniset_conf()->getArgInt("--sm-no-history",it.getProp("no_history"));
if( no_history ) if( no_history )
{ {
dwarn << myname << "(buildHistoryList): no_history='1'.. history skipped..." << endl; dwarn << myname << "(buildHistoryList): no_history='1'.. history skipped..." << endl;
...@@ -555,7 +558,7 @@ void SharedMemory::buildHistoryList( xmlNode* cnode ) ...@@ -555,7 +558,7 @@ void SharedMemory::buildHistoryList( xmlNode* cnode )
if( hi.filter.empty() ) if( hi.filter.empty() )
continue; continue;
hi.fuse_id = conf->getSensorID(it.getProp("fuse_id")); hi.fuse_id = uniset_conf()->getSensorID(it.getProp("fuse_id"));
if( hi.fuse_id == DefaultObjectId ) if( hi.fuse_id == DefaultObjectId )
{ {
dwarn << myname << "(buildHistory): not found sensor ID for " dwarn << myname << "(buildHistory): not found sensor ID for "
...@@ -604,7 +607,7 @@ void SharedMemory::checkHistoryFilter( UniXML::iterator& xit ) ...@@ -604,7 +607,7 @@ void SharedMemory::checkHistoryFilter( UniXML::iterator& xit )
continue; continue;
} }
ai.id = conf->getSensorID(xit.getProp("name")); ai.id = uniset_conf()->getSensorID(xit.getProp("name"));
if( ai.id == DefaultObjectId ) if( ai.id == DefaultObjectId )
{ {
dwarn << myname << "(checkHistoryFilter): not found sensor ID for " << xit.getProp("name") << endl; dwarn << myname << "(checkHistoryFilter): not found sensor ID for " << xit.getProp("name") << endl;
......
...@@ -19,8 +19,7 @@ int main(int argc, const char **argv) ...@@ -19,8 +19,7 @@ int main(int argc, const char **argv)
try try
{ {
string confile = UniSetTypes::getArgParam( "--confile", argc, argv, "configure.xml" ); auto conf = uniset_init(argc, argv);
conf = new Configuration(argc, argv, confile);
conf->initDebug(dlog,"dlog"); conf->initDebug(dlog,"dlog");
string logfilename = conf->getArgParam("--logfile", "smemory.log"); string logfilename = conf->getArgParam("--logfile", "smemory.log");
......
...@@ -33,25 +33,25 @@ std::list< ThreadCreator<IOControl>* > lst_iothr; ...@@ -33,25 +33,25 @@ std::list< ThreadCreator<IOControl>* > lst_iothr;
#endif #endif
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
void activator_terminate( int signo ) void activator_terminate( int signo )
{ {
if( logserver ) if( logserver )
{ {
try try
{ {
delete logserver; delete logserver;
logserver = 0; logserver = 0;
} }
catch(...){} catch(...){}
} }
#ifdef UNISET_IO_ENABLE #ifdef UNISET_IO_ENABLE
for( auto& i: lst_iothr ) for( auto& i: lst_iothr )
{ {
try try
{ {
i->stop(); i->stop();
} }
catch(...){} catch(...){}
} }
#endif #endif
} }
...@@ -67,8 +67,7 @@ int main( int argc, const char **argv ) ...@@ -67,8 +67,7 @@ int main( int argc, const char **argv )
try try
{ {
string confile = UniSetTypes::getArgParam( "--confile", argc, argv, "configure.xml" ); auto conf = uniset_init(argc, argv);
conf = new Configuration(argc, argv, confile);
string logfilename = conf->getArgParam("--logfile", "smemory-plus.log"); string logfilename = conf->getArgParam("--logfile", "smemory-plus.log");
string logname( conf->getLogDir() + logfilename ); string logname( conf->getLogDir() + logfilename );
...@@ -217,16 +216,16 @@ int main( int argc, const char **argv ) ...@@ -217,16 +216,16 @@ int main( int argc, const char **argv )
i->start(); i->start();
#endif #endif
LogAgregator la; LogAgregator la;
la.add(ulog); la.add(ulog);
la.add(dlog); la.add(dlog);
logserver = run_logserver("smplus",la); logserver = run_logserver("smplus",la);
if( logserver == 0 ) if( logserver == 0 )
{ {
cerr << "(smemory-plus): run logserver for 'smplus' FAILED" << endl; cerr << "(smemory-plus): run logserver for 'smplus' FAILED" << endl;
return 1; return 1;
} }
act->run(false); act->run(false);
...@@ -287,45 +286,46 @@ void help_print( int argc, const char* argv[] ) ...@@ -287,45 +286,46 @@ void help_print( int argc, const char* argv[] )
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
LogServer* run_logserver( const std::string& cname, DebugStream& log ) LogServer* run_logserver( const std::string& cname, DebugStream& log )
{ {
const std::shared_ptr<UniXML> xml = UniSetTypes::conf->getConfXML(); auto conf = uniset_conf();
xmlNode* cnode = UniSetTypes::conf->findNode(xml->getFirstNode(),"LogServer",cname); auto xml = conf->getConfXML();
if( cnode == 0 ) xmlNode* cnode = conf->findNode(xml->getFirstNode(),"LogServer",cname);
{ if( cnode == 0 )
cerr << "(init_ulogserver): Not found xmlnode for '" << cname << "'" << endl; {
return 0; cerr << "(init_ulogserver): Not found xmlnode for '" << cname << "'" << endl;
return 0;
}
}
UniXML::iterator it(cnode);
UniXML::iterator it(cnode);
LogServer* ls = new LogServer( log );
LogServer* ls = new LogServer( log );
timeout_t sessTimeout = conf->getArgPInt("--" + cname + "-session-timeout",it.getProp("sessTimeout"),3600000);
timeout_t cmdTimeout = conf->getArgPInt("--" + cname + "-cmd-timeout",it.getProp("cmdTimeout"),2000); timeout_t sessTimeout = conf->getArgPInt("--" + cname + "-session-timeout",it.getProp("sessTimeout"),3600000);
timeout_t outTimeout = conf->getArgPInt("--" + cname + "-out-timeout",it.getProp("outTimeout"),2000); timeout_t cmdTimeout = conf->getArgPInt("--" + cname + "-cmd-timeout",it.getProp("cmdTimeout"),2000);
timeout_t outTimeout = conf->getArgPInt("--" + cname + "-out-timeout",it.getProp("outTimeout"),2000);
ls->setSessionTimeout(sessTimeout);
ls->setCmdTimeout(cmdTimeout); ls->setSessionTimeout(sessTimeout);
ls->setOutTimeout(outTimeout); ls->setCmdTimeout(cmdTimeout);
ls->setOutTimeout(outTimeout);
std::string host = conf->getArgParam("--" + cname + "-host",it.getProp("host"));
if( host.empty() ) std::string host = conf->getArgParam("--" + cname + "-host",it.getProp("host"));
{ if( host.empty() )
cerr << "(init_ulogserver): " << cname << ": unknown host.." << endl; {
delete ls; cerr << "(init_ulogserver): " << cname << ": unknown host.." << endl;
return 0; delete ls;
} return 0;
}
ost::tpport_t port = conf->getArgPInt("--" + cname + "-port",it.getProp("port"),0);
if( port == 0 ) ost::tpport_t port = conf->getArgPInt("--" + cname + "-port",it.getProp("port"),0);
{ if( port == 0 )
cerr << "(init_ulogserver): " << cname << ": unknown port.." << endl; {
delete ls; cerr << "(init_ulogserver): " << cname << ": unknown port.." << endl;
return 0; delete ls;
} return 0;
}
cout << "logserver: " << host << ":" << port << endl;
ls->run(host, port, true); cout << "logserver: " << host << ":" << port << endl;
return ls; ls->run(host, port, true);
return ls;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -170,8 +170,8 @@ size_t UDPMessage::getMessage( UDPMessage& m, UDPPacket& p ) ...@@ -170,8 +170,8 @@ size_t UDPMessage::getMessage( UDPMessage& m, UDPPacket& p )
// проверяем наш ли пакет.. // проверяем наш ли пакет..
if( m.magic != UniSetUDP::UNETUDP_MAGICNUM ) if( m.magic != UniSetUDP::UNETUDP_MAGICNUM )
{ {
m.magic = 0; m.magic = 0;
return 0; return 0;
} }
// копируем аналоговые данные // копируем аналоговые данные
......
...@@ -18,6 +18,8 @@ sender2(0) ...@@ -18,6 +18,8 @@ sender2(0)
{ {
if( objId == DefaultObjectId ) if( objId == DefaultObjectId )
throw UniSetTypes::SystemError("(UNetExchange): objId=-1?!! Use --" + prefix +"-unet-name" ); throw UniSetTypes::SystemError("(UNetExchange): objId=-1?!! Use --" + prefix +"-unet-name" );
auto conf = uniset_conf();
cnode = conf->getNode(myname); cnode = conf->getNode(myname);
if( cnode == NULL ) if( cnode == NULL )
...@@ -376,7 +378,7 @@ void UNetExchange::startReceivers() ...@@ -376,7 +378,7 @@ void UNetExchange::startReceivers()
void UNetExchange::waitSMReady() void UNetExchange::waitSMReady()
{ {
// waiting for SM is ready... // waiting for SM is ready...
int ready_timeout = conf->getArgInt("--unet-sm-ready-timeout","15000"); int ready_timeout = uniset_conf()->getArgInt("--unet-sm-ready-timeout","15000");
if( ready_timeout == 0 ) if( ready_timeout == 0 )
ready_timeout = 15000; ready_timeout = 15000;
else if( ready_timeout < 0 ) else if( ready_timeout < 0 )
...@@ -656,6 +658,8 @@ void UNetExchange::help_print( int argc, const char* argv[] ) ...@@ -656,6 +658,8 @@ void UNetExchange::help_print( int argc, const char* argv[] )
UNetExchange* UNetExchange::init_unetexchange( int argc, const char* argv[], UniSetTypes::ObjectId icID, UNetExchange* UNetExchange::init_unetexchange( int argc, const char* argv[], UniSetTypes::ObjectId icID,
SharedMemory* ic, const std::string& prefix ) SharedMemory* ic, const std::string& prefix )
{ {
auto conf = uniset_conf();
string p("--" + prefix + "-name"); string p("--" + prefix + "-name");
string name = conf->getArgParam(p,"UNetExchange1"); string name = conf->getArgParam(p,"UNetExchange1");
if( name.empty() ) if( name.empty() )
......
...@@ -519,7 +519,7 @@ void UNetReceiver::initDCache( UniSetUDP::UDPMessage& pack, bool force ) ...@@ -519,7 +519,7 @@ void UNetReceiver::initDCache( UniSetUDP::UDPMessage& pack, bool force )
if( d.id != pack.d_id[i] ) if( d.id != pack.d_id[i] )
{ {
d.id = pack.d_id[i]; d.id = pack.d_id[i];
d.iotype = conf->getIOType(d.id); d.iotype = uniset_conf()->getIOType(d.id);
shm->initIterator(d.ioit); shm->initIterator(d.ioit);
} }
} }
...@@ -540,7 +540,7 @@ void UNetReceiver::initACache( UniSetUDP::UDPMessage& pack, bool force ) ...@@ -540,7 +540,7 @@ void UNetReceiver::initACache( UniSetUDP::UDPMessage& pack, bool force )
if( d.id != pack.a_dat[i].id ) if( d.id != pack.a_dat[i].id )
{ {
d.id = pack.a_dat[i].id; d.id = pack.a_dat[i].id;
d.iotype = conf->getIOType(d.id); d.iotype = uniset_conf()->getIOType(d.id);
shm->initIterator(d.ioit); shm->initIterator(d.ioit);
} }
} }
......
...@@ -71,7 +71,7 @@ s_thr(0) ...@@ -71,7 +71,7 @@ s_thr(0)
// выставляем поля, которые не меняются // выставляем поля, которые не меняются
mypack.nodeID = conf->getLocalNode(); mypack.nodeID = uniset_conf()->getLocalNode();
mypack.procID = shm->ID(); mypack.procID = shm->ID();
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -210,7 +210,7 @@ void UNetSender::start() ...@@ -210,7 +210,7 @@ void UNetSender::start()
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UNetSender::readConfiguration() void UNetSender::readConfiguration()
{ {
xmlNode* root = conf->getXMLSensorsSection(); xmlNode* root = uniset_conf()->getXMLSensorsSection();
if(!root) if(!root)
{ {
ostringstream err; ostringstream err;
...@@ -253,7 +253,7 @@ bool UNetSender::initItem( UniXML::iterator& it ) ...@@ -253,7 +253,7 @@ bool UNetSender::initItem( UniXML::iterator& it )
sid = DefaultObjectId; sid = DefaultObjectId;
} }
else else
sid = conf->getSensorID(sname); sid = uniset_conf()->getSensorID(sname);
if( sid == DefaultObjectId ) if( sid == DefaultObjectId )
{ {
......
...@@ -21,7 +21,7 @@ int main( int argc, const char** argv ) ...@@ -21,7 +21,7 @@ int main( int argc, const char** argv )
return 0; return 0;
} }
uniset_init(argc,argv); auto conf = uniset_init(argc,argv);
string logfilename(conf->getArgParam("--unet-logfile")); string logfilename(conf->getArgParam("--unet-logfile"));
if( logfilename.empty() ) if( logfilename.empty() )
......
...@@ -10,7 +10,7 @@ using namespace UniSetExtensions; ...@@ -10,7 +10,7 @@ using namespace UniSetExtensions;
UniExchange::NetNodeInfo::NetNodeInfo(): UniExchange::NetNodeInfo::NetNodeInfo():
oref(CORBA::Object::_nil()), oref(CORBA::Object::_nil()),
id(DefaultObjectId), id(DefaultObjectId),
node(conf->getLocalNode()), node(uniset_conf()->getLocalNode()),
sidConnection(DefaultObjectId), sidConnection(DefaultObjectId),
smap(1) smap(1)
{ {
...@@ -26,6 +26,8 @@ mymap(1), ...@@ -26,6 +26,8 @@ mymap(1),
maxIndex(0), maxIndex(0),
smReadyTimeout(15000) smReadyTimeout(15000)
{ {
auto conf = uniset_conf();
cnode = conf->getNode(myname); cnode = conf->getNode(myname);
if( cnode == NULL ) if( cnode == NULL )
throw UniSetTypes::SystemError("(UniExchange): Not found conf-node for " + myname ); throw UniSetTypes::SystemError("(UniExchange): Not found conf-node for " + myname );
...@@ -176,7 +178,7 @@ void UniExchange::execute() ...@@ -176,7 +178,7 @@ void UniExchange::execute()
catch(...) catch(...)
{ {
dcrit << myname << "(execute): sensor not avalible " dcrit << myname << "(execute): sensor not avalible "
<< conf->oind->getNameById(it.sidConnection) << uniset_conf()->oind->getNameById(it.sidConnection)
<< endl; << endl;
} }
} }
...@@ -329,6 +331,8 @@ UniExchange* UniExchange::init_exchange( int argc, const char* const* argv, ...@@ -329,6 +331,8 @@ UniExchange* UniExchange::init_exchange( int argc, const char* const* argv,
UniSetTypes::ObjectId icID, SharedMemory* ic, UniSetTypes::ObjectId icID, SharedMemory* ic,
const std::string& prefix ) const std::string& prefix )
{ {
auto conf = uniset_conf();
string p("--" + prefix + "-name"); string p("--" + prefix + "-name");
string nm(UniSetTypes::getArgParam(p,argc,argv,"UniExchange")); string nm(UniSetTypes::getArgParam(p,argc,argv,"UniExchange"));
...@@ -345,7 +349,7 @@ UniExchange* UniExchange::init_exchange( int argc, const char* const* argv, ...@@ -345,7 +349,7 @@ UniExchange* UniExchange::init_exchange( int argc, const char* const* argv,
void UniExchange::readConfiguration() void UniExchange::readConfiguration()
{ {
// readconf_ok = false; // readconf_ok = false;
xmlNode* root = conf->getXMLSensorsSection(); xmlNode* root = uniset_conf()->getXMLSensorsSection();
if(!root) if(!root)
{ {
ostringstream err; ostringstream err;
...@@ -383,7 +387,7 @@ bool UniExchange::initItem( UniXML::iterator& it ) ...@@ -383,7 +387,7 @@ bool UniExchange::initItem( UniXML::iterator& it )
i.id = DefaultObjectId; i.id = DefaultObjectId;
if( it.getProp("id").empty() ) if( it.getProp("id").empty() )
i.id = conf->getSensorID(it.getProp("name")); i.id = uniset_conf()->getSensorID(it.getProp("name"));
else else
{ {
i.id = it.getIntProp("id"); i.id = it.getIntProp("id");
......
...@@ -19,8 +19,7 @@ int main(int argc, const char **argv) ...@@ -19,8 +19,7 @@ int main(int argc, const char **argv)
try try
{ {
string confile = UniSetTypes::getArgParam( "--confile", argc, argv, "configure.xml" ); auto conf = uniset_init(argc, argv);
conf = new Configuration(argc, argv, confile);
conf->initDebug(dlog,"dlog"); conf->initDebug(dlog,"dlog");
string logfilename = conf->getArgParam("--logfile", "smemory.log"); string logfilename = conf->getArgParam("--logfile", "smemory.log");
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ. ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/ */
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// generate timestamp: 2014-01-27+04:00 // generate timestamp: 2014-11-24+03:00
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#ifndef UObject_SK_H_ #ifndef UObject_SK_H_
#define UObject_SK_H_ #define UObject_SK_H_
...@@ -25,7 +25,7 @@ class UObject_SK: ...@@ -25,7 +25,7 @@ class UObject_SK:
public LT_Object public LT_Object
{ {
public: public:
UObject_SK( UniSetTypes::ObjectId id, xmlNode* node=UniSetTypes::conf->getNode("UObject"), const std::string& argprefix="" ); UObject_SK( UniSetTypes::ObjectId id, xmlNode* node=UniSetTypes::uniset_conf()->getNode("UObject"), const std::string& argprefix="" );
UObject_SK(); UObject_SK();
virtual ~UObject_SK(); virtual ~UObject_SK();
...@@ -33,7 +33,7 @@ class UObject_SK: ...@@ -33,7 +33,7 @@ class UObject_SK:
bool alarm( UniSetTypes::ObjectId sid, bool state ); bool alarm( UniSetTypes::ObjectId sid, bool state );
long getValue( UniSetTypes::ObjectId sid ); long getValue( UniSetTypes::ObjectId sid );
void setValue( UniSetTypes::ObjectId sid, long value ); void setValue( UniSetTypes::ObjectId sid, long value );
void askSensor( UniSetTypes::ObjectId sid, UniversalIO::UIOCommand, UniSetTypes::ObjectId node = UniSetTypes::conf->getLocalNode() ); void askSensor( UniSetTypes::ObjectId sid, UniversalIO::UIOCommand, UniSetTypes::ObjectId node = UniSetTypes::uniset_conf()->getLocalNode() );
void updateValues(); void updateValues();
void setMsg( UniSetTypes::ObjectId code, bool state ); void setMsg( UniSetTypes::ObjectId code, bool state );
...@@ -76,14 +76,14 @@ class UObject_SK: ...@@ -76,14 +76,14 @@ class UObject_SK:
// ---- end of protected variables ---- // ---- end of protected variables ----
virtual void callback(); virtual void callback() override;
virtual void processingMessage( UniSetTypes::VoidMessage* msg ); virtual void processingMessage( UniSetTypes::VoidMessage* msg ) override;
virtual void sysCommand( const UniSetTypes::SystemMessage* sm ); virtual void sysCommand( const UniSetTypes::SystemMessage* sm ) override;
virtual void askSensors( UniversalIO::UIOCommand cmd ){} virtual void askSensors( UniversalIO::UIOCommand cmd ){}
virtual void sensorInfo( const UniSetTypes::SensorMessage* sm ){} virtual void sensorInfo( const UniSetTypes::SensorMessage* sm ) override{}
virtual void timerInfo( const UniSetTypes::TimerMessage* tm ){} virtual void timerInfo( const UniSetTypes::TimerMessage* tm ) override{}
virtual void sigterm( int signo ); virtual void sigterm( int signo ) override;
virtual bool activateObject(); virtual bool activateObject() override;
virtual void testMode( bool state ); virtual void testMode( bool state );
void updatePreviousValues(); void updatePreviousValues();
void checkSensors(); void checkSensors();
...@@ -100,7 +100,7 @@ class UObject_SK: ...@@ -100,7 +100,7 @@ class UObject_SK:
int resetMsgTime; int resetMsgTime;
// Выполнение очередного шага программы // Выполнение очередного шага программы
virtual void step()=0; virtual void step(){}
int sleep_msec; /*!< пауза между итерациями */ int sleep_msec; /*!< пауза между итерациями */
bool active; bool active;
...@@ -114,9 +114,9 @@ class UObject_SK: ...@@ -114,9 +114,9 @@ class UObject_SK:
xmlNode* confnode; xmlNode* confnode;
/*! получить числовое свойство из конф. файла по привязанной confnode */ /*! получить числовое свойство из конф. файла по привязанной confnode */
int getIntProp(const std::string& name) { return UniSetTypes::conf->getIntProp(confnode, name); } int getIntProp(const std::string& name) { return UniSetTypes::uniset_conf()->getIntProp(confnode, name); }
/*! получить текстовое свойство из конф. файла по привязанной confnode */ /*! получить текстовое свойство из конф. файла по привязанной confnode */
inline const std::string getProp(const std::string& name) { return UniSetTypes::conf->getProp(confnode, name); } inline const std::string getProp(const std::string& name) { return UniSetTypes::uniset_conf()->getProp(confnode, name); }
int smReadyTimeout; /*!< время ожидания готовности SM */ int smReadyTimeout; /*!< время ожидания готовности SM */
std::atomic_bool activated; std::atomic_bool activated;
......
...@@ -168,7 +168,7 @@ namespace VTypes ...@@ -168,7 +168,7 @@ namespace VTypes
static VType type(){ return vtByte; } static VType type(){ return vtByte; }
// ------------------------------------------ // ------------------------------------------
operator long(){ return lroundf(raw.w); } operator long(){ return lroundf(raw.w); }
operator unsigned short(){ return raw.w; } operator unsigned short(){ return raw.w; }
unsigned char operator[]( const int i ){ return raw.b[i]; } unsigned char operator[]( const int i ){ return raw.b[i]; }
......
...@@ -212,12 +212,12 @@ int DigitalFilter::median( int newval ) ...@@ -212,12 +212,12 @@ int DigitalFilter::median( int newval )
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
int DigitalFilter::currentMedian() int DigitalFilter::currentMedian()
{ {
if( !mvec_sorted ) if( !mvec_sorted )
{ {
mvec.assign(buf.begin(),buf.end()); mvec.assign(buf.begin(),buf.end());
sort(mvec.begin(),mvec.end()); sort(mvec.begin(),mvec.end());
// mvec_sorted = true; // специально не выставляю, чтобы если данные добавляются через add(), то тут надо каждый раз пересчитыать.. // mvec_sorted = true; // специально не выставляю, чтобы если данные добавляются через add(), то тут надо каждый раз пересчитыать..
} }
return mvec[maxsize/2]; return mvec[maxsize/2];
} }
......
...@@ -17,6 +17,8 @@ namespace UniSetExtensions ...@@ -17,6 +17,8 @@ namespace UniSetExtensions
{ {
if( shmID != DefaultObjectId ) if( shmID != DefaultObjectId )
return shmID; return shmID;
auto conf = uniset_conf();
string sname = conf->getArgParam("--smemory-id","SharedMemory1"); string sname = conf->getArgParam("--smemory-id","SharedMemory1");
shmID = conf->getControllerID(sname); shmID = conf->getControllerID(sname);
...@@ -54,7 +56,7 @@ namespace UniSetExtensions ...@@ -54,7 +56,7 @@ namespace UniSetExtensions
if( xmlCalibrationsNode ) if( xmlCalibrationsNode )
return xmlCalibrationsNode; return xmlCalibrationsNode;
xmlCalibrationsNode = conf->getNode("Calibrations"); xmlCalibrationsNode = uniset_conf()->getNode("Calibrations");
return xmlCalibrationsNode; return xmlCalibrationsNode;
} }
...@@ -103,7 +105,7 @@ namespace UniSetExtensions ...@@ -103,7 +105,7 @@ namespace UniSetExtensions
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void on_sigchild( int sig ) void on_sigchild( int sig )
{ {
while(1) while(1)
{ {
int istatus; int istatus;
pid_t pid = waitpid( -1, &istatus, WNOHANG ); pid_t pid = waitpid( -1, &istatus, WNOHANG );
......
...@@ -7,7 +7,7 @@ using namespace UniSetTypes; ...@@ -7,7 +7,7 @@ using namespace UniSetTypes;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
std::ostream& operator<<( std::ostream& os, IOBase& inf ) std::ostream& operator<<( std::ostream& os, IOBase& inf )
{ {
return os << "(" << inf.si.id << ")" << conf->oind->getMapName(inf.si.id) return os << "(" << inf.si.id << ")" << uniset_conf()->oind->getMapName(inf.si.id)
<< " default=" << inf.defval << " safety=" << inf.safety; << " default=" << inf.defval << " safety=" << inf.safety;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -136,29 +136,29 @@ void IOBase::processingAsAI( IOBase* it, long val, SMInterface* shm, bool force ...@@ -136,29 +136,29 @@ void IOBase::processingAsAI( IOBase* it, long val, SMInterface* shm, bool force
val = it->df.filterRC(val); val = it->df.filterRC(val);
} }
if( !it->rawdata ) if( !it->rawdata )
{ {
if( it->cdiagram ) // задана специальная калибровочная диаграмма if( it->cdiagram ) // задана специальная калибровочная диаграмма
{ {
if( it->craw != val ) if( it->craw != val )
{ {
it->craw = val; it->craw = val;
val = it->cdiagram->getValue(val); val = it->cdiagram->getValue(val);
it->cprev = val; it->cprev = val;
} }
else else
val = it->cprev; // просто передаём предыдущее значение val = it->cprev; // просто передаём предыдущее значение
} }
else else
{ {
IOController_i::CalibrateInfo* cal( &(it->cal) ); IOController_i::CalibrateInfo* cal( &(it->cal) );
if( cal->maxRaw!=cal->minRaw ) // задана обычная калибровка if( cal->maxRaw!=cal->minRaw ) // задана обычная калибровка
val = UniSetTypes::lcalibrate(val,cal->minRaw,cal->maxRaw,cal->minCal,cal->maxCal,true); val = UniSetTypes::lcalibrate(val,cal->minRaw,cal->maxRaw,cal->minCal,cal->maxCal,true);
} }
if( !it->noprecision && it->cal.precision > 0 ) if( !it->noprecision && it->cal.precision > 0 )
val *= lround(pow10(it->cal.precision)); val *= lround(pow10(it->cal.precision));
} }
// если предыдущее значение "обрыв", // если предыдущее значение "обрыв",
// то сбрасываем признак // то сбрасываем признак
{ {
...@@ -178,12 +178,12 @@ void IOBase::processingFasAI( IOBase* it, float fval, SMInterface* shm, bool for ...@@ -178,12 +178,12 @@ void IOBase::processingFasAI( IOBase* it, float fval, SMInterface* shm, bool for
{ {
long val = lroundf(fval); long val = lroundf(fval);
if( it->rawdata ) if( it->rawdata )
{ {
val = 0; val = 0;
memcpy(&val,&fval, std::min(sizeof(val),sizeof(fval))); memcpy(&val,&fval, std::min(sizeof(val),sizeof(fval)));
} }
else if( it->cal.precision > 0 ) else if( it->cal.precision > 0 )
val = lroundf( fval * pow10(it->cal.precision) ); val = lroundf( fval * pow10(it->cal.precision) );
// проверка на обрыв // проверка на обрыв
...@@ -325,7 +325,7 @@ float IOBase::processingFasAO( IOBase* it, SMInterface* shm, bool force ) ...@@ -325,7 +325,7 @@ float IOBase::processingFasAO( IOBase* it, SMInterface* shm, bool force )
if( it->rawdata ) if( it->rawdata )
{ {
float fval=0; float fval=0;
memcpy(&fval,&val, std::min(sizeof(val),sizeof(fval))); memcpy(&fval,&val, std::min(sizeof(val),sizeof(fval)));
return fval; return fval;
} }
...@@ -394,32 +394,32 @@ void IOBase::processingThreshold( IOBase* it, SMInterface* shm, bool force ) ...@@ -394,32 +394,32 @@ void IOBase::processingThreshold( IOBase* it, SMInterface* shm, bool force )
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
std::string IOBase::initProp( UniXML::iterator& it, const std::string& prop, const std::string& prefix, bool prefonly, const std::string& defval ) std::string IOBase::initProp( UniXML::iterator& it, const std::string& prop, const std::string& prefix, bool prefonly, const std::string& defval )
{ {
if( !it.getProp(prefix+prop).empty() ) if( !it.getProp(prefix+prop).empty() )
return it.getProp(prefix+prop); return it.getProp(prefix+prop);
if( prefonly ) if( prefonly )
return defval; return defval;
if( !it.getProp(prop).empty() ) if( !it.getProp(prop).empty() )
return it.getProp(prop); return it.getProp(prop);
return defval; return defval;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
int IOBase::initIntProp( UniXML::iterator& it, const std::string& prop, const std::string& prefix, bool prefonly, const int defval ) int IOBase::initIntProp( UniXML::iterator& it, const std::string& prop, const std::string& prefix, bool prefonly, const int defval )
{ {
string pp(prefix+prop); string pp(prefix+prop);
if( !it.getProp(pp).empty() ) if( !it.getProp(pp).empty() )
return it.getIntProp(pp); return it.getIntProp(pp);
if( prefonly ) if( prefonly )
return defval; return defval;
if( !it.getProp(prop).empty() ) if( !it.getProp(prop).empty() )
return it.getIntProp(prop); return it.getIntProp(prop);
return defval; return defval;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool IOBase::initItem( IOBase* b, UniXML::iterator& it, SMInterface* shm, const std::string& prefix, bool IOBase::initItem( IOBase* b, UniXML::iterator& it, SMInterface* shm, const std::string& prefix,
...@@ -428,12 +428,12 @@ bool IOBase::initItem( IOBase* b, UniXML::iterator& it, SMInterface* shm, const ...@@ -428,12 +428,12 @@ bool IOBase::initItem( IOBase* b, UniXML::iterator& it, SMInterface* shm, const
int def_filtersize, float def_filterT, float def_lsparam, int def_filtersize, float def_filterT, float def_lsparam,
float def_iir_coeff_prev, float def_iir_coeff_new ) float def_iir_coeff_prev, float def_iir_coeff_new )
{ {
// Переопределять ID и name - нельзя..s // Переопределять ID и name - нельзя..s
string sname( it.getProp("name") ); string sname( it.getProp("name") );
ObjectId sid = DefaultObjectId; ObjectId sid = DefaultObjectId;
if( it.getProp("id").empty() ) if( it.getProp("id").empty() )
sid = conf->getSensorID(sname); sid = uniset_conf()->getSensorID(sname);
else else
sid = it.getPIntProp("id",DefaultObjectId); sid = it.getPIntProp("id",DefaultObjectId);
...@@ -448,16 +448,16 @@ bool IOBase::initItem( IOBase* b, UniXML::iterator& it, SMInterface* shm, const ...@@ -448,16 +448,16 @@ bool IOBase::initItem( IOBase* b, UniXML::iterator& it, SMInterface* shm, const
b->val_lock.setName(sname + "_lock"); b->val_lock.setName(sname + "_lock");
b->si.id = sid; b->si.id = sid;
b->si.node = conf->getLocalNode(); b->si.node = uniset_conf()->getLocalNode();
b->nofilter = initIntProp(it,"nofilter",prefix,init_prefix_only); b->nofilter = initIntProp(it,"nofilter",prefix,init_prefix_only);
b->ignore = initIntProp(it,"ioignore",prefix,init_prefix_only); b->ignore = initIntProp(it,"ioignore",prefix,init_prefix_only);
b->invert = initIntProp(it,"ioinvert",prefix,init_prefix_only); b->invert = initIntProp(it,"ioinvert",prefix,init_prefix_only);
b->defval = initIntProp(it,"default",prefix,init_prefix_only); b->defval = initIntProp(it,"default",prefix,init_prefix_only);
b->noprecision = initIntProp(it,"noprecision",prefix,init_prefix_only); b->noprecision = initIntProp(it,"noprecision",prefix,init_prefix_only);
b->value = b->defval; b->value = b->defval;
b->breaklim = initIntProp(it,"breaklim",prefix,init_prefix_only); b->breaklim = initIntProp(it,"breaklim",prefix,init_prefix_only);
b->rawdata = initIntProp(it,"rawdata",prefix,init_prefix_only); b->rawdata = initIntProp(it,"rawdata",prefix,init_prefix_only);
long msec = initIntProp(it,"debouncedelay",prefix,init_prefix_only, UniSetTimer::WaitUpTime); long msec = initIntProp(it,"debouncedelay",prefix,init_prefix_only, UniSetTimer::WaitUpTime);
b->ptDebounce.setTiming(msec); b->ptDebounce.setTiming(msec);
...@@ -585,7 +585,7 @@ bool IOBase::initItem( IOBase* b, UniXML::iterator& it, SMInterface* shm, const ...@@ -585,7 +585,7 @@ bool IOBase::initItem( IOBase* b, UniXML::iterator& it, SMInterface* shm, const
string tai(initProp(it,"threshold_aid",prefix,init_prefix_only)); string tai(initProp(it,"threshold_aid",prefix,init_prefix_only));
if( !tai.empty() ) if( !tai.empty() )
{ {
b->t_ai = conf->getSensorID(tai); b->t_ai = uniset_conf()->getSensorID(tai);
if( b->t_ai == DefaultObjectId ) if( b->t_ai == DefaultObjectId )
{ {
if( dlog && dlog->is_crit() ) if( dlog && dlog->is_crit() )
......
...@@ -10,6 +10,7 @@ using namespace UniSetTypes; ...@@ -10,6 +10,7 @@ using namespace UniSetTypes;
#define BEG_FUNC(name) \ #define BEG_FUNC(name) \
try \ try \
{ \ { \
auto conf = ui->getConf(); \
uniset_rwmutex_wrlock l(shmMutex); \ uniset_rwmutex_wrlock l(shmMutex); \
IONotifyController_i_var shm;\ IONotifyController_i_var shm;\
for( unsigned int i=0; i<conf->getRepeatCount(); i++)\ for( unsigned int i=0; i<conf->getRepeatCount(); i++)\
...@@ -33,6 +34,7 @@ using namespace UniSetTypes; ...@@ -33,6 +34,7 @@ using namespace UniSetTypes;
#define BEG_FUNC1(name) \ #define BEG_FUNC1(name) \
try \ try \
{ \ { \
auto conf = ui->getConf(); \
uniset_rwmutex_wrlock l(shmMutex); \ uniset_rwmutex_wrlock l(shmMutex); \
if( true ) \ if( true ) \
{ \ { \
...@@ -111,7 +113,7 @@ void SMInterface::setValue( UniSetTypes::ObjectId id, long value ) ...@@ -111,7 +113,7 @@ void SMInterface::setValue( UniSetTypes::ObjectId id, long value )
IOController_i::SensorInfo si; IOController_i::SensorInfo si;
si.id = id; si.id = id;
si.node = conf->getLocalNode(); si.node = ui->getConf()->getLocalNode();
BEG_FUNC1(SMInterface::setValue) BEG_FUNC1(SMInterface::setValue)
ui->fastSetValue(si,value,myid); ui->fastSetValue(si,value,myid);
...@@ -137,7 +139,7 @@ void SMInterface::askSensor( UniSetTypes::ObjectId id, UniversalIO::UIOCommand c ...@@ -137,7 +139,7 @@ void SMInterface::askSensor( UniSetTypes::ObjectId id, UniversalIO::UIOCommand c
{ {
ConsumerInfo_var ci; ConsumerInfo_var ci;
ci->id = (backid==DefaultObjectId) ? myid : backid; ci->id = (backid==DefaultObjectId) ? myid : backid;
ci->node = conf->getLocalNode(); ci->node = ui->getConf()->getLocalNode();
if( ic ) if( ic )
{ {
...@@ -224,7 +226,7 @@ void SMInterface::localSetValue( IOController::IOStateList::iterator& it, ...@@ -224,7 +226,7 @@ void SMInterface::localSetValue( IOController::IOStateList::iterator& it,
// CHECK_IC_PTR(localSetValue) // CHECK_IC_PTR(localSetValue)
IOController_i::SensorInfo si; IOController_i::SensorInfo si;
si.id = sid; si.id = sid;
si.node = conf->getLocalNode(); si.node = ui->getConf()->getLocalNode();
ic->localSetValue(it,si.id,value,sup_id); ic->localSetValue(it,si.id,value,sup_id);
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
...@@ -246,7 +248,7 @@ void SMInterface::localSetUndefinedState( IOController::IOStateList::iterator& i ...@@ -246,7 +248,7 @@ void SMInterface::localSetUndefinedState( IOController::IOStateList::iterator& i
{ {
IOController_i::SensorInfo si; IOController_i::SensorInfo si;
si.id = sid; si.id = sid;
si.node = conf->getLocalNode(); si.node = ui->getConf()->getLocalNode();
setUndefinedState(si,undefined,myid); setUndefinedState(si,undefined,myid);
return; return;
} }
......
...@@ -39,8 +39,8 @@ int main(int argc, const char **argv) ...@@ -39,8 +39,8 @@ int main(int argc, const char **argv)
int num = conf->getArgPInt("--numproc",1); int num = conf->getArgPInt("--numproc",1);
for( int i=1; i<=num; i++ ) for( int i=1; i<=num; i++ )
{ {
ostringstream s; ostringstream s;
s << "TestProc" << i; s << "TestProc" << i;
......
...@@ -11,55 +11,55 @@ using namespace UniSetExtensions; ...@@ -11,55 +11,55 @@ using namespace UniSetExtensions;
TEST_CASE("Calibration","[calibration]") TEST_CASE("Calibration","[calibration]")
{ {
Calibration* cal = buildCalibrationDiagram("testcal"); Calibration* cal = buildCalibrationDiagram("testcal");
CHECK( cal!=0 ); CHECK( cal!=0 );
SECTION("getValue") SECTION("getValue")
{ {
REQUIRE( cal->getValue(1500,true) == 600 ); REQUIRE( cal->getValue(1500,true) == 600 );
REQUIRE( cal->getValue(1500,false) == Calibration::outOfRange ); REQUIRE( cal->getValue(1500,false) == Calibration::outOfRange );
REQUIRE( cal->getValue(1000) == 600 ); REQUIRE( cal->getValue(1000) == 600 );
REQUIRE( cal->getValue(933) == 466 ); REQUIRE( cal->getValue(933) == 466 );
REQUIRE( cal->getValue(800) == 300 ); REQUIRE( cal->getValue(800) == 300 );
REQUIRE( cal->getValue(700) == 250 ); REQUIRE( cal->getValue(700) == 250 );
REQUIRE( cal->getValue(600) == 200 ); REQUIRE( cal->getValue(600) == 200 );
REQUIRE( cal->getValue(650) > 200 ); REQUIRE( cal->getValue(650) > 200 );
REQUIRE( cal->getValue(650) < 250 ); REQUIRE( cal->getValue(650) < 250 );
REQUIRE( cal->getValue(200)== 60 ); REQUIRE( cal->getValue(200)== 60 );
REQUIRE( cal->getValue(50) == 20 ); REQUIRE( cal->getValue(50) == 20 );
REQUIRE( cal->getValue(10) == 0 ); REQUIRE( cal->getValue(10) == 0 );
REQUIRE( cal->getValue(5) == 0 ); REQUIRE( cal->getValue(5) == 0 );
REQUIRE( cal->getValue(0) == 0 ); REQUIRE( cal->getValue(0) == 0 );
REQUIRE( cal->getValue(-5) == 0 ); REQUIRE( cal->getValue(-5) == 0 );
REQUIRE( cal->getValue(-10) == 0 ); REQUIRE( cal->getValue(-10) == 0 );
REQUIRE( cal->getValue(-50) == -20 ); REQUIRE( cal->getValue(-50) == -20 );
REQUIRE( cal->getValue(-500) == -80 ); REQUIRE( cal->getValue(-500) == -80 );
REQUIRE( cal->getValue(-900) == -250 ); REQUIRE( cal->getValue(-900) == -250 );
REQUIRE( cal->getValue(-1000) == -300 ); REQUIRE( cal->getValue(-1000) == -300 );
REQUIRE( cal->getValue(-1050,true) == -300 ); REQUIRE( cal->getValue(-1050,true) == -300 );
REQUIRE( cal->getValue(-1050,false) == Calibration::outOfRange ); REQUIRE( cal->getValue(-1050,false) == Calibration::outOfRange );
} }
SECTION("Other function") SECTION("Other function")
{ {
REQUIRE( cal->getMinValue() == -300 ); REQUIRE( cal->getMinValue() == -300 );
REQUIRE( cal->getMaxValue() == 600 ); REQUIRE( cal->getMaxValue() == 600 );
REQUIRE( cal->getLeftValue() == -300 ); REQUIRE( cal->getLeftValue() == -300 );
REQUIRE( cal->getRightValue() == 600 ); REQUIRE( cal->getRightValue() == 600 );
REQUIRE( cal->getRawValue(-80) == -500 ); REQUIRE( cal->getRawValue(-80) == -500 );
REQUIRE( cal->getRawValue(-500,false) == Calibration::outOfRange ); REQUIRE( cal->getRawValue(-500,false) == Calibration::outOfRange );
REQUIRE( cal->getRawValue(-500,true) == -1000 ); REQUIRE( cal->getRawValue(-500,true) == -1000 );
REQUIRE( cal->getRawValue(150) == 500 ); REQUIRE( cal->getRawValue(150) == 500 );
REQUIRE( cal->getRawValue(700,false) == Calibration::outOfRange ); REQUIRE( cal->getRawValue(700,false) == Calibration::outOfRange );
REQUIRE( cal->getRawValue(700,true) == 1000 ); REQUIRE( cal->getRawValue(700,true) == 1000 );
REQUIRE( cal->getMinRaw() == -1000 ); REQUIRE( cal->getMinRaw() == -1000 );
REQUIRE( cal->getMaxRaw() == 1000 ); REQUIRE( cal->getMaxRaw() == 1000 );
REQUIRE( cal->getLeftRaw() == -1000 ); REQUIRE( cal->getLeftRaw() == -1000 );
REQUIRE( cal->getRightRaw() == 1000 ); REQUIRE( cal->getRightRaw() == 1000 );
} }
} }
...@@ -10,86 +10,86 @@ using namespace UniSetExtensions; ...@@ -10,86 +10,86 @@ using namespace UniSetExtensions;
TEST_CASE("DigitalFilter","[DigitalFilter]") TEST_CASE("DigitalFilter","[DigitalFilter]")
{ {
SECTION("..") SECTION("..")
{ {
WARN("List of tests for [DigitalFilter] is not complete (is not sufficient)"); WARN("List of tests for [DigitalFilter] is not complete (is not sufficient)");
}
SECTION("Default constructor (const data)")
{
DigitalFilter df;
DigitalFilter df10(10);
REQUIRE( df.size() == 5 );
REQUIRE( df10.size() == 10 );
for( int i=0; i<20; i++ )
{
df.add(50);
df10.add(50);
}
REQUIRE( df.current1() == 50 );
REQUIRE( df.currentRC() == 50 );
REQUIRE( df.currentMedian() == 50 );
REQUIRE( df10.current1() == 50 );
REQUIRE( df10.currentRC() == 50 );
REQUIRE( df10.currentMedian() == 50 );
} }
SECTION("Median filter") SECTION("Default constructor (const data)")
{ {
DigitalFilter df; DigitalFilter df;
for( int i=0; i<20; i++ ) DigitalFilter df10(10);
df.median(50);
REQUIRE( df.size() == 5 );
REQUIRE( df.currentMedian() == 50 ); REQUIRE( df10.size() == 10 );
DigitalFilter df1; for( int i=0; i<20; i++ )
DigitalFilter df10; {
vector<long> dat={0,234,356,344,234,320,250,250,250,250,250,250,250,251,252,251,252,252,250}; df.add(50);
for( auto v: dat ) df10.add(50);
{ }
df1.median(v);
df10.median(v); REQUIRE( df.current1() == 50 );
} REQUIRE( df.currentRC() == 50 );
REQUIRE( df.currentMedian() == 50 );
REQUIRE( df1.currentMedian() == 252 );
REQUIRE( df10.currentMedian() == 252 ); REQUIRE( df10.current1() == 50 );
REQUIRE( df10.currentRC() == 50 );
REQUIRE( df10.currentMedian() == 50 );
}
SECTION("Median filter")
{
DigitalFilter df;
for( int i=0; i<20; i++ )
df.median(50);
REQUIRE( df.currentMedian() == 50 );
DigitalFilter df1;
DigitalFilter df10;
vector<long> dat={0,234,356,344,234,320,250,250,250,250,250,250,250,251,252,251,252,252,250};
for( auto v: dat )
{
df1.median(v);
df10.median(v);
}
REQUIRE( df1.currentMedian() == 252 );
REQUIRE( df10.currentMedian() == 252 );
} }
SECTION("filter1") SECTION("filter1")
{ {
DigitalFilter df1; DigitalFilter df1;
DigitalFilter df10; DigitalFilter df10;
// "выброс" за СКО отсекается.. // "выброс" за СКО отсекается..
vector<long> dat={10,12,10,-8,10,10,-230,10,10}; vector<long> dat={10,12,10,-8,10,10,-230,10,10};
for( auto v: dat ) for( auto v: dat )
{ {
df1.add(v); df1.add(v);
df10.add(v); df10.add(v);
} }
REQUIRE( df1.current1() == 10 ); REQUIRE( df1.current1() == 10 );
REQUIRE( df10.current1() == 10 ); REQUIRE( df10.current1() == 10 );
} }
SECTION("filterRC") SECTION("filterRC")
{ {
double Ti = 0.09; // постоянная времени фильтра double Ti = 0.09; // постоянная времени фильтра
DigitalFilter df1(5,Ti); DigitalFilter df1(5,Ti);
DigitalFilter df10(10,Ti); DigitalFilter df10(10,Ti);
vector<long> dat={10,12,10,-8,10,10,-230,10,10,12,12,10,-8,-8,10,11,9,11,11,11,9,12,12,10,10,11,-4560,12,10,10,11,10,10,10,10}; vector<long> dat={10,12,10,-8,10,10,-230,10,10,12,12,10,-8,-8,10,11,9,11,11,11,9,12,12,10,10,11,-4560,12,10,10,11,10,10,10,10};
for( auto v: dat ) for( auto v: dat )
{ {
df1.add(v); df1.add(v);
df10.add(v); df10.add(v);
msleep(30); msleep(30);
} }
REQUIRE( df1.currentRC() == 10 ); REQUIRE( df1.currentRC() == 10 );
REQUIRE( df10.currentRC() == 10 ); REQUIRE( df10.currentRC() == 10 );
} }
} }
...@@ -6,21 +6,21 @@ ...@@ -6,21 +6,21 @@
int main( int argc, char* argv[] ) int main( int argc, char* argv[] )
{ {
Catch::Session session; Catch::Session session;
try try
{ {
UniSetTypes::uniset_init(argc,argv); UniSetTypes::uniset_init(argc,argv);
int returnCode = session.applyCommandLine( argc, argv, Catch::Session::OnUnusedOptions::Ignore ); int returnCode = session.applyCommandLine( argc, argv, Catch::Session::OnUnusedOptions::Ignore );
if( returnCode != 0 ) // Indicates a command line error if( returnCode != 0 ) // Indicates a command line error
return returnCode; return returnCode;
return session.run(); return session.run();
} }
catch( UniSetTypes::Exception& ex ) catch( UniSetTypes::Exception& ex )
{ {
std::cerr << ex << std::endl; std::cerr << ex << std::endl;
} }
return 1; return 1;
} }
...@@ -14,23 +14,23 @@ using namespace UniSetExtensions; ...@@ -14,23 +14,23 @@ using namespace UniSetExtensions;
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
int main(int argc, char* argv[] ) int main(int argc, char* argv[] )
{ {
Catch::Session session; Catch::Session session;
if( argc>1 && ( strcmp(argv[1],"--help")==0 || strcmp(argv[1],"-h")==0 ) ) if( argc>1 && ( strcmp(argv[1],"--help")==0 || strcmp(argv[1],"-h")==0 ) )
{ {
cout << "--confile - Использовать указанный конф. файл. По умолчанию configure.xml" << endl; cout << "--confile - Использовать указанный конф. файл. По умолчанию configure.xml" << endl;
SharedMemory::help_print(argc, argv); SharedMemory::help_print(argc, argv);
cout << endl << endl << "--------------- CATCH HELP --------------" << endl; cout << endl << endl << "--------------- CATCH HELP --------------" << endl;
session.showHelp("test_with_sm"); session.showHelp("test_with_sm");
return 0; return 0;
} }
int returnCode = session.applyCommandLine( argc, argv, Catch::Session::OnUnusedOptions::Ignore ); int returnCode = session.applyCommandLine( argc, argv, Catch::Session::OnUnusedOptions::Ignore );
if( returnCode != 0 ) // Indicates a command line error if( returnCode != 0 ) // Indicates a command line error
return returnCode; return returnCode;
try try
{ {
uniset_init(argc,argv); uniset_init(argc,argv);
/* /*
conf->initDebug(dlog,"dlog"); conf->initDebug(dlog,"dlog");
string logfilename = conf->getArgParam("--logfile", "smemory.log"); string logfilename = conf->getArgParam("--logfile", "smemory.log");
...@@ -52,18 +52,18 @@ int main(int argc, char* argv[] ) ...@@ -52,18 +52,18 @@ int main(int argc, char* argv[] )
int tout = 6000; int tout = 6000;
PassiveTimer pt(tout); PassiveTimer pt(tout);
while( !pt.checkTime() && !act->exist() ) while( !pt.checkTime() && !act->exist() )
msleep(100); msleep(100);
if( !act->exist() ) if( !act->exist() )
{ {
cerr << "(tests_with_sm): SharedMemory not exist! (timeout=" << tout << ")" << endl; cerr << "(tests_with_sm): SharedMemory not exist! (timeout=" << tout << ")" << endl;
return 1; return 1;
} }
int ret = session.run(); int ret = session.run();
act->oaDestroy(); act->oaDestroy();
return ret; return ret;
} }
catch( SystemError& err ) catch( SystemError& err )
{ {
......
...@@ -229,17 +229,14 @@ namespace UniSetTypes ...@@ -229,17 +229,14 @@ namespace UniSetTypes
int heartbeat_msec; int heartbeat_msec;
}; };
/*! Глобальный указатель на конфигуратор */ /*! Глобальный указатель на конфигурацию (singleton) */
extern Configuration* conf; std::shared_ptr<Configuration> uniset_conf();
/*! Глобальный объект для вывода логов */ /*! Глобальный объект для вывода логов */
extern DebugStream ulog; extern DebugStream ulog;
// Инициализация UniSetTypes::conf. /*! инициализация "глобальной" конфигурации */
// ( учитываются параметры командной строки --confile и --id-from-config ) std::shared_ptr<Configuration> uniset_init( int argc, const char* const* argv, const std::string& xmlfile="configure.xml" );
// force - инициализировать принудительно, даже если это повторная инициализация
void uniset_init( int argc, const char* const* argv, const std::string& xmlfile="configure.xml", bool force = false );
} // end of UniSetTypes namespace } // end of UniSetTypes namespace
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
......
...@@ -115,10 +115,10 @@ class DelayTimer ...@@ -115,10 +115,10 @@ class DelayTimer
return state; return state;
} }
inline bool get(){ return check(prevState); } inline bool get(){ return check(prevState); }
inline timeout_t getOnDelay(){ return onDelay; } inline timeout_t getOnDelay(){ return onDelay; }
inline timeout_t getOffDelay(){ return offDelay; } inline timeout_t getOffDelay(){ return offDelay; }
protected: protected:
PassiveTimer pt; PassiveTimer pt;
......
...@@ -95,13 +95,13 @@ class HourGlass ...@@ -95,13 +95,13 @@ class HourGlass
_state = st; _state = st;
if( !_state ) if( !_state )
{ {
timeout_t cur = t.getCurrent(); timeout_t cur = t.getCurrent();
if( cur > _size ) if( cur > _size )
cur = _size; cur = _size;
_sand -= cur; _sand -= cur;
if( _sand < 0 ) if( _sand < 0 )
_sand = 0; _sand = 0;
t.setTiming(cur); t.setTiming(cur);
} }
...@@ -123,7 +123,7 @@ class HourGlass ...@@ -123,7 +123,7 @@ class HourGlass
// получить прошедшее время // получить прошедшее время
inline timeout_t current() inline timeout_t current()
{ {
return t.getCurrent(); return t.getCurrent();
} }
// получить заданное время // получить заданное время
...@@ -145,36 +145,36 @@ class HourGlass ...@@ -145,36 +145,36 @@ class HourGlass
inline bool state(){ return _state; } inline bool state(){ return _state; }
// текущее "насыпавшееся" количество "песка" // текущее "насыпавшееся" количество "песка"
inline timeout_t amount() inline timeout_t amount()
{ {
return ( _size - remain() ); return ( _size - remain() );
} }
// остаток песка (времени) // остаток песка (времени)
inline timeout_t remain() inline timeout_t remain()
{ {
timeout_t c = t.getCurrent(); timeout_t c = t.getCurrent();
if( c > _size ) if( c > _size )
c = _size; c = _size;
// _state=false - означает, что песок пересыпается обратно.. // _state=false - означает, что песок пересыпается обратно..
if( !_state ) if( !_state )
{ {
int ret = ( _sand + c ); int ret = ( _sand + c );
if( ret > _size ) if( ret > _size )
return _size; return _size;
return ret; return ret;
} }
// _state=true - означает, что песок пересыпается.. // _state=true - означает, что песок пересыпается..
int ret = ( _sand - c ); int ret = ( _sand - c );
if( ret < 0 ) if( ret < 0 )
return 0; return 0;
return ret; return ret;
} }
protected: protected:
PassiveTimer t; /*!< таймер для отсчёта времени.. */ PassiveTimer t; /*!< таймер для отсчёта времени.. */
......
...@@ -81,7 +81,7 @@ class IOController: ...@@ -81,7 +81,7 @@ class IOController:
IOController_i::CalibrateInfo getCalibrateInfo( UniSetTypes::ObjectId sid ) override; IOController_i::CalibrateInfo getCalibrateInfo( UniSetTypes::ObjectId sid ) override;
inline IOController_i::SensorInfo SensorInfo( const UniSetTypes::ObjectId sid, inline IOController_i::SensorInfo SensorInfo( const UniSetTypes::ObjectId sid,
const UniSetTypes::ObjectId node=UniSetTypes::conf->getLocalNode()) const UniSetTypes::ObjectId node=UniSetTypes::uniset_conf()->getLocalNode())
{ {
IOController_i::SensorInfo si; IOController_i::SensorInfo si;
si.id = sid; si.id = sid;
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
class LogSession; class LogSession;
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
/*! \page pgLogServer Лог сервер /*! \page pgLogServer Лог сервер
Лог сервер предназначен для возможности удалённого чтения логов (DebugStream). Лог сервер предназначен для возможности удалённого чтения логов (DebugStream).
Ему указывается host и port для прослушивания запросов, которые можно делать при помощи Ему указывается host и port для прослушивания запросов, которые можно делать при помощи
LogReader. Читающих клиентов может быть скольугодно много, на каждого создаётся своя "сессия"(LogSession). LogReader. Читающих клиентов может быть скольугодно много, на каждого создаётся своя "сессия"(LogSession).
При этом через лог сервер имеется возможность управлять включением или отключением определённых уровней логов, При этом через лог сервер имеется возможность управлять включением или отключением определённых уровней логов,
......
############################################################################ ############################################################################
# This file is part of the UniSet library # # This file is part of the UniSet library #
############################################################################ ############################################################################
SUBDIRS=modbus SUBDIRS=modbus
......
...@@ -24,7 +24,8 @@ ...@@ -24,7 +24,8 @@
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
#ifndef ObjectRepository_H_ #ifndef ObjectRepository_H_
#define ObjectRepository_H_ #define ObjectRepository_H_
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
#include <memory>
#include <omniORB4/CORBA.h> #include <omniORB4/CORBA.h>
#include <omniORB4/Naming.hh> #include <omniORB4/Naming.hh>
#include <string> #include <string>
...@@ -46,7 +47,7 @@ ...@@ -46,7 +47,7 @@
{ {
public: public:
ObjectRepository( const UniSetTypes::Configuration* conf); ObjectRepository( const std::shared_ptr<UniSetTypes::Configuration>& conf );
~ObjectRepository(); ~ObjectRepository();
/** /**
...@@ -100,7 +101,7 @@ ...@@ -100,7 +101,7 @@
ObjectRepository(); ObjectRepository();
mutable std::string nsName; mutable std::string nsName;
const UniSetTypes::Configuration* uconf; std::shared_ptr<UniSetTypes::Configuration> uconf;
bool list(const std::string& section, UniSetTypes::ListObjectName *ls, unsigned int how_many, ObjectType type); bool list(const std::string& section, UniSetTypes::ListObjectName *ls, unsigned int how_many, ObjectType type);
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
public: public:
// ObjectRepositoryFactory(); // ObjectRepositoryFactory();
// ObjectRepositoryFactory(int* argc=argc_ptr, char* **argv=argv_ptr); // параметры инициализации ORB // ObjectRepositoryFactory(int* argc=argc_ptr, char* **argv=argv_ptr); // параметры инициализации ORB
ObjectRepositoryFactory( UniSetTypes::Configuration* conf ); ObjectRepositoryFactory( const std::shared_ptr<UniSetTypes::Configuration>& conf );
~ObjectRepositoryFactory(); ~ObjectRepositoryFactory();
//! Создание секции //! Создание секции
......
...@@ -65,8 +65,8 @@ class UInterface ...@@ -65,8 +65,8 @@ class UInterface
{ {
public: public:
UInterface( const UniSetTypes::ObjectId backid, CORBA::ORB_var orb=NULL, std::shared_ptr<UniSetTypes::ObjectIndex> oind=nullptr ); UInterface( const UniSetTypes::ObjectId backid, CORBA::ORB_var orb=NULL, const std::shared_ptr<UniSetTypes::ObjectIndex> oind=nullptr );
UInterface( const UniSetTypes::Configuration* uconf=UniSetTypes::conf ); UInterface( const std::shared_ptr<UniSetTypes::Configuration>& uconf = UniSetTypes::uniset_conf() );
~UInterface(); ~UInterface();
// --------------------------------------------------------------- // ---------------------------------------------------------------
...@@ -154,7 +154,7 @@ class UInterface ...@@ -154,7 +154,7 @@ class UInterface
//! Получить список датчиков //! Получить список датчиков
IOController_i::ShortMapSeq* getSensors( const UniSetTypes::ObjectId id, IOController_i::ShortMapSeq* getSensors( const UniSetTypes::ObjectId id,
const UniSetTypes::ObjectId node=UniSetTypes::conf->getLocalNode() ); const UniSetTypes::ObjectId node = UniSetTypes::uniset_conf()->getLocalNode() );
// --------------------------------------------------------------- // ---------------------------------------------------------------
// Работа с репозиторием // Работа с репозиторием
...@@ -185,10 +185,10 @@ class UInterface ...@@ -185,10 +185,10 @@ class UInterface
bool isExist( const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node ) const; bool isExist( const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node ) const;
bool waitReady( const UniSetTypes::ObjectId id, int msec, int pause=5000, bool waitReady( const UniSetTypes::ObjectId id, int msec, int pause=5000,
const UniSetTypes::ObjectId node = UniSetTypes::conf->getLocalNode() ); // used exist const UniSetTypes::ObjectId node = UniSetTypes::uniset_conf()->getLocalNode() ); // used exist
bool waitWorking( const UniSetTypes::ObjectId id, int msec, int pause=3000, bool waitWorking( const UniSetTypes::ObjectId id, int msec, int pause=3000,
const UniSetTypes::ObjectId node = UniSetTypes::conf->getLocalNode() ); // used getValue const UniSetTypes::ObjectId node = UniSetTypes::uniset_conf()->getLocalNode() ); // used getValue
// --------------------------------------------------------------- // ---------------------------------------------------------------
// Работа с ID, Name // Работа с ID, Name
...@@ -222,8 +222,7 @@ class UInterface ...@@ -222,8 +222,7 @@ class UInterface
// --------------------------------------------------------------- // ---------------------------------------------------------------
// Получение указателей на вспомогательные классы. // Получение указателей на вспомогательные классы.
inline const std::shared_ptr<UniSetTypes::ObjectIndex> getObjectIndex() { return oind; } inline const std::shared_ptr<UniSetTypes::ObjectIndex> getObjectIndex() { return oind; }
inline const UniSetTypes::Configuration* getConf() { return uconf; } inline const std::shared_ptr<UniSetTypes::Configuration> getConf() { return uconf; }
// --------------------------------------------------------------- // ---------------------------------------------------------------
// Посылка сообщений // Посылка сообщений
...@@ -302,7 +301,7 @@ class UInterface ...@@ -302,7 +301,7 @@ class UInterface
mutable CORBA::ORB_var orb; mutable CORBA::ORB_var orb;
CacheOfResolve rcache; CacheOfResolve rcache;
std::shared_ptr<UniSetTypes::ObjectIndex> oind; std::shared_ptr<UniSetTypes::ObjectIndex> oind;
const UniSetTypes::Configuration* uconf; std::shared_ptr<UniSetTypes::Configuration> uconf;
}; };
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
#endif #endif
......
...@@ -134,22 +134,22 @@ class UniSetActivator: ...@@ -134,22 +134,22 @@ class UniSetActivator:
struct Info struct Info
{ {
Info( pid_t p ):msgpid(p){} Info( pid_t p ):msgpid(p){}
pid_t msgpid; // pid порожденого потока обработки сообщений pid_t msgpid; // pid порожденого потока обработки сообщений
}; };
struct OInfo: struct OInfo:
public Info public Info
{ {
OInfo( UniSetObject* o, pid_t p ):Info(p),obj(o){} OInfo( UniSetObject* o, pid_t p ):Info(p),obj(o){}
UniSetObject* obj; UniSetObject* obj;
}; };
struct MInfo: struct MInfo:
public Info public Info
{ {
MInfo( UniSetManager* m, pid_t p ):Info(p),mnr(m){} MInfo( UniSetManager* m, pid_t p ):Info(p),mnr(m){}
UniSetManager* mnr; UniSetManager* mnr;
}; };
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#ifndef UniSetTypes_H_ #ifndef UniSetTypes_H_
#define UniSetTypes_H_ #define UniSetTypes_H_
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
#include <memory>
#include <cstdlib> #include <cstdlib>
#include <cstdio> #include <cstdio>
#include <string> #include <string>
...@@ -46,8 +47,6 @@ inline void msleep( unsigned int m ) { usleep(m*1000); } ...@@ -46,8 +47,6 @@ inline void msleep( unsigned int m ) { usleep(m*1000); }
namespace UniSetTypes namespace UniSetTypes
{ {
class Configuration; class Configuration;
extern Configuration* conf;
// --------------------------------------------------------------- // ---------------------------------------------------------------
// Вспомогательные типы данных и константы // Вспомогательные типы данных и константы
...@@ -172,7 +171,7 @@ namespace UniSetTypes ...@@ -172,7 +171,7 @@ namespace UniSetTypes
/*! Функция разбора строки вида: id1@node1=val1,id2@node2=val2,... /*! Функция разбора строки вида: id1@node1=val1,id2@node2=val2,...
Если '=' не указано, возвращается val=0 Если '=' не указано, возвращается val=0
Если @node не указано, возвращается node=DefaultObjectId */ Если @node не указано, возвращается node=DefaultObjectId */
std::list<ParamSInfo> getSInfoList( const std::string& s, Configuration* conf=UniSetTypes::conf ); std::list<ParamSInfo> getSInfoList( const std::string& s, std::shared_ptr<UniSetTypes::Configuration> conf = nullptr );
/*! проверка является текст в строке - числом..*/ /*! проверка является текст в строке - числом..*/
bool is_digit( const std::string& s ); bool is_digit( const std::string& s );
......
...@@ -68,20 +68,20 @@ class UniXML_iterator: ...@@ -68,20 +68,20 @@ class UniXML_iterator:
bool canPrev(); bool canPrev();
bool canNext(); bool canNext();
#if 0 #if 0
friend inline bool operator==(const UniXML_iterator& lhs, const UniXML_iterator& rhs) friend inline bool operator==(const UniXML_iterator& lhs, const UniXML_iterator& rhs)
{ {
return ( lhs.curNode != 0 && rhs.curNode!=0 && lhs.curNode == rhs.curNode ); return ( lhs.curNode != 0 && rhs.curNode!=0 && lhs.curNode == rhs.curNode );
} }
friend inline bool operator!=(const UniXML_iterator& lhs, const UniXML_iterator& rhs){return !(lhs == rhs);} friend inline bool operator!=(const UniXML_iterator& lhs, const UniXML_iterator& rhs){return !(lhs == rhs);}
inline bool operator==(int a) inline bool operator==(int a)
{ {
if( a == 0 ) if( a == 0 )
return (curNode == NULL); return (curNode == NULL);
return false; return false;
} }
#endif #endif
// Перейти к следующему узлу // Перейти к следующему узлу
UniXML_iterator operator+(int); UniXML_iterator operator+(int);
...@@ -115,12 +115,12 @@ class UniXML_iterator: ...@@ -115,12 +115,12 @@ class UniXML_iterator:
inline const std::string getName() const inline const std::string getName() const
{ {
if( curNode ) if( curNode )
{ {
if( !curNode->name ) if( !curNode->name )
return ""; return "";
return (char*) curNode->name; return (char*) curNode->name;
} }
return ""; return "";
} }
...@@ -227,9 +227,9 @@ public: ...@@ -227,9 +227,9 @@ public:
xmlNode* findNode( xmlNode* node, const std::string& searchnode, const std::string& name = "") const; xmlNode* findNode( xmlNode* node, const std::string& searchnode, const std::string& name = "") const;
xmlNode* findNodeUtf8( xmlNode* node, const std::string& searchnode, const std::string& name = "") const; xmlNode* findNodeUtf8( xmlNode* node, const std::string& searchnode, const std::string& name = "") const;
// ?? // ??
//width means number of nodes of the same level as node in 1-st parameter (width number includes first node) //width means number of nodes of the same level as node in 1-st parameter (width number includes first node)
//depth means number of times we can go to the children, if 0 we can't go only to elements of the same level //depth means number of times we can go to the children, if 0 we can't go only to elements of the same level
xmlNode* extFindNode( xmlNode* node, int depth, int width, const std::string& searchnode, const std::string& name = "", bool top=true ) const; xmlNode* extFindNode( xmlNode* node, int depth, int width, const std::string& searchnode, const std::string& name = "", bool top=true ) const;
xmlNode* extFindNodeUtf8( xmlNode* node, int depth, int width, const std::string& searchnode, const std::string& name = "", bool top=true ) const; xmlNode* extFindNodeUtf8( xmlNode* node, int depth, int width, const std::string& searchnode, const std::string& name = "", bool top=true ) const;
......
...@@ -1017,7 +1017,7 @@ namespace ModbusRTU ...@@ -1017,7 +1017,7 @@ namespace ModbusRTU
/*! проверка на переполнение */ /*! проверка на переполнение */
inline bool isFull() inline bool isFull()
{ {
// (1)subf + data count // (1)subf + data count
return ( 1+count >= MAXDATALEN ); return ( 1+count >= MAXDATALEN );
} }
......
...@@ -36,10 +36,11 @@ void pyUInterface::uniset_init( int argc, char* argv[], const char* xmlfile )thr ...@@ -36,10 +36,11 @@ void pyUInterface::uniset_init( int argc, char* argv[], const char* xmlfile )thr
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
long pyUInterface::getValue( long id )throw(UException) long pyUInterface::getValue( long id )throw(UException)
{ {
if( !UniSetTypes::conf || !ui ) auto conf = UniSetTypes::uniset_conf();
if( !conf || !ui )
throw USysError(); throw USysError();
UniversalIO::IOType t = UniSetTypes::conf->getIOType(id); UniversalIO::IOType t = conf->getIOType(id);
try try
{ {
switch(t) switch(t)
...@@ -77,10 +78,12 @@ long pyUInterface::getValue( long id )throw(UException) ...@@ -77,10 +78,12 @@ long pyUInterface::getValue( long id )throw(UException)
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void pyUInterface::setValue( long id, long val )throw(UException) void pyUInterface::setValue( long id, long val )throw(UException)
{ {
if( !UniSetTypes::conf || !ui ) auto conf = UniSetTypes::uniset_conf();
if( !conf || !ui )
throw USysError(); throw USysError();
UniversalIO::IOType t = UniSetTypes::conf->getIOType(id); UniversalIO::IOType t = conf->getIOType(id);
try try
{ {
switch(t) switch(t)
...@@ -116,40 +119,45 @@ void pyUInterface::setValue( long id, long val )throw(UException) ...@@ -116,40 +119,45 @@ void pyUInterface::setValue( long id, long val )throw(UException)
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
long pyUInterface::getSensorID( const char* name ) long pyUInterface::getSensorID( const char* name )
{ {
if( UniSetTypes::conf ) auto conf = UniSetTypes::uniset_conf();
return UniSetTypes::conf->getSensorID(name); if( conf )
return conf->getSensorID(name);
return UniSetTypes::DefaultObjectId; return UniSetTypes::DefaultObjectId;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
const char* pyUInterface::getName( long id ) const char* pyUInterface::getName( long id )
{ {
if( UniSetTypes::conf ) auto conf = UniSetTypes::uniset_conf();
return UniSetTypes::conf->oind->getMapName(id).c_str(); if( conf )
return conf->oind->getMapName(id).c_str();
return ""; return "";
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
const char* pyUInterface::getShortName( long id ) const char* pyUInterface::getShortName( long id )
{ {
if( UniSetTypes::conf ) auto conf = UniSetTypes::uniset_conf();
return ORepHelpers::getShortName(UniSetTypes::conf->oind->getMapName(id)).c_str(); if( conf )
return ORepHelpers::getShortName(conf->oind->getMapName(id)).c_str();
return ""; return "";
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
const char* pyUInterface::getTextName( long id ) const char* pyUInterface::getTextName( long id )
{ {
if( UniSetTypes::conf ) auto conf = UniSetTypes::uniset_conf();
return UniSetTypes::conf->oind->getTextName(id).c_str(); if( conf )
return conf->oind->getTextName(id).c_str();
return ""; return "";
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
const char* pyUInterface::getConfFileName() const char* pyUInterface::getConfFileName()
{ {
if( UniSetTypes::conf ) auto conf = UniSetTypes::uniset_conf();
return UniSetTypes::conf->getConfFileName().c_str(); if( conf )
return conf->getConfFileName().c_str();
return ""; return "";
......
...@@ -10,8 +10,8 @@ xmlfile(xfile) ...@@ -10,8 +10,8 @@ xmlfile(xfile)
{ {
try try
{ {
conf = new UniSetTypes::Configuration(p->argc,p->argv,xmlfile); conf = UniSetTypes::uniset_init(p->argc,p->argv,xmlfile);
ui = new UInterface(conf); ui = make_shared<UInterface>(conf);
} }
catch( UniSetTypes::Exception& ex ) catch( UniSetTypes::Exception& ex )
{ {
...@@ -30,8 +30,8 @@ xmlfile(xfile) ...@@ -30,8 +30,8 @@ xmlfile(xfile)
{ {
try try
{ {
conf = new UniSetTypes::Configuration(argc,argv,xmlfile); conf = UniSetTypes::uniset_init(argc,argv,xmlfile);
ui = new UInterface(conf); ui = make_shared<UInterface>(conf);
} }
catch( UniSetTypes::Exception& ex ) catch( UniSetTypes::Exception& ex )
{ {
...@@ -45,8 +45,6 @@ xmlfile(xfile) ...@@ -45,8 +45,6 @@ xmlfile(xfile)
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
UConnector::~UConnector() UConnector::~UConnector()
{ {
delete ui;
delete conf;
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
const char* UConnector::getConfFileName() const char* UConnector::getConfFileName()
......
#ifndef UConnector_H_ #ifndef UConnector_H_
#define UConnector_H_ #define UConnector_H_
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
#include <memory>
#include <string> #include <string>
#include "Configuration.h" #include "Configuration.h"
#include "UInterface.h" #include "UInterface.h"
...@@ -29,8 +30,8 @@ class UConnector ...@@ -29,8 +30,8 @@ class UConnector
private: private:
UniSetTypes::Configuration* conf; std::shared_ptr<UniSetTypes::Configuration> conf;
UInterface* ui; std::shared_ptr<UInterface> ui;
const char* xmlfile; const char* xmlfile;
}; };
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
......
/* ---------------------------------------------------------------------------- /* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org). * This file was automatically generated by SWIG (http://www.swig.org).
* Version 3.0.0 * Version 3.0.2
* *
* This file is not intended to be easily readable and contains a number of * This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make * coding conventions designed to improve portability and efficiency. Do not make
...@@ -2965,7 +2965,7 @@ static swig_module_info swig_module = {swig_types, 5, 0, 0, 0, 0}; ...@@ -2965,7 +2965,7 @@ static swig_module_info swig_module = {swig_types, 5, 0, 0, 0, 0};
#endif #endif
#define SWIG_name "_pyUConnector" #define SWIG_name "_pyUConnector"
#define SWIGVERSION 0x030000 #define SWIGVERSION 0x030002
#define SWIG_VERSION SWIGVERSION #define SWIG_VERSION SWIGVERSION
...@@ -3305,7 +3305,11 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size) ...@@ -3305,7 +3305,11 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size)
SWIG_InternalNewPointerObj(const_cast< char * >(carray), pchar_descriptor, 0) : SWIG_Py_Void(); SWIG_InternalNewPointerObj(const_cast< char * >(carray), pchar_descriptor, 0) : SWIG_Py_Void();
} else { } else {
#if PY_VERSION_HEX >= 0x03000000 #if PY_VERSION_HEX >= 0x03000000
#if PY_VERSION_HEX >= 0x03010000
return PyUnicode_DecodeUTF8(carray, static_cast< int >(size), "surrogateescape");
#else
return PyUnicode_FromStringAndSize(carray, static_cast< int >(size)); return PyUnicode_FromStringAndSize(carray, static_cast< int >(size));
#endif
#else #else
return PyString_FromStringAndSize(carray, static_cast< int >(size)); return PyString_FromStringAndSize(carray, static_cast< int >(size));
#endif #endif
......
/* ---------------------------------------------------------------------------- /* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org). * This file was automatically generated by SWIG (http://www.swig.org).
* Version 3.0.0 * Version 3.0.2
* *
* This file is not intended to be easily readable and contains a number of * This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make * coding conventions designed to improve portability and efficiency. Do not make
...@@ -2965,7 +2965,7 @@ static swig_module_info swig_module = {swig_types, 5, 0, 0, 0, 0}; ...@@ -2965,7 +2965,7 @@ static swig_module_info swig_module = {swig_types, 5, 0, 0, 0, 0};
#endif #endif
#define SWIG_name "_pyUExceptions" #define SWIG_name "_pyUExceptions"
#define SWIGVERSION 0x030000 #define SWIGVERSION 0x030002
#define SWIG_VERSION SWIGVERSION #define SWIG_VERSION SWIGVERSION
...@@ -3143,7 +3143,11 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size) ...@@ -3143,7 +3143,11 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size)
SWIG_InternalNewPointerObj(const_cast< char * >(carray), pchar_descriptor, 0) : SWIG_Py_Void(); SWIG_InternalNewPointerObj(const_cast< char * >(carray), pchar_descriptor, 0) : SWIG_Py_Void();
} else { } else {
#if PY_VERSION_HEX >= 0x03000000 #if PY_VERSION_HEX >= 0x03000000
#if PY_VERSION_HEX >= 0x03010000
return PyUnicode_DecodeUTF8(carray, static_cast< int >(size), "surrogateescape");
#else
return PyUnicode_FromStringAndSize(carray, static_cast< int >(size)); return PyUnicode_FromStringAndSize(carray, static_cast< int >(size));
#endif
#else #else
return PyString_FromStringAndSize(carray, static_cast< int >(size)); return PyString_FromStringAndSize(carray, static_cast< int >(size));
#endif #endif
......
/* ---------------------------------------------------------------------------- /* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org). * This file was automatically generated by SWIG (http://www.swig.org).
* Version 3.0.0 * Version 3.0.2
* *
* This file is not intended to be easily readable and contains a number of * This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make * coding conventions designed to improve portability and efficiency. Do not make
...@@ -2967,7 +2967,7 @@ static swig_module_info swig_module = {swig_types, 7, 0, 0, 0, 0}; ...@@ -2967,7 +2967,7 @@ static swig_module_info swig_module = {swig_types, 7, 0, 0, 0, 0};
#endif #endif
#define SWIG_name "_pyUniSet" #define SWIG_name "_pyUniSet"
#define SWIGVERSION 0x030000 #define SWIGVERSION 0x030002
#define SWIG_VERSION SWIGVERSION #define SWIG_VERSION SWIGVERSION
...@@ -3293,7 +3293,11 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size) ...@@ -3293,7 +3293,11 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size)
SWIG_InternalNewPointerObj(const_cast< char * >(carray), pchar_descriptor, 0) : SWIG_Py_Void(); SWIG_InternalNewPointerObj(const_cast< char * >(carray), pchar_descriptor, 0) : SWIG_Py_Void();
} else { } else {
#if PY_VERSION_HEX >= 0x03000000 #if PY_VERSION_HEX >= 0x03000000
#if PY_VERSION_HEX >= 0x03010000
return PyUnicode_DecodeUTF8(carray, static_cast< int >(size), "surrogateescape");
#else
return PyUnicode_FromStringAndSize(carray, static_cast< int >(size)); return PyUnicode_FromStringAndSize(carray, static_cast< int >(size));
#endif
#else #else
return PyString_FromStringAndSize(carray, static_cast< int >(size)); return PyString_FromStringAndSize(carray, static_cast< int >(size));
#endif #endif
......
/* ---------------------------------------------------------------------------- /* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org). * This file was automatically generated by SWIG (http://www.swig.org).
* Version 3.0.0 * Version 3.0.2
* *
* This file is not intended to be easily readable and contains a number of * This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make * coding conventions designed to improve portability and efficiency. Do not make
...@@ -2968,7 +2968,7 @@ static swig_module_info swig_module = {swig_types, 8, 0, 0, 0, 0}; ...@@ -2968,7 +2968,7 @@ static swig_module_info swig_module = {swig_types, 8, 0, 0, 0, 0};
#endif #endif
#define SWIG_name "_pyUModbus" #define SWIG_name "_pyUModbus"
#define SWIGVERSION 0x030000 #define SWIGVERSION 0x030002
#define SWIG_VERSION SWIGVERSION #define SWIG_VERSION SWIGVERSION
...@@ -3067,7 +3067,11 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size) ...@@ -3067,7 +3067,11 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size)
SWIG_InternalNewPointerObj(const_cast< char * >(carray), pchar_descriptor, 0) : SWIG_Py_Void(); SWIG_InternalNewPointerObj(const_cast< char * >(carray), pchar_descriptor, 0) : SWIG_Py_Void();
} else { } else {
#if PY_VERSION_HEX >= 0x03000000 #if PY_VERSION_HEX >= 0x03000000
#if PY_VERSION_HEX >= 0x03010000
return PyUnicode_DecodeUTF8(carray, static_cast< int >(size), "surrogateescape");
#else
return PyUnicode_FromStringAndSize(carray, static_cast< int >(size)); return PyUnicode_FromStringAndSize(carray, static_cast< int >(size));
#endif
#else #else
return PyString_FromStringAndSize(carray, static_cast< int >(size)); return PyString_FromStringAndSize(carray, static_cast< int >(size));
#endif #endif
......
# This file was automatically generated by SWIG (http://www.swig.org). # This file was automatically generated by SWIG (http://www.swig.org).
# Version 3.0.0 # Version 3.0.2
# #
# Do not make changes to this file unless you know what you are doing--modify # Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead. # the SWIG interface file instead.
......
# This file was automatically generated by SWIG (http://www.swig.org). # This file was automatically generated by SWIG (http://www.swig.org).
# Version 3.0.0 # Version 3.0.2
# #
# Do not make changes to this file unless you know what you are doing--modify # Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead. # the SWIG interface file instead.
......
# This file was automatically generated by SWIG (http://www.swig.org). # This file was automatically generated by SWIG (http://www.swig.org).
# Version 3.0.0 # Version 3.0.2
# #
# Do not make changes to this file unless you know what you are doing--modify # Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead. # the SWIG interface file instead.
......
# This file was automatically generated by SWIG (http://www.swig.org). # This file was automatically generated by SWIG (http://www.swig.org).
# Version 3.0.0 # Version 3.0.2
# #
# Do not make changes to this file unless you know what you are doing--modify # Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead. # the SWIG interface file instead.
......
...@@ -1042,16 +1042,16 @@ mbErrCode ModbusClient::recv_pdu( ModbusByte qfunc, ModbusMessage& rbuf, timeout ...@@ -1042,16 +1042,16 @@ mbErrCode ModbusClient::recv_pdu( ModbusByte qfunc, ModbusMessage& rbuf, timeout
ostringstream err; ostringstream err;
err << "(0x50): bad crc. calc.crc=" << dat2str(tcrc) err << "(0x50): bad crc. calc.crc=" << dat2str(tcrc)
<< " msg.crc=" << dat2str(mSet.crc); << " msg.crc=" << dat2str(mSet.crc);
if( dlog.is_warn() ) if( dlog.is_warn() )
dlog.warn() << err.str() << endl; dlog.warn() << err.str() << endl;
return erBadCheckSum; return erBadCheckSum;
} }
} }
if( !mSet.checkFormat() ) if( !mSet.checkFormat() )
{ {
if( dlog.is_warn() ) if( dlog.is_warn() )
dlog.warn() << "(0x50): некорректные значения..." << endl; dlog.warn() << "(0x50): некорректные значения..." << endl;
return erBadDataValue; // return erInvalidFormat; return erBadDataValue; // return erInvalidFormat;
} }
...@@ -1070,13 +1070,13 @@ mbErrCode ModbusClient::recv_pdu( ModbusByte qfunc, ModbusMessage& rbuf, timeout ...@@ -1070,13 +1070,13 @@ mbErrCode ModbusClient::recv_pdu( ModbusByte qfunc, ModbusMessage& rbuf, timeout
if( rlen1 < szDataLen ) if( rlen1 < szDataLen )
{ {
rbuf.len = bcnt + rlen1 - szModbusHeader; rbuf.len = bcnt + rlen1 - szModbusHeader;
if( dlog.is_warn() ) if( dlog.is_warn() )
{ {
dlog.warn() << "(0x66): buf: " << rbuf << endl; dlog.warn() << "(0x66): buf: " << rbuf << endl;
dlog.warn() << "(0x66)(" dlog.warn() << "(0x66)("
<< rbuf.func << "):(fnFileTransfer) " << rbuf.func << "):(fnFileTransfer) "
<< "Получили данных меньше чем ждали...(" << "Получили данных меньше чем ждали...("
<< rlen1 << " < " << szDataLen << ")" << endl; << rlen1 << " < " << szDataLen << ")" << endl;
} }
cleanupChannel(); cleanupChannel();
return erInvalidFormat; return erInvalidFormat;
...@@ -1102,8 +1102,8 @@ mbErrCode ModbusClient::recv_pdu( ModbusByte qfunc, ModbusMessage& rbuf, timeout ...@@ -1102,8 +1102,8 @@ mbErrCode ModbusClient::recv_pdu( ModbusByte qfunc, ModbusMessage& rbuf, timeout
ostringstream err; ostringstream err;
err << "(0x66): bad crc. calc.crc=" << dat2str(tcrc) err << "(0x66): bad crc. calc.crc=" << dat2str(tcrc)
<< " msg.crc=" << dat2str(mFT.crc); << " msg.crc=" << dat2str(mFT.crc);
if( dlog.is_warn() ) if( dlog.is_warn() )
dlog.warn() << err.str() << endl; dlog.warn() << err.str() << endl;
return erBadCheckSum; return erBadCheckSum;
} }
...@@ -1236,14 +1236,14 @@ mbErrCode ModbusClient::send( ModbusMessage& msg ) ...@@ -1236,14 +1236,14 @@ mbErrCode ModbusClient::send( ModbusMessage& msg )
} }
catch( mbException& ex ) catch( mbException& ex )
{ {
if( dlog.is_crit() ) if( dlog.is_crit() )
dlog.crit() << "(send): " << ex << endl; dlog.crit() << "(send): " << ex << endl;
return ex.err; return ex.err;
} }
catch( Exception& ex ) // SystemError catch( Exception& ex ) // SystemError
{ {
if( dlog.is_crit() ) if( dlog.is_crit() )
dlog.crit() << "(send): " << ex << endl; dlog.crit() << "(send): " << ex << endl;
return erHardwareError; return erHardwareError;
} }
......
...@@ -40,7 +40,7 @@ using namespace UniversalIO; ...@@ -40,7 +40,7 @@ using namespace UniversalIO;
using namespace UniSetTypes; using namespace UniSetTypes;
using namespace std; using namespace std;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
UInterface::UInterface( const UniSetTypes::Configuration* _uconf ): UInterface::UInterface( const std::shared_ptr<UniSetTypes::Configuration>& _uconf ):
rep(_uconf), rep(_uconf),
myid(UniSetTypes::DefaultObjectId), myid(UniSetTypes::DefaultObjectId),
orb(CORBA::ORB::_nil()), orb(CORBA::ORB::_nil()),
...@@ -51,15 +51,15 @@ UInterface::UInterface( const UniSetTypes::Configuration* _uconf ): ...@@ -51,15 +51,15 @@ UInterface::UInterface( const UniSetTypes::Configuration* _uconf ):
init(); init();
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
UInterface::UInterface( const ObjectId backid, CORBA::ORB_var orb, shared_ptr<ObjectIndex> _oind ): UInterface::UInterface( const ObjectId backid, CORBA::ORB_var orb, const shared_ptr<ObjectIndex> _oind ):
rep(UniSetTypes::conf), rep(UniSetTypes::uniset_conf()),
myid(backid), myid(backid),
orb(orb), orb(orb),
rcache(200,40), rcache(200,40),
oind(_oind), oind(_oind),
uconf(UniSetTypes::conf) uconf(UniSetTypes::uniset_conf())
{ {
if( oind == NULL ) if( oind == nullptr )
oind = uconf->oind; oind = uconf->oind;
init(); init();
...@@ -1287,7 +1287,7 @@ IONotifyController_i::ThresholdInfo ...@@ -1287,7 +1287,7 @@ IONotifyController_i::ThresholdInfo
{ {
IOController_i::SensorInfo si; IOController_i::SensorInfo si;
si.id = sid; si.id = sid;
si.node = conf->getLocalNode(); si.node = uconf->getLocalNode();
return getThresholdInfo(si,tid); return getThresholdInfo(si,tid);
} }
// -------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------
...@@ -1609,7 +1609,7 @@ IOController_i::SensorInfoSeq_var UInterface::getSensorSeq( const UniSetTypes::I ...@@ -1609,7 +1609,7 @@ IOController_i::SensorInfoSeq_var UInterface::getSensorSeq( const UniSetTypes::I
CORBA::Object_var oref; CORBA::Object_var oref;
try try
{ {
oref = rcache.resolve(sid,conf->getLocalNode()); oref = rcache.resolve(sid,uconf->getLocalNode());
} }
catch( NameNotFound ){} catch( NameNotFound ){}
...@@ -1618,7 +1618,7 @@ IOController_i::SensorInfoSeq_var UInterface::getSensorSeq( const UniSetTypes::I ...@@ -1618,7 +1618,7 @@ IOController_i::SensorInfoSeq_var UInterface::getSensorSeq( const UniSetTypes::I
try try
{ {
if( CORBA::is_nil(oref) ) if( CORBA::is_nil(oref) )
oref = resolve(sid,conf->getLocalNode()); oref = resolve(sid,uconf->getLocalNode());
IOController_i_var iom = IOController_i::_narrow(oref); IOController_i_var iom = IOController_i::_narrow(oref);
...@@ -1635,29 +1635,29 @@ IOController_i::SensorInfoSeq_var UInterface::getSensorSeq( const UniSetTypes::I ...@@ -1635,29 +1635,29 @@ IOController_i::SensorInfoSeq_var UInterface::getSensorSeq( const UniSetTypes::I
catch(UniSetTypes::TimeOut){} catch(UniSetTypes::TimeOut){}
catch(IOController_i::NameNotFound &ex) catch(IOController_i::NameNotFound &ex)
{ {
rcache.erase(sid,conf->getLocalNode()); rcache.erase(sid,uconf->getLocalNode());
throw UniSetTypes::NameNotFound("UI(getSensorSeq): "+string(ex.err)); throw UniSetTypes::NameNotFound("UI(getSensorSeq): "+string(ex.err));
} }
catch(IOController_i::IOBadParam& ex) catch(IOController_i::IOBadParam& ex)
{ {
rcache.erase(sid,conf->getLocalNode()); rcache.erase(sid,uconf->getLocalNode());
throw UniSetTypes::IOBadParam("UI(getSensorSeq): "+string(ex.err)); throw UniSetTypes::IOBadParam("UI(getSensorSeq): "+string(ex.err));
} }
catch(ORepFailed) catch(ORepFailed)
{ {
rcache.erase(sid,conf->getLocalNode()); rcache.erase(sid,uconf->getLocalNode());
// не смогли получить ссылку на объект // не смогли получить ссылку на объект
throw UniSetTypes::IOBadParam(set_err("UI(getSensorSeq): resolve failed ",sid,conf->getLocalNode())); throw UniSetTypes::IOBadParam(set_err("UI(getSensorSeq): resolve failed ",sid,uconf->getLocalNode()));
} }
catch(CORBA::NO_IMPLEMENT) catch(CORBA::NO_IMPLEMENT)
{ {
rcache.erase(sid,conf->getLocalNode()); rcache.erase(sid,uconf->getLocalNode());
throw UniSetTypes::IOBadParam(set_err("UI(getSensorSeq): method no implement",sid,conf->getLocalNode())); throw UniSetTypes::IOBadParam(set_err("UI(getSensorSeq): method no implement",sid,uconf->getLocalNode()));
} }
catch(CORBA::OBJECT_NOT_EXIST) catch(CORBA::OBJECT_NOT_EXIST)
{ {
rcache.erase(sid,conf->getLocalNode()); rcache.erase(sid,uconf->getLocalNode());
throw UniSetTypes::IOBadParam(set_err("UI(getSensorSeq): object not exist",sid,conf->getLocalNode())); throw UniSetTypes::IOBadParam(set_err("UI(getSensorSeq): object not exist",sid,uconf->getLocalNode()));
} }
catch(CORBA::COMM_FAILURE& ex) catch(CORBA::COMM_FAILURE& ex)
{ {
...@@ -1668,8 +1668,8 @@ IOController_i::SensorInfoSeq_var UInterface::getSensorSeq( const UniSetTypes::I ...@@ -1668,8 +1668,8 @@ IOController_i::SensorInfoSeq_var UInterface::getSensorSeq( const UniSetTypes::I
// ошибка системы коммуникации // ошибка системы коммуникации
// uwarn << "UI(getValue): CORBA::SystemException" << endl; // uwarn << "UI(getValue): CORBA::SystemException" << endl;
} }
rcache.erase(sid,conf->getLocalNode()); rcache.erase(sid,uconf->getLocalNode());
throw UniSetTypes::TimeOut(set_err("UI(getSensorSeq): Timeout",sid,conf->getLocalNode())); throw UniSetTypes::TimeOut(set_err("UI(getSensorSeq): Timeout",sid,uconf->getLocalNode()));
} }
// -------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------
...@@ -1770,7 +1770,7 @@ UniSetTypes::IDSeq_var UInterface::askSensorsSeq( const UniSetTypes::IDList& lst ...@@ -1770,7 +1770,7 @@ UniSetTypes::IDSeq_var UInterface::askSensorsSeq( const UniSetTypes::IDList& lst
CORBA::Object_var oref; CORBA::Object_var oref;
try try
{ {
oref = rcache.resolve(sid,conf->getLocalNode()); oref = rcache.resolve(sid,uconf->getLocalNode());
} }
catch( NameNotFound ){} catch( NameNotFound ){}
...@@ -1779,7 +1779,7 @@ UniSetTypes::IDSeq_var UInterface::askSensorsSeq( const UniSetTypes::IDList& lst ...@@ -1779,7 +1779,7 @@ UniSetTypes::IDSeq_var UInterface::askSensorsSeq( const UniSetTypes::IDList& lst
try try
{ {
if( CORBA::is_nil(oref) ) if( CORBA::is_nil(oref) )
oref = resolve(sid,conf->getLocalNode()); oref = resolve(sid,uconf->getLocalNode());
IONotifyController_i_var iom = IONotifyController_i::_narrow(oref); IONotifyController_i_var iom = IONotifyController_i::_narrow(oref);
...@@ -1800,29 +1800,29 @@ UniSetTypes::IDSeq_var UInterface::askSensorsSeq( const UniSetTypes::IDList& lst ...@@ -1800,29 +1800,29 @@ UniSetTypes::IDSeq_var UInterface::askSensorsSeq( const UniSetTypes::IDList& lst
catch(UniSetTypes::TimeOut){} catch(UniSetTypes::TimeOut){}
catch(IOController_i::NameNotFound &ex) catch(IOController_i::NameNotFound &ex)
{ {
rcache.erase(sid,conf->getLocalNode()); rcache.erase(sid,uconf->getLocalNode());
throw UniSetTypes::NameNotFound("UI(getSensorSeq): "+string(ex.err)); throw UniSetTypes::NameNotFound("UI(getSensorSeq): "+string(ex.err));
} }
catch(IOController_i::IOBadParam& ex) catch(IOController_i::IOBadParam& ex)
{ {
rcache.erase(sid,conf->getLocalNode()); rcache.erase(sid,uconf->getLocalNode());
throw UniSetTypes::IOBadParam("UI(getSensorSeq): "+string(ex.err)); throw UniSetTypes::IOBadParam("UI(getSensorSeq): "+string(ex.err));
} }
catch(ORepFailed) catch(ORepFailed)
{ {
rcache.erase(sid,conf->getLocalNode()); rcache.erase(sid,uconf->getLocalNode());
// не смогли получить ссылку на объект // не смогли получить ссылку на объект
throw UniSetTypes::IOBadParam(set_err("UI(askSensorSeq): resolve failed ",sid,conf->getLocalNode())); throw UniSetTypes::IOBadParam(set_err("UI(askSensorSeq): resolve failed ",sid,uconf->getLocalNode()));
} }
catch(CORBA::NO_IMPLEMENT) catch(CORBA::NO_IMPLEMENT)
{ {
rcache.erase(sid,conf->getLocalNode()); rcache.erase(sid,uconf->getLocalNode());
throw UniSetTypes::IOBadParam(set_err("UI(askSensorSeq): method no implement",sid,conf->getLocalNode())); throw UniSetTypes::IOBadParam(set_err("UI(askSensorSeq): method no implement",sid,uconf->getLocalNode()));
} }
catch(CORBA::OBJECT_NOT_EXIST) catch(CORBA::OBJECT_NOT_EXIST)
{ {
rcache.erase(sid,conf->getLocalNode()); rcache.erase(sid,uconf->getLocalNode());
throw UniSetTypes::IOBadParam(set_err("UI(askSensorSeq): object not exist",sid,conf->getLocalNode())); throw UniSetTypes::IOBadParam(set_err("UI(askSensorSeq): object not exist",sid,uconf->getLocalNode()));
} }
catch(CORBA::COMM_FAILURE& ex) catch(CORBA::COMM_FAILURE& ex)
{ {
...@@ -1833,11 +1833,11 @@ UniSetTypes::IDSeq_var UInterface::askSensorsSeq( const UniSetTypes::IDList& lst ...@@ -1833,11 +1833,11 @@ UniSetTypes::IDSeq_var UInterface::askSensorsSeq( const UniSetTypes::IDList& lst
// ошибка системы коммуникации // ошибка системы коммуникации
// uwarn << "UI(getValue): CORBA::SystemException" << endl; // uwarn << "UI(getValue): CORBA::SystemException" << endl;
} }
rcache.erase(sid,conf->getLocalNode()); rcache.erase(sid,uconf->getLocalNode());
throw UniSetTypes::TimeOut(set_err("UI(askSensorSeq): Timeout",sid,conf->getLocalNode())); throw UniSetTypes::TimeOut(set_err("UI(askSensorSeq): Timeout",sid,uconf->getLocalNode()));
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
IOController_i::ShortMapSeq* UInterface::getSensors( const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node ) IOController_i::ShortMapSeq* UInterface::getSensors( const UniSetTypes::ObjectId id, UniSetTypes::ObjectId node )
{ {
if ( id == DefaultObjectId ) if ( id == DefaultObjectId )
throw ORepFailed("UI(getSensors): error node=UniSetTypes::DefaultObjectId"); throw ORepFailed("UI(getSensors): error node=UniSetTypes::DefaultObjectId");
...@@ -1913,11 +1913,11 @@ IOController_i::ShortMapSeq* UInterface::getSensors( const UniSetTypes::ObjectId ...@@ -1913,11 +1913,11 @@ IOController_i::ShortMapSeq* UInterface::getSensors( const UniSetTypes::ObjectId
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool UInterface::waitReady( const ObjectId id, int msec, int pmsec, const ObjectId node ) bool UInterface::waitReady( const ObjectId id, int msec, int pmsec, const ObjectId node )
{ {
if( msec < 0 ) if( msec < 0 )
msec = 0; msec = 0;
if( pmsec < 0 ) if( pmsec < 0 )
pmsec = 0; pmsec = 0;
PassiveTimer ptReady(msec); PassiveTimer ptReady(msec);
bool ready = false; bool ready = false;
...@@ -1939,11 +1939,11 @@ bool UInterface::waitReady( const ObjectId id, int msec, int pmsec, const Object ...@@ -1939,11 +1939,11 @@ bool UInterface::waitReady( const ObjectId id, int msec, int pmsec, const Object
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool UInterface::waitWorking( const ObjectId id, int msec, int pmsec, const ObjectId node ) bool UInterface::waitWorking( const ObjectId id, int msec, int pmsec, const ObjectId node )
{ {
if( msec < 0 ) if( msec < 0 )
msec = 0; msec = 0;
if( pmsec < 0 ) if( pmsec < 0 )
pmsec = 0; pmsec = 0;
PassiveTimer ptReady(msec); PassiveTimer ptReady(msec);
bool ready = false; bool ready = false;
...@@ -1965,10 +1965,10 @@ bool UInterface::waitWorking( const ObjectId id, int msec, int pmsec, const Obje ...@@ -1965,10 +1965,10 @@ bool UInterface::waitWorking( const ObjectId id, int msec, int pmsec, const Obje
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
UniversalIO::IOType UInterface::getConfIOType( const UniSetTypes::ObjectId id ) const UniversalIO::IOType UInterface::getConfIOType( const UniSetTypes::ObjectId id ) const
{ {
if( !conf ) if( !uconf )
return UniversalIO::UnknownIOType; return UniversalIO::UnknownIOType;
xmlNode* x = conf->getXMLObjectNode(id); xmlNode* x = uconf->getXMLObjectNode(id);
if( !x ) if( !x )
return UniversalIO::UnknownIOType; return UniversalIO::UnknownIOType;
......
...@@ -150,13 +150,13 @@ protected: ...@@ -150,13 +150,13 @@ protected:
/// ///
virtual streamsize xsputn(char_type const * p, streamsize n) { virtual streamsize xsputn(char_type const * p, streamsize n) {
sb2->sputn(p, n); sb2->sputn(p, n);
sb3->sputn(p, n); sb3->sputn(p, n);
return sb1->sputn(p, n); return sb1->sputn(p, n);
} }
/// ///
virtual int_type overflow(int_type c = traits_type::eof()) { virtual int_type overflow(int_type c = traits_type::eof()) {
sb2->sputc(c); sb2->sputc(c);
sb3->sputc(c); sb3->sputc(c);
return sb1->sputc(c); return sb1->sputc(c);
} }
#else #else
...@@ -165,19 +165,19 @@ protected: ...@@ -165,19 +165,19 @@ protected:
/// ///
virtual int sync() { virtual int sync() {
sb2->sync(); sb2->sync();
sb3->sync(); sb3->sync();
return sb1->sync(); return sb1->sync();
} }
/// ///
virtual streamsize xsputn(char_type const * p, streamsize n) { virtual streamsize xsputn(char_type const * p, streamsize n) {
sb2->xsputn(p, n); sb2->xsputn(p, n);
sb2->xsputn(p, n); sb2->xsputn(p, n);
return sb1->xsputn(p, n); return sb1->xsputn(p, n);
} }
/// ///
virtual int_type overflow(int_type c = EOF) { virtual int_type overflow(int_type c = EOF) {
sb2->overflow(c); sb2->overflow(c);
sb3->owerflow(c); sb3->owerflow(c);
return sb1->overflow(c); return sb1->overflow(c);
} }
#endif #endif
...@@ -186,8 +186,8 @@ private: ...@@ -186,8 +186,8 @@ private:
streambuf * sb1; streambuf * sb1;
/// ///
streambuf * sb2; streambuf * sb2;
/// ///
streambuf * sb3; streambuf * sb3;
}; };
/// ///
...@@ -235,17 +235,17 @@ private: ...@@ -235,17 +235,17 @@ private:
class stringsigbuf : public streambuf { class stringsigbuf : public streambuf {
public: public:
stringsigbuf():sb(new stringbuf()) stringsigbuf():sb(new stringbuf())
{ {
} }
~stringsigbuf() ~stringsigbuf()
{ {
if( sb ) if( sb )
{ {
delete sb; delete sb;
sb = 0; sb = 0;
} }
} }
/// ///
stringsigbuf( stringbuf* b ) stringsigbuf( stringbuf* b )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment