public Form1()
 {
     InitializeComponent();
     
     ob<Control>.setup(button1);
     ob1 = new ob<Control>(1, true);
     ob2 = new ob<Control>(2, false);
     ob3 = new ob<Control>(3, false);
 }
Exemplo n.º 2
0
            public void Read(byte[] buffer)
            {
                uint i = 24;

                u32 type = getbitu(buffer, i, 12); i += 12;

                u32 staid = getbitu(buffer, i, 12); i += 12;
                double tow = getbitu(buffer, i, 30) * 0.001; i += 30;
                u32 sync = getbitu(buffer, i, 1); i += 1;
                u32 nsat = getbitu(buffer, i, 5); i += 5;

                i = 24 + 64;

                int week = 0;
                double seconds = 0;

                // asumes current week
                StaticUtils.GetFromTime(DateTime.Now, ref week, ref seconds);

                // if tow is larger than the calced curretn time, go back one week
                if (tow > seconds)
                    week--;

                DateTime gpstime = StaticUtils.GetFromGps(week, tow);

                Console.WriteLine("> {0} {1} {2} {3,2} {4} {5} {6} {7}", gpstime.Year, gpstime.Month, gpstime.Day, gpstime.Hour, gpstime.Minute, gpstime.Second + (gpstime.Millisecond / 1000.0), 0, nsat);

                for (int a = 0; a < nsat; a++)
                {
                    ob ob = new ob();

                    ob.tow = tow;
                    ob.week = week;

                    ob.raw.prn = (byte)getbitu(buffer, i, 6); i += 6;
                    ob.raw.code1 = (byte)getbitu(buffer, i, 1); i += 1;
                    ob.raw.pr1 = getbitu(buffer, i, 24); i += 24;
                    ob.raw.ppr1 = getbits(buffer, i, 20); i += 20;
                    ob.raw.lock1 = (byte)getbitu(buffer, i, 7); i += 7;
                    ob.raw.amb = (byte)getbitu(buffer, i, 8); i += 8;
                    ob.raw.cnr1 = (byte)getbitu(buffer, i, 8); i += 8;
                    ob.raw.code2 = (byte)getbitu(buffer, i, 2); i += 2;
                    ob.raw.pr21 = getbits(buffer, i, 14); i += 14;
                    ob.raw.ppr2 = getbits(buffer, i, 20); i += 20;
                    ob.raw.lock2 = (byte)getbitu(buffer, i, 7); i += 7;
                    ob.raw.cnr2 = (byte)getbitu(buffer, i, 8); i += 8;

                    double pr1 = ob.raw.pr1 * 0.02 + ob.raw.amb * PRUNIT_GPS;

                    double lam1 = CLIGHT / FREQ1;

                    double cp1 = ob.raw.ppr1 * 0.0005 / lam1;

                    if ((uint)ob.raw.ppr1 != 0xFFF80000)
                    {
                        double ce = ob.raw.pr1 * 0.02;
                        double le = ob.raw.pr1 * 0.02 + ob.raw.ppr1 * 0.0005;

                        ce += ob.raw.amb * PRUNIT_GPS;
                        le += ob.raw.amb * PRUNIT_GPS;

                        le /= lam1;

                        ob.prn = ob.raw.prn;
                        ob.cp = le;// pr1 / lam1 + cp1;
                        ob.pr = ce;// pr1;
                        ob.snr = (byte)(ob.raw.cnr1 * 0.25); // *4.0+0.5

                        double l2range = ob.raw.pr1 * 0.02 + ob.raw.pr21 * 0.02 + ob.raw.amb * PRUNIT_GPS; 

                        obs.Add(ob);

                        Console.WriteLine("G{0,2} {1,13} {2,16} {3,30}", ob.prn.ToString(), ob.pr.ToString("0.000"), ob.cp.ToString("0.0000"), ob.snr.ToString("0.000"));
                    }
                }

                nbits = i;
            }
Exemplo n.º 3
0
            public void Read(byte[] buffer)
            {
                uint i = 24;

                u32 type = getbitu(buffer, i, 12); i += 12;

                u32    staid = getbitu(buffer, i, 12); i += 12;
                double tow   = getbitu(buffer, i, 30) * 0.001; i += 30;
                u32    sync  = getbitu(buffer, i, 1); i += 1;
                u32    nsat  = getbitu(buffer, i, 5); i += 5;

                i = 24 + 64;

                int    week    = 0;
                double seconds = 0;

                // asumes current week
                StaticUtils.GetFromTime(DateTime.Now, ref week, ref seconds);

                // if tow is larger than the calced curretn time, go back one week
                if (tow > seconds)
                {
                    week--;
                }

                DateTime gpstime = StaticUtils.GetFromGps(week, tow);

                Console.WriteLine("> {0} {1} {2} {3,2} {4} {5} {6} {7}", gpstime.Year, gpstime.Month, gpstime.Day, gpstime.Hour, gpstime.Minute, gpstime.Second + (gpstime.Millisecond / 1000.0), 0, nsat);

                for (int a = 0; a < nsat; a++)
                {
                    ob ob = new ob();

                    ob.tow  = tow;
                    ob.week = week;

                    ob.raw.prn   = (byte)getbitu(buffer, i, 6); i += 6;
                    ob.raw.code1 = (byte)getbitu(buffer, i, 1); i += 1;
                    ob.raw.pr1   = getbitu(buffer, i, 24); i += 24;
                    ob.raw.ppr1  = getbits(buffer, i, 20); i += 20;
                    ob.raw.lock1 = (byte)getbitu(buffer, i, 7); i += 7;
                    ob.raw.amb   = (byte)getbitu(buffer, i, 8); i += 8;
                    ob.raw.cnr1  = (byte)getbitu(buffer, i, 8); i += 8;
                    ob.raw.code2 = (byte)getbitu(buffer, i, 2); i += 2;
                    ob.raw.pr21  = getbits(buffer, i, 14); i += 14;
                    ob.raw.ppr2  = getbits(buffer, i, 20); i += 20;
                    ob.raw.lock2 = (byte)getbitu(buffer, i, 7); i += 7;
                    ob.raw.cnr2  = (byte)getbitu(buffer, i, 8); i += 8;

                    double pr1 = ob.raw.pr1 * 0.02 + ob.raw.amb * PRUNIT_GPS;

                    double lam1 = CLIGHT / FREQ1;

                    double cp1 = ob.raw.ppr1 * 0.0005 / lam1;

                    if ((uint)ob.raw.ppr1 != 0xFFF80000)
                    {
                        double ce = ob.raw.pr1 * 0.02;
                        double le = ob.raw.pr1 * 0.02 + ob.raw.ppr1 * 0.0005;

                        ce += ob.raw.amb * PRUNIT_GPS;
                        le += ob.raw.amb * PRUNIT_GPS;

                        le /= lam1;

                        ob.prn = ob.raw.prn;
                        ob.cp  = le;                         // pr1 / lam1 + cp1;
                        ob.pr  = ce;                         // pr1;
                        ob.snr = (byte)(ob.raw.cnr1 * 0.25); // *4.0+0.5

                        double l2range = ob.raw.pr1 * 0.02 + ob.raw.pr21 * 0.02 + ob.raw.amb * PRUNIT_GPS;

                        obs.Add(ob);

                        Console.WriteLine("G{0,2} {1,13} {2,16} {3,30}", ob.prn.ToString(), ob.pr.ToString("0.000"), ob.cp.ToString("0.0000"), ob.snr.ToString("0.000"));
                    }
                }

                nbits = i;
            }