I am trying to retrieve a history entry for a string tag at a specific point in time. I have modified the sample script as follows:
import datetime
startTime = datetime.datetime.now() - datetime.timedelta(minutes=10)
endTime = datetime.datetime.now()
dataSet = system.tag.queryTagHistory(paths=['[MSSQL]Line 2/LineConfig/MiddleRoll'], startDate=startTime, endDate=endTime, returnSize=1, aggregationMode="LastValue", returnFormat='Wide')
print dataSet.getValueAt(0,1)
I store historical data at least every 10 minutes so if I set the endTime to the time I want and startTime to 10 minutes earlier I should capture at least one historical entry (I understand I am getting the most recent entry with this code but changing the date window is relatively easy). Then, if I set aggregationMode to LastValue I should get the piece of data I want.
However, it crashes because it tries to cast the string as a number:
Caused by: java.lang.ClassCastException: Error trying to coerce ' R1 - Rubber' to a number.
I have also seen this problem when developing reports and it seems to be caused by the same problem: The historian wants to turn the string into a number. How do I go about getting string data out of the historian?