Beispiel #1
0
        public override bool Generate(object outputpath)
        {
            bool   rt     = true;
            string logMsg = "";

            string path = (string)outputpath + "\\Beacon";

            Sys.NewEmptyPath(path);

            if (!Init())
            {
                return(false);
            }

            //generate beacon_name.xml file and refBeaconLst by balise layout file
            int i     = 0;
            int count = sydb.GetBeacons().Count();

            foreach (IBeaconInfo beacon in sydb.GetBeacons())
            {
                TraceMethod.RecordInfo($"Creating message file for {beacon.Info}.");

                //BMGR-0001 generate beacon_name.xml
                string filename = string.Format("{0}\\{1}.xml", path, beacon.Name);

                if (!GenBeaconXMLFile(beacon, filename))
                {
                    logMsg = string.Format("Generate {0}.xml file error!", beacon.Name);
                    TraceMethod.RecordInfo(logMsg);
                    rt = false;
                    continue;
                }

                if (isBGenBin)
                {
                    if (false == GenBeaconBinFile(path, filename, beacon))
                    {
                        logMsg = string.Format("Generate {0}.tgm and udf file error!", beacon.Name);
                        TraceMethod.RecordInfo(logMsg);
                        rt = false;
                        continue;
                    }
                }
                ++i;
                //更新进度条状态 +30 is for the following other steps
                UpdateProgressBar(count + 30, i);
            }

            if (BMGenTest.Program.GenerateTJFormat)//this output file only for user debug, not record in document
            {
                GenTJFormatFileHead(path);
            }

            TraceMethod.RecordInfo("[Steps 4-1]:BMGenTool BFGen end!");
            return(rt);
        }
Beispiel #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);
        }