Class TestServer
java.lang.Object
test.de.iip_ecosphere.platform.connectors.modbustcpipv1.TestServer
Implements a MODBUS TCP/IP test server.
So far only modbus holding registers are implemented.
- Author:
- Christian Nikolajew
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate de.iip_ecosphere.platform.connectors.modbustcpipv1.ModbusMapprivate InetAddressprivate net.wimpi.modbus.net.ModbusTCPListenerprivate intprivate String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate StringReturs the ServerSettings for the TestServer.getHost()Returns the host.de.iip_ecosphere.platform.connectors.modbustcpipv1.ModbusMapgetMap()Returns the map.intgetPort()Returns the port.intCalculates the count of Registers needed to store the ModbusServerMap and returs it.Returns the ServerSettings.voidstart()Starts the server.voidstop()Shuts down the server.
-
Field Details
-
mListener
private net.wimpi.modbus.net.ModbusTCPListener mListener -
mHost
-
mPort
private int mPort -
serverStructure
-
map
private de.iip_ecosphere.platform.connectors.modbustcpipv1.ModbusMap map
-
-
Constructor Details
-
TestServer
public TestServer(boolean defaultPort) Creates a TestServer instance.- Parameters:
defaultPort- : true -> Modbus default port 502 is used false -> Free port from NetUtils.getEphemeralPort() is used.
-
-
Method Details
-
start
public void start()Starts the server. -
stop
public void stop()Shuts down the server. -
getHost
Returns the host.- Returns:
- the host
-
getPort
public int getPort()Returns the port.- Returns:
- the port
-
getMap
public de.iip_ecosphere.platform.connectors.modbustcpipv1.ModbusMap getMap()Returns the map.- Returns:
- the map
-
getRegisterCount
public int getRegisterCount()Calculates the count of Registers needed to store the ModbusServerMap and returs it.- Returns:
- the count of Registers needed to store the ModbusServerMap
-
createServerStructure
Returs the ServerSettings for the TestServer.- Returns:
- the ServerSettings
-
getServerStructure
Returns the ServerSettings.- Returns:
- the ServerSettings
-