AnsweredAssumed Answered

AFSDK UpdateValue Error : Cannot write a value to a tag at a particular timestamp using AFSDK

Question asked by aksnk89 Champion on Aug 19, 2019
Latest reply on Aug 19, 2019 by rdavin

Hi ,

I am writing a small application which will simply update the value in the PI Tags at a specified time. Here is the code for the same.

 

DateTime dt = DateTime.SpecifyKind(datapipeEvent.Value.Timestamp, DateTimeKind.Unspecified);
DateTime dt2 = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(dt, Tagdetails[datapipeEvent.Value.PIPoint.Name], "UTC");
AFTime newTime = new AFTime(dt2);
AFValue piVal;
piVal = new AFValue(datapipeEvent.Value,newTime);
PIPoint pt = PIPoint.FindPIPoint(myPI, datapipeEvent.Value.PIPoint.Name + "_UTC");
Console.WriteLine(piVal.ToString() + " " + piVal.Timestamp);
pt.UpdateValue(piVal, AFUpdateOption.NoReplace, AFBufferOption.DoNotBuffer);

 

But the following code returns an error "Cannot convert value to a PI equivalent type for writing.

 

if i dont provide an AFTime to the AFValue object it works fine. 

 

Any thoughts on how to fix this ?

 

 

Regards,

Akash

Outcomes