Commit 1a422150 authored by Vitaly Lipatov's avatar Vitaly Lipatov

use uni_atoi string instead c_str() in each call

parent 202f2fe6
......@@ -1193,7 +1193,7 @@ int getValue(string args, UniversalInterface &ui )
// --------------------------------------------------------------------------------------
int getCalibrate(string arg, UniversalInterface &ui)
{
UniSetTypes::ObjectId sid(uni_atoi(arg.c_str()));
UniSetTypes::ObjectId sid(uni_atoi(arg));
if( sid<=0 )
{
cout << "(getCalibrate): SensorId !!!!!!"<< endl;
......@@ -1219,7 +1219,7 @@ int getCalibrate(string arg, UniversalInterface &ui)
// --------------------------------------------------------------------------------------
int getRawValue(string arg, UniversalInterface &ui )
{
UniSetTypes::ObjectId sid(uni_atoi(arg.c_str()));
UniSetTypes::ObjectId sid(uni_atoi(arg));
if( sid==0 )
{
cout << "(getRawValue): SensorId !!!!!!"<< endl;
......@@ -1296,7 +1296,7 @@ int configure(string arg, UniversalInterface &ui )
// --------------------------------------------------------------------------------------
int oinfo(string arg, UniversalInterface &ui )
{
UniSetTypes::ObjectId oid(uni_atoi(arg.c_str()));
UniSetTypes::ObjectId oid(uni_atoi(arg));
if( oid==0 )
{
cout << "(oinfo): OID!"<< endl;
......
......@@ -741,7 +741,7 @@ bool MBMaster::initItem( UniXML_iterator& it )
string f = it.getProp("mbfunc");
if( !f.empty() )
{
p.mbfunc = (ModbusRTU::SlaveFunctionCode)UniSetTypes::uni_atoi(f.c_str());
p.mbfunc = (ModbusRTU::SlaveFunctionCode)UniSetTypes::uni_atoi(f);
if( p.mbfunc == ModbusRTU::fnUnknown )
{
dlog[Debug::CRIT] << myname << "(initItem): mbfunc ='" << f
......@@ -765,7 +765,7 @@ bool MBMaster::initItem( UniXML_iterator& it )
return false;
}
p.nbit = UniSetTypes::uni_atoi(nb.c_str());
p.nbit = UniSetTypes::uni_atoi(nb);
}
if( dlog.debugging(Debug::INFO) )
......
......@@ -49,7 +49,7 @@ prefix(prefix)
dlog[Debug::INFO] << myname << "(init): read s_field='" << s_field
<< "' s_fvalue='" << s_fvalue << "'" << endl;
force = atoi(conf->getArgParam("--" + prefix + "-force",it.getProp("force")).c_str());
force = uni_atoi(conf->getArgParam("--" + prefix + "-force",it.getProp("force")));
int recv_timeout = atoi(conf->getArgParam("--" + prefix + "-recv-timeout",it.getProp("recv_timeout")).c_str());
......@@ -60,7 +60,7 @@ prefix(prefix)
else
addr = ModbusRTU::str2mbAddr(saddr);
mbregFromID = atoi(conf->getArgParam("--" + prefix + "-reg-from-id",it.getProp("reg_from_id")).c_str());
mbregFromID = uni_atoi(conf->getArgParam("--" + prefix + "-reg-from-id",it.getProp("reg_from_id")));
dlog[Debug::INFO] << myname << "(init): mbregFromID=" << mbregFromID << endl;
string stype = conf->getArgParam("--" + prefix + "-type",it.getProp("type"));
......@@ -702,6 +702,22 @@ bool MBSlave::initItem( UniXML_iterator& it )
else if( am == "rw" )
p.amode = MBSlave::amRW;
<<<<<<< HEAD:extensions/ModbusSlave/MBSlave.cc
=======
string f = it.getProp("mbfunc");
if( !f.empty() )
{
p.mbfunc = (ModbusRTU::SlaveFunctionCode)UniSetTypes::uni_atoi(f);
if( p.mbfunc == ModbusRTU::fnUnknown )
{
dlog[Debug::CRIT] << myname << "(initItem): mbfunc ='" << f
<< "' " << it.getProp("name") << endl;
return false;
}
}
>>>>>>> use uni_atoi string instead c_str() in each call:extensions/ModbusSlave/MBSlave.cc
iomap[p.mbreg] = p;
if( dlog.debugging(Debug::INFO) )
......
......@@ -1050,7 +1050,7 @@ bool RTUExchange::initRSProperty( RSProperty& p, UniXML_iterator& it )
string sbit(it.getProp("nbit"));
if( !sbit.empty() )
{
p.nbit = UniSetTypes::uni_atoi(sbit.c_str());
p.nbit = UniSetTypes::uni_atoi(sbit);
if( p.nbit < 0 || p.nbit >= ModbusRTU::BitsPerData )
{
dlog[Debug::CRIT] << myname << "(initRSProperty): BAD nbit=" << p.nbit
......@@ -1070,7 +1070,7 @@ bool RTUExchange::initRSProperty( RSProperty& p, UniXML_iterator& it )
string sbyte(it.getProp("nbyte"));
if( !sbyte.empty() )
{
p.nbyte = UniSetTypes::uni_atoi(sbyte.c_str());
p.nbyte = UniSetTypes::uni_atoi(sbyte);
if( p.nbyte < 0 || p.nbyte > VTypes::Byte::bsize )
{
dlog[Debug::CRIT] << myname << "(initRSProperty): BAD nbyte=" << p.nbyte
......@@ -1159,7 +1159,7 @@ bool RTUExchange::initRegInfo( RegInfo* r, UniXML_iterator& it, RTUExchange::RT
string f = it.getProp("mbfunc");
if( !f.empty() )
{
r->mbfunc = (ModbusRTU::SlaveFunctionCode)UniSetTypes::uni_atoi(f.c_str());
r->mbfunc = (ModbusRTU::SlaveFunctionCode)UniSetTypes::uni_atoi(f);
if( r->mbfunc == ModbusRTU::fnUnknown )
{
dlog[Debug::CRIT] << myname << "(initRegInfo): Unknown mbfunc ='" << f
......@@ -1378,7 +1378,7 @@ bool RTUExchange::initRTU188item( UniXML_iterator& it, RegInfo* p )
return false;
}
p->rtuChan = UniSetTypes::uni_atoi(chan.c_str());
p->rtuChan = UniSetTypes::uni_atoi(chan);
if( dlog.debugging(Debug::LEVEL2) )
dlog[Debug::LEVEL2] << myname << "(readRTU188Item): " << p << endl;
......
......@@ -567,7 +567,7 @@ bool UDPExchange::initItem( UniXML_iterator& it )
ObjectId sid;
if( !tid.empty() )
{
sid = UniSetTypes::uni_atoi(tid.c_str());
sid = UniSetTypes::uni_atoi(tid);
if( sid<=0 )
sid = DefaultObjectId;
}
......
......@@ -2231,7 +2231,7 @@ ModbusAddr ModbusRTU::str2mbAddr( const std::string val )
if( val.empty() )
return 0;
return (ModbusAddr)UniSetTypes::uni_atoi(val.c_str());
return (ModbusAddr)UniSetTypes::uni_atoi(val);
}
// -------------------------------------------------------------------------
ModbusData ModbusRTU::str2mbData( const std::string val )
......@@ -2239,7 +2239,7 @@ ModbusData ModbusRTU::str2mbData( const std::string val )
if( val.empty() )
return 0;
return (ModbusData)UniSetTypes::uni_atoi(val.c_str());
return (ModbusData)UniSetTypes::uni_atoi(val);
}
// -------------------------------------------------------------------------
std::string ModbusRTU::dat2str( const ModbusData dat )
......
......@@ -2248,7 +2248,7 @@ ModbusAddr ModbusRTU::str2mbAddr( const std::string val )
if( val.empty() )
return 0;
return (ModbusAddr)UniSetTypes::uni_atoi(val.c_str());
return (ModbusAddr)UniSetTypes::uni_atoi(val);
}
// -------------------------------------------------------------------------
ModbusData ModbusRTU::str2mbData( const std::string val )
......@@ -2256,7 +2256,7 @@ ModbusData ModbusRTU::str2mbData( const std::string val )
if( val.empty() )
return 0;
return (ModbusData)UniSetTypes::uni_atoi(val.c_str());
return (ModbusData)UniSetTypes::uni_atoi(val);
}
// -------------------------------------------------------------------------
std::string ModbusRTU::dat2str( const ModbusData dat )
......
......@@ -193,7 +193,7 @@ using namespace UniSetTypes;
string s(str.substr(prev,pos-prev));
if( !s.empty() )
{
l.add( uni_atoi(s.c_str()) );
l.add( uni_atoi(s) );
prev=pos+1;
}
}
......
......@@ -219,7 +219,7 @@ bool NCRestorer_XML::getBaseInfo( UniXML& xml, xmlNode* it, IOController_i::Sens
string id(xml.getProp(it,"id"));
if( !id.empty() )
sid = uni_atoi( id.c_str() );
sid = uni_atoi( id );
else
{
sname = conf->getSensorsSection()+"/"+sname;
......
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