Class SGrDeviceBase<D extends com.smartgridready.ns.v0.DeviceFrame,F extends com.smartgridready.ns.v0.FunctionalProfileBase,P extends com.smartgridready.ns.v0.DataPointBase>
- java.lang.Object
-
- com.smartgridready.communicator.common.impl.SGrDeviceBase<D,F,P>
-
- All Implemented Interfaces:
GenDeviceApi
- Direct Known Subclasses:
SGrContactsDevice
,SGrGenericDevice
,SGrMessagingDevice
,SGrModbusDevice
,SGrRestApiDevice
public abstract class SGrDeviceBase<D extends com.smartgridready.ns.v0.DeviceFrame,F extends com.smartgridready.ns.v0.FunctionalProfileBase,P extends com.smartgridready.ns.v0.DataPointBase> extends java.lang.Object implements GenDeviceApi
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SGrDeviceBase.Comparator
static class
SGrDeviceBase.RwpDirections
-
Constructor Summary
Constructors Modifier Constructor Description protected
SGrDeviceBase(D device)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected static <P extends com.smartgridready.ns.v0.DataPointBase>
ValueapplyUnitConversion(P dataPoint, Value value, java.util.function.DoubleBinaryOperator conversionFunction)
boolean
canSubscribe()
Checks whether the device can subscribe to data points.protected java.util.Optional<java.lang.String>
checkOutOfRange(Value[] values, double limit, SGrDeviceBase.Comparator comparator)
void
checkOutOfRange(Value[] values, com.smartgridready.ns.v0.DataPointBase dataPoint)
void
checkReadWritePermission(com.smartgridready.ns.v0.DataPointBase dataPoint, SGrDeviceBase.RwpDirections direction)
protected static double
divide(double dividend, double divisor)
protected P
findDataPoint(java.lang.String profileName, java.lang.String dataPointName)
protected abstract java.util.Optional<P>
findDataPointForProfile(F functionalProfile, java.lang.String dataPointName)
protected abstract java.util.Optional<F>
findProfile(java.lang.String profileName)
DataPoint
getDataPoint(java.lang.String functionalProfileName, java.lang.String dataPointName)
Get a data pointjava.util.List<DataPoint>
getDataPoints(java.lang.String functionalProfileName)
Get all data points of a functional profilejava.util.List<ConfigurationValue>
getDeviceConfigurationInfo()
Get the device interface configuration parametersDeviceInfo
getDeviceInfo()
Get device informationFunctionalProfile
getFunctionalProfile(java.lang.String functionalProfileName)
Get a functional profilejava.util.List<FunctionalProfile>
getFunctionalProfiles()
Get all functional profilesjava.util.List<DataPointValue>
getValues()
Get value of all data points in one goprotected static boolean
isNumeric(Value value)
protected static double
multiply(double factor1, double factor2)
void
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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.smartgridready.communicator.common.api.GenDeviceApi
connect, disconnect, getVal, getVal, isConnected, setVal
-
-
-
-
Field Detail
-
device
protected final D extends com.smartgridready.ns.v0.DeviceFrame device
-
-
Constructor Detail
-
SGrDeviceBase
protected SGrDeviceBase(D device)
-
-
Method Detail
-
findProfile
protected abstract java.util.Optional<F> findProfile(java.lang.String profileName)
-
findDataPointForProfile
protected abstract java.util.Optional<P> findDataPointForProfile(F functionalProfile, java.lang.String dataPointName)
-
findDataPoint
protected P findDataPoint(java.lang.String profileName, java.lang.String dataPointName) throws com.smartgridready.driver.api.common.GenDriverException
- Throws:
com.smartgridready.driver.api.common.GenDriverException
-
checkOutOfRange
public void checkOutOfRange(Value[] values, com.smartgridready.ns.v0.DataPointBase dataPoint) throws com.smartgridready.driver.api.common.GenDriverException
- Throws:
com.smartgridready.driver.api.common.GenDriverException
-
checkReadWritePermission
public void checkReadWritePermission(com.smartgridready.ns.v0.DataPointBase dataPoint, SGrDeviceBase.RwpDirections direction) throws com.smartgridready.driver.api.common.GenDriverException
- Throws:
com.smartgridready.driver.api.common.GenDriverException
-
checkOutOfRange
protected java.util.Optional<java.lang.String> checkOutOfRange(Value[] values, double limit, SGrDeviceBase.Comparator comparator) throws com.smartgridready.driver.api.common.GenDriverException
- Throws:
com.smartgridready.driver.api.common.GenDriverException
-
getDeviceInfo
public DeviceInfo getDeviceInfo() throws com.smartgridready.driver.api.common.GenDriverException
Description copied from interface:GenDeviceApi
Get device information- Specified by:
getDeviceInfo
in interfaceGenDeviceApi
- Returns:
- The device information
- Throws:
com.smartgridready.driver.api.common.GenDriverException
- Generic error while reading from the device
-
getDeviceConfigurationInfo
public java.util.List<ConfigurationValue> getDeviceConfigurationInfo()
Description copied from interface:GenDeviceApi
Get the device interface configuration parameters- Specified by:
getDeviceConfigurationInfo
in interfaceGenDeviceApi
- Returns:
- The configuration parameter list
-
getFunctionalProfiles
public java.util.List<FunctionalProfile> getFunctionalProfiles() throws com.smartgridready.driver.api.common.GenDriverException
Description copied from interface:GenDeviceApi
Get all functional profiles- Specified by:
getFunctionalProfiles
in interfaceGenDeviceApi
- Returns:
- The functional profiles
- Throws:
com.smartgridready.driver.api.common.GenDriverException
- Generic error while reading from the device
-
getFunctionalProfile
public FunctionalProfile getFunctionalProfile(java.lang.String functionalProfileName) throws com.smartgridready.driver.api.common.GenDriverException
Description copied from interface:GenDeviceApi
Get a functional profile- Specified by:
getFunctionalProfile
in interfaceGenDeviceApi
- Parameters:
functionalProfileName
- The name of the functional profile- Returns:
- The functional profile
- Throws:
com.smartgridready.driver.api.common.GenDriverException
- Generic error while reading from the device
-
getDataPoints
public java.util.List<DataPoint> getDataPoints(java.lang.String functionalProfileName) throws com.smartgridready.driver.api.common.GenDriverException
Description copied from interface:GenDeviceApi
Get all data points of a functional profile- Specified by:
getDataPoints
in interfaceGenDeviceApi
- Parameters:
functionalProfileName
- The name of the functional profile- Returns:
- The data points
- Throws:
com.smartgridready.driver.api.common.GenDriverException
- Generic error while reading from the device
-
getDataPoint
public DataPoint getDataPoint(java.lang.String functionalProfileName, java.lang.String dataPointName) throws com.smartgridready.driver.api.common.GenDriverException
Description copied from interface:GenDeviceApi
Get a data point- Specified by:
getDataPoint
in interfaceGenDeviceApi
- Parameters:
functionalProfileName
- The name of the functional profiledataPointName
- The name of the data point- Returns:
- The data point
- Throws:
com.smartgridready.driver.api.common.GenDriverException
- Generic error while reading from the device
-
getValues
public java.util.List<DataPointValue> getValues() throws com.smartgridready.driver.api.common.GenDriverException
Description copied from interface:GenDeviceApi
Get value of all data points in one go- Specified by:
getValues
in interfaceGenDeviceApi
- Returns:
- The values read from the device, by data point
- Throws:
com.smartgridready.driver.api.common.GenDriverException
- Generic error while reading from the device
-
canSubscribe
public boolean canSubscribe()
Description copied from interface:GenDeviceApi
Checks whether the device can subscribe to data points.- Specified by:
canSubscribe
in interfaceGenDeviceApi
- Returns:
- true if subscribe possible, false otherwise
-
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
- 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
- Parameters:
profileName
- The functional profile namedataPointName
- The data point name- Throws:
com.smartgridready.driver.api.common.GenDriverException
- if an error occurs
-
applyUnitConversion
protected static <P extends com.smartgridready.ns.v0.DataPointBase> Value applyUnitConversion(P dataPoint, Value value, java.util.function.DoubleBinaryOperator conversionFunction)
-
isNumeric
protected static boolean isNumeric(Value value)
-
divide
protected static double divide(double dividend, double divisor)
-
multiply
protected static double multiply(double factor1, double factor2)
-
-