Wrong OPC UA status-code constants in three existing drivers (FF-2) #497
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found while implementing SqlPollReader (verified by reflecting over Opc.Ua.StatusCodes against the pinned SDK, not by copying siblings). All PRE-EXISTING, unrelated to the Sql branch, and client-visible (OPC UA clients branch on status): (1) src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Historian.Gateway/Mapping/SampleMapper.cs names 0x800E0000 'BadNoData' — that value is BadServerHalted; BadNoData is 0x809B0000. (2) GalaxyDriver.cs:878 names 0x800B0000 'BadTimeout' — that is BadServiceUnsupported; BadTimeout is 0x800A0000. (3) TwinCATStatusMapper BadTypeMismatch = 0x80730000; real value is 0x80740000. Each needs its own fix + test; do not fold into the Sql work.
Fixed on
fix/sql-driver-followups(b95b99ba).Scope grew from 3 constants to 16. All values verified by reflecting over
Opc.Ua.StatusCodesin the pinned SDK (1.5.378.106), not by copying siblings.The three named here were confirmed exactly as reported. Two additions:
BadTypeMismatch = 0x80730000was in four drivers, not one — TwinCAT (named here) plus FOCAS, AbLegacy and AbCip. Every call site is aFormatException/InvalidCastExceptionconversion failure, so the name was right and the value was wrong in all four.0x80730000isBadWriteNotSupported.A reflection parity guard found nine more. Rather than six point fixes I added
StatusCodeParityTeststoCore.Abstractions.Tests(which already project-references every driver): it reflects over everyconst uintin the deployedZB.MOM.WW.OtOpcUa.Driver.*.dllwhose name reads as a status code and asserts it equalsOpc.Ua.StatusCodes.<name>. It went red on nine defects nobody had reported:GoodLocalOverride0x00D800000x00960000UncertainLastUsableValue0x40A40000UncertainDataSubNormal0x40900000UncertainSensorNotAccurate0x408D00000x40930000UncertainEngineeringUnitsExceeded0x408E00000x40940000UncertainSubNormal0x408F0000UncertainNoCommunicationLastUsableValue0x40950000BadOutOfService0x80BE0000BadProtocolVersionUnsupported0x808D0000BadInvalidState0x80350000BadAttributeIdInvalid0x80AF0000GoodMoreData0x00A70000GoodCommunicationEvent0x00A60000GatewayQualityMapperGood_LocalOverride0x00D800000x00960000Galaxy’s whole Uncertain block reads as though the OPC DA quality byte could be shifted into the UA substatus position — it cannot; the substatuses are an unrelated enumeration.
GatewayQualityMapperalready held the correct table, which is what the Galaxy values were reconciled against.Two inline literals were hoisted into named constants so the guard can see them at all (reflection cannot see a literal at a call site — which is precisely how
GalaxyDriver’s0x800B0000u, // BadTimeoutsurvived): Galaxy’s intoStatusCodeMap, andGatewayQualityMapper’s 15-entry table into a newHistorianStatusCodes.Also corrected: tests that pinned the wrong values (
StatusCodeMapTests,SampleMapperTests,GatewayQualityMapperTests— all written from the same bad source), and stale constants in two design docs, one of them the unexecuted MTConnect driver design, which would have propagatedBadNoData’s wrong value into a brand-new driver.The CLI’s
SnapshotFormattervalue→name table was checked against the SDK and is correct; no change needed.The drivers stay SDK-free by design — only the test project references
Opc.Ua.Core, as the oracle. Guard now checks 109 constants green; full solution builds; all 41 unit-test projects pass.