外观
lib-obix 库参考
原文: https://finproducts.atlassian.net/wiki/spaces/JIDD3/pages/34793914668/FIN+5.3.1+lib-obix 中文整理基于 FIN 5.3.1
导读: 本页为
lib-obix的 API / 标签 / 函数参考文档。
以下为 API 参考,保留英文以便对照源码;目录已列出(英文标题便于检索);概述已尽量中译。
目录(导读)
- lib
- meta
- docs
- tags
- funcs
- Overview
- Server URIs
- Server Rec to Obix Mapping
- Server Watches
- Obix Connectors
- Obix Connector Points
- Obix Cur
- Obix Writes
- Obix His
- def
- obixInvoke(conn, uri, arg)
- obixPing(conn)
- obixReadHis(conn, uri, span)
- obixReadObj(conn, uri)
- obixSyncCur(points)
- obixSyncHis(points, span: null)
- obixWriteObj(conn, uri, arg)
概述(中译)
oBIX 连接器
API 正文(英文)
docs
Overview • Server URIs • Server Rec to Obix Mapping • Server Watches • Obix Connectors • Obix Connector Points
tags
| obixConn | Connector to an oBIX HTTP server |
| obixConnRef | Used on a proxy point to reference its parent obixConn |
| obixCur | Used on a oBIX proxy point to store the URI of the entity in the remote system used to read and watch curVal |
| obixHis | URI of the obix:History to synchronized history data |
| obixLobby | The lobby URI is used to address an obixConn API endpoint |
| obixPoint | Point which synchronizes data via a oBIX connector |
| obixPollFreq | Duration between obixConn watch polls |
| obixWritable | Server export of a writable point as an obix:Writable:Point |
| obixWrite | URI of the obix:WritablePoint to write writeVal |
| obixWriteLevel | Number between 1 and 16 used with obixWrite to determine which priority level of the remote system is written to |
funcs
| obixInvoke | Invoke an obix:op operation as identified by given uri |
| obixPing | Deprecated - use connPing() |
| obixReadHis | Synchronously query a obix::History for its timestamp/value pairs |
| obixReadObj | Read one Uri from an obixConn |
| obixSyncCur | Deprecated - use connSyncCur() |
| obixSyncHis | Deprecated - use connSyncHis() |
| obixWriteObj | Write an object as identified by given uri |
lib obix
Overview
The Obix protocol is a REST protocol which uses an XML encoding. The Obix connector implements both the client and server side of the protocol. The following features are supported:
Obix Server
- reads of any record
- history queries (any record tagged as
hismaps toobix:History) - writable points are supported (if annotated correctly)
- batch operations are supported
- watches on records are supported
- alarming is not supported
Obix Client
- Obix connectors
- proxy real-time points and watches supported
- proxy writable points supported
- proxy histories and synchronization supported
- reads, writes, invokes all supported
- alarming is not supported
Server URIs
The following table summarizes the URIs of the Obix server API:
Uri Object
------------------------ -------------
{base}/obix/ lobby
{base}/obix/about/ about
{base}/obix/batch/ batch op
{base}/obix/watchService/ watch service
{base}/obix/watch/{id}/ watch operations
{base}/obix/query/{filter} query recs using filter
{base}/obix/rec/{id|name}/ record
{base}/obix/rec/{id|name}/{tag} tag
{base}/obix/icon/{id}/{uri} icon tunnellingOn Haxall nodes {base} will be /api and on SkySpark it will be /api/{proj}/ext.
Server Rec to Obix Mapping
The general rules are applied to map Folio records to Obix objects:
- marker tags are mapped to the
iscontract astag:{name} - tag name/value pairs are mapped as child objects of the appropriate scalar type
- the
distag is mapped to thedisplayNamefacet
Example:
// folio
{id:1331259c-95d44d6a, dis:"Bob", age:37, bday:1973-07-11,
person, married, spouse:1331364b-eee35493}
// obix
<obj is="tag:person tag:married"
displayName="Bob"
href="/api/proj/ext/obix/rec/1331259c-95d44d6a/">
<dis name="dis" href="dis" val="Bob"/>
<int name="age" href="age" val="37"/>
<date name="bday" href="bday" val="1973-07-11"/>
<ref name="spouse" href="/api/proj/ext/obix/1331364b-eee35493/"/>
</obj>The following tags map to Obix contracts:
pointmaps toobix:PointobixWritablemaps toobix:WritablePointhismaps toobix:HistorycurValmaps to point objectvalattributecurStatusmaps to a point objectstatusattribute
For example given this point record:
id: 1746a5e5-a5d285cb
point
his
dis: <Site-A RTU-2 Zone-Temp>
siteRef: <Site-A>
equipRef: <Site-A RTU-2>
zone
air
temp
sensor
curVal: 72°F
tz: New_York
kind: NumberMaps to this Obix representation
<real href="/api/proj/ext/obix/rec/1746a5e5-a5d285cb/"
is="obix:Point obix:History tag:air tag:his tag:point tag:sensor tag:temp tag:zone"
displayName="Site-A RTU-2 Zone-Temp"
val="72" status="ok">
<str name="tz" val="America/New_York"/>
<op name="query" href="query" in="obix:HistoryFilter" out="obix:HistoryQueryOut"/>
<str name="dis" href="dis" val="Site-A RTU-2 ZoneTemp"/>
<ref name="equipRef" href="/api/proj/ext/obix/rec/1746a5e5-920b2573/" display="Site-A RTU-2"/>
<strname="kind" href="kind" val="Number"/>
<ref name="siteRef" href="/api/proj/ext/obix/rec/1746a5e5-7f296626/" display="Site-A"/>
</real>Server Watches
The Obix server allows watches at the record level. Watch URIs must be formatted exactly as follows:
{base}/obix/rec/{id}/Any attempt to use a URI which doesn't match that format exactly or is missing a trailing slash will result in a BadUriErr for the subscription. Obix server watches map directly to a HxWatch.
On the initial poll, reference tags of type Ref will have their display attribute available for the record reference. But all polls will omit the display attribute for performance.
Obix Connectors
Client functionality is based on Obix Connectors which are created using the obixConn tag. Connectors are used to configure client settings to communicate with a remote Obix server using these tags:
conn: required marker tagobixConn: required marker tagobixLobby: the absolute URI of the server's lobby (should end in a trailing slash)username: user name for authenticationpassword: must have password stored in password db for connector's record id
Obix connectors are built with the connector framework and follow all the standard conventions.
Obix connectors will use Haystack authentication to connect to the remote system. You can force HTTP basic authentication by adding the marker tag obixBasicAuth to your connector record.
After the first read operation with the connector (see obixPing()) the following tags are available on the connector:
- vendorName: from about object
- productName: from about object
- productVersion: from about object
- tz: timezone name of remote obix server
Some older versions of Obix may not be able to derive the tz tag from the ping, in which case you should manually configure the tag to ensure that its available for history functions.
Obix Connector Points
Obix proxy points are configured under a given connector using the following tags:
obixConnRef: references the Obix connectorobixCur: URI to use for current value watchesobixWrite: URI to for writable pointsobixHis: URI to use forobix:Historyfor history synchronization
Obix Cur
When an point with the obixCur tag is put into watch, it subscribes to a watch on the Obix server. This subscription is used to maintain the current point value via the curVal. Watches are polled with a default frequency of 1sec; you can tune this frequency with the obixPollFreq tag.
Also see point.
Obix Writes
The obixWrite URI is used to configure the writePoint operation of an obix:WritablePoint. Note the URI must reference the operation inside the point object. Changes to the local writable point are written to the remote oBIX point.
Also see point.
Obix His
A proxy point with the obixHis tag is used to pull historical data from an Obix connector into the local historian. The Axon function connSyncHis() is used pull the latest history data over the Obix connector into the local historian. You can use these functions to write your own customized synchronization scripts. The general convention is to schedule history sync via tasks.
Also see point.
def
func:obixInvoke
obixInvoke(conn, uri, arg)
Invoke an obix:op operation as identified by given uri. See obixWriteObj() for supported arg values and obixReadObj() for result object.
meta
| admin | ✓ |
| def | func:obixInvoke |
| is | func |
| lib | lib:obix |
| name | obixInvoke |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:obixPing
obixPing(conn)
Deprecated - use connPing()
meta
| admin | ✓ |
| def | func:obixPing |
| deprecated | ✓ |
| is | func |
| lib | lib:obix |
| name | obixPing |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:obixReadHis
obixReadHis(conn, uri, span)
Synchronously query a obix::History for its timestamp/value pairs. Range may be any valid object used with his queries.
meta
| admin | ✓ |
| def | func:obixReadHis |
| is | func |
| lib | lib:obix |
| name | obixReadHis |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:obixReadObj
obixReadObj(conn, uri)
Read one Uri from an obixConn. The object is returned as a grid with the object's meta-data returned via grid.meta and each immediate child returned as a row in the grid. The tags used for grid meta and the columns are:
- href: meta.href is absolute uri of object, the href col is child's uri relative to meta.href
- name: obix
nameattribute - dis: obix
displayNameattribute - val: obix
valattribute unlessnullattribute is true - is: contract list
- icon: uri relative to meta.href of icon
You can read the icon via the tunnel URI:
{api}/obix/icon/{id}/{uri}Side effects:
- performs blocking network IO
meta
| admin | ✓ |
| def | func:obixReadObj |
| is | func |
| lib | lib:obix |
| name | obixReadObj |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:obixSyncCur
obixSyncCur(points)
Deprecated - use connSyncCur()
meta
| admin | ✓ |
| def | func:obixSyncCur |
| deprecated | ✓ |
| is | func |
| lib | lib:obix |
| name | obixSyncCur |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:obixSyncHis
obixSyncHis(points, span: null)
Deprecated - use connSyncHis()
meta
| admin | ✓ |
| def | func:obixSyncHis |
| deprecated | ✓ |
| is | func |
| lib | lib:obix |
| name | obixSyncHis |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:obixWriteObj
obixWriteObj(conn, uri, arg)
Write an object as identified by given uri. The following arg values are supported:
arg oBIX
--- -----
null <obj null='true'/>
"foo" <str val='foo'/>
true <bool val='true'/>
123 <real val='123.0'/>
123m <real val='123.0' unit='obix:units/meter'/>
`foo.txt` <uri val='foo.txt'/>
2012-03-06 <date val='2012-03-06'/>
23:15 <time val='23:15:00'/>
DateTime <abstime val='...' tz='...'/>
XML Str pass thruResult object is transformed using same rules as obixReadObj().
meta
| admin | ✓ |
| def | func:obixWriteObj |
| is | func |
| lib | lib:obix |
| name | obixWriteObj |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
obixConn
Connector to an oBIX HTTP server.
meta
| connFeatures | |
| def | obixConn |
| icon | obix |
| is | conn |
| lib | lib:obix |
usage
| obixConn conn |
supertypes
| marker | Marker labels a dict with typing information |
| entity | Top-level dicts with a unique identifier |
| conn | Connector for communication to a remote system |
tags
| actorTimeout | Timeout for messages send to the connector's actor thread |
| connErr | Error message associated when connStatus indicates an error condition |
| connLinger | Linger timeout used to keep a connector open |
| connOpenRetryFreq | Duration used for connector open retries |
| connPingFreq | Duration used to configure the auto-ping feature on a given connector |
| connState | Current connection state of a connector as one of the predefined strings |
| connStatus | Current status of a connector as one of the predefined strings See Connectors |
| connTuningRef | Reference to a tuning configuration defined by a connTuning rec |
| dis | Display name for an entity |
| disabled | Indicates the entity is in a disabled state |
| id | Defines the unique identifier of an entity in system using a ref value type |
| obixLobby | The lobby URI is used to address an obixConn API endpoint |
| obixPollFreq | Duration between obixConn watch polls |
| password | Manages password which is hashed/stored to the password store |
| username | Username for an authentication account |
def
obixConnRef
Used on a proxy point to reference its parent obixConn
meta
| def | obixConnRef |
| is | ref |
| lib | lib:obix |
| of | obixConn |
| tagOn | obixPoint |
supertypes
| val | Data value type |
| scalar | Scalar is an atomic value kind |
| ref | Reference to an entity |
def
obixCur
Used on a oBIX proxy point to store the URI of the entity in the remote system used to read and watch curVal.
meta
| def | obixCur |
| is | uri |
| lib | lib:obix |
| tagOn | obixPoint |
supertypes
| val | Data value type |
| scalar | Scalar is an atomic value kind |
| uri | Universal resource identifier |
def
obixHis
URI of the obix:History to synchronized history data.
meta
| def | obixHis |
| is | uri |
| lib | lib:obix |
| tagOn | obixPoint |
supertypes
| val | Data value type |
| scalar | Scalar is an atomic value kind |
| uri | Universal resource identifier |
def
obixLobby
The lobby URI is used to address an obixConn API endpoint.
meta
| def | obixLobby |
| is | uri |
| lib | lib:obix |
| tagOn | obixConn |
supertypes
| val | Data value type |
| scalar | Scalar is an atomic value kind |
| uri | Universal resource identifier |
def
obixPoint
Point which synchronizes data via a oBIX connector
meta
| def | obixPoint |
| is | connPoint |
| lib | lib:obix |
usage
| obixPoint point |
supertypes
| marker | Marker labels a dict with typing information |
| entity | Top-level dicts with a unique identifier |
| point | Data point such as a sensor or actuator |
| connPoint | Point associated with a connector for data synchronization with a remote system |
tags
| connTuningRef | Reference to a tuning configuration defined by a connTuning rec |
| cur | Supports current value |
| curCalibration | Calibration value to apply to adjust the value read from the connector before updating curVal |
| curConvert | Conversion to apply when reading curVal from connector |
| dis | Display name for an entity |
| disMacro | Display name using macro syntax |
| disabled | Indicates the entity is in a disabled state |
| enum | Defines an eumeration of string key names |
| equipRef | Reference to equip which contains this entity |
| ghgFactorHis | Identifies point record with interval emission factor data that the Greenhouse Gas Emission Engine uses to calculate emissions |
| his | Supports historization of data |
| hisConvert | Conversion to apply when reading history data from connector |
| id | Defines the unique identifier of an entity in system using a ref value type |
| kind | Kind name used to identity a value data type |
| maxVal | Inclusive maximum for a numeric value |
| minVal | Inclusive minimum for a numeric value |
| navName | Navigation name commonly used with disMacro to create computed display strings |
| obixConnRef | Used on a proxy point to reference its parent obixConn |
| obixCur | Used on a oBIX proxy point to store the URI of the entity in the remote system used to read and watch curVal |
| obixHis | URI of the obix:History to synchronized history data |
| obixWrite | URI of the obix:WritablePoint to write writeVal |
| obixWriteLevel | Number between 1 and 16 used with obixWrite to determine which priority level of the remote system is written to |
| pointFunction | Classifies the point as a sensor, command, or setpoint |
| pointQuantity | Quantity the point senses or controls |
| pointSubject | What the point senses or controls |
| siteRef | Reference to site which contains the entity |
| spaceRef | Reference to space which contains this entity |
| systemRef | Reference to system |
| tz | Timezone identifier from standard timezone database |
| unit | Unit identifier from standard unit database |
| writable | Supports writing data |
| writeConvert | Conversion to apply when writing writeVal to the connector |
def
obixPollFreq
Duration between obixConn watch polls. If not configured it defaults to 1sec.
meta
| def | obixPollFreq |
| is | duration |
| lib | lib:obix |
| tagOn | obixConn |
| val | 1sec |
supertypes
| val | Data value type |
| scalar | Scalar is an atomic value kind |
| number | Integer or floating point numbers annotated with an optional unit |
| duration | Number with a unit of time |
def
obixWritable
Server export of a writable point as an obix:Writable:Point. The value must be a level between 1 and 17 which determines which level is written by the writePoint operation.
meta
| def | obixWritable |
| is | int |
| lib | lib:obix |
supertypes
| val | Data value type |
| scalar | Scalar is an atomic value kind |
| number | Integer or floating point numbers annotated with an optional unit |
| int | Unitless integer number |
def
obixWrite
URI of the obix:WritablePoint to write writeVal.
meta
| def | obixWrite |
| is | uri |
| lib | lib:obix |
| tagOn | obixPoint |
supertypes
| val | Data value type |
| scalar | Scalar is an atomic value kind |
| uri | Universal resource identifier |
def
obixWriteLevel
Number between 1 and 16 used with obixWrite to determine which priority level of the remote system is written to.
meta
| def | obixWriteLevel |
| is | int |
| lib | lib:obix |
| maxVal | 16 |
| minVal | 1 |
| tagOn | obixPoint |
supertypes
| val | Data value type |
| scalar | Scalar is an atomic value kind |
| number | Integer or floating point numbers annotated with an optional unit |
| int | Unitless integer number |