Commit 00b4d0ee authored by Pavel Vainerman's avatar Pavel Vainerman

(Modbus): продолжаю выносить код в базовый класс

parent 61f2cc3e
......@@ -181,6 +181,7 @@ AC_CONFIG_FILES([Makefile
extensions/IOControl/libUniSetIOControl.pc
extensions/RTUExchange/Makefile
extensions/RTUExchange/libUniSetRTU.pc
extensions/ModbusMaster/Makefile
extensions/ModbusSlave/Makefile
extensions/ModbusSlave/libUniSetMBSlave.pc
extensions/MBTCPMaster/Makefile
......
......@@ -8,16 +8,18 @@ libUniSetMBTCPMaster_la_LDFLAGS = -version-info $(UMBTCP_VER)
libUniSetMBTCPMaster_la_LIBADD = $(top_builddir)/lib/libUniSet.la \
$(top_builddir)/extensions/SharedMemory/libUniSetSharedMemory.la \
$(top_builddir)/extensions/lib/libUniSetExtensions.la \
$(top_builddir)/extensions/ModbusMaster/libMBMaster.la \
$(SIGC_LIBS)
libUniSetMBTCPMaster_la_CXXFLAGS = -I$(top_builddir)/extensions/include -I$(top_builddir)/extensions/SharedMemory $(SIGC_CFLAGS)
libUniSetMBTCPMaster_la_CXXFLAGS = -I$(top_builddir)/extensions/include -I$(top_builddir)/extensions/SharedMemory -I$(top_builddir)/extensions/ModbusMaster $(SIGC_CFLAGS)
libUniSetMBTCPMaster_la_SOURCES = MBTCPMaster.cc
@PACKAGE@_mbtcpmaster_SOURCES = main.cc
@PACKAGE@_mbtcpmaster_LDADD = libUniSetMBTCPMaster.la $(top_builddir)/lib/libUniSet.la \
$(top_builddir)/extensions/SharedMemory/libUniSetSharedMemory.la \
$(top_builddir)/extensions/lib/libUniSetExtensions.la \
$(top_builddir)/extensions/ModbusMaster/libMBMaster.la \
$(SIGC_LIBS)
@PACKAGE@_mbtcpmaster_CXXFLAGS = -I$(top_builddir)/extensions/include -I$(top_builddir)/extensions/SharedMemory $(SIGC_CFLAGS)
@PACKAGE@_mbtcpmaster_CXXFLAGS = -I$(top_builddir)/extensions/include -I$(top_builddir)/extensions/SharedMemory -I$(top_builddir)/extensions/ModbusMaster $(SIGC_CFLAGS)
# install
devel_include_HEADERS = *.h
......
#!/bin/sh
./uniset-start.sh -g ./uniset-mbtcpmaster \
./uniset-start.sh -f ./uniset-mbtcpmaster \
--confile test.xml \
--mbtcp-name MBMaster1 \
--smemory-id SharedMemory \
......
......@@ -3,7 +3,7 @@
############################################################################
if HAVE_EXTENTIONS
SUBDIRS = lib include SharedMemory IOControl RTUExchange LogicProcessor \
SUBDIRS = lib include ModbusMaster SharedMemory IOControl RTUExchange LogicProcessor \
ModbusSlave MBTCPMaster SMViewer UniNetwork UNet2 DBServer-MySQL tests
#SMDBServer
#SharedMemoryPlus
......
......@@ -1547,6 +1547,69 @@ void MBExchange::updateMTR( RegMap::iterator& rit )
}
}
// -----------------------------------------------------------------------------
void MBExchange::updateRTU188( RegMap::iterator& it )
{
RegInfo* r(it->second);
if( !r->dev->rtu )
return;
using namespace ModbusRTU;
// bool save = false;
if( isWriteFunction(r->mbfunc) )
{
// save = true;
cerr << myname << "(updateRTU188): write reg(" << dat2str(r->mbreg) << ") to RTU188 NOT YET!!!" << endl;
return;
}
for( PList::iterator it=r->slst.begin(); it!=r->slst.end(); ++it )
{
try
{
if( it->stype == UniversalIO::DigitalInput )
{
bool set = r->dev->rtu->getState(r->rtuJack,r->rtuChan,it->stype);
IOBase::processingAsDI( &(*it), set, shm, force );
continue;
}
if( it->stype == UniversalIO::AnalogInput )
{
long val = r->dev->rtu->getInt(r->rtuJack,r->rtuChan,it->stype);
IOBase::processingAsAI( &(*it),val, shm, force );
continue;
}
}
catch(IOController_i::NameNotFound &ex)
{
dlog[Debug::LEVEL3] << myname << "(updateRTU188):(NameNotFound) " << ex.err << endl;
}
catch(IOController_i::IOBadParam& ex )
{
dlog[Debug::LEVEL3] << myname << "(updateRTU188):(IOBadParam) " << ex.err << endl;
}
catch(IONotifyController_i::BadRange )
{
dlog[Debug::LEVEL3] << myname << "(updateRTU188): (BadRange)..." << endl;
}
catch( Exception& ex )
{
dlog[Debug::LEVEL3] << myname << "(updateRTU188): " << ex << endl;
}
catch(CORBA::SystemException& ex)
{
dlog[Debug::LEVEL3] << myname << "(updateRTU188): CORBA::SystemException: "
<< ex.NP_minorString() << endl;
}
catch(...)
{
dlog[Debug::LEVEL3] << myname << "(updateRTU188): catch ..." << endl;
}
}
}
// -----------------------------------------------------------------------------
MBExchange::RTUDevice* MBExchange::addDev( RTUDeviceMap& mp, ModbusRTU::ModbusAddr a, UniXML_iterator& xmlit )
{
RTUDeviceMap::iterator it = mp.find(a);
......
......@@ -17,9 +17,9 @@
#include "IOBase.h"
#include "VTypes.h"
#include "MTR.h"
#include "RTUStorage.h"
#include "modbus/ModbusClient.h"
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
/*!
\par Базовый класс для реализация обмена по протоколу Modbus [RTU|TCP].
*/
......@@ -106,8 +106,8 @@ class MBExchange:
RTUDevice* dev;
// only for RTU188
// RTUStorage::RTUJack rtuJack;
// int rtuChan;
RTUStorage::RTUJack rtuJack;
int rtuChan;
// only for MTR
MTR::MTRType mtrType; /*!< тип регистра (согласно спецификации на MTR) */
......@@ -143,7 +143,9 @@ class MBExchange:
resp_invert(false),
resp_real(false),
resp_init(false),
ask_every_reg(false)
ask_every_reg(false),
speed(ComPort::ComSpeed38400),
rtu(0)
{
resp_trTimeout.change(false);
}
......@@ -167,6 +169,9 @@ class MBExchange:
// return TRUE if state changed
bool checkRespond();
// специфические поля для RS
ComPort::Speed speed;
RTUStorage* rtu;
};
friend std::ostream& operator<<( std::ostream& os, RTUDevice& d );
......@@ -221,14 +226,15 @@ class MBExchange:
InitList initRegList; /*!< список регистров для инициализации */
UniSetTypes::uniset_mutex pollMutex;
virtual ModbusClient* initMB( bool reopen=false )=0;
virtual ModbusClient* initMB( bool reopen=false )= 0;
void poll();
virtual void poll();
bool pollRTU( RTUDevice* dev, RegMap::iterator& it );
void updateSM();
void updateRTU(RegMap::iterator& it);
void updateMTR(RegMap::iterator& it);
void updateRTU188(RegMap::iterator& it);
void updateRSProperty( RSProperty* p, bool write_only=false );
bool checkUpdateSM( bool wrFunc );
......@@ -250,10 +256,11 @@ class MBExchange:
RSProperty* addProp( PList& plist, RSProperty& p );
bool initMTRitem( UniXML_iterator& it, RegInfo* p );
bool initRTU188item( UniXML_iterator& it, RegInfo* p );
bool initRSProperty( RSProperty& p, UniXML_iterator& it );
bool initRegInfo( RegInfo* r, UniXML_iterator& it, RTUDevice* dev );
bool initRTUDevice( RTUDevice* d, UniXML_iterator& it );
bool initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniXML_iterator& it );
virtual bool initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniXML_iterator& it );
void rtuQueryOptimization( RTUDeviceMap& m );
......
noinst_LTLIBRARIES = libMBMaster.la
libMBMaster_la_LIBADD = $(top_builddir)/lib/libUniSet.la \
$(top_builddir)/extensions/SharedMemory/libUniSetSharedMemory.la \
$(top_builddir)/extensions/lib/libUniSetExtensions.la \
$(SIGC_LIBS)
libMBMaster_la_CXXFLAGS = -I$(top_builddir)/extensions/include -I$(top_builddir)/extensions/SharedMemory $(SIGC_CFLAGS)
libMBMaster_la_SOURCES = MBExchange.cc RTUStorage.cc
# install
devel_include_HEADERS = *.h
devel_includedir = $(pkgincludedir)/extensions
all-local:
ln -sf ../ModbusMaster/$(devel_include_HEADERS) ../include
......@@ -32,7 +32,7 @@ RTUStorage::~RTUStorage()
{
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void RTUStorage::poll( ModbusRTUMaster* mb )
throw( ModbusRTU::mbException )
{
......@@ -54,7 +54,7 @@ void RTUStorage::poll( ModbusRTUMaster* mb )
ModbusRTU::ReadInputStatusRetMessage ret = mb->read02( addr,0,16 );
ModbusRTU::DataBits bits;
for( int b=0; b<2; b++ )
{
{
if( ret.getData(b,bits) )
{
for( int i=0; i<8; i++ )
......@@ -70,7 +70,7 @@ void RTUStorage::poll( ModbusRTUMaster* mb )
ModbusRTU::ReadCoilRetMessage ret = mb->read01( addr,0,16 );
ModbusRTU::DataBits bits;
for( int b=0; b<2; b++ )
{
{
if( ret.getData(b,bits) )
{
for( int i=0; i<8; i++ )
......@@ -84,7 +84,7 @@ void RTUStorage::poll( ModbusRTUMaster* mb )
ModbusRTU::ReadInputStatusRetMessage ret = mb->read02( addr,16,16 );
ModbusRTU::DataBits bits;
for( int b=0; b<2; b++ )
{
{
if( ret.getData(b,bits) )
{
for( int i=0; i<8; i++ )
......@@ -110,7 +110,7 @@ void RTUStorage::poll( ModbusRTUMaster* mb )
}
// -----------------------------------
}
// опрос UNIO48 DO
if( pollUNIO )
{
......@@ -118,7 +118,7 @@ void RTUStorage::poll( ModbusRTUMaster* mb )
ModbusRTU::ReadCoilRetMessage ret = mb->read01( addr,16,48 );
ModbusRTU::DataBits bits;
for( int b=0; b<8; b++ )
{
{
if( ret.getData(b,bits) )
{
for( int i=0; i<8; i++ )
......@@ -132,7 +132,7 @@ void RTUStorage::poll( ModbusRTUMaster* mb )
ModbusRTU::ReadInputStatusRetMessage ret = mb->read02( addr,32,48 );
ModbusRTU::DataBits bits;
for( int b=0; b<8; b++ )
{
{
if( ret.getData(b,bits) )
{
for( int i=0; i<8; i++ )
......@@ -186,11 +186,11 @@ float RTUStorage::getFloat( RTUJack jack, unsigned short int chan, UniversalIO::
return adc[chan];
case nX2:
return adc[4+chan];
default:
break;
}
return 0;
}
......@@ -208,14 +208,14 @@ float RTUStorage::getFloat( RTUJack jack, unsigned short int chan, UniversalIO::
return adc[chan];
case nX2:
return adc[4+chan];
default:
break;
}
return 0;
}
return 0;
}
// -----------------------------------------------------------------------------
......@@ -235,11 +235,11 @@ bool RTUStorage::getState( RTUJack jack, unsigned short int chan, UniversalIO::I
return di[chan];
case nX5:
return di[8+chan];
default:
break;
}
return false;
}
......@@ -253,14 +253,14 @@ bool RTUStorage::getState( RTUJack jack, unsigned short int chan, UniversalIO::I
return unio_do[24+chan];
case nJ5:
return dio_do[chan];
default:
break;
}
return false;
}
return false;
}
// -----------------------------------------------------------------------------
......@@ -280,11 +280,11 @@ ModbusRTU::ModbusData RTUStorage::getRegister( RTUJack jack, unsigned short chan
return 1016+chan;
case nX2:
return 1016+4+chan;
default:
break;
}
return -1;
}
......@@ -302,14 +302,14 @@ ModbusRTU::ModbusData RTUStorage::getRegister( RTUJack jack, unsigned short chan
return 1016+chan;
case nX2:
return 1016+4+chan;
default:
break;
}
return -1;
}
if( t == UniversalIO::DigitalInput )
{
switch( jack )
......@@ -324,11 +324,11 @@ ModbusRTU::ModbusData RTUStorage::getRegister( RTUJack jack, unsigned short chan
return chan;
case nX5:
return 8+chan;
default:
break;
}
return -1;
}
......@@ -342,20 +342,20 @@ ModbusRTU::ModbusData RTUStorage::getRegister( RTUJack jack, unsigned short chan
return 16+24+chan;
case nJ5:
return chan;
default:
break;
}
return -1;
}
return -1;
}
// -----------------------------------------------------------------------------
std::ostream& operator<<(std::ostream& os, RTUStorage& m )
{
os << "-------------------" << endl
os << "-------------------" << endl
<< " АЦП (8 каналов): " << endl;
for( int i=0; i<8; i++ ) // номера каналов
os << setw(12) << i << "|";
......@@ -364,67 +364,67 @@ std::ostream& operator<<(std::ostream& os, RTUStorage& m )
os << setw(12) << m.adc[i] << "|";
os << endl;
os << "-------------------" << endl
<< " DI (16 каналов): " << endl;
<< " DI (16 каналов): " << endl;
for( int i=0; i<16; i++ ) // номера каналов
os << setw(2) << i << "|";
os << endl;
os << endl;
for( int i=0; i<16; i++ )
os << setw(2) << m.di[i] << "|";
os << endl;
os << "-------------------" << endl
<< " DIO DO(16 каналов): " << endl;
<< " DIO DO(16 каналов): " << endl;
for( int i=0; i<16; i++ ) // номера каналов
os << setw(2) << i << " | ";
os << endl;
for( int i=0; i<16; i++ )
os << setw(2) << m.dio_do[i] << " | ";
os << endl;
os << endl;
os << "-------------------" << endl
<< " DIO DI(16 каналов): " << endl;
<< " DIO DI(16 каналов): " << endl;
for( int i=0; i<16; i++ ) // номера каналов
os << setw(2) << i << " | ";
os << endl;
os << endl;
for( int i=0; i<16; i++ )
os << setw(2) << m.dio_di[i] << " | ";
os << endl;
os << "-------------------" << endl
<< " DIO AI (16 каналов): " << endl;
<< " DIO AI (16 каналов): " << endl;
for( int i=0; i<16; i++ ) // номера каналов
os << setw(2) << i << " | ";
os << endl;
os << endl;
for( int i=0; i<16; i++ )
os << setw(2) << m.dio_ai[i] << " | ";
os << endl;
os << "-------------------" << endl
<< " DIO AO (16 каналов): " << endl;
<< " DIO AO (16 каналов): " << endl;
for( int i=0; i<16; i++ ) // номера каналов
os << setw(2) << i << " | ";
os << endl;
os << endl;
for( int i=0; i<16; i++ )
os << setw(2) << m.dio_ao[i] << " | ";
os << endl;
os << "-------------------" << endl
<< " UNIO48 DI: " << endl;
<< " UNIO48 DI: " << endl;
for( int i=0; i<24; i++ ) // номера каналов
os << setw(2) << i << " | ";
os << endl;
os << endl;
for( int i=0; i<24; i++ )
os << setw(2) << m.unio_di[i] << " | ";
os << endl;
for( int i=24; i<48; i++ ) // номера каналов
os << setw(2) << i << " | ";
os << endl;
os << endl;
for( int i=24; i<48; i++ )
os << setw(2) << m.unio_di[i] << " | ";
os << endl;
os << "-------------------" << endl
<< " UNIO48 DO: " << endl;
<< " UNIO48 DO: " << endl;
for( int i=0; i<24; i++ ) // номера каналов
os << setw(2) << i << " | ";
os << endl;
......@@ -439,7 +439,7 @@ std::ostream& operator<<(std::ostream& os, RTUStorage& m )
os << endl;
os << "-------------------" << endl
<< " UNIO48 AI: " << endl;
<< " UNIO48 AI: " << endl;
for( int i=0; i<12; i++ ) // номера каналов
os << setw(6) << i << " | ";
os << endl;
......@@ -454,16 +454,16 @@ std::ostream& operator<<(std::ostream& os, RTUStorage& m )
os << endl;
os << "-------------------" << endl
<< " UNIO48 AO: " << endl;
<< " UNIO48 AO: " << endl;
for( int i=0; i<12; i++ ) // номера каналов
os << setw(6) << i << " | ";
os << endl;
os << endl;
for( int i=0; i<12; i++ )
os << setw(6) << m.unio_ao[i] << " | ";
os << endl;
for( int i=12; i<24; i++ ) // номера каналов
os << setw(6) << i << " | ";
os << endl;
os << endl;
for( int i=12; i<24; i++ )
os << setw(6) << m.unio_ao[i] << " | ";
os << endl;
......
......@@ -14,7 +14,7 @@ class RTUStorage
public:
RTUStorage( ModbusRTU::ModbusAddr addr );
~RTUStorage();
void poll( ModbusRTUMaster* mb )
throw(ModbusRTU::mbException);
......@@ -25,7 +25,7 @@ class RTUStorage
inline void setPollDI( bool set ){ pollDI = set; }
inline void setPollDIO( bool set ){ pollDIO = set; }
inline void setPollUNIO( bool set ){ pollUNIO = set; }
enum RTUJack
{
nUnknown,
......@@ -37,31 +37,31 @@ class RTUStorage
nX4, // DI (8)
nX5 // DI (8)
};
static RTUJack s2j( const std::string jack );
static std::string j2s( RTUJack j );
long getInt( RTUJack jack, unsigned short channel, UniversalIO::IOTypes t );
float getFloat( RTUJack jack, unsigned short channel, UniversalIO::IOTypes t );
bool getState( RTUJack jack, unsigned short channel, UniversalIO::IOTypes t );
static ModbusRTU::ModbusData getRegister( RTUJack jack, unsigned short channel, UniversalIO::IOTypes t );
// ДОДЕЛАТЬ: setState, setValue
void print();
friend std::ostream& operator<<(std::ostream& os, RTUStorage& m );
friend std::ostream& operator<<(std::ostream& os, RTUStorage* m );
protected:
ModbusRTU::ModbusAddr addr;
bool pingOK;
bool pollADC;
bool pollDI;
bool pollDIO;
bool pollUNIO;
float adc[8]; // АЦП
bool di[16]; // Порт 16DI
......
......@@ -8,16 +8,18 @@ libUniSetRTU_la_LDFLAGS = -version-info $(URTU_VER)
libUniSetRTU_la_LIBADD = $(top_builddir)/lib/libUniSet.la \
$(top_builddir)/extensions/SharedMemory/libUniSetSharedMemory.la \
$(top_builddir)/extensions/lib/libUniSetExtensions.la \
$(top_builddir)/extensions/ModbusMaster/libMBMaster.la \
$(SIGC_LIBS)
libUniSetRTU_la_CXXFLAGS = -I$(top_builddir)/extensions/include -I$(top_builddir)/extensions/SharedMemory $(SIGC_CFLAGS)
libUniSetRTU_la_SOURCES = RTUStorage.cc RTUExchange.cc
libUniSetRTU_la_CXXFLAGS = -I$(top_builddir)/extensions/include -I$(top_builddir)/extensions/SharedMemory -I$(top_builddir)/extensions/ModbusMaster $(SIGC_CFLAGS)
libUniSetRTU_la_SOURCES = RTUExchange.cc
@PACKAGE@_rtuexchange_SOURCES = rtuexchange.cc
@PACKAGE@_rtuexchange_LDADD = libUniSetRTU.la $(top_builddir)/lib/libUniSet.la \
$(top_builddir)/extensions/SharedMemory/libUniSetSharedMemory.la \
$(top_builddir)/extensions/lib/libUniSetExtensions.la \
$(top_builddir)/extensions/ModbusMaster/libMBMaster.la \
$(SIGC_LIBS)
@PACKAGE@_rtuexchange_CXXFLAGS = -I$(top_builddir)/extensions/include -I$(top_builddir)/extensions/SharedMemory $(SIGC_CFLAGS)
@PACKAGE@_rtuexchange_CXXFLAGS = -I$(top_builddir)/extensions/include -I$(top_builddir)/extensions/SharedMemory -I$(top_builddir)/extensions/ModbusMaster $(SIGC_CFLAGS)
@PACKAGE@_mtr_conv_SOURCES = mtrconv.cc
@PACKAGE@_mtr_conv_LDADD = $(top_builddir)/extensions/lib/libUniSetExtensions.la $(top_builddir)/lib/libUniSet.la
......@@ -31,8 +33,10 @@ libUniSetRTU_la_SOURCES = RTUStorage.cc RTUExchange.cc
@PACKAGE@_vtconv_LDADD = $(top_builddir)/extensions/lib/libUniSetExtensions.la $(top_builddir)/lib/libUniSet.la
@PACKAGE@_vtconv_CXXFLAGS = -I$(top_builddir)/extensions/include
@PACKAGE@_rtu188_state_LDADD = libUniSetRTU.la $(top_builddir)/extensions/lib/libUniSetExtensions.la $(top_builddir)/lib/libUniSet.la
@PACKAGE@_rtu188_state__CXXFLAGS = -I$(top_builddir)/extensions/include
@PACKAGE@_rtu188_state_LDADD = libUniSetRTU.la \
$(top_builddir)/extensions/lib/libUniSetExtensions.la $(top_builddir)/lib/libUniSet.la \
$(top_builddir)/extensions/ModbusMaster/libMBMaster.la
@PACKAGE@_rtu188_state_CXXFLAGS = -I$(top_builddir)/extensions/include -I$(top_builddir)/extensions/ModbusMaster
@PACKAGE@_rtu188_state_SOURCES = rtustate.cc
# install
......
......@@ -25,131 +25,8 @@ class RTUExchange:
/*! глобальная функция для вывода help-а */
static void help_print( int argc, const char* const* argv );
enum Timer
{
tmExchange
};
// --------------------------------------------------------
struct RTUDevice;
struct RegInfo;
struct RSProperty:
public IOBase
{
// only for RTU
short nbit; /*!< bit number) */
VTypes::VType vType; /*!< type of value */
short rnum; /*!< count of registers */
short nbyte; /*!< byte number (1-2) */
RSProperty():
nbit(-1),vType(VTypes::vtUnknown),
rnum(VTypes::wsize(VTypes::vtUnknown)),
nbyte(0),reg(0)
{}
RegInfo* reg;
};
friend std::ostream& operator<<( std::ostream& os, const RSProperty& p );
typedef std::list<RSProperty> PList;
static std::ostream& print_plist( std::ostream& os, PList& p );
typedef std::map<ModbusRTU::ModbusData,RegInfo*> RegMap;
struct RegInfo
{
RegInfo():
mbval(0),mbreg(0),mbfunc(ModbusRTU::fnUnknown),
mtrType(MTR::mtUnknown),
rtuJack(RTUStorage::nUnknown),rtuChan(0),
dev(0),offset(0),
q_num(0),q_count(1),mb_init(false),sm_init(false),
mb_init_mbreg(0)
{}
ModbusRTU::ModbusData mbval;
ModbusRTU::ModbusData mbreg; /*!< регистр */
ModbusRTU::SlaveFunctionCode mbfunc; /*!< функция для чтения/записи */
PList slst;
// only for MTR
MTR::MTRType mtrType; /*!< тип регистра (согласно спецификации на MTR) */
// only for RTU188
RTUStorage::RTUJack rtuJack;
int rtuChan;
RTUDevice* dev;
int offset;
// optimization
int q_num; /*! number in query */
int q_count; /*! count registers for query */
RegMap::iterator rit;
bool mb_init; /*!< init before use */
bool sm_init; /*!< SM init value */
ModbusRTU::ModbusData mb_init_mbreg; /*!< mb_init register */
};
friend std::ostream& operator<<( std::ostream& os, RegInfo& r );
struct RTUDevice
{
RTUDevice():
speed(ComPort::ComSpeed38400),
respnond(false),
mbaddr(0),
dtype(dtUnknown),
resp_id(UniSetTypes::DefaultObjectId),
resp_state(false),
resp_invert(false),
resp_real(false),
resp_init(false),
rtu(0)
{
resp_trTimeout.change(false);
}
ComPort::Speed speed;
bool respnond;
ModbusRTU::ModbusAddr mbaddr; /*!< адрес устройства */
RegMap regmap;
DeviceType dtype; /*!< тип устройства */
UniSetTypes::ObjectId resp_id;
IOController::DIOStateList::iterator resp_dit;
PassiveTimer resp_ptTimeout;
Trigger resp_trTimeout;
bool resp_state;
bool resp_invert;
bool resp_real;
bool resp_init;
RTUStorage* rtu;
// return TRUE if state changed
bool checkRespond();
};
friend std::ostream& operator<<( std::ostream& os, RTUDevice& d );
typedef std::map<ModbusRTU::ModbusAddr,RTUDevice*> RTUDeviceMap;
friend std::ostream& operator<<( std::ostream& os, RTUDeviceMap& d );
void printMap(RTUDeviceMap& d);
// ----------------------------------
protected:
RTUDeviceMap rmap;
ModbusRTUMaster* mb;
ModbusRTUMaster* mbrtu;
UniSetTypes::uniset_mutex mbMutex;
std::string devname;
ComPort::Speed defSpeed;
......@@ -159,45 +36,9 @@ class RTUExchange:
virtual void step();
void poll();
bool pollRTU( RTUDevice* dev, RegMap::iterator& it );
void updateSM();
void updateRTU(RegMap::iterator& it);
void updateMTR(RegMap::iterator& it);
void updateRTU188(RegMap::iterator& it);
void updateRSProperty( RSProperty* p, bool write_only=false );
virtual void processingMessage( UniSetTypes::VoidMessage *msg );
virtual void sysCommand( UniSetTypes::SystemMessage *msg );
virtual void sensorInfo( UniSetTypes::SensorMessage*sm );
void timerInfo( UniSetTypes::TimerMessage *tm );
void askSensors( UniversalIO::UIOCommand cmd );
void initOutput();
virtual bool activateObject();
// действия при завершении работы
virtual void sigterm( int signo );
void initMB( bool reopen=false );
virtual void initIterators();
bool initItem( UniXML_iterator& it );
void initDeviceList();
void initOffsetList();
RTUDevice* addDev( RTUDeviceMap& dmap, ModbusRTU::ModbusAddr a, UniXML_iterator& it );
RegInfo* addReg( RegMap& rmap, ModbusRTU::ModbusData r, UniXML_iterator& it,
RTUDevice* dev, RegInfo* rcopy=0 );
RSProperty* addProp( PList& plist, RSProperty& p );
bool initMTRitem( UniXML_iterator& it, RegInfo* p );
bool initRTU188item( UniXML_iterator& it, RegInfo* p );
bool initRSProperty( RSProperty& p, UniXML_iterator& it );
bool initRegInfo( RegInfo* r, UniXML_iterator& it, RTUDevice* dev );
bool initRTUDevice( RTUDevice* d, UniXML_iterator& it );
bool initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniXML_iterator& it );
void rtuQueryOptimization( RTUDeviceMap& m );
virtual ModbusClient* initMB( bool reopen=false );
virtual bool initDeviceInfo( RTUDeviceMap& m, ModbusRTU::ModbusAddr a, UniXML_iterator& it );
private:
RTUExchange();
......
../ModbusMaster/MBExchange.h
\ No newline at end of file
......@@ -6,6 +6,6 @@ libUniSetExtensions_la_LDFLAGS = -version-info $(UEXT_VER)
libUniSetExtensions_la_CPPFLAGS = $(SIGC_CFLAGS) -I$(top_builddir)/extensions/include
libUniSetExtensions_la_LIBADD = $(SIGC_LIBS) $(top_builddir)/lib/libUniSet.la
libUniSetExtensions_la_SOURCES = Extensions.cc SMInterface.cc Calibration.cc SingleProcess.cc \
IOBase.cc DigitalFilter.cc PID.cc MTR.cc VTypes.cc MBExchange.cc
IOBase.cc DigitalFilter.cc PID.cc MTR.cc VTypes.cc
#UObject_SK.cc
\ No newline at end of file
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