larry.mcdonald

Cannot set custom AFValueStatus

Discussion created by larry.mcdonald on Feb 6, 2013
Latest reply on Feb 18, 2013 by hanyong

I would like to set custom statuses on AFValues.  I think I should be able to do this based on the comment in the AFSDK help: 

 

“The lower byte (bits 0-7) of the status are reserved for indicating the overall status of the value. The second lowest byte (bits 8-15) indicates vendor specific status. The Annotated bit is the top-most bit of this byte (bit 15). The top word (bits 16-31) is available for user use and the AF SDK will not apply any meaning to these bits.”

 

However, I am not able to get the custom status bits to “stick” to the value.

 

All the statuses come back with AFValueStatus.Good (192).  I have even explicitly set the status to AFValueStatus to AFValueStatus.Bad when calling UpdateValues, but the values are read back out with AFValueStatus.Good.

 

How can I ensure that I am setting the status correctly. Which retrieval call should I use to ensure that I get the custom status bits back?

 

 Example code:

 

//Set custom bits in the status

uint GetStatusForPi(uint myStatus)

{

       uint myValidStatus = 134217728;

       if (IsValid(myStatus))

       {

             return (uint)AFValueStatus.Good | myValidStatus;

       }

       else

       {

             return (uint)AFValueStatus.Bad | myValidStatus;

       }

}

 

 

 //Set the status

AFValues values = new AFValues();

values.Add(new AFValue() { Timestamp = myData.TimeStamp, Value = myData.Value, Status = (AFValueStatus)GetStatusForPi(myData.Status) });

myPiPoint.UpdateValues(values, AFUpdateOption.InsertNoCompression);

 

 

//When reading the values, I can never find my custom status bits

myAFElement[“attribute”].Data.RecordedValuesByCount(startTime, count, forward, AFBoundaryType.Inside, null, string.Empty, false);

//or

myAFElement[“attribute”].Data..InterpolatedValues(timeRange, interval, null, string.Empty, false);

 

 

 

Outcomes