Create Python Script by Importing Third-party or Custom Python Modules or Functions
About this task
Procedure
- In the same machine where you installed Python 3.8, install the needed modules or create your own functions.
-
After you install the modules, for the collector to recognize the modules, update
the following path to include the location where you installed the modules or created
your own functions:
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\GE Digital\iHistorian\CollectorServiceExtensions\PythonExpressions\PythonPath
After you update the path, the changes are reflected as follows:C:\Program Files (x86)\GE Digital\Historian Python Expressions\Python38\lib
C:\Program Files (x86)\GE Digital\Historian Python Expressions\Python38\user
C:\Users\Administrator\AppData\Local\Programs\Python\Python38-32\Lib
C:\Users\Administrator\AppData\Local\Programs\Python\Python38-32\Lib\site-packages
You can also configure Python library path using Configuration Hub. For more information, refer to Configure Python Library path using Configuration Hub. - Access Configuration Hub
-
In the NAVIGATION section, under the Configuration Hub plugin
for Historian, select Tags.
A list of tags appears.
-
Select a Python collector tag, right-click or select more options, and then select
Calculation.The PYTHON SCRIPT editor appears.
-
In the scripting section, remove
Null
(and retain theResult =
). -
In the scripting section, to import the custom or third-party functions/modules,
enter the script in the following format:
import mymodule Result=mymodule.myfunction() #Example import SimulationCalculation Result=SimulationCalculation.GetInteger()
-
To test the function, select
.
A message appears, stating whether the syntax is correct. -
In the upper-left corner of the page, select Save.
The Python script is created.
After few seconds, the added script takes effect.