Пример #1
0
        public override void Execute()
        {
            _apm.MessageLog("Executing " + diagnosticName);

            // create a device object without instance number - this will create a wildcard instance
            BACnetObjectIdentifier oid = new BACnetObjectIdentifier(BACnetEnums.BACNET_OBJECT_TYPE.OBJECT_DEVICE);

            try
            {
                ClearIncomingPacketQueue();
                BACnetUtil.SendReadProperty(_apm, _bnm, devicTreeNode.device, oid, BACnetEnums.BACNET_PROPERTY_ID.PROP_OBJECT_IDENTIFIER);
                BACnetPacket pkt = waitForPacket(5000);

                if (pkt.pduType == BACnetEnums.BACNET_PDU_TYPE.PDU_TYPE_COMPLEX_ACK &&
                    pkt.propertyID == BACnetEnums.BACNET_PROPERTY_ID.PROP_OBJECT_IDENTIFIER)
                {
                    if (pkt.objectID != null && pkt.objectID.objectInstance == devicTreeNode.device.deviceObjectID.objectInstance)
                    {
                        MarkDiagnosticSuccess();
                    }
                    else
                    {
                        MarkDiagnosticFailed("Response received, but the Object ID is not that of the Device");
                    }
                }
                else
                {
                    MarkDiagnosticFailed("Proper Complex-ACK not received");
                }
            }
            catch (TimeoutException)
            {
                // todo-put a wrapper around execute and catch all executions in a common area..
                MarkDiagnosticFailed("Timeout");
                return;
            }
            catch (Exception ex)
            {
                // other types of exception...
                _apm.MessagePanic(ex.ToString());
                return;
            }
        }