Beta Industrial App Store Wiki

Event Manager

Introduction

In Gestalt PnID’s Event Manager we provide several helper functions that help you perform specific actions within your dashboard. This page outlines what each of these functions are, what they do, and information on how they can be used within the event manager.

Global/Local Scripts

Functions and variables can be defined at the scope of a dashboard or at organisation level. See Global and Local Scripts Guide for more information.

Script Reference

Change Property

Changes the value of the specified property on a component to the specified value.

Method Signatures
changeProperty("[Component Id]", "[Property Name]", "[Property Value]")
ParameterTypeDescriptionRequired?
Component IdstringThe id of the property you want to change a property of.Yes
Property NamestringThe name of the property you would like to alter.Yes
Property ValueanyThe value to set the property to.Yes

Set Position

Changes the position of a component to the provided XY co-ordinate.

Method Signatures
setPosition("[Component Id]", "[X Position]", "[Y Position]")
ParameterTypeDescriptionRequired?
Component IdstringThe id of the property you want to change the position of.Yes
X PositionnumericThe x co-ordinate of the position to move the component to.Yes
Property ValuenumericThe y co-ordinate of the position to move the component to.Yes

Set Query

Changes the query settings of the dashboard.

Method Signatures
setQuery("[Start Time]", "[End Time]", "[Interval]", "[Data Function]")
ParameterTypeDescriptionRequired?
Start TimestringThe start date to set the query to, which can either be an absolute date in ISO format or a relative value e.g. *-10d, *-1h.Yes
End TimestringThe end date to set the query to, which can either be an absolute date in ISO format or a relative value e.g. *, *-1h.Yes
IntervalstringThe interval to set the query to e.g. 1d, 1h, 1m.Yes
Data FunctionstringThe data function to set the query to e.g. PLOT, MAX, MIN, INTERP, AVG or RAWYes

Write Value

Writes a value to the snapshot of the specified tag.

Method Signatures
writeValue("[Datasource Name]", "[Tag Name]", "[Value To Write]", "[Note]", "[Success Callback]", "[Fail Callback]")
ParameterTypeDescriptionRequired?
Data Source NamestringThe qualified data source name the tag belongs to.Yes
Tag NamestringThe name of the tag the value is to be written to.Yes
Value To Writestring/numericThe value to be written to the tag. It can be a string value or a numeric value.Yes
NotestringA note to be attached to the value being writtenNo
Success CallbackfunctionFunction that will be called when the write is successful.No
Fail CallbackfunctionFunction that will be called when the write fails.No

Query Tag Data

Retrieves the values for the specified tag and time.

Method Signatures
queryTagValues("[Datasource Name]", "[Tag Name]", "[Start Time]", "[End Time]", "[Interval]", "[Data Function]", "[Success Callback]", "[Fail Callback]", "[Show Notification]")
ParameterTypeDescriptionRequired?
Data Source NamestringThe qualified data source name the tag belongs to.Yes
Tag NamestringThe name of the tag the value is to be written to.Yes
Start TimestringThe start date to set the query to, which can either be an absolute date in ISO format or a relative value e.g. *-10d, *-1h.Yes
End TimestringThe end date to set the query to, which can either be an absolute date in ISO format or a relative value e.g. *, *-1h.Yes
IntervalstringThe interval to set the query to e.g. 1d, 1h, 1m.Yes
Data FunctionstringThe data function to set the query to e.g. PLOT, MAX, MIN, INTERP, AVG or RAWYes
CallbackfunctionFunction that will be called when the write is successful.Yes
Fail CallbackfunctionFunction that will be called when the write fails.No
Show NotificationbooleanIndicates weather or not to show Success/Fail notification. If missing, the default is false.No

Get Value

Retrieves the value for the specified tag.

Method Signatures
getValue("[Data Source]", "[Tag Name]", "[Use Selected]", "[Index]")
ParameterTypeDescriptionRequired?
Data SourcestringThe data source of the tag to retrieve the value for.Yes
Tag NamestringThe name of the tag to retrieve the value for.Yes
Use SelectedbooleanIndicates whether to return the currently selected point, or the latest. True will return the select and false will return the lates.No
IndexbooleanThe index of a specific value in the data array to return. If Use Selected is true this will have no effect.No

Get String Value

Retrieves the string value for the specified tag.

Method Signatures
getStringValue("[Data Source]", "[Tag Name]")
ParameterTypeDescriptionRequired?
Data SourcestringThe data source of the tag to retrieve the string value for.Yes
Tag NamestringThe name of the tag to retrieve the string value for.Yes

Get Tag Data

Retrieves the entire data array for the specified tag.

Method Signatures
getTagData("[Data Source]", "[Tag Name]")
ParameterTypeDescriptionRequired?
Data SourcestringThe data source of the tag to retrieve the data for.Yes
Tag NamestringThe name of the tag to retrieve the data for.Yes

Get Timestamp

Retrieves the latest timestamp for the specified tag.

Method Signatures
getTimeStamp("[Data Source]", "[Tag Name]")
ParameterTypeDescriptionRequired?
Data SourcestringThe data source of the tag to retrieve the latest timestamp for.Yes
Tag NamestringThe name of the tag to retrieve the latest timestamp for.Yes

Swap Tags

Swaps out the current set of tags present in the page for a new set. There are four overloads that can be used depending on the requirement:

  • Swaps all of the tags in a dashboard with a list of tag names that are from the same data source.
swapTags("[New Tags List]")
ParameterTypeDescriptionRequired?
New Tags ListarrayThe collection of tag names to swap out the existing with. Must be of the same length as the existing tag list in the dashboard.Yes
  • Swaps all of the tags in a dashboard with a list of tag names that are different from the old data sources.
swapTags("[New Tags List]", "[New Data Sources]")
ParameterTypeDescriptionRequired?
New Tags ListarrayThe collection of tag names to swap out the existing with. Must be of the same length as the existing tag list in the dashboard.Yes
New Data SourcesarrayThe collection of data source names of the new tags to swap out the existing with. Must be of the same length as the existing tag list.Yes
  • Swaps some of the tags with a list of tag names that are from the same data source
swapTags("[New Tags List]", "[Old Tags To Target]", "[Old Data Sources to Target]")
ParameterTypeDescriptionRequired?
New Tags ListarrayThe collection of tag names to swap out the existing with. Must be of the same length as the target listYes
Old Tags to TargetarrayThe collection of tag names to target for replacement with the new tags.Yes
Old Data Source to TargetstringThe data source of the old tags.Yes
  • Swaps some of the tags with a list of tag names that are different from the old data sources
swapTags("[New Tags List]", "[New Data Sources]", "[Old Tags To Target]", "[Old Data Source to Target]")
ParameterTypeDescriptionRequired?
New Tags ListarrayThe collection of tag names to swap out the existing with. Must be of the same length as the old tags to target list.Yes
New Data SourcesarrayThe collection of data source names to swap out the existing with. Must be of the same length as the old target tag list.Yes
Old Tags to TargetarrayThe collection of old tag names to target for replacement with the new tags.Yes
Old Data Source to TargetstringThe data source of the old tags to target.Yes

Transform Tags

Applies a transform to the names of the tags present in the page.

Method Signatures
transformTags("[Value to be Transformed]", "[New Value]", "[Data Source]")";
ParameterTypeDescriptionRequired?
Value to be TransformedstringThe substring to target for transformation.Yes
New ValuestringThe new value you want to replace the target string with.Yes
Data sourcestringThe data source of the tags you want to target. If none is provided it will target the whole set.No

Get Page State

Retrieves a value under the given key from the page state store.

Method Signatures
getPageState("[key]")
ParameterTypeDescriptionRequired?
keystringThe key of the value you want to retrieve from the page state.Yes

Set Page State

Sets a value under the given key from the page state store.

Method Signatures
setPageState("[key]", "[value]")
ParameterTypeDescriptionRequired?
keystringThe key you want to store the value against.Yes
valueanyThe value you want to store against the key.Yes

Get Component

Retrieves the object reference of the component matching the specified ID.

Method Signatures
getComponent("[Component Id]")
ParameterTypeDescriptionRequired?
Component IdstringThe id of the component you want to retrieve.Yes