7 Replies Latest reply on Sep 14, 2012 10:07 PM by ekuwana

    AFSDK Data.UpdateValue() for Digital States


      How can I populate an AFValue with a digital state and write to the PI Server?


      The PISDK casts a string as a digital state in a PIValue so it can be written to PI.


      It seems like this should be obvious, but I can't figure it out.  Any help would be greatly appreciated.







        • Re: AFSDK Data.UpdateValue() for Digital States

          Hi Benji,


          I guess you are trying to write to a digital PI Point referenced by an AFAttribute in this case? Is the datatype of the AFAttribute configured as string?


          If so, you should be able to do something similar in AF SDK, using AFAttribute.SetValue method, passing an AFValue object with a string value with the same string representation of one of the digital state that the digital set.


          For example if you have an attribute referencing CDM158, you can write the value in AF SDK like:

          attr.SetValue(new AFValue("Auto"))

          where attr is the variable representing the attribute.


          If you are getting an error doing something like this now, then I would verify if the string matches one of the digital state string correctly. Also verify the AFAttribute is set with ReadOnly = false, because the default setting is true.


          Hope this helps