Skip to content

lib-alarm 库参考 ​

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

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

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


目录(导读) ​

  • lib
  • meta
  • tags
  • funcs
  • def
  • supertypes
  • tags
  • alarmAck(alarms, message: null)
  • alarmDigest(groupBy: "site", includeUnknown: false)
  • alarmHistoryCount(target: null)
  • alarmHistoryQuery(query)
  • alarmNavCounts(grid)
  • alarmTargets(root)
  • alarms(targets: null, span: null, filter: null, pollHandle: null)
  • alarmsGetById(alarmId)
  • alarmsRemove(alarms)
  • clearAlarmHistory(spanOrBefore: null, rebuild: false)
  • clearAlarmHistoryBefore(date)
  • readAlarmHistory(targets: null, span: null)
  • toAlarm(target, nsOrState, messageOrTags: null, occurred: null, priority: null, meta: null)
  • toNormal(targets, nsOrMessage: null, occurredOrTags: null, meta: null)

概述(中译) ​

警报扩展


API 正文(英文) ​

tags ​

ackErrThis tag is set when there is an error acknowledging alarm and contains the reason for the error
ackInProgressThis alarm is current being acknowledged
ackMessageMessage or reason for acknowledgement
ackMessageRequiredThis alarm requires a message when acknowledging
ackRequiredThis alarm requires acknowledgement
ackedTime that the alarm was acknowledged
ackedByWho acknowledged the alarm
alarmAckAccessFilterString filter applied to a user record which defines which alarms a user may acknowldege
alarmHistoryAlarm history record
alarmRouteAlarm route
alarmRuleAlarm rule
fromStateState of the entity prior to alarm transition
funcNameName of function associated with route
messageMessage describing the alarm or reason for the alarm
metadataInformation related to the alarm that will live with the lifecycle of the alarm
occurredDate/Time that the alarm actually occurred
routeOnFilter that will select alarms to route
sourceRefReference to the source of the alarm
stateState of the alarm
targetFilterFilter which matches points to be commanded by this route
toStateState of the entity when going into alarm
valueValue to write to the selected points

funcs ​

alarmAckGiven a set of alarms (or alarm ids), acknowledge them and return the updated alarm records
alarmDigestGenerate an alarm digest grouped by a given parent type
alarmHistoryCountGiven an optional target, return the count of alarm history records
alarmHistoryQueryGiven a Haystack query string, return the alarm history records as a grid
alarmNavCountsGiven a grid of target records with id, enrich it with rolled-up alarm counts per row
alarmTargetsGiven a root object, return all alarm target records associated with it
alarmsGiven optional targets and/or a time span, return the current alarm records as a grid
alarmsGetByIdGiven an alarm id, return the corresponding alarm record
alarmsRemoveGiven a set of alarms (or alarm ids), remove them from the database and return the removed alarm records
clearAlarmHistoryClear alarm history records in the database based on the given parameters
clearAlarmHistoryBeforeClear alarm history records before the given date in the database
readAlarmHistoryGiven optional targets and/or a time span, query the alarm history as a grid
toAlarmGiven a target and either a legacy namespace or a new-style alarm state, transition the given namespace/target to the alarm state
toNormalGiven targets, transition alarms back to normal state using either the legacy API (namespace-based) or the new API (message/occurred/meta)


def ​

ackErr ​

This tag is set when there is an error acknowledging alarm and contains the reason for the error


meta ​

defackErr
isstr
liblib:alarm
tagOnalarm

supertypes ​

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


def ​

ackInProgress ​

This alarm is current being acknowledged


meta ​

defackInProgress
ismarker
liblib:alarm
tagOnalarm

supertypes ​

markerMarker labels a dict with typing information


def ​

ackMessage ​

Message or reason for acknowledgement


meta ​

defackMessage
isstr
liblib:alarm
tagOnalarm

supertypes ​

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


def ​

ackMessageRequired ​

This alarm requires a message when acknowledging


meta ​

defackMessageRequired
ismarker
liblib:alarm
tagOnalarm

supertypes ​

markerMarker labels a dict with typing information


def ​

ackRequired ​

This alarm requires acknowledgement


meta ​

defackRequired
ismarker
liblib:alarm
tagOnalarm

supertypes ​

markerMarker labels a dict with typing information


def ​

acked ​

Time that the alarm was acknowledged


meta ​

defacked
isdateTime
liblib:alarm
tagOnalarm

supertypes ​

valData value type
scalarScalar is an atomic value kind
dateTimeISO 8601 timestamp followed by timezone identifier


def ​

ackedBy ​

Who acknowledged the alarm


meta ​

defackedBy
isstr
liblib:alarm
tagOnalarm

supertypes ​

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


def ​

alarmAckAccessFilter ​

String filter applied to a user record which defines which alarms a user may acknowldege. See <doc#ackSecurity>.


meta ​

defalarmAckAccessFilter
isstr
liblib:alarm

supertypes ​

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


def ​

alarmHistory ​

Alarm history record


meta ​

defalarmHistory
isalarm
liblib:alarm

supertypes ​

markerMarker labels a dict with typing information
alarmNotification of a condition which requires attention

tags ​

ackErrThis tag is set when there is an error acknowledging alarm and contains the reason for the error
ackInProgressThis alarm is current being acknowledged
ackMessageMessage or reason for acknowledgement
ackMessageRequiredThis alarm requires a message when acknowledging
ackRequiredThis alarm requires acknowledgement
ackedTime that the alarm was acknowledged
ackedByWho acknowledged the alarm
createdThe timestamp when entity was created
curStatusStatus of point's current value reading
curValCurrent value of a point
fromStateState of the entity prior to alarm transition
messageMessage describing the alarm or reason for the alarm
metadataInformation related to the alarm that will live with the lifecycle of the alarm
occurredDate/Time that the alarm actually occurred
sourceRefReference to the source of the alarm
stateState of the alarm
toStateState of the entity when going into alarm


def ​

alarmRoute ​

Alarm route. value is set to the type name of the routing implementation


meta ​

defalarmRoute
isstr
liblib:alarm
mandatory✓

supertypes ​

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

tags ​

funcNameName of function associated with route
routeOnFilter that will select alarms to route
targetFilterFilter which matches points to be commanded by this route
valueValue to write to the selected points
writeLevelCurrent priority level for writeVal as number between 1 and 17


def ​

alarmRule ​

Alarm rule. value is set to the type name of the rule implementation


meta ​

defalarmRule
isstr
liblib:alarm
mandatory✓

supertypes ​

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

tags ​

messageMessage describing the alarm or reason for the alarm
metadataInformation related to the alarm that will live with the lifecycle of the alarm
ruleOnTarget filter for a rule or rule ready func
stateState of the alarm


def ​

fromState ​

State of the entity prior to alarm transition


meta ​

deffromState
isstr
liblib:alarm
tagOnalarmHistory

supertypes ​

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


def ​

funcName ​

Name of function associated with route


meta ​

deffuncName
isstr
liblib:alarm
tagOnalarmRoute

supertypes ​

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


def ​

func:alarmAck ​

alarmAck(alarms, message: null) ​

Given a set of alarms (or alarm ids), acknowledge them and return the updated alarm records.

Parameters:

  • alarms (required) - Alarm(s) to acknowledge in any of the following formats: (Grid, Dict[], Ref[], Dict, Str, Ref)
  • message (optional) - acknowledgement message

Examples:

alarmAck(alarms())
alarmAck(@alarmId, "Investigating")
alarmAck("r:demo:alarm123", "Cleared by operator")
alarmAck(readAll(alarm).keepCols(["id"]))

meta ​

deffunc:alarmAck
isfunc
liblib:alarm
namealarmAck

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:alarmDigest ​

alarmDigest(groupBy: "site", includeUnknown: false) ​

Generate an alarm digest grouped by a given parent type.

Parameters:

  • groupBy (optional) - the parent type to group by. Default is "site".
  • includeUnknown (optional) - if true, includes alarms with unknown sources in

meta ​

deffunc:alarmDigest
isfunc
liblib:alarm
namealarmDigest

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:alarmHistoryCount ​

alarmHistoryCount(target: null) ​

Given an optional target, return the count of alarm history records.

Parameters:

  • target (optional) - this is the rec or id of the target. If omitted, it will count all records in the database.

meta ​

deffunc:alarmHistoryCount
isfunc
liblib:alarm
namealarmHistoryCount

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:alarmHistoryQuery ​

alarmHistoryQuery(query) ​

Given a Haystack query string, return the alarm history records as a grid.

Parameters:

  • query (required) - Haystack query string to filter alarm history

meta ​

deffunc:alarmHistoryQuery
isfunc
liblib:alarm
namealarmHistoryQuery

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:alarmNavCounts ​

alarmNavCounts(grid) ​

Given a grid of target records with id, enrich it with rolled-up alarm counts per row.

Parameters:

  • grid (required) - grid of target records with id

meta ​

deffunc:alarmNavCounts
isfunc
liblib:alarm
namealarmNavCounts

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:alarmTargets ​

alarmTargets(root) ​

Given a root object, return all alarm target records associated with it.

Parameters:

  • root (required) - the root object to find alarm targets for

meta ​

deffunc:alarmTargets
isfunc
liblib:alarm
namealarmTargets

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:alarms ​

alarms(targets: null, span: null, filter: null, pollHandle: null) ​

Given optional targets and/or a time span, return the current alarm records as a grid.

Parameters:

  • targets (optional) - list of targets to query alarms for. If this parameter is null it will query everything
  • span (optional) - DateSpan used to filter alarms. If this is null it will return alarms for all dates
  • filter (optional) - filter used to filter alarm result
  • pollHandle: when provided, performs an incremental poll and returns only changes since the given handle (legacy compatibility). The returned grid includes a new <pollHandle> you can pass back on the next call.

Return:

  • A Grid of alarm records. The grid meta includes:
  • pollHandle: an integer handle representing the time of this query.

Examples:

alarms()
alarms(@someEquipId)
alarms(readAll(equip and siteRef==@siteId))
alarms(null, today())
alarms(null, null, null, 123456)        // poll using previous handle

meta ​

deffunc:alarms
isfunc
liblib:alarm
namealarms

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:alarmsGetById ​

alarmsGetById(alarmId) ​

Given an alarm id, return the corresponding alarm record.

Parameters:

  • alarmId: Ref of the alarm to retrieve

Examples:

alarmsGetById(@alarmId)

meta ​

deffunc:alarmsGetById
isfunc
liblib:alarm
namealarmsGetById

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:alarmsRemove ​

alarmsRemove(alarms) ​

Given a set of alarms (or alarm ids), remove them from the database and return the removed alarm records.

Parameters:

  • alarms (required) - Alarm(s) to remove in any of the following formats: (Grid, Dict[], Ref[], Dict, Str, Ref)

Examples:

alarmsRemove(alarms())
alarmsRemove(@alarmId)
alarmsRemove("r:demo:alarm123")
alarmsRemove(readAll(alarm).keepCols(["id"]))

meta ​

admin✓
deffunc:alarmsRemove
isfunc
liblib:alarm
namealarmsRemove

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:clearAlarmHistory ​

clearAlarmHistory(spanOrBefore: null, rebuild: false) ​

Clear alarm history records in the database based on the given parameters.

Parameters:

  • spanOrBefore (optional) - DateSpan of entries to clear
  • rebuild (optional) - if spanOrBefore is null and this is true, it will destroy the history database and recreate its schema.

meta ​

admin✓
deffunc:clearAlarmHistory
isfunc
liblib:alarm
nameclearAlarmHistory

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:clearAlarmHistoryBefore ​

clearAlarmHistoryBefore(date) ​

Clear alarm history records before the given date in the database.

Parameters:

  • date (required) - Deletes all alarm history entries before the specified date.

meta ​

admin✓
deffunc:clearAlarmHistoryBefore
isfunc
liblib:alarm
nameclearAlarmHistoryBefore

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:readAlarmHistory ​

readAlarmHistory(targets: null, span: null) ​

Given optional targets and/or a time span, query the alarm history as a grid.

Parameters:

  • targets (optional) - List/Grid of targets or target ids to query database for. If omitted this will query the database for all entities
  • span (optional) - DateSpan to used to query the history database. If omitted this will return records for all dates in the database

meta ​

deffunc:readAlarmHistory
isfunc
liblib:alarm
namereadAlarmHistory

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:toAlarm ​

toAlarm(target, nsOrState, messageOrTags: null, occurred: null, priority: null, meta: null) ​

Given a target and either a legacy namespace or a new-style alarm state, transition the given namespace/target to the alarm state.

Parameters:

  • targets (required) - list of targets to transition
  • state (required) - to transition targets to (offNormal, normal, fault, ...)
  • message (optional) - the message for the alarm transition
  • occurred (optional) - the time the alarm occurred. If this is omitted, the system will use the current time
  • priority (optional) - priority of the alarm. if this is omitted, the system will use this priority configured for the state.
  • metadata (optional) - this is a miscellaneous dictionary of tags that will follow the lifecycle of the alarm. For compatibility, if "ackRequired" is set on the metadata, it will take precedence over the state's configured ackRequired flag.

This is an adapter kept for backward compatibility.

  • If <nsOrState> contains ":", it is treated as a legacy namespace

Return:

  • Legacy path returns a single <Alarm>.
  • New path returns <Alarm[]>.

Examples:

toAlarm(@equipId, "highTemp", "Over temperature")
toAlarm(@equipId, "legacy:ns", {message:"Over temperature"})

meta ​

deffunc:toAlarm
isfunc
liblib:alarm
nametoAlarm

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:toNormal ​

toNormal(targets, nsOrMessage: null, occurredOrTags: null, meta: null) ​

Given targets, transition alarms back to normal state using either the legacy API (namespace-based) or the new API (message/occurred/meta).

Parameters:

  • targets (required) - list of targets to transition to normal
  • message (optional) - the message for the alarm transition
  • occurred (optional) - the time the alarm occurred. If this is omitted, the system will use the current time
  • metadata (optional) - this is a miscellaneous dictionary of tags that will follow the lifecycle of the alarm. For compatibility, if "ackRequired" is set on the metadata, it will take precedence over the state's configured ackRequired flag.

This is an adapter kept for backward compatibility:

  • If <nsOrMessage> contains ":", it is treated as a legacy namespace

Return:

  • Legacy path returns a single <Alarm?>.
  • New path returns <Alarm[]>.

Examples:

toNormal(@equipId)
toNormal(@equipId, "Cleared by operator")
toNormal(@equipId, "legacy:ns", {message:"Cleared"})

meta ​

deffunc:toNormal
isfunc
liblib:alarm
nametoNormal

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

message ​

Message describing the alarm or reason for the alarm


meta ​

defmessage
isstr
liblib:alarm
tagOnalarm, alarmRule

supertypes ​

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


def ​

metadata ​

Information related to the alarm that will live with the lifecycle of the alarm


meta ​

defmetadata
isdict
liblib:alarm
tagOnalarm, alarmRule

supertypes ​

valData value type
dictMap of name/value tag pairs


def ​

occurred ​

Date/Time that the alarm actually occurred


meta ​

defoccurred
isdateTime
liblib:alarm
tagOnalarm

supertypes ​

valData value type
scalarScalar is an atomic value kind
dateTimeISO 8601 timestamp followed by timezone identifier


def ​

routeOn ​

Filter that will select alarms to route


meta ​

defrouteOn
isstr
liblib:alarm
tagOnalarmRoute

supertypes ​

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


def ​

sourceRef ​

Reference to the source of the alarm. This is usually the entity that went into alarm


meta ​

defsourceRef
isref
liblib:alarm
tagOnalarm

supertypes ​

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


def ​

state ​

State of the alarm


meta ​

defstate
isstr
liblib:alarm
tagOnalarm, alarmRule

supertypes ​

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


def ​

targetFilter ​

Filter which matches points to be commanded by this route


meta ​

deftargetFilter
isstr
liblib:alarm
tagOnalarmRoute

supertypes ​

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


def ​

toState ​

State of the entity when going into alarm


meta ​

deftoState
isstr
liblib:alarm
tagOnalarmHistory

supertypes ​

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


def ​

value ​

Value to write to the selected points


meta ​

defvalue
isscalar
liblib:alarm
tagOnalarmRoute

supertypes ​

valData value type
scalarScalar is an atomic value kind