Skip to content

lib-conn 库参考 ​

原文: https://finproducts.atlassian.net/wiki/spaces/JIDD3/pages/34793259180/FIN+5.3.1+lib-conn 中文整理基于 FIN 5.3.1

导读: 本页为 lib-conn 的 API / 标签 / 函数参考文档。

以下为 API 参考,保留英文以便对照源码;目录已列出(英文标题便于检索);概述已尽量中译。


目录(导读) ​

  • lib
  • meta
  • tags
  • funcs
  • views
  • def
  • supertypes
  • subtypes
  • tags
  • usage
  • enum
  • connClose(conn)
  • connDetails(obj)
  • connLearn(conn, arg: null)
  • connPing(conn)
  • connPoints(conn, checked: true)
  • connPointsVia(points, libOrConn)
  • connSyncCur(points)
  • connSyncHis(points, span: null)
  • connTrace(conn, opts: null)
  • connTraceClear(conn)
  • connTraceDisable(conn)
  • connTraceDisableAll()
  • connTraceEnable(conn)
  • connTraceIsEnabled(conn)
    • src

概述(中译) ​

连接器框架


API 正文(英文) ​

tags ​

actorTimeoutTimeout for messages send to the connector's actor thread
connConnector for communication to a remote system
connErrError message associated when connStatus indicates an error condition
connFeaturesDefines the features supported by a given connector
connLingerLinger timeout used to keep a connector open
connOpenRetryFreqDuration used for connector open retries
connPingFreqDuration used to configure the auto-ping feature on a given connector
connPointPoint associated with a connector for data synchronization with a remote system
connStateCurrent connection state of a connector as one of the predefined strings
connStatusCurrent status of a connector as one of the predefined strings See Connectors
connTuningMarker applied to a rec which defines a tuning configuration
connTuningRefReference to a tuning configuration defined by a connTuning rec
curCalibrationCalibration value to apply to adjust the value read from the connector before updating curVal
curConvertConversion to apply when reading curVal from connector
hisConvertConversion to apply when reading history data from connector
pointConvertPoint value conversion used to normalize data to/from a remote system
pollTimeFrequency between polls of curVal
staleTimeTime before a point's curStatus marked from "ok" to "stale" See Connector Tuning
writeConvertConversion to apply when writing writeVal to the connector
writeMaxTimeMaximum time between writes used to send periodic writes
writeMinTimeMinimum time between writes used to throttle the speed of writes
writeOnOpenIssue a write every time the connector transitions from open to closed
writeOnStartIssue a write when the system first starts up

funcs ​

connCloseForce the given connector closed and return a future
connDetailsReturn debug details for a connector or a connector point
connLearnPerform a learn on the given connector and return a future
connPingPerform a ping on the given connector and return a future
connPointsReturn the points for a connector as list of dicts
connPointsViaSelect a group of points explicitly via specific connector library or connector
connSyncCurPerform a remote sync of current values for the given points
connSyncHisPerform a remote sync of history data for the given points
connTraceRead a connector trace log as a grid
connTraceClearClear the trace log for the given connector
connTraceDisableDisable tracing on the given connector
connTraceDisableAllDisable tracing on every connector in the database
connTraceEnableEnable tracing on the given connector
connTraceIsEnabledReturn true or false if given connector has its tracing enabled

views ​

connTraceView debug connector tracing
connTuningManage connector tuning records in the local project database
connsManage connectors in the local project database


def ​

actorTimeout ​

Timeout for messages send to the connector's actor thread. It must be a number with a duration unit. If omitted a default of 1min is used. This value effectively determines how long a blocking remote request should take before raising a timeout error. For protocols which communicate via HTTP/TCP it is also used to configure the socket's receive timeout. See Connector Tuning


meta ​

defactorTimeout
isduration
liblib:conn
tagOnconn

supertypes ​

valData value type
scalarScalar is an atomic value kind
numberInteger or floating point numbers annotated with an optional unit
durationNumber with a unit of time


def ​

conn ​

Connector for communication to a remote system. See Connectors


meta ​

defconn
isentity
liblib:conn
mandatory✓

supertypes ​

markerMarker labels a dict with typing information
entityTop-level dicts with a unique identifier

subtypes ​

arcbeamConnArcbeam connector
ecobeeConnEcobee connector
energyStarConnEnergy Star connector to a portfolio manager account
haystackConnHaystack connector to a Haystack REST API server
modbusConnModbus connector
mqttConnMQTT connector to an MQTT Broker
nestConnGoogle Nest connector
obixConnConnector to an oBIX HTTP server
opcConnMarker tag for OPC connector record which stores the configuration for connectivity to an OPC UA endpoint
sedonaConnSedona Sox connector to a remote device
snmpConnSNMP connector
sqlConnSQL connector to a relational database using JDBC
tplTrendConnTplTrend connector

tags ​

actorTimeoutTimeout for messages send to the connector's actor thread
connErrError message associated when connStatus indicates an error condition
connLingerLinger timeout used to keep a connector open
connOpenRetryFreqDuration used for connector open retries
connPingFreqDuration used to configure the auto-ping feature on a given connector
connStateCurrent connection state of a connector as one of the predefined strings
connStatusCurrent status of a connector as one of the predefined strings See Connectors
connTuningRefReference to a tuning configuration defined by a connTuning rec
disDisplay name for an entity
disabledIndicates the entity is in a disabled state
idDefines the unique identifier of an entity in system using a ref value type


def ​

connErr ​

Error message associated when connStatus indicates an error condition. See Connectors


meta ​

defconnErr
isstr
liblib:conn
tagOnconn
transient✓

supertypes ​

valData value type
scalarScalar is an atomic value kind
strUnicode string of characters


def ​

connFeatures ​

Defines the features supported by a given connector. This is a tag added to the conn def itself. The value is a dict with the following standardized keys:

  • learn: marker tag if point learn is supported
  • pollMode: manual or buckets

Also see Custom Connectors


meta ​

defconnFeatures
isdict
liblib:conn

supertypes ​

valData value type
dictMap of name/value tag pairs


def ​

connLinger ​

Linger timeout used to keep a connector open. If not configured then a default of 30sec is used. See Connector Tuning


meta ​

defconnLinger
isduration
liblib:conn
tagOnconn

supertypes ​

valData value type
scalarScalar is an atomic value kind
numberInteger or floating point numbers annotated with an optional unit
durationNumber with a unit of time


def ​

connOpenRetryFreq ​

Duration used for connector open retries. When a connector should be pinned opened for application use, then this frequency is used to periodically attempt retries. For example if a down connector has watched points, then this frequency is used to determine how often we retry to reopen the connection. The default is 10sec if not specified. See Connector Tuning


meta ​

defconnOpenRetryFreq
isduration
liblib:conn
tagOnconn

supertypes ​

valData value type
scalarScalar is an atomic value kind
numberInteger or floating point numbers annotated with an optional unit
durationNumber with a unit of time


def ​

connPingFreq ​

Duration used to configure the auto-ping feature on a given connector. When this tag is configured the connector will automatically attempt a ping based on the configured frequency. For connectors which might not have watched points this ensures periodic checks of the connectivity status. If this tag is not defined on a connector then the feature is disabled. See Connector Tuning


meta ​

defconnPingFreq
isduration
liblib:conn
tagOnconn

supertypes ​

valData value type
scalarScalar is an atomic value kind
numberInteger or floating point numbers annotated with an optional unit
durationNumber with a unit of time


def ​

connPoint ​

Point associated with a connector for data synchronization with a remote system.


meta ​

defconnPoint
ispoint
liblib:conn

usage ​

connPoint  point

supertypes ​

markerMarker labels a dict with typing information
entityTop-level dicts with a unique identifier
pointData point such as a sensor or actuator

subtypes ​

arcbeamPointPoint which synchronizes data via a arcbeam connector
ecobeePointPoint which synchronizes data via an Ecobee connector
haystackPointPoint which synchronizes data via a Haystack connector
modbusPointPoint which synchronizes data via a Haystack connector
mqttPointPoint which synchronizes data via a MQTT connector
nestPointPoint which synchronizes data via a Nest connector
obixPointPoint which synchronizes data via a oBIX connector
opcPointPoint which synchronizes data via an OPC connector
sedonaPointPoint which synchronizes data via a Sedona connector
snmpPointPoint which synchronizes data via an SNMP connector
sqlPointPoint which synchronizes data via a SQL connector
tplTrendPointPoint which synchronizes data via the TplTrend connector

tags ​

connTuningRefReference to a tuning configuration defined by a connTuning rec
curSupports current value
curCalibrationCalibration value to apply to adjust the value read from the connector before updating curVal
curConvertConversion to apply when reading curVal from connector
disDisplay name for an entity
disMacroDisplay name using macro syntax
disabledIndicates the entity is in a disabled state
enumDefines an eumeration of string key names
equipRefReference to equip which contains this entity
ghgFactorHisIdentifies point record with interval emission factor data that the Greenhouse Gas Emission Engine uses to calculate emissions
hisSupports historization of data
hisConvertConversion to apply when reading history data from connector
idDefines the unique identifier of an entity in system using a ref value type
kindKind name used to identity a value data type
maxValInclusive maximum for a numeric value
minValInclusive minimum for a numeric value
navNameNavigation name commonly used with disMacro to create computed display strings
pointFunctionClassifies the point as a sensor, command, or setpoint
pointQuantityQuantity the point senses or controls
pointSubjectWhat the point senses or controls
siteRefReference to site which contains the entity
spaceRefReference to space which contains this entity
systemRefReference to system
tzTimezone identifier from standard timezone database
unitUnit identifier from standard unit database
writableSupports writing data
writeConvertConversion to apply when writing writeVal to the connector


def ​

connState ​

Current connection state of a connector as one of the predefined strings. See Connectors


meta ​

defconnState
enumSee below
isstr
liblib:conn
tagOnconn
transient✓

enum ​

closedConnection is closed
closingConnection is currently being closed
openConnection is open
openingConnection is currently being opened

supertypes ​

valData value type
scalarScalar is an atomic value kind
strUnicode string of characters


def ​

connStatus ​

Current status of a connector as one of the predefined strings See Connectors


meta ​

defconnStatus
enumSee below
isstr
liblib:conn
tagOnconn
transient✓

enum ​

okAll is okay
faultConfiguration problem
downCommunication or network problem
disabledManual disable
unknownStatus not computed yet

supertypes ​

valData value type
scalarScalar is an atomic value kind
strUnicode string of characters


def ​

connTuning ​

Marker applied to a rec which defines a tuning configuration. See Connector Tuning


meta ​

defconnTuning
isentity
liblib:conn
mandatory✓

supertypes ​

markerMarker labels a dict with typing information
entityTop-level dicts with a unique identifier

tags ​

disDisplay name for an entity
idDefines the unique identifier of an entity in system using a ref value type
pollTimeFrequency between polls of curVal
staleTimeTime before a point's curStatus marked from "ok" to "stale" See Connector Tuning
writeMaxTimeMaximum time between writes used to send periodic writes
writeMinTimeMinimum time between writes used to throttle the speed of writes
writeOnOpenIssue a write every time the connector transitions from open to closed
writeOnStartIssue a write when the system first starts up


def ​

connTuningRef ​

Reference to a tuning configuration defined by a connTuning rec. See Connector Tuning


meta ​

defconnTuningRef
isref
liblib:conn
ofconnTuning
tagOnconn, connPoint, lib

supertypes ​

valData value type
scalarScalar is an atomic value kind
refReference to an entity


def ​

curCalibration ​

Calibration value to apply to adjust the value read from the connector before updating curVal. The conversion is applied to the ConnPoint.updateCurOk value after curConvert is applied and before writing curVal to the database. See Connectors


meta ​

defcurCalibration
isnumber
liblib:conn
tagOnconnPoint

supertypes ​

valData value type
scalarScalar is an atomic value kind
numberInteger or floating point numbers annotated with an optional unit


def ​

curConvert ​

Conversion to apply when reading curVal from connector. The conversion is applied to the ConnPoint.updateCurOk value before applying curCalibration and writing curVal to the database. See Connectors


meta ​

defcurConvert
ispointConvert
liblib:conn
tagOnconnPoint

supertypes ​

valData value type
scalarScalar is an atomic value kind
strUnicode string of characters
pointConvertPoint value conversion used to normalize data to/from a remote system


def ​

func:connClose ​

connClose(conn) ​

Force the given connector closed and return a future. The future result is the connector rec dict. The conn parameter may be anything accepted by toRecId().

Examples:

read(conn).connClose
connClose(connId)

meta ​

admin✓
deffunc:connClose
isfunc
liblib:conn
nameconnClose

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:connDetails ​

connDetails(obj) ​

Return debug details for a connector or a connector point. The argument is anything acceptable by toRecId(). The result is returned as a plain text string.


meta ​

admin✓
deffunc:connDetails
isfunc
liblib:conn
nameconnDetails

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:connLearn ​

connLearn(conn, arg: null) ​

Perform a learn on the given connector and return a future. The future result is the learn grid. The conn parameter may be anything acceptable by toRecId(). The arg is an opaque identifier used to walk the learn tree via the learn column. Pass null for arg to return the root of the learn tree.

Examples:

connLearn(connId, learnArg)

meta ​

admin✓
deffunc:connLearn
isfunc
liblib:conn
nameconnLearn

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:connPing ​

connPing(conn) ​

Perform a ping on the given connector and return a future. The future result is the connector rec dict. The conn parameter may be anything accepted by toRecId().

Examples:

read(conn).connPing
connPing(connId)

meta ​

admin✓
deffunc:connPing
isfunc
liblib:conn
nameconnPing

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:connPoints ​

connPoints(conn, checked: true) ​

Return the points for a connector as list of dicts. The conn parameter may be anything accepted by toRecId(). If conn cannot be be mapped to an active connector then raise an exception or return an empty list based on checked flag.

Examples:

read(haystackConn).connPoints
connPoints(@my-conn-id)

meta ​

deffunc:connPoints
isfunc
liblib:conn
nameconnPoints

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:connPointsVia ​

connPointsVia(points, libOrConn) ​

Select a group of points explicitly via specific connector library or connector. This function is required when points are associated with multiple connectors. Pass a connector library name to select for a protocol. Or pass a connector id/rec to select via a specific connector. Also see Connectors.

Examples:

// explicitly sync via the SQL connector library
readAll(sqlConnRef).connPointsVia("sql").connSyncHis

// get debug details for specific connector
connPointsVia(pt, pt->bacnetConnRef).connDetails

meta ​

admin✓
deffunc:connPointsVia
isfunc
liblib:conn
nameconnPointsVia

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:connSyncCur ​

connSyncCur(points) ​

Perform a remote sync of current values for the given points. The points parameter may be anything acceptable by toRecIdList(). Return a list of futures for each unique connector. The result of each future is unspecified. Also see Connectors.

Examples:

readAll(bacnetCur).connSyncCur

meta ​

admin✓
deffunc:connSyncCur
isfunc
liblib:conn
nameconnSyncCur

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:connSyncHis ​

connSyncHis(points, span: null) ​

Perform a remote sync of history data for the given points. The points parameter may be anything acceptable by toRecIdList(). The span parameter is anything acceptable by toSpan(). Or pass null for span to perform a sync for items after the point's hisEnd. This blocks the calling thread until each point is synchronized one by one. Normally it should only be called within a task. The result from this function is undefined. Also see Connectors.

Examples:

readAll(haystackHis).connSyncHis(null)

meta ​

admin✓
deffunc:connSyncHis
isfunc
liblib:conn
nameconnSyncHis

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:connTrace ​

connTrace(conn, opts: null) ​

Read a connector trace log as a grid. If tracing is not enabled for the given connector, then an empty grid is returned. The conn parameter may be anything acceptable by toRecId().

Examples:

read(conn).connTrace
connTrace(connId)

meta ​

admin✓
deffunc:connTrace
isfunc
liblib:conn
nameconnTrace

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:connTraceClear ​

connTraceClear(conn) ​

Clear the trace log for the given connector. The conn parameter can be anything acceptable by toRecId().


meta ​

admin✓
deffunc:connTraceClear
isfunc
liblib:conn
nameconnTraceClear

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:connTraceDisable ​

connTraceDisable(conn) ​

Disable tracing on the given connector. The conn parameter can be anything acceptable by toRecId().


meta ​

admin✓
deffunc:connTraceDisable
isfunc
liblib:conn
nameconnTraceDisable

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:connTraceDisableAll ​

connTraceDisableAll() ​

Disable tracing on every connector in the database.


meta ​

admin✓
deffunc:connTraceDisableAll
isfunc
liblib:conn
nameconnTraceDisableAll

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:connTraceEnable ​

connTraceEnable(conn) ​

Enable tracing on the given connector. The conn parameter can be anything acceptable by toRecId().


meta ​

admin✓
deffunc:connTraceEnable
isfunc
liblib:conn
nameconnTraceEnable

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:connTraceIsEnabled ​

connTraceIsEnabled(conn) ​

Return true or false if given connector has its tracing enabled. The conn parameter can be anything acceptable by toRecId().


meta ​

admin✓
deffunc:connTraceIsEnabled
isfunc
liblib:conn
nameconnTraceIsEnabled

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

hisConvert ​

Conversion to apply when reading history data from connector. The conversion is applied to each item passed to ConnPoint.updateHisOk before writing to the database. This conversion happens before the hisOnWrite conversion hooks. See Connectors


meta ​

defhisConvert
ispointConvert
liblib:conn
tagOnconnPoint

supertypes ​

valData value type
scalarScalar is an atomic value kind
strUnicode string of characters
pointConvertPoint value conversion used to normalize data to/from a remote system


def ​

pointConvert ​

Point value conversion used to normalize data to/from a remote system. See Connectors


meta ​

defpointConvert
isstr
liblib:conn

supertypes ​

valData value type
scalarScalar is an atomic value kind
strUnicode string of characters

subtypes ​

curConvertConversion to apply when reading curVal from connector
hisConvertConversion to apply when reading history data from connector
writeConvertConversion to apply when writing writeVal to the connector


def ​

pollTime ​

Frequency between polls of curVal. See Connector Tuning.


meta ​

defpollTime
isduration
liblib:conn
tagOnconnTuning

supertypes ​

valData value type
scalarScalar is an atomic value kind
numberInteger or floating point numbers annotated with an optional unit
durationNumber with a unit of time


def ​

staleTime ​

Time before a point's curStatus marked from "ok" to "stale" See Connector Tuning.


meta ​

defstaleTime
isduration
liblib:conn
tagOnconnTuning

supertypes ​

valData value type
scalarScalar is an atomic value kind
numberInteger or floating point numbers annotated with an optional unit
durationNumber with a unit of time


def ​

view:connTrace ​

View debug connector tracing


meta ​

admin✓
appNameconn
defview:connTrace
disKeyui::trace
iconview
isview
liblib:conn
order110

supertypes ​

featureFeature namespace of definitions formatted as feature:name
viewFresco UI view

src ​

view:    { uiType:"uiBuilder::ConnTraceView" }
conn:    { input var kind:"Ref<conn>" }
types:   { input var kind:"Str" defVal:"phase,dispatch,req,res,event,log" uiInput:"uiBuilder::ConnTraceTypesInput" }
ping:    { action:"connPing" select noFlash }
close:   { action:"connClose" select noFlash }
enable:  { action:"connTraceEnable" select noFlash }
disable: { action:"connTraceDisable" select noFlash }
clear:   { action:"connTraceClear" select noFlash }
menu:    { action:"uiContextMenu" selInput:"conn"}
details: { action:"connBuilderDetails" select }
data:    { expr:"connTrace({{conn}}, {types:{{types}}})" }


def ​

view:connTuning ​

Manage connector tuning records in the local project database


meta ​

admin✓
appNameconn
defview:connTuning
defNameconnTuning
disKeyui::tuning
iconview
isview
liblib:conn
order105

supertypes ​

featureFeature namespace of definitions formatted as feature:name
viewFresco UI view

src ​

view:    { inherit:"table" }
search:  { input var kind:"Str" defVal:"" }
new:     { action:"recNew" }
edit:    { action:"recEdit" }
trash:   { action:"recTrash" }
data:    { expr:"readAll(connTuning, { sort, search:{{search}} })" }


def ​

view:conns ​

Manage connectors in the local project database


meta ​

admin✓
appNameconn
defview:conns
disKeyui::connector
iconview
isview
liblib:conn
order100

supertypes ​

featureFeature namespace of definitions formatted as feature:name
viewFresco UI view

src ​

view: { uiType:"uiBuilder::ConnBuilder" }
menu: { action:"uiContextMenu" }


def ​

writeConvert ​

Conversion to apply when writing writeVal to the connector. The conversion is applied to writeVal before calling ConnDispatch.onWrite. See Connectors


meta ​

defwriteConvert
ispointConvert
liblib:conn
tagOnconnPoint

supertypes ​

valData value type
scalarScalar is an atomic value kind
strUnicode string of characters
pointConvertPoint value conversion used to normalize data to/from a remote system


def ​

writeMaxTime ​

Maximum time between writes used to send periodic writes. See Connector Tuning.


meta ​

defwriteMaxTime
isduration
liblib:conn
tagOnconnTuning

supertypes ​

valData value type
scalarScalar is an atomic value kind
numberInteger or floating point numbers annotated with an optional unit
durationNumber with a unit of time


def ​

writeMinTime ​

Minimum time between writes used to throttle the speed of writes. See Connector Tuning.


meta ​

defwriteMinTime
isduration
liblib:conn
tagOnconnTuning

supertypes ​

valData value type
scalarScalar is an atomic value kind
numberInteger or floating point numbers annotated with an optional unit
durationNumber with a unit of time


def ​

writeOnOpen ​

Issue a write every time the connector transitions from open to closed. See Connector Tuning.


meta ​

defwriteOnOpen
ismarker
liblib:conn
tagOnconnTuning

supertypes ​

markerMarker labels a dict with typing information


def ​

writeOnStart ​

Issue a write when the system first starts up. If missing then the first write is suppressed on startup. See Connector Tuning.


meta ​

defwriteOnStart
ismarker
liblib:conn
tagOnconnTuning

supertypes ​

markerMarker labels a dict with typing information