Commit 6e876dea authored by Vitaly Lipatov's avatar Vitaly Lipatov

use appropriate getArg(P)Int, get(P)IntProp instead direct atoi using

parent 13ced4c3
...@@ -364,8 +364,8 @@ void DBServer_MySQL::init() ...@@ -364,8 +364,8 @@ void DBServer_MySQL::init()
tblMap[UniSetTypes::Message::Alarm] = "Messages"; tblMap[UniSetTypes::Message::Alarm] = "Messages";
tblMap[UniSetTypes::Message::SensorInfo] = "AnalogSensors"; tblMap[UniSetTypes::Message::SensorInfo] = "AnalogSensors";
PingTime = atoi( conf->getProp(node,"pingTime").c_str() ); PingTime = conf->getIntProp(node,"pingTime");
ReconnectTime = atoi( conf->getProp(node,"reconnectTime").c_str() ); ReconnectTime = conf->getIntProp(node,"reconnectTime");
if( dbnode.empty() ) if( dbnode.empty() )
dbnode = "localhost"; dbnode = "localhost";
......
...@@ -21,7 +21,7 @@ MBSlave::MBSlave( ModbusRTU::ModbusAddr addr, const std::string dev, const std:: ...@@ -21,7 +21,7 @@ MBSlave::MBSlave( ModbusRTU::ModbusAddr addr, const std::string dev, const std::
{ {
cout << "$Id: MBSlave.cc,v 1.7 2009/02/24 20:27:24 vpashka Exp $" << endl; cout << "$Id: MBSlave.cc,v 1.7 2009/02/24 20:27:24 vpashka Exp $" << endl;
// int replyTimeout = atoi( conf->getArgParam("--reply-timeout",it.getProp("reply_timeout")).c_str() ); // int replyTimeout = uni_atoi( conf->getArgParam("--reply-timeout",it.getProp("reply_timeout")).c_str() );
// if( replyTimeout <= 0 ) // if( replyTimeout <= 0 )
// replyTimeout = 2000; // replyTimeout = 2000;
......
...@@ -20,7 +20,7 @@ MBTCPServer::MBTCPServer( ModbusAddr myaddr, const string inetaddr, int port, bo ...@@ -20,7 +20,7 @@ MBTCPServer::MBTCPServer( ModbusAddr myaddr, const string inetaddr, int port, bo
{ {
cout << "$Id: MBTCPServer.cc,v 1.1 2008/11/22 23:22:23 vpashka Exp $" << endl; cout << "$Id: MBTCPServer.cc,v 1.1 2008/11/22 23:22:23 vpashka Exp $" << endl;
// int replyTimeout = atoi( conf->getArgParam("--reply-timeout",it.getProp("reply_timeout")).c_str() ); // int replyTimeout = uni_atoi( conf->getArgParam("--reply-timeout",it.getProp("reply_timeout")).c_str() );
// if( replyTimeout <= 0 ) // if( replyTimeout <= 0 )
// replyTimeout = 2000; // replyTimeout = 2000;
......
...@@ -512,13 +512,9 @@ activated(false) ...@@ -512,13 +512,9 @@ activated(false)
</xsl:if> </xsl:if>
</xsl:for-each> </xsl:for-each>
sleep_msec = conf->getArgInt("--sleep-msec","<xsl:call-template name="settings"><xsl:with-param name="varname" select="'sleep-msec'"/></xsl:call-template>"); sleep_msec = conf->getArgPInt("--sleep-msec","<xsl:call-template name="settings"><xsl:with-param name="varname" select="'sleep-msec'"/></xsl:call-template>", <xsl:call-template name="settings"><xsl:with-param name="varname" select="'sleep-msec'"/></xsl:call-template>);
if( sleep_msec &lt;=0 )
sleep_msec = <xsl:call-template name="settings"><xsl:with-param name="varname" select="'sleep-msec'"/></xsl:call-template>;
resetMsgTime = uni_atoi(conf->getProp(cnode,"resetMsgTime")); resetMsgTime = conf->getPIntProp(cnode,"resetMsgTime", 200);
if( resetMsgTime &lt;= 0 )
resetMsgTime = 200;
ptResetMsg.setTiming(resetMsgTime); ptResetMsg.setTiming(resetMsgTime);
smReadyTimeout = conf->getArgInt("--sm-ready-timeout","<xsl:call-template name="settings"><xsl:with-param name="varname" select="'smReadyTimeout'"/></xsl:call-template>"); smReadyTimeout = conf->getArgInt("--sm-ready-timeout","<xsl:call-template name="settings"><xsl:with-param name="varname" select="'smReadyTimeout'"/></xsl:call-template>");
...@@ -527,13 +523,9 @@ activated(false) ...@@ -527,13 +523,9 @@ activated(false)
else if( smReadyTimeout &lt; 0 ) else if( smReadyTimeout &lt; 0 )
smReadyTimeout = UniSetTimer::WaitUpTime; smReadyTimeout = UniSetTimer::WaitUpTime;
activateTimeout = conf->getArgInt("--activate-timeout"); activateTimeout = conf->getArgPInt("--activate-timeout", 20000);
if( activateTimeout&lt;=0 )
activateTimeout = 20000;
int msec = conf->getArgInt("--startup-timeout"); int msec = conf->getArgPInt("--startup-timeout", 10000);
if( msec&lt;=0 )
msec = 10000;
ptStartUpTimeout.setTiming(msec); ptStartUpTimeout.setTiming(msec);
} }
...@@ -709,13 +701,9 @@ activated(false) ...@@ -709,13 +701,9 @@ activated(false)
</xsl:call-template> </xsl:call-template>
</xsl:for-each> </xsl:for-each>
sleep_msec = conf->getArgInt("--sleep-msec","<xsl:call-template name="settings-alone"><xsl:with-param name="varname" select="'sleep-msec'"/></xsl:call-template>"); sleep_msec = conf->getArgPInt("--sleep-msec","<xsl:call-template name="settings-alone"><xsl:with-param name="varname" select="'sleep-msec'"/></xsl:call-template>", <xsl:call-template name="settings-alone"><xsl:with-param name="varname" select="'sleep-msec'"/></xsl:call-template>);
if( sleep_msec &lt;=0 )
sleep_msec = <xsl:call-template name="settings-alone"><xsl:with-param name="varname" select="'sleep-msec'"/></xsl:call-template>;
resetMsgTime = uni_atoi(conf->getProp(cnode,"resetMsgTime")); resetMsgTime = conf->getPIntProp(cnode,"resetMsgTime", 0);
if( resetMsgTime &lt;= 0 )
resetMsgTime = 0;
ptResetMsg.setTiming(resetMsgTime); ptResetMsg.setTiming(resetMsgTime);
smReadyTimeout = conf->getArgInt("--sm-ready-timeout","<xsl:call-template name="settings"><xsl:with-param name="varname" select="'smReadyTimeout'"/></xsl:call-template>"); smReadyTimeout = conf->getArgInt("--sm-ready-timeout","<xsl:call-template name="settings"><xsl:with-param name="varname" select="'smReadyTimeout'"/></xsl:call-template>");
...@@ -724,13 +712,9 @@ activated(false) ...@@ -724,13 +712,9 @@ activated(false)
else if( smReadyTimeout &lt; 0 ) else if( smReadyTimeout &lt; 0 )
smReadyTimeout = UniSetTimer::WaitUpTime; smReadyTimeout = UniSetTimer::WaitUpTime;
activateTimeout = conf->getArgInt("--activate-timeout"); activateTimeout = conf->getArgPInt("--activate-timeout", 20000);
if( activateTimeout&lt;=0 )
activateTimeout = 20000;
int msec = conf->getArgInt("--startup-timeout"); int msec = conf->getArgPInt("--startup-timeout", 10000);
if( msec&lt;=0 )
msec = 10000;
ptStartUpTimeout.setTiming(msec); ptStartUpTimeout.setTiming(msec);
} }
......
...@@ -53,7 +53,7 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID, ...@@ -53,7 +53,7 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID,
if( cnode == NULL ) if( cnode == NULL )
throw SystemError("Not find conf-node " + cname + " for " + myname); throw SystemError("Not find conf-node " + cname + " for " + myname);
defCardNum = atoi( conf->getArgParam("--io-default-cardnum","-1").c_str()); defCardNum = conf->getArgInt("--io-default-cardnum","-1");
unideb[Debug::INFO] << myname << "(init): numcards=" << numcards << endl; unideb[Debug::INFO] << myname << "(init): numcards=" << numcards << endl;
...@@ -120,9 +120,7 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID, ...@@ -120,9 +120,7 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID,
force = conf->getArgInt("--io-force",it.getProp("force")); force = conf->getArgInt("--io-force",it.getProp("force"));
force_out = conf->getArgInt("--io-force-out",it.getProp("force_out")); force_out = conf->getArgInt("--io-force-out",it.getProp("force_out"));
filtersize = conf->getArgInt("--io-filtersize",it.getProp("filtersize")); filtersize = conf->getArgPInt("--io-filtersize",it.getProp("filtersize"), 1);
if( filtersize <= 0 )
filtersize = 1;
filterT = atof(conf->getArgParam("--io-filterT",it.getProp("filterT")).c_str()); filterT = atof(conf->getArgParam("--io-filterT",it.getProp("filterT")).c_str());
...@@ -150,25 +148,16 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID, ...@@ -150,25 +148,16 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID,
unideb[Debug::INFO] << myname << "(init): read s_field='" << s_field unideb[Debug::INFO] << myname << "(init): read s_field='" << s_field
<< "' s_fvalue='" << s_fvalue << "'" << endl; << "' s_fvalue='" << s_fvalue << "'" << endl;
int blink_msec = conf->getArgInt("--io-blink-time",it.getProp("blink-time")); int blink_msec = conf->getArgPInt("--io-blink-time",it.getProp("blink-time"), 300);
if( blink_msec<=0 )
blink_msec = 300;
ptBlink.setTiming(blink_msec); ptBlink.setTiming(blink_msec);
int blink2_msec = conf->getArgInt("--io-blink2-time",it.getProp("blink2-time")); int blink2_msec = conf->getArgPInt("--io-blink2-time",it.getProp("blink2-time"), 150);
if( blink2_msec<=0 )
blink2_msec = 150;
ptBlink2.setTiming(blink2_msec); ptBlink2.setTiming(blink2_msec);
int blink3_msec = conf->getArgInt("--io-blink3-time",it.getProp("blink3-time")); int blink3_msec = conf->getArgPInt("--io-blink3-time",it.getProp("blink3-time"), 100);
if( blink3_msec<=0 )
blink3_msec = 100;
ptBlink3.setTiming(blink2_msec); ptBlink3.setTiming(blink2_msec);
smReadyTimeout = atoi(conf->getArgParam("--io-sm-ready-timeout",it.getProp("ready_timeout")).c_str()); smReadyTimeout = conf->getArgInt("--io-sm-ready-timeout",it.getProp("ready_timeout"));
if( smReadyTimeout == 0 ) if( smReadyTimeout == 0 )
smReadyTimeout = 15000; smReadyTimeout = 15000;
else if( smReadyTimeout < 0 ) else if( smReadyTimeout < 0 )
...@@ -207,14 +196,10 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID, ...@@ -207,14 +196,10 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID,
else else
ptHeartBeat.setTiming(UniSetTimer::WaitUpTime); ptHeartBeat.setTiming(UniSetTimer::WaitUpTime);
maxHeartBeat = conf->getArgInt("--io-heartbeat-max",it.getProp("heartbeat_max")); maxHeartBeat = conf->getArgPInt("--io-heartbeat-max",it.getProp("heartbeat_max"), 10);
if( maxHeartBeat <= 0 )
maxHeartBeat = 10;
} }
activateTimeout = conf->getArgInt("--activate-timeout"); activateTimeout = conf->getArgPInt("--activate-timeout", 25000);
if( activateTimeout <= 0 )
activateTimeout = 25000;
if( !shm->isLocalwork() ) // ic if( !shm->isLocalwork() ) // ic
ic->addReadItem( sigc::mem_fun(this,&IOControl::readItem) ); ic->addReadItem( sigc::mem_fun(this,&IOControl::readItem) );
...@@ -672,10 +657,7 @@ bool IOControl::initIOItem( UniXML_iterator& it ) ...@@ -672,10 +657,7 @@ bool IOControl::initIOItem( UniXML_iterator& it )
string c(it.getProp("card")); string c(it.getProp("card"));
if( c.empty() ) inf.ncard = uni_atoi( c );
inf.ncard = defCardNum;
else
inf.ncard = atoi( c.c_str() );
if( c.empty() || inf.ncard < 0 || inf.ncard >= (int)cards.size() ) if( c.empty() || inf.ncard < 0 || inf.ncard >= (int)cards.size() )
{ {
...@@ -686,7 +668,7 @@ bool IOControl::initIOItem( UniXML_iterator& it ) ...@@ -686,7 +668,7 @@ bool IOControl::initIOItem( UniXML_iterator& it )
inf.ncard = defCardNum; inf.ncard = defCardNum;
} }
inf.subdev = atoi( it.getProp("subdev").c_str()); inf.subdev = it.getIntProp("subdev");
if( inf.subdev < 0 ) if( inf.subdev < 0 )
inf.subdev = DefaultSubdev; inf.subdev = DefaultSubdev;
...@@ -708,8 +690,8 @@ bool IOControl::initIOItem( UniXML_iterator& it ) ...@@ -708,8 +690,8 @@ bool IOControl::initIOItem( UniXML_iterator& it )
inf.subdev = DefaultSubdev; inf.subdev = DefaultSubdev;
} }
inf.channel = atoi((it.getProp("channel")).c_str()); inf.channel = it.getIntProp("channel");
if( inf.channel<0 || inf.channel > 32 ) if( inf.channel < 0 || inf.channel > 32 )
{ {
unideb[Debug::WARN] << myname << "(readItem): : " << inf.channel unideb[Debug::WARN] << myname << "(readItem): : " << inf.channel
<< " " << it.getProp("name") << endl; << " " << it.getProp("name") << endl;
...@@ -719,14 +701,14 @@ bool IOControl::initIOItem( UniXML_iterator& it ) ...@@ -719,14 +701,14 @@ bool IOControl::initIOItem( UniXML_iterator& it )
if( !IOBase::initItem(&inf,it,shm,&unideb,myname,filtersize,filterT) ) if( !IOBase::initItem(&inf,it,shm,&unideb,myname,filtersize,filterT) )
return false; return false;
inf.lamp = atoi( it.getProp("lamp").c_str() ); inf.lamp = it.getIntProp("lamp");
inf.no_testlamp = atoi( it.getProp("no_iotestlamp").c_str() ); inf.no_testlamp = it.getIntProp("no_iotestlamp");
inf.aref = 0; inf.aref = 0;
inf.range = 0; inf.range = 0;
if( inf.stype == UniversalIO::AnalogInput || inf.stype == UniversalIO::AnalogOutput ) if( inf.stype == UniversalIO::AnalogInput || inf.stype == UniversalIO::AnalogOutput )
{ {
inf.range = atoi((it.getProp("range")).c_str()); inf.range = it.getIntProp("range");
if( inf.range < 0 || inf.range > 3 ) if( inf.range < 0 || inf.range > 3 )
{ {
unideb[Debug::WARN] << myname << "(readItem): (range): " << inf.range unideb[Debug::WARN] << myname << "(readItem): (range): " << inf.range
...@@ -735,7 +717,7 @@ bool IOControl::initIOItem( UniXML_iterator& it ) ...@@ -735,7 +717,7 @@ bool IOControl::initIOItem( UniXML_iterator& it )
return false; return false;
} }
inf.aref = atoi((it.getProp("aref")).c_str()); inf.aref = it.getIntProp("aref");
if( inf.aref < 0 || inf.aref > 3 ) if( inf.aref < 0 || inf.aref > 3 )
{ {
unideb[Debug::WARN] << myname << "(readItem): : " << inf.aref unideb[Debug::WARN] << myname << "(readItem): : " << inf.aref
...@@ -753,7 +735,8 @@ bool IOControl::initIOItem( UniXML_iterator& it ) ...@@ -753,7 +735,8 @@ bool IOControl::initIOItem( UniXML_iterator& it )
// //
if( maxItem >= iomap.size() ) if( maxItem >= iomap.size() )
iomap.resize(maxItem+10); iomap.resize(maxItem+10);
int prior = atoi((it.getProp("iopriority")).c_str());
int prior = it.getIntProp("iopriority");
if( prior > 0 ) if( prior > 0 )
{ {
IOPriority p(prior,maxItem); IOPriority p(prior,maxItem);
...@@ -1039,10 +1022,7 @@ IOControl* IOControl::init_iocontrol( int argc, const char* const* argv, ...@@ -1039,10 +1022,7 @@ IOControl* IOControl::init_iocontrol( int argc, const char* const* argv,
return 0; return 0;
} }
int numcards = atoi(conf->getArgParam("--io-numcards","1").c_str()); int numcards = conf->getArgPInt("--io-numcards",1);
if( numcards <= 0 )
numcards = 1;
unideb[Debug::INFO] << "(iocontrol): name = " << name << "(" << ID << ")" << endl; unideb[Debug::INFO] << "(iocontrol): name = " << name << "(" << ID << ")" << endl;
return new IOControl(ID,icID,ic,numcards); return new IOControl(ID,icID,ic,numcards);
......
...@@ -7,8 +7,7 @@ using namespace UniSetTypes; ...@@ -7,8 +7,7 @@ using namespace UniSetTypes;
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
LProcessor::LProcessor() LProcessor::LProcessor()
{ {
sleepTime = conf->getArgInt("--sleepTime"); sleepTime = conf->getArgPInt("--sleepTime", 200);
sleepTime = (sleepTime<=0) ? 200 : sleepTime;
} }
LProcessor::~LProcessor() LProcessor::~LProcessor()
......
...@@ -50,9 +50,7 @@ void SchemaXML::read( const string xmlfile ) ...@@ -50,9 +50,7 @@ void SchemaXML::read( const string xmlfile )
{ {
string type(xml.getProp(it, "type")); string type(xml.getProp(it, "type"));
string ID(xml.getProp(it, "id")); string ID(xml.getProp(it, "id"));
int inCount(atoi(xml.getProp(it, "inCount").c_str())); int inCount(xml.getPIntProp(it, "inCount", 1));
inCount = (inCount <= 0) ? 1 : inCount;
if( type == "OR" ) if( type == "OR" )
manage( new TOR(ID, inCount) ); manage( new TOR(ID, inCount) );
...@@ -60,12 +58,12 @@ void SchemaXML::read( const string xmlfile ) ...@@ -60,12 +58,12 @@ void SchemaXML::read( const string xmlfile )
manage( new TAND(ID, inCount) ); manage( new TAND(ID, inCount) );
else if( type == "Delay" ) else if( type == "Delay" )
{ {
int delayMS = atoi( xml.getProp(it,"delayMS").c_str() ); int delayMS = xml.getIntProp(it,"delayMS");
manage( new TDelay(ID,delayMS,inCount) ); manage( new TDelay(ID,delayMS,inCount) );
} }
else if( type == "NOT" ) else if( type == "NOT" )
{ {
bool defout = atoi( xml.getProp(it,"default_out_state").c_str() ); bool defout = xml.getIntProp(it,"default_out_state");
manage( new TNOT(ID,defout) ); manage( new TNOT(ID,defout) );
} }
else else
...@@ -98,7 +96,7 @@ void SchemaXML::read( const string xmlfile ) ...@@ -98,7 +96,7 @@ void SchemaXML::read( const string xmlfile )
string type(xml.getProp(it, "type")); string type(xml.getProp(it, "type"));
string fID(xml.getProp(it, "from")); string fID(xml.getProp(it, "from"));
string tID(xml.getProp(it, "to")); string tID(xml.getProp(it, "to"));
int toIn(atoi(xml.getProp(it, "toInput").c_str())); int toIn(xml.getIntProp(it, "toInput"));
if( type == "ext" ) if( type == "ext" )
{ {
......
...@@ -51,7 +51,7 @@ prefix(prefix) ...@@ -51,7 +51,7 @@ prefix(prefix)
force = conf->getArgInt("--" + prefix + "-force",it.getProp("force")); force = conf->getArgInt("--" + prefix + "-force",it.getProp("force"));
// int recv_timeout = atoi(conf->getArgParam("--" + prefix + "-recv-timeout",it.getProp("recv_timeout")).c_str()); // int recv_timeout = conf->getArgParam("--" + prefix + "-recv-timeout",it.getProp("recv_timeout")));
string saddr = conf->getArgParam("--" + prefix + "-my-addr",it.getProp("addr")); string saddr = conf->getArgParam("--" + prefix + "-my-addr",it.getProp("addr"));
...@@ -95,9 +95,7 @@ prefix(prefix) ...@@ -95,9 +95,7 @@ prefix(prefix)
if( iaddr.empty() ) if( iaddr.empty() )
throw UniSetTypes::SystemError(myname+"(MBSlave): Unknown TCP server address. Use: --mbs-inet-addr [ XXX.XXX.XXX.XXX| hostname ]"); throw UniSetTypes::SystemError(myname+"(MBSlave): Unknown TCP server address. Use: --mbs-inet-addr [ XXX.XXX.XXX.XXX| hostname ]");
int port = atoi(conf->getArgParam("--" + prefix + "-inet-port",it.getProp("iport")).c_str()); int port = conf->getArgPInt("--" + prefix + "-inet-port",it.getProp("iport"), 502);
if( port <=0 )
port = 502;
ost::InetAddress ia(iaddr.c_str()); ost::InetAddress ia(iaddr.c_str());
mbslot = new ModbusTCPServerSlot(ia,port); mbslot = new ModbusTCPServerSlot(ia,port);
...@@ -126,9 +124,7 @@ prefix(prefix) ...@@ -126,9 +124,7 @@ prefix(prefix)
// mbslot->connectRemoteService( sigc::mem_fun(this, &MBSlave::remoteService) ); // mbslot->connectRemoteService( sigc::mem_fun(this, &MBSlave::remoteService) );
// ------------------------------- // -------------------------------
initPause = atoi(conf->getArgParam("--" + prefix + "-initPause",it.getProp("initPause")).c_str()); initPause = conf->getArgPInt("--" + prefix + "-initPause",it.getProp("initPause"), 3000);
if( !initPause )
initPause = 3000;
if( shm->isLocalwork() ) if( shm->isLocalwork() )
{ {
...@@ -157,10 +153,7 @@ prefix(prefix) ...@@ -157,10 +153,7 @@ prefix(prefix)
else else
ptHeartBeat.setTiming(UniSetTimer::WaitUpTime); ptHeartBeat.setTiming(UniSetTimer::WaitUpTime);
maxHeartBeat = conf->getArgInt("--" + prefix + "-heartbeat-max",it.getProp("heartbeat_max")); maxHeartBeat = conf->getArgPInt("--" + prefix + "-heartbeat-max",it.getProp("heartbeat_max"), 10);
if( maxHeartBeat <= 0 )
maxHeartBeat = 10;
test_id = sidHeartBeat; test_id = sidHeartBeat;
} }
else else
...@@ -184,14 +177,9 @@ prefix(prefix) ...@@ -184,14 +177,9 @@ prefix(prefix)
if( wait_msec < 500 ) if( wait_msec < 500 )
wait_msec = 500; wait_msec = 500;
activateTimeout = conf->getArgInt("--" + prefix + "-activate-timeout"); activateTimeout = conf->getArgPInt("--" + prefix + "-activate-timeout", 20000);
if( activateTimeout <= 0 )
activateTimeout = 20000;
timeout_t msec = conf->getArgInt("--" + prefix + "-timeout",it.getProp("timeout"));
if( msec == 0 )
msec = 3000;
timeout_t msec = conf->getArgPInt("--" + prefix + "-timeout",it.getProp("timeout"), 3000);
ptTimeout.setTiming(msec); ptTimeout.setTiming(msec);
dlog[Debug::INFO] << myname << "(init): rs-timeout=" << msec << " msec" << endl; dlog[Debug::INFO] << myname << "(init): rs-timeout=" << msec << " msec" << endl;
...@@ -212,8 +200,8 @@ prefix(prefix) ...@@ -212,8 +200,8 @@ prefix(prefix)
dlog[Debug::WARN] << myname << "(build file list): ignore empty name... " << endl; dlog[Debug::WARN] << myname << "(build file list): ignore empty name... " << endl;
continue; continue;
} }
int id = atoi(fit.getProp("id").c_str()); int id = fit.getIntProp("id");
if( id==0 ) if( id == 0 )
{ {
dlog[Debug::WARN] << myname << "(build file list): FAILED ID for " << nm << "... ignore..." << endl; dlog[Debug::WARN] << myname << "(build file list): FAILED ID for " << nm << "... ignore..." << endl;
continue; continue;
......
...@@ -57,13 +57,9 @@ allNotRespond(false) ...@@ -57,13 +57,9 @@ allNotRespond(false)
use485F = conf->getArgInt("--rs-use485F",it.getProp("use485F")); use485F = conf->getArgInt("--rs-use485F",it.getProp("use485F"));
defSpeed = ComPort::getSpeed(speed); defSpeed = ComPort::getSpeed(speed);
recv_timeout = conf->getArgInt("--rs-recv-timeout",it.getProp("recv_timeout")); recv_timeout = conf->getArgPInt("--rs-recv-timeout",it.getProp("recv_timeout"), 50);
if( recv_timeout <= 0 )
recv_timeout = 50;
int alltout = conf->getArgInt("--rs-all-timeout",it.getProp("all_timeout")); int alltout = conf->getArgPInt("--rs-all-timeout",it.getProp("all_timeout"), 2000);
if( alltout <= 0 )
alltout = 2000;
ptAllNotRespond.setTiming(alltout); ptAllNotRespond.setTiming(alltout);
...@@ -73,13 +69,9 @@ allNotRespond(false) ...@@ -73,13 +69,9 @@ allNotRespond(false)
mbregFromID = conf->getArgInt("--mbs-reg-from-id",it.getProp("reg_from_id")); mbregFromID = conf->getArgInt("--mbs-reg-from-id",it.getProp("reg_from_id"));
dlog[Debug::INFO] << myname << "(init): mbregFromID=" << mbregFromID << endl; dlog[Debug::INFO] << myname << "(init): mbregFromID=" << mbregFromID << endl;
polltime = conf->getArgInt("--rs-polltime",it.getProp("polltime")); polltime = conf->getArgPInt("--rs-polltime",it.getProp("polltime"), 100);
if( !polltime )
polltime = 100;
initPause = conf->getArgInt("--rs-initPause",it.getProp("initPause")); initPause = conf->getArgPInt("--rs-initPause",it.getProp("initPause"), 3000);
if( !initPause )
initPause = 3000;
force = conf->getArgInt("--rs-force",it.getProp("force")); force = conf->getArgInt("--rs-force",it.getProp("force"));
force_out = conf->getArgInt("--rs-force-out",it.getProp("force_out")); force_out = conf->getArgInt("--rs-force-out",it.getProp("force_out"));
...@@ -112,9 +104,7 @@ allNotRespond(false) ...@@ -112,9 +104,7 @@ allNotRespond(false)
else else
ptHeartBeat.setTiming(UniSetTimer::WaitUpTime); ptHeartBeat.setTiming(UniSetTimer::WaitUpTime);
maxHeartBeat = conf->getArgInt("--rs-heartbeat-max",it.getProp("heartbeat_max")); maxHeartBeat = conf->getArgPInt("--rs-heartbeat-max",it.getProp("heartbeat_max"), 10);
if( maxHeartBeat <= 0 )
maxHeartBeat = 10;
test_id = sidHeartBeat; test_id = sidHeartBeat;
} }
else else
...@@ -131,9 +121,7 @@ allNotRespond(false) ...@@ -131,9 +121,7 @@ allNotRespond(false)
dlog[Debug::INFO] << myname << "(init): test_id=" << test_id << endl; dlog[Debug::INFO] << myname << "(init): test_id=" << test_id << endl;
activateTimeout = conf->getArgInt("--activate-timeout"); activateTimeout = conf->getArgPInt("--activate-timeout", 20000);
if( activateTimeout <= 0 )
activateTimeout = 20000;
initMB(false); initMB(false);
...@@ -1534,13 +1522,9 @@ bool RTUExchange::initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniX ...@@ -1534,13 +1522,9 @@ bool RTUExchange::initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniX
} }
dlog[Debug::INFO] << myname << "(initDeviceInfo): add addr=" << ModbusRTU::addr2str(a) << endl; dlog[Debug::INFO] << myname << "(initDeviceInfo): add addr=" << ModbusRTU::addr2str(a) << endl;
int tout = atoi(it.getProp("timeout").c_str()); int tout = it.getPIntProp("timeout", UniSetTimer::WaitUpTime);
if( tout > 0 )
d->second->resp_ptTimeout.setTiming(tout); d->second->resp_ptTimeout.setTiming(tout);
else d->second->resp_invert = it.getIntProp("invert");
d->second->resp_ptTimeout.setTiming(UniSetTimer::WaitUpTime);
d->second->resp_invert = atoi(it.getProp("invert").c_str());
string s = it.getProp("speed"); string s = it.getProp("speed");
if( !s.empty() ) if( !s.empty() )
......
...@@ -62,8 +62,8 @@ namespace UniSetExtensions ...@@ -62,8 +62,8 @@ namespace UniSetExtensions
UniXML_iterator it(cnode); UniXML_iterator it(cnode);
heartBeatTime = atoi(it.getProp("time_msec").c_str()); heartBeatTime = it.getIntProp("time_msec");
if( heartBeatTime <=0 ) if( heartBeatTime <= 0 )
{ {
heartBeatTime = 0; heartBeatTime = 0;
dlog[Debug::WARN] << "(getHeartBeatTime): 'HEARTBEAT' !" << endl; dlog[Debug::WARN] << "(getHeartBeatTime): 'HEARTBEAT' !" << endl;
......
...@@ -414,34 +414,24 @@ bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm, ...@@ -414,34 +414,24 @@ bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm,
b->si.id = sid; b->si.id = sid;
b->si.node = conf->getLocalNode(); b->si.node = conf->getLocalNode();
b->nofilter = atoi( it.getProp("nofilter").c_str() ); b->nofilter = it.getIntProp("nofilter");
b->ignore = atoi( it.getProp("ioignore").c_str() ); b->ignore = it.getIntProp("ioignore");
b->invert = atoi( it.getProp("ioinvert").c_str() ); b->invert = it.getIntProp("ioinvert");
b->defval = atoi( it.getProp("default").c_str() ); b->defval = it.getIntProp("default");
b->noprecision = atoi( it.getProp("noprecision").c_str() ); b->noprecision = it.getIntProp("noprecision");
b->value = b->defval; b->value = b->defval;
b->breaklim = atoi( it.getProp("breaklim").c_str() ); b->breaklim = it.getIntProp("breaklim");
long msec = atoi( it.getProp("jardelay").c_str() ); long msec = it.getPIntProp("jardelay", UniSetTimer::WaitUpTime);
b->ptJar.setTiming(msec); b->ptJar.setTiming(msec);
if( msec<=0 )
b->ptJar.setTiming(UniSetTimer::WaitUpTime);
msec = atoi( it.getProp("ondelay").c_str() ); msec = it.getPIntProp("ondelay", UniSetTimer::WaitUpTime);
b->ptOnDelay.setTiming(msec); b->ptOnDelay.setTiming(msec);
if( msec<=0 )
b->ptOnDelay.setTiming(UniSetTimer::WaitUpTime);
msec = atoi( it.getProp("offdelay").c_str() ); msec = it.getPIntProp("offdelay", UniSetTimer::WaitUpTime);
b->ptOffDelay.setTiming(msec); b->ptOffDelay.setTiming(msec);
if( msec<=0 )
b->ptOffDelay.setTiming(UniSetTimer::WaitUpTime);
string saf = it.getProp("safety"); b->safety = it.getPIntProp("safety", NoSafety);
if( !saf.empty() )
b->safety = atoi(saf.c_str());
else
b->safety = NoSafety;
b->stype = UniSetTypes::getIOType(it.getProp("iotype")); b->stype = UniSetTypes::getIOType(it.getProp("iotype"));
if( b->stype == UniversalIO::UnknownIOType ) if( b->stype == UniversalIO::UnknownIOType )
...@@ -466,16 +456,16 @@ bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm, ...@@ -466,16 +456,16 @@ bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm,
if( b->stype == UniversalIO::AnalogInput || b->stype == UniversalIO::AnalogOutput ) if( b->stype == UniversalIO::AnalogInput || b->stype == UniversalIO::AnalogOutput )
{ {
b->cal.minRaw = atoi( it.getProp("rmin").c_str() ); b->cal.minRaw = it.getIntProp("rmin");
b->cal.maxRaw = atoi( it.getProp("rmax").c_str() ); b->cal.maxRaw = it.getIntProp("rmax");
b->cal.minCal = atoi( it.getProp("cmin").c_str() ); b->cal.minCal = it.getIntProp("cmin");
b->cal.maxCal = atoi( it.getProp("cmax").c_str() ); b->cal.maxCal = it.getIntProp("cmax");
b->cal.sensibility = atoi( it.getProp("sensibility").c_str() ); b->cal.sensibility = it.getIntProp("sensibility");
b->cal.precision = atoi( it.getProp("precision").c_str() ); b->cal.precision = it.getIntProp("precision");
int f_size = def_filtersize; int f_size = def_filtersize;
float f_T = def_filterT; float f_T = def_filterT;
int f_median = atoi( it.getProp("filtermedian").c_str() ); int f_median = it.getIntProp("filtermedian");
if( f_median > 0 ) if( f_median > 0 )
{ {
...@@ -486,9 +476,8 @@ bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm, ...@@ -486,9 +476,8 @@ bool IOBase::initItem( IOBase* b, UniXML_iterator& it, SMInterface* shm,
{ {
if( !it.getProp("filtersize").empty() ) if( !it.getProp("filtersize").empty() )
{ {
f_size = atoi(it.getProp("filtersize").c_str()); #warning " 0, f_size def_filtersize?"
if( f_size < 0 ) f_size = it.getPIntProp("filtersize", 0);
f_size = 0;
} }
} }
......
...@@ -38,13 +38,9 @@ activated(false) ...@@ -38,13 +38,9 @@ activated(false)
{ {
si.node = conf->getLocalNode(); si.node = conf->getLocalNode();
sleep_msec = conf->getArgInt("--sleep-msec","200"); sleep_msec = conf->getArgPInt("--sleep-msec", 200);
if( sleep_msec <= 0 )
sleep_msec = 200;
resetMsgTime = conf->getIntProp(cnode,"resetMsgTime"); resetMsgTime = conf->getPIntProp(cnode,"resetMsgTime", 200);
if( resetMsgTime <= 0 )
resetMsgTime = 200;
ptResetMsg.setTiming(resetMsgTime); ptResetMsg.setTiming(resetMsgTime);
smReadyTimeout = conf->getArgInt("--sm-ready-timeout",""); smReadyTimeout = conf->getArgInt("--sm-ready-timeout","");
...@@ -53,13 +49,9 @@ activated(false) ...@@ -53,13 +49,9 @@ activated(false)
else if( smReadyTimeout < 0 ) else if( smReadyTimeout < 0 )
smReadyTimeout = UniSetTimer::WaitUpTime; smReadyTimeout = UniSetTimer::WaitUpTime;
activateTimeout = conf->getArgInt("--activate-timeout")); activateTimeout = conf->getArgPInt("--activate-timeout", 20000);
if( activateTimeout <= 0 )
activateTimeout = 20000;
timeout_t msec = conf->getArgInt("--startup-timeout"); timeout_t msec = conf->getArgPInt("--startup-timeout", 10000);
if( msec == 0 )
msec = 10000;
ptStartUpTimeout.setTiming(msec); ptStartUpTimeout.setTiming(msec);
} }
......
...@@ -66,22 +66,16 @@ stCountOfQueueFull(0) ...@@ -66,22 +66,16 @@ stCountOfQueueFull(0)
myname = "noname"; myname = "noname";
section = "nonameSection"; section = "nonameSection";
SizeOfMessageQueue = atoi(conf->getField("SizeOfMessageQueue").c_str()); SizeOfMessageQueue = conf->getPIntField("SizeOfMessageQueue", 1000);
if( SizeOfMessageQueue <= 0 )
SizeOfMessageQueue = 1000;
MaxCountRemoveOfMessage = atoi(conf->getField("MaxCountRemoveOfMessage").c_str()); MaxCountRemoveOfMessage = conf->getIntField("MaxCountRemoveOfMessage");
if( MaxCountRemoveOfMessage <= 0 ) if( MaxCountRemoveOfMessage <= 0 )
MaxCountRemoveOfMessage = SizeOfMessageQueue / 4; MaxCountRemoveOfMessage = SizeOfMessageQueue / 4;
if( MaxCountRemoveOfMessage <= 0 ) if( MaxCountRemoveOfMessage <= 0 )
MaxCountRemoveOfMessage = 10; MaxCountRemoveOfMessage = 10;
recvMutexTimeout = atoi(conf->getField("RecvMutexTimeout").c_str()); recvMutexTimeout = conf->getPIntField("RecvMutexTimeout", 10000);
if( recvMutexTimeout <= 0 )
recvMutexTimeout = 10000;
pushMutexTimeout = atoi(conf->getField("PushMutexTimeout").c_str()); pushMutexTimeout = conf->getPIntField("PushMutexTimeout", 9000);
if( pushMutexTimeout <= 0 )
pushMutexTimeout = 9000;
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
UniSetObject::UniSetObject( ObjectId id ): UniSetObject::UniSetObject( ObjectId id ):
...@@ -100,11 +94,9 @@ MaxCountRemoveOfMessage(10), ...@@ -100,11 +94,9 @@ MaxCountRemoveOfMessage(10),
stMaxQueueMessages(0), stMaxQueueMessages(0),
stCountOfQueueFull(0) stCountOfQueueFull(0)
{ {
SizeOfMessageQueue = atoi(conf->getField("SizeOfMessageQueue").c_str()); SizeOfMessageQueue = conf->getPIntField("SizeOfMessageQueue", 1000);
if( SizeOfMessageQueue <= 0 )
SizeOfMessageQueue = 1000;
MaxCountRemoveOfMessage = atoi(conf->getField("MaxCountRemoveOfMessage").c_str()); MaxCountRemoveOfMessage = conf->getIntField("MaxCountRemoveOfMessage");
if( MaxCountRemoveOfMessage <= 0 ) if( MaxCountRemoveOfMessage <= 0 )
MaxCountRemoveOfMessage = SizeOfMessageQueue / 4; MaxCountRemoveOfMessage = SizeOfMessageQueue / 4;
if( MaxCountRemoveOfMessage <= 0 ) if( MaxCountRemoveOfMessage <= 0 )
...@@ -124,13 +116,8 @@ stCountOfQueueFull(0) ...@@ -124,13 +116,8 @@ stCountOfQueueFull(0)
myname = "noname"; myname = "noname";
section = "nonameSection"; section = "nonameSection";
} }
recvMutexTimeout = atoi(conf->getField("RecvMutexTimeout").c_str()); recvMutexTimeout = conf->getPIntField("RecvMutexTimeout", 10000);
if( recvMutexTimeout <= 0 ) pushMutexTimeout = conf->getPIntField("PushMutexTimeout", 9000);
recvMutexTimeout = 10000;
pushMutexTimeout = atoi(conf->getField("PushMutexTimeout").c_str());
if( pushMutexTimeout <= 0 )
pushMutexTimeout = 9000;
} }
...@@ -160,23 +147,16 @@ stCountOfQueueFull(0) ...@@ -160,23 +147,16 @@ stCountOfQueueFull(0)
unideb[Debug::WARN] << "name: ObjectsMap!!!" << endl; unideb[Debug::WARN] << "name: ObjectsMap!!!" << endl;
throw Exception(name+": ObjectsMap!!!"); throw Exception(name+": ObjectsMap!!!");
} }
SizeOfMessageQueue = atoi(conf->getField("SizeOfMessageQueue").c_str()); SizeOfMessageQueue = conf->getPIntField("SizeOfMessageQueue", 1000);
if( SizeOfMessageQueue <= 0 )
SizeOfMessageQueue = 1000;
MaxCountRemoveOfMessage = atoi(conf->getField("MaxCountRemoveOfMessage").c_str()); MaxCountRemoveOfMessage = conf->getIntField("MaxCountRemoveOfMessage");
if( MaxCountRemoveOfMessage <= 0 ) if( MaxCountRemoveOfMessage <= 0 )
MaxCountRemoveOfMessage = SizeOfMessageQueue / 4; MaxCountRemoveOfMessage = SizeOfMessageQueue / 4;
if( MaxCountRemoveOfMessage <= 0 ) if( MaxCountRemoveOfMessage <= 0 )
MaxCountRemoveOfMessage = 10; MaxCountRemoveOfMessage = 10;
recvMutexTimeout = atoi(conf->getField("RecvMutexTimeout").c_str()); recvMutexTimeout = conf->getPIntField("RecvMutexTimeout", 10000);
if( recvMutexTimeout <= 0 ) pushMutexTimeout = conf->getPIntField("PushMutexTimeout", 9000);
recvMutexTimeout = 10000;
pushMutexTimeout = atoi(conf->getField("PushMutexTimeout").c_str());
if( pushMutexTimeout <= 0 )
pushMutexTimeout = 9000;
ui.initBackId(myid); ui.initBackId(myid);
} }
......
...@@ -61,7 +61,7 @@ InfoServer::InfoServer( ObjectId id, ISRestorer* d ): ...@@ -61,7 +61,7 @@ InfoServer::InfoServer( ObjectId id, ISRestorer* d ):
xmlNode* root = xml->findNode(xml->getFirstNode(),"LocalInfoServer"); xmlNode* root = xml->findNode(xml->getFirstNode(),"LocalInfoServer");
if( root ) if( root )
{ {
dbrepeat = atoi(xml->getProp(root,"dbrepeat").c_str()); dbrepeat = xml->getIntProp(root,"dbrepeat");
if( !dbrepeat ) if( !dbrepeat )
unideb[Debug::INFO] << myname << "(init): dbrepeat="<< dbrepeat << endl; unideb[Debug::INFO] << myname << "(init): dbrepeat="<< dbrepeat << endl;
......
...@@ -357,8 +357,8 @@ void TimerService::init(const string& confnode) ...@@ -357,8 +357,8 @@ void TimerService::init(const string& confnode)
return; return;
} }
MaxCountTimers = atoi(conf->getProp(node,"MaxCountTimers").c_str()); MaxCountTimers = conf->getIntProp(node,"MaxCountTimers");
AskLifeTimeSEC = atoi(conf->getProp(node,"AskLifeTimeSEC").c_str()); AskLifeTimeSEC = conf->getIntProp(node,"AskLifeTimeSEC");
assert( TimerService::MaxCountTimers > 0 ); assert( TimerService::MaxCountTimers > 0 );
assert( TimerService::AskLifeTimeSEC >= 0 ); assert( TimerService::AskLifeTimeSEC >= 0 );
......
...@@ -605,8 +605,8 @@ void NCRestorer_XML::build_depends( UniXML& xml, xmlNode* node, IONotifyControll ...@@ -605,8 +605,8 @@ void NCRestorer_XML::build_depends( UniXML& xml, xmlNode* node, IONotifyControll
continue; continue;
} }
mydepinfo.block_invert = atoi( dit.getProp("block_invert").c_str());; mydepinfo.block_invert = dit.getIntProp("block_invert");
long block_val = atoi( dit.getProp("block_value").c_str());; long block_val = dit.getIntProp("block_value");
long defval = 0; long defval = 0;
if( blk.dit != dioEnd(ic) ) if( blk.dit != dioEnd(ic) )
......
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