1#ifndef MBTCPTestServer_H_
2#define MBTCPTestServer_H_
7#include <unordered_set>
8#include "modbus/ModbusTCPServerSlot.h"
15 MBTCPTestServer(
const std::unordered_set<uniset::ModbusRTU::ModbusAddr>&
vaddr,
const std::string& inetaddr,
int port = 502,
bool verbose =
false );
18 inline void setVerbose(
bool state )
23 inline void setReply( uint32_t val )
29 void setLog( std::shared_ptr<DebugStream> dlog );
31 inline bool isRunning()
36 inline void disableExchange(
bool set =
true )
41 inline bool getForceSingleCoilCmd()
43 return forceSingleCoilCmd;
45 inline int16_t getLastWriteRegister( uint16_t reg )
47 return lastWriteRegister[reg].value;
49 inline float getLastWriteRegisterF2( uint16_t reg )
51 uniset::ModbusRTU::ModbusData data[] = {(uniset::ModbusRTU::ModbusData)lastWriteRegister[reg].value,
52 (uniset::ModbusRTU::ModbusData)lastWriteRegister[reg + 1].value
57 inline uint16_t getLastWriteRegisterByte( uint16_t reg )
62 inline float getLastWriteRegisterF2r( uint16_t reg )
64 uniset::ModbusRTU::ModbusData data[] = {(uniset::ModbusRTU::ModbusData)lastWriteRegister[reg].value,
65 (uniset::ModbusRTU::ModbusData)lastWriteRegister[reg + 1].value
70 inline double getLastWriteRegisterF4( uint16_t reg )
72 uniset::ModbusRTU::ModbusData data[] = {(uniset::ModbusRTU::ModbusData)lastWriteRegister[reg].value,
73 (uniset::ModbusRTU::ModbusData)lastWriteRegister[reg + 1].value,
74 (uniset::ModbusRTU::ModbusData)lastWriteRegister[reg + 2].value,
75 (uniset::ModbusRTU::ModbusData)lastWriteRegister[reg + 3].value
80 inline int32_t getLastWriteRegisterI2( uint16_t reg )
82 uniset::ModbusRTU::ModbusData data[] = {(uniset::ModbusRTU::ModbusData)lastWriteRegister[reg].value,
83 (uniset::ModbusRTU::ModbusData)lastWriteRegister[reg + 1].value
88 inline int32_t getLastWriteRegisterI2r( uint16_t reg )
90 uniset::ModbusRTU::ModbusData data[] = {(uniset::ModbusRTU::ModbusData)lastWriteRegister[reg].value,
91 (uniset::ModbusRTU::ModbusData)lastWriteRegister[reg + 1].value
96 inline uint32_t getLastWriteRegisterU2( uint16_t reg )
98 uniset::ModbusRTU::ModbusData data[] = {(uniset::ModbusRTU::ModbusData)lastWriteRegister[reg].value,
99 (uniset::ModbusRTU::ModbusData)lastWriteRegister[reg + 1].value
104 inline uint32_t getLastWriteRegisterU2r( uint16_t reg )
106 uniset::ModbusRTU::ModbusData data[] = {(uniset::ModbusRTU::ModbusData)lastWriteRegister[reg].value,
107 (uniset::ModbusRTU::ModbusData)lastWriteRegister[reg + 1].value
110 return (uint32_t)u2r;
112 inline long getWriteRegisterCount( uint16_t reg )
114 return lastWriteRegister[reg].count;
118 return lastForceCoilsQ;
122 return lastWriteOutputQ;
125 friend std::ostream& operator<<(std::ostream& os,
const MBTCPTestServer* m );
127 inline float getF2TestValue()
129 return f2_test_value;
134 void sigterm(
int signo );
193 std::unordered_set<uniset::ModbusRTU::ModbusAddr>
vaddr;
197 bool forceSingleCoilCmd;
202 void setValue(int16_t val)
208 std::unordered_map<int16_t, regData> lastWriteRegister;
211 float f2_test_value = {0.0};
214 typedef std::map<uniset::ModbusRTU::mbErrCode, unsigned int> ExchangeErrorMap;
215 ExchangeErrorMap errmap;
216 uniset::ModbusRTU::mbErrCode prev;
224 typedef std::map<int, std::string> FileList;
Definition MBTCPTestServer.h:13
uniset::ModbusRTU::mbErrCode writeOutputSingleRegister(uniset::ModbusRTU::WriteSingleOutputMessage &query, uniset::ModbusRTU::WriteSingleOutputRetMessage &reply)
Definition MBTCPTestServer.cc:334
uniset::ModbusTCPServerSlot * sslot
Definition MBTCPTestServer.h:192
uniset::ModbusRTU::mbErrCode remoteService(uniset::ModbusRTU::RemoteServiceMessage &query, uniset::ModbusRTU::RemoteServiceRetMessage &reply)
Definition MBTCPTestServer.cc:421
uniset::ModbusRTU::mbErrCode writeOutputRegisters(uniset::ModbusRTU::WriteOutputMessage &query, uniset::ModbusRTU::WriteOutputRetMessage &reply)
Definition MBTCPTestServer.cc:306
uniset::ModbusRTU::mbErrCode forceMultipleCoils(uniset::ModbusRTU::ForceCoilsMessage &query, uniset::ModbusRTU::ForceCoilsRetMessage &reply)
Definition MBTCPTestServer.cc:291
uniset::ModbusRTU::mbErrCode readCoilStatus(uniset::ModbusRTU::ReadCoilMessage &query, uniset::ModbusRTU::ReadCoilRetMessage &reply)
Definition MBTCPTestServer.cc:107
void execute()
Definition MBTCPTestServer.cc:95
uniset::ModbusRTU::mbErrCode journalCommand(uniset::ModbusRTU::JournalCommandMessage &query, uniset::ModbusRTU::JournalCommandRetMessage &reply)
Definition MBTCPTestServer.cc:366
uniset::ModbusRTU::mbErrCode setDateTime(uniset::ModbusRTU::SetDateTimeMessage &query, uniset::ModbusRTU::SetDateTimeRetMessage &reply)
Definition MBTCPTestServer.cc:406
uniset::ModbusRTU::mbErrCode forceSingleCoil(uniset::ModbusRTU::ForceSingleCoilMessage &query, uniset::ModbusRTU::ForceSingleCoilRetMessage &reply)
Definition MBTCPTestServer.cc:349
uniset::ModbusRTU::mbErrCode readInputStatus(uniset::ModbusRTU::ReadInputStatusMessage &query, uniset::ModbusRTU::ReadInputStatusRetMessage &reply)
Definition MBTCPTestServer.cc:155
uniset::ModbusRTU::mbErrCode readInputRegisters(uniset::ModbusRTU::ReadInputMessage &query, uniset::ModbusRTU::ReadInputRetMessage &reply)
Definition MBTCPTestServer.cc:203
std::unordered_set< uniset::ModbusRTU::ModbusAddr > vaddr
Definition MBTCPTestServer.h:193
uniset::ModbusRTU::mbErrCode readOutputRegisters(uniset::ModbusRTU::ReadOutputMessage &query, uniset::ModbusRTU::ReadOutputRetMessage &reply)
Definition MBTCPTestServer.cc:248
Definition ModbusTCPServerSlot.h:16
static size_t wsize()
Definition VTypes.h:88
static size_t wsize()
Definition VTypes.h:175
static size_t wsize()
Definition VTypes.h:382
static size_t wsize()
Definition VTypes.h:459
Definition MBTCPTestServer.h:199
Definition ModbusTypes.h:1118
Definition ModbusTypes.h:1176
Definition ModbusTypes.h:1575
Definition ModbusTypes.h:1603
Definition ModbusTypes.h:727
Definition ModbusTypes.h:804
Definition ModbusTypes.h:937
Definition ModbusTypes.h:988
Definition ModbusTypes.h:1310
Definition ModbusTypes.h:1333
Definition ModbusTypes.h:1188
Definition ModbusTypes.h:1243
Definition ModbusTypes.h:347
Definition ModbusTypes.h:378
Definition ModbusTypes.h:548
Definition ModbusTypes.h:577
Definition ModbusTypes.h:1456
Definition ModbusTypes.h:1489
Definition ModbusTypes.h:1398
Definition ModbusTypes.h:1436
Definition ModbusTypes.h:844
Definition ModbusTypes.h:898
Definition ModbusTypes.h:1033
Definition ModbusTypes.h:1079