ScriptManager.runScriptFunction() example


My main aim is to use python system functions and make a module according to our application.

I am trying to extract tag historian Data through SDK module programming.
I have taken managed-tag-provider example provided by the SDK as my skeleton project and trying to run ignition's system functions through scriptManager.runFunction().
I am stuck with trying to implement the mentioned function.
Here is the code which i have tried:

public List<Map<String, Object>> getTagHistory(String tagPath, Date startDate, Date endDate, int returnSize) {
String functionName = "system.tag.queryTagHistory";
Map<String, Object> args = new HashMap<>();
args.put("paths", new String { tagPath });
args.put("startDate", startDate);
args.put("endDate", endDate);
args.put("returnSize", Integer.valueOf(returnSize));

    result = script.runFunction(functionName , args);

    return (List<Map<String, Object>>) result;

script is a global instance of ScriptManager.

I am getting this error : Cannot resolve method 'runFunction(String, Map<String, Object>)'

I understood the method signature is different. But I am not able to implement this function.
Any example on how to use this method would be really helpful.



You can directly access the SDK and do what you need to, without the overhead of translation to and from Jython objects.

Thanks for your reply. I had changed my plan from using Jython to Java and though I am not getting any errors but tag history is returning only 1 row. As I was checking for rowCount() in the logger, Though it logged so many values in the span of 5 minutes on change, but the function only logged 1 as the getRowCount() result in the gateway logs.

public void getTagHistory(String tagPath, Date startDate, Date endDate) throws IOException {

    BasicTagHistoryQueryParams params = new BasicTagHistoryQueryParams();"startDate : " + startDate);"endDate : "  + endDate);

    List<String> tagPaths = Arrays.asList(tagPath);
    List<Path> paths = new ArrayList<>();
    for (String tP : tagPaths) {
        Path path = null;
        try {
            path = TagPathParser.parse(tP);
        } catch (IOException e) {
            throw new RuntimeException(e);


// params.setAggregationMode(AggregationMode.SimpleAverage);
// params.setReturnFormat(ReturnFormat.Wide);

    BasicStreamingDataset dataset = new BasicStreamingDataset();


This function is called in startup lifecycle event with required params.

If I add returnSize param of BasicTagHistoryQueryParams to 1000:

Though I am getting rowCount as 1000 . they are all the same values without change.
When we configure tagHistorian, we configure the data to be logged into database only when the tag value is changed. However, i am finding all the values upto some rows are the same.

It is working now. I have used java methods instead of Script Manager. Thanks for the help.