Write Data to an Arbitrary Tag

Before you begin

If the tags that you want to specify are also used as trigger tags or source tags of a calculation, ensure that the Calculation collector does not read the tag data before you add the tag. To do so:
  1. Access the ShouldPreReadData registry key under HKEY_LOCAL_MACHINE\Software\Intellution, Inc.\iHistorian\Services\CalculationCollector\.
  2. Create a DWORD named ShouldPreReadData, and set its value to zero.
  3. Restart the collector.

About this task

You can write data to an arbitrary tag in the Historian archive through the AddData function. This function is used in a calculation formula to write values, errors, time stamps and qualities of one or more tags to the Historian archive.

Procedure

Use the following syntax to write data to an arbitrary tag:
errs = AddData(TagNames, Values, Timestamps, Qualities)
The following table provides information on the parameters.
Parameter Description
TagNames Identifies the names of the tags. A value is required, and must exist in the archive to which you want to send the tag data. You can provide a single tag name or an array of tag names, enclosed in double quotation marks.
Values Identifies the values of the tags. A value is required, and must be a single value or an array of values, depending on whether the tag name is a single name or an array. Values must be enclosed in double quotation marks. You can enter only a single value for each tag name.
Timestamp Identifies the timestamp of the tag data. Enter an absolute time value, enclosed in double quotation marks ("24/12/20242:32:15 PM"). If you do not want to enter a value, enter NULL, and the current time will be considered. Do not enter a future timestamp.
Qualities Identifies the quality of the tag data. Enter an integer from 0 to 100, with 0 indicating bad quality and 100 indicating good quality.
Tip: You can refer to Examples of Using the AddData Function. For information on the status codes and their descriptions, refer to Status Codes of the AddData Function.