osisoft updating values ​with python

406 Views Asked by At

I want to get the data from Excel and update the values ​​of the data between certain dates in the osisoft system. But I don't know how to code AfTimeRange. I get the error "value cannot be converted to OSIsoft.AF.Time.AFTime".

enter image description here

1

There are 1 best solutions below

0
On

Good news: You've constructed your [AFTimeRange] correctly!

Notice that the error being thrown is not by the [AFTimeRange] constructor, but from something else.

The issue is that you are trying to set the 'Timestamp' attribute [OSIsoft.AF.Time.AFTime] to a value of type [OSIsoft.AF.Time.AFTimeRange], and so it's failing. A PI event has a single timestamp, not a time range.

I'm not familiar with Python, but it should work if you input the value as an AFTime object using its string constructor, assuming you're intending to use yesterday midnight as your timestamp:

val.timestamp = AFTime("y")

See the documentation on AFTime for more detail.