Class SGrModbusDevice

    • Constructor Detail

      • SGrModbusDevice

        public SGrModbusDevice​(com.smartgridready.ns.v0.DeviceFrame aDeviceDescription,
                               com.smartgridready.driver.api.modbus.GenDriverAPI4ModbusFactory aDriverFactory,
                               ModbusGatewayRegistry aGatewayRegistry)
                        throws com.smartgridready.driver.api.common.GenDriverException
        Construct with pre-defined shared Modbus gateway registry.
        Parameters:
        aDeviceDescription - the EID description
        aDriverFactory - the Modbus gateway factory
        aGatewayRegistry - the shared Modbus gateway registry
        Throws:
        com.smartgridready.driver.api.common.GenDriverException - when gateway cannot be created
      • SGrModbusDevice

        public SGrModbusDevice​(com.smartgridready.ns.v0.DeviceFrame aDeviceDescription,
                               com.smartgridready.driver.api.modbus.GenDriverAPI4ModbusFactory aDriverFactory)
                        throws com.smartgridready.driver.api.common.GenDriverException
        Construct with custom Modbus gateway factory.
        Parameters:
        aDeviceDescription - the EID description
        aDriverFactory - the Modbus gateway factory
        Throws:
        com.smartgridready.driver.api.common.GenDriverException - when gateway cannot be created
      • SGrModbusDevice

        public SGrModbusDevice​(com.smartgridready.ns.v0.DeviceFrame aDeviceDescription,
                               com.smartgridready.driver.api.modbus.GenDriverAPI4Modbus aTransport)
        Construct with pre-defined transport (legacy method). Transport must be managed externally.
        Parameters:
        aDeviceDescription - the EID description
        aTransport - the Modbus transport
    • 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 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
      • getVal

        public Value getVal​(java.lang.String sProfileName,
                            java.lang.String sDataPointName)
                     throws com.smartgridready.driver.api.common.GenDriverException,
                            com.smartgridready.driver.api.modbus.GenDriverSocketException,
                            com.smartgridready.driver.api.modbus.GenDriverModbusException
        Description copied from interface: GenDeviceApi4Modbus
        Read a value from the modbus device in its generic data point representation (see Value).
        Specified by:
        getVal in interface GenDeviceApi
        Specified by:
        getVal in interface GenDeviceApi4Modbus
        Parameters:
        sProfileName - The name of the functional profile.
        sDataPointName - The name of the data point.
        Returns:
        The value converted to String
        Throws:
        com.smartgridready.driver.api.common.GenDriverException - If a general exception occurred.
        com.smartgridready.driver.api.modbus.GenDriverSocketException - In case of communication errors with the modbus device.
        com.smartgridready.driver.api.modbus.GenDriverModbusException - If the modbus command could not be interpreted/executed on the device.
        See Also:
        Value
      • getVal

        public Value getVal​(java.lang.String sProfileName,
                            java.lang.String sDataPointName,
                            java.util.Properties parameters)
                     throws com.smartgridready.driver.api.common.GenDriverException,
                            com.smartgridready.driver.api.modbus.GenDriverSocketException,
                            com.smartgridready.driver.api.modbus.GenDriverModbusException
        Description copied from interface: GenDeviceApi
        Get a value for a given data point, with request-specific parameters
        Specified by:
        getVal in interface GenDeviceApi
        Parameters:
        sProfileName - The functional profile name
        sDataPointName - 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
        com.smartgridready.driver.api.modbus.GenDriverSocketException - A connection error occurred
        com.smartgridready.driver.api.modbus.GenDriverModbusException - The modbus command returned an error code
      • setVal

        public void setVal​(java.lang.String sProfileName,
                           java.lang.String sDataPointName,
                           Value value)
                    throws com.smartgridready.driver.api.common.GenDriverException,
                           com.smartgridready.driver.api.modbus.GenDriverSocketException,
                           com.smartgridready.driver.api.modbus.GenDriverModbusException
        Description copied from interface: GenDeviceApi4Modbus
        Write a value to the modbus device using the generic data point representation (see Value). The value is converted from the format given within the value parameter to the value required by the modbus device (as defined within the external interface XML of the device).
        Specified by:
        setVal in interface GenDeviceApi
        Specified by:
        setVal in interface GenDeviceApi4Modbus
        Parameters:
        sProfileName - The name of the functional profile.
        sDataPointName - The name of the data point.
        value - The value as Value
        Throws:
        com.smartgridready.driver.api.common.GenDriverException - If a general exception occurred.
        com.smartgridready.driver.api.modbus.GenDriverSocketException - In case of communication errors with the modbus device.
        com.smartgridready.driver.api.modbus.GenDriverModbusException - If the modbus command could not be interpreted/executed on the device.
        See Also:
        Value
      • findProfile

        protected java.util.Optional<com.smartgridready.ns.v0.ModbusFunctionalProfile> findProfile​(java.lang.String aProfileName)
        Specified by:
        findProfile in class SGrDeviceBase<com.smartgridready.ns.v0.DeviceFrame,​com.smartgridready.ns.v0.ModbusFunctionalProfile,​com.smartgridready.ns.v0.ModbusDataPoint>
      • findDataPointForProfile

        protected java.util.Optional<com.smartgridready.ns.v0.ModbusDataPoint> findDataPointForProfile​(com.smartgridready.ns.v0.ModbusFunctionalProfile aProfile,
                                                                                                       java.lang.String aDataPointName)
        Specified by:
        findDataPointForProfile in class SGrDeviceBase<com.smartgridready.ns.v0.DeviceFrame,​com.smartgridready.ns.v0.ModbusFunctionalProfile,​com.smartgridready.ns.v0.ModbusDataPoint>