Asle Frantzen

Parse PI time in custom symbol?

Discussion created by Asle Frantzen Champion on Oct 23, 2020
Latest reply on Oct 29, 2020 by Asle Frantzen

I have a custom symbol which connects to a restful webservice for its data, and until now I've just taken the time of the request and passed that along as part of the request. But now the customer wants this time to follow the end time of the display instead.


I've injected the timeProvider and successfully subscribed to the onDisplayTimeChanged event, so I know both the start time and end time of the display as soon as they change. The issue I'm having is PI Time format related, because the end time of the display may easily return as 't' or '*-1mo'. 


Is there a way I could get these values/expressions parsed using functionality from within the PI Vision framework?


Other than this path I know I can do something with the PI WebAPI, which we will have available even after we upgrade to Vision 2020. https://URL-TO-SERVER/piwebapi/calculation/times?expression=ParseTime("*-8h")&time=*  will return the correct value for me, but I would really like to avoid having to query another webapi to get this.