Message Variables New

A variable is a name in braces, such as {groupName}, that OAS replaces with text from the tag, its groups, the message or the system when it publishes. One setting can then give a different result for each tag: plant/{groupPathSlash} publishes each group's tags on a topic of its own, and {site}/{area}/{tagShortName} fills a field with Dallas/Plant/Speed.

This page lists every variable, where each driver reads them, and how the drivers differ.

Where variables can be written

DriverWhere a variable can be written
MQTT driverPublish Topic Id, with Publish All Tags As One Topic on - see Topic patterns. In a schema, with Output Format ISA-95 Lite or Custom AVRO Schema: a Custom Format mapping and a tag map's key.
Kafka driverThe same as the MQTT driver. A topic must also be a legal Kafka topic name - see Kafka driver.
MQTT brokerIn a library schema used by a schema topic or a $schema/ group topic: a Custom Format mapping and a tag map's key. The topic is the one the client subscribes to, so the broker has no topic setting.
Snowflake driverA column's value, with the Custom Format source. Not a column name. See Snowflake driver.
Every other driverNone.

Settings that may look as if they take a variable, but do not:

SettingWhat happens to braces
Snowflake column nameNot allowed. The Column Mapper and the driver both show an error.
Kafka Subject NameNot allowed. The name is used exactly as typed, braces included, and the web app warns when it holds braces.
Kafka Subject Name left blankThe subject is the Publish Topic Id followed by -value. This is a fixed rule, not a variable.
Publish Topic Id with Publish All Tags As One Topic offNot used: each tag is published on the topic named by its own Id.
A Constant mapping, in a schema or a Snowflake columnSent exactly as typed, braces included.
A broker group topic under $group/It carries the broker's standard payload, which has no variables.

Writing a variable

RuleDetail
TextAny number of variables, with any text between them: company/{siteId}/{area}.
CaseNames are matched without regard to case: {siteId} and {siteid} are the same.
A literal braceIn a Custom Format, write {{ or }}. In Publish Topic Id, doubled braces around a variable a topic may use give its name in single braces (data/{{site}} gives data/{site}); doubled braces around anything else are kept as written (data/{{line}} stays data/{{line}}). A Kafka topic may not hold braces, so on Kafka such a tag is not published.
Field typeCustom Format works only on text fields and on a tag map's key. The schema editor flags it on any other field, and the library will not save it there.
A variable with no valueNever sent as empty text. In a field of one tag - an entry of a tag array, a tag map's key or value, or a message of one tag - that tag is left out of the message. In a field built once for the whole message, the message is not sent. Either is logged once in System Errors, naming the variable and the tag, and Data Test shows it as a note. A topic works the same way: the tag is not published.
{value} with no valueThe one exception: with bad quality, or an empty text value, it is sent as empty text.
An unknown variable in a schemaAn error in the schema editor. A driver or the broker publishes nothing with that schema and logs one system error naming the variable.
Braces in Publish Topic Id that are not a variable a topic may useLeft as written, and the web app warns about them. A topic with no usable variable is one topic, published exactly as written.

What counts as no value:

  • an Id part past the last |, or with nothing between two bars - A||B has no {tagIdPart2},
  • a level no group above the tag has,
  • a group variable, such as {groupPath}, {groupName} or {hierarchyPath}, on a tag that is in no group,
  • an unset {workCenterType} or {workUnitType},
  • an empty property,
  • {schemaName} with Output Format Default,
  • on the broker and in Data Test opened from the library, {driverName},
  • on the broker, {tagSeq0} and {tagSeq1},
  • on Snowflake, {topic}, {schemaName}, {seq0} and {seq1}.

The variables

The examples are for the tag Acme.Dallas.Plant.Line1.Speed.Value, where:

  • the groups Acme, Dallas, Plant and Line1 have the ISA-95 levels Enterprise, Site, Area and Work Center,
  • the site's ID is DAL,
  • the tag's Units property is rpm,
  • the tag is listed in a driver's Tags To Publish with the Id SPD-01|Hall_A.

Topic says whether Publish Topic Id accepts the variable; the ones it does not accept change with every value or every message. MQTT only means Kafka accepts the variable too, but it always gives a /, which a Kafka topic may not hold, so on Kafka the tag is never published.

The tag

VariableGivesExampleTopic
{tagName}The tag name with its variableSpeed.ValueYes
{tagShortName}The tag name aloneSpeedYes
{variable}The tag variableValueYes
{tagPath}The full path, dottedAcme.Dallas.Plant.Line1.Speed.ValueYes
{tagPathSlash}The full path, with each group a levelAcme/Dallas/Plant/Line1/Speed.ValueMQTT only
{tagId}The Id the tag is published under, from the driver's Tags To PublishSPD-01|Hall_AYes
{tagIdPart1}, {tagIdPart2}, …The parts of that Id between |, counted from 1, without the spaces around themSPD-01, Hall_AYes
{property:Name}A tag property by name, as the Custom Property... mapping reads it. The name keeps its case and its spaces{property:Units} gives rpmYes
{dataType}The data type of the value: BOOLEAN, INT, LONG, FLOAT, DOUBLE or STRINGDOUBLENo
{value}The value as text. Empty when the quality is bad, and still sent1450No
{quality}true or falsetrueNo
{timestampUnixMs}The value's timestamp, in Unix millisecondsNo
{timestampUnixSec}The value's timestamp, in Unix secondsNo
{timestampIso}The value's timestamp, in ISO 8601No

One entry of a tag array or tag map

These work only inside a tag array or tag map. Anywhere else they are an error.

VariableGivesTopic
{seq0}, {seq1}The entry's position in this message, from 0 or from 1. It starts again in every message, so the same number can be a different tag in the next messageNo
{tagSeq0}, {tagSeq1}The tag's fixed position in the driver's Tags To Publish, from 0 or from 1. The same tag has the same number in every message. A tag listed more than once has the number of its first listingNo

For a number that must always mean the same point, such as pointID_{tagSeq1}, use {tagSeq1}.

The tag's group

VariableGivesExampleTopic
{groupPath}The group path, dottedAcme.Dallas.Plant.Line1Yes
{groupPathSlash}The group path, with each group a levelAcme/Dallas/Plant/Line1MQTT only
{groupName}The tag's own groupLine1Yes
{groupLevel1}, {groupLevel2}, …The group at that depth, counted from the top. No value below the tag's own groupAcme, DallasYes
{enterprise}, {site}, {area}, {workCenter}, {workUnit}, {equipmentModule}, {controlModule}The nearest group above the tag with that ISA-95 level: its export name override, or its name{area} gives PlantYes
{siteId}, {workUnitId}, {equipmentModuleId}, {controlModuleId}That group's ID, or its name when the ID is empty{siteId} gives DALYes
{workCenterType}, {workUnitType}That group's typeYes
{hierarchyPath}The groups above the tag that have a level, top down, dotted, with overrides appliedAcme.Dallas.Plant.Line1Yes
{hierarchyPathSlash}The same, with each group a levelAcme/Dallas/Plant/Line1MQTT only

The group path variables use the groups' real names. The level and hierarchy variables use a group's export name override when it has one, and give the same text as the Hierarchy mapping.

The message and the system

VariableGivesTopic
{driverName}The driver interface's nameYes
{hostName}The name of the machine OAS runs onYes
{schemaName}The schema's record name, in lower case with spaces as hyphens: isa-95-lite on a driver set to ISA-95 Lite. A driver keeps its own copy of a schema, not the name it was loaded under in the library. Only with Output Format ISA-95 Lite or Custom AVRO Schema; with Default it has no value, so a topic that uses it publishes nothingYes
{topic}The topic the message is published onNo
{tagCount}The number of tags in the messageNo
{uuid}A new identifier for each message, the same wherever it is used in that messageNo
{publishTimeUnixMs}, {publishTimeUnixSec}, {publishTimeIso}The time of the publish, the same in every message of one publishNo

Where a variable may be used inside a schema

When a message holds many tags, a field outside the tag array or tag map is built once for the whole message:

  • it may use the group, message and system variables,
  • a tag or entry variable there is an error, just as mapping that field to a tag's value is,
  • a group variable there means one message per group.

MQTT driver

  • Topic. A Publish Topic Id that holds a variable a topic may use is a topic pattern. Each tag goes to the topic the pattern gives it, and tags of one publish that share a topic share a message. This works with every Output Format, including Default. The topic a tag gets may not contain + or #. The slash variables give one topic level per group. Topics are worked out again once a minute, so a renamed group or a changed property is followed within a minute, without a restart.
  • Message. Variables are read in a schema only with Output Format ISA-95 Lite or Custom AVRO Schema. The Default payload has no variables.
  • Many tags in one message. With Publish All Tags As One Topic on, Batched Messages on and a schema with a tag array or tag map, {seq0}, {seq1} and {tagCount} count the tags in the message. A message is split by Max Tags Per Publish, and by group when a field outside the tag array reads a group variable.
  • Several Ids. A tag listed in Tags To Publish under several Ids gives one entry per Id, each with its own {tagId} and parts, when the mapping or the topic reads the Id. A tag map whose key does not read the Id keeps the last Id, and that is logged once for the tag. A pattern that reads the Id gives each Id its own topic.

Kafka driver

  • Topic. A topic pattern works as it does on MQTT, including the refresh once a minute, and the Kafka topic is created under the filled-in name. The topic a tag gets must also be a legal Kafka topic name: 1 to 249 characters of A-Z, a-z, 0-9, ., _ and -, and not . or ... A tag whose topic breaks the rule is not published, and System Errors gets one entry for it. The line under Publish Topic Id in the web app warns about it before you apply. In practice:
    • use {groupPath}, {tagPath} or {hierarchyPath} - their slash forms always fail,
    • a group, tag or override name with a space, or any character outside that set, fails,
    • {property:Name} fails when the property's value holds such a character.
  • Message. As on MQTT, variables are read only with ISA-95 Lite or Custom AVRO Schema. The Default message, with or without a Schema Registry, has no variables.
  • Many tags in one message. Only with Custom AVRO Schema, a tag array or tag map, Batched Messages on and Publish All Tags As One Topic on. Otherwise every message holds one tag, so {seq0} is 0, {seq1} is 1 and {tagCount} is 1.
  • Subject Name. Variables are not allowed. The schema is registered once, when the driver connects, under that one name, and every topic's messages carry its ID. With a topic pattern and Enable Schema Registry on, the name is required: left blank, the driver does not connect, raises a schema alarm, and the web app shows an error on the setting. A subject for each topic is not supported.
  • Several Ids. As on MQTT.

MQTT broker

The broker reads variables in the library schema a client names, on a schema topic such as Sine.Value/plant-a-v2 or a $schema/ group topic such as $schema/plant-a-v2/Plant/Line1/+. It has no Tags To Publish list and no driver name, so a few variables give something else - see What differs.

A $schema/ group topic that sends one message per tag gives what a schema topic gives, except {topic}, which is the tag's group topic.

One message per group, under $schema/default/ or with a schema that has a tag array or tag map ($schema/line-batch/Plant/Line1), gives:

VariableOne message per group
{topic}The group's topic, $schema/line-batch/Plant/Line1, not the filter subscribed to
{schemaName}The schema's name in the library, in lower case with spaces as hyphens (line-batch for Line Batch), not its record name
{tagCount}The tags in that message. When Group Max Tags Per Message splits the group, the tags in that part
{seq0}, {seq1}The tag's position in the message
{tagSeq0}, {tagSeq1}No value: the broker has no list, so the tag is left out
{tagId}, {tagIdPart1}The tag's path, Plant.Line1.Speed.Value
{driverName}No value, so the message is not sent
{publishTimeUnixMs} and the other twoThe time the message is built

Snowflake driver

A column's value can be a Custom Format: in the Column Mapper, set the column's source to Custom Format and write text and variables, such as {site}-{tagName}. Each row is filled for its own tag, and the result goes into the column as text, so the Column Mapper sets the column's type to STRING. See Custom Format in the Snowflake Config Reference.

A column name cannot hold a variable. It is the table's column, used exactly as written, and a column name with braces is an error in the Column Mapper and in the driver's settings.

A row is one tag with no message around it, so a few variables give something else:

VariableSnowflake driver
{tagId}, {tagIdPart1}The Id in Tags To Publish
{tagSeq0}, {tagSeq1}The position in Tags To Publish
{driverName}The driver interface's name
{uuid}A new identifier for each row, the same in every column of that row
{publishTimeUnixMs} and the other twoThe time of the publish, the same for every row it sends
{seq0}, {seq1}, {topic}, {schemaName}No value, so the row is not sent. The Column Mapper does not offer them, and shows an error if one is typed
{tagCount}Always 1. The Column Mapper does not offer it

A row left out because a variable has no value is logged once in System Errors, naming the variable and the tag. A Constant is still sent exactly as typed, braces included.

What differs between the drivers and the broker

Every variable not listed here gives the same text wherever it is read.

VariableMQTT driverKafka driverMQTT broker, schema topic
{tagId}, {tagIdPart1}The Id in Tags To PublishThe Id in Tags To PublishThe tag's path (Sine.Value): the broker has no Id list
{tagSeq0}, {tagSeq1}The position in Tags To PublishThe position in Tags To PublishNo value: the broker has no list, so the tag is left out
{seq0}, {seq1}The position in the messageThe position in the message when it holds many tags; otherwise 0, 10, 1: one tag per message
{tagCount}The tags in the messageThe tags in the message when it holds many tags; otherwise 11
{driverName}The driver interface's nameThe driver interface's nameNo value, so the message is not sent
{schemaName}The schema's record nameThe schema's record nameThe schema's record name
{topic}The topic published on: Publish Topic Id, the topic its pattern gives, or the tag's own topicWith a topic per tag, that topic, each Id of a tag listed more than once getting its own. With all tags in one topic, Publish Topic Id as written, or the topic its pattern givesThe topic as subscribed to and published (Sine.Value/plant-a-v2). On a group topic, the tag's group topic ($schema/plant-a-v2/Plant/Line1/Speed.Value), not the filter subscribed to
{publishTimeUnixMs} and the other twoThe time of the publishThe time of the publishThe time the message is built
The topic itselfPublish Topic Id, with + and # refusedPublish Topic Id, with the Kafka name rulesThe client's subscription

Where next