Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Info
iconfalse

Download the Solution Example here: TagsParse.dbsln


  • Solution Name: Tags Parse
  • Software Version:
10.1
  • v10
  • Keywords: Tags. Parse. Scripts. ScriptClass. Expressions. EventHandling.

Summary

This example demonstrates how to parse Tags using three distinct methods.

Image RemovedImage Added


Technical Information

There are various methods to address challenges when parsing Tags. This example showcases three approaches: simple script-based parsing, expression-driven tag changes, and event-driven parsing. Depending on the complexity of the task and required flexibility, these methods can be employed as solutions.

Method 1: Parsing Tags via Client Script

Image RemovedImage Added

In this method, the button in the purple box is linked to a script called ParseTags_Client. When pressed, it invokes the ParseTags_Client method, which calls the asynchronous Main method, passing the name of the tag obtained from @Tag.TagTestClient.GetName() as a parameter. The Main method updates MessageClassClient with the text "TagName: " followed by the actual tag name, which is displayed in a message box. It also traces the tag name for logging purposes. The aforementioned code is seen below:

Code Block
public async Task ParseTags_Client(object sender, System.Windows.Input.InputEventArgs e) {
    @Script.Class.ParseTags_Client.Main(@Tag.TagTestClient.GetName());
    // Sends the desired tag to the function, receives a response string TagName: <tag name>
}



Method 2: Using Expressions and ScriptClass

Image RemovedImage Added

In this method, the button in the blue box triggers a tag's value to change, this tag is configured as a trigger to the expression Script.Class.ParseTags.ParseTagServer(Tag.TagTestServer.GetName()). This expression calls the ParseTagServer method from the ParseTags script, passing the name of the tag obtained from Tag.TagTestServer.GetName() as a parameter. The ParseTagServer method traces the tag name for logging purposes and updates the MessageExpressions with "TagName: " followed by the actual tag name, which is displayed in a message box when triggered.


Method 3: Complex Parsing with Event Handling

Image RemovedImage Added

The third example demonstrates a more complex setup. Upon solution initialization, the Initialize method from the ParseTags ScriptClass is called. This method initializes a list and feeds two Tags into it. When the values of these tags change, an event is triggered, displaying the updated tag value in a message box. The ObjectReferenceHandler method logs the tag’s name and value when the event is triggered. To illustrate this, a button was included. When pressed, it changes the tagTestServer's value, causing this event to be registered and the new value to be displayed in the message box.  


Reference Information

→ See Unified Namespaces Enumerations for more information.


In this section:

Page Tree
root@parent
spacesV10