public override void Execute() { try { // basic test, interrogate router for Routing Table, check the Port IDs BACnetUtil.SendInitRoutingTable(_apm, _bnm, new DADR(devicTreeNode.device.adr)); BACnetPacket incomingPkt = waitForPacket(5000, BACnetEnums.BACNET_NETWORK_MESSAGE_TYPE.NETWORK_MESSAGE_INIT_RT_TABLE_ACK); foreach (RoutingTableEntry rte in incomingPkt.routerTableList) { if (rte.portID == 0) { // fails //Console.WriteLine("Illegal Port ID " + rte.ToString()); // Need to mark diagnostic as failed, with a comment MarkDiagnosticFailed("Port ID found to be out of range: " + rte.ToString()); return; } } } catch (TimeoutException) { // todo-put a wrapper around execute and catch all executions in a common area.. MarkDiagnosticFailed("Timeout"); return; } MarkDiagnosticSuccess(); }
// Notes: This test may timeout on devices the other side of routers due to insufficiencies in the router itself. Be aware of this for // now, and make changes to isolate and not report these cases. public override void Execute() { // If the device is the other side of a router, do not execute this test on it. //if (!deviceNode.device.adr.directlyConnected) //{ // MarkDiagnosticWithNote("This device is the other side of a Router, cannot complete this test"); // return; //} int receiveCount = 0; ClearIncomingPacketQueue(); try { int tries = 3; for (int i = 0; i < tries; i++) { BACnetUtil.SendWhoIs(_apm, _bnm, devicTreeNode.device); Sleep(10); // without a little sleep, it seems that the first few packets out the ports may stumble } for (int i = 0; i < tries; i++) { if (devicTreeNode.device.adr.directlyConnected == true) { waitForPacket(1000); // todo set the IAM field in waitforpacket } else { waitForPacket(5000); } receiveCount++; } } catch (TimeoutException) { // todo-put a wrapper around execute and catch all executions in a common area.. if (receiveCount > 0) { // got at least one message. if (!devicTreeNode.device.adr.directlyConnected) { // and device is the other side of a router. We can be a bit forgiving here - some routers dont queue the messages. MarkDiagnosticWithNote("This device failed to respond to all three messages, but it did respond to at least one"); MarkDiagnosticWithNote(" - and it is the other side of a router, so the failure may be due to the router in the way"); return; } } MarkDiagnosticFailed("Timeout"); return; } catch (Exception ex) { // other types of exception... throw ex; } MarkDiagnosticSuccess(); }
public override void Execute() { _apm.MessageLog("Executing " + diagnosticName); bool foundFlag = false; try { BACnetPacket resp; BACnetPacket pkt = new BACnetPacket(this._apm); pkt.EncodeNPCI(new DADR(), BACnetPacket.MESSAGE_TYPE.APPLICATION); pkt.EncodeAPDUheader(BACnetEnums.BACNET_PDU_TYPE.PDU_TYPE_UNCONFIRMED_SERVICE_REQUEST, BACnetEnums.BACNET_UNCONFIRMED_SERVICE.SERVICE_UNCONFIRMED_WHO_IS); pkt.EncodeContextTag(0, (int)devicTreeNode.device.deviceObjectID.objectInstance); pkt.EncodeContextTag(1, (int)devicTreeNode.device.deviceObjectID.objectInstance); BACnetUtil.SendOffPacket(_apm, _bnm, pkt, pkt.buffer, pkt.optr); // wait for _our_ device to respond do { try { // We expect to timeout resp = waitForPacket(5000, BACnetEnums.BACNET_UNCONFIRMED_SERVICE.SERVICE_UNCONFIRMED_I_AM); if (resp.srcDevice.deviceObjectID.Equals(devicTreeNode.device.deviceObjectID)) { foundFlag = true; } else { Sleep(5000); ClearIncomingPacketQueue(); MarkDiagnosticFailed(); return; } } catch (TimeoutException) { // remember we expect to time out if (foundFlag == true) { MarkDiagnosticSuccess(); return; } else { MarkDiagnosticFailed(); return; } } }while (true); } catch (Exception ex) { // other types of exception... _apm.MessagePanic(ex.ToString()); return; } }
public override void Execute() { try { ClearIncomingPacketQueue(); BACnetPacket pkt = new BACnetPacket(_apm, BACnetEnums.BACNET_CONFIRMED_SERVICE.SERVICE_CONFIRMED_READ_PROPERTY); pkt.dAdr = new DADR(this.device.adr); pkt.EncodeNPCI(pkt.dAdr, BACnetPacket.MESSAGE_TYPE.APPLICATION); pkt.EncodeAPDUheader(BACnetEnums.BACNET_CONFIRMED_SERVICE.SERVICE_CONFIRMED_READ_PROPERTY); // Encode the rest of the packet according to http://www.bacnetwiki.com/wiki/index.php?title=Read_Property pkt.EncodeContextTag(0, this.device.deviceObjectID); pkt.EncodeContextTag(1, BACnetEnums.BACNET_PROPERTY_ID.PROP_OBJECT_TYPE); pkt.EncodeContextTag(1, BACnetEnums.BACNET_PROPERTY_ID.PROP_OBJECT_IDENTIFIER); BACnetUtil.SendOffPacket(this._apm, this._bnm, pkt, pkt.buffer, pkt.optr); BACnetPacket 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_REJECT) { if (respPkt.pduRejectReason == BACnetEnums.BACNET_BACNET_REJECT_REASON.REJECT_REASON_TOO_MANY_ARGUMENTS || respPkt.pduRejectReason == BACnetEnums.BACNET_BACNET_REJECT_REASON.REJECT_REASON_INVALID_TAG) { MarkDiagnosticSuccess(); return; } else { MarkDiagnosticFailed("Reject PDU OK, but reason not OK"); return; } } else { MarkDiagnosticFailed("Reject PDU expected"); 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; //BACnetLibrary.Panic(ex.ToString()); //return; } }
public override void Execute() { try { ClearIncomingPacketQueue(); BACnetPacket pkt = new BACnetPacket(_apm, BACnetEnums.BACNET_CONFIRMED_SERVICE.SERVICE_CONFIRMED_READ_PROPERTY); pkt.dAdr = new DADR(this.device.adr); pkt.EncodeNPCI(pkt.dAdr, BACnetPacket.MESSAGE_TYPE.APPLICATION); pkt.EncodeAPDUheader(BACnetEnums.BACNET_CONFIRMED_SERVICE.SERVICE_CONFIRMED_READ_PROPERTY); // Encode the rest of the packet according to http://www.bacnetwiki.com/wiki/index.php?title=Read_Property pkt.EncodeContextTag(0, this.device.deviceObjectID); pkt.EncodeContextTag(1, BACnetEnums.BACNET_PROPERTY_ID.PROP_OBJECT_TYPE); // Now, by definition, there can only be one device instance. Try and read the 3rd. If the device responds with anything but an error, it fails pkt.EncodeContextTag(2, 3); BACnetUtil.SendOffPacket(this._apm, this._bnm, pkt, pkt.buffer, pkt.optr); BACnetPacket 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_ERROR) { if (respPkt.errorClass == (int)BACnetEnums.BACNET_ERROR_CLASS.ERROR_CLASS_PROPERTY && respPkt.errorCode == (int)BACnetEnums.BACNET_ERROR_CODE.ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY) { MarkDiagnosticSuccess(); return; } else { MarkDiagnosticFailed("Error PDU OK, but error class or error code not OK"); return; } } else { MarkDiagnosticFailed("Error PDU expected"); 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; } }
public override void Execute() { try { _apm.MessageLog("Executing " + diagnosticName); ClearIncomingPacketQueue(); // find a non-existing network number in the whole attached BACnet internetwork by examining our internal router table that // has been built up during device discovery phase int useThisNetworkNumber = 9; for (int i = 0xfffe; i > 1; i--) { if (_apm.internalRouterInfo.FindRoutingTableEntry(i) == null) { // we have not seen or used this network number yet useThisNetworkNumber = i; break; } } // BACnetUtil.SendReadProperty(_apm, _bnm, deviceNode.device, deviceNode.device.deviceObjectID, BACnetEnums.BACNET_PROPERTY_ID.PROP_OBJECT_TYPE); BACnetPacket pkt = new BACnetPacket(_apm); // pkt.EncodeBVLL(new DADR(deviceNode.device.adr), BACnetEnums.BACNET_BVLC_FUNCTION.BVLC_ORIGINAL_UNICAST_NPDU); pkt.EncodeNPCI(new DADR(devicTreeNode.device.adr), new ADR((ushort)useThisNetworkNumber, (uint)3), BACnetLibrary.BACnetPacket.MESSAGE_TYPE.APPLICATION); // todonow, put these next steps into functions // build confirmed request header // http://www.bacnetwiki.com/wiki/index.php?title=BACnet-Confirmed-Request-PDU pkt.buffer[pkt.optr++] = (Byte)BACnetEnums.BACNET_PDU_TYPE.PDU_TYPE_CONFIRMED_SERVICE_REQUEST; pkt.buffer[pkt.optr++] = 0x05; // max segs, max resp. todo pkt.buffer[pkt.optr++] = _apm.invokeID++; // sequence number may come next, dep on flags. todo pkt.buffer[pkt.optr++] = (byte)BACnetEnums.BACNET_CONFIRMED_SERVICE.SERVICE_CONFIRMED_READ_PROPERTY; // context encoding // http://www.bacnetwiki.com/wiki/index.php?title=Read_Property devicTreeNode.device.deviceObjectID.Encode(pkt.buffer, ref pkt.optr); BACnetUtil.EncodeContextTag(pkt.buffer, ref pkt.optr, 1, (int)BACnetEnums.BACNET_PROPERTY_ID.PROP_OBJECT_TYPE); BACnetUtil.SendOffPacket(_apm, _bnm, pkt, pkt.buffer, pkt.optr); BACnetPacket respPkt = waitForPacket(5000); } 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(); }
private void buttonWhoIsLongMAC_Click(object sender, EventArgs e) { // BTL Implementation Guide, Section 2.9 - be prepared to accept a MAC address up to 18 bytes long. Here is the test. I have not found any device that passes this yet. BACnetPacket pkt = new BACnetPacket(_apm); pkt.EncodeBVLL(BACnetEnums.BACNET_BVLC_FUNCTION.BVLC_ORIGINAL_BROADCAST_NPDU); pkt.EncodeNPCI(new DADR(BACnetPacket.ADDRESS_TYPE.GLOBAL_BROADCAST), new ADR(3333, "0102030405060708"), BACnetLibrary.BACnetPacket.MESSAGE_TYPE.APPLICATION); pkt.EncodeAPDUheader(BACnetEnums.BACNET_PDU_TYPE.PDU_TYPE_UNCONFIRMED_SERVICE_REQUEST, BACnetEnums.BACNET_UNCONFIRMED_SERVICE.SERVICE_UNCONFIRMED_WHO_IS); BACnetUtil.SendOffPacket(_apm, _bnm, pkt, pkt.buffer, pkt.optr); }
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 } }
public override void Execute() { bool someFails = false; WaitForQuietOnIncomingPacketQueue(); ClearIncomingPacketQueue(); try { if (this.devicTreeNode.device.adr.directlyConnected == true) { MarkDiagnosticWithNote("This node needs to be directly connected for this Diagnostic. 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... BACnetUtil.SendWhoIsRouter(_apm, _bnm, BACnetPacket.ADDRESS_TYPE.LOCAL_BROADCAST); WaitForQuietOnIncomingPacketQueue(); // check the incoming packets, make sure that they are all from local addresses if (_apm.pktQueueToApplication.Count == 0) { MarkDiagnosticFailed("No response to the Who-Is-Router"); return; } while (_apm.pktQueueToApplication.Count > 0) { BACnetPacket pkt = waitForPacket(1); if (!pkt.dAdr.isLocalBroadcast) { MarkDiagnosticFailed("A Router [" + pkt.srcDevice.adr.ToString() + "] did not use a local broadcast"); someFails = true; } } } catch (TimeoutException) { // todo-put a wrapper around execute and catch all executions in a common area.. MarkDiagnosticFailed("Timeout"); return; } catch (Exception ex) { throw ex; } if (!someFails) { MarkDiagnosticSuccess(); // Mark this diagnostic a success, any failures will re } }
// 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 } }
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; } }
public override void Execute() { _apm.MessageLog("Executing " + diagnosticName); try { BACnetPacket resp; BACnetPacket pkt = new BACnetPacket(this._apm); pkt.EncodeNPCI(new DADR(), BACnetPacket.MESSAGE_TYPE.APPLICATION); pkt.EncodeAPDUheader(BACnetEnums.BACNET_PDU_TYPE.PDU_TYPE_UNCONFIRMED_SERVICE_REQUEST, BACnetEnums.BACNET_UNCONFIRMED_SERVICE.SERVICE_UNCONFIRMED_WHO_IS); pkt.EncodeContextTag(0, 0); pkt.EncodeContextTag(1, BACnetEnums.BACNET_MAX_INSTANCE); BACnetUtil.SendOffPacket(_apm, _bnm, pkt, pkt.buffer, pkt.optr); // wait for _our_ device to respond do { resp = waitForPacket(5000, BACnetEnums.BACNET_UNCONFIRMED_SERVICE.SERVICE_UNCONFIRMED_I_AM); if (resp.srcDevice.deviceObjectID.Equals(devicTreeNode.device.deviceObjectID)) { Sleep(5000); ClearIncomingPacketQueue(); MarkDiagnosticSuccess(); return; } }while (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... _apm.MessagePanic(ex.ToString()); return; } }
public override void Execute() { _apm.MessageLog("Executing " + diagnosticName); try { ClearIncomingPacketQueue(); BACnetPacket pkt = new BACnetPacket(this._apm); pkt.EncodeNPCI(new DADR(), BACnetPacket.MESSAGE_TYPE.APPLICATION); pkt.EncodeAPDUheader(BACnetEnums.BACNET_PDU_TYPE.PDU_TYPE_UNCONFIRMED_SERVICE_REQUEST, BACnetEnums.BACNET_UNCONFIRMED_SERVICE.SERVICE_UNCONFIRMED_WHO_IS); pkt.EncodeContextTag(0, (int)devicTreeNode.device.deviceObjectID.objectInstance); // Ha! Notice we did not encode the second part of the who-is. Devices should not respond. BACnetUtil.SendOffPacket(_apm, _bnm, pkt, pkt.buffer, pkt.optr); // wait for _our_ device to respond while (true) { try { // We expect to timeout waitForPacket(5000, BACnetEnums.BACNET_UNCONFIRMED_SERVICE.SERVICE_UNCONFIRMED_I_AM); ClearIncomingPacketQueue(); MarkDiagnosticFailed("There should be NO response from the device"); return; } catch (TimeoutException) { // remember we expect to time out MarkDiagnosticSuccess(); return; } } } catch (Exception ex) { // other types of exception... _apm.MessagePanic(ex.ToString()); return; } }
public override void Execute() { try { ClearIncomingPacketQueue(); BACnetUtil.SendReadProtocolServices(_apm, _bnm, devicTreeNode.device); waitForPacket(5000); } 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; } MarkDiagnosticSuccess(); }
private void SendWhoIsButton(object sender, EventArgs e) { BACnetUtil.SendWhoIs(_apm, _bnm, BACnetPacket.ADDRESS_TYPE.GLOBAL_BROADCAST); }
public override void Execute() { BACnetPacket incomingPkt; //if (!(deviceNode.device.GetType() == typeof(Router))) //{ // MarkDiagnosticWithNote("Device is not a router, cannot run this test"); // return; //} // todo, block this queue unless a diagnostic is running // clear the queue ClearIncomingPacketQueue(); try { BACnetUtil.SendInitRoutingTable(_apm, _bnm, new DADR(devicTreeNode.device.adr)); incomingPkt = waitForPacket(5000, BACnetEnums.BACNET_NETWORK_MESSAGE_TYPE.NETWORK_MESSAGE_INIT_RT_TABLE_ACK); // todo, add fromaddress... // got it. foreach (RoutingTableEntry rte in incomingPkt.routerTableList) { Console.WriteLine(rte.ToString()); } // record the number of entries, and record the last item int entrycount = incomingPkt.routerTableList.Count; if (entrycount < 1 || entrycount > 255) { Console.WriteLine("Failed this time around"); // test fails, impossible count return; //throw new Exception("m0525-Totally bogus router table entry count"); } RoutingTableEntry rtDupe = incomingPkt.routerTableList[entrycount - 1]; // now write the last entry again. BACnetPacket outgoingPkt = new BACnetPacket(_apm, BACnetEnums.BACNET_NETWORK_MESSAGE_TYPE.NETWORK_MESSAGE_INIT_RT_TABLE); outgoingPkt.SetDestination(new DADR(incomingPkt.srcDevice.adr)); outgoingPkt.routerTableList = new List <RoutingTableEntry>(); outgoingPkt.routerTableList.Add(rtDupe); outgoingPkt.EncodeBACnet(); _bnm.insideSocket.OurSendTo(outgoingPkt.buffer, outgoingPkt.optr, incomingPkt.srcDevice.adr.ResolvedIPEP()); // wait for the ack incomingPkt = waitForPacket(5000, BACnetEnums.BACNET_NETWORK_MESSAGE_TYPE.NETWORK_MESSAGE_INIT_RT_TABLE_ACK); // drop the packet // re-read the routing table BACnetUtil.SendInitRoutingTable(_apm, _bnm, new DADR(devicTreeNode.device.adr)); incomingPkt = waitForPacket(5000, BACnetEnums.BACNET_NETWORK_MESSAGE_TYPE.NETWORK_MESSAGE_INIT_RT_TABLE_ACK); foreach (RoutingTableEntry rte in incomingPkt.routerTableList) { Console.WriteLine(rte.ToString()); } // record the number of entries, and record the last item if (incomingPkt.routerTableList.Count != entrycount) { Console.WriteLine("m0165-Failed entrycount"); // Todo, check if this _IS_ OK. MarkDiagnosticFailed("The entrycount did not remain the same, i.e. The router allowed the addition of a duplicate Network Number"); 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; //BACnetLibrary.Panic(ex.ToString()); //return; } MarkDiagnosticSuccess(); Console.WriteLine("Diag done"); }
private void buttonSendIAm_Click(object sender, EventArgs e) { BACnetUtil.SendIAm(_apm, _bnm, BACnetPacket.ADDRESS_TYPE.GLOBAL_BROADCAST, (uint)Convert.ToDecimal(textBoxDeviceInstance.Text)); }
public override void Execute() { BACnetUtil.SendWhoIs(_apm, _bnm, BACnetPacket.ADDRESS_TYPE.LOCAL_BROADCAST); MarkDiagnosticSuccess(); }
public override void Execute() { try { List <BACnetEnums.BACNET_PROPERTY_ID> propList = new List <BACnetEnums.BACNET_PROPERTY_ID>(new BACnetEnums.BACNET_PROPERTY_ID[] { BACnetEnums.BACNET_PROPERTY_ID.PROP_OBJECT_IDENTIFIER, BACnetEnums.BACNET_PROPERTY_ID.PROP_OBJECT_NAME, BACnetEnums.BACNET_PROPERTY_ID.PROP_OBJECT_TYPE, BACnetEnums.BACNET_PROPERTY_ID.PROP_SYSTEM_STATUS, BACnetEnums.BACNET_PROPERTY_ID.PROP_VENDOR_NAME, BACnetEnums.BACNET_PROPERTY_ID.PROP_VENDOR_IDENTIFIER, BACnetEnums.BACNET_PROPERTY_ID.PROP_MODEL_NAME, BACnetEnums.BACNET_PROPERTY_ID.PROP_FIRMWARE_REVISION, BACnetEnums.BACNET_PROPERTY_ID.PROP_APPLICATION_SOFTWARE_VERSION, BACnetEnums.BACNET_PROPERTY_ID.PROP_PROTOCOL_VERSION, BACnetEnums.BACNET_PROPERTY_ID.PROP_PROTOCOL_REVISION, BACnetEnums.BACNET_PROPERTY_ID.PROP_PROTOCOL_SERVICES_SUPPORTED, BACnetEnums.BACNET_PROPERTY_ID.PROP_PROTOCOL_OBJECT_TYPES_SUPPORTED, BACnetEnums.BACNET_PROPERTY_ID.PROP_OBJECT_LIST, BACnetEnums.BACNET_PROPERTY_ID.PROP_MAX_APDU_LENGTH_ACCEPTED, BACnetEnums.BACNET_PROPERTY_ID.PROP_SEGMENTATION_SUPPORTED, BACnetEnums.BACNET_PROPERTY_ID.PROP_APDU_TIMEOUT, BACnetEnums.BACNET_PROPERTY_ID.PROP_NUMBER_OF_APDU_RETRIES, // todo, only mstp BACnetEnums.BACNET_PROPERTY_ID.PROP_MAX_MASTER, // todo, only mstp BACnetEnums.BACNET_PROPERTY_ID.PROP_MAX_INFO_FRAMES, BACnetEnums.BACNET_PROPERTY_ID.PROP_DEVICE_ADDRESS_BINDING, BACnetEnums.BACNET_PROPERTY_ID.PROP_DATABASE_REVISION }); foreach (BACnetEnums.BACNET_PROPERTY_ID pid in propList) { ClearIncomingPacketQueue(); BACnetPacket pkt = new BACnetPacket(_apm, BACnetEnums.BACNET_CONFIRMED_SERVICE.SERVICE_CONFIRMED_READ_PROPERTY); pkt.dAdr = new DADR(this.device.adr); pkt.EncodeNPCI(pkt.dAdr, BACnetPacket.MESSAGE_TYPE.APPLICATION); pkt.EncodeAPDUheader(BACnetEnums.BACNET_CONFIRMED_SERVICE.SERVICE_CONFIRMED_READ_PROPERTY); // Encode the rest of the packet according to http://www.bacnetwiki.com/wiki/index.php?title=Read_Property pkt.EncodeContextTag(0, this.device.deviceObjectID); pkt.EncodeContextTag(1, pid); BACnetUtil.SendOffPacket(this._apm, this._bnm, pkt, pkt.buffer, pkt.optr); BACnetPacket 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 if (respPkt.invokeID + 1 != _apm.invokeID) { MarkDiagnosticFailed("Bad Invoke ID in the response"); return; } if (respPkt.propertyID != pid) { MarkDiagnosticFailed("Bad Property in the response"); 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(); }