Commit 2b468646 authored by Pavel Vainerman's avatar Pavel Vainerman

(ModbusTCP): добавил больше параметров в выводе информации о состоянии связи

parent dd5e3175
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
Name: libuniset2 Name: libuniset2
Version: 2.1 Version: 2.1
Release: alt16 Release: alt16.1
Summary: UniSet - library for building distributed industrial control systems Summary: UniSet - library for building distributed industrial control systems
...@@ -456,6 +456,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname ...@@ -456,6 +456,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
# .. # ..
%changelog %changelog
* Thu Aug 20 2015 Pavel Vainerman <pv@altlinux.ru> 2.1-alt16.1
- (ModbusTCP): add more vmonit parameters
* Thu Aug 20 2015 Pavel Vainerman <pv@altlinux.ru> 2.1-alt16 * Thu Aug 20 2015 Pavel Vainerman <pv@altlinux.ru> 2.1-alt16
- (modbustcptest): add 'check' for connection - (modbustcptest): add 'check' for connection
......
...@@ -78,9 +78,9 @@ ...@@ -78,9 +78,9 @@
<item addr="0x01" invert="0" respondSensor="RespondRTU_S" timeout="5000" modeSensor="MB1_Mode_AS"/> <item addr="0x01" invert="0" respondSensor="RespondRTU_S" timeout="5000" modeSensor="MB1_Mode_AS"/>
</DeviceList> </DeviceList>
</MBMaster1> </MBMaster1>
<MBMultiMaster1 levels="info,warn,crit" name="MBMaster1" poll_time="200" reply_timeout="60"> <MBMultiMaster1 levels="info,warn,crit" name="MBMaster1" polltime="200">
<DeviceList> <DeviceList>
<item addr="0x01" invert="0" respondSensor="RespondRTU_S" timeout="5000" modeSensor="MB1_Mode_AS"/> <item addr="0x01" invert="0" force="0" respondSensor="RespondRTU_S" timeout="1000" modeSensor="MB1_Mode_AS"/>
</DeviceList> </DeviceList>
<GateList> <GateList>
<item ip="localhost" port="2048" recv_timeout="800" invert="1" respondSensor="MM1_Not_Respond_S"/> <item ip="localhost" port="2048" recv_timeout="800" invert="1" respondSensor="MM1_Not_Respond_S"/>
......
...@@ -3231,8 +3231,27 @@ UniSetTypes::SimpleInfo* MBExchange::getInfo() ...@@ -3231,8 +3231,27 @@ UniSetTypes::SimpleInfo* MBExchange::getInfo()
inf << i->info << endl; inf << i->info << endl;
inf << vmon.pretty_str() << endl; inf << vmon.pretty_str() << endl;
inf << "LogServer: " << logserv_host << ":" << logserv_port << endl; inf << "LogServer: " << logserv_host << ":" << logserv_port << endl;
inf << "Devices:" << endl;
for( const auto& it: rmap )
inf << " " << it.second->getShortInfo() << endl;
i->info = inf.str().c_str(); i->info = inf.str().c_str();
return i._retn(); return i._retn();
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
std::string MBExchange::RTUDevice::getShortInfo() const
{
ostringstream s;
s << "mbaddr=" << ModbusRTU::addr2str(mbaddr) << ":"
<< " resp_state=" << resp_state
<< " (resp_id=" << resp_id << " resp_force=" << resp_force
<< " resp_invert=" << resp_invert
<< " numreply=" << numreply
<< " timeout=" << resp_Delay.getOnDelay()
<< " type=" << dtype
<< ")" << endl;
return std::move( s.str() );
}
// ----------------------------------------------------------------------------
...@@ -164,7 +164,6 @@ class MBExchange: ...@@ -164,7 +164,6 @@ class MBExchange:
struct RTUDevice struct RTUDevice
{ {
RTUDevice(): RTUDevice():
respnond(false),
mbaddr(0), mbaddr(0),
dtype(dtUnknown), dtype(dtUnknown),
resp_id(UniSetTypes::DefaultObjectId), resp_id(UniSetTypes::DefaultObjectId),
...@@ -180,7 +179,6 @@ class MBExchange: ...@@ -180,7 +179,6 @@ class MBExchange:
{ {
} }
bool respnond;
ModbusRTU::ModbusAddr mbaddr; /*!< адрес устройства */ ModbusRTU::ModbusAddr mbaddr; /*!< адрес устройства */
RegMap regmap; RegMap regmap;
...@@ -211,6 +209,8 @@ class MBExchange: ...@@ -211,6 +209,8 @@ class MBExchange:
// специфические поля для RS // специфические поля для RS
ComPort::Speed speed; ComPort::Speed speed;
RTUStorage* rtu; RTUStorage* rtu;
std::string getShortInfo() const;
}; };
friend std::ostream& operator<<( std::ostream& os, RTUDevice& d ); friend std::ostream& operator<<( std::ostream& os, RTUDevice& d );
......
...@@ -497,7 +497,11 @@ std::shared_ptr<MBTCPMultiMaster> MBTCPMultiMaster::init_mbmaster( int argc, con ...@@ -497,7 +497,11 @@ std::shared_ptr<MBTCPMultiMaster> MBTCPMultiMaster::init_mbmaster( int argc, con
const std::string MBTCPMultiMaster::MBSlaveInfo::getShortInfo() const const std::string MBTCPMultiMaster::MBSlaveInfo::getShortInfo() const
{ {
ostringstream s; ostringstream s;
s << myname << " respond=" << respond; s << myname << " respond=" << respond
<< " (respond_id=" << respond_id << " respond_invert=" << respond_invert
<< " recv_timeout=" << recv_timeout
<< " use=" << use << " ignore=" << ignore << " priority=" << priority << ")";
return std::move(s.str()); return std::move(s.str());
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
......
...@@ -8,9 +8,9 @@ ...@@ -8,9 +8,9 @@
--mbtcp-set-prop-prefix \ --mbtcp-set-prop-prefix \
--mbtcp-filter-field rs \ --mbtcp-filter-field rs \
--mbtcp-filter-value 5 \ --mbtcp-filter-value 5 \
--mbtcp-recv-timeout 1000 \ --mbtcp-recv-timeout 7000 \
--mbtcp-timeout 2000 \ --mbtcp-timeout 2000 \
--mbtcp-polltime 1000 \ --mbtcp-polltime 5000 \
--mbtcp-force-out 1 \ --mbtcp-force-out 1 \
--mbtcp-log-add-levels any \ --mbtcp-log-add-levels any \
$* $*
......
...@@ -125,16 +125,16 @@ class DelayTimer ...@@ -125,16 +125,16 @@ class DelayTimer
return check(prevState); return check(prevState);
} }
inline timeout_t getOnDelay() inline timeout_t getOnDelay() const
{ {
return onDelay; return onDelay;
} }
inline timeout_t getOffDelay() inline timeout_t getOffDelay() const
{ {
return offDelay; return offDelay;
} }
inline timeout_t getCurrent() inline timeout_t getCurrent() const
{ {
return pt.getCurrent(); return pt.getCurrent();
} }
......
...@@ -46,8 +46,8 @@ class UniSetTimer ...@@ -46,8 +46,8 @@ class UniSetTimer
virtual timeout_t setTiming( timeout_t msec ) = 0; /*!< установить таймер и запустить */ virtual timeout_t setTiming( timeout_t msec ) = 0; /*!< установить таймер и запустить */
virtual void reset() = 0; /*!< перезапустить таймер */ virtual void reset() = 0; /*!< перезапустить таймер */
virtual timeout_t getCurrent() = 0; /*!< получить текущее значение таймера */ virtual timeout_t getCurrent() const = 0; /*!< получить текущее значение таймера */
virtual timeout_t getInterval() = 0; /*!< получить интервал, на который установлен таймер, в мс */ virtual timeout_t getInterval() const = 0; /*!< получить интервал, на который установлен таймер, в мс */
timeout_t getLeft(timeout_t timeout) /*!< получить время, которое остается от timeout после прошествия времени getCurrent() */ timeout_t getLeft(timeout_t timeout) /*!< получить время, которое остается от timeout после прошествия времени getCurrent() */
{ {
timeout_t ct = getCurrent(); timeout_t ct = getCurrent();
...@@ -104,8 +104,8 @@ class PassiveTimer: ...@@ -104,8 +104,8 @@ class PassiveTimer:
virtual timeout_t setTiming( timeout_t msec ); /*!< установить таймер и запустить. timeMS = 0 вызовет немедленное срабатывание */ virtual timeout_t setTiming( timeout_t msec ); /*!< установить таймер и запустить. timeMS = 0 вызовет немедленное срабатывание */
virtual void reset(); /*!< перезапустить таймер */ virtual void reset(); /*!< перезапустить таймер */
virtual timeout_t getCurrent(); /*!< получить текущее значение таймера, в мс */ virtual timeout_t getCurrent() const override; /*!< получить текущее значение таймера, в мс */
virtual timeout_t getInterval() /*!< получить интервал, на который установлен таймер, в мс */ virtual timeout_t getInterval() const override /*!< получить интервал, на который установлен таймер, в мс */
{ {
return (t_msec != UniSetTimer::WaitUpTime ? t_msec : 0); return (t_msec != UniSetTimer::WaitUpTime ? t_msec : 0);
} }
......
...@@ -72,7 +72,7 @@ void PassiveTimer::reset(void) ...@@ -72,7 +72,7 @@ void PassiveTimer::reset(void)
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// получить текущее значение таймера // получить текущее значение таймера
timeout_t PassiveTimer::getCurrent() timeout_t PassiveTimer::getCurrent() const
{ {
return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - t_start).count(); return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - t_start).count();
} }
......
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