Commit db987174 authored by Pavel Vainerman's avatar Pavel Vainerman

(Modbus): повторно исправил ошибку в конфигурировании для RTU188

parent 69973cd4
...@@ -279,6 +279,9 @@ MBExchange::DeviceType MBExchange::getDeviceType( const std::string dtype ) ...@@ -279,6 +279,9 @@ MBExchange::DeviceType MBExchange::getDeviceType( const std::string dtype )
if( dtype == "rtu" || dtype == "RTU" ) if( dtype == "rtu" || dtype == "RTU" )
return dtRTU; return dtRTU;
if( dtype == "rtu188" || dtype == "RTU188" )
return dtRTU188;
return dtUnknown; return dtUnknown;
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
...@@ -1840,6 +1843,12 @@ bool MBExchange::initRegInfo( RegInfo* r, UniXML_iterator& it, MBExchange::RTUD ...@@ -1840,6 +1843,12 @@ bool MBExchange::initRegInfo( RegInfo* r, UniXML_iterator& it, MBExchange::RTUD
if( !initMTRitem(it,r) ) if( !initMTRitem(it,r) )
return false; return false;
} }
else if( dev->dtype == MBExchange::dtRTU188 )
{
// only for RTU188
if( !initRTU188item(it,r) )
return false;
}
else else
{ {
dlog[Debug::CRIT] << myname << "(initRegInfo): Unknown mbtype='" << dev->dtype dlog[Debug::CRIT] << myname << "(initRegInfo): Unknown mbtype='" << dev->dtype
...@@ -2116,11 +2125,11 @@ bool MBExchange::initItem( UniXML_iterator& it ) ...@@ -2116,11 +2125,11 @@ bool MBExchange::initItem( UniXML_iterator& it )
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
bool MBExchange::initMTRitem( UniXML_iterator& it, RegInfo* p ) bool MBExchange::initMTRitem( UniXML_iterator& it, RegInfo* p )
{ {
p->mtrType = MTR::str2type(it.getProp("mtrtype")); p->mtrType = MTR::str2type(it.getProp(prop_prefix + "mtrtype"));
if( p->mtrType == MTR::mtUnknown ) if( p->mtrType == MTR::mtUnknown )
{ {
dlog[Debug::CRIT] << myname << "(readMTRItem): Unknown mtrtype '" dlog[Debug::CRIT] << myname << "(readMTRItem): Unknown mtrtype '"
<< it.getProp("mtrtype") << it.getProp(prop_prefix + "mtrtype")
<< "' for " << it.getProp("name") << endl; << "' for " << it.getProp("name") << endl;
return false; return false;
...@@ -2129,6 +2138,40 @@ bool MBExchange::initMTRitem( UniXML_iterator& it, RegInfo* p ) ...@@ -2129,6 +2138,40 @@ bool MBExchange::initMTRitem( UniXML_iterator& it, RegInfo* p )
return true; return true;
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
bool MBExchange::initRTU188item( UniXML_iterator& it, RegInfo* p )
{
string jack(it.getProp(prop_prefix + "jack"));
string chan(it.getProp(prop_prefix + "channel"));
if( jack.empty() )
{
dlog[Debug::CRIT] << myname << "(readRTU188Item): Unknown jack='' "
<< " for " << it.getProp("name") << endl;
return false;
}
p->rtuJack = RTUStorage::s2j(jack);
if( p->rtuJack == RTUStorage::nUnknown )
{
dlog[Debug::CRIT] << myname << "(readRTU188Item): Unknown jack=" << jack
<< " for " << it.getProp("name") << endl;
return false;
}
if( chan.empty() )
{
dlog[Debug::CRIT] << myname << "(readRTU188Item): Unknown channel='' "
<< " for " << it.getProp("name") << endl;
return false;
}
p->rtuChan = UniSetTypes::uni_atoi(chan);
if( dlog.debugging(Debug::LEVEL2) )
dlog[Debug::LEVEL2] << myname << "(readRTU188Item): " << p << endl;
return true;
}
// ------------------------------------------------------------------------------------------
std::ostream& operator<<( std::ostream& os, const MBExchange::DeviceType& dt ) std::ostream& operator<<( std::ostream& os, const MBExchange::DeviceType& dt )
{ {
switch(dt) switch(dt)
......
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