Пример #1
0
        void test_AddNewRoute()
        {
            Prepare.ReloadGlobalSydb(".//input//Routes_fromHHHT2.xml");
            RouteSegConfig SyDBRouteCfg = new RouteSegConfig(sydb);

            var sydbroute = sydb.routeInfoList.Find(x => x.ID == 231);//this route has point

            Debug.Assert(false == SyDBRouteCfg.AddNewRoute(true,new RouteSegment(sydbroute)));
        }
Пример #2
0
        public void test_overlapAPI()
        {
            Prepare.ReloadGlobalSydb(".//input//overlapsSydb_FromHHHT2.xml");

            ObjOverlap ovelap = new ObjOverlap(null, null);

            Debug.Assert(true == ovelap.GeneratePath(null));
            Debug.Assert(ovelap.GetSigname() == "Null");

            Dictionary <string, string[]> validoverlaps = new Dictionary <string, string[]>()
            {
                //overlap                   //dstSig  //ibbm   //variant num //olpathInfo
                { "O_S0101", new string[] { "S0101", "VB0101", "0", "" } },
                { "O_S0102", new string[] { "S0102", "VB0102", "0", "" } },
                { "O_S0103", new string[] { "S0103", "VB0103", "0", "S0103" } },
                { "O_S0107", new string[] { "S0107", "VB0107", "2", "S0107|P0101-N S0107|P0101-R" } },
                { "O_S0107_N", new string[] { "S0107", "VB0107", "2", "S0107|P0101-N" } },
                { "O_S0107_R", new string[] { "S0107", "VB0107", "2", "S0107|P0101-R" } },
                { "O_S0107_NOIN", new string[] { "S0107", "VB0107E", "2", "S0107|P0101-R" } },
                { "O_X0109", new string[] { "X0109", "VB0109", "6", "X0109|P0105-R|P0103-R|P0102-R" } },
                { "O_S0304", new string[] { "S0304", "VB0304", "4", "S0304|P0302-N|P0602-N S0304|P0302-N|P0602-R" } },
                { "O_S0304_NOIN", new string[] { "S0304", "VB0304E", "4", "S0304|P0302-N|P0602-R" } },
                { "O_S1101_N", new string[] { "S1101", "VB1101", "4", "S1101|P1101-N|P1103-N" } },
                { "O_S1101_R", new string[] { "S1101", "VB1101", "2", "S1101|P1101-R" } },
                { "O_S0608", new string[] { "S0608", "VB0608", "6", "S0608|P0606-N|P0608-N|P0610-R S0608|P0606-R" } }
            };

            #region check for valid ovelap
            {
                foreach (var ol in sydb.overlapInfoList)
                {
                    if (validoverlaps.ContainsKey(ol.Name))
                    {
                        string signame = validoverlaps[ol.Name][0];
                        GENERIC_SYSTEM_PARAMETERS.SIGNALS.SIGNAL sig = (GENERIC_SYSTEM_PARAMETERS.SIGNALS.SIGNAL)Sys.GetNode(signame,sydb.signalInfoList.Cast <Node>().ToList());
                        ObjOverlap overlap = new ObjOverlap(ol,sig);
                        Debug.Assert(overlap.GetSigname() == signame);

                        GENERIC_SYSTEM_PARAMETERS.IMPLEMENTATION_BEACON_BLOCK_MODE.BM_BEACON inb = (GENERIC_SYSTEM_PARAMETERS.IMPLEMENTATION_BEACON_BLOCK_MODE.BM_BEACON)Sys.GetNode(validoverlaps[ol.Name][1],sydb.ibbmInfoList.Cast <Node>().ToList());
                        Debug.Assert(true == overlap.GeneratePath(inb));
                        Debug.Assert(validoverlaps[ol.Name][3] == Prepare.getXmlNodeStr(overlap.GetXmlNode(),"/Path/@NAME"));

                        List <Variant> vlist = new List <Variant>();
                        Debug.Assert(true == overlap.CalVariants(vlist));
                        Debug.Assert(vlist.Count.ToString() == validoverlaps[ol.Name][2]);

                        haschecked = true;
                    }
                }
                Debug.Assert(haschecked == true);
                haschecked = false;
            }
            #endregion
        }
Пример #3
0
        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
        }
Пример #4
0
        void test_generate()
        {
            List <LEU>    leulist = new List <LEU>();
            List <BEACON> blist   = new List <BEACON>();
            BMVFGen       bmvf    = new BMVFGen(false, ref blist, ref leulist);

            sydb.clear();
            Debug.Assert(false == bmvf.Generate(".//output"));//lack load data, so generate return false

            Prepare.ReloadGlobalSydb(".//input//BMVF_FromZJ.xml");
            BFGen bf = new BFGen(".//input//BMVF_FromZJ.csv", "", "", false, false);

            MethodHelper.InvokePrivateMethod <BFGen>(bf, "Init");

            Debug.Assert(true == bmvf.Generate(".//output"));  // generate BMVF file.
            Debug.Assert(true == File.Exists(".//output//BMV//block_mode_variants_file.xml"));
        }
Пример #5
0
        void test_RouteSegment()
        {
            Prepare.ReloadGlobalSydb(".//input//Routes_fromHHHT2.xml");
            {
                var          sydbroute = sydb.routeInfoList.Find(x => x.ID == 224);//this route has no points
                RouteSegment newr      = new RouteSegment(sydbroute);
                Debug.Assert(newr.m_PtLst.Count == 0);
            }

            {                                                                       //check length for oginal route
                var          sydbroute = sydb.routeInfoList.Find(x => x.ID == 231); //this route has points
                RouteSegment newr      = new RouteSegment(sydbroute);

                List <string> pnames = new List <string>()
                {
                    "P01D-N","P07D-R","P09D-R"
                };                              //the pts in route 231
                int i = 0;
                foreach (var p in newr.m_PtLst) //check for route get points info
                {
                    Debug.Assert(pnames[i] == p.getNamePosStr());
                    ++i;
                }
                Debug.Assert((626856 - 615248 + 41374 - 26856) == newr.GetLength());
            }

            {                                                                            //check length for the splitted routes
                var            sydbroute    = sydb.routeInfoList.Find(x => x.ID == 183); //this route has Spacing_Signal_ID_List
                RouteSegConfig SyDBRouteCfg = new RouteSegConfig(sydb);
                clearlist(SyDBRouteCfg);
                SyDBRouteCfg.splitRoute(sydbroute);
                SyDBRouteCfg.m_RouteSpacing_routeLst.AddRange(SyDBRouteCfg.m_Spacing_routeLst);
                int[] lengths = { 1170639 - 906 - (1058617 - 747),1058617 - 747 - (1041880 - 747),(1041880 - 747) - (963697 + 176) };//length for the splitted route
                int   i       = 0;
                foreach (var r in SyDBRouteCfg.m_RouteSpacing_routeLst)
                {
                    Debug.Assert(lengths [i] == r.GetLength());
                    ++i;
                }
            }
        }
Пример #6
0
        void test_splitRoute()
        {
            Prepare.ReloadGlobalSydb(".//input//Routes_fromHHHT2.xml");
            RouteSegConfig SyDBRouteCfg = new RouteSegConfig(sydb);

            Debug.Assert(false == SyDBRouteCfg.splitRoute(null));

            int[] rids = { 183,161,66,76,231 }; //these route has Spacing_Signal_ID_List, 231 has no Spacing_Signal_ID_List also can be test by this
            foreach (int id in rids)
            {                                   //test blockinfo of route has Spacing_Signal_ID_List
                clearlist(SyDBRouteCfg);
                var sydbroute = sydb.routeInfoList.Find(x => x.ID == id);

                Debug.Assert(true == SyDBRouteCfg.splitRoute(sydbroute));

                Debug.Assert(SyDBRouteCfg.m_RouteSpacing_routeLst[0].m_OrgSig.ID == sydbroute.Origin_Signal_ID);         //get RouteSpacing_route start with same sig as 183
                Debug.Assert(SyDBRouteCfg.m_Spacing_routeLst.Count == sydbroute.Spacing_Signal_ID_List.Signal_ID.Count); //get some Spacing_route

                List <StringData> blocks = new List <StringData>();
                SyDBRouteCfg.m_Spacing_routeLst.AddRange(SyDBRouteCfg.m_RouteSpacing_routeLst);
                foreach (var r in SyDBRouteCfg.m_Spacing_routeLst)
                {
                    foreach (var b in r.m_BlkLst)
                    {
                        blocks.Add(b.ID);
                    }
                }

                Debug.Assert(sydbroute.Block_ID_List.Block_ID.All(blocks.Contains));//add all split route blocks == orinal route blocks
            }

            {                                                                                                    //test pointlist of route has no Spacing_Signal_ID_List
                clearlist(SyDBRouteCfg);
                var sydbroute = sydb.routeInfoList.Find(x => x.ID == 231);                                       //this route has no Spacing_Signal_ID_List
                Debug.Assert(true == SyDBRouteCfg.splitRoute(sydbroute));
                Debug.Assert(SyDBRouteCfg.m_RouteSpacing_routeLst[0].m_OrgSig.ID == sydbroute.Origin_Signal_ID); //get RouteSpacing_route same as 231
                GENERIC_SYSTEM_PARAMETERS.SIGNALS.SIGNAL dstsig = (GENERIC_SYSTEM_PARAMETERS.SIGNALS.SIGNAL)MethodHelper.InvokePrivateMember(SyDBRouteCfg.m_RouteSpacing_routeLst[0],"DstSig");
                Debug.Assert(dstsig.ID == sydbroute.Destination_Signal_ID);
                Debug.Assert(SyDBRouteCfg.m_Spacing_routeLst.Count == 0);//get no Spacing_route
            }
        }
Пример #7
0
        void test_generateRouteSegments()
        {
            Prepare.ReloadGlobalSydb(".//input//Routes_fromHHHT2.xml");
            RouteSegConfig SyDBRouteCfg = new RouteSegConfig(sydb);//this will call RouteSegConfig.generateRouteSegments()

            Debug.Assert(true == SyDBRouteCfg.generateRouteSegments());

            int count      = 0;
            int splitcount = 0;

            foreach (var r in sydb.routeInfoList)
            {
                if (r.IsValidBMRoute())
                {
                    RouteSegment route = SyDBRouteCfg.m_RouteSpacing_routeLst.Find(x => x.m_OrgSig.ID == r.Origin_Signal_ID && x.RouteInfo().ID == r.ID);
                    Debug.Assert(null != route);
                    ++count;
                    splitcount = splitcount + r.Spacing_Signal_ID_List.Signal_ID.Count;
                    foreach (int id in r.Spacing_Signal_ID_List.Signal_ID)
                    {
                        route = SyDBRouteCfg.m_Spacing_routeLst.Find(x => x.m_OrgSig.ID == id && x.RouteInfo().ID == r.ID);
                        Debug.Assert(null != route);
                    }


                    route.CalOverlap(null);

                    GENERIC_SYSTEM_PARAMETERS.SIGNALS.SIGNAL dstsig = (GENERIC_SYSTEM_PARAMETERS.SIGNALS.SIGNAL)MethodHelper.InvokePrivateMember(route,"DstSig");
                    if (null != dstsig.Overlap_ID)
                    {
                        Debug.Assert(null != route.m_overlap);
                    }
                    else
                    {
                        Debug.Assert(null == route.m_overlap);
                    }
                }
            }
            Debug.Assert(count == SyDBRouteCfg.m_RouteSpacing_routeLst.Count());
            Debug.Assert(splitcount == SyDBRouteCfg.m_Spacing_routeLst.Count());
        }
Пример #8
0
        void test_RouteSegmentLenVariantPts()
        {
            Prepare.ReloadGlobalSydb(".//input//RouteLength_fromTestLine.xml");
            Dictionary <int, int[]> routes = new Dictionary <int, int[]>()
            {
                //id                //ptnum     //length
                { 234, new int[] { 13, 451833 - 393833 + 600100 - 592163 + 611317 - 606247 + 4000 + 626856 - 611317 + 632996 - 626856 + 961697 - 632996 } },
                { 233, new int[] { 8, 451833 - 393833 + 600100 - 592163 + 611317 - 606247 + 4000 + 626856 - 611317 + 632996 - 626856 + 641374 - 632996 } },
                { 50, new int[] { 5, 451833 - 446833 + 604100 - 592163 + 641374 - 605177 } },
                { 400, new int[] { 0, 1197376 - 1115639 + 240000 } },
                { 401, new int[] { 0, 1197376 - 1115639 + 240000 } },
                { 402, new int[] { 0, 1197376 - 1115639 + 240000 } },
                { 403, new int[] { 0, 1197376 - 1115639 + 240000 } },
                { 404, new int[] { 0, 1197376 - 1115639 + 240000 } },
                { 405, new int[] { 0, 1197376 - 1115639 + 240000 } },
                { 445, new int[] { 2, 1035200 - 1000000 } },
                { 61, new int[] { 2, 613473 - 842 - 485281 } },
                { 66, new int[] { 2, 613473 - 842 - 485281 } },
            };

            Dictionary <string, string[]> pts = new Dictionary <string, string[]>()
            {
                //NAME                       //ORIEN
                { "P02D", new string[] { Sys.Divergent } },
                { "P20D", new string[] { Sys.Divergent } },
                { "P08D", new string[] { Sys.Convergent } },
                { "P21D", new string[] { Sys.Convergent } },
                { "P10D", new string[] { Sys.Convergent } },
                { "P14D", new string[] { Sys.Convergent } },
                { "P09D", new string[] { Sys.Divergent } },
                { "P07D", new string[] { Sys.Convergent } },
                { "P01D", new string[] { Sys.Convergent } },
                { "P16D", new string[] { Sys.Divergent } },
                { "P18D", new string[] { Sys.Convergent } },
                { "P02E", new string[] { Sys.Divergent } },
                { "P20E", new string[] { Sys.Convergent } },
                { "P01E", new string[] { Sys.Convergent } },
                { "P08B", new string[] { Sys.Divergent } },
                { "P02B", new string[] { Sys.Convergent } },
                { "P12D", new string[] { Sys.Convergent } },
                { "P06D", new string[] { Sys.Divergent } },
            };

            haschecked = false;
            foreach (var r in sydb.routeInfoList)
            {
                RouteSegment route = new RouteSegment(r);

                if (route.GetPointLstFromBlkLst() == false)
                {
                    haschecked = true;
                }

                foreach (var pt in route.m_PtLst)
                {
                    Debug.Assert(pts[pt.Point.Name][0] == pt.Orientation);
                }

                List <Variant> vlist = new List <Variant>();
                Debug.Assert(route.CalVariants(vlist, false) == true);
                Debug.Assert(vlist.Count == routes[(int)(r.ID)][0] * 2);

                Debug.Assert(route.GetLength() == routes[(int)(r.ID)][1]);
            }

            Debug.Assert(haschecked == true);//if the route of pt more than 10, retur false
        }