//in this func use class member BFGen.isITC private bool GenBeaconXMLFile(IBeaconInfo beacon, string filename) { Balise xmlFile = new Balise(); //BMGR-0002 xmlFile.name = new StringData(beacon.Name); //BMGR-0003 xmlFile.Telegram.type = new StringData("LONG"); //Telegram get if (isITC) {//BMGR-0004 TraceMethod.RecordInfo("error:iTC not support now!"); xmlFile.Telegram.Value = new StringData("iTC not support"); } else { BeaconMessage bm = new BeaconMessage(); xmlFile.Telegram.Value = new StringData(bm.GenerateMessage(beacon, sydb.LineID)); } FileSerializer.Serialize(xmlFile, filename, AddLogHead()); return(true); }
private void Watcher_Received(BluetoothLEAdvertisementWatcher sender, BluetoothLEAdvertisementReceivedEventArgs args) { try { foreach (var beacon in BeaconsList) { if (beacon.BeaconType != Beacon.BeaconTypeEnum.Unknown) { BeaconMessage bm = new BeaconMessage(beacon); if (Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Mobile") { bm.Device = "NL635Gk_8"; } else { bm.Device = "GorkmaSP3"; } _azureEventHubService.SendMessage(JsonConvert.SerializeObject(bm)); if (SelectedBeacon == beacon) { SelectedBeaconMessage = bm; } } else if (SelectedBeacon == beacon) { SelectedBeaconMessage = null; } } } catch (Exception) { // Sometimes the collection changes while getting through the foreach loop } }
private void GenTJFormatFileHead(string path) { string logMsg = ""; XmlVisitor allFileRoot = null; string filename = string.Format("{0}\\all_beacons.xml", path); XmlFileHelper allxmlFile = XmlFileHelper.CreateFromString(null); AddLogHead(ref allxmlFile); allxmlFile.SetRoot("Beacons", null); allxmlFile.Save2File(filename); allFileRoot = allxmlFile.GetRoot(); allFileRoot.UpdateAttribute("NUMBERS", sydb.GetBeacons().Count()); foreach (IBeaconInfo beacon in sydb.GetBeacons()) { string telValue = ""; if (isITC) {//BMGR-0004 TraceMethod.RecordInfo("iTC not support now!"); telValue = "iTC not support"; } else { BeaconMessage bm = new BeaconMessage(); telValue = bm.GenerateMessage(beacon, sydb.LineID); } byte[] urstel = DataOpr.String2byte(telValue); XmlVisitor beaconNode = XmlVisitor.Create("Beacon", null); beaconNode.UpdateAttribute("ID", beacon.ID); beaconNode.UpdateAttribute("NAME", beacon.Name); byte[] content = new byte[128]; bool result = DataOpr.PackCallScram_Tel(urstel, content); if (result) { string tel1 = DataOpr.Byte2string(content); beaconNode.AppendChild("Telegram0", telValue); beaconNode.AppendChild("Telegram1", tel1); } else { logMsg = string.Format("Encoding Error!"); TraceMethod.RecordInfo(logMsg); continue; } allFileRoot.AppendChild(beaconNode); } allxmlFile.Save2File(filename); logMsg = "Generate basic_beacons.xml file successfully!"; TraceMethod.RecordInfo(logMsg); }
private bool GenerateLEUResultFilterFile(string filename) { XmlFileHelper xmlFile = XmlFileHelper.CreateFromString(null); AddLogHead(ref xmlFile); //BMGR-0044 xmlFile.SetRoot("LEU_filtered_values", null); xmlFile.Save2File(filename); XmlVisitor root = xmlFile.GetRoot(); //BMGR-0044 root.UpdateAttribute("LINE_ID", sydb.LineID); //BMGR-0045 List <LEU> orderLEULst = m_LEULst.OrderBy(o => o.ID).ToList(); foreach (LEU leu in orderLEULst) { XmlVisitor LEUnode = XmlVisitor.Create("LEU", null); //set LEU info if (false == GenerateLEUInfoNode(leu, ref LEUnode)) { return(false); } string[] bNames = leu.GetBeaconNames(); //BMGR-0046 for (int i = 0; i < bNames.Count(); ++i) { string bName = bNames[i]; if ("" == bName) { continue; } int Bidx = m_BeaconLst.FindIndex(x => (x.Name == bName)); if (-1 == Bidx) { TraceMethod.RecordInfo($"Warning:LEU[{leu.Name}] contain beacon[{bName}] which not in valid beacon List, this beacon will be ignore!"); continue; } XmlVisitor beaconnode = XmlVisitor.Create("Beacon", null); if (false == GenerateBeaconInfoNode(m_BeaconLst[Bidx], ref beaconnode, i + 1)) { // } m_BeaconLst[Bidx].m_MsgLst = GenerateMessage(m_BeaconLst[Bidx]); if (m_BeaconLst[Bidx].m_MsgLst.Count() > 128) {//BMGR-0050 TraceMethod.RecordInfo($"LEU[{leu.Info} {m_BeaconLst[Bidx].Info}] generate messages {m_BeaconLst[Bidx].m_MsgLst.Count()} > 128"); } foreach (Message msg in m_BeaconLst[Bidx].m_MsgLst) { //mes and combine_sections XmlVisitor msgNode = msg.GetXmlNode(); //BMGR-0051 Variant_state string varstate = GetMsgVar(msg, m_BeaconLst[Bidx]); if (BEACON.MAXVARNUM != varstate.Length) { TraceMethod.RecordInfo($"Beacon[{m_BeaconLst[Bidx].Name}] Variant_state[{varstate}] length != {BEACON.MAXVARNUM}"); } msgNode.AppendChild("Variant_state", varstate); string msgBuff = ""; //Urbalis_iTC if (0 == msg.GetRank()) {//BMGR-0004 leu default msg for input beacon varstate = ""; } //don't output Urbalis_iTC for BMGen tool this time #if itcsupport msgBuff = m_BeaconLst[Bidx].GenMsgItc(varstate); if (86 != msgBuff.Length) { TraceMethod.RecordInfo(string.Format("Beacon[{0}] Urbalis_iTC message length != 16", m_BeaconLst[Bidx].Name)); return(false); } msgNode.AppendChild("Urbalis_iTC", msgBuff); #endif //Interoperable BeaconMessage bm = new BeaconMessage(); msgBuff = bm.GenerateMessage(m_BeaconLst[Bidx], sydb.LineID, msg); if (311 != msgBuff.Length) { TraceMethod.RecordInfo($"{m_BeaconLst[Bidx].Info} Interoperable message length != 311"); } msgNode.AppendChild("Interoperable", msgBuff); beaconnode.AppendChild(msgNode); } LEUnode.AppendChild(beaconnode); } root.AppendChild(LEUnode); } xmlFile.Save2File(filename); return(true); }