static void Main(string[] args) { Console.WriteLine("BBMD Demo Application started on 0xBAC0 Udp port\n\nAll foreign devices accepted (no filtering)\n"); // start the FD acceptation at least if BBMD list is empty or corrupted // and set up the device, see BacnetActivity static constructor BacnetActivity.AddPeerBBMD(null, null); if (BacnetActivity.OpenError == true) { Console.WriteLine("\t Error, certainly due to the Udp Port already in use"); return; } // Set BBMD peers SetBBMDList(); // Update each 10s the second CHARACTERSTRING OBJECT Present Value BacnetObjectId b = new BacnetObjectId(BacnetObjectTypes.OBJECT_CHARACTERSTRING_VALUE, 1); for ( ; ;) { Thread.Sleep(10000); BacnetActivity.SetBacObjectPresentValue(b, new BacnetValue(BacnetActivity.GetFDList())); } }
static void SetBBMDList() { StringBuilder BBMDList = new StringBuilder(); // Read the BBMD Peer List from the Config.txt file try { StreamReader sr = new StreamReader("Config.txt"); while (!sr.EndOfStream) { String l = sr.ReadLine(); if ((l.Length != 0) && (l[0] != '/')) { String[] Param = l.Split(';'); BacnetActivity.AddPeerBBMD(new IPEndPoint(IPAddress.Parse(Param[0]), Convert.ToInt32(Param[2])), IPAddress.Parse(Param[1])); BBMDList.Append(Param[0] + ":" + Param[2] + ";"); Console.WriteLine("\tWorking with peer BBMD : {0}:{1}", Param[0], Param[2]); } } sr.Close(); } catch { } // Update the first CHARACTERSTRING OBJECT Present Value BacnetObjectId b = new BacnetObjectId(BacnetObjectTypes.OBJECT_CHARACTERSTRING_VALUE, 0); BacnetActivity.SetBacObjectPresentValue(b, new BacnetValue(BBMDList.ToString())); }