示例#1
0
        /// <summary>
        /// test if generate the beacon default message files
        /// </summary>
        void test_Generate()
        {
            BFGen bfgen = new BFGen("", "", "", false, false);
            {
                string xml = ".//input//validbeacons.xml";
                Debug.Assert(false == bfgen.Generate(".\\output"));
                Debug.Assert(false == checkbeaconfiles(".\\output", false));

                bfgen = new BFGen("", xml, "", false, false);
                Debug.Assert(true == bfgen.Generate(".\\output"));
                Debug.Assert(true == checkbeaconfiles(".\\output", false));
            }

            {
                string csv = ".//input//validbeacons.csv";
                bfgen = new BFGen(csv, "", "", false, true);//lack bin generate tool so rt false
                Debug.Assert(false == bfgen.Generate(".\\output"));
                Debug.Assert(false == checkbeaconfiles(".\\output", true));
                //here error. beacon which is outof range can raise error info, but data still in the list

                bfgen = new BFGen(csv, "", ".\\compiler\\CompilerBaliseV4000\\main\\compile.exe", false, true);
                Debug.Assert(true == bfgen.Generate(".\\output"));
                Debug.Assert(true == checkbeaconfiles(".\\output", false));
            }
        }
示例#2
0
        /// <summary>
        /// test generate default message of VB and FB from csv and xml
        /// </summary>
        public void test_DefaultGenerateMessage()
        {
            BeaconMessage bm = new BeaconMessage();

            Debug.Assert("" == bm.GenerateMessage(null, 1));

            //Arrange
            string csv   = ".//input//validbeacons.csv";
            string xml   = ".//input//validbeacons.xml";
            BFGen  bfgen = new BFGen(csv, xml, "", false, false);

            Debug.Assert(bfgen.Init() == true);
            SyDB sydb = SyDB.GetInstance();

            int[] lineids = { 0, 1, 0x3ff };
            int   i       = 0;

            foreach (IBeaconInfo b in sydb.GetBeacons())
            {
                //Act
                BeaconMessage bm1    = new BeaconMessage();
                int           lineid = lineids[i % (lineids.Count())];
                checkbeaconmessage(b, bm1.GenerateMessage(b, lineid), lineid);
                ++i;
            }
            Debug.Assert(i == 12);
        }
示例#3
0
        public void test_GenrateDeviceByIBBM()
        {
            //Arrange
            sydb.clear();
            List <LEU>    leulist = new List <LEU>();
            List <BEACON> blist   = new List <BEACON>();

            BMVFGen bvf = new BMVFGen(false, ref blist, ref leulist);  // initial

            //Act Assert
            Debug.Assert(false == bvf.GenrateDeviceByIBBM());

            //Arrange
            BFGen bf = new BFGen(".//input//validbeacons.csv", "", "", false, false);

            bf.Init();

            List <string> validleunames = new List <string>()
            {
                "E1D", "E2D", "E3D", "E1C", "E3D2", "E2D2", "E2D3", "E2C1", "E2C7"
            };

            GENERIC_SYSTEM_PARAMETERS.IMPLEMENTATION_BEACON_BLOCK_MODE ibbms = FileLoader.Load <GENERIC_SYSTEM_PARAMETERS.IMPLEMENTATION_BEACON_BLOCK_MODE>(".//input//IBBM.xml");
            sydb.ibbmInfoList.Clear();
            sydb.ibbmInfoList = ibbms.BM_Beacon;  // read all IBBM beacons

            //Act
            Debug.Assert(true == bvf.GenrateDeviceByIBBM());
            //Assert

            foreach (IBeaconInfo b in sydb.GetBeacons())
            {
                if (b.IsVariantBeacon() == true)
                {
                    Debug.Assert(blist.Exists(x => x.Name == b.Name));
                }
                else
                {
                    Debug.Assert(false == blist.Exists(x => x.Name == b.Name));
                }
            }

            leulist.ForEach(Print);

            Debug.Assert(validleunames.Count == leulist.Count());
            int leuid = 1;

            foreach (LEU l in leulist)
            {
                Debug.Assert(leuid == l.ID);
                Debug.Assert(l.Name == validleunames[leuid - 1]);
                ++leuid;
            }
        }
示例#4
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
        }
示例#5
0
        void RunBFGenInit(object obj)
        {
            BFGen bfgen = new BFGen("", beaconxmlfullname, "", false, false);

            bfgen.Init();
            if (obj != null)
            {
                int BMB_SDDB_distance_cm = (int)(obj);

                SyDB sydb             = SyDB.GetInstance();
                List <IBeaconInfo> bs = sydb.GetBeacons();

                Debug.Assert(bs[0].BMB_Distance_cm == BMB_SDDB_distance_cm);
            }
        }
示例#6
0
        //check read csv file, only right range beacon will read in
        //check read xml file
        //check repeat beacon id or repeat beacon name will be ignore
        void test_BFGenIni()
        {
            //Arrange
            Func <int, bool> checkbeaconnumber = (num) =>
            {
                SyDB sydb             = SyDB.GetInstance();
                List <IBeaconInfo> bs = sydb.GetBeacons();
                Debug.Assert(bs.Count == num);//only read the valid beacons
                return(true);
            };

            Func <int, int[], bool> checkbeaconkps = (num, kps) =>
            {
                SyDB sydb             = SyDB.GetInstance();
                List <IBeaconInfo> bs = sydb.GetBeacons();
                Debug.Assert(bs.Count == num);//only read the valid beacons

                for (int i = 0; i < kps.Length; ++i)
                {
                    Debug.Assert(bs[i].kp.Value == kps[i]);
                }
                return(true);
            };

            string csv = ".//input//beacons.csv";
            string xml = ".//input//beacons.xml";
            //Arrange of wrong file type
            BFGen bfgen = new BFGen(xml, csv, "", false, false);

            //Act   Assert
            Debug.Assert(bfgen.Init() == false);

            //no file
            bfgen = new BFGen("", "", "", false, false);
            Debug.Assert(bfgen.Init() == false);

            //csv: input data valid range
            bfgen = new BFGen(csv, "", "", false, false);
            Debug.Assert(bfgen.Init() == true);
            int[] kpscsv = { 0, 10000000, 9999900, 9999910, 9999992, 9999992, 0, 10000000, 9999900, 9999910, 9999992, 9999992 }; //valid beacon kps from csv
            checkbeaconkps(21, kpscsv);

            //csv and xml beacon repeated
            bfgen = new BFGen(csv, xml, "", false, false);
            Debug.Assert(bfgen.Init() == true);
            //delete the beacon of same name and same ID
            checkbeaconnumber(24);
        }
示例#7
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"));
        }
示例#8
0
        private void Generate()
        {
            try
            {
                beaconList.Clear();
                leuList.Clear();
                SyDB.GetInstance().clear();

                if (false == clearOutputDir())
                {
                    return;
                }
                //log is updating
                {
                    IDataGen.toolVer = this.Text;
                    GENERIC_SYSTEM_PARAMETERS sydb = FileLoader.Load <GENERIC_SYSTEM_PARAMETERS>(this.textBoxSyDB.Text);
                    SyDB.GetInstance().LoadData(sydb);

                    IDataGen.sydbFile = this.textBoxSyDB.Text;//todo will delete
                }

                {
                    IDataGen gen         = null;
                    string   compilepath = currentRunDir + "\\compiler\\CompilerBaliseV4000\\main\\compile.exe";
                    gen = new BFGen(this.textBoxLayout.Text, this.textBoxBoundaryBeacon.Text, compilepath, this.radioButtoniTC.Checked, this.checkBoxGenBin.Checked);
                    ((BFGen)gen).genPro += new BFGen.GenProess(GenProess);
                    if (false == gen.Generate(this.textBoxOutput.Text))
                    {
                        return;
                    }
                }

                {
                    IDataGen gen = null;
                    gen = new BMVFGen(this.radioButtoniTC.Checked && this.Upstream_path_considered.Checked,
                                      ref beaconList,
                                      ref leuList,
                                      this.textBox_UpstreamFile.Text);

                    if (false == gen.Generate(this.textBoxOutput.Text))
                    {
                        return;
                    }
                }

                {
                    IDataGen gen = null;
                    gen = new LEURFGen(ref beaconList, ref leuList);
                    if (false == gen.Generate(this.textBoxOutput.Text))
                    {
                        return;
                    }
                }

                {
                    IDataGen gen       = null;
                    string   LEURFFile = this.textBoxOutput.Text + "\\LEU\\LEU_Result_Filtered_Values.xml";

                    gen = new LEUXmlGen(leuList, LEURFFile, currentRunDir, this.radioButtoniTC.Checked, this.checkBoxGenBin.Checked);
                    ((LEUXmlGen)gen).genPro += new LEUXmlGen.GenProess(GenProess);
                    if (false == gen.Generate(this.textBoxOutput.Text))
                    {
                        return;
                    }
                }
            }
            finally
            {
                IsBusy = false;
            }
        }
示例#9
0
 public static bool Init(this BFGen instance)
 {
     return((bool)MethodHelper.InvokePrivateMethod <BFGen>(instance, "Init"));  // read csv correctly.
 }