Gets the container's communication manager.
Gets the container object of this controller.
Gets the controller's options as specified in the configuration options.
Gets the registered name of this controller.
The registered name is either defined by the corresponding key in the
Components.controllers
object in the container configuration, or by
invoking Container.registerController
method with this name.
Returns all the registered sensor containers in an array.
Returns all the registered Sensors in an array.
Gets the container's Runtime object.
Overwrite this method to define how Observation object should be created.
Do not call this method in your application code, it is called by this controller internally.
Sensor container creating this observation
value of the observation
the quality of the result
the validity time of the observation (optional)
extra parameters for the observation (optional)
Whenever one of the controller's log methods (e.g. logDebug
, logInfo
,
logWarning
, logError
, logFatal
) is called by application code, the
controller creates a Log object with appropriate property values and
passes it to this method before advertising it.
You can override this method to additionally set certain properties (such
as LogHost.hostname
or Log.logLabels
). Ensure that
super.extendLogObject
is called in your override. The base method does
nothing.
log object to be extended before being advertised
Returns the first registered sensor where the given predicate is true,
undefined
otherwise.
findSensor calls predicate once in arbitrary order for each registered sensor, until it finds one where predicate returns true. If such a sensor is found, that sensor is returned immediately. Otherwise, undefined is returned
the first sensor matching the predicate; otherwise undefined
Returns the channelId associated with a sensor container.
By default, it is the objectId of the Sensor. Subclasses can override this method to provide their own logic.
Returns the Sensor associated with the given Sensor objectId.
If no such sensor exists then undefined
is returned.
Returns the sensor container associated with the given Sensor objectId.
If no such container exists then undefined
is returned.
Returns the sensor IO interface associated with the given Sensor objectId.
If no such sensor IO exists then undefined
is returned.
Returns an observable that emits values read from the sensor.
Only the values read with publishChanneledObservation or publishAdvertisedObservation will emit new values. Reading the sensor value manually with SensorIo.read will not emit any new value.
The observable is created lazily and cached. Once the Sensor associated with the observable is unregistered, all subscriptions to the observable are also unsubscribed.
If the Sensor is not registered, this method will throw an error.
Determines whether a Sensor with the given objectId is registered with this controller.
Advertise a Log object for debugging purposes.
a debug message
any number of log tags
Advertise a Log object for an error.
an error (object)
additional error message
any number of log tags
Advertise a Log object for an error with stacktrace information.
an error (object)
additional error message
any number of log tags
Advertise a Log object for a fatal error.
an error (object)
additional error message
any number of log tags
Advertise an informational Log object.
an informational message
any number of log tags
Advertise a Log object for a warning.
a warning message
any number of log tags
Lifecycle method called immediately after an observation is published for a specific Sensor. Default implementation does nothing.
Lifecycle method called just before an observation is published for a specific Sensor.
Default implementation does nothing.
Publishes an observation for a registered Sensor.
If no such registered Sensor exists then an error is thrown. The publication is performed in the form of an advertise event.
The observation value is read directly from the IO handler of the Sensor. The observation time is recorded as this method is called. Subclasses can change the final value of the observation object by overriding the createObservation method.
ObjectId of the Sensor to publish the observation.
The quality of the result. (optional)
The validity time of the observation. (optional)
Extra parameters for the observation. (optional)
UUID of associated feature of interest. (optional)
Publishes an observation for a registered Sensor.
If no such registered Sensor exists then an error is thrown. The publication is performed in the form of a channel event. By default the channelId is the sensorId. However, subclasses can change it by overriding getChannelId method.
The observation value is read directly from the IO handler of the Sensor. The observation time is recorded as this method is called. Subclasses can change the final value of the observation object by overriding the createObservation method.
ObjectId of the Sensor to publish the observation.
The quality of the result. (optional)
The validity time of the observation. (optional)
Extra parameters for the observation. (optional)
UUID of associated feature of interest. (optional)
Register a Sensor to this controller.
You can call this function at runtime or register sensors automatically
at the beginning by passing them in the controller options under
'sensors' objects (see documentation of base class
SensorSourceController
). In both cases, specify a sensor's io interface
to be of type OpcuaSensorIo
and specify the
observationPublicationType
property either as
"none"
: an observation is published on a Channel event synchronously
with each received OPC UA data value (default),"advertise"
: an observation is published on an Advertise event at
regular intervals specified by samplingInterval
, or"channel"
: an observation is published on a Channel event at regular
intervals specified by samplingInterval
.a Sensor object
the sensor's io interface
how to publish sensor observations, one of "none", "advertise", "channel" (optional)
regular publication interval in milliseconds (optional)
Registers a Thing to this controller.
You can call this function at runtime or register things automatically at the beginning by passing them in the controller options under 'things' as an array of Thing objects.
If a Thing with the given objectId already exists, this method is simply ignored.
Whenever a thing is registered, it is advertised to notify other
listeners (unless ignoreThingAdvertise
option is set). The controller
class also starts to listen on Discover events for Things (unless
skipThingDiscoverEvents
option is set). Registered things are
discoverable either by their Thing object type or by their Thing object
type and their external ID.
Thing to register to the controller.
Overwrite this method to define how internal OPC UA errors within this controller should be traced.
By default, OPC UA errors are logged on the console.
Do not call this method in your application code, it is called by this controller internally.
an OPC UA error
Unregisters a previously registered Sensor.
If no such Sensor is registered, then an error is thrown.
This also sends a disadvertise event to notify the listeners (unless ignoreSensorDeadvertise option is set). The query and discover events for this Sensor are ignored from this point on.
If a value observable for the Sensor exists, then all subscriptions to that observable are unsubscribed.
Generated using TypeDoc
Creates and manages Sensor and Thing objects for monitored OPC UA items.
Acts as a sensor source for OPC UA items (e.g. analog data items), i.e. advertises sensor objects, makes them discoverable, and publishes observations for its sensors associated with OPC UA items.
Mappings from OPC UA data sources to sensor object ids are configured on a controller option named
opcuaSensorOptions
which must implement theopcuaSensorOptions
interface.The sensor used for mapping OPC UA data sources can be defined either programmatically by calling
registerSensor
method or by specifying them in the controller'ssensors
option (see documentation of base classSensorSourceController
). In both cases, specify a sensor's io interface to be of typeOpcuaSensorIo
and specify theobservationPublicationType
property either as"none"
: an observation is published on a Channel event synchronously with each received OPC UA data value (default),"advertise"
: an observation is published on an Advertise event at regular intervals specified bysamplingInterval
, or"channel"
: an observation is published on a Channel event at regular intervals specified bysamplingInterval
.Thing objects for the registered sensors can be registered either programmatically by calling
registerThing
method or by specifying them in the controller'sthings
option as an array ofThing
objects. Registered Thing objects are advertised (unlessignoreThingAdvertise
option is set) and made discoverable (unlessskipThingDiscoverEvents
option is set) either by their Thing object type or by their Thing object type and their external ID.By default, monitored OPC UA data values are passed unchanged as observation results. You can implement a specific data value coercion by defining a
coerceValue
function in the associatedOpcuaDataSource
.This controller only runs in a Node.js runtime, not in a browser.