We have been using PI in my company for roughly 15 years. For each tag, we have always taken whatever engineering units the device provides and stored those in PI.
We are now looking at standardizing on metric units wherever we can. This is going to be a gradual process that will likely take many years. We aren't going to be switching everything all at once, but as equipment gets replaced, we would like to use metric where the new devices support it. For instance, there may be a PLC that currently gives us temperatures in degrees Fahrenheit. When that PLC gets replaced, we would like the new one to send us temperatures in degrees Celsius. To reduce confusion, we would also like to convert all of the historical data for the temperature tags coming from that PLC over to degrees Celsius.
What is the best way to handle this sort of thing? I looked at the ReplaceValue method of the IPIData2 interface and it seems to be a good possibility, but are there any gotchas associated with this, especially when we'll be replacing every value going back through 15 years worth of archives in some cases?
We would probably do something like this for each tag as we need to change them. We're using VB.Net (2005).
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim srv As PISDK.Server
Dim pt As PISDK.PIPoint
Dim mysdk As New PISDK.PISDK
Dim val As PISDK.PIValue
Dim ts As Date
Dim ds As PISDK.DigitalState
srv = mySDK.servers("TheServer")
pt = srv.PIPoints("TheTag")
'Get the latest value to start with
Val = pt.Data.ArcValue("*", PISDK.RetrievalTypeConstants.rtBefore)
ts = val.TimeStamp.LocalDate
ds = val.Value
'Loop backwards through PI to when the point was created
While ds.Name <> "Pt Created"
Val = pt.Data.ArcValue(ts, PISDK.RetrievalTypeConstants.rtBefore)
If Not IsNumeric(Val.Value) Then ds = Val.Value
ts = Val.TimeStamp.LocalDate
' ReplaceValue code here - calculate converted value and write it back at the same timestamp as the old value
How have others dealt with this sort of thing, and what problems (if any) did you encounter?