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); }
//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); }
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); }
public void test_GenerateBMBSDDBDisInfoNode() { List <LEU> leulist = new List <LEU>(); List <BEACON> blist = new List <BEACON>(); BMVFGen bmvf = new BMVFGen(false, ref blist, ref leulist); XmlVisitor beaconNodenull = XmlVisitor.Create("Beacon", null); Debug.Assert(false == bmvf.GenerateBMBSDDBDisInfoNode(null, ref beaconNodenull)); Prepare.ReloadGlobalSydb(".//input//BMBDisSydb.xml"); BFGen bf = new BFGen(".//input//BMBDisBeacons.csv", ".//input//BMBDisBeacons.xml", "", false, false); MethodHelper.InvokePrivateMethod <BFGen>(bf, "Init"); bmvf.GenrateDeviceByIBBM(); //the corresponding beacons are: //VB0102 VB0106 vb0101 vb0110 vb0111 vb0203 VB0609 vb1402 VB1303 ib1303 vb2002 fb1914 vb1705 VB0614 VB0601 VB0604 string[] validdis = { "8.630", "5.910", "6.410", "5.340", "6.020", "6.060", "5.710", "5.550", "5.650", "5.650", "130.580", "44.740", "73.580", "3.230", "3.100", "6.000" }; #region test the beacons of valid bmbdis { int beaconi = 0; foreach (var curdis in validdis) { XmlVisitor beaconNode = XmlVisitor.Create("Beacon", null); haschecked = false; Debug.Assert(true == bmvf.GenerateBMBSDDBDisInfoNode(blist[beaconi], ref beaconNode)); //check BMBSDDB calculate and node generate Debug.Assert(curdis == Prepare.getXmlNodeStr(beaconNode, "BMB_SDDB_distance")); //check BeaconMessage use the right BMB_Dis BeaconMessage bm = new BeaconMessage(); bm.GenerateMessage(blist[beaconi], 1, null); Debug.Assert(bm.BMB_Distance_Unitcm() == blist[beaconi].BMB_Distance_cm); ++beaconi; } } #endregion #region test the beacons of invalid bmbdis {//IB0302 FB1916 int errBeaconi = validdis.Length; for (; errBeaconi < blist.Count; errBeaconi++) { Debug.Assert(false == bmvf.GenerateBMBSDDBDisInfoNode(blist[errBeaconi], ref beaconNodenull)); } } #endregion }
//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); }
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); }
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); }
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); }
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); }
public XmlVisitor GetCombinedSectionsNode() { XmlVisitor Node = XmlVisitor.Create("Combined_sections", null); //BMGR-0048 red signal has <Combined_sections /> if (null != upPath) {//BMGR-0070 AddCombinSectionNode(ref Node, "Upstream_section", upPath.GetUpstreamPathName()); UpSection = upPath.GetUpstreamPathName(); } if (null != rpRs) {//BMGR-0077 AddCombinSectionNode(ref Node, "Reopening_section", rpRs.GetName()); RpSection = rpRs.GetName(); } if (null != apRs) {//BMGR-0078 AddCombinSectionNode(ref Node, "Approach_section", apRs.GetName()); ApSection = apRs.GetName(); } //BMGR-0079 if (null != olPath) { AddCombinSectionNode(ref Node, "Overlap_section", olPath.GetOverlapPathName()); OlSection = olPath.GetOverlapPathName(); } else if (null != overlap) { AddCombinSectionNode(ref Node, "Overlap_section", overlap.GetSigname()); OlSection = overlap.GetSigname(); } return(Node); }
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(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); }
public virtual XmlVisitor GetVariantXmlNode() { XmlVisitor variant1 = XmlVisitor.Create("Variant", null); return(variant1); }