Timestamp and Qualities Parameters
The Timestamp
and Qualities
parameters are optional.
Timestamp
The Timestamp
parameter takes an absolute time value enclosed within two quotes ("). This value must be a timestamp in the past, for example: "24/12/20042:32:15 PM"
.
Quality
The Quality
parameter takes an integer value from 0 to 100 (0 being bad quality, 100 being good quality).
Errs
is an output variable, which receives an array of status codes, one for each tag written to. The following table describes the status codes.
Error Code | String | Description |
---|---|---|
0 | ihSTATUS_OK | The values were successfully written to the tags. |
-1 | ihSTATUS_FAILED | The operation failed. |
-2 | ihSTATUS_API_ TIMEOUT | The operation timed out while connecting to Historian. |
-3 | ihSTATUS_NOT_ CONNECTED | The Calculation Collector could not connect to the Historian archive. |
-4 | ihSTATUS_INTERFACE_ NOT_FOUND | The collector could not be contacted or connected to. |
-5 | ihSTATUS_NOT_ SUPPORTED | The write operation was not supported. |
-6 | ihSTATUS_DUPLICATE_ DATA | The write operation would have created duplicate data in the archive. |
-7 | ihSTATUS_NOT_VALID_ USER | The user name used to connect to the Historian archive is not valid. |
-8 | ihSTATUS_ACCESS_ DENIED | The user name used to connect to the Historian archive does not have write access to the Historian archive. |
-9 | ihSTATUS_WRITE_IN_ FUTURE | The timestamp supplied with the function call is set to a time in the future. |
-10 | ihSTATUS_WRITE_ ARCH_OFFLINE | The Historian archive is currently offline. |
-11 | ihSTATUS_ARCH_ READONLY | The Historian archive is set to read-only. |
-12 | ihSTATUS_WRITE_ OUTSIDE_ACTIVE | An attempt was made to write data to a time before the archive was created. |
-13 | ihSTATUS_WRITE_NO_ ARCH_AVAIL | No Historian archive is available for writing. |
-14 | ihSTATUS_INVALID_ TAGNAME | The tag name or tag names supplied do not exist in the Historian archive. |
-15 | ihSTATUS_LIC_TOO_MANY_TAGS | The function has attempted to add more tags than the current license allows. |
-16 | ihSTATUS_LIC_TOO_ MANY_USERS | There are currently too many users connected to the Historian archive. |
-17 | ihSTATUS_LIC_ INVALID_LIC_DLL | The Historian license is expired or invalid. |
-18 | ihSTATUS_NO_VALUE | No value was supplied for the tag. |
-19 | ihSTATUS_DUPLICATE_ INTERFACE | Two collectors exist with the same name. |
-20 | ihSTATUS_NOT_ LICENSED | The Historian license is not installed. |
-21 | ihSTATUS_CALC_CIRC_ REFERENCE | A circular reference has been entered in the Calculation formula. |
-22 | ihSTATUS_BACKUP_ EXCEEDED_SPACE | The Historian archive being written to has reached the Minimum Hard Drive Space setting, and no new archives are being created. |
-23 | ihSTATUS_INVALID_ SERVER_VERSION | The Historian archive being written to is not compatible with the calculation collector. |
-24 | ihSTATUS_DATA_ RETRIEVAL_COUNT_ EXCEEDED | Indicates there were too many data points to retrieve. |
Examples
The following examples show sample usage of the AddData
function.
- Simple data write
- This example writes a single value, the current time, and a good quality value to a single tag.
errs = AddData("Bucket Brigade.UInt4", 9, "Now", 100)
- Writing array data
- This example uses arrays to write several values to several tags.
Dim Tags(3) Tags(0) = "Bucket Brigade.Boolean" Tags(1) = "Bucket Brigade.Int4" Tags(2) = "Bucket Brigade.Real8" Tags(3) = "Bucket Brigade.String" Dim Values(3) Values(0) = True Values(1) = 5 Values(2) = 172.3 Values(3) = "Hello, World" errs = AddData(Tags, Values, Null, Null)
- Writing timestamps and qualities
- This extends the previous example, including time stamps and qualities for the values.
Dim Tags(3) Tags(0) = "Bucket Brigade.Boolean" Tags(1) = "Bucket Brigade.Int4" Tags(2) = "Bucket Brigade.Real8" Tags(3) = "Bucket Brigade.String" Dim Values(3) Values(0) = True Values(1) = 5 Values(2) = 172.3 Values(3) = "Hello, World" Dim Timestamps(3) Timestamps(0) = "Today" Timestamps(1) = "Now" Timestamps(2) = "Yesterday" Timestamps(3) = "24/12/2004 2:32:15 PM" Dim Qualities(3) Qualities(0) = 100 Qualities(1) = 0 Qualities(2) = 100 Qualities(3) = 0 Dim errs errs = AddData(Tags, Values, Timestamps, Qualities)