Querying Data in a Report
To query data, the mplreport class has the FetchHistory function.
The function takes a single parameter - the AQL function you want to run. Note that this function should not include the call to GETHISTORY. The API will take care of adding that for you. You simply need to include a query that returns a list of ARDI points.
For example, if we wanted to make a report showing every temperature measurement in our system, we could do the following…
thedata = report.FetchHistory("'Temperature' PROPERTYEX ALLPOINTS")
The thedata variable would now contain a AQLHistResponse object. This object contains both the metadata for your query (describing the individual points), and a pandas dataframe containing your data.
NOTE: If you're following along with your own ARDI databases, we suggest substituting 'Temperature' for a value that exists in your ARDI system.
Checking for Errors
You can check to see if there were any issues access data using report.FetchFailure function. This returns True if there was some kind of issue access your data, or False if there were no problems.
You can reset this with flag with report.ClearFailures, or access a list of the errors with report.errors.
If there is no way to gracefully handle an issue - such as failure to read data - you can call report.Failed to generate a placeholder report advising users of the failure. This will also trigger failure handing inside the ARDI reporting system.
thedata = report.FetchHistory("'Temperature' PROPERTYEX ALLPOINTS") if report.FetchFailure(): report.Failed("\n".join(report.errors))
The Next Step
Next, we'd like to use our historical data in our report.