Class SGrMessagingDevice
- java.lang.Object
-
- com.smartgridready.communicator.common.impl.SGrDeviceBase<com.smartgridready.ns.v0.DeviceFrame,com.smartgridready.ns.v0.MessagingFunctionalProfile,com.smartgridready.ns.v0.MessagingDataPoint>
-
- com.smartgridready.communicator.messaging.impl.SGrMessagingDevice
-
- All Implemented Interfaces:
GenDeviceApi,GenDeviceApi4Messaging,java.io.Closeable,java.lang.AutoCloseable
public class SGrMessagingDevice extends SGrDeviceBase<com.smartgridready.ns.v0.DeviceFrame,com.smartgridready.ns.v0.MessagingFunctionalProfile,com.smartgridready.ns.v0.MessagingDataPoint> implements GenDeviceApi4Messaging
Implements a messaging-based 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 SGrMessagingDevice(com.smartgridready.ns.v0.DeviceFrame deviceDescription, com.smartgridready.driver.api.messaging.GenMessagingClientFactory messagingClientFactory)Constructs a new instance.SGrMessagingDevice(com.smartgridready.ns.v0.DeviceFrame deviceDescription, java.util.Map<com.smartgridready.driver.api.messaging.model.MessagingPlatformType,com.smartgridready.driver.api.messaging.GenMessagingClientFactory> messagingClientFactories)Constructs a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanSubscribe()Checks whether the device can subscribe to data points.voidclose()voidconnect()Connect the device.voiddisconnect()Disconnect the device.protected java.util.Optional<com.smartgridready.ns.v0.MessagingDataPoint>findDataPointForProfile(com.smartgridready.ns.v0.MessagingFunctionalProfile functionalProfile, java.lang.String dataPointName)Finds a data point of a given functional profile by name.protected java.util.Optional<com.smartgridready.ns.v0.MessagingFunctionalProfile>findProfile(java.lang.String profileName)Finds a functional profile by name.ValuegetVal(java.lang.String profileName, java.lang.String dataPointName)Get a value for a given data pointValuegetVal(java.lang.String profileName, java.lang.String dataPointName, long timeoutMs)Gets a value from the device by readingValuegetVal(java.lang.String profileName, java.lang.String dataPointName, java.util.Properties parameters)Get a value for a given data point, with request-specific parametersValuegetVal(java.lang.String profileName, java.lang.String dataPointName, java.util.Properties parameters, long timeoutMs)Gets a value from the device by readingbooleanisConnected()Checks if the device is connected.voidsetVal(java.lang.String profileName, java.lang.String dataPointName, Value value)Set a value for a given data pointvoidsubscribe(java.lang.String profileName, java.lang.String dataPointName, java.util.function.Consumer<io.vavr.control.Either<java.lang.Throwable,Value>> callbackFunction)Subscribes to messages that are related to the given data pointvoidunsubscribe(java.lang.String profileName, java.lang.String dataPointName)Unsubscribes from messages that are related to a given data point-
Methods inherited from class com.smartgridready.communicator.common.impl.SGrDeviceBase
applyUnitConversion, checkOutOfRange, checkOutOfRange, checkReadWritePermission, divide, findDataPoint, getDataPoint, getDataPoints, getDeviceConfigurationInfo, getDeviceInfo, getFunctionalProfile, getFunctionalProfiles, getValues, isNumeric, multiply
-
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
getDataPoint, getDataPoints, getDeviceConfigurationInfo, getDeviceInfo, getFunctionalProfile, getFunctionalProfiles, getValues
-
-
-
-
Constructor Detail
-
SGrMessagingDevice
public SGrMessagingDevice(com.smartgridready.ns.v0.DeviceFrame deviceDescription, java.util.Map<com.smartgridready.driver.api.messaging.model.MessagingPlatformType,com.smartgridready.driver.api.messaging.GenMessagingClientFactory> messagingClientFactories) throws com.smartgridready.driver.api.common.GenDriverExceptionConstructs a new instance.- Parameters:
deviceDescription- the EID descriptionmessagingClientFactories- a list of messaging client factory implementations, can support multiple protocols- Throws:
com.smartgridready.driver.api.common.GenDriverException- on generic error
-
SGrMessagingDevice
public SGrMessagingDevice(com.smartgridready.ns.v0.DeviceFrame deviceDescription, com.smartgridready.driver.api.messaging.GenMessagingClientFactory messagingClientFactory) throws com.smartgridready.driver.api.common.GenDriverExceptionConstructs a new instance.- Parameters:
deviceDescription- the EID descriptionmessagingClientFactory- the protocol-specific messaging client factory implementation- Throws:
com.smartgridready.driver.api.common.GenDriverException- on generic error
-
-
Method Detail
-
findProfile
protected java.util.Optional<com.smartgridready.ns.v0.MessagingFunctionalProfile> findProfile(java.lang.String profileName)
Description copied from class:SGrDeviceBaseFinds a functional profile by name.- Specified by:
findProfilein classSGrDeviceBase<com.smartgridready.ns.v0.DeviceFrame,com.smartgridready.ns.v0.MessagingFunctionalProfile,com.smartgridready.ns.v0.MessagingDataPoint>- Parameters:
profileName- the name of the functional profile- Returns:
- an optional functional profile
-
findDataPointForProfile
protected java.util.Optional<com.smartgridready.ns.v0.MessagingDataPoint> findDataPointForProfile(com.smartgridready.ns.v0.MessagingFunctionalProfile functionalProfile, java.lang.String dataPointName)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.MessagingFunctionalProfile,com.smartgridready.ns.v0.MessagingDataPoint>- Parameters:
functionalProfile- the functional profiledataPointName- the name of the data point to find- Returns:
- an optional data point
-
getVal
public Value getVal(java.lang.String profileName, java.lang.String dataPointName) throws com.smartgridready.driver.api.common.GenDriverException
Description copied from interface:GenDeviceApiGet a value for a given data point- Specified by:
getValin interfaceGenDeviceApi- Parameters:
profileName- The functional profile namedataPointName- The data point name- Returns:
- The value read from the device
- Throws:
com.smartgridready.driver.api.common.GenDriverException- Generic error while reading from the device
-
getVal
public Value getVal(java.lang.String profileName, java.lang.String dataPointName, java.util.Properties parameters) throws com.smartgridready.driver.api.common.GenDriverException
Description copied from interface:GenDeviceApiGet a value for a given data point, with request-specific parameters- Specified by:
getValin interfaceGenDeviceApi- Parameters:
profileName- The functional profile namedataPointName- 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 device
-
getVal
public Value getVal(java.lang.String profileName, java.lang.String dataPointName, long timeoutMs) throws com.smartgridready.driver.api.common.GenDriverException
Description copied from interface:GenDeviceApi4MessagingGets a value from the device by reading- Specified by:
getValin interfaceGenDeviceApi4Messaging- Parameters:
profileName- The functional profile namedataPointName- The data point nametimeoutMs- The read timeout in milliseconds- Returns:
- The value received from the device
- Throws:
com.smartgridready.driver.api.common.GenDriverException- if an error occurs
-
getVal
public Value getVal(java.lang.String profileName, java.lang.String dataPointName, java.util.Properties parameters, long timeoutMs) throws com.smartgridready.driver.api.common.GenDriverException
Description copied from interface:GenDeviceApi4MessagingGets a value from the device by reading- Specified by:
getValin interfaceGenDeviceApi4Messaging- Parameters:
profileName- The functional profile namedataPointName- The data point nameparameters- The request-specific parameterstimeoutMs- The read timeout in milliseconds- Returns:
- The value received from the device
- Throws:
com.smartgridready.driver.api.common.GenDriverException- if an error occurs
-
setVal
public void setVal(java.lang.String profileName, java.lang.String dataPointName, Value value) throws com.smartgridready.driver.api.common.GenDriverExceptionDescription copied from interface:GenDeviceApiSet a value for a given data point- Specified by:
setValin interfaceGenDeviceApi- Parameters:
profileName- The functional profile namedataPointName- The data point namevalue- The value to be set- Throws:
com.smartgridready.driver.api.common.GenDriverException- Generic error while reading from the device
-
subscribe
public void subscribe(java.lang.String profileName, java.lang.String dataPointName, java.util.function.Consumer<io.vavr.control.Either<java.lang.Throwable,Value>> callbackFunction) throws com.smartgridready.driver.api.common.GenDriverExceptionDescription copied from interface:GenDeviceApiSubscribes to messages that are related to the given data point- Specified by:
subscribein interfaceGenDeviceApi- Overrides:
subscribein classSGrDeviceBase<com.smartgridready.ns.v0.DeviceFrame,com.smartgridready.ns.v0.MessagingFunctionalProfile,com.smartgridready.ns.v0.MessagingDataPoint>- Parameters:
profileName- The functional profile namedataPointName- The data point namecallbackFunction- A callback function that provides the received value- Throws:
com.smartgridready.driver.api.common.GenDriverException- if an error occurs
-
unsubscribe
public void unsubscribe(java.lang.String profileName, java.lang.String dataPointName) throws com.smartgridready.driver.api.common.GenDriverExceptionDescription copied from interface:GenDeviceApiUnsubscribes from messages that are related to a given data point- Specified by:
unsubscribein interfaceGenDeviceApi- Overrides:
unsubscribein classSGrDeviceBase<com.smartgridready.ns.v0.DeviceFrame,com.smartgridready.ns.v0.MessagingFunctionalProfile,com.smartgridready.ns.v0.MessagingDataPoint>- Parameters:
profileName- The functional profile namedataPointName- The data point name- Throws:
com.smartgridready.driver.api.common.GenDriverException- if an error occurs
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
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
-
canSubscribe
public boolean canSubscribe()
Description copied from interface:GenDeviceApiChecks whether the device can subscribe to data points.- Specified by:
canSubscribein interfaceGenDeviceApi- Overrides:
canSubscribein classSGrDeviceBase<com.smartgridready.ns.v0.DeviceFrame,com.smartgridready.ns.v0.MessagingFunctionalProfile,com.smartgridready.ns.v0.MessagingDataPoint>- Returns:
- true if subscribe possible, false otherwise
-
-