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, and is not supported by SQL Historian.
Changed in 8.3.5
Metadata can be provided as individual parameter lists or as objects created with system.historian.types.metadataPoint.
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. |
| List | timestamps | A list of 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​
Code Snippet 1: Syntax #1
# 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))
Code Snippet 2: Syntax #1
# 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"
}
)
Code Snippet 1: Syntax #2
# Create metadata using the types API and store it
source = "histprov:CoreHistorian:/sys:gateway:/prov:default:/tag:Folder/MyTag"
metadata = system.historian.types.metadataPoint(
source,
{
"engUnit": "degF",
"engLow": 0.0,
"engHigh": 500.0
},
system.date.now()
)
system.historian.storeMetadata([metadata])