Esempio n. 1
0
        public List <IBeaconInfo> GetBeacons()
        {
            List <IBeaconInfo> list = new List <IBeaconInfo>();

            list.AddRange(beaconInfoList);
            list.AddRange(boundBeaconInfoList);

            List <string> beaconnames = (from beacon in list
                                         select beacon.Name).ToList <string>();

            string buff = "The beaconnames from layout.csv and boundarybeacons.xml is repeated, please modify";

            if (false == checkRepeat(beaconnames,ref buff))   // no repeat return true else false.
            {
                TraceMethod.Record(TraceMethod.TraceKind.ERROR,buff);
            }
            list = list.GroupBy(p => p.Name).Select(g => g.First()).ToList();

            List <string> ids = (from beacon in list select beacon.ID.ToString()).ToList <string>();

            buff = "The IDs from layout.csv and boundarybeacons.xml is repeated, please modify";
            if (false == checkRepeat(ids,ref buff))
            {
                TraceMethod.Record(TraceMethod.TraceKind.ERROR,buff);
            }
            return(list.GroupBy(p => p.ID).Select(g => g.First()).ToList());
        }
Esempio n. 2
0
        /// <summary>
        /// get values from input data
        /// and set the values in member processData for write to excel
        /// </summary>
        /// <param name="leulist"></param>
        /// <param name="data">data in LEU_Result_Filtered_Values.xml</param>
        /// <param name="msgfiledir">path of LEUBinary which include all TGM files of all LEUs</param>
        /// <returns></returns>
        private void getdataprocess(List <LEU> leulist, List <LEU_filtered_values.leu> data, string msgfiledir)
        {
            if (null == leulist || 0 == leulist.Count)
            {
                return;
            }
            var groupedList = leulist.GroupBy(r => r.CI_Name);//1 sheet == 1 CI area

            foreach (var group in groupedList)
            {
                List <List <string> > pagedata = new List <List <string> >();//one page has leus in same group
                if (null != data)
                {
                    foreach (LEU leuname in group)
                    {
                        if (-1 == data.FindIndex(l => l.NAME == leuname.Name))
                        {
                            TraceMethod.Record(TraceMethod.TraceKind.WARNING,
                                               $"can't find leu[{leuname.Name}] in file LEU_Result_Filtered_Values.xml, CI-LEU report will lack this LEU");
                            continue;
                        }
                        LEU_filtered_values.leu leu = data.Find(l => l.NAME == leuname.Name);
                        foreach (LEU_filtered_values.leu.BEACON b in leu.beaconList)
                        {
                            pagedata.AddRange(getrecordfrombeacon(b, leu.NAME, msgfiledir, hasTGM));
                        }
                    }
                }
                processData[group.Key] = pagedata;
            }
        }
Esempio n. 3
0
        //BMGR-0066
        private string GetSwitchPos()
        {
            string sp = "";

            if (null == m_Ol)
            {
                return(sp);
            }
            switch ((string)m_Ol.Overlap_Type)
            {
            case "Not Interlocked":
            case "Reduce":
            case "":
                break;

            case "CBI Critical Normal":
                sp = "Normal";
                break;

            case "CBI Critical Reverse":
                sp = "Reverse";
                break;

            case "CBI Preferred Normal":
            case "CBI Preferred Reverse":
                sp = "Either";
                break;

            default:
                TraceMethod.Record(TraceMethod.TraceKind.WARNING,$"Invalid OverlapType in sydb [{m_Ol.Overlap_Type}]");
                break;
            }
            return(sp);
        }
Esempio n. 4
0
 private bool AddNewRoute(bool isSplitRoute, RouteSegment rs)
 {
     if (isSplitRoute == true)
     {
         if (rs.m_PtLst.Count > 0)
         {
             TraceMethod.Record(TraceMethod.TraceKind.ERROR, $"sydb split route[{rs.Info}] should has no point, this route will ignore\n");
             return(false);
         }
         if (null == m_Spacing_routeLst.Find(x => (x.m_OrgSig.ID == rs.m_OrgSig.ID &&
                                                   x.m_BlkLst.Count == rs.m_BlkLst.Count && x.m_BlkLst.All(rs.m_BlkLst.Contains))))
         {
             m_Spacing_routeLst.Add(rs);
         }
         else
         {
             TraceMethod.RecordInfo($"Warning: split route[{rs.Info}] is repeated, ignore the repeat ones!\r\n");
         }
     }
     else
     {
         if (null == m_RouteSpacing_routeLst.Find(x => (x.m_OrgSig.ID == rs.m_OrgSig.ID &&
                                                        x.m_BlkLst.Count == rs.m_BlkLst.Count && x.m_BlkLst.All(rs.m_BlkLst.Contains))))
         {
             m_RouteSpacing_routeLst.Add(rs);
         }
         else
         {
             TraceMethod.RecordInfo($"Warning: route[{rs.Info}] is repeated, ignore the repeat ones!\r\n");
         }
     }
     return(true);
 }
Esempio n. 5
0
        /// <summary>
        /// get the distance of beacon and nearest sddb in beacon direction
        /// unit: cm( sydb kp data is cm)
        /// </summary>
        /// <param name="beacon"></param>
        /// <returns></returns>
        private int CalBeacon2SDDB(BEACON beacon)
        {
            GENERIC_SYSTEM_PARAMETERS.BLOCKS.BLOCK beaconBlk = SyDB.GetLocatedBlock(beacon.m_layoutInfo.kp, beacon.m_layoutInfo.TrackID);

            if (null == beaconBlk)
            {
                TraceMethod.Record(TraceMethod.TraceKind.ERROR, $"Beacon {beacon.Info} type={beacon.m_ibbmInfo.GetBeaconType()} find beacon located block get null, can't get BMB_SDDB_distance");
                return(0);
            }
            //calculate length from beacon to beacon located Blk end
            string dir    = beacon.m_ibbmInfo.Direction;
            int    length = Sys.GetSDDBLenOfLocatedBlock(beacon.m_layoutInfo.kp, beaconBlk, dir);

            if (Sys.GetSDDBPosInLocatedBlock(beaconBlk, dir) == Sys.SddbInBlock.end)
            {
                return(length);
            }

            //calculate length from beaconBlk end to SDDB //only sddb and beacon in different blk will do this
            int nextBlkID = -1;

            GENERIC_SYSTEM_PARAMETERS.BLOCKS.BLOCK curBlk = beaconBlk;
            while (true)
            {
                if (curBlk.Is_Direction_Opposite.Equals(true))
                {
                    dir = SyDB.GetReverseDir(dir);
                }
                nextBlkID = SyDB.GetNextBlkID(curBlk, dir);
                if (nextBlkID == -1)
                {
                    TraceMethod.RecordInfo($"{curBlk.Info} search next block in {dir} occer convergent point,Error:Beacon {beacon.Info} type={beacon.m_ibbmInfo.GetBeaconType()} can't get BMB_SDDB_distance.");
                    return(0);
                }
                var nextBlk = (GENERIC_SYSTEM_PARAMETERS.BLOCKS.BLOCK)Sys.GetNode(nextBlkID, sydb.blockInfoList.Cast <Node>().ToList());
                if (null == nextBlk)
                {
                    TraceMethod.RecordInfo($"{curBlk.Info} search next block in {dir} get null,Error:Beacon {beacon.Info} type={beacon.m_ibbmInfo.GetBeaconType()} can't get BMB_SDDB_distance");
                    return(0);
                }

                Sys.SddbInBlock sddbInWalk = Sys.SddbWalkThroughBlock(nextBlk, dir);
                if (Sys.SddbInBlock.none != sddbInWalk)
                {
                    if (Sys.SddbInBlock.end == sddbInWalk)
                    {
                        length += nextBlk.GetBlockLen();
                    }
                    break;
                }

                length += nextBlk.GetBlockLen();
                curBlk  = nextBlk;
            }
            return(length);
        }
Esempio n. 6
0
 public string GenerateMessage(IBeaconInfo layout, int lineID)
 {
     if (null == layout)
     {
         TraceMethod.Record(TraceMethod.TraceKind.ERROR, "GenerateMessage Error:input null beacon");;
         return("");
     }
     setValue(lineID, layout);
     return(GenerateMessage());
 }
Esempio n. 7
0
 /// <summary>
 /// 通过childname的限制信息验证value。
 /// 与public bool SetParentPath(string xpath)配合使用xpath到childname的父节点
 /// </summary>
 /// <param name="value"></param>
 /// <param name="childname"></param>
 /// <returns></returns>
 public bool Validate(string value, string childname)
 {
     foreach (var n in root.Children())
     {
         if (n.Name == childname)
         {
             return(ValidateValue(value, n.Children()));
         }
     }
     TraceMethod.Record(TraceMethod.TraceKind.WARNING,
                        $"Get no restriction info of {childname}, lack check of {value}");
     return(false);
 }
Esempio n. 8
0
        /// <summary>
        /// set data in record to cols of input row
        /// </summary>
        /// <param name="row"></param>
        /// <param name="record"></param>
        /// <param name="cols"></param>
        private void setRow(IRow row, List <string> record, int[] cols)
        {
            int i = 0;

            if (record.Count != cols.Length)
            {
                TraceMethod.Record(TraceMethod.TraceKind.ERROR,
                                   $"call setMsgRow error, record count {record.Count} != cols count {cols.Length}");
                return;
            }
            foreach (int col in cols)
            {
                setcellvaluestyle(row, col, record[i]);
                ++i;
            }
        }
Esempio n. 9
0
        public int AddBeacon(int BeaconOutNum, string beaconName)
        {
            if (BeaconOutNum < 1 || BeaconOutNum > 4)
            {
                TraceMethod.Record(TraceMethod.TraceKind.ERROR, $"sydb file data error: Beacon[{beaconName}] IBBM.BM_Beacon.LEU.@Beacon_Output_Nb={BeaconOutNum} not in [1,4]");
                return(-1);
            }
            //check if LEU.BeaconOutNum is repeated
            if ("" != beaconNames[BeaconOutNum - 1])
            {
                TraceMethod.Record(TraceMethod.TraceKind.ERROR,
                                   $"sydb.IBBM data error: Beacon[{beaconNames[BeaconOutNum - 1]}] and Beacon[{beaconName}] has same LEU={Name} Beacon_Output_number={BeaconOutNum}");
                return(-2);
            }

            beaconNames[BeaconOutNum - 1] = beaconName;
            return(0);
        }
Esempio n. 10
0
 public void ReadBoundaryBeacon(Line_boundary_BM_beacons bbeacons)
 {
     boundBeaconInfoList.Clear();
     foreach (Line_boundary_BM_beacons.BEACON b in bbeacons.Beacon)
     {
         try
         {
             boundaryBeacon beacon = new boundaryBeacon(b);
             boundBeaconInfoList.Add(beacon);
         }
         catch (Exception ex)
         {
             TraceMethod.Record(TraceMethod.TraceKind.ERROR,
                                $"Warning:load boundary beacon {b.Name} fail {ex.Message}, ignore this beacon.");
             continue;
         }
     }
 }
Esempio n. 11
0
        //BMGR-0027
        private bool GenerateVariantList(BEACON beacon)
        {
            beacon.m_variantLst = new List <Variant>();
            foreach (OriginSignal sig in beacon.GetOrgSignalList())
            {
                sig.CalVariants(beacon.m_variantLst);
            }

            foreach (Variant var in beacon.m_variantLst)
            {
                if (var.GetVarSrc() == VAR_TYPE.E_POINT)
                {
                    VariantPoint pvar = (VariantPoint)var;
                    //BMGR-0031 set inputRank from IBBM
                    var.InputRank = beacon.m_ibbmInfo.getInputRank(var.GetName(), pvar.PointVariantPos);
                    pvar.check(beacon.Name);
                }
            }
            //del repeat by object_name
            beacon.m_variantLst = beacon.m_variantLst.Distinct().ToList();

            //set idx
            int idx = 1;

            foreach (Variant var in beacon.m_variantLst)
            {
                var.SetIdx(idx);
                ++idx;
            }

            if (beacon.m_variantLst.Count() > BEACON.MAXVARNUM)
            {
                TraceMethod.Record(TraceMethod.TraceKind.ERROR, $"{beacon.Info} has {beacon.m_variantLst.Count()} variants more than {BEACON.MAXVARNUM}!");
                foreach (Variant var in beacon.m_variantLst)
                {
                    TraceMethod.RecordInfo($"{var.Info}");
                }
            }
            return(true);
        }
Esempio n. 12
0
        /// <summary>
        /// read compiled messages from Tgm file
        /// </summary>
        /// <param name="tgmfilefullname">fullname of the tgm file</param>
        /// <param name="msgnum">nums of message you want to get, [0, 127]</param>
        /// <returns></returns>
        public static List <string> readcompiledmsg(string tgmfilefullname, ushort msgnum)
        {
            List <string> msgs = new List <string>();

            if (false == File.Exists(tgmfilefullname))
            {
                TraceMethod.Record(TraceMethod.TraceKind.ERROR, $"readcompiledmsg Error. input {tgmfilefullname} is not exist");
                return(msgs);
            }
            if (msgnum > (ushort)127)
            {
                TraceMethod.Record(TraceMethod.TraceKind.ERROR, $"readcompiledmsg Error: input msgnum={msgnum} should in [0,127]");
                return(msgs);
            }
            using (StreamReader tgmfile = new StreamReader(tgmfilefullname))
            {
                string buff    = tgmfile.ReadToEnd();
                string pattern = @".TGML ([0-9a-fA-F\s\r\n]*)";

                int i = 0;
                foreach (Match match in Regex.Matches(buff, pattern))
                {
                    if (i == msgnum)
                    {//read the first msgnum msgs is enough
                        break;
                    }
                    msgs.Add(match.Groups[1].ToString().Trim().Replace("\n", " ").Replace("\r", ""));
                    ++i;
                }
            }
            if (msgnum != (ushort)msgs.Count)
            {
                TraceMethod.Record(TraceMethod.TraceKind.ERROR, $"readcompiledmsg {tgmfilefullname} Error. Please Check:\r\n" +
                                   $"get msg num {msgs.Count} != {msgnum}");
                return(msgs);
            }
            return(msgs);
        }
Esempio n. 13
0
        //BMGR-0024
        //the blockList is in order of direction
        public bool GetPointLstFromBlkLst()
        {
            m_PtLst.Clear();
            if (0 == m_BlkLst.Count)
            {
                TraceMethod.Record(TraceMethod.TraceKind.ERROR,$"route[{Info}] include no block, original route[{RouteInfo.Info}]\n");
                return(false);
            }

            for (int i = 0; i < m_BlkLst.Count - 1; ++i)
            {
                GENERIC_SYSTEM_PARAMETERS.BLOCKS.BLOCK preBlock  = m_BlkLst[i];
                GENERIC_SYSTEM_PARAMETERS.BLOCKS.BLOCK nextBlock = m_BlkLst[i + 1];
                if (preBlock.Point_ID == nextBlock.Point_ID && null != preBlock.Point_ID)
                {//BMGR-0025 cal point info by block link
                    var point = (GENERIC_SYSTEM_PARAMETERS.POINTS.POINT)Sys.GetNode((int)preBlock.Point_ID,SyDB.GetInstance().pointInfoList.Cast <Node>().ToList());

                    PointInfo objpt = new PointInfo(point,
                                                    SyDB.GetPosByBlocks(preBlock,nextBlock),
                                                    SyDB.GetOrientByBlocks(preBlock,nextBlock),
                                                    PointLocation.Route,
                                                    this.RouteInfo);

                    m_PtLst.Add(objpt);
                }
            }
            if (10 < m_PtLst.Count())
            {
                TraceMethod.Record(TraceMethod.TraceKind.ERROR,$"points in route[{Info}] is more than 10.\n");
                foreach (PointInfo pt in m_PtLst)
                {
                    TraceMethod.RecordInfo(pt.Info);
                }
                return(false);
            }
            return(true);
        }
Esempio n. 14
0
        private bool ValidateValue(string value, IEnumerable <XmlVisitor> resnodes)
        {
            string log = "";

            foreach (var res in resnodes)
            {
                if (res.Name == "INT")
                {
                    IntRestriction intrange = CreatIntResriction(res);
                    if (true == intrange.validate(value))
                    {
                        return(true);
                    }
                    log += res.ToString();
                }
                else
                {
                    throw new Exception($"Restriction {res.ToString()} is unknown.");
                }
            }
            TraceMethod.Record(TraceMethod.TraceKind.WARNING,
                               $"{value} is invalid of restriction {log}");
            return(false);
        }
Esempio n. 15
0
        private bool GenLEUXmlFile(LEU_filtered_values.leu leurf, GID gid, string filename)
        {
            try
            {
                XmlFileHelper xmlFile = XmlFileHelper.CreateFromString(null);
                AddLogHead(ref xmlFile);

                //根据LEU Result Filtered Values文件的内容修改可变部分的值
                leuXmlTemplate.name = leurf.NAME;

                //5.2.1生成Output_balise
                leuXmlTemplate.Output_balise.Clear();//先清掉已有数据

                //calculate leugb.obList by leurf.beaconList
                #region [cal oblist]
                foreach (LEU_filtered_values.leu.BEACON beacon in leurf.beaconList)
                {
                    LEUXML.LEU.OUTPUT_BALISE ob = new LEUXML.LEU.OUTPUT_BALISE(beacon.NAME, beacon.NUM);

                    string[] varInputs = beacon.Variants_inputs.ToString().Split(' ');
                    int      index     = 0;
                    //BMGR-0064
                    foreach (string varInput in varInputs)
                    {
                        if (varInput != "0")
                        {
                            LEUXML.LEU.OUTPUT_BALISE.INPUT input = new LEUXML.LEU.OUTPUT_BALISE.INPUT();
                            input.Channel = new StringData("00");
                            input.Number  = new StringData(varInput.PadLeft(2, '0'));
                            input.index   = index;
                            ob.Input.Add(input);
                        }
                        ++index;//BMGR-0072 this is the pos index in variant_input and varait_state
                    }
                    ob.Input.Sort((x, y) =>
                    {
                        return(x.Number.ToString().CompareTo(y.Number.ToString()));   //根据intNum重新排序,这个排序影响mask的值
                    });

                    foreach (LEU_filtered_values.leu.BEACON.MESSAGE msg in beacon.msgList)
                    {
                        if (0 != msg.RANK)//BMGR-0071
                        {
                            LEUXML.LEU.OUTPUT_BALISE.ASPECT asp = new LEUXML.LEU.OUTPUT_BALISE.ASPECT();
                            string mask = "";
                            //BMGR-0072
                            //根据Input的顺序确定其在MASK中的位置,根据其num找到其在Variants_inputs中的索引
                            //根据其在Variants_inputs中索引,确定此码位在Variant_state中的索引.[两个索引相等]
                            //判断此索引位置的值,为0则取0,为1则取1,为P或S则取X,然后将MASK不足X至30位
                            foreach (var inNode in ob.Input)
                            {
                                string value = msg.VarState.Substring(inNode.index, 1);
                                if (value == "0")
                                {
                                    mask += '0';
                                }
                                else if (value == "1")
                                {
                                    mask += '1';
                                }
                                else if (value == "P" || value == "S")
                                {
                                    mask += 'X';
                                }
                            }
                            //补足30位
                            for (int i = mask.Length; i < 30; i++)
                            {
                                mask += 'X';
                            }
                            asp.Mask = new StringData(mask);
                            //BMGR-0073
                            if (isITC)
                            {
                                throw new NotImplementedException();
                            }
                            else
                            {
                                asp.Telegram = msg.Interoperable;
                            }
                            ob.CheckAspect(asp);
                            ob.Aspect.Add(asp);
                        }
                    }
                    //BMGR-0074
                    LEU_filtered_values.leu.BEACON.MESSAGE dftMsg = beacon.msgList.Find(x => (int)x.RANK == 0);
                    if (isITC)
                    {
                        throw new NotImplementedException();
                    }
                    else
                    {
                        ob.Default_telegram = dftMsg.Interoperable;
                    }
                    leuXmlTemplate.Output_balise.Add(ob);
                }
                #endregion

                //GMBR-0060
                leuXmlTemplate.updateGid(gid);

                FileSerializer.Serialize(leuXmlTemplate, filename, AddLogHead());

                return(true);
            }
            catch (System.Exception ex)
            {
                TraceMethod.Record(TraceMethod.TraceKind.ERROR, ex.Message);
                return(false);
            }
        }
Esempio n. 16
0
        /// <summary>
        /// output the processData to excel
        /// excel is genrate accorint to input templatefile
        /// </summary>
        /// <param name="templatefile"></param>
        /// <param name="outputpath"></param>
        public void generateExcel(string templatefile, string outputpath)
        {
            const int templatepage  = 3;
            const int formatline    = 11;
            const int datastartline = 11;
            const int notestartline = 12;
            const int existdataline = notestartline - datastartline;

            string outputFullName = Path.Combine(outputpath, Path.GetFileName(templatefile));

            if (false == File.Exists(templatefile))
            {
                TraceMethod.Record(TraceMethod.TraceKind.ERROR,
                                   $"CI-LEU report templelate file is missing {templatefile}, please check!");
                return;
            }
            using (FileStream sw = new FileStream(templatefile, FileMode.Open, FileAccess.ReadWrite))
            {
                workBook = createworkbook(sw);
                if (null == workBook)
                {
                    return;
                }

                getstyles(workBook, templatepage, formatline);

                int sheetidx = 1;
                foreach (var page in processData)
                {
                    ISheet sheet = workBook.CloneSheet(templatepage);
                    workBook.SetSheetName(templatepage + sheetidx, $"{page.Key}联锁区");
                    ++sheetidx;

                    int recordnum = processData[page.Key].Count();
                    sheet.ShiftRows(notestartline, sheet.LastRowNum, recordnum - existdataline, true, true);
                    for (int wor = 0; wor < recordnum; ++wor)
                    {
                        IRow row = sheet.CreateRow(datastartline + wor);
                        if (null == processData[page.Key][wor])
                        {
                            //empty row need do nothing
                        }
                        else if (defaultmsgcols.Count() == processData[page.Key][wor].Count)
                        {
                            setDefaultMsgRow(row, processData[page.Key][wor]);
                        }
                        else if (cols.Count() == processData[page.Key][wor].Count)
                        {
                            setRow(row, processData[page.Key][wor], cols);
                        }
                        else
                        {
                            TraceMethod.Record(TraceMethod.TraceKind.ERROR,
                                               $"get invalid data reocrd cols count {processData[page.Key][wor].Count}\n"
                                               + $"{processData[page.Key][wor].ToString()}");
                        }
                    }
                    //set MergedRegion, but the existed line should not set again or excel will raise error while open
                    for (int rowidx = 0; rowidx < recordnum - existdataline; rowidx++)
                    {
                        for (int mergedidx = 0; mergedidx < mergedcolinfo.Count() / 2; ++mergedidx)
                        {
                            CellRangeAddress region = new CellRangeAddress(
                                datastartline + existdataline + rowidx, datastartline + existdataline + rowidx,
                                mergedcolinfo[mergedidx * 2], mergedcolinfo[mergedidx * 2 + 1]);
                            sheet.AddMergedRegion(region);
                        }
                    }
                }
                workBook.RemoveSheetAt(templatepage);

                FileStream sw1 = new FileStream(outputFullName, FileMode.Create, FileAccess.ReadWrite);
                workBook.Write(sw1);
                sw.Close();
                sw1.Close();
            }
        }
Esempio n. 17
0
                public string GetBeaconType()
                {
                    if (BeaconType.Unknown == type)
                    {
                        reopenSigNum = 0;
                        appSigNum    = 0;
                        //BMGR-0082
                        foreach (var input in Input_Signal)
                        {
                            if (input.Type == Sys.Reopening)
                            {
                                ++reopenSigNum;
                                linkedSigName = input.Name;
                            }
                            else if (input.Type == Sys.Approach)
                            {
                                ++appSigNum;
                                if ("" == linkedSigName)
                                {
                                    linkedSigName = input.Name;
                                }
                            }
                            else
                            {
                                //error unknow input type
                                TraceMethod.Record(TraceMethod.TraceKind.ERROR,
                                                   $"input IBBM error: beacon {Name} has unknow input signal type[{input.Type}]!");
                            }
                        }

                        //chapter 4.1 check the IBBM<input_signal>
                        //1   approach 0 reopening: type = approach beacon
                        //0   approach 1 reopening: type = Reopening beacon
                        //1-3 approach 1 reopening: type = Reopening_Approach beacon
                        //others error

                        //BMGR-0015 get the type by ibbm input signal
                        //type = approach beacon:
                        //0 reopening 1 approach
                        if ((0 == reopenSigNum && 1 == appSigNum)
                            )
                        {//@Type is Approach
                            type = BeaconType.Approach;
                        }
                        else if (1 == reopenSigNum)
                        {
                            BEACON.SignamReBeaconDic[linkedSigName] = Name;
                            if (appSigNum > 3)
                            {//error
                                type = BeaconType.Invalid;
                                TraceMethod.RecordInfo($"Beacon {Name} data error, the input signal number of approach is more than 3!");
                            }

                            else if (0 == appSigNum)
                            {//0 approach 1 reopening: type = Reopening beacon
                                type = BeaconType.Reopening;
                            }
                            else
                            {//1-3 approach 1 reopening: type = Reopening_Approach beacon
                                type = BeaconType.Reopening_Approach;
                            }
                        }
                        else
                        {//error
                            type = BeaconType.Invalid;
                            TraceMethod.RecordInfo($"Sydb file error: Beacon {Name}, the input signal number is unknown Reopening={reopenSigNum} Approach={appSigNum}!");
                        }
                    }

                    return(type.ToString());
                }
Esempio n. 18
0
        //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);
        }
Esempio n. 19
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);
        }
Esempio n. 20
0
        /// <summary>
        /// route_segment length, based on blk_list, check sddb
        /// </summary>//0035
        /// <param name="blockList"></param>
        /// <returns></returns>
        /// //BMGR-0035
        public int GetLength()
        {
            int len       = 0;
            int startBIdx = 0;

            for (int i = 0; i < m_BlkLst.Count; ++i)
            {
                if (OrgSig.SDDId == m_BlkLst[i].Secondary_Detection_Device_ID &&
                    0 != m_BlkLst[i].Secondary_Detection_Device_ID)
                {
                    startBIdx = i;
                    break;
                }
            }

            int endBIdx = m_BlkLst.Count - 1;

            if (m_BlkLst.Count() > 1)
            {
                //find signal located block
                GENERIC_SYSTEM_PARAMETERS.BLOCKS.BLOCK blk = SyDB.GetLocatedBlock(DstSig.Kp,DstSig.Track_ID);
                if (blk == null)
                {
                    TraceMethod.Record(TraceMethod.TraceKind.ERROR,$"dstSignal{DstSig.Info} can't find located block");
                    return(-1);
                }
                if (SyDB.IsLocatedOnBlockBeginOrEnd(DstSig.Kp,DstSig.Track_ID,blk))
                {
                    if (m_BlkLst.Exists(s => s.ID == blk.ID) == false)
                    {
                        //the last one is the endBIdx, so donothing
                    }
                    else
                    {
                        endBIdx = m_BlkLst.FindIndex(s => s.ID == blk.ID);
                        var preBlk = (GENERIC_SYSTEM_PARAMETERS.BLOCKS.BLOCK)Sys.GetNode((int)(m_BlkLst[endBIdx - 1].ID),SyDB.GetInstance().blockInfoList.Cast <Node>().ToList());
                        if (SyDB.IsLocatedOnBlockBeginOrEnd(DstSig.Kp,DstSig.Track_ID,preBlk))
                        {
                            endBIdx = endBIdx - 1;//route length end with preblk
                        }
                        else
                        {
                            //the located one is the endBIdx, so donothing
                        }
                    }
                }
                else
                {//the local block is the end one
                    if (m_BlkLst.Exists(s => s.ID == blk.ID) == false)
                    {
                        m_BlkLst.Add(blk);
                        ++endBIdx;
                    }
                    else
                    {
                        endBIdx = m_BlkLst.FindIndex(s => s.ID == blk.ID);
                    }
                }
            }

            string log = "";

            for (int i = startBIdx; i <= endBIdx; ++i)
            {
                len += m_BlkLst[i].GetBlockLen();
                log += "[" + m_BlkLst[i].Info + "]";
            }
            //TraceMethod.RecordInfo($"RouteSegment {Info} has blocks {log}");

            return(len);
        }
Esempio n. 21
0
        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);
        }
Esempio n. 22
0
        private bool Init()
        {
            if (isBin)
            {
                if (!File.Exists(leuComPath))
                {
                    string logMsg = string.Format("[{0}] the compile tool for bin file is not exist, please check!", leuComPath);
                    TraceMethod.RecordInfo(logMsg);
                    return(false);
                }
            }

            //read all LEU info from LEU_Result_Filtered_Values.xml
            try
            {
                LEU_filtered_values leurfxml = FileLoader.Load <LEU_filtered_values>(leuRF);
                LeuInfoList = leurfxml.LEU;
            }
            catch (System.Exception ex)
            {
                TraceMethod.RecordInfo($"Read LEU file [{leuRF}] error {ex.Message}, please check!");
                return(false);
            }

            //read LEU template info for each LEU.xml from LEUXMLTemplateExample.xml
            try
            {
                leuXmlTemplate = FileLoader.Load <LEUXML.LEU>(leuTF);
            }
            catch (System.Exception ex)
            {
                TraceMethod.RecordInfo("Read LEU XML Template file error {0}, please check!", ex.Message);
                return(false);
            }

            List <string> gidList      = new List <string>();
            string        gidRepeatLog = "";

            try
            {
                StreamReader sr   = new StreamReader(gidTable);
                string       line = null;
                while ((line = sr.ReadLine()) != null && gidList.Count < LeuInfoList.Count * 3)
                {
                    //the used GID table, should not be repeated
                    if (gidList.Contains(line))
                    {
                        gidRepeatLog += line + "   ";
                        continue;
                    }

                    if (line.Length == 16)
                    {
                        //add check of gid data
                    }
                    else if ("" == line)
                    {
                        continue;
                    }
                    else
                    {
                        TraceMethod.RecordInfo($"invalid [{line}] in {gidTable}");
                        return(false);
                    }

                    gidList.Add(line);
                }

                sr.Close();
            }
            catch (System.Exception ex)
            {
                TraceMethod.RecordInfo($"Read GID file [{gidTable}] error {ex.Message}, please check!");
                return(false);
            }

            //read all the GID data from \\Config\\GID-Table.txt


            //BMGR-0062
            //伪随机数不够,则返回false
            if (gidList.Count < LeuInfoList.Count * 3)
            {
                if ("" != gidRepeatLog)
                {
                    gidRepeatLog = "Repeated gid: " + gidRepeatLog + " ";
                }
                gidRepeatLog += $" The data in GID-Table.txt has {gidList.Count} unique records, should be {LeuInfoList.Count * 3}!";
                TraceMethod.Record(TraceMethod.TraceKind.ERROR, gidRepeatLog);
                return(false);
            }

            for (int i = 0; i < LeuInfoList.Count; ++i)
            {
                GID gid = new GID(gidList[i * 3], gidList[(i * 3) + 1], gidList[(i * 3) + 2]);
                GidInfoList.Add(gid);
            }
            return(true);
        }