I would like to retreive status code of PI Tag using PISDK. I know that it's stored as Digital State in value field while point is not good but I wonder if it's possible to get status code for points which are in good state?
In PISDK, you can determine the "status" of the PI tag in the PIValue object. First of all, the IsGood method will determine if the tag is in a good state. If you use IPIValueAttribute, you can further determine whether the tag is annotated, questionable, or substituted (refer to the SDK reference guide at %pihome%\help\pisdk.chm for more information). If a tag is good, the status code for the tag will be the same value.
I hope this answers your question. If not, can you tell me what kind of information you are trying to get from a good PI tag? I will be able to provide further information.
I need to store DigitalState.Code in database even if the tag is in "Good" state. I don't want to hardcode this value, that's why I want to retreive it from PI. I wonder if there is any other way to get status code for "Good" digital state than using PIServer.StateSets (like using PIPoint object).
When a PI tag is bad, the "status" code is a number which corresponds to a state in the SYSTEM digital state set; when a PI tag is good, the "status" code is effectively 0. If the PI tag is not a digital tag, the number of 0 when the tag is good does not correspond to a valid state in the SYSTEM digital state set, and the tag does not "uses" the digital state set at all. Therefore, you can only get a status code for a PI tag when it's not in a good state, because it doesn't use a digital sate when the status is good. Note that when we say a tag is good here, it is different from the digital state "Good" (307) within the SYSTEM digital state set.With that said, if you want to store the status in your database when the tag is good, consider using IsGood to find whether the status is good, and assign the value of 0 to the status. Keep in mind that the value of 0 in this case should not correspond to a valid state in the SYSTEM digital state set.
DigitalState objects are typically retrieved from a StateSet to send to PI, or they may be returned as part of a PIValue. The PIValue.Value property returns a string, a numeric, or an object such as a DigitalState or PITime. Could you tell us if your tags are digital or numeric tags? For e.g., for numeric tags, if the value is good, a numeric is returned. So it would not be possible to get a DigitalState object from PI.
Retrieving data ...