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
-
-
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 void
connect()
Connect the device.void
disconnect()
Disconnect the device.protected java.util.Optional<com.smartgridready.ns.v0.ModbusDataPoint>
findDataPointForProfile(com.smartgridready.ns.v0.ModbusFunctionalProfile aProfile, java.lang.String aDataPointName)
protected java.util.Optional<com.smartgridready.ns.v0.ModbusFunctionalProfile>
findProfile(java.lang.String aProfileName)
Value
getVal(java.lang.String sProfileName, java.lang.String sDataPointName)
Read a value from the modbus device in its generic data point representation (seeValue
).Value
getVal(java.lang.String sProfileName, java.lang.String sDataPointName, java.util.Properties parameters)
Get a value for a given data point, with request-specific parametersboolean
isConnected()
Checks if the device is connected.void
setVal(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.GenDriverException
Construct 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.GenDriverException
Construct 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.GenDriverException
Description copied from interface:GenDeviceApi
Connect the device.- Specified by:
connect
in 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.GenDriverException
Description copied from interface:GenDeviceApi
Disconnect the device.- Specified by:
disconnect
in interfaceGenDeviceApi
- Throws:
com.smartgridready.driver.api.common.GenDriverException
- Generic error while reading from the device
-
isConnected
public boolean isConnected()
Description copied from interface:GenDeviceApi
Checks if the device is connected.- Specified by:
isConnected
in 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:GenDeviceApi4Modbus
Read a value from the modbus device in its generic data point representation (seeValue
).- Specified by:
getVal
in interfaceGenDeviceApi
- Specified by:
getVal
in 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:GenDeviceApi
Get a value for a given data point, with request-specific parameters- Specified by:
getVal
in 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.GenDriverModbusException
Description copied from interface:GenDeviceApi4Modbus
Write a value to the modbus device using the generic data point representation (seeValue
). The value is converted from the format given within thevalue
parameter to the value required by the modbus device (as defined within the external interface XML of the device).- Specified by:
setVal
in interfaceGenDeviceApi
- Specified by:
setVal
in 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)
- Specified by:
findProfile
in classSGrDeviceBase<com.smartgridready.ns.v0.DeviceFrame,com.smartgridready.ns.v0.ModbusFunctionalProfile,com.smartgridready.ns.v0.ModbusDataPoint>
-
findDataPointForProfile
protected java.util.Optional<com.smartgridready.ns.v0.ModbusDataPoint> findDataPointForProfile(com.smartgridready.ns.v0.ModbusFunctionalProfile aProfile, java.lang.String aDataPointName)
- Specified by:
findDataPointForProfile
in classSGrDeviceBase<com.smartgridready.ns.v0.DeviceFrame,com.smartgridready.ns.v0.ModbusFunctionalProfile,com.smartgridready.ns.v0.ModbusDataPoint>
-
-