Class SGrModbusDevice
- java.lang.Object
-
- com.smartgridready.communicator.common.impl.SGrDeviceBase<com.smartgridready.ns.v0.DeviceFrame,com.smartgridready.ns.v0.ModbusFunctionalProfile,com.smartgridready.ns.v0.ModbusDataPoint>
-
- com.smartgridready.communicator.modbus.impl.SGrModbusDevice
-
- All Implemented Interfaces:
GenDeviceApi,GenDeviceApi4Modbus
public class SGrModbusDevice extends SGrDeviceBase<com.smartgridready.ns.v0.DeviceFrame,com.smartgridready.ns.v0.ModbusFunctionalProfile,com.smartgridready.ns.v0.ModbusDataPoint> implements GenDeviceApi4Modbus
Implements a Modbus device communication interface.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.smartgridready.communicator.common.impl.SGrDeviceBase
SGrDeviceBase.Comparator, SGrDeviceBase.RwpDirections
-
-
Field Summary
-
Fields inherited from class com.smartgridready.communicator.common.impl.SGrDeviceBase
device
-
-
Constructor Summary
Constructors Constructor Description SGrModbusDevice(com.smartgridready.ns.v0.DeviceFrame aDeviceDescription, com.smartgridready.driver.api.modbus.GenDriverAPI4Modbus aTransport)Construct with pre-defined transport (legacy method).SGrModbusDevice(com.smartgridready.ns.v0.DeviceFrame aDeviceDescription, com.smartgridready.driver.api.modbus.GenDriverAPI4ModbusFactory aDriverFactory)Construct with custom Modbus gateway factory.SGrModbusDevice(com.smartgridready.ns.v0.DeviceFrame aDeviceDescription, com.smartgridready.driver.api.modbus.GenDriverAPI4ModbusFactory aDriverFactory, ModbusGatewayRegistry aGatewayRegistry)Construct with pre-defined shared Modbus gateway registry.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconnect()Connect the device.voiddisconnect()Disconnect the device.protected java.util.Optional<com.smartgridready.ns.v0.ModbusDataPoint>findDataPointForProfile(com.smartgridready.ns.v0.ModbusFunctionalProfile aProfile, java.lang.String aDataPointName)Finds a data point of a given functional profile by name.protected java.util.Optional<com.smartgridready.ns.v0.ModbusFunctionalProfile>findProfile(java.lang.String aProfileName)Finds a functional profile by name.ValuegetVal(java.lang.String sProfileName, java.lang.String sDataPointName)Read a value from the modbus device in its generic data point representation (seeValue).ValuegetVal(java.lang.String sProfileName, java.lang.String sDataPointName, java.util.Properties parameters)Get a value for a given data point, with request-specific parametersbooleanisConnected()Checks if the device is connected.voidsetVal(java.lang.String sProfileName, java.lang.String sDataPointName, Value value)Write a value to the modbus device using the generic data point representation (seeValue).-
Methods inherited from class com.smartgridready.communicator.common.impl.SGrDeviceBase
applyUnitConversion, canSubscribe, checkOutOfRange, checkOutOfRange, checkReadWritePermission, divide, findDataPoint, getDataPoint, getDataPoints, getDeviceConfigurationInfo, getDeviceInfo, getFunctionalProfile, getFunctionalProfiles, getValues, isNumeric, multiply, subscribe, unsubscribe
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.smartgridready.communicator.common.api.GenDeviceApi
canSubscribe, getDataPoint, getDataPoints, getDeviceConfigurationInfo, getDeviceInfo, getFunctionalProfile, getFunctionalProfiles, getValues, subscribe, unsubscribe
-
-
-
-
Constructor Detail
-
SGrModbusDevice
public SGrModbusDevice(com.smartgridready.ns.v0.DeviceFrame aDeviceDescription, com.smartgridready.driver.api.modbus.GenDriverAPI4ModbusFactory aDriverFactory, ModbusGatewayRegistry aGatewayRegistry) throws com.smartgridready.driver.api.common.GenDriverExceptionConstruct with pre-defined shared Modbus gateway registry.- Parameters:
aDeviceDescription- the EID descriptionaDriverFactory- the Modbus gateway factoryaGatewayRegistry- the shared Modbus gateway registry- Throws:
com.smartgridready.driver.api.common.GenDriverException- when gateway cannot be created
-
SGrModbusDevice
public SGrModbusDevice(com.smartgridready.ns.v0.DeviceFrame aDeviceDescription, com.smartgridready.driver.api.modbus.GenDriverAPI4ModbusFactory aDriverFactory) throws com.smartgridready.driver.api.common.GenDriverExceptionConstruct with custom Modbus gateway factory.- Parameters:
aDeviceDescription- the EID descriptionaDriverFactory- the Modbus gateway factory- Throws:
com.smartgridready.driver.api.common.GenDriverException- when gateway cannot be created
-
SGrModbusDevice
public SGrModbusDevice(com.smartgridready.ns.v0.DeviceFrame aDeviceDescription, com.smartgridready.driver.api.modbus.GenDriverAPI4Modbus aTransport)Construct with pre-defined transport (legacy method). Transport must be managed externally.- Parameters:
aDeviceDescription- the EID descriptionaTransport- the Modbus transport
-
-
Method Detail
-
connect
public void connect() throws com.smartgridready.driver.api.common.GenDriverExceptionDescription copied from interface:GenDeviceApiConnect the device.- Specified by:
connectin interfaceGenDeviceApi- Throws:
com.smartgridready.driver.api.common.GenDriverException- Generic error while reading from the device
-
disconnect
public void disconnect() throws com.smartgridready.driver.api.common.GenDriverExceptionDescription copied from interface:GenDeviceApiDisconnect the device.- Specified by:
disconnectin interfaceGenDeviceApi- Throws:
com.smartgridready.driver.api.common.GenDriverException- Generic error while reading from the device
-
isConnected
public boolean isConnected()
Description copied from interface:GenDeviceApiChecks if the device is connected.- Specified by:
isConnectedin interfaceGenDeviceApi- Returns:
- true if connected, false otherwise
-
getVal
public Value getVal(java.lang.String sProfileName, java.lang.String sDataPointName) throws com.smartgridready.driver.api.common.GenDriverException, com.smartgridready.driver.api.modbus.GenDriverSocketException, com.smartgridready.driver.api.modbus.GenDriverModbusException
Description copied from interface:GenDeviceApi4ModbusRead a value from the modbus device in its generic data point representation (seeValue).- Specified by:
getValin interfaceGenDeviceApi- Specified by:
getValin interfaceGenDeviceApi4Modbus- Parameters:
sProfileName- The name of the functional profile.sDataPointName- The name of the data point.- Returns:
- The value converted to
String - Throws:
com.smartgridready.driver.api.common.GenDriverException- If a general exception occurred.com.smartgridready.driver.api.modbus.GenDriverSocketException- In case of communication errors with the modbus device.com.smartgridready.driver.api.modbus.GenDriverModbusException- If the modbus command could not be interpreted/executed on the device.- See Also:
Value
-
getVal
public Value getVal(java.lang.String sProfileName, java.lang.String sDataPointName, java.util.Properties parameters) throws com.smartgridready.driver.api.common.GenDriverException, com.smartgridready.driver.api.modbus.GenDriverSocketException, com.smartgridready.driver.api.modbus.GenDriverModbusException
Description copied from interface:GenDeviceApiGet a value for a given data point, with request-specific parameters- Specified by:
getValin interfaceGenDeviceApi- Parameters:
sProfileName- The functional profile namesDataPointName- The data point nameparameters- Key value pairs with request parameters- Returns:
- The value read from the device
- Throws:
com.smartgridready.driver.api.common.GenDriverException- Generic error while reading from the devicecom.smartgridready.driver.api.modbus.GenDriverSocketException- A connection error occurredcom.smartgridready.driver.api.modbus.GenDriverModbusException- The modbus command returned an error code
-
setVal
public void setVal(java.lang.String sProfileName, java.lang.String sDataPointName, Value value) throws com.smartgridready.driver.api.common.GenDriverException, com.smartgridready.driver.api.modbus.GenDriverSocketException, com.smartgridready.driver.api.modbus.GenDriverModbusExceptionDescription copied from interface:GenDeviceApi4ModbusWrite a value to the modbus device using the generic data point representation (seeValue). The value is converted from the format given within thevalueparameter to the value required by the modbus device (as defined within the external interface XML of the device).- Specified by:
setValin interfaceGenDeviceApi- Specified by:
setValin interfaceGenDeviceApi4Modbus- Parameters:
sProfileName- The name of the functional profile.sDataPointName- The name of the data point.value- The value asValue- Throws:
com.smartgridready.driver.api.common.GenDriverException- If a general exception occurred.com.smartgridready.driver.api.modbus.GenDriverSocketException- In case of communication errors with the modbus device.com.smartgridready.driver.api.modbus.GenDriverModbusException- If the modbus command could not be interpreted/executed on the device.- See Also:
Value
-
findProfile
protected java.util.Optional<com.smartgridready.ns.v0.ModbusFunctionalProfile> findProfile(java.lang.String aProfileName)
Description copied from class:SGrDeviceBaseFinds a functional profile by name.- Specified by:
findProfilein classSGrDeviceBase<com.smartgridready.ns.v0.DeviceFrame,com.smartgridready.ns.v0.ModbusFunctionalProfile,com.smartgridready.ns.v0.ModbusDataPoint>- Parameters:
aProfileName- the name of the functional profile- Returns:
- an optional functional profile
-
findDataPointForProfile
protected java.util.Optional<com.smartgridready.ns.v0.ModbusDataPoint> findDataPointForProfile(com.smartgridready.ns.v0.ModbusFunctionalProfile aProfile, java.lang.String aDataPointName)Description copied from class:SGrDeviceBaseFinds a data point of a given functional profile by name.- Specified by:
findDataPointForProfilein classSGrDeviceBase<com.smartgridready.ns.v0.DeviceFrame,com.smartgridready.ns.v0.ModbusFunctionalProfile,com.smartgridready.ns.v0.ModbusDataPoint>- Parameters:
aProfile- the functional profileaDataPointName- the name of the data point to find- Returns:
- an optional data point
-
-