Page tree

Overview

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.


Basics

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


Core Methods

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 Data Source Types

List all installed Eigen Ingenuity Factory Types  

list_data_source_types()

List Instances of a Specific Data Source

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")

Get Default Instance of Data Source Type

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 Apps

List all installed Eigen Apps

list_apps()

Get App Url

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)

List Feature Properties

Request information about installed Eigen Ingenuity Feature Properties  

list_feature_properties()

Get Feature Property

Get the value of the specified Eigen Ingenuity Feature Property  

get_feature_property(property)


Supported Historian Methods

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 DataTags

List all tags in Historian, or those matching the wildcard if one is given  

h.listDataTags(wildcards(optional))

Get Raw Points

Get Range of Raw DataPoints for Tags.  This returns (maxpoints) raw datapoints for tags:

  • a map of {"items":{}}
  • In items a map of tags to lists of DataPoints {"tag1":[DataPoint1,DataPoint2],"tag2":[]}
  • Each DataPoint can be formatted individually using built-in __str__() functionality
  • The results of getRawDataPoints can also be formatted as a group for console output using format_datapoint_results() in utils.

If any datapointlimitexceeded exceptions occur in retrieving the data, a DataPointLimitExceeded Exception is raised, which has the following methods:

  • getAllTags()
  • getTruncatedTags()
  • getUntruncatedTags()
  • getEarliestTimestamp()
  • getEarliestTimestamp(tagname)
  • getLatestTimestamp()
  • getLatestTimestamp(tagname)
  • getNumPointsFound(tagname)
  • getLimit(tagname)
  • getDataPoints()
  • getDataPoints(tagname)
  • getDataPointsBounded(tagname)- Not implemented yet
  • getDataPointsBounded()- Not implemented yet
h.getRawDataPoints(tags, start, end, maxpoints (defaults to 1000))

Count Points

Returns the number of raw datapoints in the given time range for each tag  

h.countPoints(tags, start, end)


Unsupported Historian Methods

Warning: these are alpha code. Use at your own risk!

Get Current DataPoint for Tags

Return latest data point for each tag  

h.getCurrentDataPoints(tags)

Get Interpolated DataPoint for Tags at Timestamps

Return interpolated datapoints for each timestamp on each tag  

h.getInterpolatedPoints(tags, timestamps)

Get Interpolated Range of Points for Tags

Return interpolated datapoints between start and end timestamp for each tag, up to maxpoints  

h.getInterpolatedRange(tags, start, end, count)

Get Aggregates

Returns min, max, avg, sum, numgood, numnotgood, stddev and variance  

h.getAggregates(tags, start, end, count, fields(optional))

Create DataTag

Creates a datatag with units  

h.createDataTag(tag, units)

Write DataPoints

Write data entered as a list of DataPoints, in a tagged map.

h.writeDataPoints(data)

Format for data:  

        {'tagname1': [DataPoint1, DataPoint2, ...],
         'tagname2': [...]
        }

Write DataPoints (from Json)

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"}]}}


Sample Python Program

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>


  • No labels