Table of Contents
Page Tree
This Python library provides a client interface to some of the Eigen Ingenuity system, most notably the Historian API.
In the usual Python way, documentation on classes and objects can be found using pydoc, e.g. pydoc eigeningenuity.historian.
The libraries use the EIGENSERVER environment variable to locate the server. This can be either a hostname, or a hostname:port, or a full URL path e.g. !http://eigeninenuity.my.com:8080/. The default value if the environment variable is not set is localhost:8080
The eigeningenuity.core provides methods for finding out information about the installation, including configured data sources and installed applications. Are imported directly from eigeningenuity as in ...
From eigeningenuity import list_factory_types
The following methods are available:
List all installed Eigen Ingenuity Factory Types
list_data_source_types()
List the instances for a specified Eigen Ingenuity Factory Type Returns None if there are no instances
list_data_sources(type)
An example
from eigeningenuity.core import list_data_sources
allhistorians = list_data_sources("historian")
Returns the name of the default instance for a specified Eigen Ingenuity Factory Type Returns None if no default instance can be found
get_default_data_source(type)
An example
from eigeningenuity.core import get_default_data_source
instance = get_default_data_source("historian")
List all installed Eigen Apps
list_apps()
Find the base URL for a specified Eigen Ingenuity apps. Note this is something like "historian-servlet" not "trend" or "jsonbridgehistorian". Think "module" rather than "tool". Returns None if the app is not installed.
get_app_url(appname)
Request information about installed Eigen Ingenuity Feature Properties
list_feature_properties()
Get the value of the specified Eigen Ingenuity Feature Property
get_feature_property(property)
After importing the historian code and declaring a historian instance,
from eigeningenuity import get_historian
h = get_historian("historianname")
To instantiate the default historian, call get_historian without any parameters
from eigeningenuity import get_historian
h = get_historian()
The following methods are available:
List all tags in Historian, or those matching the wildcard if one is given
h.listDataTags(wildcards(optional))
Get Range of Raw DataPoints for Tags. This returns (maxpoints) raw datapoints for tags:
If any datapointlimitexceeded exceptions occur in retrieving the data, a DataPointLimitExceeded Exception is raised, which has the following methods:
h.getRawDataPoints(tags, start, end, maxpoints (defaults to 1000))
Returns the number of raw datapoints in the given time range for each tag
h.countPoints(tags, start, end)
Warning: these are alpha code. Use at your own risk!
Return latest data point for each tag
h.getCurrentDataPoints(tags)
Return interpolated datapoints for each timestamp on each tag
h.getInterpolatedPoints(tags, timestamps)
Return interpolated datapoints between start and end timestamp for each tag, up to maxpoints
h.getInterpolatedRange(tags, start, end, count)
Returns min, max, avg, sum, numgood, numnotgood, stddev and variance
h.getAggregates(tags, start, end, count, fields(optional))
Creates a datatag with units
h.createDataTag(tag, units)
Write data entered as a list of DataPoints, in a tagged map.
h.writeDataPoints(data)
Format for data:
{'tagname1': [DataPoint1, DataPoint2, ...],
'tagname2': [...]
}
Write data entered in json (currently DISABLED)
h.writeDataPoints(data)
Format for json:
{'write':
{'tagname': [
{"value":value1, "timestamp": epochms, "status":status},
{"value":value2, "timestamp": epochms, "status":status}
],
'tagname2': [
{...}
]
}
}
Example: {"write":{"testtag1":[{"value":20,"timestamp":1462886123000,"status":"OK"}]}}
Here's a sample program which gets list the tags on a historian instance called "dev1-influxdb"
#!/usr/bin/python
#
import sys, os
from eigeningenuity import get_historian
h = get_historian("dev1-influxdb")
tags = h.listDataTags()
for tag in sorted(tags):
print tag
</verbatim>