Class ModbusTcpIpConnector<CO,CI>
java.lang.Object
de.iip_ecosphere.platform.connectors.AbstractConnector<ModbusItem,Object,CO,CI>
de.iip_ecosphere.platform.connectors.modbustcpipv1.ModbusTcpIpConnector<CO,CI>
- Type Parameters:
CO- the output type of the connectorCI- the input type of the connector
- All Implemented Interfaces:
de.iip_ecosphere.platform.connectors.Connector<ModbusItem,,Object, CO, CI> de.iip_ecosphere.platform.connectors.events.EventHandlingConnector,de.iip_ecosphere.platform.connectors.model.AbstractModelAccess.NotificationChangedListener
@MachineConnector(hasModel=true,
supportsModelStructs=false,
supportsEvents=false,
specificSettings={"SERVER_STRUCTURE","UNITID","TIMEOUT","BIGBYTE"})
public class ModbusTcpIpConnector<CO,CI>
extends de.iip_ecosphere.platform.connectors.AbstractConnector<ModbusItem,Object,CO,CI>
Implements the generic MODBUS TCP/IP connector.
- Author:
- Christian Nikolajew
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe descriptor of this connector (see META-INF/services).protected classImplements the model access for MODBUS TCP/IP.Nested classes/interfaces inherited from class de.iip_ecosphere.platform.connectors.AbstractConnector
de.iip_ecosphere.platform.connectors.AbstractConnector.BasicAdapterProvider -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate com.ghgande.j2mod.modbus.net.TCPMasterConnectionprivate AtomicBooleanprivate ModbusItemprivate static final de.iip_ecosphere.platform.support.logging.Loggerprivate ModbusMapstatic final Stringprivate de.iip_ecosphere.platform.connectors.ConnectorParameterprivate intprivate intFields inherited from class de.iip_ecosphere.platform.connectors.AbstractConnector
DEFAULT_CHANNEL -
Constructor Summary
ConstructorsConstructorDescriptionModbusTcpIpConnector(de.iip_ecosphere.platform.connectors.AdapterSelector<ModbusItem, Object, CO, CI> selector, de.iip_ecosphere.platform.connectors.types.ProtocolAdapter<ModbusItem, Object, CO, CI>... adapter) Creates an instance and installs the protocol adapter.ModbusTcpIpConnector(de.iip_ecosphere.platform.connectors.types.ProtocolAdapter<ModbusItem, Object, CO, CI>... adapter) Creates an instance and installs the protocol adapter. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidconnectImpl(de.iip_ecosphere.platform.connectors.ConnectorParameter params) protected voidprotected voidprotected voidprivate com.ghgande.j2mod.modbus.procimg.Register[]getDatetimeAsRegisters(ModbusVarItem varItem) Creates Register[] out of a Datetime value.private LocalDateTimegetDatetimeFromRegisters(com.ghgande.j2mod.modbus.procimg.Register[] registers) Create a LocalDateTime out of Registers.private com.ghgande.j2mod.modbus.procimg.Register[]getDoubleAsRegisters(ModbusVarItem varItem) Creates Register[] out of a Double value.private doublegetDoubleFromRegisters(com.ghgande.j2mod.modbus.procimg.Register[] registers) Creates an Double out of four Registers.private StringgetEndpointUrl(de.iip_ecosphere.platform.connectors.ConnectorParameter params) Construct the endpoint URL.private com.ghgande.j2mod.modbus.procimg.Register[]getFloatAsRegisters(ModbusVarItem varItem) Creates Register[] out of a Float value.private floatgetFloatFromRegisters(com.ghgande.j2mod.modbus.procimg.Register[] registers) Creates an Float out of two Registers.private com.ghgande.j2mod.modbus.procimg.Register[]getIntegerAsRegisters(ModbusVarItem varItem) Creates Register[] out of a Integer value.private intgetIntegerFromRegisters(com.ghgande.j2mod.modbus.procimg.Register[] registers) Creates an Integer out of two Registers.private com.ghgande.j2mod.modbus.procimg.Register[]getLongAsRegisters(ModbusVarItem varItem) Creates Register[] out of a Long value.private longgetLongFromRegisters(com.ghgande.j2mod.modbus.procimg.Register[] registers) Creates an Long out of four Registers.getMap()Getter for ModbusMap.getName()private com.ghgande.j2mod.modbus.procimg.Register[]getStringAsRegisters(ModbusVarItem varItem) Creates Register[] out of a String value.private StringgetStringFromRegisters(com.ghgande.j2mod.modbus.procimg.Register[] registers) Creates a ASCII String out of Registers.private com.ghgande.j2mod.modbus.procimg.Register[]Creates Register[] out of a unsigned Integer value.private longgetUnsignedIntegerFromRegisters(com.ghgande.j2mod.modbus.procimg.Register[] registers) Creates an Long containing the value of a unsignedInteger.private com.ghgande.j2mod.modbus.procimg.Register[]getUnsignedLongAsRegisters(ModbusVarItem varItem) Creates Register[] out of a unsigned Long value.private BigIntegergetUnsignedLongFromRegisters(com.ghgande.j2mod.modbus.procimg.Register[] registers) Creates a BigInteger containing the value of a unsignedLong.protected ModbusItemread()private com.ghgande.j2mod.modbus.procimg.Register[]registers(ModbusVarItem varItem, Object varItemValue) Creates the registers to write to the Machine.private voidSets the ModbusMap.voidtrigger(de.iip_ecosphere.platform.connectors.events.ConnectorTriggerQuery query) protected voidMethods inherited from class de.iip_ecosphere.platform.connectors.AbstractConnector
checkCache, configureAdapter, configureModelAccess, connect, createTlsContext, disconnect, dispose, enableNotifications, enablePolling, getCachingStrategy, getCachingStrategyCls, getConnectorInputType, getConnectorOutputType, getConnectorParameter, getInitCachingStrategyCls, getInstanceIdentification, getProtocolInputType, getProtocolOutputType, getSelector, getStorageValue, initializeModelAccess, initSelector, installPollTask, isPolling, notificationsChanged, notifyDataTimeDifference, notifyReconfigured, received, received, request, request, setDataTimeDifference, setDataTimeDifferenceProvider, setInstanceIdentification, setReceptionCallback, setStorageValue, trigger, uninstallPollTask, useTls, writeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.iip_ecosphere.platform.connectors.Connector
createSharedSpace, disconnectSafe, enableSharedSpace, setReceptionCallbackSafe
-
Field Details
-
NAME
- See Also:
-
LOGGER
private static final de.iip_ecosphere.platform.support.logging.Logger LOGGER -
map
-
item
-
connection
private com.ghgande.j2mod.modbus.net.TCPMasterConnection connection -
params
private de.iip_ecosphere.platform.connectors.ConnectorParameter params -
inPolling
-
timeout
private int timeout -
bigByte
private boolean bigByte -
unitId
private int unitId
-
-
Constructor Details
-
ModbusTcpIpConnector
@SafeVarargs public ModbusTcpIpConnector(de.iip_ecosphere.platform.connectors.types.ProtocolAdapter<ModbusItem, Object, CO, CI>... adapter) Creates an instance and installs the protocol adapter.- Parameters:
adapter- the protocol adapter
-
ModbusTcpIpConnector
@SafeVarargs public ModbusTcpIpConnector(de.iip_ecosphere.platform.connectors.AdapterSelector<ModbusItem, Object, CO, CI> selector, de.iip_ecosphere.platform.connectors.types.ProtocolAdapter<ModbusItem, Object, CO, CI>... adapter) Creates an instance and installs the protocol adapter.- Parameters:
selector- the adapter selector (null leads to a default selector for the first adapter)adapter- the protocol adapter(s)
-
-
Method Details
-
getName
-
getEndpointUrl
Construct the endpoint URL.- Parameters:
params- the connector parameters- Returns:
- the endpoint URL
-
connectImpl
protected void connectImpl(de.iip_ecosphere.platform.connectors.ConnectorParameter params) throws IOException - Specified by:
connectImplin classde.iip_ecosphere.platform.connectors.AbstractConnector<ModbusItem,Object, CO, CI> - Throws:
IOException
-
setModbusMap
private void setModbusMap()Sets the ModbusMap. -
getMap
Getter for ModbusMap.- Returns:
- the ModbusMap
-
doPolling
protected void doPolling()- Overrides:
doPollingin classde.iip_ecosphere.platform.connectors.AbstractConnector<ModbusItem,Object, CO, CI>
-
disconnectImpl
- Specified by:
disconnectImplin classde.iip_ecosphere.platform.connectors.AbstractConnector<ModbusItem,Object, CO, CI> - Throws:
IOException
-
error
- Specified by:
errorin classde.iip_ecosphere.platform.connectors.AbstractConnector<ModbusItem,Object, CO, CI>
-
read
- Specified by:
readin classde.iip_ecosphere.platform.connectors.AbstractConnector<ModbusItem,Object, CO, CI> - Throws:
IOException
-
getIntegerFromRegisters
private int getIntegerFromRegisters(com.ghgande.j2mod.modbus.procimg.Register[] registers) Creates an Integer out of two Registers.- Parameters:
registers- containing the Integer- Returns:
- the Integer
-
getUnsignedIntegerFromRegisters
private long getUnsignedIntegerFromRegisters(com.ghgande.j2mod.modbus.procimg.Register[] registers) Creates an Long containing the value of a unsignedInteger.- Parameters:
registers- containing the unsignedInteger- Returns:
- the value of unsignedInteger as long
-
getFloatFromRegisters
private float getFloatFromRegisters(com.ghgande.j2mod.modbus.procimg.Register[] registers) Creates an Float out of two Registers.- Parameters:
registers- containing the Float- Returns:
- the Float
-
getLongFromRegisters
private long getLongFromRegisters(com.ghgande.j2mod.modbus.procimg.Register[] registers) Creates an Long out of four Registers.- Parameters:
registers- containing the Long- Returns:
- the Long
-
getUnsignedLongFromRegisters
private BigInteger getUnsignedLongFromRegisters(com.ghgande.j2mod.modbus.procimg.Register[] registers) Creates a BigInteger containing the value of a unsignedLong.- Parameters:
registers- containing the unsignedLong- Returns:
- the value of unsignedLong as BigInteger
-
getDoubleFromRegisters
private double getDoubleFromRegisters(com.ghgande.j2mod.modbus.procimg.Register[] registers) Creates an Double out of four Registers.- Parameters:
registers- containing the Double- Returns:
- the Double
-
getStringFromRegisters
Creates a ASCII String out of Registers.- Parameters:
registers- containing the String- Returns:
- the String
-
getDatetimeFromRegisters
private LocalDateTime getDatetimeFromRegisters(com.ghgande.j2mod.modbus.procimg.Register[] registers) Create a LocalDateTime out of Registers.- Parameters:
registers- containing LocalDateTime- Returns:
- The LocalDateTime
-
trigger
public void trigger(de.iip_ecosphere.platform.connectors.events.ConnectorTriggerQuery query) - Specified by:
triggerin interfacede.iip_ecosphere.platform.connectors.events.EventHandlingConnector- Overrides:
triggerin classde.iip_ecosphere.platform.connectors.AbstractConnector<ModbusItem,Object, CO, CI>
-
writeImpl
- Specified by:
writeImplin classde.iip_ecosphere.platform.connectors.AbstractConnector<ModbusItem,Object, CO, CI> - Throws:
IOException
-
registers
private com.ghgande.j2mod.modbus.procimg.Register[] registers(ModbusVarItem varItem, Object varItemValue) Creates the registers to write to the Machine.- Parameters:
varItem- the ModbusVarItem to writevarItemValue- the Value for the ModbusVarItem to write- Returns:
- the registers to write to the Machine
-
getIntegerAsRegisters
Creates Register[] out of a Integer value.- Parameters:
varItem- to set the Integer value for- Returns:
- Register[] with the Integer value in it
-
getUnsignedIntegerAsRegisters
private com.ghgande.j2mod.modbus.procimg.Register[] getUnsignedIntegerAsRegisters(ModbusVarItem varItem) Creates Register[] out of a unsigned Integer value.- Parameters:
varItem- to set the unsigned Integer value for- Returns:
- Register[] with the unsigned Integer value in it
-
getFloatAsRegisters
Creates Register[] out of a Float value.- Parameters:
varItem- to set the Float value for- Returns:
- the Register with the Float value in it
-
getLongAsRegisters
Creates Register[] out of a Long value.- Parameters:
varItem- to set the Long value for- Returns:
- the Register with the Long value in it
-
getUnsignedLongAsRegisters
private com.ghgande.j2mod.modbus.procimg.Register[] getUnsignedLongAsRegisters(ModbusVarItem varItem) Creates Register[] out of a unsigned Long value.- Parameters:
varItem- to set the unsigned Long value for- Returns:
- the Register with the unsigned Long value in it
-
getDoubleAsRegisters
Creates Register[] out of a Double value.- Parameters:
varItem- to set the Double value for- Returns:
- the Register with the Double value in it
-
getStringAsRegisters
Creates Register[] out of a String value.- Parameters:
varItem- to set the String value for- Returns:
- the Register with the String value in it
-
getDatetimeAsRegisters
Creates Register[] out of a Datetime value.- Parameters:
varItem- to set the Datetime value for- Returns:
- the Register with the Datetime value in it
-
supportedEncryption
-
enabledEncryption
-