private void setValue(int lID, IBeaconInfo layout) { lineID = lID; beaconID = layout.ID; isVB = layout.IsVariantBeacon(); version = layout.getVersion(); }
/// <summary> /// check the lineid bid bversionid in default message of FB and VB /// </summary> /// <param name="b"></param> /// <param name="msg"></param> /// <param name="lineid"></param> public static void checkbeaconmessage(IBeaconInfo b, string msg, int lineid) { string pattern = ""; if (false == b.IsVariantBeacon()) { pattern = @"90 00 7F([0-9a-fA-F\s]*)B 10 18 32 ([0-9a-fA-F\s]*)F FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FC"; } else { pattern = @"90 00 7E([0-9a-fA-F\s]*)B 10 18 32 ([0-9a-fA-F\s]*)B 10 3E 32 C0 00 08 00 00 40 00 00 00 00 00 03 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FC"; } //Assert Match match = Regex.Match(msg, pattern); Debug.Assert(match.Groups.Count == 3); Debug.Assert(lineid == (int)getInt64inhex(match.Groups[1].ToString(), 0x007FE0000, 17)); Debug.Assert(b.ID == (int)getInt64inhex(match.Groups[1].ToString(), 0x00001FFF8, 3)); Debug.Assert(b.getVersion() == (int)getInt64inhex(match.Groups[2].ToString(), 0x003FFFC, 2)); }
/// <summary> /// in this function will check and load beacon info from sydb.IBBM /// all LEU and Beacon from sydb.IBBM will be generate in this function /// </summary> /// <returns></returns> private bool GenrateDeviceByIBBM() { bool rt = true; //BMGR-0016 LEUID start from 1 int LEUID = 1; //clear leu and beacon before add new data to them LEUList.Clear(); beaconList.Clear(); int IsAddBeacon; List <IBeaconInfo> list1 = sydb.GetBeacons(); // newly added to avoid outputting the same ID and name repeatedly //List<string> ibbmBeaconList = (from ibbmBeacon in sydb.ibbmInfoList select ibbmBeacon.Name); foreach (GENERIC_SYSTEM_PARAMETERS.IMPLEMENTATION_BEACON_BLOCK_MODE.BM_BEACON ibbm in sydb.ibbmInfoList)//search sydb.ibbm, LEUID should be same with this order { //IBeaconInfo layout = sydb.GetBeacons().Find(x => x.Name == ibbm.Name); // This line will repeat the output ID and Name IBeaconInfo layout = list1.Find(x => x.Name == ibbm.Name); //judge the beacon first, if this beacon is not exist in Beacons, then ignore this beacon and LEU if (null == layout) { TraceMethod.Record(TraceMethod.TraceKind.WARNING, $"Beacon[{ibbm.Name}] exist in Implementation_Beacon_Block_Mode but not exist in Beacons."); continue; } if (false == layout.IsVariantBeacon()) { TraceMethod.Record(TraceMethod.TraceKind.WARNING, $"Beacon[{ibbm.Name}] exist in Implementation_Beacon_Block_Mode but is Fixed Beacon."); continue; } BEACON newbeacon = new BEACON(layout, ibbm); beaconList.Add(newbeacon); if (newbeacon.m_Type == "Invalid") { continue; } int LEUidx = LEUList.FindIndex(x => x.Name == ibbm.LEU.LEU_Name); if (-1 == LEUidx)//if the LEU not exist, then create a new one { //BMGR-0016 set LEUID for each new LEU in IBBM order LEU newLEU = new LEU(ibbm.LEU.LEU_Name, LEUID, ibbm.CI_Name); ++LEUID;//LEU ID start from 1, add 1 for each diff one LEUList.Add(newLEU); LEUidx = LEUList.Count() - 1; } { //check LEU.BeaconOutNum IsAddBeacon = LEUList[LEUidx].AddBeacon(ibbm.LEU.Beacon_Output_number, ibbm.Name); //if (false == LEUList[LEUidx].AddBeacon(ibbm.LEU.Beacon_Output_number, ibbm.Name)) if (-1 == IsAddBeacon) { LEUList.RemoveAt(LEUidx); // new add to remove error LEU --LEUID; continue; } else if (-2 == IsAddBeacon) { //LEUList.RemoveAt(LEUidx); // new add to remove error LEU //--LEUID; TraceMethod.Record(TraceMethod.TraceKind.WARNING, $"Beacon {ibbm.Info} will link to LEU {ibbm.LEU.Info} faild."); } } //BEACON newbeacon = new BEACON(layout, ibbm); //beaconList.Add(newbeacon); //if (newbeacon.m_Type == "Invalid") //{ // continue; //} } if (null == beaconList || beaconList.Count() <= 0) { TraceMethod.Record(TraceMethod.TraceKind.ERROR, "GenrateDeviceByIBBM, after check IBBM and Beacons, no valid beacon can used to generate data"); return(false); } //check if exist variant beacon which in beacons but not in Implementation_Beacon_Block_Mode //foreach (IBeaconInfo beacon in sydb.GetBeacons()) foreach (IBeaconInfo beacon in list1) { if (true == beacon.IsVariantBeacon()) { int Bidx = beaconList.FindIndex(x => x.Name == beacon.Name); if (-1 == Bidx) { TraceMethod.Record(TraceMethod.TraceKind.WARNING, $"{beacon.Info} can't get vaild info from sydb.IBBM. BMVF file will generate no info for this beacon"); continue; } } } LEUList.ForEach(delegate(LEU name) // print LEU { Console.WriteLine(name.Name); }); return(rt); }