Interface InstructionHandler

All Known Implementing Classes:
DefaultDatumService, DefaultOperationalModesService, SimpleNodeControlsService, SimpleNodeSettingsService

public interface InstructionHandler
API to be implemented by a service that can handle instructions.
Version:
2.2
Author:
matt
  • Field Details

    • TOPIC_SET_CONTROL_PARAMETER

      static final String TOPIC_SET_CONTROL_PARAMETER
      The instruction topic for setting control parameters.

      By convention the instruction should have a parameter whose key is the ID of the control to change and whose value is some control-specific data.

      See Also:
    • TOPIC_DEMAND_BALANCE

      static final String TOPIC_DEMAND_BALANCE
      The instruction topic for balancing power generation to power demand.

      By convention the instruction should have a parameter whose key is the ID of the control that should respond to the balancing request and whose value is an integer percentage (0 - 100) of the maximum desired power generation capacity.

      Since:
      1.1
      See Also:
    • TOPIC_SHED_LOAD

      static final String TOPIC_SHED_LOAD
      The instruction topic for a request to reduce power demand.

      By convention the instruction should have a parameter whose key is the ID of the control that should respond to the shed request and whose value is an integer representing the amount of power, in watts, requested to be shed. If the requested power is 0 then any restriction on power should be removed, so that no limit is placed.

      Since:
      1.2
      See Also:
    • TOPIC_SET_OPERATING_STATE

      static final String TOPIC_SET_OPERATING_STATE
      The instruction topic for a request to change the DeviceOperatingState of a device.

      By convention the instruction should have a parameter whose key is the ID of the control that should respond to the request and whose value is either an integer representing a DeviceOperatingState.getCode() value or a string representing a Enum.name().

      Since:
      1.3
      See Also:
    • TOPIC_SIGNAL

      static final String TOPIC_SIGNAL
      The instruction topic for a request to signal a control or device.

      By convention the instruction should have a parameter whose key is the ID of the control that should respond to the request and whose value is a string representing the signal name. Signal names are control/device specific.

      Since:
      1.4
      See Also:
    • TOPIC_SYSTEM_CONFIGURE

      static final String TOPIC_SYSTEM_CONFIGURE
      The instruction topic for applying system configuration.

      A PARAM_SERVICE parameter must be provided that specifies the system service to apply the configuration to. Each service may define additional parameters that can be configured.

      Since:
      1.5
      See Also:
    • PARAM_SERVICE

      static final String PARAM_SERVICE
      An instruction parameter for a service name.

      The nature of this parameter depends on the topic it is associated with. Generally it is meant to refer to the name of some service to be operated on.

      Since:
      1.5
      See Also:
    • PARAM_SERVICE_ARGUMENT

      static final String PARAM_SERVICE_ARGUMENT
      An instruction parameter for a service argument.

      The nature of this parameter depends on the topic it is associated with. Generally it is meant to refer to an argument to pass to a service to be operated on.

      Since:
      1.5
      See Also:
    • PARAM_SERVICE_RESULT

      static final String PARAM_SERVICE_RESULT
      An instruction parameter for a service result.

      The nature of this parameter depends on the topic it is associated with. Generally it is meant to refer to the result of some service execution.

      Since:
      1.5
      See Also:
    • PARAM_STATUS_CODE

      static final String PARAM_STATUS_CODE
      An instruction parameter for a status code.

      The nature of this parameter depends on the topic it is associated with. Generally it is meant to refer to a standardized enumeration such as an HTTP status code.

      Since:
      1.5
      See Also:
    • PARAM_MESSAGE

      static final String PARAM_MESSAGE
      An instruction parameter for a message.

      The nature of this parameter depends on the topic it is associated with. Generally it is meant to refer to a brief message to describe a service result, such as a status code description.

      Since:
      1.5
      See Also:
    • TOPIC_CANCEL_INSTRUCTION

      static final String TOPIC_CANCEL_INSTRUCTION
      The instruction topic to cancel an instruction.

      A PARAM_ID parameter must be provided that specifies the instruction ID to cancel. The instruction, if not already complete, will be changed to the Declined state and a result message will be added.

      Since:
      2.1
      See Also:
    • PARAM_ID

      static final String PARAM_ID
      An instruction parameter for an identifier.

      The nature of this parameter depends on the topic it is associated with. Generally it is meant to refer to a unique identifier associated with the topic.

      Since:
      2.1
      See Also:
    • TOPIC_SYSTEM_CONFIGURATION

      static final String TOPIC_SYSTEM_CONFIGURATION
      The instruction topic for obtaining system configuration.

      A PARAM_SERVICE parameter must be provided that specifies the system service to get the configuration for. Each service may define additional parameters that can be configured.

      Since:
      2.2
      See Also:
  • Method Details

    • handlesTopic

      boolean handlesTopic(String topic)
      Test if a topic is handled by this handler.
      Parameters:
      topic - the topic
      Returns:
      true only if this handler can execute the job for the given topic
    • processInstruction

      InstructionStatus processInstruction(Instruction instruction)
      Process an instruction.
      Parameters:
      instruction - the instruction to process
      Returns:
      the status for the instruction, or null if the instruction was not handled