public override XmlVisitor GetVariantXmlNode() { XmlVisitor variant1 = XmlVisitor.Create("Variant", null); {//BMGR-0040 //BMGR-0030 variant1.AppendChild("Index", m_Idx); variant1.AppendChild("Type", string.Format("POINT_{0}", PointVariantPos[0])); variant1.AppendChild("Object_name", string.Format("{0}_{1}", m_pt.Point.Name, PointVariantPos[0])); } //BMGR-0041 //BMGR-0031 if (-1 != InputRank) { variant1.AppendChild("Input_rank", InputRank); } else if (-1 != value) { variant1.AppendChild("Value", value); } else { TraceMethod.RecordInfo($"Point[{m_pt.Info}] not in IBBM input and can't calculate value, log Error!"); } return(variant1); }
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); }
//BMGR-0025 BMGR-0069 public XmlVisitor GetXmlNode() {//if point is in upstream, not support now, need modify XmlVisitor pointNode = XmlVisitor.Create("Point", null); pointNode.UpdateAttribute("NAME", this.Point.Name); pointNode.AppendChild("Id", this.Point.ID); pointNode.AppendChild("Position", this.Position);//BMGR-0024 //BMGR-0069 pointNode.AppendChild("Orientation_in_route", orient); return(pointNode); }
public override XmlVisitor GetVariantXmlNode() { XmlVisitor variant1 = XmlVisitor.Create("Variant", null); variant1.AppendChild("Index", m_Idx); variant1.AppendChild("Type", "SIGNAL"); variant1.AppendChild("Object_name", m_signal.SignalInfo.Name); variant1.AppendChild("Input_rank", InputRank); return(variant1); }
//BMGR-0016 output LEU info private bool GenerateLEUInfoNode(GENERIC_SYSTEM_PARAMETERS.IMPLEMENTATION_BEACON_BLOCK_MODE.BM_BEACON ibbm, ref XmlVisitor node) { if (false == LEUList.Exists(x => x.Name == ibbm.LEU.LEU_Name)) { TraceMethod.RecordInfo($"input LEU[{ibbm.LEU.LEU_Name}] error, not exist in LEU list"); return(false); } int idx = LEUList.FindIndex(x => x.Name == ibbm.LEU.LEU_Name); //LEU XmlVisitor leu = XmlVisitor.Create("LEU", null); leu.UpdateAttribute("NAME", LEUList[idx].Name); leu.AppendChild("Id", LEUList[idx].ID); leu.AppendChild("BM_beacon_output_number", ibbm.LEU.Beacon_Output_number); node.AppendChild(leu); return(true); }
//BMGR-0027 private XmlVisitor CalBMVariantNode(BEACON beacon) { XmlVisitor bmNode = XmlVisitor.Create("BM_variants", null); foreach (Variant var in beacon.m_variantLst) { bmNode.AppendChild(var.GetVariantXmlNode()); } return(bmNode); }
public XmlVisitor GetDstSigXmlNode(bool bOverLap) { XmlVisitor dstSig = XmlVisitor.Create("Destination_signal",null); { //BMGR-0036 dstSig.UpdateAttribute("NAME",GetDstSignalName()); dstSig.AppendChild("Id",NodeApi.getIDNullSafe(DstSig)); } //BMGR-0026 if (bOverLap && null != m_overlap) { XmlVisitor overlop = XmlVisitor.Create("Overlap",null); overlop = m_overlap.GetXmlNode(); dstSig.AppendChild(overlop); } return(dstSig); }
//BMGR-0046 private bool GenerateBeaconInfoNode(BEACON beacon, ref XmlVisitor node, int outnum) { if (false == beacon.SetBeaconInfoNode_LEURF(ref node, outnum)) { TraceMethod.RecordInfo($"Write SetBeaconInfoNode_LEURF for {beacon.Info} error!"); return(false); } //BMGR-0047 node.AppendChild("Variants_inputs", beacon.GetVariantsInputs()); return(true); }
public XmlVisitor GetXmlNode() { XmlVisitor node = XmlVisitor.Create("Overlap",null); {//BMGR-0065 node.UpdateAttribute("ID",m_Ol.ID); node.AppendChild("Distance",Sys.Cm2Meter(m_Ol.D_Overlap,3).ToString(Sys.StrFormat)); } //BMGR-0066 BMGR-0067 if ("" != m_switchPos) { node.AppendChild("Switch_position",m_switchPos); foreach (PathInfo path in m_pathLst) { node.AppendChild(path.GetXmlNode()); } } return(node); }
//BMGR-0015 Block_mode_beacons.Beacon tag public bool SetBeaconInfoNode_BMVF(ref XmlVisitor beaconNode) { beaconNode.UpdateAttribute("NAME", Name); beaconNode.UpdateAttribute("TYPE", m_ibbmInfo.GetBeaconType()); beaconNode.UpdateAttribute("VERSION", m_layoutInfo.getVersion()); beaconNode.AppendChild("Id", m_layoutInfo.ID); //if m_ibbmInfo not valid return false if (null == m_ibbmInfo) { TraceMethod.RecordInfo($"Error:Beacon[{Info}] has on ibbm input struct"); //log error return(false); } beaconNode.AppendChild("Direction", m_ibbmInfo.Direction); if (true == m_ibbmInfo.Is_Guaranted_Beacon) { beaconNode.AppendChild("Is_guaranted_BM_beacon", null); } return(true); }
private bool GenerateBMVFile(string filename) { XmlFileHelper xmlFile = XmlFileHelper.CreateFromString(null); AddLogHead(ref xmlFile); xmlFile.SetRoot("Block_mode_beacons", null); XmlVisitor root = xmlFile.GetRoot(); root.UpdateAttribute("LINE_ID", sydb.LineID);//BMGR-0014 log lineID foreach (BEACON beacon in GetValidBeaconList()) { XmlVisitor beaconNode = XmlVisitor.Create("Beacon", null); if (false == beacon.SetBeaconInfoNode_BMVF(ref beaconNode) || false == GenerateLEUInfoNode(beacon.m_ibbmInfo, ref beaconNode) || false == GenerateBMBSDDBDisInfoNode(beacon, ref beaconNode)) { //log error TraceMethod.RecordInfo($"Warning:GenerateBMVFile base info[Beacon][LEU][BMBSDDB_Distance] faild for {beacon.Info}."); } //then all reopen sig and the approach sig foreach (OriginSignal orgSig in beacon.GetOrgSignalList()) { beaconNode.AppendChild(orgSig.GetXmlNode(beacon.Name)); } beaconNode.AppendChild(CalBMVariantNode(beacon)); root.AppendChild(beaconNode); } xmlFile.Save2File(filename); return(true); }
public XmlVisitor GetXmlNode() { XmlVisitor node = XmlVisitor.Create("Path",null); if (PATH_TYPE.OVERLAP == m_type) { //BMGR-0068 node.UpdateAttribute("NAME",GetOverlapPathName()); //BMGR-0069 foreach (PointInfo pt in pointList) { node.AppendChild(pt.GetXmlNode()); } } return(node); }
private bool Save2Config(TextBox textBox, string nodeName) { XmlFileHelper configInfo = XmlFileHelper.CreateFromFile(configFile); XmlVisitor root = configInfo.GetRoot(); XmlVisitor compiler = root.FirstChildByPath(nodeName); if (null == compiler) { root.AppendChild(nodeName, textBox.Text); } else { compiler.Value = textBox.Text; } configInfo.Save2File(configFile); return(true); }
public XmlVisitor GetXmlNode() { XmlVisitor Node = XmlVisitor.Create("Message", null); Node.UpdateAttribute("RANK", Rank); //BMGR-0048 rank=0 has no Combined_sections if (0 != Rank) { Node.AppendChild(GetCombinedSectionsNode()); } //Variant_state //Urbalise_iTC //Interoperable //they are generate after call this function return(Node); }
private void AddCombinSectionNode(ref XmlVisitor node, string attri, string value) { m_combinedsectionsBuffer += "[" + value + "]"; node.AppendChild(attri, value); }
public XmlVisitor GetXmlNode(string bName) { if (0 == RsList.Count) { TraceMethod.RecordInfo($"Warning: Beacon[{bName}] OriginSignal[{SignalInfo.Info}] has no RouteSegment!"); } XmlVisitor orgSigNode = XmlVisitor.Create("Origin_signal",null); {//BMGR-0017 orgSigNode.UpdateAttribute("NAME",m_ibbmIn.Name); orgSigNode.AppendChild("Id",SignalInfo.ID); if (Sys.TYPEFUNC_ROUTESPACING == SignalInfo.Signal_Type_Function) { orgSigNode.AppendChild("Type_function","Route_spacing_signal"); } else if (Sys.TYPEFUNC_SPACING == SignalInfo.Signal_Type_Function) { orgSigNode.AppendChild("Type_function","Spacing_signal"); } else { TraceMethod.RecordInfo($"sydb Error:signal[{GetName()}] Signal_Type_Function={SignalInfo.Signal_Type_Function} is unknow!"); } orgSigNode.AppendChild("BMB_type",m_ibbmIn.Type); } foreach (RouteSegment route in RsList) { XmlVisitor routeNode = XmlVisitor.Create("Route_segment",null); { routeNode.UpdateAttribute("NAME",route.GetName()); int len = route.GetLength(); if (len <= 0) { TraceMethod.RecordInfo($"signal[{GetName()}] Route {route.Info} get length[{len}] is invalid!"); } routeNode.AppendChild("Length",Sys.Cm2Meter(len,3).ToString(Sys.StrFormat)); foreach (PointInfo pt in route.m_PtLst) { routeNode.AppendChild(pt.GetXmlNode()); } //BMGR-0036 //use IBBM signal type instead of BMB_type if (Sys.Reopening == m_ibbmIn.Type)//BMGR-0026 only reopen signal of the beacon use overlap { routeNode.AppendChild(route.GetDstSigXmlNode(true)); } else { routeNode.AppendChild(route.GetDstSigXmlNode(false)); } } orgSigNode.AppendChild(routeNode); } return(orgSigNode); }
//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); }
private bool GenerateLEUResultFilterFile(string filename) { XmlFileHelper xmlFile = XmlFileHelper.CreateFromString(null); AddLogHead(ref xmlFile); //BMGR-0044 xmlFile.SetRoot("LEU_filtered_values", null); xmlFile.Save2File(filename); XmlVisitor root = xmlFile.GetRoot(); //BMGR-0044 root.UpdateAttribute("LINE_ID", sydb.LineID); //BMGR-0045 List <LEU> orderLEULst = m_LEULst.OrderBy(o => o.ID).ToList(); foreach (LEU leu in orderLEULst) { XmlVisitor LEUnode = XmlVisitor.Create("LEU", null); //set LEU info if (false == GenerateLEUInfoNode(leu, ref LEUnode)) { return(false); } string[] bNames = leu.GetBeaconNames(); //BMGR-0046 for (int i = 0; i < bNames.Count(); ++i) { string bName = bNames[i]; if ("" == bName) { continue; } int Bidx = m_BeaconLst.FindIndex(x => (x.Name == bName)); if (-1 == Bidx) { TraceMethod.RecordInfo($"Warning:LEU[{leu.Name}] contain beacon[{bName}] which not in valid beacon List, this beacon will be ignore!"); continue; } XmlVisitor beaconnode = XmlVisitor.Create("Beacon", null); if (false == GenerateBeaconInfoNode(m_BeaconLst[Bidx], ref beaconnode, i + 1)) { // } m_BeaconLst[Bidx].m_MsgLst = GenerateMessage(m_BeaconLst[Bidx]); if (m_BeaconLst[Bidx].m_MsgLst.Count() > 128) {//BMGR-0050 TraceMethod.RecordInfo($"LEU[{leu.Info} {m_BeaconLst[Bidx].Info}] generate messages {m_BeaconLst[Bidx].m_MsgLst.Count()} > 128"); } foreach (Message msg in m_BeaconLst[Bidx].m_MsgLst) { //mes and combine_sections XmlVisitor msgNode = msg.GetXmlNode(); //BMGR-0051 Variant_state string varstate = GetMsgVar(msg, m_BeaconLst[Bidx]); if (BEACON.MAXVARNUM != varstate.Length) { TraceMethod.RecordInfo($"Beacon[{m_BeaconLst[Bidx].Name}] Variant_state[{varstate}] length != {BEACON.MAXVARNUM}"); } msgNode.AppendChild("Variant_state", varstate); string msgBuff = ""; //Urbalis_iTC if (0 == msg.GetRank()) {//BMGR-0004 leu default msg for input beacon varstate = ""; } //don't output Urbalis_iTC for BMGen tool this time #if itcsupport msgBuff = m_BeaconLst[Bidx].GenMsgItc(varstate); if (86 != msgBuff.Length) { TraceMethod.RecordInfo(string.Format("Beacon[{0}] Urbalis_iTC message length != 16", m_BeaconLst[Bidx].Name)); return(false); } msgNode.AppendChild("Urbalis_iTC", msgBuff); #endif //Interoperable BeaconMessage bm = new BeaconMessage(); msgBuff = bm.GenerateMessage(m_BeaconLst[Bidx], sydb.LineID, msg); if (311 != msgBuff.Length) { TraceMethod.RecordInfo($"{m_BeaconLst[Bidx].Info} Interoperable message length != 311"); } msgNode.AppendChild("Interoperable", msgBuff); beaconnode.AppendChild(msgNode); } LEUnode.AppendChild(beaconnode); } root.AppendChild(LEUnode); } xmlFile.Save2File(filename); return(true); }
//BMGR-0021 private bool GenerateBMBSDDBDisInfoNode(BEACON beacon, ref XmlVisitor node) { if (null == beacon) { return(false); } try { //boundary beacon then get the value and return. node.AppendChild("BMB_SDDB_distance", Sys.Cm2Meter(beacon.m_layoutInfo.BMB_Distance_cm, 3).ToString("0.000")); //node.AppendChild("BMB_SDDB_distance", beacon.m_layoutInfo.BMB_Distance_cm); beacon.BMB_Distance_cm = beacon.m_layoutInfo.BMB_Distance_cm; return(true); } catch (Exception ex) { //if not boundary beacon then do next } BEACON reopeningBeacon = null; if (beacon.m_ibbmInfo.GetBeaconType() == BeaconType.Approach) { //find the reopen beacon string sigName = beacon.m_ibbmInfo.getLinkedSigName(); if (BEACON.SignamReBeaconDic.ContainsKey(sigName)) { string reopenBeaconName = BEACON.SignamReBeaconDic[sigName]; reopeningBeacon = beaconList.Find(x => x.Name == reopenBeaconName); } } else { reopeningBeacon = beacon; } if (null == reopeningBeacon) { TraceMethod.Record(TraceMethod.TraceKind.ERROR, $"Beacon {beacon.Info} type={beacon.m_ibbmInfo.GetBeaconType()} find reopen Beacon ERROR, can't get BMB_SDDB_distance"); return(false); } if (reopeningBeacon.BMB_Distance_cm <= 0) { int length = CalBeacon2SDDB(reopeningBeacon); if (length <= 0) { TraceMethod.Record(TraceMethod.TraceKind.ERROR, $"Beacon {beacon.Info} type={beacon.m_ibbmInfo.GetBeaconType()} can't get BMB_SDDB_distance"); return(false); } beacon.BMB_Distance_cm = length; } else { beacon.BMB_Distance_cm = reopeningBeacon.BMB_Distance_cm; } try { node.AppendChild("BMB_SDDB_distance", Sys.Cm2Meter(beacon.BMB_Distance_cm, 3).ToString("0.000")); //node.AppendChild("BMB_SDDB_distance", beacon.BMB_Distance_cm); } catch (Exception ex) { TraceMethod.Record(TraceMethod.TraceKind.ERROR, $"Beacon {beacon.Info} type={beacon.m_ibbmInfo.GetBeaconType()} calculate BMB_SDDB_distance {ex.Message}."); return(false); } return(true); }