示例#1
0
        public override void Execute()
        {
            bool someFails = false;

            WaitForQuietOnIncomingPacketQueue();
            ClearIncomingPacketQueue();
            try
            {
                if (this.devicTreeNode.device.adr.directlyConnected == true)
                {
                    MarkDiagnosticWithNote("This node is directly connected. Diagnostic not appropriate");
                    return;
                }
                // todo. the ADR constructor is going to use an IP broadcast. We should know the router for this device and transmit the packet only to that router...
                DADR dadr = new DADR(_bnm, BACnetPacket.ADDRESS_TYPE.REMOTE_BROADCAST, this.devicTreeNode.device.adr.networkNumber);
                BACnetUtil.SendWhoIs(_apm, _bnm, dadr);
                WaitForQuietOnIncomingPacketQueue();
                // check the incoming packets, make sure that they are all from the desired address
                if (_apm.pktQueueToApplication.Count == 0)
                {
                    MarkDiagnosticFailed("No response to the Who-Is");
                    return;
                }
                while (_apm.pktQueueToApplication.Count > 0)
                {
                    //                    BACnetPacket pkt = _apm.pktQueueToApplication.myDequeue();
                    BACnetPacket pkt = waitForPacket(1);
                    if (pkt.srcDevice.adr.networkNumber != this.devicTreeNode.device.adr.networkNumber)
                    {
                        MarkDiagnosticFailed("A device [" + pkt.srcDevice.adr.ToString() + "] from network [" + pkt.srcDevice.adr.networkNumber.ToString() + "] that is not directly connected responded");
                        someFails = true;
                    }
                }
            }
            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;
                //BACnetLibrary.Panic(ex.ToString());
                //return;
            }
            if (!someFails)
            {
                MarkDiagnosticSuccess();             // Mark this diagnostic a success, any failures will re
            }
        }
示例#2
0
        // tests that only local devices answer to local broadcasts. (A type of router test).

        public override void Execute()
        {
            bool someFails = false;

            WaitForQuietOnIncomingPacketQueue();
            ClearIncomingPacketQueue();

            try
            {
                DADR dadr = new DADR(_bnm, BACnetPacket.ADDRESS_TYPE.LOCAL_BROADCAST);
                BACnetUtil.SendWhoIs(_apm, _bnm, dadr);
                // Sleep(1000);        // and perhaps longer on large networks....
                WaitForQuietOnIncomingPacketQueue();

                // check the incoming packets, make sure that they are all local addresses
                while (_apm.pktQueueToApplication.Count > 0)
                {
                    if (_apm.pktQueueToApplication.Count == 0)
                    {
                        // wait just a while longer, there may be more packets dribbling in. So by pausing here
                        // we wait 1 second longer than the last packet to arrive... seems reasonable to me
                        Sleep(1000);
                    }

                    BACnetPacket pkt = _apm.pktQueueToApplication.myDequeue();
                    pkt.DecodeBACnet();

                    if (pkt.srcDevice.adr.directlyConnected != true)
                    {
                        MarkDiagnosticFailed("A device [" + pkt.srcDevice.adr.ToString() + "] that is not directly connected responded");
                        someFails = true;
                    }
                }
            }
            catch (TimeoutException)
            {
                // todo-put a wrapper around execute and catch all executions in a common area..
                MarkDiagnosticFailed("Timeout");
                return;
            }
            if (someFails == false)
            {
                MarkDiagnosticSuccess();                     // Mark this diagnostic a success, any failures will re
            }
        }