namespace ZB.MOM.WW.OtOpcUa.Host.Domain { /// /// OPC DA quality codes mapped from MXAccess quality values. (MXA-009, OPC-005) /// public enum Quality : byte { // Bad family (0-63) /// /// No valid process value is available. /// Bad = 0, /// /// The value is invalid because the Galaxy attribute definition or mapping is wrong. /// BadConfigError = 4, /// /// The bridge is not currently connected to the Galaxy runtime. /// BadNotConnected = 8, /// /// The runtime device or adapter failed while obtaining the value. /// BadDeviceFailure = 12, /// /// The underlying field source reported a bad sensor condition. /// BadSensorFailure = 16, /// /// Communication with the runtime failed while retrieving the value. /// BadCommFailure = 20, /// /// The attribute is intentionally unavailable for service, such as a locked or unwritable value. /// BadOutOfService = 24, /// /// The bridge is still waiting for the first usable value after startup or resubscription. /// BadWaitingForInitialData = 32, // Uncertain family (64-191) /// /// A value is available, but it should be treated cautiously. /// Uncertain = 64, /// /// The last usable value is being repeated because a newer one is unavailable. /// UncertainLastUsable = 68, /// /// The sensor or source is providing a value with reduced accuracy. /// UncertainSensorNotAccurate = 80, /// /// The value exceeds its engineered limits. /// UncertainEuExceeded = 84, /// /// The source is operating in a degraded or subnormal state. /// UncertainSubNormal = 88, // Good family (192+) /// /// The value is current and suitable for normal client use. /// Good = 192, /// /// The value is good but currently overridden locally rather than flowing from the live source. /// GoodLocalOverride = 216 } /// /// Helper methods for reasoning about OPC quality families used by the bridge. /// public static class QualityExtensions { /// /// Determines whether the quality represents a good runtime value that can be trusted by OPC UA clients. /// /// The quality code to inspect. /// when the value is in the good quality range; otherwise, . public static bool IsGood(this Quality q) { return (byte)q >= 192; } /// /// Determines whether the quality represents an uncertain runtime value that should be treated cautiously. /// /// The quality code to inspect. /// when the value is in the uncertain range; otherwise, . public static bool IsUncertain(this Quality q) { return (byte)q >= 64 && (byte)q < 192; } /// /// Determines whether the quality represents a bad runtime value that should not be used as valid process data. /// /// The quality code to inspect. /// when the value is in the bad range; otherwise, . public static bool IsBad(this Quality q) { return (byte)q < 64; } } }