Class SGrRestApiDevice
- java.lang.Object
-
- com.smartgridready.communicator.common.impl.SGrDeviceBase<com.smartgridready.ns.v0.DeviceFrame,com.smartgridready.ns.v0.RestApiFunctionalProfile,com.smartgridready.ns.v0.RestApiDataPoint>
-
- com.smartgridready.communicator.rest.impl.SGrRestApiDevice
-
- All Implemented Interfaces:
GenDeviceApi
,GenDeviceApi4Rest
public class SGrRestApiDevice extends SGrDeviceBase<com.smartgridready.ns.v0.DeviceFrame,com.smartgridready.ns.v0.RestApiFunctionalProfile,com.smartgridready.ns.v0.RestApiDataPoint> implements GenDeviceApi4Rest
-
-
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 SGrRestApiDevice(com.smartgridready.ns.v0.DeviceFrame deviceDescription, com.smartgridready.driver.api.http.GenHttpClientFactory httpClientFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
authenticate()
Authenticates the REST API client.void
connect()
Connect the device.void
disconnect()
Disconnect the device.protected java.util.Optional<com.smartgridready.ns.v0.RestApiDataPoint>
findDataPointForProfile(com.smartgridready.ns.v0.RestApiFunctionalProfile aProfile, java.lang.String aDataPointName)
protected java.util.Optional<com.smartgridready.ns.v0.RestApiFunctionalProfile>
findProfile(java.lang.String profileName)
Value
getVal(java.lang.String profileName, java.lang.String dataPointName)
Reads a value in its string representation from the REST API device.Value
getVal(java.lang.String profileName, java.lang.String dataPointName, java.util.Properties parameters)
Reads a value in its string representation from the REST API device.boolean
isConnected()
Checks if the device is connected.void
setVal(java.lang.String profileName, java.lang.String dataPointName, Value value)
Writes a value to the REST API device.-
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
-
SGrRestApiDevice
public SGrRestApiDevice(com.smartgridready.ns.v0.DeviceFrame deviceDescription, com.smartgridready.driver.api.http.GenHttpClientFactory httpClientFactory) throws RestApiAuthenticationException
- Throws:
RestApiAuthenticationException
-
-
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
-
authenticate
public void authenticate() throws RestApiAuthenticationException, java.io.IOException, RestApiServiceCallException, RestApiResponseParseException
Description copied from interface:GenDeviceApi4Rest
Authenticates the REST API client. Authenticate uses the authentication method and credentials given within the external interface description XML of the device. The credentials may be given as parameters when loading theSGrRestApiDevice
using the properties parameter of theDeviceDescriptionLoader
.- Specified by:
authenticate
in interfaceGenDeviceApi4Rest
- Throws:
RestApiAuthenticationException
- If the authentication failed.java.io.IOException
- If the communication with the server failed.RestApiServiceCallException
- If the service call could not be executed on the remote side.RestApiResponseParseException
- If parsing of the service response failed.- See Also:
SGrRestApiDevice
,DeviceDescriptionLoader
-
getVal
public Value getVal(java.lang.String profileName, java.lang.String dataPointName) throws java.io.IOException, RestApiServiceCallException, RestApiResponseParseException, com.smartgridready.driver.api.common.GenDriverException
Description copied from interface:GenDeviceApi4Rest
Reads a value in its string representation from the REST API device.- Specified by:
getVal
in interfaceGenDeviceApi
- Specified by:
getVal
in interfaceGenDeviceApi4Rest
- Parameters:
profileName
- The name of the functional profile.dataPointName
- The name of the data point within the functional profile.- Returns:
- The value read from the device.
- Throws:
java.io.IOException
- If the communication with the server failed.RestApiServiceCallException
- If the service call could not be executed on the remote side.RestApiResponseParseException
- If parsing of the service response failed.com.smartgridready.driver.api.common.GenDriverException
- If a common error occured.
-
getVal
public Value getVal(java.lang.String profileName, java.lang.String dataPointName, java.util.Properties parameters) throws java.io.IOException, RestApiServiceCallException, RestApiResponseParseException, com.smartgridready.driver.api.common.GenDriverException
Description copied from interface:GenDeviceApi4Rest
Reads a value in its string representation from the REST API device.- Specified by:
getVal
in interfaceGenDeviceApi
- Specified by:
getVal
in interfaceGenDeviceApi4Rest
- Parameters:
profileName
- The name of the functional profile.dataPointName
- The name of the data point within the functional profile.parameters
- Key value pairs with request parameters- Returns:
- The value read from the device.
- Throws:
java.io.IOException
- If the communication with the server failed.RestApiServiceCallException
- If the service call could not be executed on the remote side.RestApiResponseParseException
- If parsing of the service response failed.com.smartgridready.driver.api.common.GenDriverException
- If a common error occurred.
-
setVal
public void setVal(java.lang.String profileName, java.lang.String dataPointName, Value value) throws java.io.IOException, RestApiServiceCallException, RestApiResponseParseException, com.smartgridready.driver.api.common.GenDriverException
Description copied from interface:GenDeviceApi4Rest
Writes a value to the REST API device. The value may be provided as:- single string value
- http request body on json or XML
- Specified by:
setVal
in interfaceGenDeviceApi
- Specified by:
setVal
in interfaceGenDeviceApi4Rest
- Parameters:
profileName
- The name of the functional profile.dataPointName
- The name of the data point within the functional profile.value
- The value to be written. Will replace the value tagged with[[value]]
within the external interfaceRestApiServiceCall
element for the given data point.- Throws:
java.io.IOException
- If the communication with the server failed.RestApiServiceCallException
- If the service call could not be executed on the remote side.RestApiResponseParseException
- If parsing of the service response failed.com.smartgridready.driver.api.common.GenDriverException
- If a common error occurred.
-
findProfile
protected java.util.Optional<com.smartgridready.ns.v0.RestApiFunctionalProfile> findProfile(java.lang.String profileName)
- Specified by:
findProfile
in classSGrDeviceBase<com.smartgridready.ns.v0.DeviceFrame,com.smartgridready.ns.v0.RestApiFunctionalProfile,com.smartgridready.ns.v0.RestApiDataPoint>
-
findDataPointForProfile
protected java.util.Optional<com.smartgridready.ns.v0.RestApiDataPoint> findDataPointForProfile(com.smartgridready.ns.v0.RestApiFunctionalProfile aProfile, java.lang.String aDataPointName)
- Specified by:
findDataPointForProfile
in classSGrDeviceBase<com.smartgridready.ns.v0.DeviceFrame,com.smartgridready.ns.v0.RestApiFunctionalProfile,com.smartgridready.ns.v0.RestApiDataPoint>
-
-