Class SGrMessagingDevice

    • 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 class SGrDeviceBase<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 class SGrDeviceBase<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 interface GenDeviceApi
        Parameters:
        profileName - The functional profile name
        dataPointName - 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 interface GenDeviceApi
        Parameters:
        profileName - The functional profile name
        dataPointName - The data point name
        parameters - 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 interface GenDeviceApi4Messaging
        Parameters:
        profileName - The functional profile name
        dataPointName - The data point name
        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.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 interface GenDeviceApi4Messaging
        Parameters:
        profileName - The functional profile name
        dataPointName - The data point name
        parameters - The request-specific 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
      • 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 interface GenDeviceApi
        Parameters:
        profileName - The functional profile name
        dataPointName - The data point name
        value - 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 interface GenDeviceApi
        Overrides:
        subscribe in class SGrDeviceBase<com.smartgridready.ns.v0.DeviceFrame,​com.smartgridready.ns.v0.MessagingFunctionalProfile,​com.smartgridready.ns.v0.MessagingDataPoint>
        Parameters:
        profileName - The functional profile name
        dataPointName - The data point name
        callbackFunction - 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 interface GenDeviceApi
        Overrides:
        unsubscribe in class SGrDeviceBase<com.smartgridready.ns.v0.DeviceFrame,​com.smartgridready.ns.v0.MessagingFunctionalProfile,​com.smartgridready.ns.v0.MessagingDataPoint>
        Parameters:
        profileName - The functional profile name
        dataPointName - 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 interface java.lang.AutoCloseable
        Specified by:
        close in interface java.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 interface GenDeviceApi
        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 interface GenDeviceApi
        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 interface GenDeviceApi
        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 interface GenDeviceApi
        Overrides:
        canSubscribe in class SGrDeviceBase<com.smartgridready.ns.v0.DeviceFrame,​com.smartgridready.ns.v0.MessagingFunctionalProfile,​com.smartgridready.ns.v0.MessagingDataPoint>
        Returns:
        true if subscribe possible, false otherwise