Offers a modbus server and read/write functionality via subscription/publication.
More...
#include <pilz_modbus_server_mock.h>
|
bool | init (const char *ip, unsigned int port) |
| Allocates needed resources for running the server. More...
|
|
| PilzModbusServerMock (const unsigned int &holding_register_size) |
|
RegCont | readHoldingRegister (const RegCont::size_type start_index, const RegCont::size_type num_reg_to_read) |
| Reads the specified number of registers, beginning at the specified start point from the holding register. More...
|
|
void | run () |
| Run the server and publish the register values as messages. The value of the modbus register is read in a loop. Once in a loop pass the value is published as a message. In order for clients to differentiate between messages notifying about changes in the register the timestamp of the message is only changed if a register value changed. More...
|
|
void | setHoldingRegister (std::initializer_list< std::pair< unsigned int, uint16_t > > reg_list) |
|
void | setHoldingRegister (const RegCont &data, unsigned int start_index) |
| Set the values in the holding register. More...
|
|
void | setTerminateFlag () |
|
void | start (const char *ip, const unsigned int port) |
| Start the modbus server and make it accessible for clients. More...
|
|
void | startAsync (const char *ip, const unsigned int port) |
| Start the modbus server asynchronously and make it accessible for clients. More...
|
|
void | terminate () |
| Terminate the Server. Reading or connecting to it will fail. More...
|
|
| ~PilzModbusServerMock () |
|
Offers a modbus server and read/write functionality via subscription/publication.
Definition at line 41 of file pilz_modbus_server_mock.h.
prbt_hardware_support::PilzModbusServerMock::PilzModbusServerMock |
( |
const unsigned int & |
holding_register_size | ) |
|
prbt_hardware_support::PilzModbusServerMock::~PilzModbusServerMock |
( |
| ) |
|
bool prbt_hardware_support::PilzModbusServerMock::init |
( |
const char * |
ip, |
|
|
unsigned int |
port |
|
) |
| |
Allocates needed resources for running the server.
This needs to be called before a successful run()
- Parameters
-
ip | The ip the server attaches to |
port | The used port |
- Returns
- True on success, false otherwise
Definition at line 57 of file pilz_modbus_server_mock.cpp.
RegCont prbt_hardware_support::PilzModbusServerMock::readHoldingRegister |
( |
const RegCont::size_type |
start_index, |
|
|
const RegCont::size_type |
num_reg_to_read |
|
) |
| |
Reads the specified number of registers, beginning at the specified start point from the holding register.
- Parameters
-
start_index | Index of first register to read. |
num_reg_to_read | Number of registers to read. |
- Returns
- the registers which were read.
Definition at line 118 of file pilz_modbus_server_mock.cpp.
void prbt_hardware_support::PilzModbusServerMock::run |
( |
| ) |
|
Run the server and publish the register values as messages. The value of the modbus register is read in a loop. Once in a loop pass the value is published as a message. In order for clients to differentiate between messages notifying about changes in the register the timestamp of the message is only changed if a register value changed.
Definition at line 148 of file pilz_modbus_server_mock.cpp.
void prbt_hardware_support::PilzModbusServerMock::setHoldingRegister |
( |
std::initializer_list< std::pair< unsigned int, uint16_t > > |
reg_list | ) |
|
void prbt_hardware_support::PilzModbusServerMock::setHoldingRegister |
( |
const RegCont & |
data, |
|
|
unsigned int |
start_index |
|
) |
| |
Set the values in the holding register.
- Parameters
-
data | The values in the holding register |
start_index | The index from where the value is set, other values remain untouched. |
Definition at line 92 of file pilz_modbus_server_mock.cpp.
void prbt_hardware_support::PilzModbusServerMock::setTerminateFlag |
( |
| ) |
|
|
inline |
bool prbt_hardware_support::PilzModbusServerMock::shutdownSignalReceived |
( |
| ) |
|
|
inlineprivate |
void prbt_hardware_support::PilzModbusServerMock::start |
( |
const char * |
ip, |
|
|
const unsigned int |
port |
|
) |
| |
Start the modbus server and make it accessible for clients.
- Parameters
-
ip | The ip the server attaches to |
port | The used port |
Definition at line 131 of file pilz_modbus_server_mock.cpp.
void prbt_hardware_support::PilzModbusServerMock::startAsync |
( |
const char * |
ip, |
|
|
const unsigned int |
port |
|
) |
| |
Start the modbus server asynchronously and make it accessible for clients.
- Parameters
-
ip | The ip the server attaches to |
port | The used port |
Returns as soon as it is running
Definition at line 137 of file pilz_modbus_server_mock.cpp.
void prbt_hardware_support::PilzModbusServerMock::terminate |
( |
| ) |
|
|
inline |
constexpr uint32_t prbt_hardware_support::PilzModbusServerMock::DISCONNECT_TIMEOUT_IN_SEC {1} |
|
staticprivate |
constexpr uint32_t prbt_hardware_support::PilzModbusServerMock::DISCONNECT_TIMEOUT_IN_USEC {0} |
|
staticprivate |
const unsigned int prbt_hardware_support::PilzModbusServerMock::holding_register_size_ |
|
private |
modbus_mapping_t* prbt_hardware_support::PilzModbusServerMock::mb_mapping_ {nullptr} |
|
private |
modbus_t* prbt_hardware_support::PilzModbusServerMock::modbus_connection_ {nullptr} |
|
private |
std::mutex prbt_hardware_support::PilzModbusServerMock::modbus_register_access_mutex |
|
private |
constexpr uint32_t prbt_hardware_support::PilzModbusServerMock::RESPONSE_TIMEOUT_IN_SEC {0} |
|
staticprivate |
constexpr uint32_t prbt_hardware_support::PilzModbusServerMock::RESPONSE_TIMEOUT_IN_USEC {10000} |
|
staticprivate |
std::condition_variable prbt_hardware_support::PilzModbusServerMock::running_cv_ |
|
private |
std::mutex prbt_hardware_support::PilzModbusServerMock::running_mutex_ |
|
private |
int prbt_hardware_support::PilzModbusServerMock::socket_ {-1} |
|
private |
std::atomic_bool prbt_hardware_support::PilzModbusServerMock::terminate_ {false} |
|
private |
const unsigned int prbt_hardware_support::PilzModbusServerMock::terminate_register_idx_ |
|
private |
constexpr uint16_t prbt_hardware_support::PilzModbusServerMock::TERMINATE_SIGNAL {1} |
|
staticprivate |
std::thread prbt_hardware_support::PilzModbusServerMock::thread_ |
|
private |
The documentation for this class was generated from the following files: