Options
All
  • Public
  • Public/Protected
  • All
Menu

Class OpcuaIoActorController

Connect to OPC UA server and map IO values received by IO actors to OPC UA variables.

Each IO value received by an IO actor is written as an OPC UA variable value. Mappings are configured on a controller option named opcuaIoActorOptions which must implement the OpcuaIoActorOptions interface.

By default, IO values are written unchanged as OPC UA variable values. You can implement a specific data value coercion by defining a coerceValue function in the associated OpcuaDataSource.

To perform application-specific side effects on write operations or conditional writes, subclass this controller and overwrite the protected method writeDataValue.

remarks

This controller only runs in a Node.js runtime, not in a browser.

Hierarchy

  • IoActorController
    • OpcuaIoActorController

Implements

  • IController

Index

Constructors

constructor

  • new OpcuaIoActorController(_container: Container, _options: ControllerOptions, _controllerName: string): OpcuaIoActorController
  • internal

    For internal use in framework only.

    Never instantiate Controller objects in your application; they are created automatically by dependency injection.

    Parameters

    • _container: Container
    • _options: ControllerOptions
    • _controllerName: string

    Returns OpcuaIoActorController

Accessors

communicationManager

  • get communicationManager(): CommunicationManager

container

  • get container(): Container
  • Gets the container object of this controller.

    Returns Container

options

  • get options(): Readonly<ControllerOptions>
  • Gets the controller's options as specified in the configuration options.

    Returns Readonly<ControllerOptions>

registeredName

  • get registeredName(): string
  • 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 string

runtime

  • get runtime(): Runtime
  • Gets the container's Runtime object.

    Returns Runtime

Methods

Protected extendLogObject

  • extendLogObject(log: Log): void
  • 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.

    Parameters

    • log: Log

      log object to be extended before being advertised

    Returns void

getIoValue

  • getIoValue<T>(actor: IoActor): T
  • Gets the lastest IO value emitted to the given IO actor or undefined if none exists yet.

    Type parameters

    • T

    Parameters

    • actor: IoActor

      an IO actor object

    Returns T

    the latest IO value for the given actor if one exists

isAssociated

  • isAssociated<T>(actor: IoActor): boolean
  • Determines whether the given IO actor is currently associated.

    Type parameters

    • T

    Parameters

    • actor: IoActor

    Returns boolean

logDebug

  • logDebug(message: string, ...tags: string[]): void
  • Advertise a Log object for debugging purposes.

    Parameters

    • message: string

      a debug message

    • Rest ...tags: string[]

      any number of log tags

    Returns void

logError

  • logError(error: any, message: string, ...tags: string[]): void
  • Advertise a Log object for an error.

    Parameters

    • error: any

      an error (object)

    • message: string

      additional error message

    • Rest ...tags: string[]

      any number of log tags

    Returns void

logErrorWithStacktrace

  • logErrorWithStacktrace(error: any, message: string, ...tags: string[]): void
  • Advertise a Log object for an error with stacktrace information.

    Parameters

    • error: any

      an error (object)

    • message: string

      additional error message

    • Rest ...tags: string[]

      any number of log tags

    Returns void

logFatal

  • logFatal(error: any, message: string, ...tags: string[]): void
  • Advertise a Log object for a fatal error.

    Parameters

    • error: any

      an error (object)

    • message: string

      additional error message

    • Rest ...tags: string[]

      any number of log tags

    Returns void

logInfo

  • logInfo(message: string, ...tags: string[]): void
  • Advertise an informational Log object.

    Parameters

    • message: string

      an informational message

    • Rest ...tags: string[]

      any number of log tags

    Returns void

logWarning

  • logWarning(message: string, ...tags: string[]): void
  • Advertise a Log object for a warning.

    Parameters

    • message: string

      a warning message

    • Rest ...tags: string[]

      any number of log tags

    Returns void

observeAssociation

  • observeAssociation<T>(actor: IoActor): Observable<boolean>
  • Listen to associations or disassociations for the given IO actor. The returned observable emits distinct boolean values until changed, i.e true when the first association is made and false, when the last association becomes disassociated. When subscribed, the current association state is emitted immediately.

    remarks

    Note that subscriptions on the observable returned must be manually unsubscribed by the application; they are not automatically unsubscribed when communication manager is stopped.

    Type parameters

    • T

    Parameters

    • actor: IoActor

      an IO actor object

    Returns Observable<boolean>

observeIoValue

  • observeIoValue<T>(actor: IoActor): Observable<T>
  • Listen to IO values for the given IO actor. The returned observable always emits the last value received for the given IO actor. When subscribed, the current value (or undefined if none exists yet) is emitted immediately.

    Due to this behavior the cached value of the observable will also be emitted after reassociation. If this is not desired use this.communicationManager.observeIoValue instead. This method doesn't cache any previously emitted value.

    remarks

    Note that subscriptions on the observable returned must be manually unsubscribed by the application; they are not automatically unsubscribed when communication manager is stopped.

    Type parameters

    • T

    Parameters

    • actor: IoActor

      an IO actor object

    Returns Observable<T>

    an observable emitting IO values for the given actor

onCommunicationManagerStarting

  • onCommunicationManagerStarting(): void

onCommunicationManagerStopping

  • onCommunicationManagerStopping(): void

onDispose

  • onDispose(): void

onInit

  • onInit(): void

Protected traceOpcuaError

  • traceOpcuaError(error: any): void
  • 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.

    Parameters

    • error: any

      an OPC UA error

    Returns void

Protected writeDataValue

  • Overwrite this method to perform side effects on writing a single data value or to perform conditional writes.

    By default, the given data value is written to the given OPC UA data source variable. If an error occurs it is emitted by the traceOpcuaError method.

    Parameters

    • dataSource: OpcuaDataSource

      an OPC UA data source for a variable to be written

    • dataValue: any

      the value to be written

    Returns void

Generated using TypeDoc