Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

PI Connector for UFL

Learn about action examples

  • Last UpdatedJan 28, 2025
  • 5 minute read

The following examples illustrate the use of actions to modify data in Data Archive as well as in PI AF.

Note: For all three actions; that is StoreEvent(), StoreElement() and StoreEventFrame(), the following principle is applied: If a PI point, AF element, or event frame does not exist, the Connector will create it; otherwise it will update the corresponding values/properties/attributes.

StoreEvent() Example 1

This example shows a simple event to Data Archive:

FIELD(1).Name = "NumVal"
FIELD(1).Type = "Number"

Write a value of FIELD(1) to the PI tag "In:AB:001" (Float64) ' using current time.

NumVal = ["(*)"]
StoreEvent("In:AB:001", ,NOW(), NumVal)

StoreEvent() Example 2

Event with status and questionable to Data Archive.

FIELD(1).Name = "NumVal"
FIELD(1).Type = "Number"
FIELD(2).Name = "NumStatus"
FIELD(2).Type = "Number"
FIELD(3).Name = "NumQuestionable"
FIELD(3).Type = "Number"

Write a value of FIELD(1) to the PI tag "In:AB:001" (Float64) using current time. Optional parameters to StoreEvent() are, status and questionable. Any non-zero value in the status parameter will reflect the corresponding entry in the PI System digital set and any non-zero value at the questionable attr. position will set on the flag questionable in PI.

NumVal = ["*,(*)"]
StoreEvent("In:AB:001", ,NOW(), NumVal, NumStatus, NumQuestionable)

StoreElement() Example 1

Simple event to PI AF with subsequent two AF elements creation. The leaf AF element will reference the tag as its dynamic data reference.

FIELD(1).Name = "NumVal"
FIELD(1).Type = "Number"
FIELD(2).Name = "DynAttrCol"
FIELD(2).Type = "Collection"

Create two AF elements: "GatewayAB" and "GatewayAB\Input". The first one (of the FolderType; that is, without attributes), the second one with one dynamic parameter pointing to the previously created PI tag "In:AB:001". The name of the "GatewayAB\Input" element dynamic attribute in AF will be "Temperature".

NumVal = ["*,(*)"]

StoreEvent("In:AB:001", "Temperature", NOW(), NumVal)

DynAttrCol = Add("In:AB:001")
StoreElement("GatewayAB")
StoreElement("GatewayAB\Input", "Measurements2", DynAttrCol)

StoreElement() Example 1

StoreElement() Example 2

Simple event to Data Archive with subsequent two AF elements creation. The leaf AF element will reference the tag as its dynamic data reference; in addition, it will have one static attribute.

FIELD(1).Name = "DynAttrCol"
FIELD(1).Type = "Collection"
FIELD(2).Name = "StatAttrCol"
FIELD(2).Type = "Collection"
FIELD(3).Name = "NumVal"
FIELD(3).Type = "Number"

Create two AF elements: "GatewayCD" and "GatewayCD\Input". The first one (of the FolderType; that is, without attributes), the second one with one dynamic attribute pointing to the previously created PI tag "In:CD:002" and one static attribute "Slot position" (Int32).

NumVal = ["*,(*)"]

StoreEvent("In:CD:002","Temperature",NOW(), NumVal)

DynAttrCol = Add("In:CD:002")
StatAttrCol = Add("Slot position", 2)

StoreElement("GatewayCD")
StoreElement("GatewayCD\Input", "Measurements2", DynAttrCol, StatAttrCol)

StoreElement() Example 2

StoreElement() Example 3

Simple events to Data Archive with subsequent two AF elements creation. The leaf AF element will reference several tags as its dynamic data references; in addition, it will also employ one static attribute.

FIELD(1).Name = "DynAttrCol"
FIELD(1).Type = "Collection"
FIELD(2).Name = "StatAttrCol"
FIELD(2).Type = "Collection"
FIELD(3).Name = "Geo"
FIELD(4).Name = "NumVal"
FIELD(4).Type = "Number"

Create two AF elements: "GatewayEF" and "GatewayEF\Input". The first one (of the FolderType; that is, without attributes), the second one with three dynamic attributes, pointing to the previously created three PI tags "In:EF:001,2,3" and two static attributes "Geo-Spatial coordinates" and a "Name" (String).

Geo = ["(*),*"]
NumVal = ["*,(*),*"]
StoreEvent("In:EF:001","Temperature", NOW(),NumVal)
NumVal = ["*,*,(*),*"]
StoreEvent("In:EF:002","Pressure",NOW(), NumVal)
NumVal = ["*,*,*,(*)"]
StoreEvent("In:EF:003","Humidity",NOW(), NumVal)

DynAttrCol = Add("In:EF:001")
DynAttrCol = Add("In:EF:002")
DynAttrCol = Add("In:EF:003")

StatAttrCol = Add("Geo-Spatial coordinates", Geo)
StatAttrCol = Add("Name", "Ullersdorf")

StoreElement("GatewayEF")
StoreElement("GatewayEF\Input", "WeatherAt", DynAttrCol, StatAttrCol)

StoreElement() Example 3

StoreEventFrame() Example 1

Simple event frame with fixed duration.

Create a plain event frame "Temperature" with ten-minute duration.

StoreEventFrame("Temperature", "EFTemp", NOW(), NOW() + "00:10:00")

StoreEventFrame() Example 2

Simple event frame started and ended when a condition is true.

FIELD(1).Name = "AttrCol"
FIELD(1).Type = "Collection"
FIELD(2).Name = "Tempr"
FIELD(2).Type = "Number"

Tempr = ["(*)"]

Create an event frame "TempOver_10_oC" with one static attribute: "City".

IF( Tempr >= 10 ) THEN

AttrCol = Add("City", "Ostrava")

Open an event frame; that is, do not specify the EndTime parameter.

StoreEventFrame("TempOver_10_oC", "EFTemp", NOW(), , , AttrCol)

ENDIF

IF( Tempr < 10 ) THEN

Close it; that is, EndTime does exist (StartTime is ignored).

StoreEventFrame("TempOver_10_oC", "EFTemp", , NOW())

ENDIF

StoreEventFrame() Example 2

StoreEventFrame() Example 3

Simple event frame started and ended when a condition is true, referencing the previously-created PI point and AF element.

FIELD(1).Name = "DynAttrCol"
FIELD(1).Type = "Collection"
FIELD(2).Name = "StatAttrCol"
FIELD(2).Type = "Collection"
FIELD(3).Name = "Tempr"
FIELD(3).Type = "Number"

Values extraction:

Tempr = ["*,(*)"]

Write a value of "Tempr" to the PI tag "In:CD:002" (Float64).

StoreEvent("In:CD:002","Temperature",NOW(), Tempr)

Create two PI AF elements,"GatewayCD" and "GatewayCD\Input", with one dynamic and one static attribute: "Slot position".

DynAttrCol = Add("In:CD:002")
StatAttrCol = Add("Slot position", 2)

StoreElement("GatewayCD")
StoreElement("GatewayCD\Input", "Measurements2", DynAttrCol, StatAttrCol)

Create an event frame "TempOver_10_oC" with one static attribute, "City", referencing a previously created element "GatewayCD\Input".

IF( Tempr >= 10 ) THEN

DynAttrCol = Clear()
DynAttrCol = Add("In:CD:002")
StatAttrCol = Clear()
StatAttrCol = Add("City", "Ostrava")

Open an event frame; that is, no EndTime parameter.

StoreEventFrame("TempOver_10_oC", "EFTemp", NOW(), ,"GatewayCD\Input",
DynAttrCol, StatAttrCol)

ENDIF

IF( Tempr < 10 ) THEN

Close it; that is, EndTime does exist.

StoreEventFrame("TempOver_10_oC", "EFTemp", , NOW())

ENDIF

StoreEventFrame() Example 3

StoreEventFrame() Example 3

In This Topic
TitleResults for “How to create a CRG?”Also Available in