Skip to content

OcaNumericObserver#

This document describes the controller implementation of OcaNumericObserver. This class is documented in the AES70 standard as:

Observer of a scalar numeric or boolean property ("target property") of a specified object. Does not work for array, list, map, struct, or string properties.

OcaNumericObserver emits an Observation event under certain conditions. There are three kinds of conditions:

Numeric comparison. The target property value meets a certain comparison condition. A selection of comparison operators is available. Such observations are called "asynchronous observations"., Timer expiry. The value of the Period property, if nonzero, is the time interval for the recurrent timed emission of Observation events. Such events ("periodic observations") are emitted regardless of the target property's value., Combination of (1) and (2). If a numeric comparison and a nonzero period are both specified, then the Observation event is emitted when the timer expires and the numeric comparison is true. Such observations are called "conditional-periodic observations".

This is a weakly typed class. Its threshold is specified as an OcaFloat64 number.

For unsigned integer targets, the threshold and target are both coerced to OcaUint64 before comparing., For signed integer targets, the threshold and target are both coerced to OcaInt64 before comparing., For boolean values, the threshold threshold and target are both coerced to OcaUint8, True is assigned the value One, False is assigned the value Zero.

Note that this coercion may result in rounding errors if the observed datatype is of type OcaUint64 or OcaInt64.

An OcaNumericObserver instance and the property it observes are bound at the time the OcaNumericObserver instance is constructed. For static devices, construction will occur during manufacture, or possibly during a subsequent hardware configuration step. For reconfigurable devices, construction might be done by online controllers as part of device configuration sessions.

This class is normally used for monitoring sensor readings, but may be used equally well for watching workers' parameter settings.


Overview#

Class Declaration#

namespace aes70::controller
{
  class OcaNumericObserver : public OcaAgent
  {
  public:
    OcaNumericObserver(std::shared_ptr<connection> connection,
            uin32_t object_number);
    OcaNumericObserver(const OcaNumericObserver &o);

    // Control Methods
    // Calls GetLastObservation and calls on_result or on_failure
    void GetLastObservation(auto on_result, failure_callback on_failure);
    // Calls GetState and calls on_result or on_failure
    void GetState(auto on_result, failure_callback on_failure);
    // Calls GetObservedProperty and calls on_result or on_failure
    void GetObservedProperty(auto on_result, failure_callback on_failure);
    // Calls SetObservedProperty and calls on_result or on_failure
    void SetObservedProperty(OcaProperty property, auto on_result, failure_callback on_failure);
    // Calls SetObservedProperty and does not wait for the response
    void SetObservedProperty(OcaProperty property);
    // Calls GetThreshold and calls on_result or on_failure
    void GetThreshold(auto on_result, failure_callback on_failure);
    // Calls SetThreshold and calls on_result or on_failure
    void SetThreshold(OcaFloat64 Threshold, auto on_result, failure_callback on_failure);
    // Calls SetThreshold and does not wait for the response
    void SetThreshold(OcaFloat64 Threshold);
    // Calls GetOperator and calls on_result or on_failure
    void GetOperator(auto on_result, failure_callback on_failure);
    // Calls SetOperator and calls on_result or on_failure
    void SetOperator(OcaRelationalOperator operator, auto on_result, failure_callback on_failure);
    // Calls SetOperator and does not wait for the response
    void SetOperator(OcaRelationalOperator operator);
    // Calls GetTwoWay and calls on_result or on_failure
    void GetTwoWay(auto on_result, failure_callback on_failure);
    // Calls SetTwoWay and calls on_result or on_failure
    void SetTwoWay(OcaBoolean twoWay, auto on_result, failure_callback on_failure);
    // Calls SetTwoWay and does not wait for the response
    void SetTwoWay(OcaBoolean twoWay);
    // Calls GetHysteresis and calls on_result or on_failure
    void GetHysteresis(auto on_result, failure_callback on_failure);
    // Calls SetHysteresis and calls on_result or on_failure
    void SetHysteresis(OcaFloat64 hysteresis, auto on_result, failure_callback on_failure);
    // Calls SetHysteresis and does not wait for the response
    void SetHysteresis(OcaFloat64 hysteresis);
    // Calls GetPeriod and calls on_result or on_failure
    void GetPeriod(auto on_result, failure_callback on_failure);
    // Calls SetPeriod and calls on_result or on_failure
    void SetPeriod(OcaTimeInterval period, auto on_result, failure_callback on_failure);
    // Calls SetPeriod and does not wait for the response
    void SetPeriod(OcaTimeInterval period);

    // Observing Properties
    subscription observeState(auto callback, failure_callback on_failure);
    subscription observeObservedProperty(auto callback, failure_callback on_failure);
    subscription observeThreshold(auto callback, failure_callback on_failure);
    subscription observeOperator(auto callback, failure_callback on_failure);
    subscription observeTwoWay(auto callback, failure_callback on_failure);
    subscription observeHysteresis(auto callback, failure_callback on_failure);
    subscription observePeriod(auto callback, failure_callback on_failure);

    // Property Changed Subscriptions
    subscription OnStateChanged(auto callback, failure_callback on_failure);
    subscription OnObservedPropertyChanged(auto callback, failure_callback on_failure);
    subscription OnThresholdChanged(auto callback, failure_callback on_failure);
    subscription OnOperatorChanged(auto callback, failure_callback on_failure);
    subscription OnTwoWayChanged(auto callback, failure_callback on_failure);
    subscription OnHysteresisChanged(auto callback, failure_callback on_failure);
    subscription OnPeriodChanged(auto callback, failure_callback on_failure);
  };
}

Methods#

GetLastObservation#

void GetLastObservation(auto on_result, failure_callback on_failure)

Calls the method GetLastObservation in the remote device.

Parameters:#

  • auto on_result: A callable (e.g. a lambda) with the following arguments:
    • OcaFloat64 Observation
  • failure_callback on_failure: A callback which is called on error.

GetState#

void GetState(auto on_result, failure_callback on_failure)

Calls the method GetState in the remote device.

Parameters:#

  • auto on_result: A callable (e.g. a lambda) with the following arguments:
    • OcaObserverState state
  • failure_callback on_failure: A callback which is called on error.

GetObservedProperty#

void GetObservedProperty(auto on_result, failure_callback on_failure)

Calls the method GetObservedProperty in the remote device.

Parameters:#

  • auto on_result: A callable (e.g. a lambda) with the following arguments:
    • OcaProperty property
  • failure_callback on_failure: A callback which is called on error.

SetObservedProperty#

void SetObservedProperty(OcaProperty property, auto on_result, failure_callback on_failure)

Calls the method SetObservedProperty in the remote device. If no result and error callback is specified, the method will be called without requesting a response.

Parameters:#

  • OcaProperty property
  • auto on_result: A callable (e.g. a lambda) with 0 arguments.
  • failure_callback on_failure: A callback which is called on error.

GetThreshold#

void GetThreshold(auto on_result, failure_callback on_failure)

Calls the method GetThreshold in the remote device.

Parameters:#

  • auto on_result: A callable (e.g. a lambda) with the following arguments:
    • OcaFloat64 Threshold
  • failure_callback on_failure: A callback which is called on error.

SetThreshold#

void SetThreshold(OcaFloat64 Threshold, auto on_result, failure_callback on_failure)

Calls the method SetThreshold in the remote device. If no result and error callback is specified, the method will be called without requesting a response.

Parameters:#

  • OcaFloat64 Threshold
  • auto on_result: A callable (e.g. a lambda) with 0 arguments.
  • failure_callback on_failure: A callback which is called on error.

GetOperator#

void GetOperator(auto on_result, failure_callback on_failure)

Calls the method GetOperator in the remote device.

Parameters:#

  • auto on_result: A callable (e.g. a lambda) with the following arguments:
    • OcaRelationalOperator operator
  • failure_callback on_failure: A callback which is called on error.

SetOperator#

void SetOperator(OcaRelationalOperator operator, auto on_result, failure_callback on_failure)

Calls the method SetOperator in the remote device. If no result and error callback is specified, the method will be called without requesting a response.

Parameters:#

  • OcaRelationalOperator operator
  • auto on_result: A callable (e.g. a lambda) with 0 arguments.
  • failure_callback on_failure: A callback which is called on error.

GetTwoWay#

void GetTwoWay(auto on_result, failure_callback on_failure)

Calls the method GetTwoWay in the remote device.

Parameters:#

  • auto on_result: A callable (e.g. a lambda) with the following arguments:
    • OcaBoolean twoWay
  • failure_callback on_failure: A callback which is called on error.

SetTwoWay#

void SetTwoWay(OcaBoolean twoWay, auto on_result, failure_callback on_failure)

Calls the method SetTwoWay in the remote device. If no result and error callback is specified, the method will be called without requesting a response.

Parameters:#

  • OcaBoolean twoWay
  • auto on_result: A callable (e.g. a lambda) with 0 arguments.
  • failure_callback on_failure: A callback which is called on error.

GetHysteresis#

void GetHysteresis(auto on_result, failure_callback on_failure)

Calls the method GetHysteresis in the remote device.

Parameters:#

  • auto on_result: A callable (e.g. a lambda) with the following arguments:
    • OcaFloat64 hysteresis
  • failure_callback on_failure: A callback which is called on error.

SetHysteresis#

void SetHysteresis(OcaFloat64 hysteresis, auto on_result, failure_callback on_failure)

Calls the method SetHysteresis in the remote device. If no result and error callback is specified, the method will be called without requesting a response.

Parameters:#

  • OcaFloat64 hysteresis
  • auto on_result: A callable (e.g. a lambda) with 0 arguments.
  • failure_callback on_failure: A callback which is called on error.

GetPeriod#

void GetPeriod(auto on_result, failure_callback on_failure)

Calls the method GetPeriod in the remote device.

Parameters:#

  • auto on_result: A callable (e.g. a lambda) with the following arguments:
    • OcaTimeInterval period
  • failure_callback on_failure: A callback which is called on error.

SetPeriod#

void SetPeriod(OcaTimeInterval period, auto on_result, failure_callback on_failure)

Calls the method SetPeriod in the remote device. If no result and error callback is specified, the method will be called without requesting a response.

Parameters:#

  • OcaTimeInterval period
  • auto on_result: A callable (e.g. a lambda) with 0 arguments.
  • failure_callback on_failure: A callback which is called on error.

observeState#

subscription observeState(auto callback, failure_callback on_failure)

Fetches the remote property State and subscribes for modifications. The callback is called with the initial values of State and whenever it changes.

Parameters:#

  • auto callback: A callable (e.g. a lambda) with one argument: OcaObserverState State
  • failure_callback on_failure: A callback which is called on error.

observeObservedProperty#

subscription observeObservedProperty(auto callback, failure_callback on_failure)

Fetches the remote property ObservedProperty and subscribes for modifications. The callback is called with the initial values of ObservedProperty and whenever it changes.

Parameters:#

  • auto callback: A callable (e.g. a lambda) with one argument: OcaProperty ObservedProperty
  • failure_callback on_failure: A callback which is called on error.

observeThreshold#

subscription observeThreshold(auto callback, failure_callback on_failure)

Fetches the remote property Threshold and subscribes for modifications. The callback is called with the initial values of Threshold and whenever it changes.

Parameters:#

  • auto callback: A callable (e.g. a lambda) with one argument: OcaFloat64 Threshold
  • failure_callback on_failure: A callback which is called on error.

observeOperator#

subscription observeOperator(auto callback, failure_callback on_failure)

Fetches the remote property Operator and subscribes for modifications. The callback is called with the initial values of Operator and whenever it changes.

Parameters:#

  • auto callback: A callable (e.g. a lambda) with one argument: OcaRelationalOperator Operator
  • failure_callback on_failure: A callback which is called on error.

observeTwoWay#

subscription observeTwoWay(auto callback, failure_callback on_failure)

Fetches the remote property TwoWay and subscribes for modifications. The callback is called with the initial values of TwoWay and whenever it changes.

Parameters:#

  • auto callback: A callable (e.g. a lambda) with one argument: OcaBoolean TwoWay
  • failure_callback on_failure: A callback which is called on error.

observeHysteresis#

subscription observeHysteresis(auto callback, failure_callback on_failure)

Fetches the remote property Hysteresis and subscribes for modifications. The callback is called with the initial values of Hysteresis and whenever it changes.

Parameters:#

  • auto callback: A callable (e.g. a lambda) with one argument: OcaFloat64 Hysteresis
  • failure_callback on_failure: A callback which is called on error.

observePeriod#

subscription observePeriod(auto callback, failure_callback on_failure)

Fetches the remote property Period and subscribes for modifications. The callback is called with the initial values of Period and whenever it changes.

Parameters:#

  • auto callback: A callable (e.g. a lambda) with one argument: OcaTimeInterval Period
  • failure_callback on_failure: A callback which is called on error.

OnStateChanged#

subscription OnStateChanged(auto callback, failure_callback on_failure)

Parameters#

  • auto callback: A callable (e.g. a lambda) with one argument: OcaObserverState State
  • failure_callback on_failure: A callback which is called on error.

OnObservedPropertyChanged#

subscription OnObservedPropertyChanged(auto callback, failure_callback on_failure)

Parameters#

  • auto callback: A callable (e.g. a lambda) with one argument: OcaProperty ObservedProperty
  • failure_callback on_failure: A callback which is called on error.

OnThresholdChanged#

subscription OnThresholdChanged(auto callback, failure_callback on_failure)

Parameters#

  • auto callback: A callable (e.g. a lambda) with one argument: OcaFloat64 Threshold
  • failure_callback on_failure: A callback which is called on error.

OnOperatorChanged#

subscription OnOperatorChanged(auto callback, failure_callback on_failure)

Parameters#

  • auto callback: A callable (e.g. a lambda) with one argument: OcaRelationalOperator Operator
  • failure_callback on_failure: A callback which is called on error.

OnTwoWayChanged#

subscription OnTwoWayChanged(auto callback, failure_callback on_failure)

Parameters#

  • auto callback: A callable (e.g. a lambda) with one argument: OcaBoolean TwoWay
  • failure_callback on_failure: A callback which is called on error.

OnHysteresisChanged#

subscription OnHysteresisChanged(auto callback, failure_callback on_failure)

Parameters#

  • auto callback: A callable (e.g. a lambda) with one argument: OcaFloat64 Hysteresis
  • failure_callback on_failure: A callback which is called on error.

OnPeriodChanged#

subscription OnPeriodChanged(auto callback, failure_callback on_failure)

Parameters#

  • auto callback: A callable (e.g. a lambda) with one argument: OcaTimeInterval Period
  • failure_callback on_failure: A callback which is called on error.