Exemplo n.º 1
0
        static void dev_OnReceiveText(object sender, TextPackage txtObj)
        {
            try
            {
                if (txtObj.Text[0] == 0x02 && txtObj.Text[1] == 0x30 || txtObj.Text[0] == 0x02 && txtObj.Text[1] == 0x31)
                {

                   // Console.WriteLine("[" + string.Format("{0:X2}", txtObj.Text[0]) + " " + string.Format("{0:X2}", txtObj.Text[1]) + "],"+txtObj.Text.Length);
                 //   Console.WriteLine(V2DLE.ToHexString(txtObj.Text));

                    UBIDBase idbase = new GPSDevice.GPSMessage.UBIDBase(txtObj.Text);
                    Console.WriteLine(idbase.ToString());
                    if (Matrix != null)
                    {
                        int svid =(int) idbase[1];

                        if (idbase.GetMessageID() == 0x0230)  //alm
                        {
                            //for (int i = 0; i < 8; i++)
                            //    Matrix[svid - 1, i] = (uint)idbase[3 + i];
                            Matrix[svid - 1, 0] = idbase.alm_Eccentricity;
                            Matrix[svid - 1, 1] = idbase.alm_toa;
                            Matrix[svid - 1, 2] = idbase.alm_delti;
                            Matrix[svid - 1, 3] = idbase.alm_omegadot;
                            Matrix[svid - 1, 4] = idbase.alm_sqrtA;
                            Matrix[svid - 1, 5] = idbase.alm_omega0;
                            Matrix[svid - 1, 6] = idbase.alm_w;
                            Matrix[svid - 1, 7] = idbase.alm_mean0;
                            Matrix[svid - 1, 8] = idbase.alm_af0;
                            Matrix[svid - 1, 9] = idbase.alm_af1;
                            Console.WriteLine("Eccentricity=" + idbase.alm_Eccentricity);
                            Console.WriteLine("toa=" + idbase.alm_toa);
                            Console.WriteLine("delti=" + idbase.alm_delti);
                            Console.WriteLine("omegadot=" + idbase.alm_omegadot);
                            Console.WriteLine("sqrtA=" + idbase.alm_sqrtA);
                            Console.WriteLine("omega0=" + idbase.alm_omega0);
                            Console.WriteLine("w=" + idbase.alm_w);
                            Console.WriteLine("mean0=" + idbase.alm_mean0);
                            Console.WriteLine("af0=" + idbase.alm_af0);
                            Console.WriteLine("af1=" + idbase.alm_af1);

                            Console.WriteLine("=============================");
                        }

                        if (idbase.GetMessageID() == 0x0231)  //eph
                        {
                            //for (int i = 0; i < 24; i++)
                            //{
                                // fill eph here
                                //Matrix[svid - 1, 8 + i] = (uint)idbase[3 + i];
                                Matrix[svid-1,10]=idbase.eph_toc;
                                Matrix[svid - 1, 11] = idbase.eph_af2;
                                Matrix[svid - 1, 12] = idbase.eph_af1;
                                Matrix[svid - 1, 13] = idbase.eph_af0;
                                Matrix[svid - 1, 14] = idbase.eph_crs;
                                Matrix[svid - 1, 15] = idbase.eph_deltan;
                                Matrix[svid - 1, 16] = idbase.eph_m0;
                                Matrix[svid - 1, 17] = idbase.eph_cuc;
                                Matrix[svid - 1, 18] = idbase.eph_e;
                                Matrix[svid - 1, 19] = idbase.eph_cus;
                                Matrix[svid - 1, 20] = idbase.eph_sqrtA;
                                Matrix[svid - 1, 21] = idbase.eph_toe;
                                Matrix[svid - 1, 22] = idbase.eph_cic;
                                Matrix[svid - 1, 23] = idbase.eph_w0;
                                Matrix[svid - 1, 24] = idbase.eph_cis;
                                Matrix[svid - 1, 25] = idbase.eph_i0;
                                Matrix[svid - 1, 26] = idbase.eph_crc;
                                Matrix[svid - 1, 27] = idbase.eph_w;
                                Matrix[svid - 1, 28] = idbase.eph_wdot;
                                Matrix[svid - 1, 29] = idbase.eph_idot;
                                Console.WriteLine("eph_toc="+ idbase.eph_toc);
                                Console.WriteLine("eph_af2=" + idbase.eph_af2);
                                Console.WriteLine("eph_af1=" + idbase.eph_af1);
                                Console.WriteLine("eph_af0=" + idbase.eph_af0);
                                Console.WriteLine("eph_crs=" + idbase.eph_crs);
                                Console.WriteLine("eph_deltan=" + idbase.eph_deltan);
                                Console.WriteLine("eph_m0=" + idbase.eph_m0);
                                Console.WriteLine("eph_cuc=" + idbase.eph_cuc);
                                Console.WriteLine("eph_e=" + idbase.eph_e);
                                Console.WriteLine("eph_cus=" + idbase.eph_cus);
                                Console.WriteLine("eph_sqrtA=" + idbase.eph_sqrtA);
                                Console.WriteLine("eph_toe=" + idbase.eph_toe);
                                Console.WriteLine("eph_cic=" + idbase.eph_cic);
                                Console.WriteLine("eph_w0=" + idbase.eph_w0);
                                Console.WriteLine("eph_cis=" + idbase.eph_cis);
                                Console.WriteLine("eph_i0=" + idbase.eph_i0);
                                Console.WriteLine("eph_crc=" + idbase.eph_crc);
                                Console.WriteLine("eph_w=" + idbase.eph_w);
                                Console.WriteLine("eph_wdot=" + idbase.eph_wdot);
                                Console.WriteLine("eph_idot=" + idbase.eph_idot);
                                double[] xyz = idbase.eph_xyz(0);
                                Console.WriteLine("x:{0} y:{1} z:{2}", xyz[0], xyz[1], xyz[2]);

                                Console.WriteLine("=============================");
                                if (!idbase.IsValid)
                                    for (int j = 0; j < 10; j++)
                                        Matrix[svid - 1, j] = 0;
                            //}

                            if (svid == 32) // print matrix
                            {

                                string str = "[\r\n";
                                for (int row = 0; row < 32; row++)
                                {

                                    for (int col = 0; col < 30 ; col++)  // for alm only
                                       str+=Matrix[row, col] + ",";

                                    str = str.TrimEnd(",".ToCharArray())+";" + "\r\n";

                                }
                                str = str.TrimEnd(",".ToCharArray()) + "]\r\n";

                                Console.Write(str);
                                System.IO.File.AppendAllText("log.txt", str);
                                //Write File Here

                                Console.WriteLine();

                            }

                        }

                    }

                    if (idbase.GetMessageID() == 0x0231 && (int)idbase[1] == 32)
                        Matrix = new double[32, 30];
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + "," + ex.StackTrace);
            }
            //throw new NotImplementedException();
        }
Exemplo n.º 2
0
        public override void sensorDev_OnReceiveText(object sender, TextPackage txtObj)
        {
            if (txtObj.Text[0] == 0x02 && txtObj.Text[1] == 0x31)  //eph data
            {

                UBIDBase idbase = new UBIDBase(txtObj.Text);
                if (++eph_cnt >= 32)
                    eph_cnt = 32;

                if (idbase == null)
                    return;
                eph_datas[idbase.svid - 1] = idbase;
                Console.WriteLine(this.SensorName+" svid:" + idbase.svid+" "+ idbase.IsValid);
                //if (idbase.IsValid)
                //{
                //    eph_datas[idbase.svid - 1] = idbase;
                //    // double[] xyz=idbase.eph_xyz(0);
                //    //   Console.WriteLine("svid={0} x:{1} y:{2} z:{3} at t=0", idbase.svid,xyz[0], xyz[1], xyz[2]);
                //}
                //else
                //    eph_datas[idbase.svid - 1] = null;

            }
            else if (txtObj.Text[0] == 0x01 && txtObj.Text[1] == 0x22)
            {
                //Console.WriteLine("01 22");

                UBIDBase idbase = new UBIDBase(txtObj.Text);
            //    Console.WriteLine("0x01 0x22, itow=" + System.Convert.ToInt32(idbase["itow"] / 1000.0));
                idbase0122 = idbase;
                //   Console.WriteLine(idbase0122.ToString());
            }
            else if (txtObj.Text[0] == 0x02 && txtObj.Text[1] == 0x20)
            {
                UBIDBase idbase = new UBIDBase(txtObj.Text);
               //     Console.WriteLine("0x02 0x20, itow=" + System.Convert.ToInt32(idbase["itow"] / 1000.0));
                idbase0220 = idbase;
                PrepareGPSDataMatrix();
                // Console.WriteLine(idbase0220.ToString());
            }
            else if (txtObj.Text[0] == 0x02 && txtObj.Text[1] == 0x10)
            {
                UBIDBase idbase = new UBIDBase(txtObj.Text);
                idbase0210 = idbase;
               // Console.WriteLine("0x02 0x10, itow=" + System.Convert.ToInt32(idbase["itow"] / 1000.0));
             //   Console.WriteLine(idbase0210.ToString());
            }
            else if (txtObj.Text[0] == 0x01 && txtObj.Text[1] == 0x32)
            {
                UBIDBase idbase = new UBIDBase(txtObj.Text);
                idbase0132 = idbase;
               // Console.WriteLine("0x01 0x32, itow=" + idbase.itow);
             //   Console.WriteLine(idbase0132.ToString());
            }
            else if (txtObj.Text[0] == 0x01 && txtObj.Text[1] == 0x01)
            {
                UBIDBase idbase = new UBIDBase(txtObj.Text);
                idbase0101 = idbase;
              //  Console.WriteLine("0x01 0x01, itow=" + idbase.itow);

            }
            else if (txtObj.Text[0] == 0x02 && txtObj.Text[1] == 0x30)
            {
                // dummy
            }
            else
            {
                UBIDBase idbase = new UBIDBase(txtObj.Text);
                Console.WriteLine("unknow id {0:X4}", idbase.GetMessageID());
            }
        }