2.3. Access to DataHub Points

The main purpose of writing DataHub scripts is to interact with the live data represented by DataHub points. Gamma, the DataHub scripting language, has a few special provisions for working DataHub points. Understanding these will make your task much easier.

2.3.1. Point Names

First, a DataHub point name is not a legal symbol in Gamma. DataHub point names use a colon (:) to separate the point name from the domain name, and commonly use a dot (.) as well, like this: DataSim:Sine or MyDomain:Plant1.Tank3.Valve2. Colons and dots are not normally allowed in a Gamma variable name, so we use the Gamma symbol character operater $ to turn the whole string of characters into a single, valid Gamma variable. For example, thess expressions:

$DataSim:Sine
$MyDomain:Plant1.Tank3.Valve2

are valid Gamma variables.

The $ operator tells Gamma that all characters except white space (space, tab, newline, carriage return, form feed) and the the set: []()",'; are accepted in the symbol name. To get any of the above characters in a symbol name, you need to precede that character by a backslash. So, for example, this DataHub point::

default:plant.water level[1]

would be written in a script like this:

$default:plant.water\ level\[1\]

In brief, you need to put a $ before any DataHub point name in a DataHub script, and use a backslash within the name before any whitespace or []()",'; character.

2.3.2. Point Values

Often when we use a DataHub point as a variable in a script, we don't want to evaluate it at the time that the code is being read. We want to simply quote it, and let it be evaluated when an event occurs. In these cases, we use the # quote operator when referring to a DataHub point, like this:

#$DataSim:Sine

Or, if the point name is within an expression that requires partial evaluation, the syntax would be like this:

@$DataSim:Sine

Please refer to Section 2.2.2, “The Read/Evaluate Cycle” for more details about evaluation, or to Section 4.3, “Accessing Data” for an example of this syntax in use.

2.3.3. Point Timestamps and Qualities

In addition to the value of a DataHub point, you might need to know its timestamp or quality at the moment of an event. This information can be accessed through two special Gamma scripts: Time.g and Quality.g. You can require these scripts by adding a require function at the beginning of your script, like this:

require ("Application");
...
require ("Time");
require ("Quality");
...

The Time.g script offers a number of time-related functions, while the Quality.g file has a single function that converts a numerical quality code into a human-readable text string.