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
-
-
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)
SGrMessagingDevice(com.smartgridready.ns.v0.DeviceFrame deviceDescription, java.util.Map<com.smartgridready.driver.api.messaging.model.MessagingPlatformType,com.smartgridready.driver.api.messaging.GenMessagingClientFactory> messagingClientFactories)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canSubscribe()
Checks whether the device can subscribe to data points.void
close()
void
connect()
Connect the device.void
disconnect()
Disconnect the device.protected java.util.Optional<com.smartgridready.ns.v0.MessagingDataPoint>
findDataPointForProfile(com.smartgridready.ns.v0.MessagingFunctionalProfile functionalProfile, java.lang.String dataPointName)
protected java.util.Optional<com.smartgridready.ns.v0.MessagingFunctionalProfile>
findProfile(java.lang.String profileName)
Value
getVal(java.lang.String profileName, java.lang.String dataPointName)
Get a value for a given data pointValue
getVal(java.lang.String profileName, java.lang.String dataPointName, long timeoutMs)
Gets a value from the device by readingValue
getVal(java.lang.String profileName, java.lang.String dataPointName, java.util.Properties parameters)
Get a value for a given data point, with request-specific parametersValue
getVal(java.lang.String profileName, java.lang.String dataPointName, java.util.Properties parameters, long timeoutMs)
Gets a value from the device by readingboolean
isConnected()
Checks if the device is connected.void
setVal(java.lang.String profileName, java.lang.String dataPointName, Value value)
Set a value for a given data pointvoid
subscribe(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 pointvoid
unsubscribe(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.GenDriverException
- Throws:
com.smartgridready.driver.api.common.GenDriverException
-
SGrMessagingDevice
public SGrMessagingDevice(com.smartgridready.ns.v0.DeviceFrame deviceDescription, com.smartgridready.driver.api.messaging.GenMessagingClientFactory messagingClientFactory) throws com.smartgridready.driver.api.common.GenDriverException
- Throws:
com.smartgridready.driver.api.common.GenDriverException
-
-
Method Detail
-
findProfile
protected java.util.Optional<com.smartgridready.ns.v0.MessagingFunctionalProfile> findProfile(java.lang.String profileName)
- Specified by:
findProfile
in classSGrDeviceBase<com.smartgridready.ns.v0.DeviceFrame,com.smartgridready.ns.v0.MessagingFunctionalProfile,com.smartgridready.ns.v0.MessagingDataPoint>
-
findDataPointForProfile
protected java.util.Optional<com.smartgridready.ns.v0.MessagingDataPoint> findDataPointForProfile(com.smartgridready.ns.v0.MessagingFunctionalProfile functionalProfile, java.lang.String dataPointName)
- Specified by:
findDataPointForProfile
in classSGrDeviceBase<com.smartgridready.ns.v0.DeviceFrame,com.smartgridready.ns.v0.MessagingFunctionalProfile,com.smartgridready.ns.v0.MessagingDataPoint>
-
getVal
public Value getVal(java.lang.String profileName, java.lang.String dataPointName) throws com.smartgridready.driver.api.common.GenDriverException
Description copied from interface:GenDeviceApi
Get a value for a given data point- Specified by:
getVal
in 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:GenDeviceApi
Get a value for a given data point, with request-specific parameters- Specified by:
getVal
in 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:GenDeviceApi4Messaging
Gets a value from the device by reading- Specified by:
getVal
in 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:GenDeviceApi4Messaging
Gets a value from the device by reading- Specified by:
getVal
in 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.GenDriverException
Description copied from interface:GenDeviceApi
Set a value for a given data point- Specified by:
setVal
in 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.GenDriverException
Description copied from interface:GenDeviceApi
Subscribes to messages that are related to the given data point- Specified by:
subscribe
in interfaceGenDeviceApi
- Overrides:
subscribe
in 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.GenDriverException
Description copied from interface:GenDeviceApi
Unsubscribes from messages that are related to a given data point- Specified by:
unsubscribe
in interfaceGenDeviceApi
- Overrides:
unsubscribe
in 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:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
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
-
canSubscribe
public boolean canSubscribe()
Description copied from interface:GenDeviceApi
Checks whether the device can subscribe to data points.- Specified by:
canSubscribe
in interfaceGenDeviceApi
- Overrides:
canSubscribe
in classSGrDeviceBase<com.smartgridready.ns.v0.DeviceFrame,com.smartgridready.ns.v0.MessagingFunctionalProfile,com.smartgridready.ns.v0.MessagingDataPoint>
- Returns:
- true if subscribe possible, false otherwise
-
-