Conn (Connector) Flashcards

1
Q

Conn Overview

A

The ConnExt provides the connector framework and its APIs. This framework entails:

  • standardizes conventions for modeling connectors to remote systems
  • standardizes connector status: ok, down, fault, disabled
  • standardizes connector operations: open, close, ping, syncPoint, syncHis, etc
  • standardizes point “cur” real-time synchronization and watches
  • standardizes writable points
  • standardizes point “his” historical data synchronization
  • implements concurrency and lifecycle model
  • provides simple callback mechanism for connector implementations
  • defines standard Fresco app model and tabs

The connector framework provides significant infrastructure to ensure that integration to remote systems is easy to implement by software developers. But more importantly it provides a set of conventions to ensure that connectors provide uniformity for system integrators who deploy them on projects.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Conn Naming Conventions

A

The connector framework relies heavily on naming conventions. Everything starts with your extensions name. For example if you are developing a extension named “foo”, then the following names would be used:

foo ext/connector name fooExt ext pod name fooConn marker tag for connector rec fooConnRef tag applied to points to associated them with a connector fooCur point address tag for real-time synchronization fooWrite point address tag for writing to an output fooHis point address tag for history synchronization fooPing function to ping connector fooSyncCur function to sync curVal of points fooSyncHis function to sync history of points fooLearn function for discovery and learn mapping FooExt class name of connExt::ConnImplExt subclass FooConn class name of connExt::Conn subclass FooModel class name of connExt::ConnModel subclass

All of these names are generated automatically and accessible via the ConnModel class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

ConnIMpIExt

A

ConnImplExt

All connectors will create a normal their Ext by subclassing from ConnImplExt:

  • base class handles start/stop lifecycle
  • base class handles managing your connector map and their actors
  • connector actor lookup
  • the constructor will take your ConnModel
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

ConnModel

A

ConnModel

All connectors must create subclass of ConnModel which defines their tag names, func names, and capabilities:

  • used by ConnImplExt and ConnApp
  • all tag/func names derived using standard naming conventions
  • override ConnModel.isPollingSupported to return true if supported
  • override ConnModel.isLearnSupported to return true if supported
  • override ConnModel.isCurSupported to return true if supported
  • override ConnModel.isWriteSupported to return true if supported
  • override ConnModel.isHisSupported to return true if supported
  • override ConnModel.pointAddrType to return address type if your connector uses Uri or Number instead of Str
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

ConnLib

A

ConnLib

All connectors will create a FooLib class which defines their Axon functions. There is no base class for this, but your library class must use the normal extension pattern. A specific set of functions should be defined which will map directly to methods in the framework:

  • fooPing(conn): ConnActor.ping
  • fooSyncCur(points): ConnImplExt.syncCur
  • fooSyncHis(points): ConnImplExt.syncHis
  • fooLearn(conn, arg): ConnActor.learn
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

ConnActor

A

ConnActor

Every connector rec defined in the database is mapped to to exactly one ConnActor. Each actor wraps one Conn instance which is responsible for managing all mutable state and networking to the remote system.

All messages to the Conn are sent as ConnMsg which is designed to allow implementations to perform their own messaging. Each of your messages should use a unique string identifier so that you don’t interfere with the built-in messages.

All messaging to the ConnActor uses a coalesing queue. For example if you send 100 ping messages and the actor is busy, they will coalesce into one single ping message. Coalescing is determined by ConnMsg.equals which in turn is determined by equality of the message arguments.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Conn

A

Conn

Every connector must define a subclass of Conn which is the heart of the framework; it is a mutable class which models the state, networking, and points of a fooConn record. As a mutable class, all state is managed within a ConnActor and other actors/threads communicate with yourConn via messaging.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Conn Accessors

A

Conn Accessors

Conn provides many accessor methods to environment:

  • Conn.ext: reference to your ConnImplExt instance
  • Conn.proj: reference to project database
  • Conn.actor: actor used to manage all messaging to your Conn
  • Conn.rec: current state of your connector record
  • Conn.id: connector record id
  • Conn.dis: convenience for rec.dis
  • Conn.log: debugging and error logging
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Conn Lifecycle Callbacks

A

Conn Lifecycle Callbacks

All the connector and point life cycle operators map to callbacks on this class. All of the following callbacks are make on the ConnActor thread:

  • Conn.onOpen: open network connection to device which results in a) successful communication, b) your subclass raises an DownErr if there is a communication error, or c) raises FaultErr if configuration problem
  • Conn.onClose: gracefully close down connection
  • Conn.onPing: perform simple round trip communication with remote system and return metadata tags like device make, model, version
  • Conn.onHouseKeeping: callback to periodically check background tasks (called every few seconds)
  • Conn.onDiff: when connector record is modified
  • Conn.onDelete: when connector record is removed from database
  • Conn.onLearn: callback for your fooLearn Axon function which is used by FooApp | Learn tab
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Conn Point Callbacks

A

Conn Point Callbacks

The following callbacks are made on Conn to support its associated points:

  • Conn.onPoll: callback by poll scheduler
  • Conn.onSyncCur: synchronize curVal for a batch of points
  • Conn.onSyncHis: synchronize history items for a single point and date range
  • Conn.onWatch: callback when batch of points put into watch
  • Conn.onUnwatch: callback when batch of points put taken out of watch
  • Conn.onWrite: callback when writable point’s output command has been updated

Points are discussed further in under ConnPoint

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Conn State

A

Conn State

A connector is in the opening, open, closing, or closed state indicated by the connState tag. These methods are used to manage a connector’s open state:

  • Conn.openLinger: open connector and leave it open for a linger period (default 30sec). After linger period if no one else has requested the connector open it automatically closes
  • Conn.openPin: pin the connector open for a specific application; for example if there is ongoing data logging we want to keep the connector open all the time. A string key is used to indicate which application wishes the connector open.
  • Conn.closePin: pinned apps must call this method with their string key when done. When all pinned applications are closed and there no linger, then the connector is closed down. -connExt::Conn.close: by default linger timeout and closePin are used to control closing of the connector. But if a communication failure or some other event is detected which indicates the connector is down, then they should call close with the exception

When the an open is first requested, your Conn.onOpen callback is invoke. If onOpen throws an exception, then connStatus and connErr are updated based on the exception type (use DownErr to indicate a communication failure). If onOpen returns without raising an exception then connStatusis set to “ok”.

Your connector should establish connectivity during the onOpen callback. This might be establishing a TCP or session if your connector is session oriented. Or might just be a ping if using UDP or stateless protocol such as HTTP.

If your connector is disabled, then all callbacks are by-passed and status is forced to “disabled”.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Conn Learn

A

Conn Learn

The learn feature is used to “walk” the external system native data model and learn which points are available. to add learn to your connector you should create an Axon function called fooLearnwhich routes to ConnActor.learn. This in turn results in the Conn.onLearn callback.

The learn argument is an connector specific identifier used to keep of track of position within the tree or graph of the remote system data model. The null argument indicates learn at the root learn. Each call to learn takes the argument and returns a grid of the items at that level of the tree in the external system. If an item may be navigated into, then it should define its own learn identifier in the learn column. The ConnApp Learn tab uses the data to implement navigation of the external system via your Axon learn function.

If a learn item supports mapping to a point, then your resulting grid should include standard point data like fooCur, fooWrite, fooHis, kind, unit, etc. See Conn.onLearn for further details.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

ConnPoint

A

ConnPoint

The ConnPoint is a mutable class used to keep track of state per point. ConnPoint is not subclassed by implementations, but you can stash a implementation specific object inConnPoint.data.

The Conn base class automatically keeps track of all a connector’s points associated by thefooConnRef. Each rec is wrapped by a ConnPoint instance. The following methods are used to work with a connector’s point list:

  • Conn.point: lookup a point by its record id
  • Conn.points: list of all points
  • Conn.pointsWatched: list of all points currently in a watch
  • Conn.hasPointsWatched: are any connector’s point currently in a watch
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

ConnPoint Cur

A

ConnPoint Cur

Standard behavior of current value subscription is defined by pointExt.

Current value is synchronized once by the fooSyncCur function which results in theConn.onSyncCur callback. This callback works with a batch of points. If your protocol supports batch reads, then typically it most efficient to sync entire batch.

Continous synchronization of current value is managed when the point is put into a watch. Watch state is managed by the callbacks Conn.onWatch and Conn.onUnwatch. Both callbacks work with a batch of points. Typically there are two watch strategies:

  • if the protocol supports change of value subscriptions, then watch/unwatch maps to subscribe/unsubscribe messages
  • if the protocol does not support subscriptions, then your connector should use poll scheduler to periodically poll all points in watch

The poll scheduler is enabled by ConnModel.isPollingSupported which automatically schedules the Conn.onPoll callback. The poll frequency is determined by the Conn.pollFreq method. By convention polling should be configured on a per connector basis using a tag called fooPollFreqor fallback to suitable default.

There are many ways that your points will end up synchronizing their current value:

  • one time onSyncCur read
  • initial subscription from onWatch
  • async message from subscription change event
  • read during onPoll

In all cases if the current value is read successfully, then the connector should callConnPoint.updateCurOk with the SkySpark representation of the current value. If an error is detected such as a bad address, then ConnPoint.updateCurErr should be called. These methods manage the curVal, curStatus, and curErr tags for you automatically.

As a general principle, if there is an exception reading a point then call updateCurErr with the exception. The following exceptions type should be used for special cases:

  • FaultErr: connector is communicating correctly, but there is a configuration error with the point
  • RemoteStatusErr: remote point can be read correctly, but the remote system status is not “ok”. For example if the remote point is “disabled”, then use this exception to set the local point into “remoteDisabled”
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

ConnPoint Writes

A

ConnPoint Writes

The standard behavior of writable points is defined by pointExt. The pointExt manages the 16-level priority array and calculates when a new command should be written by the connector - this results in the Conn.onWrite callback. Your callback should write the new value to the remote system, and then call ConnPoint.updateWriteOk or ConnPoint.updateWriteErr.

Connector library do not need to define any functions for writing. Writes are controlled by the standard point functions such as pointOverride and pointAuto.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

ConnPoint His

A

ConnPoint His

If the connector’s protocol support history time-series data synchronization, then it should declare an axon function calls fooSyncHis which takes a list of points and a date range. The Axon function should route to ConnImplExt.syncHis which manages the nasty details for you:

  • mapping points to records by connector
  • mapping date range to actual DateTimeSpan
  • iterating through each connector with proper job status and logging

The result is a series of calls to the Conn.onSyncHis callback which your connector should use to fetch the history items for the given date range. Your callback must then call updateHisOk with latest data or else call updateHisErr if there is an error. The framework automatically handles writing to the historian and managing your hisStatus and hisErr tags.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Tuning

A

Tuning

The ConnTuning class models the options used to tune the functionality of the connector points.

Tuning configurations are created as a rec in the Folio database with the connTuning tag.

Points are assigned to a tuning configuration via the connTuningRef tag. This tag is searched in the following order:

  1. Point rec itself
  2. Point’s connector rec
  3. Connector’s ext rec
  4. Fallback to default tuning

The standard tuning options supported by the connector framework are detailed below. In addition, connector’s may use the tuning framework for their own custom options.

Note: all the tuning timers rely on periodic background processing which is only accurate to within 5 to 10sec.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

pollTime

A

pollTime

The pollTime tag specifies a duration Number which is the frequency used to poll a point forcurVal. This tag is only used for connectors which support polling for their current value. Connectors which use a COV subscription model will ignore this value. If unspecified the default is 10sec.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

staleTime

A

staleTime

The staleTime tag specifies a duration Number used to transition a point’s curStatus tag from “ok” to “stale”. It ensures that users and applications are aware that data might not be fresh. The transition to stale occurs when all the following conditions are met:

  1. the point’s curStatus is currently “ok”
  2. the point is not in a watch
  3. the last successful read exceeds the stale time

Note that we assume points in a watch are currently up-to-date even if their last read time exceeds the stale time. This is because change of value subscriptions might not be callingupdateCurOk continuously if no changes are received. If unspecified the default is 5min.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

writeMinTime

A

writeMinTime

The writeMinTime tag specifies a duration Number used to throttle the frequency of writes to the remote device. For example if configured to 5sec, then writes will be issued no faster than 5sec. After a successful write occurs, if any writes are attempted within that 5sec window then they are queued as a pending write. After 5sec has elapsed the last pending write is issued to the connector’s onWrite callback. Note that writeMinTime is only enforced after successful writes. If the connector reports a write failure, then writeMinTime is not enforced on subsequent attempts.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

writeMaxTime

A

writeMaxTime

The writeMaxTime tag specifies a duration Number used to issue periodic rewrites to the remote device. For example if configured to 10min, then if no successful writes have been issued after 10min then a write is automatically scheduled to the connector’s onWrite callback. The writeMaxTime does not go into effect until after the project reaches steady state.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Point Conversions

A

Point Conversions

The following tags are used to configure conversions between the normalized SkySpark representations and the connector’s remote device:

  • curConvert: converts from raw read value to curVal
  • curCalibration: adjusts value before reading to curVal
  • writeConvert: converts writeVal to raw value to write
  • hisConvert: converts history items values from connector

The conversion is specified as a string using the point convert syntax.

For example if reading a temperature sensor we might apply a thermistor table to convert the raw sensor value into a normalized representation of Fahrenheit or Celsius degrees:

curConvert: "thermistor(10k-2)"

If the sensor needs calibration, we might further decide to adjust plus or minus a few degrees. If for example we wanted to add 2°F to the value being read from the sensor then:

curConvert: "thermistor(10k-2)" curCalibration: 2°F
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

ConnApplet

A

ConnApplet

The connector framework defines a standard app and allows connectors to plugin into the app by subclassing ConnApplet.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

actor

A

actor

const ConnActor actor

Actor used to manage async processing of this connector

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

close

A

close

Void close(Err? cause)

Force this connector closed and call onClose.

26
Q

commit

A

commit

Void commit(Diff diff)

Commit changes to this connector, update rec

27
Q

connExt

A

connExt

ConnExt connExt()

Master ConnExt instance

28
Q

connLinger

A

connLinger

Duration connLinger()

Configured linger timeout - see connLinger

29
Q

connPingFreq

A

connPingFreq

Duration? connPingFreq()

Configured ping frequency to test connection or null if feature is disabled - seeconnPingFreq

30
Q

dis

A

dis

Str dis()

Convenience for rec.dis

31
Q

ext

A

ext

ConnImplExt ext()

Connector extension for project

32
Q

hasPointsWatched

A

hasPointsWatched

Bool hasPointsWatched()

Return if there is one or more points currently in watch. Also see pointsWatched.

33
Q

id

A

id

Ref id()

Folio record id of rec

34
Q

isClosed

A

isClosed

Bool isClosed()

Is the connection currently closed

35
Q

isOpen

A

isOpen

Bool isOpen { private set }

Is the connection currently open

36
Q

log

A

log

Log log()

Convenience for ext.log

37
Q

make

A

make

new make(ConnActor actor, Dict rec)

Construct with actor and current record

38
Q

model

A

model

ConnModel model()

Model tags and functions for implementation

39
Q

onClose

A

onClose

abstract Void onClose()

Callback to handle close of the connection. This callback is made on connector’s actor.

40
Q

onDelete

A

onDelete

virtual Void onDelete()

Callback when connector is deleted from Folio database. The onClose method is always called first if the connector was open. This callback is made on connector’s actor.

41
Q

onDiff

A

onDiff

virtual Void onDiff(Diff diff)

Callback when tags on the connector record have been updated. This callback is made on connector’s actor.

42
Q

onHouseKeeping

A

onHouseKeeping

virtual Void onHouseKeeping()

Callback made periodically every few seconds to handle backup tasks. This callback is made on connector’s actor.

43
Q

onLearn

A
  • onLearn
  • virtual Grid onLearn(Obj? arg)

Callback to handle learn tree navigation. This method should return a grid where the rows are either navigation elements to traverse or potential points to map. The learn tag is used to indicate a row which may be “dived into” to navigate the remote system’s tree. The learn value is passed back to this function to get the next level of the tree. A null arg should return the root of the learn tree. The following tags should be used to indicate points to map:

< >dis: display name for navigation (required for all rows)point: marker indicating point (1 or more fooCur/His/Write)fooCur: address if object can be mapped for cur real-time syncfooWrite: address if object can be mapped for writingfooHis: address if object can be mapped for history synckind: point kind type if knownunit: point unit if knownhisInterpolate: if point is known to be collected as COVenum: if range of bool or multi-state is knownany other known tags to map to the learned pointsconnExt.

<dl>
</dl>

44
Q

onOpen

A

onOpen

abstract Void onOpen()

Callback to handle opening the connection. Raise DownErr or FaultErr if the connection failed. This callback is always called before operations such as onPing. This callback is made on connector’s actor.

45
Q

onPing

A

onPing

abstract Dict onPing()

Callback to handle ping of the connector. Return custom status tags such as device version, etc to store onthe connector record persistently. If there are version tags which should be removed then map those tags to Remove.val. If ping fails then raise DownErr or FaultErr. This callback is made on connector’s actor thread.

46
Q

onPoll

A

onPoll

virtual Void onPoll()

Callback made every pollFreq to perform a poll. Use pointsWatched to get the list of points currently being watched. Implementations must set ConnModel.isPollingSupported to true to enable polling.

47
Q

onSyncCur

A

onSyncCur

virtual Void onSyncCur(ConnPoint[] points)

Callback to synchronize the given list of points. The result of this call should be to invokeConnPoint.updateCurOk or ConnPoint.updateCurErr on each point.

48
Q

onSyncHis

A

onSyncHis

virtual Obj? onSyncHis(ConnPoint point, DateTimeSpan dates)

Callback to synchronize the a point’s history data from the connector. The result of this callback must be to invoke ConnPoint.updateHisOk or ConnPoint.updateHisErr (or just raise exception). The return of this method should be whatever updateHisXXX returns.

49
Q

onUnwatch

A

onUnwatch

virtual Void onUnwatch(ConnPoint[] points)

Callback when one or more points are taken out of watch mode.

50
Q

onWatch

A

onWatch

virtual Void onWatch(ConnPoint[] points)

Callback when one or more points are put into watch mode.

51
Q

onWrite

A

onWrite

virtual Void onWrite(ConnPoint point, Obj? val, Number level)

Callback to write a point. The val and level indicate the current command from the point’s 16 level priority array, where a level of 17 indicates the relinquish default. The connector should write the value to the remote system. If successful then callConnPoint.updateWriteOk, or if there is an error then invoke ConnPoint.updateWriteErr or just raise exception. The value passed may have been converted from writeVal ifwriteConvert is configured.

52
Q

openLinger

A

openLinger

Void openLinger(Duration linger := this.connLinger())

Open connection and then auto-close after a linger timeout.

53
Q

ping

A

ping

Void ping()

Ping this connector and call onPing. If the connector is not currently open then callopenLinger

54
Q

point

A

point

ConnPoint? point(Ref id, Bool checked := true)

Get the ConnPoint associated with this connector point rec id.

55
Q

points

A

points

ConnPoint[] points()

Get full list of points associated with this connector.

56
Q

pointsWatched

A

pointsWatched

ConnPoint[] pointsWatched()

Get list of points which are currently in watch. Also see hasPointsWatched.

57
Q

pollFreq

A

pollFreq

virtual Duration? pollFreq()

Frequency used poll the points in the watch. Implementations which use polling should override this method to return a non-null Duration. By convention polling for connector “foo” is tuned with a connector tag “fooPollFreq” or falls back to suitable default like 1sec. If polling is enabled, then subclasses must also implement the onPoll callback. Implementations must set ConnModel.isPollingSupported to true to enable polling.

58
Q

proj

A

proj

Proj proj()

Project for extension

59
Q

rec

A

rec

Dict rec { private set }

Current version of the Folio connector record

60
Q

receive

A

receive

virtual Obj? receive(ConnMsg msg)

Handle actor message. Subclasses which wish to to perform custom messages should check their messages and call super for unhandled messags to ensure standard messages are processed.

61
Q

status

A

status

ConnStatus status := ConnStatus.unknown { private set }

Current connection status.

62
Q
A