Script Execution Example Page 4

In the previous section, we found that the command 'TE101' ASSET would result in the stack being in the following state…

StackCode
AssetList [ { id: 203, name: “Temperature Sensor #1”, ern: “TE101” } ]

Here, we are going to learn to do more.

There are several commands that work with asset lists, so we can use those commands to look further into our data.

For example, the VALUES command will convert an asset list and a property list into a single list of points, which we need to be able to read property values.

So to go from an asset name and a property name to the actual value of the property, we will need to…

  1. Find the asset by name,
  2. Find the property by name, and
  3. Combine these to form a list of points.

Finding the Asset

We've already done the first step in our example - 'TE101' ASSET gave us information about the asset.

Finding the Property

Next, we do a very similar thing to how we found the asset, using the PROPERTY command.

'Stove Temperature' PROPERTY will give us a Property Lists that contains the stove temperature.

With the full command 'TE101' ASSET 'Stove Temperature' PROPERTY, we get the following remaining on the stack…

StackCode
AssetList [ { id: 203, name: “Temperature Sensor #1”, ern: “TE101” } ]
PropertyList [ { id: 22, name: “Temperature - Stove” } ]

Combining the Two

Finally, we can use the POINTS command to convert these into a single list of points. This command eats two items off the stack (the list of assets and list of properties), then combines them to form a list of valid points.

The final output of 'TE101' ASSET 'Stove Temperature' PROPERTY VALUES is…

StackCode
PointList [ { assetid: 203, sourceid: 203, assetname: “Temperature Sensor #1”, propertyid: 22, propertyname: “Temperature - Stove” , ern: “TE101”, value: “23.57 Deg C”, rawvalue: 22.57 } ]

Telling us that the current temperature of Temperature Sensor #1 is 23.57 Deg C.


This is enough to give you an idea of the basic AQL queries. Now might be a good time to check out the example queries to see what AQL can do.

You can also discover how to debug AQL queries.

If you'd like to explore deeper, you can check out Complex Queries to see more.