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");
// --------------------------------------------------------------------------
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 configure( const string& args, UInterface &ui );
int logRotate( const string& args, UInterface &ui );
int setValue( const string& args, UInterface &ui, Configuration* conf = UniSetTypes::conf );
int getValue( const string& args, UInterface &ui, Configuration* conf = UniSetTypes::conf );
int setValue( const string& args, UInterface &ui );
int getValue( const string& args, UInterface &ui );
int getRawValue( const string& args, UInterface &ui );
int getState( const string& args, UInterface &ui );
int getCalibrate( const string& args, UInterface &ui );
......@@ -153,14 +153,14 @@ int main(int argc, char** argv)
case 'b': //--create
{
uniset_init(argc,argv,conffile);
auto conf = uniset_init(argc,argv,conffile);
createSections(conf);
}
return 0;
case 'x': //--setValue
{
uniset_init(argc,argv,conffile);
auto conf = uniset_init(argc,argv,conffile);
UInterface ui(conf);
return setValue(optarg,ui);
}
......@@ -169,7 +169,7 @@ int main(int argc, char** argv)
case 'g': //--getValue
{
// cout<<"(main):received option --getValue='"<<optarg<<"'"<<endl;
uniset_init(argc,argv,conffile);
auto conf = uniset_init(argc,argv,conffile);
UInterface ui(conf);
return getValue(optarg,ui);
}
......@@ -178,7 +178,7 @@ int main(int argc, char** argv)
case 'w': //--getRawValue
{
// cout<<"(main):received option --getRawValue='"<<optarg<<"'"<<endl;
uniset_init(argc,argv,conffile);
auto conf = uniset_init(argc,argv,conffile);
UInterface ui(conf);
return getRawValue(optarg,ui);
}
......@@ -187,7 +187,7 @@ int main(int argc, char** argv)
case 'p': //--oinfo
{
// cout<<"(main):received option --oinfo='"<<optarg<<"'"<<endl;
uniset_init(argc,argv,conffile);
auto conf = uniset_init(argc,argv,conffile);
UInterface ui(conf);
return oinfo(optarg,ui);
}
......@@ -196,7 +196,7 @@ int main(int argc, char** argv)
case 'e': //--exist
{
// cout<<"(main):received option --exist"<<endl;
uniset_init(argc,argv,conffile);
auto conf = uniset_init(argc,argv,conffile);
UInterface ui(conf);
verb = true;
......@@ -213,7 +213,7 @@ int main(int argc, char** argv)
case 's': //--start
{
// cout<<"(main):received option --start"<<endl;
uniset_init(argc,argv,conffile);
auto conf = uniset_init(argc,argv,conffile);
UInterface ui(conf);
Command cmd=StartUp;
......@@ -227,7 +227,7 @@ int main(int argc, char** argv)
case 'r': //--configure
{
uniset_init(argc,argv,conffile);
auto conf = uniset_init(argc,argv,conffile);
UInterface ui(conf);
return configure(optarg,ui);
}
......@@ -236,7 +236,7 @@ int main(int argc, char** argv)
case 'f': //--finish
{
// cout<<"(main):received option --finish"<<endl;
uniset_init(argc,argv,conffile);
auto conf = uniset_init(argc,argv,conffile);
UInterface ui(conf);
Command cmd=Finish;
......@@ -252,7 +252,7 @@ int main(int argc, char** argv)
case 'l': //--logrotate
{
uniset_init(argc,argv,conffile);
auto conf = uniset_init(argc,argv,conffile);
UInterface ui(conf);
return logRotate(optarg, ui);
}
......@@ -261,7 +261,7 @@ int main(int argc, char** argv)
case 'y': //--getCalibrate
{
// cout<<"(main):received option --getCalibrate='"<<optarg<<"'"<<endl;
uniset_init(argc,argv,conffile);
auto conf = uniset_init(argc,argv,conffile);
UInterface ui(conf);
return getCalibrate(optarg, ui);
}
......@@ -270,7 +270,7 @@ int main(int argc, char** argv)
case 'u': //--foldUp
{
// cout<<"(main):received option --foldUp"<<endl;
uniset_init(argc,argv,conffile);
auto conf = uniset_init(argc,argv,conffile);
UInterface ui(conf);
Command cmd=FoldUp;
......@@ -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);
......@@ -469,7 +469,7 @@ int omap()
{
cout.setf(ios::left, ios::adjustfield);
cout << "========================== ObjectsMap =================================\n";
conf->oind->printMap(cout);
uniset_conf()->oind->printMap(cout);
cout << "==========================================================================\n";
}
catch( Exception& ex )
......@@ -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;
auto conf = ui.getConf();
typedef std::list<UniSetTypes::ParamSInfo> SList;
SList sl = UniSetTypes::getSInfoList(args, 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;
auto conf = ui.getConf();
typedef std::list<UniSetTypes::ParamSInfo> SList;
SList sl = UniSetTypes::getSInfoList( args, UniSetTypes::conf );
SList sl = UniSetTypes::getSInfoList( args, conf );
if( verb )
cout << "====== getValue ======" << endl;
......@@ -594,8 +596,9 @@ int getValue( const string& args, UInterface &ui, Configuration* conf )
int getCalibrate( const std::string& args, UInterface &ui )
{
int err = 0;
auto conf = ui.getConf();
typedef std::list<UniSetTypes::ParamSInfo> SList;
SList sl = UniSetTypes::getSInfoList( args, UniSetTypes::conf );
SList sl = UniSetTypes::getSInfoList( args, conf );
if( verb )
cout << "====== getCalibrate ======" << endl;
......@@ -635,8 +638,9 @@ int getCalibrate( const std::string& args, UInterface &ui )
int getRawValue( const std::string& args, UInterface &ui )
{
int err = 0;
auto conf = ui.getConf();
typedef std::list<UniSetTypes::ParamSInfo> SList;
SList sl = UniSetTypes::getSInfoList( args, UniSetTypes::conf );
SList sl = UniSetTypes::getSInfoList( args, conf );
if( verb )
cout << "====== getRawValue ======" << endl;
for( SList::iterator it=sl.begin(); it!=sl.end(); ++it )
......@@ -668,6 +672,7 @@ int getRawValue( const std::string& args, UInterface &ui )
// --------------------------------------------------------------------------------------
int logRotate( const string& arg, UInterface &ui )
{
auto conf = ui.getConf();
// посылка всем
if( arg.empty() || (arg.c_str())[0]!='-' )
{
......@@ -699,6 +704,7 @@ int logRotate( const string& arg, UInterface &ui )
// --------------------------------------------------------------------------------------
int configure( const string& arg, UInterface &ui )
{
auto conf = ui.getConf();
// посылка всем
if( arg.empty() || (arg.c_str())[0]!='-' )
{
......
......@@ -36,7 +36,7 @@ int main(int argc, char** argv)
return 0;
}
uniset_init(argc,argv,"configure.xml");
auto conf = uniset_init(argc,argv,"configure.xml");
// определяем ID объекта
......
......@@ -36,8 +36,8 @@ int main( int argc, char **argv )
}
// -------------------------------------
uniset_init(argc, argv, "configure.xml" );
UInterface ui;
auto conf = uniset_init(argc, argv, "configure.xml" );
UInterface ui(conf);
string sid(conf->getArgParam("--sid"));
if( sid.empty() )
......@@ -46,7 +46,7 @@ int main( int argc, char **argv )
return 1;
}
std::list<UniSetTypes::ParamSInfo> lst = UniSetTypes::getSInfoList(sid,UniSetTypes::conf);
std::list<UniSetTypes::ParamSInfo> lst = UniSetTypes::getSInfoList(sid,conf);
if( lst.empty() )
{
......
......@@ -19,7 +19,7 @@ int main( int argc, const char **argv )
return 0;
}
uniset_init(argc,argv,"configure.xml");
auto conf = uniset_init(argc,argv,"configure.xml");
ObjectId ID(DefaultObjectId);
string name = conf->getArgParam("--name", "TestProc");
......
......@@ -21,7 +21,7 @@ int main(int argc, const char **argv)
return 0;
}
uniset_init(argc,argv,"configure.xml");
auto conf = uniset_init(argc,argv,"configure.xml");
bool fullname = false;
if( findArgParam("--fullname",conf->getArgc(),conf->getArgv()) != -1 )
......
......@@ -50,10 +50,10 @@
<xsl:if test="normalize-space(@vartype)!='io'">
<xsl:value-of select="../../@name"/>(<xsl:value-of select="../../@id"/>),
<xsl:if test="not(normalize-space(../../@node)='')">
node_<xsl:value-of select="../../@name"/>(conf->getNodeID("<xsl:value-of select="../../@node"/>")),
node_<xsl:value-of select="../../@name"/>(uniset_conf()->getNodeID("<xsl:value-of select="../../@node"/>")),
</xsl:if>
<xsl:if test="normalize-space(../../@node)=''">
node_<xsl:value-of select="../../@name"/>(UniSetTypes::conf->getLocalNode()),
node_<xsl:value-of select="../../@name"/>(UniSetTypes::uniset_conf()->getLocalNode()),
</xsl:if>
<xsl:if test="normalize-space(../../@default)=''">
<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/>(0),
......@@ -159,7 +159,7 @@
bool alarm( UniSetTypes::ObjectId sid, bool state );
long getValue( UniSetTypes::ObjectId sid );
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 setMsg( UniSetTypes::ObjectId code, bool state );
......@@ -229,9 +229,9 @@
xmlNode* confnode;
/*! получить числовое свойство из конф. файла по привязанной confnode */
int getIntProp(const std::string&amp; name) { return UniSetTypes::conf->getIntProp(confnode, name); }
int getIntProp(const std::string&amp; name) { return UniSetTypes::uniset_conf()->getIntProp(confnode, name); }
/*! получить текстовое свойство из конф. файла по привязанной confnode */
inline const std::string getProp(const std::string&amp; name) { return UniSetTypes::conf->getProp(confnode, name); }
inline const std::string getProp(const std::string&amp; name) { return UniSetTypes::uniset_conf()->getProp(confnode, name); }
int smReadyTimeout; /*!&lt; время ожидания готовности SM */
std::atomic_bool activated;
......@@ -418,7 +418,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::waitSM( int wait_msec, ObjectId _te
</xsl:template>
<xsl:template name="COMMON-ID-LIST">
if( UniSetTypes::findArgParam("--print-id-list",conf->getArgc(),conf->getArgv()) != -1 )
if( UniSetTypes::findArgParam("--print-id-list",uniset_conf()->getArgc(),uniset_conf()->getArgv()) != -1 )
{
<xsl:for-each select="//smap/item">
if( <xsl:value-of select="normalize-space(@name)"/> != UniSetTypes::DefaultObjectId )
......@@ -444,22 +444,22 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::waitSM( int wait_msec, ObjectId _te
</xsl:template>
<xsl:template name="init-variables">
<xsl:if test="normalize-space(@type)='int'">
<xsl:value-of select="normalize-space(@name)"/>(uni_atoi( init3_str(conf->getArgParam("--" + argprefix + "<xsl:value-of select="@name"/>"),conf->getProp(cnode,"<xsl:value-of select="@name"/>"),"<xsl:value-of select="normalize-space(@default)"/>"))),
<xsl:value-of select="normalize-space(@name)"/>(uni_atoi( init3_str(uniset_conf()->getArgParam("--" + argprefix + "<xsl:value-of select="@name"/>"),uniset_conf()->getProp(cnode,"<xsl:value-of select="@name"/>"),"<xsl:value-of select="normalize-space(@default)"/>"))),
</xsl:if>
<xsl:if test="normalize-space(@type)='long'">
<xsl:value-of select="normalize-space(@name)"/>(uni_atoi( init3_str(conf->getArgParam("--" + argprefix + "<xsl:value-of select="@name"/>"),conf->getProp(cnode,"<xsl:value-of select="@name"/>"),"<xsl:value-of select="normalize-space(@default)"/>"))),
<xsl:value-of select="normalize-space(@name)"/>(uni_atoi( init3_str(uniset_conf()->getArgParam("--" + argprefix + "<xsl:value-of select="@name"/>"),uniset_conf()->getProp(cnode,"<xsl:value-of select="@name"/>"),"<xsl:value-of select="normalize-space(@default)"/>"))),
</xsl:if>
<xsl:if test="normalize-space(@type)='float'">
<xsl:value-of select="normalize-space(@name)"/>(atof( init3_str(conf->getArgParam("--" + argprefix + "<xsl:value-of select="@name"/>"),conf->getProp(cnode,"<xsl:value-of select="@name"/>"),"<xsl:value-of select="normalize-space(@default)"/>").c_str())),
<xsl:value-of select="normalize-space(@name)"/>(atof( init3_str(uniset_conf()->getArgParam("--" + argprefix + "<xsl:value-of select="@name"/>"),uniset_conf()->getProp(cnode,"<xsl:value-of select="@name"/>"),"<xsl:value-of select="normalize-space(@default)"/>").c_str())),
</xsl:if>
<xsl:if test="normalize-space(@type)='double'">
<xsl:value-of select="normalize-space(@name)"/>(atof( init3_str(conf->getArgParam("--" + argprefix + "<xsl:value-of select="@name"/>"),conf->getProp(cnode,"<xsl:value-of select="@name"/>"),"<xsl:value-of select="normalize-space(@default)"/>").c_str())),
<xsl:value-of select="normalize-space(@name)"/>(atof( init3_str(uniset_conf()->getArgParam("--" + argprefix + "<xsl:value-of select="@name"/>"),uniset_conf()->getProp(cnode,"<xsl:value-of select="@name"/>"),"<xsl:value-of select="normalize-space(@default)"/>").c_str())),
</xsl:if>
<xsl:if test="normalize-space(@type)='bool'">
<xsl:value-of select="normalize-space(@name)"/>(uni_atoi( init3_str(conf->getArgParam("--" + argprefix + "<xsl:value-of select="@name"/>"),conf->getProp(cnode,"<xsl:value-of select="@name"/>"),"<xsl:value-of select="normalize-space(@default)"/>"))),
<xsl:value-of select="normalize-space(@name)"/>(uni_atoi( init3_str(uniset_conf()->getArgParam("--" + argprefix + "<xsl:value-of select="@name"/>"),uniset_conf()->getProp(cnode,"<xsl:value-of select="@name"/>"),"<xsl:value-of select="normalize-space(@default)"/>"))),
</xsl:if>
<xsl:if test="normalize-space(@type)='str'">
<xsl:value-of select="normalize-space(@name)"/>(init3_str(conf->getArgParam("--" + argprefix + "<xsl:value-of select="@name"/>"),conf->getProp(cnode,"<xsl:value-of select="@name"/>"),"<xsl:value-of select="normalize-space(@default)"/>")),
<xsl:value-of select="normalize-space(@name)"/>(init3_str(uniset_conf()->getArgParam("--" + argprefix + "<xsl:value-of select="@name"/>"),uniset_conf()->getProp(cnode,"<xsl:value-of select="@name"/>"),"<xsl:value-of select="normalize-space(@default)"/>")),
</xsl:if>
</xsl:template>
......@@ -552,13 +552,13 @@ static const std::string init3_str( const std::string&amp; s1, const std::string
// Инициализация идентификаторов (имена берутся из конф. файла)
<xsl:for-each select="//smap/item">
<xsl:if test="normalize-space(@vartype)!='io'">
<xsl:value-of select="normalize-space(@name)"/>(conf->getSensorID(conf->getProp(cnode,"<xsl:value-of select="normalize-space(@name)"/>"))),
node_<xsl:value-of select="normalize-space(@name)"/>( conf->getNodeID(conf->getProp(cnode,"node_<xsl:value-of select="normalize-space(@name)"/>")) ),
<xsl:value-of select="normalize-space(@name)"/>(uniset_conf()->getSensorID(uniset_conf()->getProp(cnode,"<xsl:value-of select="normalize-space(@name)"/>"))),
node_<xsl:value-of select="normalize-space(@name)"/>( uniset_conf()->getNodeID(uniset_conf()->getProp(cnode,"node_<xsl:value-of select="normalize-space(@name)"/>")) ),
</xsl:if>
</xsl:for-each>
// Используемые идентификаторы сообщений (имена берутся из конф. файла)
<xsl:for-each select="//msgmap/item"><xsl:value-of select="normalize-space(@name)"/>(conf->getSensorID(conf->getProp(cnode,"<xsl:value-of select="normalize-space(@name)"/>"))),
node_<xsl:value-of select="normalize-space(@name)"/>(conf->getNodeID( conf->getProp(cnode,"node_<xsl:value-of select="normalize-space(@name)"/>"))),
<xsl:for-each select="//msgmap/item"><xsl:value-of select="normalize-space(@name)"/>(uniset_conf()->getSensorID(uniset_conf()->getProp(cnode,"<xsl:value-of select="normalize-space(@name)"/>"))),
node_<xsl:value-of select="normalize-space(@name)"/>(uniset_conf()->getNodeID( uniset_conf()->getProp(cnode,"node_<xsl:value-of select="normalize-space(@name)"/>"))),
m_<xsl:value-of select="normalize-space(@name)"/>(false),
prev_m_<xsl:value-of select="normalize-space(@name)"/>(false),
</xsl:for-each>
......@@ -577,8 +577,8 @@ sleep_msec(<xsl:call-template name="settings"><xsl:with-param name="varname" sel
active(true),
<xsl:if test="normalize-space($TESTMODE)!=''">
isTestMode(false),
idTestMode_S(conf->getSensorID("TestMode_S")),
idLocalTestMode_S(conf->getSensorID(conf->getProp(cnode,"LocalTestMode_S"))),
idTestMode_S(uniset_conf()->getSensorID("TestMode_S")),
idLocalTestMode_S(uniset_conf()->getSensorID(uniset_conf()->getProp(cnode,"LocalTestMode_S"))),
in_TestMode_S(false),
in_LocalTestMode_S(false),
</xsl:if>
......@@ -587,7 +587,7 @@ maxHeartBeat(10),
confnode(cnode),
smReadyTimeout(0),
activated(false),
askPause(conf->getPIntProp(cnode,"askPause",2000)),
askPause(uniset_conf()->getPIntProp(cnode,"askPause",2000)),
<xsl:for-each select="//variables/item">
<xsl:if test="normalize-space(@private)!=''">
<xsl:call-template name="init-variables"/>
......@@ -595,6 +595,8 @@ askPause(conf->getPIntProp(cnode,"askPause",2000)),
</xsl:for-each>
end_private(false)
{
auto conf = uniset_conf();
<xsl:call-template name="COMMON-ID-LIST"/>
if( getId() == DefaultObjectId )
......@@ -898,8 +900,8 @@ sleep_msec(<xsl:call-template name="settings-alone"><xsl:with-param name="varnam
active(true),
<xsl:if test="normalize-space($TESTMODE)!=''">
isTestMode(false),
idTestMode_S(conf->getSensorID("TestMode_S")),
idLocalTestMode_S(conf->getSensorID(conf->getProp(cnode,"LocalTestMode_S"))),
idTestMode_S(uniset_conf()->getSensorID("TestMode_S")),
idLocalTestMode_S(uniset_conf()->getSensorID(uniset_conf()->getProp(cnode,"LocalTestMode_S"))),
in_TestMode_S(false),
in_LocalTestMode_S(false),
</xsl:if>
......@@ -907,8 +909,10 @@ idHeartBeat(DefaultObjectId),
maxHeartBeat(10),
confnode(cnode),
activated(false),
askPause(conf->getPIntProp(cnode,"askPause",2000))
askPause(uniset_conf()->getPIntProp(cnode,"askPause",2000))
{
auto conf = uniset_conf();
if( getId() == DefaultObjectId )
{
ostringstream err;
......
......@@ -51,10 +51,10 @@ class <xsl:value-of select="$CLASSNAME"/>_SK:
{
public:
<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 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:value-of select="$CLASSNAME"/>_SK();
......
......@@ -52,10 +52,10 @@ class <xsl:value-of select="$CLASSNAME"/>_SK:
{
public:
<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 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:value-of select="$CLASSNAME"/>_SK();
virtual ~<xsl:value-of select="$CLASSNAME"/>_SK();
......
......@@ -50,9 +50,7 @@ int main( int argc,char* argv[] )
try
{
string confile = UniSetTypes::getArgParam( "--confile", argc, argv, "configure.xml" );
conf = new Configuration(argc, argv,confile);
auto conf = uniset_init(argc, argv);
// определяем ID объекта
ObjectId ID(DefaultObjectId);
......@@ -74,7 +72,7 @@ int main( int argc,char* argv[] )
string logname( conf->getLogDir() + logfilename );
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));
SystemMessage sm(SystemMessage::StartUp);
......
......@@ -52,9 +52,7 @@ int main( int argc, const char** argv )
try
{
string confile = UniSetTypes::getArgParam( "--confile", argc, argv, "configure.xml" );
conf = new Configuration(argc, argv, confile);
auto conf = uniset_init(argc, argv);
<xsl:if test="not(normalize-space(//@OID))=''">
<xsl:value-of select="$CLASSNAME"/> obj;
......@@ -82,7 +80,7 @@ int main( int argc, const char** argv )
</xsl:if>
UniSetActivator* act = UniSetActivator::Instance();
auto act = UniSetActivator::Instance();
act-&gt;addObject(static_cast&lt;class UniSetObject*&gt;(&amp;obj));
SystemMessage sm(SystemMessage::StartUp);
......
......@@ -9,7 +9,7 @@ int main( int argc, const char **argv )
{
try
{
uniset_init(argc, argv);
auto conf = uniset_init(argc, argv);
string logfilename = conf->getArgParam("--logfile", "Skel.log");
string logname( conf->getLogDir() + logfilename );
......@@ -17,7 +17,7 @@ int main( int argc, const char **argv )
ulog.logFile( logname.c_str() );
// conf->initDebug(dlog,"dlog");
UniSetActivator act;
auto act = UniSetActivator::Instance();
xmlNode* cnode = conf->getNode("Skel");
if( cnode == NULL )
{
......@@ -35,7 +35,7 @@ int main( int argc, const char **argv )
ulog << "(Skel::main): -------------- Skel START -------------------------\n\n";
dlog << "\n\n\n";
dlog << "(Skel::main): -------------- Skel START -------------------------\n\n";
act.run(false);
act->run(false);
}
catch(SystemError& err)
{
......
......@@ -8,7 +8,7 @@ class Skel:
public Skel_SK
{
public:
Skel( UniSetTypes::ObjectId id, xmlNode* confnode = UniSetTypes::conf->getNode("Skel") );
Skel( UniSetTypes::ObjectId id, xmlNode* confnode = UniSetTypes::uniset_conf()->getNode("Skel") );
virtual ~Skel();
protected:
......
......@@ -8,7 +8,7 @@ class TestGen:
public TestGen_SK
{
public:
TestGen( UniSetTypes::ObjectId id, xmlNode* confnode = UniSetTypes::conf->getNode("TestGen") );
TestGen( UniSetTypes::ObjectId id, xmlNode* confnode = UniSetTypes::uniset_conf()->getNode("TestGen") );
virtual ~TestGen();
......
......@@ -8,7 +8,7 @@ class TestGenAlone:
public TestGenAlone_SK
{
public:
TestGenAlone( UniSetTypes::ObjectId id, xmlNode* confnode = UniSetTypes::conf->getNode("TestGenAlone") );
TestGenAlone( UniSetTypes::ObjectId id, xmlNode* confnode = UniSetTypes::uniset_conf()->getNode("TestGenAlone") );
virtual ~TestGenAlone();
......
......@@ -59,7 +59,7 @@ DBServer_MySQL::DBServer_MySQL(ObjectId id):
}
DBServer_MySQL::DBServer_MySQL():
DBServer(conf->getDBServer()),
DBServer(uniset_conf()->getDBServer()),
db(new MySQLInterface()),
PingTime(300000),
ReconnectTime(180000),
......@@ -266,6 +266,8 @@ void DBServer_MySQL::init_dbserver()
return;
}
auto conf = uniset_conf();
if( conf->getDBServer() == UniSetTypes::DefaultObjectId )
{
ostringstream msg;
......@@ -335,6 +337,8 @@ void DBServer_MySQL::init_dbserver()
//--------------------------------------------------------------------------------------------
void DBServer_MySQL::createTables( MySQLInterface *db )
{
auto conf = uniset_conf();
UniXML::iterator it( conf->getNode("Tables") );
if(!it)
{
......
......@@ -21,7 +21,7 @@ int main(int argc, char** argv)
return 0;
}
uniset_init(argc,argv,"configure.xml");
auto conf = uniset_init(argc,argv,"configure.xml");
ObjectId ID = conf->getDBServer();
......
......@@ -57,7 +57,7 @@ DBServer_SQLite::DBServer_SQLite( ObjectId id ):
}
DBServer_SQLite::DBServer_SQLite():
DBServer(conf->getDBServer()),
DBServer(uniset_conf()->getDBServer()),
db(new SQLiteInterface()),
PingTime(300000),
ReconnectTime(180000),
......@@ -251,6 +251,8 @@ void DBServer_SQLite::init_dbserver()
return;
}
auto conf = uniset_conf();
if( conf->getDBServer() == UniSetTypes::DefaultObjectId )
{
ostringstream msg;
......@@ -313,6 +315,7 @@ void DBServer_SQLite::init_dbserver()
//--------------------------------------------------------------------------------------------
void DBServer_SQLite::createTables( SQLiteInterface *db )
{
auto conf = uniset_conf();
UniXML::iterator it( conf->getNode("Tables") );
if(!it)
{
......
......@@ -21,7 +21,7 @@ int main(int argc, char** argv)
return 0;
}
uniset_init(argc,argv,"configure.xml");
auto conf = uniset_init(argc,argv,"configure.xml");
ObjectId ID = conf->getDBServer();
......
......@@ -10,7 +10,7 @@ using namespace UniSetExtensions;
// -----------------------------------------------------------------------------
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
<< " aref=" << inf.aref << " range=" << inf.range
<< " default=" << inf.defval << " safety=" << inf.safety;
......@@ -50,6 +50,8 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID,
testmode(tmNone),
prev_testmode(tmNone)
{
auto conf = uniset_conf();
string cname = conf->getArgParam("--"+prefix+"-confnode",myname);
cnode = conf->getNode(cname);
if( cnode == NULL )
......@@ -288,7 +290,7 @@ void IOControl::execute()
// чтение параметров по входам-выходам
initIOCard();
bool skip_iout = conf->getArgInt("--"+prefix+"-skip-init-output");
bool skip_iout = uniset_conf()->getArgInt("--"+prefix+"-skip-init-output");
if( !skip_iout )
initOutputs();
......@@ -646,7 +648,7 @@ void IOControl::readConfiguration()
{
readconf_ok = false;
xmlNode* root = conf->getXMLSensorsSection();
xmlNode* root = uniset_conf()->getXMLSensorsSection();
if(!root)
{
ostringstream err;
......@@ -746,7 +748,7 @@ bool IOControl::initIOItem( UniXML::iterator& it )
iomap[maxItem++] = std::move(inf);
if( dlog.debugging(Debug::LEVEL3) )
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;
}
inf.channel = IOBase::initIntProp(it,"channel",prop_prefix,false);
......@@ -1114,6 +1116,7 @@ IOControl* IOControl::init_iocontrol( int argc, const char* const* argv,
UniSetTypes::ObjectId icID, SharedMemory* ic,
const std::string& prefix )
{
auto conf = uniset_conf();
string name = conf->getArgParam("--"+prefix+"-name","IOControl1");
if( name.empty() )
{
......@@ -1474,6 +1477,8 @@ void IOControl::waitSM()
// -----------------------------------------------------------------------------
void IOControl::buildCardsList()
{
auto conf = uniset_conf();
xmlNode* nnode = conf->getXMLNodesSection();
if( !nnode )
{
......@@ -1481,7 +1486,7 @@ void IOControl::buildCardsList()
return;
}
const std::shared_ptr<UniXML> xml = conf->getConfXML();
auto xml = conf->getConfXML();
if( !xml )
{
dwarn << myname << "(buildCardsList): xml=NULL?!" << endl;
......
......@@ -21,8 +21,7 @@ int main(int argc, const char **argv)
try
{
string confile = UniSetTypes::getArgParam( "--confile", argc, argv, "configure.xml" );
conf = new Configuration(argc, argv, confile);
auto conf = uniset_init(argc, argv);
conf->initDebug(dlog,"dlog");
string logfilename = conf->getArgParam("--io-logfile","iocontrol.log");
......
......@@ -11,6 +11,7 @@ using namespace UniSetExtensions;
LProcessor::LProcessor( const std::string& name ):
logname(name)
{
auto conf = uniset_conf();
sleepTime = conf->getArgPInt("--sleepTime", 200);
smReadyTimeout = conf->getArgInt("--sm-ready-timeout","");
if( smReadyTimeout == 0 )
......@@ -58,6 +59,8 @@ void LProcessor::step()
// -------------------------------------------------------------------------
void LProcessor::build( const string& lfile )
{
auto conf = uniset_conf();
sch.read(lfile);
// составляем карту внешних входов
......
......@@ -11,6 +11,8 @@ PassiveLProcessor::PassiveLProcessor( std::string lfile, UniSetTypes::ObjectId o
UniSetObject_LT(objId),
shm(0)
{
auto conf = uniset_conf();
logname = myname;
shm = new SMInterface(shmID,&(UniSetObject_LT::ui),objId,ic);
build(lfile);
......
......@@ -11,8 +11,7 @@ int main(int argc, const char **argv)
{
try
{
string confile=UniSetTypes::getArgParam("--confile",argc,argv,"configure.xml");
conf = new Configuration( argc, argv, confile );
auto conf = uniset_init( argc, argv );
string logfilename(conf->getArgParam("--logicproc-logfile"));
if( logfilename.empty() )
......
......@@ -13,8 +13,7 @@ int main(int argc, const char **argv)
{
try
{
string confile=UniSetTypes::getArgParam("--confile",argc,argv,"configure.xml");
conf = new Configuration( argc, argv, confile );
auto conf = uniset_init( argc, argv );
string logfilename(conf->getArgParam("--logicproc-logfile"));
if( logfilename.empty() )
......
......@@ -34,6 +34,7 @@ pollActivated(false)
if( objId == DefaultObjectId )
throw UniSetTypes::SystemError("(MBExchange): objId=-1?!! Use --" + prefix + "-name" );
auto conf = uniset_conf();
mutex_start.setName(myname + "_mutex_start");
string conf_name(conf->getArgParam("--" + prefix + "-confnode",myname));
......@@ -188,7 +189,7 @@ MBExchange::~MBExchange()
void MBExchange::waitSMReady()
{
// 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 )
ready_timeout = 15000;
else if( ready_timeout < 0 )
......@@ -254,7 +255,7 @@ void MBExchange::sigterm( int signo )
void MBExchange::readConfiguration()
{
// readconf_ok = false;
xmlNode* root = conf->getXMLSensorsSection();
xmlNode* root = uniset_conf()->getXMLSensorsSection();
if(!root)
{
ostringstream err;
......@@ -527,6 +528,8 @@ void MBExchange::rtuQueryOptimization( RTUDeviceMap& m )
//std::ostream& operator<<( std::ostream& os, MBExchange::PList& lst )
std::ostream& MBExchange::print_plist( std::ostream& os, const MBExchange::PList& lst )
{
auto conf = uniset_conf();
os << "[ ";
for( auto it=lst.begin(); it!=lst.end(); ++it )
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
if( mbregFromID )
{
if( it.getProp("id").empty() )
r->mbreg = conf->getSensorID(it.getProp("name"));
r->mbreg = uniset_conf()->getSensorID(it.getProp("name"));
else
r->mbreg = it.getIntProp("id");
}
......@@ -2370,6 +2373,7 @@ std::ostream& operator<<( std::ostream& os, const MBExchange::RSProperty& p )
// -----------------------------------------------------------------------------
void MBExchange::initDeviceList()
{
auto conf = uniset_conf();
xmlNode* respNode = 0;
const std::shared_ptr<UniXML> xml = conf->getConfXML();
if( xml )
......@@ -2410,7 +2414,7 @@ bool MBExchange::initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniXM
string s(it.getProp("respondSensor"));
if( !s.empty() )
{
d->second->resp_id = conf->getSensorID(s);
d->second->resp_id = uniset_conf()->getSensorID(s);
if( d->second->resp_id == DefaultObjectId )
{
dinfo << myname << "(initDeviceInfo): not found ID for respondSensor=" << s << endl;
......@@ -2418,6 +2422,8 @@ bool MBExchange::initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniXM
}
}
auto conf = uniset_conf();
string mod(it.getProp("modeSensor"));
if( !mod.empty() )
{
......
......@@ -20,6 +20,8 @@ pollThread(0)
if( objId == DefaultObjectId )
throw UniSetTypes::SystemError("(MBTCPMaster): objId=-1?!! Use --" + prefix + "-name" );
auto conf = uniset_conf();
// префикс для "свойств" - по умолчанию
prop_prefix = "tcp_";
// если задано поле для "фильтрации"
......@@ -219,6 +221,7 @@ MBTCPMaster* MBTCPMaster::init_mbmaster( int argc, const char* const* argv,
UniSetTypes::ObjectId icID, SharedMemory* ic,
const std::string& prefix )
{
auto conf = uniset_conf();
string name = conf->getArgParam("--" + prefix + "-name","MBTCPMaster1");
if( name.empty() )
{
......
......@@ -22,6 +22,8 @@ checkThread(0)
if( objId == DefaultObjectId )
throw UniSetTypes::SystemError("(MBTCPMultiMaster): objId=-1?!! Use --" + prefix + "-name" );
auto conf = uniset_conf();
// префикс для "свойств" - по умолчанию
prop_prefix = "tcp_";
// если задано поле для "фильтрации"
......@@ -365,6 +367,8 @@ MBTCPMultiMaster* MBTCPMultiMaster::init_mbmaster( int argc, const char* const*
UniSetTypes::ObjectId icID, SharedMemory* ic,
const std::string& prefix )
{
auto conf = uniset_conf();
string name = conf->getArgParam("--" + prefix + "-name","MBTCPMultiMaster1");
if( name.empty() )
{
......
......@@ -20,6 +20,8 @@ rs_pre_clean(false)
if( objId == DefaultObjectId )
throw UniSetTypes::SystemError("(RTUExchange): objId=-1?!! Use --" + prefix + "-name" );
auto conf = uniset_conf();
// префикс для "свойств" - по умолчанию
prop_prefix = "";
// если задано поле для "фильтрации"
......@@ -317,6 +319,8 @@ void RTUExchange::poll()
RTUExchange* RTUExchange::init_rtuexchange( int argc, const char* const* argv, UniSetTypes::ObjectId icID,
SharedMemory* ic, const std::string& prefix )
{
auto conf = uniset_conf();
string name = conf->getArgParam("--" + prefix + "-name","RTUExchange1");
if( name.empty() )
{
......
......@@ -23,8 +23,7 @@ int main( int argc, const char** argv )
try
{
string confile=UniSetTypes::getArgParam("--confile",argc, argv, "configure.xml");
conf = new Configuration( argc, argv, confile );
auto conf = uniset_init( argc, argv );
string logfilename(conf->getArgParam("--mbtcp-logfile"));
if( logfilename.empty() )
......
......@@ -23,8 +23,7 @@ int main( int argc, const char** argv )
try
{
string confile=UniSetTypes::getArgParam("--confile",argc, argv, "configure.xml");
conf = new Configuration( argc, argv, confile );
auto conf = uniset_init( argc, argv );
string logfilename(conf->getArgParam("--mbtcp-logfile"));
if( logfilename.empty() )
......
......@@ -21,8 +21,7 @@ int main( int argc, char** argv )
return 0;
}
string confile=UniSetTypes::getArgParam("--confile", argc, argv, "configure.xml");
conf = new Configuration( argc, argv, confile );
auto conf = uniset_init( argc, argv );
string logfilename(conf->getArgParam("--rs-logfile"));
if( logfilename.empty() )
......
......@@ -32,6 +32,7 @@ prefix(prefix)
if( objId == DefaultObjectId )
throw UniSetTypes::SystemError("(MBSlave): objId=-1?!! Use --mbs-name" );
auto conf = uniset_conf();
mutex_start.setName(myname + "_mutex_start");
// xmlNode* cnode = conf->getNode(myname);
......@@ -377,7 +378,7 @@ MBSlave::~MBSlave()
void MBSlave::waitSMReady()
{
// 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 )
ready_timeout = 15000;
else if( ready_timeout < 0 )
......@@ -774,7 +775,7 @@ void MBSlave::sigterm( int signo )
void MBSlave::readConfiguration()
{
// readconf_ok = false;
xmlNode* root = conf->getXMLSensorsSection();
xmlNode* root = uniset_conf()->getXMLSensorsSection();
if(!root)
{
ostringstream err;
......@@ -936,6 +937,7 @@ void MBSlave::help_print( int argc, const char* const* argv )
MBSlave* MBSlave::init_mbslave( int argc, const char* const* argv, UniSetTypes::ObjectId icID, SharedMemory* ic,
const string& prefix )
{
auto conf = uniset_conf();
string name = conf->getArgParam("--" + prefix + "-name","MBSlave1");
if( name.empty() )
{
......
......@@ -15,6 +15,8 @@ MBTCPMultiSlave::MBTCPMultiSlave( UniSetTypes::ObjectId objId, UniSetTypes::Obje
MBSlave(objId,shmId,ic,prefix),
sesscount_id(DefaultObjectId)
{
auto conf = uniset_conf();
cnode = conf->getNode(myname);
if( cnode == NULL )
throw UniSetTypes::SystemError("(MBSlave): Not found conf-node for " + myname );
......@@ -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,
const string& prefix )
{
auto conf = uniset_conf();
string name = conf->getArgParam("--" + prefix + "-name","MBSlave1");
if( name.empty() )
{
......
......@@ -36,4 +36,4 @@ pkgconfig_DATA = libUniSet2MBSlave.pc
all-local:
ln -sf ../ModbusSlave/$(devel_include_HEADERS) ../include
#SUBDIRS=tests
SUBDIRS=tests
......@@ -28,8 +28,7 @@ int main(int argc, const char **argv)
try
{
string confile = UniSetTypes::getArgParam( "--confile", argc, argv, "configure.xml" );
conf = new Configuration(argc, argv,confile);
auto conf = uniset_init(argc, argv);
string logfilename(conf->getArgParam("--mbs-logfile"));
if( logfilename.empty() )
......
......@@ -28,8 +28,7 @@ int main(int argc, const char **argv)
try
{
string confile = UniSetTypes::getArgParam( "--confile", argc, argv, "configure.xml" );
conf = new Configuration(argc, argv,confile);
auto conf = uniset_init(argc, argv);
string logfilename(conf->getArgParam("--mbs-logfile"));
if( logfilename.empty() )
......
......@@ -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/SharedMemory $(SIGC_CFLAGS) $(COMCPP_CFLAGS)
$(top_builddir)/extensions/lib/libUniSet2Extensions.la:
cd $(top_builddir)/extensions/lib/ && make
#$(top_builddir)/extensions/lib/libUniSet2Extensions.la:
# cd $(top_builddir)/extensions/lib/ && make
$(top_builddir)/extensions/ModbusSlave/libUniSet2MBSlave.la:
cd $(top_builddir)/extensions/ModbusSlave/ && make
#$(top_builddir)/extensions/ModbusSlave/libUniSet2MBSlave.la:
# cd $(top_builddir)/extensions/ModbusSlave/ && make
include $(top_builddir)/testsuite/testsuite-common.mk
......
......@@ -18,14 +18,15 @@ static UInterface* ui = nullptr;
// -----------------------------------------------------------------------------
void InitTest()
{
CHECK( conf!=0 );
auto conf = uniset_conf();
CHECK( conf!=nullptr );
if( ui == nullptr )
{
ui = new UInterface();
// UI понадобиться для проверки записанных в SM значений.
CHECK( ui->getObjectIndex() != nullptr );
CHECK( ui->getConf() == UniSetTypes::conf );
CHECK( ui->getConf() == conf );
CHECK( ui->waitReady(slaveID,5000) );
}
......@@ -673,6 +674,7 @@ static void test_write10_F2( const float& val )
REQUIRE( ret.start == tREG );
REQUIRE( ret.quant == F2::wsize() );
auto conf = uniset_conf();
IOController_i::SensorInfo si;
si.id = 2007;
si.node = conf->getLocalNode();
......@@ -693,6 +695,7 @@ static void test_write10_F2r( const float& val )
REQUIRE( ret.start == tREG );
REQUIRE( ret.quant == F2r::wsize() );
auto conf = uniset_conf();
IOController_i::SensorInfo si;
si.id = 2008;
si.node = conf->getLocalNode();
......@@ -716,6 +719,7 @@ static void test_write10_F4raw( const float& val )
REQUIRE( ret.start == tREG );
REQUIRE( ret.quant == F4::wsize() );
auto conf = uniset_conf();
IOController_i::SensorInfo si;
si.id = 2013;
si.node = conf->getLocalNode();
......@@ -740,6 +744,7 @@ static void test_write10_F4prec( const float& val )
REQUIRE( ret.start == tREG );
REQUIRE( ret.quant == F4::wsize() );
auto conf = uniset_conf();
IOController_i::SensorInfo si;
si.id = 2009;
si.node = conf->getLocalNode();
......
......@@ -31,7 +31,7 @@ int main(int argc, char* argv[] )
try
{
uniset_init(argc,argv);
auto conf = uniset_init(argc,argv);
conf->initDebug(dlog,"dlog");
bool apart = findArgParam("--apart",argc,argv) != -1;
......
......@@ -98,6 +98,7 @@ void RRDServer::initRRD( xmlNode* cnode, int tmID )
// try
{
auto conf = uniset_conf();
xmlNode* snode = conf->getXMLSensorsSection();
if(!snode)
......@@ -225,6 +226,8 @@ RRDServer* RRDServer::init_rrdstorage( int argc, const char* const* argv,
UniSetTypes::ObjectId icID, SharedMemory* ic,
const std::string& prefix )
{
auto conf = uniset_conf();
string name = conf->getArgParam("--" + prefix + "-name","RRDServer");
if( name.empty() )
{
......
......@@ -23,8 +23,7 @@ int main( int argc, const char** argv )
try
{
string confile=UniSetTypes::getArgParam("--confile",argc, argv, "configure.xml");
conf = new Configuration( argc, argv, confile );
auto conf = uniset_init( argc, argv );
string logfilename(conf->getArgParam("--rrdstorage-logfile"));
if( logfilename.empty() )
......
......@@ -7,7 +7,7 @@ using namespace UniSetTypes;
using namespace UniSetExtensions;
//--------------------------------------------------------------------------------
SMViewer::SMViewer( UniSetTypes::ObjectId shmID ):
SViewer(conf->getControllersSection(),true)
SViewer(uniset_conf()->getControllersSection(),true)
{
shm = new SMInterface(shmID,&ui,DefaultObjectId,0);
}
......
......@@ -18,8 +18,7 @@ int main( int argc, const char **argv )
return 0;
}
string confile = UniSetTypes::getArgParam( "--confile", argc, argv, "configure.xml" );
conf = new Configuration( argc, argv, confile );
auto conf = uniset_init( argc, argv );
ObjectId shmID = DefaultObjectId;
string sID = conf->getArgParam("--smemory-id");
......
......@@ -43,9 +43,11 @@ SharedMemory::SharedMemory( ObjectId id, const std::string& datafile, const std:
{
mutex_start.setName(myname + "_mutex_start");
auto conf = uniset_conf();
string cname(confname);
if( cname.empty() )
cname = ORepHelpers::getShortName(conf->oind->getMapName(id));
cname = ORepHelpers::getShortName( conf->oind->getMapName(id));
xmlNode* cnode = conf->getNode(cname);
if( cnode == NULL )
......@@ -374,7 +376,7 @@ bool SharedMemory::readItem( const std::shared_ptr<UniXML>& xml, UniXML::iterato
}
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 )
{
ostringstream msg;
......@@ -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 )
{
auto conf = uniset_conf();
string dfile = conf->getArgParam("--datfile", conf->getConfFileName());
if( dfile[0]!='.' && dfile[0]!='/' )
......@@ -439,7 +442,7 @@ void SharedMemory::buildEventList( xmlNode* cnode )
// -----------------------------------------------------------------------------
void SharedMemory::readEventList( const std::string& oname )
{
xmlNode* enode = conf->getNode(oname);
xmlNode* enode = uniset_conf()->getNode(oname);
if( enode == NULL )
{
dwarn << myname << "(readEventList): " << oname << " не найден..." << endl;
......@@ -508,7 +511,7 @@ void SharedMemory::buildHistoryList( xmlNode* cnode )
{
dinfo << myname << "(buildHistoryList): ..." << endl;
const std::shared_ptr<UniXML> xml = conf->getConfXML();
const std::shared_ptr<UniXML> xml = uniset_conf()->getConfXML();
if( !xml )
{
dwarn << myname << "(buildHistoryList): xml=NULL?!" << endl;
......@@ -525,7 +528,7 @@ void SharedMemory::buildHistoryList( xmlNode* cnode )
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 )
{
dwarn << myname << "(buildHistoryList): no_history='1'.. history skipped..." << endl;
......@@ -555,7 +558,7 @@ void SharedMemory::buildHistoryList( xmlNode* cnode )
if( hi.filter.empty() )
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 )
{
dwarn << myname << "(buildHistory): not found sensor ID for "
......@@ -604,7 +607,7 @@ void SharedMemory::checkHistoryFilter( UniXML::iterator& xit )
continue;
}
ai.id = conf->getSensorID(xit.getProp("name"));
ai.id = uniset_conf()->getSensorID(xit.getProp("name"));
if( ai.id == DefaultObjectId )
{
dwarn << myname << "(checkHistoryFilter): not found sensor ID for " << xit.getProp("name") << endl;
......
......@@ -19,8 +19,7 @@ int main(int argc, const char **argv)
try
{
string confile = UniSetTypes::getArgParam( "--confile", argc, argv, "configure.xml" );
conf = new Configuration(argc, argv, confile);
auto conf = uniset_init(argc, argv);
conf->initDebug(dlog,"dlog");
string logfilename = conf->getArgParam("--logfile", "smemory.log");
......
......@@ -67,8 +67,7 @@ int main( int argc, const char **argv )
try
{
string confile = UniSetTypes::getArgParam( "--confile", argc, argv, "configure.xml" );
conf = new Configuration(argc, argv, confile);
auto conf = uniset_init(argc, argv);
string logfilename = conf->getArgParam("--logfile", "smemory-plus.log");
string logname( conf->getLogDir() + logfilename );
......@@ -287,8 +286,9 @@ void help_print( int argc, const char* argv[] )
// -----------------------------------------------------------------------------
LogServer* run_logserver( const std::string& cname, DebugStream& log )
{
const std::shared_ptr<UniXML> xml = UniSetTypes::conf->getConfXML();
xmlNode* cnode = UniSetTypes::conf->findNode(xml->getFirstNode(),"LogServer",cname);
auto conf = uniset_conf();
auto xml = conf->getConfXML();
xmlNode* cnode = conf->findNode(xml->getFirstNode(),"LogServer",cname);
if( cnode == 0 )
{
cerr << "(init_ulogserver): Not found xmlnode for '" << cname << "'" << endl;
......
......@@ -19,6 +19,8 @@ sender2(0)
if( objId == DefaultObjectId )
throw UniSetTypes::SystemError("(UNetExchange): objId=-1?!! Use --" + prefix +"-unet-name" );
auto conf = uniset_conf();
cnode = conf->getNode(myname);
if( cnode == NULL )
throw UniSetTypes::SystemError("(UNetExchange): Not found conf-node for " + myname );
......@@ -376,7 +378,7 @@ void UNetExchange::startReceivers()
void UNetExchange::waitSMReady()
{
// 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 )
ready_timeout = 15000;
else if( ready_timeout < 0 )
......@@ -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,
SharedMemory* ic, const std::string& prefix )
{
auto conf = uniset_conf();
string p("--" + prefix + "-name");
string name = conf->getArgParam(p,"UNetExchange1");
if( name.empty() )
......
......@@ -519,7 +519,7 @@ void UNetReceiver::initDCache( UniSetUDP::UDPMessage& pack, bool force )
if( 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);
}
}
......@@ -540,7 +540,7 @@ void UNetReceiver::initACache( UniSetUDP::UDPMessage& pack, bool force )
if( 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);
}
}
......
......@@ -71,7 +71,7 @@ s_thr(0)
// выставляем поля, которые не меняются
mypack.nodeID = conf->getLocalNode();
mypack.nodeID = uniset_conf()->getLocalNode();
mypack.procID = shm->ID();
}
// -----------------------------------------------------------------------------
......@@ -210,7 +210,7 @@ void UNetSender::start()
// -----------------------------------------------------------------------------
void UNetSender::readConfiguration()
{
xmlNode* root = conf->getXMLSensorsSection();
xmlNode* root = uniset_conf()->getXMLSensorsSection();
if(!root)
{
ostringstream err;
......@@ -253,7 +253,7 @@ bool UNetSender::initItem( UniXML::iterator& it )
sid = DefaultObjectId;
}
else
sid = conf->getSensorID(sname);
sid = uniset_conf()->getSensorID(sname);
if( sid == DefaultObjectId )
{
......
......@@ -21,7 +21,7 @@ int main( int argc, const char** argv )
return 0;
}
uniset_init(argc,argv);
auto conf = uniset_init(argc,argv);
string logfilename(conf->getArgParam("--unet-logfile"));
if( logfilename.empty() )
......
......@@ -10,7 +10,7 @@ using namespace UniSetExtensions;
UniExchange::NetNodeInfo::NetNodeInfo():
oref(CORBA::Object::_nil()),
id(DefaultObjectId),
node(conf->getLocalNode()),
node(uniset_conf()->getLocalNode()),
sidConnection(DefaultObjectId),
smap(1)
{
......@@ -26,6 +26,8 @@ mymap(1),
maxIndex(0),
smReadyTimeout(15000)
{
auto conf = uniset_conf();
cnode = conf->getNode(myname);
if( cnode == NULL )
throw UniSetTypes::SystemError("(UniExchange): Not found conf-node for " + myname );
......@@ -176,7 +178,7 @@ void UniExchange::execute()
catch(...)
{
dcrit << myname << "(execute): sensor not avalible "
<< conf->oind->getNameById(it.sidConnection)
<< uniset_conf()->oind->getNameById(it.sidConnection)
<< endl;
}
}
......@@ -329,6 +331,8 @@ UniExchange* UniExchange::init_exchange( int argc, const char* const* argv,
UniSetTypes::ObjectId icID, SharedMemory* ic,
const std::string& prefix )
{
auto conf = uniset_conf();
string p("--" + prefix + "-name");
string nm(UniSetTypes::getArgParam(p,argc,argv,"UniExchange"));
......@@ -345,7 +349,7 @@ UniExchange* UniExchange::init_exchange( int argc, const char* const* argv,
void UniExchange::readConfiguration()
{
// readconf_ok = false;
xmlNode* root = conf->getXMLSensorsSection();
xmlNode* root = uniset_conf()->getXMLSensorsSection();
if(!root)
{
ostringstream err;
......@@ -383,7 +387,7 @@ bool UniExchange::initItem( UniXML::iterator& it )
i.id = DefaultObjectId;
if( it.getProp("id").empty() )
i.id = conf->getSensorID(it.getProp("name"));
i.id = uniset_conf()->getSensorID(it.getProp("name"));
else
{
i.id = it.getIntProp("id");
......
......@@ -19,8 +19,7 @@ int main(int argc, const char **argv)
try
{
string confile = UniSetTypes::getArgParam( "--confile", argc, argv, "configure.xml" );
conf = new Configuration(argc, argv, confile);
auto conf = uniset_init(argc, argv);
conf->initDebug(dlog,"dlog");
string logfilename = conf->getArgParam("--logfile", "smemory.log");
......
......@@ -8,7 +8,7 @@
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/
// --------------------------------------------------------------------------
// generate timestamp: 2014-01-27+04:00
// generate timestamp: 2014-11-24+03:00
// -----------------------------------------------------------------------------
#ifndef UObject_SK_H_
#define UObject_SK_H_
......@@ -25,7 +25,7 @@ class UObject_SK:
public LT_Object
{
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();
virtual ~UObject_SK();
......@@ -33,7 +33,7 @@ class UObject_SK:
bool alarm( UniSetTypes::ObjectId sid, bool state );
long getValue( UniSetTypes::ObjectId sid );
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 setMsg( UniSetTypes::ObjectId code, bool state );
......@@ -76,14 +76,14 @@ class UObject_SK:
// ---- end of protected variables ----
virtual void callback();
virtual void processingMessage( UniSetTypes::VoidMessage* msg );
virtual void sysCommand( const UniSetTypes::SystemMessage* sm );
virtual void callback() override;
virtual void processingMessage( UniSetTypes::VoidMessage* msg ) override;
virtual void sysCommand( const UniSetTypes::SystemMessage* sm ) override;
virtual void askSensors( UniversalIO::UIOCommand cmd ){}
virtual void sensorInfo( const UniSetTypes::SensorMessage* sm ){}
virtual void timerInfo( const UniSetTypes::TimerMessage* tm ){}
virtual void sigterm( int signo );
virtual bool activateObject();
virtual void sensorInfo( const UniSetTypes::SensorMessage* sm ) override{}
virtual void timerInfo( const UniSetTypes::TimerMessage* tm ) override{}
virtual void sigterm( int signo ) override;
virtual bool activateObject() override;
virtual void testMode( bool state );
void updatePreviousValues();
void checkSensors();
......@@ -100,7 +100,7 @@ class UObject_SK:
int resetMsgTime;
// Выполнение очередного шага программы
virtual void step()=0;
virtual void step(){}
int sleep_msec; /*!< пауза между итерациями */
bool active;
......@@ -114,9 +114,9 @@ class UObject_SK:
xmlNode* 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 */
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 */
std::atomic_bool activated;
......
......@@ -18,6 +18,8 @@ namespace UniSetExtensions
if( shmID != DefaultObjectId )
return shmID;
auto conf = uniset_conf();
string sname = conf->getArgParam("--smemory-id","SharedMemory1");
shmID = conf->getControllerID(sname);
......@@ -54,7 +56,7 @@ namespace UniSetExtensions
if( xmlCalibrationsNode )
return xmlCalibrationsNode;
xmlCalibrationsNode = conf->getNode("Calibrations");
xmlCalibrationsNode = uniset_conf()->getNode("Calibrations");
return xmlCalibrationsNode;
}
......
......@@ -7,7 +7,7 @@ using namespace UniSetTypes;
// -----------------------------------------------------------------------------
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;
}
// -----------------------------------------------------------------------------
......@@ -433,7 +433,7 @@ bool IOBase::initItem( IOBase* b, UniXML::iterator& it, SMInterface* shm, const
ObjectId sid = DefaultObjectId;
if( it.getProp("id").empty() )
sid = conf->getSensorID(sname);
sid = uniset_conf()->getSensorID(sname);
else
sid = it.getPIntProp("id",DefaultObjectId);
......@@ -448,7 +448,7 @@ bool IOBase::initItem( IOBase* b, UniXML::iterator& it, SMInterface* shm, const
b->val_lock.setName(sname + "_lock");
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->ignore = initIntProp(it,"ioignore",prefix,init_prefix_only);
......@@ -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));
if( !tai.empty() )
{
b->t_ai = conf->getSensorID(tai);
b->t_ai = uniset_conf()->getSensorID(tai);
if( b->t_ai == DefaultObjectId )
{
if( dlog && dlog->is_crit() )
......
......@@ -10,6 +10,7 @@ using namespace UniSetTypes;
#define BEG_FUNC(name) \
try \
{ \
auto conf = ui->getConf(); \
uniset_rwmutex_wrlock l(shmMutex); \
IONotifyController_i_var shm;\
for( unsigned int i=0; i<conf->getRepeatCount(); i++)\
......@@ -33,6 +34,7 @@ using namespace UniSetTypes;
#define BEG_FUNC1(name) \
try \
{ \
auto conf = ui->getConf(); \
uniset_rwmutex_wrlock l(shmMutex); \
if( true ) \
{ \
......@@ -111,7 +113,7 @@ void SMInterface::setValue( UniSetTypes::ObjectId id, long value )
IOController_i::SensorInfo si;
si.id = id;
si.node = conf->getLocalNode();
si.node = ui->getConf()->getLocalNode();
BEG_FUNC1(SMInterface::setValue)
ui->fastSetValue(si,value,myid);
......@@ -137,7 +139,7 @@ void SMInterface::askSensor( UniSetTypes::ObjectId id, UniversalIO::UIOCommand c
{
ConsumerInfo_var ci;
ci->id = (backid==DefaultObjectId) ? myid : backid;
ci->node = conf->getLocalNode();
ci->node = ui->getConf()->getLocalNode();
if( ic )
{
......@@ -224,7 +226,7 @@ void SMInterface::localSetValue( IOController::IOStateList::iterator& it,
// CHECK_IC_PTR(localSetValue)
IOController_i::SensorInfo si;
si.id = sid;
si.node = conf->getLocalNode();
si.node = ui->getConf()->getLocalNode();
ic->localSetValue(it,si.id,value,sup_id);
}
// --------------------------------------------------------------------------
......@@ -246,7 +248,7 @@ void SMInterface::localSetUndefinedState( IOController::IOStateList::iterator& i
{
IOController_i::SensorInfo si;
si.id = sid;
si.node = conf->getLocalNode();
si.node = ui->getConf()->getLocalNode();
setUndefinedState(si,undefined,myid);
return;
}
......
......@@ -11,7 +11,7 @@
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/
// --------------------------------------------------------------------------
// generate timestamp: 2014-01-27+04:00
// generate timestamp: 2014-11-24+03:00
// -----------------------------------------------------------------------------
#include "Configuration.h"
#include "Exceptions.h"
......@@ -38,7 +38,7 @@ idHeartBeat(DefaultObjectId),
maxHeartBeat(10),
confnode(0),
smReadyTimeout(0),
activated(0),
activated(false),
askPause(2000),
end_private(false)
......@@ -73,13 +73,15 @@ idHeartBeat(DefaultObjectId),
maxHeartBeat(10),
confnode(cnode),
smReadyTimeout(0),
activated(0),
askPause(conf->getPIntProp(cnode,"askPause",2000)),
activated(false),
askPause(uniset_conf()->getPIntProp(cnode,"askPause",2000)),
end_private(false)
{
auto conf = uniset_conf();
if( UniSetTypes::findArgParam("--print-id-list",conf->getArgc(),conf->getArgv()) != -1 )
if( UniSetTypes::findArgParam("--print-id-list",uniset_conf()->getArgc(),uniset_conf()->getArgv()) != -1 )
{
// abort();
......@@ -405,8 +407,9 @@ void UObject_SK::callback()
// -----------------------------------------------------------------------------
void UObject_SK::setValue( UniSetTypes::ObjectId _sid, long _val )
{
// ui.setState(sid,state);
ui.setValue(_sid,_val);
}
// -----------------------------------------------------------------------------
void UObject_SK::updateOutputs( bool _force )
......@@ -431,16 +434,14 @@ long UObject_SK::getValue( UniSetTypes::ObjectId _sid )
try
{
ucrit << myname << "(getValue): Обращение к неизвестному датчику sid="
<< _sid << endl;
return ui.getValue(_sid);
}
catch(Exception& ex)
{
ucrit << myname << "(getValue): " << ex << endl;
throw;
}
return 0;
}
// -----------------------------------------------------------------------------
......
......@@ -11,7 +11,7 @@ using namespace UniSetExtensions;
TEST_CASE("IOBase","[IOBase class tests]")
{
CHECK( UniSetTypes::conf != 0 );
CHECK( uniset_conf()!=nullptr );
SECTION("Default constructor (const data)")
{
......@@ -58,6 +58,7 @@ TEST_CASE("IOBase","[IOBase class tests]")
SECTION("Init from xml")
{
auto conf = uniset_conf();
xmlNode* cnode = conf->getNode("iobasetest");
CHECK( cnode != NULL );
UniXML::iterator it(cnode);
......
......@@ -9,11 +9,13 @@ using namespace UniSetTypes;
TEST_CASE("UInterface","[UInterface]")
{
CHECK( conf!=0 );
CHECK( uniset_conf()!=nullptr );
std::string sidName("Input1_S");
std::string aidName("AI_AS");
auto conf = uniset_conf();
ObjectId testOID = conf->getObjectID("TestProc");
CHECK( testOID != DefaultObjectId );
......@@ -26,7 +28,7 @@ TEST_CASE("UInterface","[UInterface]")
UInterface ui;
CHECK( ui.getObjectIndex() != nullptr );
CHECK( ui.getConf() == UniSetTypes::conf );
CHECK( ui.getConf() == uniset_conf() );
REQUIRE( ui.getConfIOType(sid) == UniversalIO::DI );
REQUIRE( ui.getConfIOType(aid) == UniversalIO::AI );
......
......@@ -229,17 +229,14 @@ namespace UniSetTypes
int heartbeat_msec;
};
/*! Глобальный указатель на конфигуратор */
extern Configuration* conf;
/*! Глобальный указатель на конфигурацию (singleton) */
std::shared_ptr<Configuration> uniset_conf();
/*! Глобальный объект для вывода логов */
extern DebugStream ulog;
// Инициализация UniSetTypes::conf.
// ( учитываются параметры командной строки --confile и --id-from-config )
// force - инициализировать принудительно, даже если это повторная инициализация
void uniset_init( int argc, const char* const* argv, const std::string& xmlfile="configure.xml", bool force = false );
/*! инициализация "глобальной" конфигурации */
std::shared_ptr<Configuration> uniset_init( int argc, const char* const* argv, const std::string& xmlfile="configure.xml" );
} // end of UniSetTypes namespace
// --------------------------------------------------------------------------
......
......@@ -81,7 +81,7 @@ class IOController:
IOController_i::CalibrateInfo getCalibrateInfo( UniSetTypes::ObjectId sid ) override;
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;
si.id = sid;
......
......@@ -25,6 +25,7 @@
#ifndef ObjectRepository_H_
#define ObjectRepository_H_
// --------------------------------------------------------------------------
#include <memory>
#include <omniORB4/CORBA.h>
#include <omniORB4/Naming.hh>
#include <string>
......@@ -46,7 +47,7 @@
{
public:
ObjectRepository( const UniSetTypes::Configuration* conf);
ObjectRepository( const std::shared_ptr<UniSetTypes::Configuration>& conf );
~ObjectRepository();
/**
......@@ -100,7 +101,7 @@
ObjectRepository();
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);
......
......@@ -40,7 +40,7 @@
public:
// ObjectRepositoryFactory();
// ObjectRepositoryFactory(int* argc=argc_ptr, char* **argv=argv_ptr); // параметры инициализации ORB
ObjectRepositoryFactory( UniSetTypes::Configuration* conf );
ObjectRepositoryFactory( const std::shared_ptr<UniSetTypes::Configuration>& conf );
~ObjectRepositoryFactory();
//! Создание секции
......
......@@ -65,8 +65,8 @@ class UInterface
{
public:
UInterface( const UniSetTypes::ObjectId backid, CORBA::ORB_var orb=NULL, std::shared_ptr<UniSetTypes::ObjectIndex> oind=nullptr );
UInterface( const UniSetTypes::Configuration* uconf=UniSetTypes::conf );
UInterface( const UniSetTypes::ObjectId backid, CORBA::ORB_var orb=NULL, const std::shared_ptr<UniSetTypes::ObjectIndex> oind=nullptr );
UInterface( const std::shared_ptr<UniSetTypes::Configuration>& uconf = UniSetTypes::uniset_conf() );
~UInterface();
// ---------------------------------------------------------------
......@@ -154,7 +154,7 @@ class UInterface
//! Получить список датчиков
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
bool isExist( const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node ) const;
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,
const UniSetTypes::ObjectId node = UniSetTypes::conf->getLocalNode() ); // used getValue
const UniSetTypes::ObjectId node = UniSetTypes::uniset_conf()->getLocalNode() ); // used getValue
// ---------------------------------------------------------------
// Работа с ID, Name
......@@ -222,8 +222,7 @@ class UInterface
// ---------------------------------------------------------------
// Получение указателей на вспомогательные классы.
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
mutable CORBA::ORB_var orb;
CacheOfResolve rcache;
std::shared_ptr<UniSetTypes::ObjectIndex> oind;
const UniSetTypes::Configuration* uconf;
std::shared_ptr<UniSetTypes::Configuration> uconf;
};
// --------------------------------------------------------------------------
#endif
......
......@@ -25,6 +25,7 @@
#ifndef UniSetTypes_H_
#define UniSetTypes_H_
// --------------------------------------------------------------------------
#include <memory>
#include <cstdlib>
#include <cstdio>
#include <string>
......@@ -46,8 +47,6 @@ inline void msleep( unsigned int m ) { usleep(m*1000); }
namespace UniSetTypes
{
class Configuration;
extern Configuration* conf;
// ---------------------------------------------------------------
// Вспомогательные типы данных и константы
......@@ -172,7 +171,7 @@ namespace UniSetTypes
/*! Функция разбора строки вида: id1@node1=val1,id2@node2=val2,...
Если '=' не указано, возвращается val=0
Если @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 );
......
......@@ -36,10 +36,11 @@ void pyUInterface::uniset_init( int argc, char* argv[], const char* xmlfile )thr
//---------------------------------------------------------------------------
long pyUInterface::getValue( long id )throw(UException)
{
if( !UniSetTypes::conf || !ui )
auto conf = UniSetTypes::uniset_conf();
if( !conf || !ui )
throw USysError();
UniversalIO::IOType t = UniSetTypes::conf->getIOType(id);
UniversalIO::IOType t = conf->getIOType(id);
try
{
switch(t)
......@@ -77,10 +78,12 @@ long pyUInterface::getValue( long id )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();
UniversalIO::IOType t = UniSetTypes::conf->getIOType(id);
UniversalIO::IOType t = conf->getIOType(id);
try
{
switch(t)
......@@ -116,40 +119,45 @@ void pyUInterface::setValue( long id, long val )throw(UException)
//---------------------------------------------------------------------------
long pyUInterface::getSensorID( const char* name )
{
if( UniSetTypes::conf )
return UniSetTypes::conf->getSensorID(name);
auto conf = UniSetTypes::uniset_conf();
if( conf )
return conf->getSensorID(name);
return UniSetTypes::DefaultObjectId;
}
//---------------------------------------------------------------------------
const char* pyUInterface::getName( long id )
{
if( UniSetTypes::conf )
return UniSetTypes::conf->oind->getMapName(id).c_str();
auto conf = UniSetTypes::uniset_conf();
if( conf )
return conf->oind->getMapName(id).c_str();
return "";
}
//---------------------------------------------------------------------------
const char* pyUInterface::getShortName( long id )
{
if( UniSetTypes::conf )
return ORepHelpers::getShortName(UniSetTypes::conf->oind->getMapName(id)).c_str();
auto conf = UniSetTypes::uniset_conf();
if( conf )
return ORepHelpers::getShortName(conf->oind->getMapName(id)).c_str();
return "";
}
//---------------------------------------------------------------------------
const char* pyUInterface::getTextName( long id )
{
if( UniSetTypes::conf )
return UniSetTypes::conf->oind->getTextName(id).c_str();
auto conf = UniSetTypes::uniset_conf();
if( conf )
return conf->oind->getTextName(id).c_str();
return "";
}
//---------------------------------------------------------------------------
const char* pyUInterface::getConfFileName()
{
if( UniSetTypes::conf )
return UniSetTypes::conf->getConfFileName().c_str();
auto conf = UniSetTypes::uniset_conf();
if( conf )
return conf->getConfFileName().c_str();
return "";
......
......@@ -10,8 +10,8 @@ xmlfile(xfile)
{
try
{
conf = new UniSetTypes::Configuration(p->argc,p->argv,xmlfile);
ui = new UInterface(conf);
conf = UniSetTypes::uniset_init(p->argc,p->argv,xmlfile);
ui = make_shared<UInterface>(conf);
}
catch( UniSetTypes::Exception& ex )
{
......@@ -30,8 +30,8 @@ xmlfile(xfile)
{
try
{
conf = new UniSetTypes::Configuration(argc,argv,xmlfile);
ui = new UInterface(conf);
conf = UniSetTypes::uniset_init(argc,argv,xmlfile);
ui = make_shared<UInterface>(conf);
}
catch( UniSetTypes::Exception& ex )
{
......@@ -45,8 +45,6 @@ xmlfile(xfile)
// --------------------------------------------------------------------------
UConnector::~UConnector()
{
delete ui;
delete conf;
}
// --------------------------------------------------------------------------
const char* UConnector::getConfFileName()
......
#ifndef UConnector_H_
#define UConnector_H_
// --------------------------------------------------------------------------
#include <memory>
#include <string>
#include "Configuration.h"
#include "UInterface.h"
......@@ -29,8 +30,8 @@ class UConnector
private:
UniSetTypes::Configuration* conf;
UInterface* ui;
std::shared_ptr<UniSetTypes::Configuration> conf;
std::shared_ptr<UInterface> ui;
const char* xmlfile;
};
//---------------------------------------------------------------------------
......
/* ----------------------------------------------------------------------------
* 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
* 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};
#endif
#define SWIG_name "_pyUConnector"
#define SWIGVERSION 0x030000
#define SWIGVERSION 0x030002
#define SWIG_VERSION SWIGVERSION
......@@ -3305,7 +3305,11 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size)
SWIG_InternalNewPointerObj(const_cast< char * >(carray), pchar_descriptor, 0) : SWIG_Py_Void();
} else {
#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));
#endif
#else
return PyString_FromStringAndSize(carray, static_cast< int >(size));
#endif
......
/* ----------------------------------------------------------------------------
* 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
* 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};
#endif
#define SWIG_name "_pyUExceptions"
#define SWIGVERSION 0x030000
#define SWIGVERSION 0x030002
#define SWIG_VERSION SWIGVERSION
......@@ -3143,7 +3143,11 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size)
SWIG_InternalNewPointerObj(const_cast< char * >(carray), pchar_descriptor, 0) : SWIG_Py_Void();
} else {
#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));
#endif
#else
return PyString_FromStringAndSize(carray, static_cast< int >(size));
#endif
......
/* ----------------------------------------------------------------------------
* 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
* 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};
#endif
#define SWIG_name "_pyUniSet"
#define SWIGVERSION 0x030000
#define SWIGVERSION 0x030002
#define SWIG_VERSION SWIGVERSION
......@@ -3293,7 +3293,11 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size)
SWIG_InternalNewPointerObj(const_cast< char * >(carray), pchar_descriptor, 0) : SWIG_Py_Void();
} else {
#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));
#endif
#else
return PyString_FromStringAndSize(carray, static_cast< int >(size));
#endif
......
/* ----------------------------------------------------------------------------
* 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
* 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};
#endif
#define SWIG_name "_pyUModbus"
#define SWIGVERSION 0x030000
#define SWIGVERSION 0x030002
#define SWIG_VERSION SWIGVERSION
......@@ -3067,7 +3067,11 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size)
SWIG_InternalNewPointerObj(const_cast< char * >(carray), pchar_descriptor, 0) : SWIG_Py_Void();
} else {
#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));
#endif
#else
return PyString_FromStringAndSize(carray, static_cast< int >(size));
#endif
......
# 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
# the SWIG interface file instead.
......
# 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
# the SWIG interface file instead.
......
# 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
# the SWIG interface file instead.
......
# 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
# the SWIG interface file instead.
......
......@@ -40,7 +40,7 @@ using namespace UniversalIO;
using namespace UniSetTypes;
using namespace std;
// -----------------------------------------------------------------------------
UInterface::UInterface( const UniSetTypes::Configuration* _uconf ):
UInterface::UInterface( const std::shared_ptr<UniSetTypes::Configuration>& _uconf ):
rep(_uconf),
myid(UniSetTypes::DefaultObjectId),
orb(CORBA::ORB::_nil()),
......@@ -51,15 +51,15 @@ UInterface::UInterface( const UniSetTypes::Configuration* _uconf ):
init();
}
// -----------------------------------------------------------------------------
UInterface::UInterface( const ObjectId backid, CORBA::ORB_var orb, shared_ptr<ObjectIndex> _oind ):
rep(UniSetTypes::conf),
UInterface::UInterface( const ObjectId backid, CORBA::ORB_var orb, const shared_ptr<ObjectIndex> _oind ):
rep(UniSetTypes::uniset_conf()),
myid(backid),
orb(orb),
rcache(200,40),
oind(_oind),
uconf(UniSetTypes::conf)
uconf(UniSetTypes::uniset_conf())
{
if( oind == NULL )
if( oind == nullptr )
oind = uconf->oind;
init();
......@@ -1287,7 +1287,7 @@ IONotifyController_i::ThresholdInfo
{
IOController_i::SensorInfo si;
si.id = sid;
si.node = conf->getLocalNode();
si.node = uconf->getLocalNode();
return getThresholdInfo(si,tid);
}
// --------------------------------------------------------------------------------------------------------------
......@@ -1609,7 +1609,7 @@ IOController_i::SensorInfoSeq_var UInterface::getSensorSeq( const UniSetTypes::I
CORBA::Object_var oref;
try
{
oref = rcache.resolve(sid,conf->getLocalNode());
oref = rcache.resolve(sid,uconf->getLocalNode());
}
catch( NameNotFound ){}
......@@ -1618,7 +1618,7 @@ IOController_i::SensorInfoSeq_var UInterface::getSensorSeq( const UniSetTypes::I
try
{
if( CORBA::is_nil(oref) )
oref = resolve(sid,conf->getLocalNode());
oref = resolve(sid,uconf->getLocalNode());
IOController_i_var iom = IOController_i::_narrow(oref);
......@@ -1635,29 +1635,29 @@ IOController_i::SensorInfoSeq_var UInterface::getSensorSeq( const UniSetTypes::I
catch(UniSetTypes::TimeOut){}
catch(IOController_i::NameNotFound &ex)
{
rcache.erase(sid,conf->getLocalNode());
rcache.erase(sid,uconf->getLocalNode());
throw UniSetTypes::NameNotFound("UI(getSensorSeq): "+string(ex.err));
}
catch(IOController_i::IOBadParam& ex)
{
rcache.erase(sid,conf->getLocalNode());
rcache.erase(sid,uconf->getLocalNode());
throw UniSetTypes::IOBadParam("UI(getSensorSeq): "+string(ex.err));
}
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)
{
rcache.erase(sid,conf->getLocalNode());
throw UniSetTypes::IOBadParam(set_err("UI(getSensorSeq): method no implement",sid,conf->getLocalNode()));
rcache.erase(sid,uconf->getLocalNode());
throw UniSetTypes::IOBadParam(set_err("UI(getSensorSeq): method no implement",sid,uconf->getLocalNode()));
}
catch(CORBA::OBJECT_NOT_EXIST)
{
rcache.erase(sid,conf->getLocalNode());
throw UniSetTypes::IOBadParam(set_err("UI(getSensorSeq): object not exist",sid,conf->getLocalNode()));
rcache.erase(sid,uconf->getLocalNode());
throw UniSetTypes::IOBadParam(set_err("UI(getSensorSeq): object not exist",sid,uconf->getLocalNode()));
}
catch(CORBA::COMM_FAILURE& ex)
{
......@@ -1668,8 +1668,8 @@ IOController_i::SensorInfoSeq_var UInterface::getSensorSeq( const UniSetTypes::I
// ошибка системы коммуникации
// uwarn << "UI(getValue): CORBA::SystemException" << endl;
}
rcache.erase(sid,conf->getLocalNode());
throw UniSetTypes::TimeOut(set_err("UI(getSensorSeq): Timeout",sid,conf->getLocalNode()));
rcache.erase(sid,uconf->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
CORBA::Object_var oref;
try
{
oref = rcache.resolve(sid,conf->getLocalNode());
oref = rcache.resolve(sid,uconf->getLocalNode());
}
catch( NameNotFound ){}
......@@ -1779,7 +1779,7 @@ UniSetTypes::IDSeq_var UInterface::askSensorsSeq( const UniSetTypes::IDList& lst
try
{
if( CORBA::is_nil(oref) )
oref = resolve(sid,conf->getLocalNode());
oref = resolve(sid,uconf->getLocalNode());
IONotifyController_i_var iom = IONotifyController_i::_narrow(oref);
......@@ -1800,29 +1800,29 @@ UniSetTypes::IDSeq_var UInterface::askSensorsSeq( const UniSetTypes::IDList& lst
catch(UniSetTypes::TimeOut){}
catch(IOController_i::NameNotFound &ex)
{
rcache.erase(sid,conf->getLocalNode());
rcache.erase(sid,uconf->getLocalNode());
throw UniSetTypes::NameNotFound("UI(getSensorSeq): "+string(ex.err));
}
catch(IOController_i::IOBadParam& ex)
{
rcache.erase(sid,conf->getLocalNode());
rcache.erase(sid,uconf->getLocalNode());
throw UniSetTypes::IOBadParam("UI(getSensorSeq): "+string(ex.err));
}
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)
{
rcache.erase(sid,conf->getLocalNode());
throw UniSetTypes::IOBadParam(set_err("UI(askSensorSeq): method no implement",sid,conf->getLocalNode()));
rcache.erase(sid,uconf->getLocalNode());
throw UniSetTypes::IOBadParam(set_err("UI(askSensorSeq): method no implement",sid,uconf->getLocalNode()));
}
catch(CORBA::OBJECT_NOT_EXIST)
{
rcache.erase(sid,conf->getLocalNode());
throw UniSetTypes::IOBadParam(set_err("UI(askSensorSeq): object not exist",sid,conf->getLocalNode()));
rcache.erase(sid,uconf->getLocalNode());
throw UniSetTypes::IOBadParam(set_err("UI(askSensorSeq): object not exist",sid,uconf->getLocalNode()));
}
catch(CORBA::COMM_FAILURE& ex)
{
......@@ -1833,11 +1833,11 @@ UniSetTypes::IDSeq_var UInterface::askSensorsSeq( const UniSetTypes::IDList& lst
// ошибка системы коммуникации
// uwarn << "UI(getValue): CORBA::SystemException" << endl;
}
rcache.erase(sid,conf->getLocalNode());
throw UniSetTypes::TimeOut(set_err("UI(askSensorSeq): Timeout",sid,conf->getLocalNode()));
rcache.erase(sid,uconf->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 )
throw ORepFailed("UI(getSensors): error node=UniSetTypes::DefaultObjectId");
......@@ -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
{
if( !conf )
if( !uconf )
return UniversalIO::UnknownIOType;
xmlNode* x = conf->getXMLObjectNode(id);
xmlNode* x = uconf->getXMLObjectNode(id);
if( !x )
return UniversalIO::UnknownIOType;
......
......@@ -71,7 +71,7 @@ void IORFile::unlinkIOR( const ObjectId id ) const
string IORFile::genFName( const ObjectId id ) const
{
ostringstream fname;
fname << conf->getLockDir() << id;
fname << uniset_conf()->getLockDir() << id;
return std::move( fname.str() );
}
// -----------------------------------------------------------------------------------------
......@@ -87,6 +87,7 @@ std::ostream& operator<<(std::ostream& os, ObjectIndex_Array& oi )
std::ostream& ObjectIndex_Array::printMap( std::ostream& os )
{
auto oind = uniset_conf()->oind;
for( unsigned int i=0;;i++)
{
if( !objectInfo[i].repName )
......@@ -95,7 +96,7 @@ std::ostream& ObjectIndex_Array::printMap( std::ostream& os )
assert (i==objectInfo[i].id);
os << setw(5) << objectInfo[i].id << " "
<< setw(45) << conf->oind->getBaseName(objectInfo[i].repName)
<< setw(45) << oind->getBaseName(objectInfo[i].repName)
<< " " << objectInfo[i].textName << endl;
}
......
......@@ -36,7 +36,7 @@ using namespace UniSetTypes;
using namespace std;
// --------------------------------------------------------------------------
ObjectRepository::ObjectRepository( const Configuration* _conf ):
ObjectRepository::ObjectRepository( const std::shared_ptr<UniSetTypes::Configuration>& _conf ):
nsName(_conf->getNSName()),
uconf(_conf)
{
......
......@@ -35,7 +35,7 @@ using namespace UniSetTypes;
using namespace std;
using namespace omni;
// ---------------------------------------------------------------------------------------------------------------
ObjectRepositoryFactory::ObjectRepositoryFactory( Configuration* _conf ):
ObjectRepositoryFactory::ObjectRepositoryFactory( const std::shared_ptr<UniSetTypes::Configuration>& _conf ):
ObjectRepository(_conf)
{
}
......
......@@ -41,7 +41,7 @@ PassiveObject::PassiveObject( UniSetTypes::ObjectId id ):
mngr(0),
id(id)
{
string myfullname = conf->oind->getNameById(id);
string myfullname = uniset_conf()->oind->getNameById(id);
myname = ORepHelpers::getShortName(myfullname.c_str());
}
......@@ -49,7 +49,7 @@ PassiveObject::PassiveObject( ObjectId id, ProxyManager* mngr ):
mngr(mngr),
id(id)
{
string myfullname = conf->oind->getNameById(id);
string myfullname = uniset_conf()->oind->getNameById(id);
myname = ORepHelpers::getShortName(myfullname.c_str());
if( mngr )
......
......@@ -84,7 +84,7 @@ bool ProxyManager::activateObject()
uinfo << myname << "(registered): попытка "
<< i+1 << " регистриую (id=" << it.first << ") "
<< " (pname=" << it.second->getName() << ") "
<< conf->oind->getNameById(it.first) << endl;
<< uniset_conf()->oind->getNameById(it.first) << endl;
ui.registered(it.first, getRef(),true);
break;
......
......@@ -121,6 +121,7 @@ void UniSetActivator::init()
if( getId() == DefaultObjectId )
myname = "UniSetActivator";
auto conf = uniset_conf();
orb = conf->getORB();
CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
......
......@@ -516,7 +516,7 @@ int UniSetManager::getObjectsInfo( UniSetManager* mngr, SimpleInfoSeq* seq,
catch(...)
{
uwarn << myname << "(getObjectsInfo): не смог получить у объекта "
<< conf->oind->getNameById( (*it)->getId() ) << " информацию" << endl;
<< uniset_conf()->oind->getNameById( (*it)->getId() ) << " информацию" << endl;
}
}
......
......@@ -168,6 +168,8 @@ void UniSetObject::init_object()
refmutex.setName(myname + "_refmutex");
// mutex_act.setName(myname + "_mutex_act");
auto conf = uniset_conf();
SizeOfMessageQueue = conf->getArgPInt("--uniset-object-size-message-queue",conf->getField("SizeOfMessageQueue"), 1000);
MaxCountRemoveOfMessage = conf->getArgInt("--uniset-object-maxcount-remove-message",conf->getField("MaxCountRemoveOfMessage"));
if( MaxCountRemoveOfMessage <= 0 )
......@@ -705,7 +707,7 @@ bool UniSetObject::activate()
throw ORepFailed(err.c_str());
}
if( conf->isTransientIOR() )
if( uniset_conf()->isTransientIOR() )
{
// activate witch generate id
poa->activate_object(static_cast<PortableServer::ServantBase*>(this));
......
......@@ -104,7 +104,7 @@ long UniSetTypes::setoutregion(long ret, long calMin, long calMax)
// -------------------------------------------------------------------------
UniSetTypes::IDList::IDList():
node(UniSetTypes::conf->getLocalNode())
node(UniSetTypes::uniset_conf()->getLocalNode())
{
}
......@@ -232,8 +232,11 @@ bool UniSetTypes::is_digit( const std::string& s )
//return (std::count_if(s.begin(),s.end(),std::isdigit) == s.size()) ? true : false;
}
// --------------------------------------------------------------------------------------
std::list<UniSetTypes::ParamSInfo> UniSetTypes::getSInfoList( const string& str, Configuration* conf )
std::list<UniSetTypes::ParamSInfo> UniSetTypes::getSInfoList( const string& str, std::shared_ptr<Configuration> conf )
{
if( conf == nullptr )
conf = uniset_conf();
std::list<UniSetTypes::ParamSInfo> res;
auto lst = UniSetTypes::explode_str(str,',');
......
......@@ -49,7 +49,7 @@ IOController::IOController(const string& name, const string& section):
IOController::IOController(ObjectId id):
UniSetManager(id),
ioMutex(string(conf->oind->getMapName(id))+"_ioMutex"),
ioMutex(string(uniset_conf()->oind->getMapName(id))+"_ioMutex"),
isPingDBServer(true)
{
}
......@@ -145,7 +145,7 @@ long IOController::localGetValue( IOController::IOStateList::iterator& li, const
// -------------
ostringstream err;
err << myname << "(localGetValue): Not found sensor (" << sid << ") "
<< conf->oind->getNameById(sid);
<< uniset_conf()->oind->getNameById(sid);
uinfo << err.str() << endl;
throw IOController_i::NameNotFound(err.str().c_str());
......@@ -168,7 +168,7 @@ void IOController::localSetUndefinedState( IOStateList::iterator& li,
{
ostringstream err;
err << myname << "(localSetUndefined): Unknown sensor (" << sid << ")"
<< "name: " << conf->oind->getNameById(sid);
<< "name: " << uniset_conf()->oind->getNameById(sid);
throw IOController_i::NameNotFound(err.str().c_str());
}
......@@ -255,7 +255,7 @@ void IOController::localSetValue( IOController::IOStateList::iterator& li,
{
ostringstream err;
err << myname << "(localSaveValue): Unknown sensor (" << sid << ")"
<< "name: " << conf->oind->getNameById(sid);
<< "name: " << uniset_conf()->oind->getNameById(sid);
throw IOController_i::NameNotFound(err.str().c_str());
}
......@@ -271,7 +271,7 @@ void IOController::localSetValue( IOController::IOStateList::iterator& li,
if( checkIOFilters(li->second,value,sup_id) || blocked )
{
uinfo << myname << ": save sensor value (" << sid << ")"
<< " name: " << conf->oind->getNameById(sid)
<< " name: " << uniset_conf()->oind->getNameById(sid)
<< " value="<< value << endl;
long prev = li->second.value;
......@@ -328,7 +328,7 @@ IOType IOController::getIOType( UniSetTypes::ObjectId sid )
return ali->second.type;
ostringstream err;
err << myname << "(getIOType): датчик имя: " << conf->oind->getNameById(sid) << " не найден";
err << myname << "(getIOType): датчик имя: " << uniset_conf()->oind->getNameById(sid) << " не найден";
throw IOController_i::NameNotFound(err.str().c_str());
}
// ---------------------------------------------------------------------------
......@@ -352,7 +352,7 @@ void IOController::ioRegistration( USensorInfo&& ainf, bool force )
{
ostringstream err;
err << "Попытка повторной регистрации датчика("<< ainf.si.id << "). имя: "
<< conf->oind->getNameById(ainf.si.id);
<< uniset_conf()->oind->getNameById(ainf.si.id);
throw ObjectNameAlready(err.str().c_str());
}
}
......@@ -380,7 +380,7 @@ void IOController::ioRegistration( USensorInfo&& ainf, bool force )
{
uinfo << myname
<< "(ioRegistration): регистрирую "
<< conf->oind->getNameById(ainf.si.id) << endl;
<< uniset_conf()->oind->getNameById(ainf.si.id) << endl;
ui.registered( ainf.si.id, getRef(), true );
return;
......@@ -414,7 +414,7 @@ void IOController::logging( UniSetTypes::SensorMessage& sm )
{
// struct timezone tz;
// gettimeofday(&sm.tm,&tz);
ObjectId dbID = conf->getDBServer();
ObjectId dbID = uniset_conf()->getDBServer();
// значит на этом узле нет DBServer-а
if( dbID == UniSetTypes::DefaultObjectId )
return;
......@@ -437,7 +437,7 @@ void IOController::logging( UniSetTypes::SensorMessage& sm )
void IOController::dumpToDB()
{
// значит на этом узле нет DBServer-а
if( conf->getDBServer() == UniSetTypes::DefaultObjectId )
if( uniset_conf()->getDBServer() == UniSetTypes::DefaultObjectId )
return;
{ // lock
......@@ -500,7 +500,7 @@ IOController_i::SensorIOInfo IOController::getSensorIOInfo( const UniSetTypes::O
// -------------
ostringstream err;
err << myname << "(getSensorIOInfo): Unknown sensor (" << sid << ")"
<< conf->oind->getNameById(sid);
<< uniset_conf()->oind->getNameById(sid);
uinfo << err.str() << endl;
......@@ -514,7 +514,7 @@ CORBA::Long IOController::getRawValue( UniSetTypes::ObjectId sid )
{
ostringstream err;
err << myname << "(getRawValue): Unknown analog sensor (" << sid << ")"
<< conf->oind->getNameById(sid);
<< uniset_conf()->oind->getNameById(sid);
throw IOController_i::NameNotFound(err.str().c_str());
}
......@@ -542,11 +542,11 @@ void IOController::calibrate( UniSetTypes::ObjectId sid,
{
ostringstream err;
err << myname << "(calibrate): Unknown analog sensor (" << sid << ")"
<< conf->oind->getNameById(sid);
<< uniset_conf()->oind->getNameById(sid);
throw IOController_i::NameNotFound(err.str().c_str());
}
uinfo << myname <<"(calibrate): from " << conf->oind->getNameById(adminId) << endl;
uinfo << myname <<"(calibrate): from " << uniset_conf()->oind->getNameById(adminId) << endl;
it->second.ci = ci;
}
......@@ -558,7 +558,7 @@ IOController_i::CalibrateInfo IOController::getCalibrateInfo( UniSetTypes::Objec
{
ostringstream err;
err << myname << "(calibrate): Unknown analog sensor (" << sid << ")"
<< conf->oind->getNameById(sid);
<< uniset_conf()->oind->getNameById(sid);
throw IOController_i::NameNotFound(err.str().c_str());
}
return it->second.ci;
......@@ -717,7 +717,7 @@ IOController_i::ShortIOInfo IOController::getChangedTime( UniSetTypes::ObjectId
// -------------
ostringstream err;
err << myname << "(getChangedTime): вход(выход) с именем "
<< conf->oind->getNameById(sid) << " не найден";
<< uniset_conf()->oind->getNameById(sid) << " не найден";
uinfo << err.str() << endl;
throw IOController_i::NameNotFound(err.str().c_str());
......@@ -753,7 +753,7 @@ IOController::ChangeSignal IOController::signal_change_value( UniSetTypes::Objec
{
ostringstream err;
err << myname << "(signal_change_value): вход(выход) с именем "
<< conf->oind->getNameById(sid) << " не найден";
<< uniset_conf()->oind->getNameById(sid) << " не найден";
uinfo << err.str() << endl;
throw IOController_i::NameNotFound(err.str().c_str());
......@@ -775,7 +775,7 @@ IOController::ChangeUndefinedStateSignal IOController::signal_change_undefined_s
{
ostringstream err;
err << myname << "(signal_change_undefine): вход(выход) с именем "
<< conf->oind->getNameById(sid) << " не найден";
<< uniset_conf()->oind->getNameById(sid) << " не найден";
uinfo << err.str() << endl;
......
......@@ -42,7 +42,7 @@ IONotifyController::IONotifyController():
restorer(NULL),
askIOMutex("askIOMutex"),
trshMutex("trshMutex"),
maxAttemtps(conf->getPIntField("ConsumerMaxAttempts", 5))
maxAttemtps(uniset_conf()->getPIntField("ConsumerMaxAttempts", 5))
{
}
......@@ -52,7 +52,7 @@ IONotifyController::IONotifyController(const string& name, const string& section
restorer(d),
askIOMutex(name+"askIOMutex"),
trshMutex(name+"trshMutex"),
maxAttemtps(conf->getPIntField("ConsumerMaxAttempts", 5))
maxAttemtps(uniset_conf()->getPIntField("ConsumerMaxAttempts", 5))
{
// добавляем фильтры
addIOFilter( sigc::mem_fun(this,&IONotifyController::myIOFilter) );
......@@ -61,9 +61,9 @@ IONotifyController::IONotifyController(const string& name, const string& section
IONotifyController::IONotifyController( ObjectId id, NCRestorer* d ):
IOController(id),
restorer(d),
askIOMutex(string(conf->oind->getMapName(id))+"_askIOMutex"),
trshMutex(string(conf->oind->getMapName(id))+"_trshMutex"),
maxAttemtps(conf->getPIntField("ConsumerMaxAttempts", 5))
askIOMutex(string(uniset_conf()->oind->getMapName(id))+"_askIOMutex"),
trshMutex(string(uniset_conf()->oind->getMapName(id))+"_trshMutex"),
maxAttemtps(uniset_conf()->getPIntField("ConsumerMaxAttempts", 5))
{
signal_change_undefined_state().connect(sigc::mem_fun(*this, &IONotifyController::onChangeUndefinedState));
signal_init().connect(sigc::mem_fun(*this, &IONotifyController::initItem));
......@@ -133,9 +133,9 @@ void IONotifyController::askSensor(const UniSetTypes::ObjectId sid,
const UniSetTypes::ConsumerInfo& ci, UniversalIO::UIOCommand cmd )
{
uinfo << "(askSensor): поступил " << ( cmd == UIODontNotify ? "отказ" :"заказ" ) << " от "
<< conf->oind->getNameById(ci.id) << "@" << ci.node
<< uniset_conf()->oind->getNameById(ci.id) << "@" << ci.node
<< " на аналоговый датчик "
<< conf->oind->getNameById(sid) << endl;
<< uniset_conf()->oind->getNameById(sid) << endl;
// если такого аналогового датчика нет, здесь сработает исключение...
auto li = myioEnd();
......@@ -156,7 +156,7 @@ void IONotifyController::askSensor(const UniSetTypes::ObjectId sid,
{
SensorMessage smsg;
smsg.id = sid;
smsg.node = conf->getLocalNode();
smsg.node = uniset_conf()->getLocalNode();
smsg.consumer = ci.id;
smsg.supplier = getId();
smsg.sensor_type = li->second.type;
......@@ -178,17 +178,17 @@ void IONotifyController::askSensor(const UniSetTypes::ObjectId sid,
}
catch( Exception& ex )
{
uwarn << myname << "(askSensor): " << conf->oind->getNameById(sid) << " error: "<< ex << endl;
uwarn << myname << "(askSensor): " << uniset_conf()->oind->getNameById(sid) << " error: "<< ex << endl;
}
catch( CORBA::SystemException& ex )
{
uwarn << myname << "(askSensor): " << conf->oind->getNameById(ci.id) << "@" << ci.node
uwarn << myname << "(askSensor): " << uniset_conf()->oind->getNameById(ci.id) << "@" << ci.node
<< " недоступен!!(CORBA::SystemException): "
<< ex.NP_minorString() << endl;
}
catch(...)
{
uwarn << myname << "(askSensor): " << conf->oind->getNameById(ci.id) << "@" << ci.node
uwarn << myname << "(askSensor): " << uniset_conf()->oind->getNameById(ci.id) << "@" << ci.node
<< " catch..." << endl;
}
}
......@@ -317,7 +317,7 @@ void IONotifyController::localSetValue( IOController::IOStateList::iterator& li,
{
ostringstream err;
err << myname << "(localSetValue): вход(выход) с именем "
<< conf->oind->getNameById(sid) << " не найден";
<< uniset_conf()->oind->getNameById(sid) << " не найден";
uinfo << err.str() << endl;
throw IOController_i::NameNotFound(err.str().c_str());
......@@ -337,7 +337,7 @@ void IONotifyController::localSetValue( IOController::IOStateList::iterator& li,
// Рассылаем уведомления только в слуае изменения значения
sm.id = sid;
sm.node = conf->getLocalNode();
sm.node = uniset_conf()->getLocalNode();
sm.value = li->second.value;
sm.undefined = li->second.undefined;
sm.priority = (Message::Priority)li->second.priority;
......@@ -408,18 +408,18 @@ void IONotifyController::send( ConsumerListInfo& lst, UniSetTypes::SensorMessage
catch(Exception& ex)
{
uwarn << myname << "(IONotifyController::send): " << ex
<< " for " << conf->oind->getNameById(li->id) << "@" << li->node << endl;
<< " for " << uniset_conf()->oind->getNameById(li->id) << "@" << li->node << endl;
}
catch( CORBA::SystemException& ex )
{
uwarn << myname << "(IONotifyController::send): "
<< conf->oind->getNameById(li->id) << "@" << li->node << " (CORBA::SystemException): "
<< uniset_conf()->oind->getNameById(li->id) << "@" << li->node << " (CORBA::SystemException): "
<< ex.NP_minorString() << endl;
}
catch(...)
{
ucrit << myname << "(IONotifyController::send): "
<< conf->oind->getNameById(li->id) << "@" << li->node
<< uniset_conf()->oind->getNameById(li->id) << "@" << li->node
<< " catch..." << endl;
}
......@@ -545,7 +545,7 @@ void IONotifyController::askThreshold(UniSetTypes::ObjectId sid, const UniSetTyp
ThresholdExtList lst; // создаем новый список
ThresholdsListInfo tli;
tli.si.id = sid;
tli.si.node = conf->getLocalNode();
tli.si.node = uniset_conf()->getLocalNode();
tli.list = std::move(lst);
tli.type = li->second.type;
tli.ait = myioEnd();
......@@ -595,7 +595,7 @@ void IONotifyController::askThreshold(UniSetTypes::ObjectId sid, const UniSetTyp
{
SensorMessage sm;
sm.id = sid;
sm.node = conf->getLocalNode();
sm.node = uniset_conf()->getLocalNode();
sm.value = val;
sm.undefined = li->second.undefined;
sm.sensor_type = li->second.type;
......@@ -743,7 +743,7 @@ void IONotifyController::checkThreshold( IOStateList::iterator& li,
SensorMessage sm;
sm.id = sid;
sm.node = conf->getLocalNode();
sm.node = uniset_conf()->getLocalNode();
sm.sensor_type = li->second.type;
sm.priority = (Message::Priority)li->second.priority;
sm.ci = li->second.ci;
......@@ -853,7 +853,7 @@ IONotifyController_i::ThresholdInfo IONotifyController::getThresholdInfo( UniSet
{
ostringstream err;
err << myname << "(getThresholds): Not found sensor (" << sid << ") "
<< conf->oind->getNameById(sid);
<< uniset_conf()->oind->getNameById(sid);
uinfo << err.str() << endl;
throw IOController_i::NameNotFound(err.str().c_str());
......@@ -870,7 +870,7 @@ IONotifyController_i::ThresholdInfo IONotifyController::getThresholdInfo( UniSet
ostringstream err;
err << myname << "(getThresholds): Not found for sensor (" << sid << ") "
<< conf->oind->getNameById(sid) << " ThresholdID='" << tid << "'";
<< uniset_conf()->oind->getNameById(sid) << " ThresholdID='" << tid << "'";
uinfo << err.str() << endl;
throw IOController_i::NameNotFound(err.str().c_str());
......@@ -885,7 +885,7 @@ IONotifyController_i::ThresholdList* IONotifyController::getThresholds( UniSetTy
{
ostringstream err;
err << myname << "(getThresholds): Not found sensor (" << sid << ") "
<< conf->oind->getNameById(sid);
<< uniset_conf()->oind->getNameById(sid);
uinfo << err.str() << endl;
throw IOController_i::NameNotFound(err.str().c_str());
......@@ -902,7 +902,7 @@ IONotifyController_i::ThresholdList* IONotifyController::getThresholds( UniSetTy
catch( Exception& ex )
{
uwarn << myname << "(getThresholdsList): для датчика "
<< conf->oind->getNameById(it->second.si.id)
<< uniset_conf()->oind->getNameById(it->second.si.id)
<< " " << ex << endl;
}
......@@ -944,7 +944,7 @@ IONotifyController_i::ThresholdsListSeq* IONotifyController::getThresholdsList()
catch(Exception& ex)
{
uwarn << myname << "(getThresholdsList): для датчика "
<< conf->oind->getNameById(it->second.si.id)
<< uniset_conf()->oind->getNameById(it->second.si.id)
<< " " << ex << endl;
continue;
}
......
......@@ -64,7 +64,7 @@ void NCRestorer::addlist( IONotifyController* ic, SInfo&& inf, IONotifyControlle
default:
ucrit << ic->getName() << "(askDumper::addlist): НЕИЗВЕСТНЫЙ ТИП ДАТЧИКА! -> "
<< conf->oind->getNameById(inf.si.id) << endl;
<< uniset_conf()->oind->getNameById(inf.si.id) << endl;
return;
break;
......@@ -83,7 +83,7 @@ void NCRestorer::addlist( IONotifyController* ic, SInfo&& inf, IONotifyControlle
default:
ucrit << ic->getName() << "(NCRestorer::addlist): НЕИЗВЕСТНЫЙ ТИП ДАТЧИКА!-> "
<< conf->oind->getNameById(inf.si.id) << endl;
<< uniset_conf()->oind->getNameById(inf.si.id) << endl;
break;
}
}
......@@ -155,8 +155,8 @@ void NCRestorer::init_depends_signals( IONotifyController* ic )
continue;
uinfo << ic->getName() << "(NCRestorer::init_depends_signals): "
<< " init depend: '" << conf->oind->getMapName(it->second.si.id) << "'"
<< " dep_name=(" << it->second.d_si.id << ")'" << conf->oind->getMapName(it->second.d_si.id) << "'"
<< " init depend: '" << uniset_conf()->oind->getMapName(it->second.si.id) << "'"
<< " dep_name=(" << it->second.d_si.id << ")'" << uniset_conf()->oind->getMapName(it->second.d_si.id) << "'"
<< endl;
IOController::ChangeSignal s = ic->signal_change_value(it->second.d_si.id);
......
......@@ -85,8 +85,8 @@ void NCRestorer_XML::init( const std::string& fname )
*/
try
{
if( fname == conf->getConfFileName() )
uxml = conf->getConfXML();
if( fname == uniset_conf()->getConfFileName() )
uxml = uniset_conf()->getConfXML();
else
uxml = make_shared<UniXML>(fname);
}
......@@ -163,12 +163,12 @@ void NCRestorer_XML::read_list( const std::shared_ptr<UniXML>& xml, xmlNode* nod
// ------------------------------------------------------------------------------------------
void NCRestorer_XML::read( IONotifyController* ic, const string& fn )
{
const std::shared_ptr<UniXML> confxml = conf->getConfXML();
const std::shared_ptr<UniXML> confxml = uniset_conf()->getConfXML();
if( !fn.empty() )
{
// оптимизация (не загружаем второй раз xml-файл)
if( fn == conf->getConfFileName() && confxml )
if( fn == uniset_conf()->getConfFileName() && confxml )
read( ic, confxml );
else
{
......@@ -180,7 +180,7 @@ void NCRestorer_XML::read( IONotifyController* ic, const string& fn )
else if( !fname.empty() )
{
// оптимизация (не загружаем второй раз xml-файл)
if( fname == conf->getConfFileName() && confxml )
if( fname == uniset_conf()->getConfFileName() && confxml )
read( ic, confxml );
else if( uxml && uxml->isOpen() && uxml->filename == fn )
read(ic,uxml);
......@@ -197,8 +197,8 @@ void NCRestorer_XML::read( IONotifyController* ic, const std::shared_ptr<UniXML>
{
xmlNode* node;
if( xml == conf->getConfXML() )
node = conf->getXMLSensorsSection();
if( xml == uniset_conf()->getConfXML() )
node = uniset_conf()->getXMLSensorsSection();
else
node = xml->findNode( xml->getFirstNode(),"sensors");
......@@ -232,7 +232,7 @@ bool NCRestorer_XML::getBaseInfo( const std::shared_ptr<UniXML>& xml, xmlNode* i
if( !id.empty() )
sid = uni_atoi( id );
else
sid = conf->getSensorID(sname);
sid = uniset_conf()->getSensorID(sname);
if( sid == UniSetTypes::DefaultObjectId )
{
......@@ -240,10 +240,10 @@ bool NCRestorer_XML::getBaseInfo( const std::shared_ptr<UniXML>& xml, xmlNode* i
return false;
}
ObjectId snode = conf->getLocalNode();
ObjectId snode = uniset_conf()->getLocalNode();
string snodename(xml->getProp(it,"node"));
if( !snodename.empty() )
snode = conf->getNodeID(snodename);
snode = uniset_conf()->getNodeID(snodename);
if( snode == UniSetTypes::DefaultObjectId )
{
......@@ -309,7 +309,7 @@ bool NCRestorer_XML::getSensorInfo( const std::shared_ptr<UniXML>& xml, xmlNode*
string d_txt( xml->getProp(it, "depend") );
if( !d_txt.empty() )
{
inf.d_si.id = conf->getSensorID(d_txt);
inf.d_si.id = uniset_conf()->getSensorID(d_txt);
if( inf.d_si.id == UniSetTypes::DefaultObjectId )
{
ucrit << "(NCRestorer_XML:getSensorInfo): sensor='"
......@@ -319,7 +319,7 @@ bool NCRestorer_XML::getSensorInfo( const std::shared_ptr<UniXML>& xml, xmlNode*
return false;
}
inf.d_si.node = conf->getLocalNode();
inf.d_si.node = uniset_conf()->getLocalNode();
// по умолчанию срабатывание на "1"
inf.d_value = xml->getProp(it,"depend_value").empty() ? 1 : xml->getIntProp(it,"depend_value");
......@@ -363,7 +363,7 @@ void NCRestorer_XML::read_thresholds( const std::shared_ptr<UniXML>& xml, xmlNod
uwarn << ic->getName()
<< "(read_thresholds): не смог получить информацию о пороге"
<< " для датчика "
<< conf->oind->getNameById(inf.si.id) << endl;
<< uniset_conf()->oind->getNameById(inf.si.id) << endl;
continue;
}
......@@ -384,7 +384,7 @@ void NCRestorer_XML::read_thresholds( const std::shared_ptr<UniXML>& xml, xmlNod
uwarn << ic->getName()
<< "(read_thresholds): не смог получить список заказчиков"
<< " для порога " << ti.id
<< " датчика " << conf->oind->getNameById(inf.si.id) << endl;
<< " датчика " << uniset_conf()->oind->getNameById(inf.si.id) << endl;
}
}
}
......@@ -447,7 +447,7 @@ bool NCRestorer_XML::getThresholdInfo( const std::shared_ptr<UniXML>& xml,xmlNod
string sid_name = uit.getProp("sid");
if( !sid_name.empty() )
{
ti.sid = conf->getSensorID(sid_name);
ti.sid = uniset_conf()->getSensorID(sid_name);
if( ti.sid == UniSetTypes::DefaultObjectId )
{
ucrit << "(NCRestorer_XML:getThresholdInfo): "
......@@ -455,7 +455,7 @@ bool NCRestorer_XML::getThresholdInfo( const std::shared_ptr<UniXML>& xml,xmlNod
}
else
{
UniversalIO::IOType iotype = conf->getIOType(ti.sid);
UniversalIO::IOType iotype = uniset_conf()->getIOType(ti.sid);
// Пока что IONotifyController поддерживает работу только с 'DI'.
if( iotype != UniversalIO::DI )
{
......
......@@ -41,7 +41,7 @@ DBServer::DBServer(ObjectId id):
{
if( getId() == DefaultObjectId )
{
id = conf->getDBServer();
id = uniset_conf()->getDBServer();
if( id == DefaultObjectId )
{
ostringstream msg;
......@@ -53,11 +53,11 @@ DBServer::DBServer(ObjectId id):
}
DBServer::DBServer():
UniSetObject_LT(conf->getDBServer())
UniSetObject_LT(uniset_conf()->getDBServer())
{
if( getId() == DefaultObjectId )
{
ObjectId id = conf->getDBServer();
ObjectId id = uniset_conf()->getDBServer();
if( id == DefaultObjectId )
{
ostringstream msg;
......
......@@ -72,10 +72,22 @@ ostream& UniSetTypes::Configuration::help(ostream& os)
}
// -------------------------------------------------------------------------
namespace UniSetTypes
{
DebugStream ulog;
Configuration* conf = 0;
static shared_ptr<Configuration> uconf;
std::shared_ptr<Configuration> uniset_conf()
{
if( uconf == nullptr )
throw SystemError("Don`t init uniset configuration! First use uniset_init().");
return uconf; // см. uniset_init..
}
// -------------------------------------------------------------------------
Configuration::Configuration():
oind(NULL),
......@@ -982,19 +994,18 @@ UniversalIO::IOType Configuration::getIOType( const std::string& name )
return UniversalIO::UnknownIOType;
}
// -------------------------------------------------------------------------
void uniset_init( int argc, const char* const* argv, const std::string& xmlfile, bool force )
std::shared_ptr<Configuration> uniset_init( int argc, const char* const* argv, const std::string& xmlfile )
{
string confile = UniSetTypes::getArgParam( "--confile", argc, argv, xmlfile );
ulog.setLogName("ulog");
if( UniSetTypes::conf )
if( UniSetTypes::uconf )
{
if( !force && confile == UniSetTypes::conf->getConfFileName() )
return;
delete UniSetTypes::conf;
cerr << "Reusable call uniset_init... ignore.." << endl;
return UniSetTypes::uconf;
}
UniSetTypes::conf = new Configuration(argc, argv, confile);
string confile = UniSetTypes::getArgParam( "--confile", argc, argv, xmlfile );
ulog.setLogName("ulog");
UniSetTypes::uconf = make_shared<Configuration>(argc, argv, confile);
return UniSetTypes::uconf;
}
// -------------------------------------------------------------------------
} // end of UniSetTypes namespace
......@@ -35,7 +35,7 @@ namespace UniSetTypes
//--------------------------------------------------------------------------------------------
Message::Message():
type(Unused), priority(Medium),
node(UniSetTypes::conf->getLocalNode()),
node(UniSetTypes::uniset_conf()->getLocalNode()),
supplier(DefaultObjectId),
consumer(DefaultObjectId)
{
......
......@@ -72,11 +72,11 @@ bool Restorer_XML::getConsumerInfo( UniXML::iterator& it,
string otype(it.getProp("type"));
if( otype == "controllers" )
cname = conf->getControllersSection()+"/"+cname;
cname = uniset_conf()->getControllersSection()+"/"+cname;
else if( otype == "objects" )
cname = conf->getObjectsSection()+"/"+cname;
cname = uniset_conf()->getObjectsSection()+"/"+cname;
else if( otype == "services" )
cname = conf->getServicesSection()+"/"+cname;
cname = uniset_conf()->getServicesSection()+"/"+cname;
else
{
uwarn << "(Restorer_XML:getConsumerInfo): неизвестный тип объекта "
......@@ -84,7 +84,7 @@ bool Restorer_XML::getConsumerInfo( UniXML::iterator& it,
return false;
}
cid = conf->oind->getIdByName(cname);
cid = uniset_conf()->oind->getIdByName(cname);
if( cid == UniSetTypes::DefaultObjectId )
{
ucrit << "(Restorer_XML:getConsumerInfo): НЕ НАЙДЕН ИДЕНТИФИКАТОР заказчика -->"
......@@ -94,9 +94,9 @@ bool Restorer_XML::getConsumerInfo( UniXML::iterator& it,
string cnodename(it.getProp("node"));
if( !cnodename.empty() )
cnode = conf->oind->getIdByName(cnodename);
cnode = uniset_conf()->oind->getIdByName(cnodename);
else
cnode = conf->getLocalNode();
cnode = uniset_conf()->getLocalNode();
if( cnode == UniSetTypes::DefaultObjectId )
{
......
......@@ -20,14 +20,14 @@ SMonitor::SMonitor(ObjectId id):
UniSetObject_LT(id),
script("")
{
string sid(conf->getArgParam("--sid"));
string sid(uniset_conf()->getArgParam("--sid"));
lst = UniSetTypes::getSInfoList(sid,UniSetTypes::conf);
lst = UniSetTypes::getSInfoList(sid,uniset_conf());
if( lst.empty() )
throw SystemError("Не задан список датчиков (--sid)");
script = conf->getArgParam("--script");
script = uniset_conf()->getArgParam("--script");
}
......@@ -49,7 +49,7 @@ void SMonitor::sysCommand( const SystemMessage *sm )
for( auto &it: lst )
{
if( it.si.node == DefaultObjectId )
it.si.node = conf->getLocalNode();
it.si.node = uniset_conf()->getLocalNode();
try
{
......@@ -86,7 +86,7 @@ void SMonitor::sensorInfo( const SensorMessage* si )
{
cout << "(" << setw(6) << si->id << "): " << setw(8) << timeToString(si->sm_tv_sec,":")
<< "(" << setw(6) << si->sm_tv_usec << "): ";
cout << setw(45) << conf->oind->getMapName(si->id);
cout << setw(45) << uniset_conf()->oind->getMapName(si->id);
cout << "\tvalue=" << si->value << "\tfvalue=" << ( (float)si->value / pow(10.0,si->ci.precision) ) << endl;
if( !script.empty() )
......@@ -97,7 +97,7 @@ void SMonitor::sensorInfo( const SensorMessage* si )
if( script[0] == '.' || script[0] == '/' )
cmd << script;
else
cmd << conf->getBinDir() << script;
cmd << uniset_conf()->getBinDir() << script;
cmd << " " << si->id << " " << si->value << " " << si->sm_tv_sec << " " << si->sm_tv_usec;
......
......@@ -37,9 +37,9 @@ using namespace std;
// --------------------------------------------------------------------------
SViewer::SViewer(const string& csec, bool sn):
csec(csec),
rep(UniSetTypes::conf),
rep(UniSetTypes::uniset_conf()),
cache(500, 15),
ui(UniSetTypes::conf),
ui(UniSetTypes::uniset_conf()),
isShort(sn)
{
}
......@@ -140,7 +140,7 @@ void SViewer::readSection( const string& section, const string& secRoot )
{
string ob(*li);
string fname(curSection+ "/"+ ob);
ObjectId id = conf->oind->getIdByName( fname );
ObjectId id = uniset_conf()->oind->getIdByName( fname );
if( id == DefaultObjectId )
cout << "(readSection): ID?! для " << fname << endl;
else
......@@ -165,14 +165,14 @@ void SViewer::getInfo( ObjectId id )
{
try
{
oref = cache.resolve(id, conf->getLocalNode());
oref = cache.resolve(id, uniset_conf()->getLocalNode());
}
catch( NameNotFound ){}
if( CORBA::is_nil(oref) )
{
oref = ui.resolve(id);
cache.cache(id, conf->getLocalNode(), oref);
cache.cache(id, uniset_conf()->getLocalNode(), oref);
}
IONotifyController_i_var ioc = IONotifyController_i::_narrow(oref);
......@@ -204,13 +204,13 @@ void SViewer::getInfo( ObjectId id )
cout << "(getInfo): catch ..." << endl;
}
cache.erase(id, conf->getLocalNode());
cache.erase(id, uniset_conf()->getLocalNode());
}
// ---------------------------------------------------------------------------
void SViewer::updateSensors( IOController_i::SensorInfoSeq_var& amap, UniSetTypes::ObjectId oid )
{
string owner = ORepHelpers::getShortName(conf->oind->getMapName(oid));
string owner = ORepHelpers::getShortName(uniset_conf()->oind->getMapName(oid));
cout << "\n======================================================\n" << owner;
cout << "\t Датчики";
cout << "\n------------------------------------------------------"<< endl;
......@@ -219,10 +219,10 @@ void SViewer::updateSensors( IOController_i::SensorInfoSeq_var& amap, UniSetType
{
if( amap[i].type == UniversalIO::AI || amap[i].type == UniversalIO::DI )
{
string name(conf->oind->getNameById(amap[i].si.id));
string name(uniset_conf()->oind->getNameById(amap[i].si.id));
if( isShort )
name = ORepHelpers::getShortName(name);
string txtname( conf->oind->getTextName(amap[i].si.id) );
string txtname( uniset_conf()->oind->getTextName(amap[i].si.id) );
printInfo( amap[i].si.id, name, amap[i].value, owner, txtname, "AI");
}
}
......@@ -235,10 +235,10 @@ void SViewer::updateSensors( IOController_i::SensorInfoSeq_var& amap, UniSetType
{
if( amap[i].type == UniversalIO::AO || amap[i].type == UniversalIO::DO )
{
string name(conf->oind->getNameById(amap[i].si.id));
string name(uniset_conf()->oind->getNameById(amap[i].si.id));
if( isShort )
name = ORepHelpers::getShortName(name);
string txtname( conf->oind->getTextName(amap[i].si.id) );
string txtname( uniset_conf()->oind->getTextName(amap[i].si.id) );
printInfo( amap[i].si.id, name, amap[i].value, owner, txtname, "AO");
}
}
......@@ -249,7 +249,7 @@ void SViewer::updateSensors( IOController_i::SensorInfoSeq_var& amap, UniSetType
void SViewer::updateThresholds( IONotifyController_i::ThresholdsListSeq_var& tlst, UniSetTypes::ObjectId oid )
{
int size = tlst->length();
string owner = ORepHelpers::getShortName(conf->oind->getMapName(oid));
string owner = ORepHelpers::getShortName(uniset_conf()->oind->getMapName(oid));
cout << "\n======================================================\n" << owner;
cout << "\t Пороговые датчики";
cout << "\n------------------------------------------------------"<< endl;
......@@ -272,7 +272,7 @@ void SViewer::updateThresholds( IONotifyController_i::ThresholdsListSeq_var& tls
break;
}
string sname(conf->oind->getNameById(tlst[i].si.id));
string sname(uniset_conf()->oind->getNameById(tlst[i].si.id));
if( isShort )
sname = ORepHelpers::getShortName(sname);
......
......@@ -9,8 +9,10 @@ using namespace UniSetTypes;
// --------------------------------------------------------------------------
TEST_CASE( "Configuration", "[Configuration]" )
{
assert( conf != 0 );
assert( conf->oind != 0 );
auto conf = uniset_conf();
assert( conf != nullptr );
assert( conf->oind != nullptr );
// смотри tests_with_conf.xml
ObjectId testID = 1;
......
......@@ -9,7 +9,8 @@ using namespace UniSetTypes;
TEST_CASE("UInterface","[UInterface]")
{
CHECK( conf!=0 );
auto conf = uniset_conf();
CHECK( conf!=nullptr );
std::string sidName("Input1_S");
......@@ -22,7 +23,7 @@ TEST_CASE("UInterface","[UInterface]")
UInterface ui;
CHECK( ui.getObjectIndex() != nullptr );
CHECK( ui.getConf() == UniSetTypes::conf );
CHECK( ui.getConf() == conf );
CHECK( ui.getConfIOType(sid) != UniversalIO::UnknownIOType );
......
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