Class DataPoint
- java.lang.Object
-
- com.smartgridready.communicator.common.api.dto.DataPoint
-
public class DataPoint extends java.lang.ObjectImplements a generic data point facade.
-
-
Constructor Summary
Constructors Constructor Description DataPoint(java.lang.String name, java.lang.String functionalProfileName, DataTypeInfo dataType, com.smartgridready.ns.v0.Units unit, com.smartgridready.ns.v0.DataDirectionProduct permissions, java.lang.Double minimumValue, java.lang.Double maximumValue, java.lang.Integer arrayLen, java.util.List<GenericAttribute> genericAttributes, java.util.List<DynamicRequestParameter> dynamicRequestParameters, GenDeviceApi genDeviceApi)Constructs a data point.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidauthenticate()Deprecated, for removal: This API element is subject to removal in a future version.Since version 2.1.0.booleancanSubscribe()Tells if the device interface supports subscribe/unsubscribe.java.lang.IntegergetArrayLen()Gets the number of array elements of the data point value.DataTypeInfogetDataType()Gets the data type.java.util.List<DynamicRequestParameter>getDynamicRequestParameters()Gets the available dynamic request parameters that need to be provided asPropertieswhen calling the methodGenDeviceApi.getVal(String, String, Properties).java.lang.StringgetFunctionalProfileName()Gets the functional profile name.java.util.List<GenericAttribute>getGenericAttributes()Gets the generic attributes of the data point.java.lang.DoublegetMaximumValue()Gets the maximal allowed data point value forsetVal().java.lang.DoublegetMinimumValue()Gets the maximal allowed data point value forsetVal().java.lang.StringgetName()Gets the data point name.com.smartgridready.ns.v0.DataDirectionProductgetPermissions()Gets the read-write permissions of the data point.com.smartgridready.ns.v0.UnitsgetUnit()Gets the unit of measurement.ValuegetVal()Read the value from this data point.ValuegetVal(long timeoutMs)Gets a value from the device by reading.ValuegetVal(java.util.Properties parameters)Read the value from this data point, with request-specific parameters.ValuegetVal(java.util.Properties parameters, long timeoutMs)Gets a value from the device by reading.voidsetVal(Value value)Write a value to the data point.voidsubscribe(java.util.function.Consumer<io.vavr.control.Either<java.lang.Throwable,Value>> callbackFunction)Subscribes to messages that are related to the given data point.voidunsubscribe()Unsubscribes from messages that are related to a given data point.
-
-
-
Constructor Detail
-
DataPoint
public DataPoint(java.lang.String name, java.lang.String functionalProfileName, DataTypeInfo dataType, com.smartgridready.ns.v0.Units unit, com.smartgridready.ns.v0.DataDirectionProduct permissions, java.lang.Double minimumValue, java.lang.Double maximumValue, java.lang.Integer arrayLen, java.util.List<GenericAttribute> genericAttributes, java.util.List<DynamicRequestParameter> dynamicRequestParameters, GenDeviceApi genDeviceApi)Constructs a data point.- Parameters:
name- the data point namefunctionalProfileName- the functional profile namedataType- the data type and rangeunit- the unit of measurementpermissions- the read-write permissionsminimumValue- the minimal allowed valuemaximumValue- the maximal allowed valuearrayLen- the number of array elements, if the value is an arraygenericAttributes- the generic attributesdynamicRequestParameters- the dynamic request parametersgenDeviceApi- the device interface
-
-
Method Detail
-
getName
public java.lang.String getName()
Gets the data point name.- Returns:
- The data point name
-
getFunctionalProfileName
public java.lang.String getFunctionalProfileName()
Gets the functional profile name.- Returns:
- The functional profile name
-
getDataType
public DataTypeInfo getDataType()
Gets the data type.- Returns:
- The data type name and range
-
getUnit
public com.smartgridready.ns.v0.Units getUnit()
Gets the unit of measurement.- Returns:
- The units of the data point value
-
getPermissions
public com.smartgridready.ns.v0.DataDirectionProduct getPermissions()
Gets the read-write permissions of the data point.- Returns:
- The RW permissions
-
getMinimumValue
public java.lang.Double getMinimumValue()
Gets the maximal allowed data point value forsetVal().- Returns:
- The minimal allowed value
-
getMaximumValue
public java.lang.Double getMaximumValue()
Gets the maximal allowed data point value forsetVal().- Returns:
- The maximal allowed value
-
getArrayLen
public java.lang.Integer getArrayLen()
Gets the number of array elements of the data point value.- Returns:
- The array length if the data point represents an array of values, otherwise null
-
getGenericAttributes
public java.util.List<GenericAttribute> getGenericAttributes()
Gets the generic attributes of the data point.- Returns:
- A list of generic attributes for this data point.
-
getDynamicRequestParameters
public java.util.List<DynamicRequestParameter> getDynamicRequestParameters()
Gets the available dynamic request parameters that need to be provided asPropertieswhen calling the methodGenDeviceApi.getVal(String, String, Properties).- Returns:
- A list of the dynamic request parameters
-
getVal
public Value getVal() throws com.smartgridready.driver.api.common.GenDriverException, RestApiResponseParseException, com.smartgridready.driver.api.modbus.GenDriverModbusException, RestApiServiceCallException, com.smartgridready.driver.api.modbus.GenDriverSocketException, java.io.IOException
Read the value from this data point.- Returns:
- The value delivered by the device.
- Throws:
com.smartgridready.driver.api.common.GenDriverException- On a generic errorRestApiResponseParseException- If the web service response could not be parsedcom.smartgridready.driver.api.modbus.GenDriverModbusException- If the modbus command could not be processedRestApiServiceCallException- If web service call failedcom.smartgridready.driver.api.modbus.GenDriverSocketException- If the COM port socket unexpectedly closedjava.io.IOException- On generic IO operation errors
-
getVal
public Value getVal(java.util.Properties parameters) throws com.smartgridready.driver.api.common.GenDriverException, RestApiResponseParseException, com.smartgridready.driver.api.modbus.GenDriverModbusException, RestApiServiceCallException, com.smartgridready.driver.api.modbus.GenDriverSocketException, java.io.IOException
Read the value from this data point, with request-specific parameters.- Parameters:
parameters- Key value pairs with request parameters- Returns:
- The value delivered by the device.
- Throws:
com.smartgridready.driver.api.common.GenDriverException- On a generic errorRestApiResponseParseException- If the web service response could not be parsedcom.smartgridready.driver.api.modbus.GenDriverModbusException- If the modbus command could not be processedRestApiServiceCallException- If web service call failedcom.smartgridready.driver.api.modbus.GenDriverSocketException- If the COM port socket unexpectedly closedjava.io.IOException- On generic IO operation errors
-
setVal
public void setVal(Value value) throws com.smartgridready.driver.api.common.GenDriverException, RestApiResponseParseException, com.smartgridready.driver.api.modbus.GenDriverModbusException, RestApiServiceCallException, com.smartgridready.driver.api.modbus.GenDriverSocketException, java.io.IOException
Write a value to the data point.- Parameters:
value- The value to write- Throws:
com.smartgridready.driver.api.common.GenDriverException- On a generic errorRestApiResponseParseException- If the web service response could not be parsedcom.smartgridready.driver.api.modbus.GenDriverModbusException- If the modbus command could not be processedRestApiServiceCallException- If web service call failedcom.smartgridready.driver.api.modbus.GenDriverSocketException- If the COM port socket unexpectedly closedjava.io.IOException- On generic IO operation errors
-
authenticate
@Deprecated(since="2.1.0", forRemoval=true) public void authenticate() throws RestApiResponseParseException, RestApiAuthenticationException, RestApiServiceCallException, java.io.IOExceptionDeprecated, for removal: This API element is subject to removal in a future version.Since version 2.1.0.Does the authentication to access the web service if needed. Note: can be removed, as this is already covered by connect()- Throws:
RestApiResponseParseException- If the authentication response could not be parsedRestApiAuthenticationException- If the authentication could not be performedRestApiServiceCallException- If the REST API service call failedjava.io.IOException- If an IO operation error occurred
-
getVal
public Value getVal(long timeoutMs) throws com.smartgridready.driver.api.common.GenDriverException
Gets a value from the device by reading. This operation is supported for messaging devices only.- Parameters:
timeoutMs- 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.util.Properties parameters, long timeoutMs) throws com.smartgridready.driver.api.common.GenDriverException
Gets a value from the device by reading. This operation is supported for messaging devices only.- Parameters:
parameters- the dynamic request parameterstimeoutMs- The read timeout in milliseconds- Returns:
- The value received from the device
- Throws:
com.smartgridready.driver.api.common.GenDriverException- if an error occurs
-
subscribe
public void subscribe(java.util.function.Consumer<io.vavr.control.Either<java.lang.Throwable,Value>> callbackFunction) throws com.smartgridready.driver.api.common.GenDriverException
Subscribes to messages that are related to the given data point. This operation is supported for messaging devices only.- Parameters:
callbackFunction- A callback function that provides the received value- Throws:
com.smartgridready.driver.api.common.GenDriverException- if an error occurs
-
unsubscribe
public void unsubscribe() throws com.smartgridready.driver.api.common.GenDriverExceptionUnsubscribes from messages that are related to a given data point. This operation is supported for messaging devices only.- Throws:
com.smartgridready.driver.api.common.GenDriverException- if an error occurs
-
canSubscribe
public boolean canSubscribe()
Tells if the device interface supports subscribe/unsubscribe.- Returns:
- true if
-
-