static void ServiceToBeTested() { // Try to debug the reception of the first frame from the .pcap file // 2nd param is the number of frames (more than 1 in case of segmentation) byte invokeId = SetReplyPackets(@"..\..\ReadPropMultiple.pcap", 1, 0x2e); BacnetPropertyReference[] properties = new BacnetPropertyReference[] { new BacnetPropertyReference((uint)BacnetPropertyIds.PROP_ALL, System.IO.BACnet.Serialize.ASN1.BACNET_ARRAY_ALL) }; IList <BacnetReadAccessResult> multi_value_list; BacnetObjectId BOid = new BacnetObjectId(BacnetObjectTypes.OBJECT_DEVICE, 16); System.Diagnostics.Debugger.Break(); bacnet_client.ReadPropertyMultipleRequest(nowhere, BOid, properties, out multi_value_list, invokeId); // to debug server handle methods, just send any kind of unconfirmed message such as whois }
private void LoadProperties() { RecipientsTab.Controls.Clear(); // Two properties List <BacnetPropertyReference> props = new List <BacnetPropertyReference>(); props.Add(new BacnetPropertyReference((uint)BacnetPropertyIds.PROP_RECIPIENT_LIST, ASN1.BACNET_ARRAY_ALL)); props.Add(new BacnetPropertyReference((uint)BacnetPropertyIds.PROP_PRIORITY, ASN1.BACNET_ARRAY_ALL)); IList <BacnetReadAccessResult> PropertiesValues; comm.ReadPropertyMultipleRequest(adr, object_id, props, out PropertiesValues); foreach (BacnetPropertyValue aProp in PropertiesValues[0].values) { // priorities are common to all recipients if (aProp.property.propertyIdentifier == (uint)BacnetPropertyIds.PROP_PRIORITY) { P_Off.Text = aProp.value[0].Value.ToString(); P_Fault.Text = aProp.value[1].Value.ToString(); P_Normal.Text = aProp.value[2].Value.ToString(); } else { // a TabPage in the TabControl for each recipient for (int i = 0; i < aProp.value.Count / 7; i++) { // convert the List<BacnetValue> into a DeviceReportingRecipient DeviceReportingRecipient recipient = new DeviceReportingRecipient(aProp.value[i * 7], aProp.value[i * 7 + 1], aProp.value[i * 7 + 2], aProp.value[i * 7 + 3], aProp.value[i * 7 + 4], aProp.value[i * 7 + 5], aProp.value[i * 7 + 6]); TabPage NewTab = new System.Windows.Forms.TabPage(); NewTab.Text = NewTab.Name = i.ToString(); // Create a Usercontrol and put it into the TabPage RecipientUserCtrl content = new RecipientUserCtrl(NewTab, recipient); content.DeviceAddrOK += new Action <RecipientUserCtrl, bool>(content_DeviceAddrOK); NewTab.Controls.Add(content); RecipientsTab.Controls.Add(NewTab); labelEmpty.Visible = false; } } } }
/// <summary> /// 扫描设备 /// </summary> public void ScanPointsBatch(BacNode device, uint deviceCount, uint count) { try { if (device == null) { return; } var pid = BacnetPropertyIds.PROP_OBJECT_LIST; var device_id = device.DeviceId; var bobj = new BacnetObjectId(BacnetObjectTypes.OBJECT_DEVICE, device_id); var adr = device.Address; if (adr == null) { return; } device.Properties.Clear(); List <BacnetPropertyReference> rList = new List <BacnetPropertyReference>(); for (uint i = 0; i < count; i++) { rList.Add(new BacnetPropertyReference((uint)pid, i)); if ((i != 0 && i % deviceCount == 0) || i == count - 1)//不要超了 MaxAPDU { IList <BacnetReadAccessResult> lstAccessRst; var bRst = Bacnet_client.ReadPropertyMultipleRequest(adr, bobj, rList, out lstAccessRst, this.GetCurrentInvokeId()); if (bRst) { foreach (var aRst in lstAccessRst) { if (aRst.values == null) { continue; } foreach (var bPValue in aRst.values) { if (bPValue.value == null) { continue; } foreach (var bValue in bPValue.value) { var strBValue = "" + bValue.Value; //Log(pid + " , " + strBValue + " , " + bValue.Tag); var strs = strBValue.Split(':'); if (strs.Length < 2) { continue; } var strType = strs[0]; var strObjId = strs[1]; var subNode = new BacProperty(); BacnetObjectTypes otype; Enum.TryParse(strType, out otype); if (otype == BacnetObjectTypes.OBJECT_NOTIFICATION_CLASS || otype == BacnetObjectTypes.OBJECT_DEVICE) { continue; } subNode.ObjectId = new BacnetObjectId(otype, Convert.ToUInt32(strObjId)); //添加属性 device.Properties.Add(subNode); } } } } rList.Clear(); } } } catch (Exception exp) { Log("Err:" + exp.Message); } }