Example #1
0
 //BMGR-0045
 private bool GenerateLEUInfoNode(LEU leuInfo, ref XmlVisitor leu)
 {
     leu.UpdateAttribute("ID", leuInfo.ID);
     leu.UpdateAttribute("NAME", leuInfo.Name);
     return(true);
 }
Example #2
0
        /// <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);
        }