Available Functions
This topic describes the built-in functions that you can use to create a calculation formula. You can also use third-party or custom Python modules in the script.
Function Type | Function | Description | Example |
---|---|---|---|
Add Data | Historian.AddData(tags, values,times) |
Write data to a tag in the Historian archive. | Result=Historian.AddData
('Python_Sample_Calculation',0,'2023-12-13T15:13:44.536Z',100) |
Check Data Quality | Historian.CurrentQuality('tag name') |
The current quality of the tag (0 for bad quality and 100 for good quality). | Result=Historian.CurrentQuality('Tag') |
Check Data Quality | Historian.InterpolatedQuality('tag
name','time') |
The current quality of the interpolated tag. | Result=Historian.InterpolatedQuality('Tag1','2023-12-13T16:32:03.626Z') |
Check Data Quality | Historian.NextGoodQuality('tag name', 'time') |
The good quality of the raw sample after the time. Time is provided as string in standard ISO 8601 format. | Result=Historian.NextGoodQuality('Tag1','2023-12-13T16:34:19.154Z') |
Check Data Quality | Historian.NextQuality('tag name','time') |
The quality of the tag (0 for bad quality and 100 for good quality) after the time. Time is provided as string in standard ISO 8601 format. | Result=Historian.NextQuality('Tag2','2023-12-13T16:35:41.709Z') |
Check Data Quality | Historian.PreviousGoodQuality('tag
name','time') |
The good quality of the raw sample prior to the time. Time is provided as string in standard ISO 8601 format. |
Result=Historian.PreviousGoodQuality('Tag3','2023-12-13T16:36:47.736Z') |
Check Data Quality | Historian.PreviousQuality('tag name','time') |
The quality of the tag (0 for bad quality and 100 for good quality) prior to the time specified. Time is provided as string in standard ISO 8601 format. |
|
Insert A Calculation- Non-filtered Calculation | Historian.Calculation('tag name', 'CalculationMode', 'StartTime',
'EndTime') |
Unfiltered calculated data query that returns a single value, similar to the Excel Add-In feature. For a list of the calculation mode, refer to calculation modes. All times are provided as string in standard ISO 8601 format. |
|
Insert A Calculation- Filtered | Historian. CalculationFilter('tag name', 'CalculationMode',
'StartTime', 'EndTime', 'FilterTagname', 'FilterMode', 'FilterComparison',
'FilterValue') |
Filtered calculated data query that returns a single value, similar to the Excel Add-In feature. All times are provided as string in standard ISO 8601 format. |
|
Insert A Calculation Quality- Non-filtered Calculation | Historian.CalculationQuality('tag name', 'CalculationMode',
'StartTime', 'EndTime') |
Unfiltered calculated data query that returns the quality of resulting value. For a list of the calculation mode, refer to calculation modes. All times are provided as string in standard ISO 8601 format. |
Result=Historian.CalculationQuality('Python_2','Average','2023-12-13T16:54:27.296Z','2023-12-13T16:54:28.296Z') |
Insert A Calculation Quality- Filtered Calculation | Historian.CalculationFilterQuality('tag name', 'CalculationMode',
'StartTime', 'EndTime', 'FilterTagname', 'FilterMode', 'FilterComparison',
'FilterValue') |
Filtered calculated data query that returns the quality of value. All times are provided as string in standard ISO 8601 format. | Result=Historian.CalculationFilterQuality('Tag','Average','2023-12-13T16:56:08.123Z','2023-12-13T16:56:09.123Z','Tag','AfterTime','Equal','') |
Insert A Tagname | 'Tag' |
The selected tag name. | Result='Python_3_tag' |
Insert A Timestamp | Historian.CurrentTime() |
The calculation execution time, which becomes the timestamp of the stored value. The result is returned as a string. For real-time
processing of polled tags, the calculation execution time is the time when
the calculation is triggered. For unsolicited tags, the calculation
execution time is the timestamp delivered with the subscription. For recovery of polled or unsolicited tags, the
calculation execution time is the time when the calculation would have been
performed if the collector were running.Note: When a calculation is performed, the timestamp of
the result is the time that the calculation has begun, not the time that
it completed. |
|
Insert A Timestamp |
|
The timestamp of the good raw sample after the time. Time is provided as string in standard ISO 8601 format. | Result=Historian.NextGoodTime('Tag',2023-12-13T17:54:44.223Z) |
Insert A Timestamp | Historian.NextTime(‘tag name’, ‘time’) |
The timestamp of the raw sample after the timestamp. Time is provided as string in standard ISO 8601 format. | Result=Historian.NextTime('Tag','2023-12-13T17:56:21.726Z') |
Insert A Timestamp | Historian.PreviousGoodTime(‘tag name’, ‘time’) |
The timestamp of the latest good quality of the raw sample prior to the time. Time is provided as string in standard ISO 8601 format. | Result=Historian.PreviousGoodTime('Tag','2023-12-13T17:57:45.308Z') |
Insert A Timestamp | Historian.PreviousTime(‘tag name’, ‘time’) |
The timestamp of the raw sample prior to the time. Time is provided as string in standard ISO 8601 format. | Result=Historian.PreviousTime('Test_Sim.Simulation00001','2023-03-27T16:02:08.070557') |
Insert A Timestamp | 'time shortcut' |
The timestamp.value as a string format, in ISO 8601 format. | Result='2023-12-13T18:00:38.186Z' |
Insert A Value | Historian.CurrentValue(‘tag name’) |
The value of the tag, interpolated to the calculation execution time. The
CurrentValue function returns 0 if the quality is 0 (bad
quality). This occurs if you initialized it to 0, or if a previous call
failed. |
Result=Historian.CurrentValue('Test_Sim.Simulation00001') |
Insert A Value | Historian.InterpolatedValue(‘tag name’,
‘time’) |
The tag value, interpolated to the time that you enter. Time is provided as string in standard ISO 8601 format. | Result=Historian.InterpolatedValue('Tag',
'2023-12-13T18:05:29.367Z')' |
Insert A Value | Historian.NextGoodValue(‘tag name’, ‘time’) |
The value of the good raw sample after the time. Time is provided as string in standard ISO 8601 format. | Result=Historian.NextGoodValue('Tag',
'2023-12-13T18:06:41.622Z') |
Insert A Value | Historian.NextValue(‘tag name’, ‘time’) |
The value of the raw sample after the timestamp. Time is provided as string in standard ISO 8601 format. | Result=Historian.NextValue('Tag',
'2023-12-13T18:07:44.369Z') |
Insert A Value | Historian.PreviousGoodValue(‘tag name’,
‘time’) |
The latest good value of the raw sample prior to the time. Time is provided as string in standard ISO 8601 format. |
|
Insert A Value | Historian.PreviousValue(‘tag name’, ‘time’) |
The tag value of the raw sample prior to the time specified. Time is provided as string in standard ISO 8601 format. |
|
Insert An Advanced Calculation- Non-filtered Calculation | Historian.AdvancedCalculation('Tagname', 'CalculationMode',
‘CriteriaString’ 'StartTime', 'EndTime') |
Unfiltered calculated data query with criteria string that returns a single value. All times are provided as string in standard ISO 8601 format. | Result=Historian.AdvancedCalculation('Tag','Average','','2023-12-13T18:15:22.189Z','2023-12-13T17:15:23.189Z') |
Insert An Advanced Calculation- Filtered Calculation | Historian.AdvancedCalculationFilter ('Tagname',
'CalculationMode', ‘CriteriaString’, 'StartTime', 'EndTime',
'FilterTagname', 'FilterMode', 'FilterComparison',
'FilterValue') |
Filtered calculated data query with criteria string that returns a single value. All times are provided as string in standard ISO 8601 format. | Result=Historian.AdvancedCalculationFilter('Tag','Average','','2023-12-13T18:16:29.333Z','2023-12-13T18:16:30.333Z','Tag','AfterTime','Equal','') |
Insert An Advanced Calculation Quality- Non-filtered Calculation | Historian.AdvancedCalculationQuality('Tagname',
'CalculationMode', ‘CriteriaString’ 'StartTime',
'EndTime') |
Unfiltered calculated data query with criteria string that returns the quality of value. All times are provided as string in standard ISO 8601 format. | Result=Historian.AdvancedCalculationQuality('Tag','Average','','2023-12-13T18:18:32.238Z','2023-12-13T18:18:33.238Z') |
Insert An Advanced Calculation Quality- Filtered Calculation | Historian.AdvancedCalculationFilterQuality ('Tagname',
'CalculationMode', ‘CriteriaString’, 'StartTime', 'EndTime',
'FilterTagname', 'FilterMode', 'FilterComparison',
'FilterValue') |
Filtered calculated data query with criteria string that returns the quality of value. All times are provided as string in standard ISO 8601 format. | Result=Historian.AdvancedCalculationFilterQuality('Tag','Average','','2023-12-13T18:20:19.954Z','2023-12-13T18:20:20.954Z','Tag','AfterTime','Equal','') |
NA | Historian.LogMessage(string_message) |
Allows you to write messages to the collector log file for debugging
purposes. The collector log files are located in the
folder. |
Result=Historian.LogMessage(test_message) |