Commit e6fabab1 authored by Pavel Vainerman's avatar Pavel Vainerman

Сделал более информативным вывод лога о неудачном опросе регистра

parent 208b2d17
...@@ -279,26 +279,31 @@ void MBTCPMaster::poll() ...@@ -279,26 +279,31 @@ void MBTCPMaster::poll()
dlog[Debug::INFO] << myname << "(poll): ask addr=" << ModbusRTU::addr2str(d->mbaddr) dlog[Debug::INFO] << myname << "(poll): ask addr=" << ModbusRTU::addr2str(d->mbaddr)
<< " regs=" << d->regmap.size() << endl; << " regs=" << d->regmap.size() << endl;
d->resp_real = true; d->resp_real = false;
for( MBTCPMaster::RegMap::iterator it=d->regmap.begin(); it!=d->regmap.end(); ++it ) for( MBTCPMaster::RegMap::iterator it=d->regmap.begin(); it!=d->regmap.end(); ++it )
{ {
try try
{ {
if( d->dtype==MBTCPMaster::dtRTU || d->dtype==MBTCPMaster::dtMTR ) if( d->dtype==MBTCPMaster::dtRTU || d->dtype==MBTCPMaster::dtMTR )
{ {
pollRTU(d,it); if( pollRTU(d,it) )
d->resp_real = true;
} }
} }
catch( ModbusRTU::mbException& ex ) catch( ModbusRTU::mbException& ex )
{ {
if( d->resp_real ) // if( d->resp_real )
// {
if( dlog.debugging(Debug::LEVEL3) )
{ {
dlog[Debug::CRIT] << myname << "(poll): FAILED ask addr=" << ModbusRTU::addr2str(d->mbaddr) dlog[Debug::LEVEL3] << myname << "(poll): FAILED ask addr=" << ModbusRTU::addr2str(d->mbaddr)
<< " reg=" << ModbusRTU::dat2str(it->second->mbreg) << " reg=" << ModbusRTU::dat2str(it->second->mbreg)
<< " -> " << ex << endl; << " for sensors: "; print_plist(dlog(Debug::LEVEL3),it->second->slst);
dlog(Debug::LEVEL3) << " err: " << ex << endl;
} }
// }
d->resp_real = false; // d->resp_real = false;
if( !d->ask_every_reg ) if( !d->ask_every_reg )
break; break;
} }
...@@ -2212,3 +2217,14 @@ void MBTCPMaster::execute() ...@@ -2212,3 +2217,14 @@ void MBTCPMaster::execute()
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
//std::ostream& operator<<( std::ostream& os, MBTCPMaster::PList& lst )
std::ostream& MBTCPMaster::print_plist( std::ostream& os, MBTCPMaster::PList& lst )
{
os << "[ ";
for( MBTCPMaster::PList::const_iterator it=lst.begin(); it!=lst.end(); ++it )
os << "(" << it->si.id << ")" << conf->oind->getBaseName(conf->oind->getMapName(it->si.id)) << " ";
os << "]";
return os;
}
// -----------------------------------------------------------------------------
\ No newline at end of file
...@@ -212,6 +212,7 @@ class MBTCPMaster: ...@@ -212,6 +212,7 @@ class MBTCPMaster:
friend std::ostream& operator<<( std::ostream& os, const RSProperty& p ); friend std::ostream& operator<<( std::ostream& os, const RSProperty& p );
typedef std::list<RSProperty> PList; typedef std::list<RSProperty> PList;
static std::ostream& print_plist( std::ostream& os, PList& p );
typedef std::map<ModbusRTU::ModbusData,RegInfo*> RegMap; typedef std::map<ModbusRTU::ModbusData,RegInfo*> RegMap;
struct RegInfo struct RegInfo
......
...@@ -4,7 +4,7 @@ uniset-start.sh -f ./uniset-mbtcpmaster \ ...@@ -4,7 +4,7 @@ uniset-start.sh -f ./uniset-mbtcpmaster \
--confile test.xml \ --confile test.xml \
--mbtcp-name MBMaster1 \ --mbtcp-name MBMaster1 \
--smemory-id SharedMemory \ --smemory-id SharedMemory \
--dlog-add-levels info,crit,warn,level4 \ --dlog-add-levels info,crit,warn,level4,level3 \
--mbtcp-filter-field mbtcp \ --mbtcp-filter-field mbtcp \
--mbtcp-filter-value 1 \ --mbtcp-filter-value 1 \
--mbtcp-gateway-iaddr 127.0.0.1 \ --mbtcp-gateway-iaddr 127.0.0.1 \
......
...@@ -305,8 +305,11 @@ void RTUExchange::poll() ...@@ -305,8 +305,11 @@ void RTUExchange::poll()
{ {
if( d->resp_real ) if( d->resp_real )
{ {
if( dlog.debugging(Debug::LEVEL3) )
{
dlog[Debug::CRIT] << myname << "(poll): FAILED ask addr=" << ModbusRTU::addr2str(d->mbaddr) dlog[Debug::CRIT] << myname << "(poll): FAILED ask addr=" << ModbusRTU::addr2str(d->mbaddr)
<< " -> " << ex << endl; << " -> " << ex << endl;
}
d->resp_real = false; d->resp_real = false;
} }
} }
...@@ -328,13 +331,17 @@ void RTUExchange::poll() ...@@ -328,13 +331,17 @@ void RTUExchange::poll()
} }
catch( ModbusRTU::mbException& ex ) catch( ModbusRTU::mbException& ex )
{ {
if( d->resp_real ) // if( d->resp_real )
// {
if( dlog.debugging(Debug::LEVEL3) )
{ {
dlog[Debug::CRIT] << myname << "(poll): FAILED ask addr=" << ModbusRTU::addr2str(d->mbaddr) dlog[Debug::LEVEL3] << myname << "(poll): FAILED ask addr=" << ModbusRTU::addr2str(d->mbaddr)
<< " reg=" << ModbusRTU::dat2str(it->second->mbreg) << " reg=" << ModbusRTU::dat2str(it->second->mbreg)
<< " -> " << ex << endl; << " for sensors: "; print_plist(dlog(Debug::LEVEL3), it->second->slst);
// d->resp_real = false; dlog(Debug::LEVEL3) << " err: " << ex << endl;
} }
// d->resp_real = false;
// }
} }
if( it==d->regmap.end() ) if( it==d->regmap.end() )
...@@ -2262,3 +2269,14 @@ void RTUExchange::updateRTU188( RegMap::iterator& it ) ...@@ -2262,3 +2269,14 @@ void RTUExchange::updateRTU188( RegMap::iterator& it )
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
//std::ostream& operator<<( std::ostream& os, MBTCPMaster::PList& lst )
std::ostream& RTUExchange::print_plist( std::ostream& os, RTUExchange::PList& lst )
{
os << "[ ";
for( RTUExchange::PList::const_iterator it=lst.begin(); it!=lst.end(); ++it )
os << "(" << it->si.id << ")" << conf->oind->getBaseName(conf->oind->getMapName(it->si.id)) << " ";
os << "]";
return os;
}
// -----------------------------------------------------------------------------
...@@ -77,6 +77,7 @@ class RTUExchange: ...@@ -77,6 +77,7 @@ class RTUExchange:
friend std::ostream& operator<<( std::ostream& os, const RSProperty& p ); friend std::ostream& operator<<( std::ostream& os, const RSProperty& p );
typedef std::list<RSProperty> PList; typedef std::list<RSProperty> PList;
static std::ostream& print_plist( std::ostream& os, PList& p );
typedef std::map<ModbusRTU::ModbusData,RegInfo*> RegMap; typedef std::map<ModbusRTU::ModbusData,RegInfo*> RegMap;
struct RegInfo struct RegInfo
......
...@@ -7,7 +7,7 @@ uniset-start.sh -f ./uniset-rtuexchange --confile test.xml \ ...@@ -7,7 +7,7 @@ uniset-start.sh -f ./uniset-rtuexchange --confile test.xml \
--rs-speed 38400 \ --rs-speed 38400 \
--rs-filter-field rs \ --rs-filter-field rs \
--rs-filter-value 1 \ --rs-filter-value 1 \
--dlog-add-levels info,crit,warn \ --dlog-add-levels info,crit,warn,level4,level3 \
--rs-force 0 \ --rs-force 0 \
--rs-force-out 0 \ --rs-force-out 0 \
#,level3 #,level3
......
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