system.historian.storeMetadata
This function is used in Python Scripting.
Description​
Store a list of metadata to the specified historian. This function applies to the Core Historian and Internal Historian only.
When provided as individual parameter lists, ensure all parameters are 1:1, meaning all provided lists must be of the same length. If a particular annotation doesn't need a parameter, that element can be None in the list.
Client Permission Restrictions​
This scripting function has no Client Permission restrictions.
Syntax #1​
system.historian.storeMetadata(paths, timestamps, properties)
Parameters​
| Type | Parameter | Description |
|---|---|---|
| List | paths | A list of historical paths. See Path Syntax for more information on recommended syntax. |
| List | timestamps | A list of timestamps. Note: It is possible to store two datapoints with the same timestamp with the Core Historian. If this occurs, the trends will use the highest value point for interpolation. However, it is not recommended to attempt storing two points with identical timestamps. |
| Dictionary | properties | A dictionary of desired properties to be stored as historical metadata, entered as defined key-value pairs corresponding to any relevant tag properties. |
Returns​
List - A list of QualityCode objects. The quality code will indicate success or failure.
Scope​
Gateway, Vision Client, Perspective Session
Syntax #2​
system.historian.storeMetadata(metadata)
Parameters​
| Type | Parameter | Description |
|---|---|---|
| List | metadata | A list of metadata point objects created with system.historian.types.metadataPoint. |
Returns​
List - A list of QualityCode objects. The quality code will indicate success or failure.
Scope​
Gateway, Vision Client, Perspective Session
Code Examples​
# Store a single property to a specified historical tag path and log an info level formatted message.
paths = ["histprov:Historian:/sys:gw1:/prov:default:/tag:remote_200"]
curr = system.date.now()
timestamps = [curr]
properties = { "tooltip": "changing with perspective"}
results = system.historian.storeMetadata(paths, timestamps, properties)
system.util.getLogger('HistorianTest: storeMetadata').info(str(results))
# Store a list of properties to a specified historical tag path.
qualityCodes = system.historian.storeMetadata(
paths=["histprov:CoreHistorian:/sys:gateway:/prov:default:/tag:Folder/MyTag"],
timestamps=[system.date.now()],
properties={
"engUnit": "degF",
"engLow": 0.0,
"engHigh": 500.0,
"documentation": "Main reactor temperature sensor",
"calibrationDate": "2024-01-15"
}
)
# Create metadata using the types API and store it
source = "histprov:CoreHistorian:/sys:gateway:/prov:default:/tag:Folder/MyTag"
properties = {"tooltip":"metadata text"}
timestamp = system.date.now()
metaDataPoints = [system.historian.types.metadataPoint(source, properties, timestamp)]
system.historian.storeMetadata([metadata])