1 Reply Latest reply on Jul 19, 2010 1:54 AM by hanyong

    SetValue and UOM Conversion

    afiset

      Lets say I have an AF atttribute configured with the degrees celsius UOM. If users are writing to this attribute with different UOM, one writes 32 Celsius and another one writes 96 Farenheit, how can this be handled? I notice there's a UOM parameter you can passed to the AFAttribute.SetValue method. Is this it? When will the conversion happened? For a PI Point DR, will the 96 Farenheit value be converted to 35.56 Celsius before it is archived in the PI point? For a staic attribute with no data reference, will that value show up as 35.56 Celsius.

        • Re: SetValue and UOM Conversion
          hanyong

          Yes, you are right. If your attribute has a UOM defined (in this case "degree Celsius") and you are writing a value with another UOM ("degree Fahrenheit") of the same class, the value will be converted and stored based on the defined UOM ("degree Celsius").

           

          You can either use AFAttribute.SetValue(object newValue, UOM uom) or create use AFValue with a specified UOM, like new AFValue(object newValue, AFTime timestamp, UOM uom) with AFAttribute.SetValue(AFValue newValue).

           

          Alexandre Fiset

          For a PI Point DR, will the 96 Farenheit value be converted to 35.56 Celsius before it is archived in the PI point?

          For PI Point DR, it is converted before writing back to PI. One thing to note, there is another UOM setting in the PI Point DR setting. Ultimately a value is converted to this UOM when written to PI .

           

          Alexandre Fiset

          For a staic attribute with no data reference, will that value show up as 35.56 Celsius.

          Like PI Point DR, static attributes save the value after conversion. With respect to your example, it should show up as 35.56 deg C without specifying UOM.