public override void Execute()
        {
            try
            {
                ClearIncomingPacketQueue();

                // Create, encode and send a packet
                BACnetPacket pkt = new BACnetPacket(_apm, _bnm, this.device.adr, this.device.deviceObjectID, BACnetEnums.BACNET_PROPERTY_ID.PROP_PROTOCOL_REVISION);
                pkt.SendPacket();

                // Wait for response
                BACnetPacket responsePkt = waitForPacket(5000);

                // Since we made a deliberate mistake with our request, we expect a reject PDU. Make sure we get it

                if (responsePkt.pduType == BACnetEnums.BACNET_PDU_TYPE.PDU_TYPE_COMPLEX_ACK)
                {
                    if (responsePkt.confirmedServiceChoice == BACnetEnums.BACNET_CONFIRMED_SERVICE.SERVICE_CONFIRMED_READ_PROPERTY)
                    {
                        _apm.MessageLog("Protocol revision = " + responsePkt.protocolRevision.ToString());
                    }
                    else
                    {
                        MarkDiagnosticFailed("errDiag00001 - Wrong confirmedServiceChoice in response");
                        return;
                    }
                }
                else
                {
                    MarkDiagnosticFailed("errDiag00002 - Complex ACK not received");
                    return;
                }
            }
            catch (TimeoutException)
            {
                MarkDiagnosticFailed("Timeout");
                return;
            }
            catch (Exception ex)
            {
                _apm.MessagePanic("Diagnostic Exception " + ex.ToString());
                return;
            }
            MarkDiagnosticSuccess();
        }
Beispiel #2
0
        public override void Execute()
        {
            int protocolRevision;

            try
            {
                ClearIncomingPacketQueue();
                BACnetPacket pkt = new BACnetPacket(_apm, _bnm, this.device.adr, this.device.deviceObjectID, BACnetEnums.BACNET_PROPERTY_ID.PROP_PROTOCOL_REVISION);
                pkt.SendPacket();
                BACnetPacket respPkt = waitForPacket(5000);

                protocolRevision = respPkt.protocolRevision;

                pkt = new BACnetPacket(_apm, _bnm, this.device.adr, this.device.deviceObjectID, BACnetEnums.BACNET_PROPERTY_ID.PROP_PROTOCOL_OBJECT_TYPES_SUPPORTED);
                pkt.SendPacket();
                respPkt = waitForPacket(5000);


                // Since we made a deliberate mistake with our request, we expect a reject PDU. Make sure we get it

                if (respPkt.pduType == BACnetEnums.BACNET_PDU_TYPE.PDU_TYPE_COMPLEX_ACK)
                {
                    if (respPkt.confirmedServiceChoice == BACnetEnums.BACNET_CONFIRMED_SERVICE.SERVICE_CONFIRMED_READ_PROPERTY)
                    {
                        // so far, so good, continue
                        switch (protocolRevision)
                        {
                        case 2:
                            if (respPkt.bitString != null && respPkt.bitString.Count() != 0x19)
                            {
                                MarkDiagnosticFailed("Object Type List not the correct length for the protocol");
                                return;
                            }
                            break;

                        case 6:
                            if (respPkt.bitString != null && respPkt.bitString.Count() != 38)
                            {
                                MarkDiagnosticFailed("Object Type List not the correct length for the protocol");
                                return;
                            }
                            break;

                        case 10:
                            if (respPkt.bitString != null && respPkt.bitString.Count() != 0x33)
                            {
                                MarkDiagnosticFailed("Object Type List not the correct length for the protocol");
                                return;
                            }
                            break;

                        default:
                            MarkDiagnosticFailed("Unknown protocol revision");
                            return;
                        }
                    }
                    else
                    {
                        MarkDiagnosticFailed("Did not receive a response to the confirmed read property");
                        return;
                    }
                }
                else
                {
                    MarkDiagnosticFailed("Expected a Complex ACK response");
                    return;
                }
            }
            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...
                throw ex;
            }
            MarkDiagnosticSuccess();
        }