Skip to content

lib-haystack 库参考 ​

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

导读: Haystack HTTP API 连接器

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


目录(导读) ​

  • lib
  • meta
  • docs
  • tags
  • funcs
  • Overview
  • Current Points
  • Writable Points
  • His Sync
  • haystackCall(conn, op, req: null, checked: true)
  • haystackEval(conn, expr, opts: null)
  • haystackHisRead(conn, id, range)
  • haystackInvokeAction(conn, id, action, args: null)
  • haystackLearn(conn, arg: null)
  • haystackPing(conn)
  • haystackRead(conn, filterExpr, checked: true)
  • haystackReadAll(conn, filterExpr)
  • haystackReadById(conn, id, checked: true)
  • haystackReadByIds(conn, ids, checked: true)
  • haystackSyncCur(points)
  • haystackSyncHis(points, span: null)

概述(中译) ​

Haystack HTTP API 连接器


API 正文(英文) ​

docs ​

Overview • Current Points • Writable Points • His Sync


tags ​

haystackConnHaystack connector to a Haystack REST API server
haystackConnRefUsed on a proxy point to reference its parent haystackConn
haystackCurUsed on a haystack proxy point to store the id of the entity in the remote system used to read and watch curVal
haystackHisUsed on a haystack proxy point object to store the id of the historized point in the remote system used to sync history data
haystackPointPoint which synchronizes data via a Haystack connector
haystackPollFreqApplied to haystackConn to tune the duration between watch polls
haystackWriteUsed on a haystack proxy point to store the id of the entity in the remote system used to write writeVal
haystackWriteLevelNumber between 1 and 16 used with haystackWrite to determine which priority level of the remote system is written to

funcs ​

haystackCallPerform Haystack HTTP API call to given Str op name and with given request grid (can be anything acceptable toGrid())
haystackEvalEvaluate an Axon expression in a remote server over a haystack connector
haystackHisReadPerform Haystack REST API "hisRead" call to read history data for the record identified by the id (must be Ref)
haystackInvokeActionInvoke a remote action on the given Haystack connector and remote entity
haystackLearnDeprecated - use connLearn()
haystackPingDeprecated - use connPing()
haystackReadPerform Haystack REST API call to read single entity with filter
haystackReadAllPerform Haystack REST API call to read all entities with filter
haystackReadByIdPerform Haystack HTTP API call to read a record by its unique identifier
haystackReadByIdsPerform Haystack HTTP API call to read a list of records by their identifiers
haystackSyncCurDeprecated - use connSyncCur()
haystackSyncHisDeprecated - use connSyncHis()

lib haystack ​

Overview ​

This library provides a client connector for the Haystack HTTP API This connector can be used to communicate with other Haxall and SkySpark systems which all implement the server side of the Haystack API protocol. It is also commonly used to communicate with Niagara via the nHaystack and nhaystackAx modules.

The haystack connector provides full support for the following connector features:

  • Learn tree via the nav op
  • Current value subscription using watches
  • Writable point support using pointWrite op
  • History sync using the hisRead op

Note the haystackCur, haystackWrite, and haystackHis addresses for this connector must all be strings (not refs). This prevents them from being confused as internal references.

Current Points ​

Haystack proxy points are configured with haystackCur tag. Subscription uses Haystack watches to subscribe to the remote points current value. Watches use a poll for change design; you can tune the poll frequency via the haystackPollFreq connector tag.

Writable Points ​

Haystack proxy points are configured to write to remote system points via the haystackWrite tag. The priority level to write to in the remote system must be configured via the haystackWriteLevel tag. The following point would write its computed writeVal to level 14 of "remote-point":

point
writable
haystackConnRef: @conn
haystackWrite: "remote-point"
haystackWriteLevel: 14

His Sync ​

Haystack proxy points are configured for history synchronization via the haystackHis tag. These points use the hisRead op to read history data from the remote system.



def ​

func:haystackCall ​

haystackCall(conn, op, req: null, checked: true) ​

Perform Haystack HTTP API call to given Str op name and with given request grid (can be anything acceptable toGrid()). If the checked flag is true and server returns an error grid, then raise CallErr, otherwise return the grid itself. Result is returned as Grid. Also see Client.call.


meta ​

admin✓
deffunc:haystackCall
isfunc
liblib:haystack
namehaystackCall

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:haystackEval ​

haystackEval(conn, expr, opts: null) ​

Evaluate an Axon expression in a remote server over a haystack connector. The remote server must be a SkySpark server which supports the "eval" REST op with an Axon expression. This function blocks while the network request is made. The result is always returned as a Grid using the same rules as Etc.toGrid.

The expression to evaluate in the remote server may capture variables from the local scope. If these variables are atomic types, then they are captured as defined by local scope and serialized to the remote server. Pass {debug} for opts to dump to stdout the actual expr with serialized scope.

Options:

  • debug: dumps full expr with seralized scope to stdout
  • evalTimeout: duration number to override remote project's default evalTimeout

Examples:

read(haystackConn).haystackEval(3 + 4)
read(haystackConn).haystackEval(readAll(site))
read(haystackConn).haystackEval(readAll(kw).hisRead(yesterday))

meta ​

admin✓
deffunc:haystackEval
isfunc
liblib:haystack
namehaystackEval

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:haystackHisRead ​

haystackHisRead(conn, id, range) ​

Perform Haystack REST API "hisRead" call to read history data for the record identified by the id (must be Ref). The range is any string encoding supported by the REST API or any value supported by toDateSpan(). Return results as grid with "ts" and "val" column.


meta ​

admin✓
deffunc:haystackHisRead
isfunc
liblib:haystack
namehaystackHisRead

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:haystackInvokeAction ​

haystackInvokeAction(conn, id, action, args: null) ​

Invoke a remote action on the given Haystack connector and remote entity. The id must be a Ref of the remote entity's identifier and action is a Str action name. If args are specified, then they should be a Dict keyed by parameter name.


meta ​

admin✓
deffunc:haystackInvokeAction
isfunc
liblib:haystack
namehaystackInvokeAction

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:haystackLearn ​

haystackLearn(conn, arg: null) ​

Deprecated - use connLearn()


meta ​

admin✓
deffunc:haystackLearn
deprecated✓
isfunc
liblib:haystack
namehaystackLearn

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:haystackPing ​

haystackPing(conn) ​

Deprecated - use connPing()


meta ​

admin✓
deffunc:haystackPing
deprecated✓
isfunc
liblib:haystack
namehaystackPing

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:haystackRead ​

haystackRead(conn, filterExpr, checked: true) ​

Perform Haystack REST API call to read single entity with filter. The filter is an expression like readAll(). Return result as dict. If the record is not found, then return null or raise UnknownRecErr based on checked flag. Also see Client.read.


meta ​

admin✓
deffunc:haystackRead
isfunc
liblib:haystack
namehaystackRead

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:haystackReadAll ​

haystackReadAll(conn, filterExpr) ​

Perform Haystack REST API call to read all entities with filter. The filter is an expression like readAll(). Return results as grid. Also see Client.readAll.


meta ​

admin✓
deffunc:haystackReadAll
isfunc
liblib:haystack
namehaystackReadAll

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:haystackReadById ​

haystackReadById(conn, id, checked: true) ​

Perform Haystack HTTP API call to read a record by its unique identifier. Return result as dict. If the record is not found, then return null or raise UnknownRecErr based on checked flag. Also see Client.readById.


meta ​

admin✓
deffunc:haystackReadById
isfunc
liblib:haystack
namehaystackReadById

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:haystackReadByIds ​

haystackReadByIds(conn, ids, checked: true) ​

Perform Haystack HTTP API call to read a list of records by their identifiers. Return a grid where each row of the grid maps to the respective id list (indexes line up). If checked is true and any one of the ids cannot be resolved then raise UnknownRecErr for first id not resolved. If checked is false, then each id not found has a row where every cell is null. Also see Client.readByIds.


meta ​

admin✓
deffunc:haystackReadByIds
isfunc
liblib:haystack
namehaystackReadByIds

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:haystackSyncCur ​

haystackSyncCur(points) ​

Deprecated - use connSyncCur()


meta ​

admin✓
deffunc:haystackSyncCur
deprecated✓
isfunc
liblib:haystack
namehaystackSyncCur

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:haystackSyncHis ​

haystackSyncHis(points, span: null) ​

Deprecated - use connSyncHis()


meta ​

admin✓
deffunc:haystackSyncHis
deprecated✓
isfunc
liblib:haystack
namehaystackSyncHis

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

haystackConn ​

Haystack connector to a Haystack REST API server.


meta ​

connFeatures
defhaystackConn
iconhaystack
isconn
liblib:haystack

usage ​

haystackConn  conn

supertypes ​

markerMarker labels a dict with typing information
entityTop-level dicts with a unique identifier
connConnector for communication to a remote system

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
haystackPollFreqApplied to haystackConn to tune the duration between watch polls
idDefines the unique identifier of an entity in system using a ref value type
passwordManages password which is hashed/stored to the password store
tzTimezone identifier from standard timezone database
uriUniversal resource identifier
usernameUsername for an authentication account


def ​

haystackConnRef ​

Used on a proxy point to reference its parent haystackConn


meta ​

defhaystackConnRef
isref
liblib:haystack
ofhaystackConn
tagOnhaystackPoint

supertypes ​

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


def ​

haystackCur ​

Used on a haystack proxy point to store the id of the entity in the remote system used to read and watch curVal.


meta ​

defhaystackCur
isstr
liblib:haystack
tagOnhaystackPoint

supertypes ​

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


def ​

haystackHis ​

Used on a haystack proxy point object to store the id of the historized point in the remote system used to sync history data.


meta ​

defhaystackHis
isstr
liblib:haystack
tagOnhaystackPoint

supertypes ​

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


def ​

haystackPoint ​

Point which synchronizes data via a Haystack connector.


meta ​

defhaystackPoint
isconnPoint
liblib:haystack

usage ​

haystackPoint  point

supertypes ​

markerMarker labels a dict with typing information
entityTop-level dicts with a unique identifier
pointData point such as a sensor or actuator
connPointPoint associated with a connector for data synchronization with a remote system

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
haystackConnRefUsed on a proxy point to reference its parent haystackConn
haystackCurUsed on a haystack proxy point to store the id of the entity in the remote system used to read and watch curVal
haystackHisUsed on a haystack proxy point object to store the id of the historized point in the remote system used to sync history data
haystackWriteUsed on a haystack proxy point to store the id of the entity in the remote system used to write writeVal
haystackWriteLevelNumber between 1 and 16 used with haystackWrite to determine which priority level of the remote system is written to
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 ​

haystackPollFreq ​

Applied to haystackConn to tune the duration between watch polls. If not configured it defaults to 1sec.


meta ​

defhaystackPollFreq
isduration
liblib:haystack
tagOnhaystackConn
val1sec

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 ​

haystackWrite ​

Used on a haystack proxy point to store the id of the entity in the remote system used to write writeVal.


meta ​

defhaystackWrite
isstr
liblib:haystack
tagOnhaystackPoint

supertypes ​

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


def ​

haystackWriteLevel ​

Number between 1 and 16 used with haystackWrite to determine which priority level of the remote system is written to.


meta ​

defhaystackWriteLevel
defVal16
isint
liblib:haystack
maxVal16
minVal1
tagOnhaystackPoint

supertypes ​

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