system.historian.storeDataPoints
This function is used in Python Scripting.
Description​
Store a list of data points to the specified historian.
Changed in 8.3.5
Data points can be provided as individual parameter lists or as objects created with system.historian.types.dataPoint.
Client Permission Restrictions​
This scripting function has no Client Permission restrictions.
Syntax #1​
system.historian.storeDataPoints(paths, values, [timestamps], [qualities])
Parameters​
| Type | Parameter | Description |
|---|---|---|
| List | paths | A list of historical paths. |
| List | values | A list of historical values. |
| List | timestamps | A list of timestamps. If omitted, the current time will be used. [optional] |
| List | qualities | A list of qualities. If omitted, "good" quality will be used.[optional] |
| Boolean | blockForResult | Whether the result should be blocked until confirmation that the storage has been attempted. Default is True. [optional] |
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.storeDataPoints(datapoints)
Parameters​
| Type | Parameter | Description |
|---|---|---|
| List | datapoints | A list of data point Java objects created with system.historian.types.dataPoint. |
Returns​
List - A list of QualityCode objects. The quality code will indicate success or failure.
Scope​
Gateway, Vision Client, Perspective Session
Code Examples​
Syntax #1 Code Snippet
paths = ["histprov:mariadb:/sys:gatewayName1:/prov:default:/tag:test_a"]
values = [1]
timestamps = [system.date.now()]
qualities = [192]
listOfQualityCodes = system.historian.storeDataPoints(paths, values, timestamps, qualities)
Syntax #2 Code Snippet
import random
from java.time import Instant
from com.inductiveautomation.historian.common.model.data import DataPointFactory
from com.inductiveautomation.ignition.common.model.values import QualityCode
from com.inductiveautomation.ignition.common import QualifiedPathUtils
# Define all the paths you want to store data for
source_path_strings = [
"histprov:my_historian:/sys:my_gateway:/prov:my_tag_provider:/tag:Motor_1_Amps",
"histprov:my_historian:/sys:my_gateway:/prov:my_tag_provider:/tag:Motor_2_Amps",
"histprov:my_historian:/sys:my_gateway:/prov:my_tag_provider:/tag:Tank_1_Level",
"histprov:my_historian:/sys:my_gateway:/prov:my_tag_provider:/tag:Valve_Status"
]
# This list will hold all the DataPoint objects
datapoints = []
# Get a single timestamp and quality for all points
timestamp = Instant.now()
quality = QualityCode.Good
# Loop over your list of paths
for path_string in source_path_strings:
# Create the QualifiedPath 'source'
source = QualifiedPathUtils.toPathFromHistoricalString(path_string)
# Generate a new random value
value = random.randint(1, 100)
# Create the data point
datapoint = DataPointFactory.createAtomicPoint(value, quality, timestamp, source)
# Add the point to our datapoints list
datapoints.append(datapoint)
system.historian.storeDataPoints(datapoints)