コード例 #1
0
        private bool GenLEUGlobalFile(LEURF leurf, LEUGlobal leugb, GID gid, string filename)
        {
            try
            {
                XmlFileHelper xmlFile = XmlFileHelper.CreateFromString(null);
                //根据LEU Result Filtered Values文件的内容修改可变部分的值
                leugb.leuName      = leurf.leuName;
                leugb.inBoard.gid  = gid.ibGid;
                leugb.outBoard.gid = gid.ouGid;
                //5.2.1生成Output_balise,TBD
                foreach (LEUBeacon beacon in leurf.beaconList)
                {
                    OutBalise ob = new OutBalise();
                    ob.id       = beacon.outNum;
                    ob.telegram = "LONG";

                    leugb.obList.Add(ob);
                }
                leugb.encoder.netGid = gid.netGid;

                //根据模板文件格式写入LEU文件
                XmlVisitor leuNode = leugb.Write();
                xmlFile.SetRoot(leuNode);
                xmlFile.Save2File(filename);
                return(true);
            }
            catch (System.Exception ex)
            {
                return(false);
            }
        }
コード例 #2
0
        public void Generate(object output)
        {
            string outputpath = (string)output;
            string path       = "";

            if (Option.BEACON == option)
            {
                //chapter 3
                path = outputpath + "\\Beacon";
                if (!Directory.Exists(path))
                {
                    DirectoryInfo di = new DirectoryInfo(path);
                    di.Create();
                }
                //生成beacon_name.xml文件
                for (int i = 0; i < BeaconInfoList.Count; i++)
                {
                    BeaconLayout beacon = BeaconInfoList[i];
                    logMsg = string.Format("Generating {0}.xml and bin files......", beacon.Name);
                    WriteLog(logMsg, LogManager.Level.Info);
                    //生成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);
                        WriteLog(logMsg, LogManager.Level.Error);
                        continue;
                    }

                    //调用beacon compiler生成.udf和.tgm
                    Process p = new Process();
                    p.StartInfo.FileName = this.balComPath;
                    if (isITC)
                    {
                        p.StartInfo.Arguments = string.Format("{0} -o {1} -udf -telformat sacem", filename, path);
                    }
                    else
                    {
                        p.StartInfo.Arguments = string.Format("{0} -o {1} -udf -telformat udf", filename, path);
                    }
                    p.StartInfo.CreateNoWindow  = true;
                    p.StartInfo.UseShellExecute = false;
                    p.Start();
                    p.WaitForExit();
                    p.Close();

                    //更新进度条状态
                    if (genPro != null)
                    {
                        genPro(BeaconInfoList.Count, i + 1);
                    }
                }
            }
            else if (Option.BMV == option)
            {
                //chapter 4
                path = outputpath + "\\BMV";
                if (!Directory.Exists(path))
                {
                    DirectoryInfo di = new DirectoryInfo(path);
                    di.Create();
                }
                string filename = string.Format("{0}\\block_mode_variants_file.xml", path);
                if (!GenBMVFile(sydb.ibbmInfoList, filename))
                {
                    logMsg = "Generate block mode variant file error!";
                    WriteLog(logMsg, LogManager.Level.Error);
                    return;
                }
            }
            else if (Option.LEURF == option)
            {
                //chapter 5.1
                path = outputpath + "\\LEU";
                if (!Directory.Exists(path))
                {
                    DirectoryInfo di = new DirectoryInfo(path);
                    di.Create();
                }
                string filename = string.Format("{0}\\LEU_Result_Filtered_Values.xml", path);
                if (!GenLEURFFile(this.BmvInfoList, filename))
                {
                    logMsg = "Generate LEU Result Filtered Value file error!";
                    WriteLog(logMsg, LogManager.Level.Error);
                    return;
                }
            }
            else if (Option.LEUXML == option)
            {
                //chapter 5.2
                path = outputpath + "\\LEUBianry";
                if (!Directory.Exists(path))
                {
                    DirectoryInfo di = new DirectoryInfo(path);
                    di.Create();
                }
                //读取模板文件
                LEUGlobal leuGlobal = new LEUGlobal();
                if (!leuGlobal.Read(xmlLEUTFInfo))
                {
                    logMsg = "Read LEU Template file error, please check!";
                    WriteLog(logMsg, LogManager.Level.Error);
                    return;
                }
                //伪随机数不够,则返回false
                if (GidInfoList.Count < LeuInfoList.Count)
                {
                    logMsg = "The random data num in GID-Table.txt file is not enough!";
                    WriteLog(logMsg, LogManager.Level.Error);
                    return;
                }
                int i = 0;
                foreach (LEURF leu in LeuInfoList)
                {
                    string filename = string.Format("{0}\\{1}.xml", path, leu.leuName);
                    //生成每一个LEU的LEU Global.xml文件
                    if (!this.GenLEUGlobalFile(leu, leuGlobal, GidInfoList[i++], filename))
                    {
                        logMsg = string.Format("Generate {0}.xml file error!", leu.leuName);
                        WriteLog(logMsg, LogManager.Level.Error);
                        continue;
                    }
                }
            }
            else if (Option.LEUBIN == option)
            {
                //chapter 5.3
                path = outputpath + "\\LEUBianry";
                if (!Directory.Exists(path))
                {
                    DirectoryInfo di = new DirectoryInfo(path);
                    di.Create();
                }
                //调用LEU compiler生成.udf,.tgm和bin文件
                string[]      list  = Directory.GetFiles(leuFilesDir);
                List <string> files = new List <string>();
                foreach (string name in list)
                {
                    FileInfo fi = new FileInfo(name);
                    if (fi.Extension == ".xml")
                    {
                        files.Add(fi.FullName);
                    }
                }

                foreach (string filename in files)
                {
                    FileInfo fi = new FileInfo(filename);
                    logMsg = string.Format("Generating bin file of {0}......", fi.Name);
                    WriteLog(logMsg, LogManager.Level.Info);

                    Process p = new Process();
                    p.StartInfo.FileName = this.leuComPath;
                    if (isITC)
                    {
                        p.StartInfo.Arguments = string.Format("{0} -o {1} -udf -tgm -telformat sacem", filename, path);
                    }
                    else
                    {
                        p.StartInfo.Arguments = string.Format("{0} -o {1} -udf -tgm -telformat udf", filename, path);
                    }
                    p.StartInfo.CreateNoWindow  = true;
                    p.StartInfo.UseShellExecute = false;
                    p.Start();
                    p.WaitForExit();
                    p.Close();
                }
            }
            return;
        }