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); }
/// <summary> /// 根据配置信息进行表比较 /// </summary> public virtual List <ComparaResult> Compara(SettingInfo settinInfo) { settinInfo.TargetDB.InitConn(); var targetTbList = DataOpr.GetTableList(settinInfo.InFilter, settinInfo.NotFilter); settinInfo.ComparaDB.InitConn(); var comparaTbList = DataOpr.GetTableList(settinInfo.InFilter, settinInfo.NotFilter); // 重置(清空)小平台数据库连接 ExtDBInfo.SetDefault(); return(ComparaTable(targetTbList, comparaTbList) .Where(data => data.Flag != StatusFlag.None).ToList()); }
public ClearProcBO(string sysCode) { ProcName = DataOpr.GetClearProcName(sysCode); OriginProcText = DataOpr.GetProcText(ProcName); if (OriginProcText.IsEmpty()) { OriginProcText = SQLTemplet.GetInitClearProc(sysCode, ConfigDS.SysList.GetSysInfo(sysCode).SysName); } ProcNoNotes = SQLExt.DelNotes(OriginProcText); ProcText = OriginProcText; // TODO:需要拆分吗? AllSQL = GetAllSQL(); BUSQL = GetBUSQL(); }
//BMRG-0037 private Dictionary <string, List <PathInfo> > GetConfigBeacon(string filename) { Dictionary <string, List <PathInfo> > allBeacons = new Dictionary <string, List <PathInfo> >(); XmlFileHelper xmlfile = XmlFileHelper.CreateFromFile(filename); if (null != xmlfile) { XmlVisitor root = xmlfile.GetRoot(); List <XmlVisitor> beacons = root.Children().ToList(); foreach (XmlVisitor node in beacons) { string beaconName = node.GetAttribute("name"); List <PathInfo> list = new List <PathInfo>(); List <XmlVisitor> pathList = node.Children().ToList(); foreach (XmlVisitor up in pathList) { string pathName = up.GetAttribute("name"); List <PointInfo> pointList = new List <PointInfo>(); List <XmlVisitor> pnList = up.Children().ToList(); foreach (XmlVisitor pn in pnList) { string ptName = pn.GetAttribute("name"); int id = DataOpr.Xmlvalue2Int(pn, "id"); Point point = (Point)Sys.GetNode(id, Sydb.pointInfoList.Cast <Basic>().ToList()); string pos = pn.FirstChildByPath("position").Value; string orit = pn.FirstChildByPath("orientation_in_route").Value; if (orit == Sys.Convergent || orit == Sys.Divergent) { PointInfo info = new PointInfo(point, pos, orit, true); pointList.Add(info); } else { //log error } } PathInfo path = new PathInfo(pathName, pointList); list.Add(path); } allBeacons.Add(beaconName, list); } } return(allBeacons); }
public bool Configure() { if (Option.BEACON == option) { //读取beacon layout文件 List <XmlVisitor> beaconList = xmlBeaconInfo.Children().ToList(); if (null != beaconList) { foreach (XmlVisitor node in beaconList) { BeaconLayout beacon = new BeaconLayout(); if (!beacon.SetBeacon(node)) { logMsg = string.Format("Read Beacon.ID = {0} error, please check!", beacon.ID); WriteLog(logMsg, LogManager.Level.Error); continue; } BeaconInfoList.Add(beacon); } } } else if (Option.BMV == option) { //读取beacon layout文件 List <XmlVisitor> beaconList = xmlBeaconInfo.Children().ToList(); if (null != beaconList) { foreach (XmlVisitor node in beaconList) { BeaconLayout beacon = new BeaconLayout(); if (!beacon.SetBeacon(node)) { logMsg = string.Format("Read Beacon.ID = {0} error in beacon layout file, please check!", beacon.ID); WriteLog(logMsg, LogManager.Level.Error); continue; } BeaconInfoList.Add(beacon); } } try { ReadSyDB readSydb = new ReadSyDB(xmlSyDBInfo); //计算LINE.ID sydb.LineID = readSydb.ReadLineId(); //读SYDB的IBBM表 sydb.ibbmInfoList = readSydb.ReadIBBM(); //读SYDB的route表 sydb.routeInfoList = readSydb.ReadRoute(); //读取SYDB的signal表 sydb.signalInfoList = readSydb.ReadSignal(); //读取SYDB的block表 sydb.blockInfoList = readSydb.ReadBlock(); //读取SYDB的point表 sydb.pointInfoList = readSydb.ReadPoint(); //读取SYDB的overlap表 sydb.overlapInfoList = readSydb.ReadOverlap(); //读取SYDB的TFC表 sydb.tfcInfoList = readSydb.ReadTFC(); //读取SYDB的TFC表 sydb.sddbInfoList = readSydb.ReadSDDB(); } catch (System.Exception ex) { logMsg = "Read sydb data error, please check!"; WriteLog(logMsg, LogManager.Level.Error); return(false); } } else if (Option.LEURF == option) { //读取BMV文件 this.lineID = DataOpr.Xmlattr2Int(xmlBMVInfo, "LINE_ID"); List <XmlVisitor> bmvList = xmlBMVInfo.Children().ToList(); if (null != bmvList) { foreach (XmlVisitor node in bmvList) { BMVBeaconInfo bm = new BMVBeaconInfo(node); BmvInfoList.Add(bm.GetBMBeaconInfo()); } } } else if (Option.LEUXML == option) { this.lineID = DataOpr.Xmlattr2Int(xmlLEURFInfo, "LINE_ID"); List <XmlVisitor> leuList = xmlLEURFInfo.Children().ToList(); if (null != leuList) { foreach (XmlVisitor node in leuList) { LEURF leu = new LEURF(); if (!leu.Read(node)) { logMsg = string.Format("Read LEU.ID = {0} error int LEU result filtered file, please check!", leu.leuId); WriteLog(logMsg, LogManager.Level.Error); continue; } LeuInfoList.Add(leu); } } //根据Config文件夹下GID-Table文件的内容计算伪随机数列表 string filename = System.IO.Directory.GetCurrentDirectory() + "\\Config\\GID-Table.txt"; StreamReader sr = new StreamReader(filename); string line = null; while ((line = sr.ReadLine()) != null) { string[] gids = line.Split(','); if (gids.Length < 3) { continue; } GID gid = new GID(); gid.ibGid = gids[0]; gid.ouGid = gids[1]; gid.netGid = gids[2]; GidInfoList.Add(gid); } } return(true); }
public bool ReadcsvBeacon(string csvFileName) { beaconInfoList.Clear(); CsvFileReader csvFileRd = new CsvFileReader(csvFileName, Encoding.UTF8, ';'); int count = csvFileRd.RowCount; if (count <= 2) { TraceMethod.RecordInfo($"Warning: {csvFileName} line number <=2, can't get beacon info."); return(false); } List <List <string> > data = csvFileRd.GetData(1, count); //get csv data List <string> headList = data[0]; for (int idx = 0; idx < headList.Count(); ++idx) { headList[idx] = headList[idx].ToLower(); } Func <string, int, string> readcsv = (colName, row) => { int col = headList.IndexOf(colName.ToLower()); if (1 <= col) { return(data[row][col].Trim()); } return(""); }; Func <string, int, Restriction, int> readintcsv = (colName, row, restri) => { string buff = readcsv(colName, row); int val = int.Parse(buff); if (restri.Validate(buff, colName) == false) { throw new Exception($"[{colName}] is invalid, read {buff}"); } return(val); }; //get first beacon line int start = 2; for (int i = 1; i <= count; ++i) { bool isNote = false; if (data[i][0].ToUpper() == "V") { for (int j = 0; j < csvFileRd.ColCount; ++j) { if (data[i][j].StartsWith("\"")) { isNote = true; break; } } } if (false == isNote) { start = i; break; } } //get restriction info Restriction res = new Restriction(@"./Config/Restriction.xml"); res.SetParentPath("BEACON_LAYOUT"); //for each line for (int i = start; i < count; ++i) { //check start if (data[i][0].ToUpper() == "V") { BeaconLayout beacon = new BeaconLayout(); try { beacon.Name = readcsv("Beacon_Name", i); beacon.BeaconVersion = readintcsv("Beacon_Version", i, res); beacon.ID = readintcsv("Beacon_ID", i, res); beacon.TrackID = readintcsv("Track_ID", i, res); beacon.kp = new KP_V(); // kp in csv file = finally kp beacon.kp.Value = new StringData(DataOpr.Multi100(readcsv("Kp", i))); beacon.BeaconBM = readintcsv("Beacon_Block_Mode", i, res); } catch (Exception ex) { TraceMethod.Record(TraceMethod.TraceKind.ERROR, $"Warning:load layout beacon {beacon.Name} fail {ex.Message}, ignore this beacon."); continue; } beaconInfoList.Add(beacon); } } if (0 == beaconInfoList.Count()) { return(false); } return(true); }
public boundaryBeacon(Line_boundary_BM_beacons.BEACON indata) { data = indata; //this func may raise exception if error _BMB_Distance_cm = int.Parse(DataOpr.Multi100(data.BMB_SDDB_distance)); }
//for tj format private bool GenBasciXml(string leuFile, string outputPath) { LEU_filtered_values leurfxml = FileLoader.Load <LEU_filtered_values>(leuFile); List <BasicBeacon> BeaconInfoList = new List <BasicBeacon>(); foreach (LEU_filtered_values.leu leurf in leurfxml.LEU) { foreach (LEU_filtered_values.leu.BEACON leuBeacon in leurf.Beacon) { BasicBeacon baBeacon = new BasicBeacon(leuBeacon); var signal = (GENERIC_SYSTEM_PARAMETERS.SIGNALS.SIGNAL)Sys.GetNode((string)leuBeacon.LINKED_SIGNAL,sydb.signalInfoList.Cast <Node>().ToList()); if (null == signal) { continue; } baBeacon.SignalId = signal.ID; baBeacon.SignalName = signal.Name; baBeacon.MsgList = new List <MsgRank>(); foreach (LEU_filtered_values.leu.BEACON.MESSAGE msg in leuBeacon.msgList) { MsgRank msgRk = new MsgRank(); msgRk.routeInfo = new List <string>(); //按照Upstream_section,Reopening_section,Approach_section,Overlap_section的顺序将进路上的道岔和信号机依次取出 //先算道岔,再算信号机 List <string> ptList = new List <string>(); List <string> sigList = new List <string>(); if (null != msg.Combined_sections) { JudgeSection(msg.Combined_sections.Upstream_section,ptList,sigList); JudgeSection(msg.Combined_sections.Reopening_section,ptList,sigList); JudgeSection(msg.Combined_sections.Approach_section,ptList,sigList); JudgeSection(msg.Combined_sections.Overlap_section,ptList,sigList); } msgRk.routeInfo.AddRange(ptList); msgRk.routeInfo.AddRange(sigList); //计算tel0和tel1 msgRk.Tel0 = msg.Interoperable; byte[] content = new byte[128]; byte[] telValue = DataOpr.String2byte(msgRk.Tel0); bool result = ScrambleTel(telValue,content); if (result) { msgRk.Tel1 = DataOpr.Byte2string(content); } else { TraceMethod.RecordInfo("Encoding Error!"); continue; } baBeacon.MsgList.Add(msgRk); } BeaconInfoList.Add(baBeacon); } } //写入可变报文配置文件 string allFileName = string.Format("{0}\\basic_beacons.xml",outputPath); XmlFileHelper allxmlFile = XmlFileHelper.CreateFromString(null); AddLogHead(ref allxmlFile); allxmlFile.SetRoot("Beacons",null); allxmlFile.Save2File(allFileName); XmlVisitor allFileRoot = allxmlFile.GetRoot(); allFileRoot.UpdateAttribute("NUMBERS",BeaconInfoList.Count); foreach (BasicBeacon basBeacon in BeaconInfoList) { XmlVisitor beaconNode = XmlVisitor.Create("Beacon",null); beaconNode.UpdateAttribute("ID",basBeacon.ID); beaconNode.UpdateAttribute("NAME",basBeacon.Name); beaconNode.UpdateAttribute("RANKS",basBeacon.MsgList.Count()); beaconNode.UpdateAttribute("TYPE",basBeacon.Type); beaconNode.UpdateAttribute("LINKED_SIGNALID",basBeacon.SignalId); beaconNode.UpdateAttribute("LINKED_SIGNALName",basBeacon.SignalName); for (int i = 0; i < basBeacon.MsgList.Count(); i++) { XmlVisitor rankNode = XmlVisitor.Create("Message",null); rankNode.UpdateAttribute("Rank",i); string route = ""; foreach (string info in basBeacon.MsgList[i].routeInfo) { route += info + "|"; } if (route.EndsWith('|'.ToString())) { route = route.Remove(route.LastIndexOf('|')); } if ("" != route) { rankNode.AppendChild("Route", route); } rankNode.AppendChild("Telegram0", basBeacon.MsgList[i].Tel0); rankNode.AppendChild("Telegram1", basBeacon.MsgList[i].Tel1); beaconNode.AppendChild(rankNode); } allFileRoot.AppendChild(beaconNode); } allxmlFile.Save2File(allFileName); return(true); }
public TableInfo(string tableName) { TableName = tableName; TableNameChn = DataOpr.GetTableNameChn(TableName); FieldList = DataOpr.GetFieldList(TableName); }