Ejemplo n.º 1
0
 public poloha()
 {
     this.Sirka   = 0;
     this.Delka   = 0;
     this.Sever   = false;
     this.Vychod  = false;
     this.Kvalita = kvalitaSignaluGPS.NeurcenaPozice;
 }
Ejemplo n.º 2
0
 public poloha(string Retezec)                                             // vstupní formáty 4912.2526N 01635.0378E a N4912.2526 E01635.0378
 {
     if (Retezec.Substring(0, 1) == "N" || Retezec.Substring(0, 1) == "S") //
     {
         this.Sirka  = double.Parse(Retezec.Substring(1, Retezec.IndexOf(" ") - 1).Replace(".", ","));
         this.Sever  = (Retezec.Substring(0, 1)) == "N";
         Retezec     = Retezec.Substring(Retezec.IndexOf(" ") + 1);
         this.Vychod = (Retezec.Substring(0, 1)) == "E";
         Retezec     = Retezec.Substring(1);
         this.Delka  = double.Parse(Retezec.Substring(1).Replace(".", ","));
     }
     else
     {
         this.Sirka  = double.Parse(Retezec.Substring(0, Retezec.IndexOf(" ") - 1).Replace(".", ","));
         this.Sever  = (Retezec.Substring(Retezec.IndexOf(" ") - 1, 1)) == "N";
         Retezec     = Retezec.Substring(Retezec.IndexOf(" ") + 1, Retezec.Length - (Retezec.IndexOf(" ") + 1));
         this.Delka  = double.Parse(Retezec.Substring(0, Retezec.Length - 1).Replace(".", ","));
         this.Vychod = (Retezec.Substring(Retezec.Length - 1, 1)) == "E";
     }
     this.Kvalita = kvalitaSignaluGPS.ZjistenaPozice;
 }
Ejemplo n.º 3
0
 // vstupní formáty 4912.2526N 01635.0378E a N4912.2526 E01635.0378
 public poloha(string Retezec)
 {
     if (Retezec.Substring(0, 1) == "N" || Retezec.Substring(0, 1) == "S") //
     {
         this.Sirka = double.Parse(Retezec.Substring(1, Retezec.IndexOf(" ") - 1).Replace(".", ","));
         this.Sever = (Retezec.Substring(0, 1)) == "N";
         Retezec = Retezec.Substring(Retezec.IndexOf(" ") + 1);
         this.Vychod = (Retezec.Substring(0, 1)) == "E";
         Retezec = Retezec.Substring(1);
         this.Delka = double.Parse(Retezec.Substring(1).Replace(".", ","));
     }
     else
     {
         this.Sirka = double.Parse(Retezec.Substring(0, Retezec.IndexOf(" ") - 1).Replace(".", ","));
         this.Sever = (Retezec.Substring(Retezec.IndexOf(" ") - 1, 1)) == "N";
         Retezec = Retezec.Substring(Retezec.IndexOf(" ") + 1, Retezec.Length - (Retezec.IndexOf(" ") + 1));
         this.Delka = double.Parse(Retezec.Substring(0, Retezec.Length - 1).Replace(".", ","));
         this.Vychod = (Retezec.Substring(Retezec.Length - 1, 1)) == "E";
     }
     this.Kvalita = kvalitaSignaluGPS.ZjistenaPozice;
 }
Ejemplo n.º 4
0
 public poloha()
 {
     this.Sirka = 0;
     this.Delka = 0;
     this.Sever = false;
     this.Vychod = false;
     this.Kvalita = kvalitaSignaluGPS.NeurcenaPozice;
 }
Ejemplo n.º 5
0
    void VlaknoCteniGPS()
    {
        StreamWriter GPSSoubor = new StreamWriter("GPS.txt", true);
        string Radek = "";
        while (!StopVlaknoGPS)
        {
            try
            {
                Radek = GPSPort.ReadLine();
            }
            catch (TimeoutException)
            {
                continue;
            }
            catch
            {
                break;
            }
            string[] Elementy = Radek.Split(',');// Parsuj(Radek,',');
            DateTime Cas = DateTime.Now;
            if (Elementy[0].Contains("$GP"))
            {
                Elementy[0] = Elementy[0].Replace("$GP", "");
                switch (Elementy[0])
                {
                    case "GSA":
                        break;
                    case "RMC":
                        // reálný čas

                        byte Hod, Min, Sec = 0;
                        int mSec = 0;
                        string Retezec = Elementy[1];
                        Hod = (byte)(byte.Parse(Retezec.Substring(0, 2)) + RozdilProtiUTC);
                        Min = byte.Parse(Retezec.Substring(2, 2));
                        Sec = byte.Parse(Retezec.Substring(4, 2));
                        try
                        {
                            mSec = int.Parse(Retezec.Substring(7, 3));
                        }
                        catch (Exception ex)
                        { }
                        //textBox4.Text = Hod + ":" + Min + ":" + Sec + "," + mSec;
                        DateTime Dnes = DateTime.Now;
                        Retezec = Dnes.Year + "-" + ("" + Dnes.Month).PadLeft(2, '0') + "-" + ("" + Dnes.Day).PadLeft(2, '0') + "T" + ("" + Hod).PadLeft(2, '0') +
                            ":" + ("" + Min).PadLeft(2, '0') + ":" + ("" + Sec).PadLeft(2, '0') + "." + ("" + mSec).PadLeft(7, '0') + "Z";//((string)
                        CasGPS = DateTime.ParseExact(Retezec,
                                    "yyyy-MM-dd'T'HH:mm:ss.fffffff'Z'",
                                    CultureInfo.InvariantCulture,
                                    DateTimeStyles.AssumeUniversal |
                                    DateTimeStyles.AdjustToUniversal);
                        // rychlost GPS
                        if (Elementy[7] != "")
                        {
                            speed = (int)Math.Round(double.Parse(Elementy[7].Replace('.', ',')) * 1.852);
                        }
                        GPSSoubor.WriteLine(Cas.ToShortDateString() + " " + Cas.ToLongTimeString() + "\t" + Radek);

                        break;

                    case "GGA":
                        if (Elementy[2] != "")
                        {
                            string PolohaSTR = Elementy[3] + Elementy[2] + " " + Elementy[5] + Elementy[4];
                            // poloha
                            Poloha = new poloha(PolohaSTR);
                            //string debug = Poloha.ToString();
                            // platnost dat polohy

                            KvalitaSignaluGPS = (kvalitaSignaluGPS)int.Parse(Elementy[6]);
                            // výpočet rychlosti delty polohy

                            if (PredchoziPozice == "")
                            {
                                PredchoziPozice = PolohaSTR;
                                Zacatek = DateTime.Now;
                            }
                            else
                            {
                                TimeSpan delka = DateTime.Now - Zacatek;
                                string AktualniPozice = PolohaSTR;
                                double Vzdalenost = VypocetVzdalenosti(PredchoziPozice, AktualniPozice);
                                RychlostGeoid = (double)(Vzdalenost / delka.TotalSeconds);
                                PredchoziPozice = PolohaSTR;
                                Zacatek = DateTime.Now;
                            }
                        }
                        GPSSoubor.WriteLine(Cas.ToShortDateString() + " " + Cas.ToLongTimeString() + "\t" + Radek);
                        break;

                    case "GLL":
                        break;

                    case "GSV":

                        break;

                    case "VTG":

                        break;

                }
        //                    string Debug = Elementy[0];
            }
        }
        GPSSoubor.Flush();
        GPSSoubor.Close();
    }
Ejemplo n.º 6
0
    public object ParseLine(Value value)
    {
        string Radek = (string)value.data;
        string[] Elementy = Radek.Split(',');// Parsuj(Radek,',');
        DateTime Cas = Time;
        value.date = Cas;
        value.data = null;
        if (Radek.Contains("$GP"))
        {
            Elementy[0] = Elementy[0].Replace("$GP", "");
            switch (Elementy[0])
            {
                case "GSA":
                    break;
                case "RMC":
                    // reálný čas

                    byte Hod, Min, Sec = 0;
                    int mSec = 0;
                    string Retezec = Elementy[1];
                    Hod = (byte)(byte.Parse(Retezec.Substring(0, 2)) + RozdilProtiUTC);
                    Min = byte.Parse(Retezec.Substring(2, 2));
                    Sec = byte.Parse(Retezec.Substring(4, 2));
                    try
                    {
                        mSec = int.Parse(Retezec.Substring(7, 3));
                    }
                    catch (Exception ex)
                    { }
                    //textBox4.Text = Hod + ":" + Min + ":" + Sec + "," + mSec;
                    DateTime Dnes = DateTime.Now;
                    Retezec = Dnes.Year + "-" + ("" + Dnes.Month).PadLeft(2, '0') + "-" + ("" + Dnes.Day).PadLeft(2, '0') + "T" + ("" + Hod).PadLeft(2, '0') +
                        ":" + ("" + Min).PadLeft(2, '0') + ":" + ("" + Sec).PadLeft(2, '0') + "." + ("" + mSec).PadLeft(7, '0') + "Z";//((string)
                    CasGPS = DateTime.ParseExact(Retezec,
                                "yyyy-MM-dd'T'HH:mm:ss.fffffff'Z'",
                                CultureInfo.InvariantCulture,
                                DateTimeStyles.AssumeUniversal |
                                DateTimeStyles.AdjustToUniversal);
                    // rychlost GPS
                    if (Elementy[7] != "")
                    {
                        speed = (int)Math.Round(double.Parse(Elementy[7].Replace('.', ',')) * 1.852);
                    }
                    if (LogFile != null) LogFile.WriteLine(Cas.ToShortDateString() + " " + Cas.ToLongTimeString() + "\t" + Radek);

                    break;

                case "GGA":
                    if (Elementy[2] != "")
                    {
                        string PolohaSTR = Elementy[3] + Elementy[2] + " " + Elementy[5] + Elementy[4];
                        // poloha
                        Poloha = new poloha(PolohaSTR);
                        //string debug = Poloha.ToString();
                        // platnost dat polohy

                        KvalitaSignaluGPS = (kvalitaSignaluGPS)int.Parse(Elementy[6]);
                        // výpočet rychlosti delty polohy

                        if (PredchoziPozice == "")
                        {
                            PredchoziPozice = PolohaSTR;
                            Zacatek = DateTime.Now;
                        }
                        else
                        {
                            TimeSpan delka = DateTime.Now - Zacatek;
                            string AktualniPozice = PolohaSTR;
                            double Vzdalenost = VypocetVzdalenosti(PredchoziPozice, AktualniPozice);
                            RychlostGeoid = (double)(Vzdalenost / delka.TotalSeconds);
                            PredchoziPozice = PolohaSTR;
                            Zacatek = DateTime.Now;
                        }
                        if (KvalitaSignaluGPS == kvalitaSignaluGPS.ZjistenaPozice)
                        {
                            value.data = Poloha;
                        }
                        GGA gga;
                        gga.Poloha = Poloha;
                        return gga;
                    }
                    if (LogFile != null) LogFile.WriteLine(Cas.ToShortDateString() + " " + Cas.ToLongTimeString() + "\t" + Radek);
                    break;

                case "GLL":
                    break;

                case "GSV":

                    break;

                case "VTG":

                    break;
                default:
                    break;

            }
            //value.data = "";
            //                    string Debug = Elementy[0];
        }
        return value;
    }
Ejemplo n.º 7
0
    void VlaknoCteniGPS()
    {
        StreamWriter GPSSoubor = new StreamWriter("GPS.txt", true);
        string       Radek     = "";

        while (!StopVlaknoGPS)
        {
            try
            {
                Radek = GPSPort.ReadLine();
            }
            catch (TimeoutException)
            {
                continue;
            }
            catch
            {
                break;
            }
            string[] Elementy = Radek.Split(',');// Parsuj(Radek,',');
            DateTime Cas      = DateTime.Now;
            if (Elementy[0].Contains("$GP"))
            {
                Elementy[0] = Elementy[0].Replace("$GP", "");
                switch (Elementy[0])
                {
                case "GSA":
                    break;

                case "RMC":
                    // reálný čas

                    byte   Hod, Min, Sec = 0;
                    int    mSec    = 0;
                    string Retezec = Elementy[1];
                    Hod = (byte)(byte.Parse(Retezec.Substring(0, 2)) + RozdilProtiUTC);
                    Min = byte.Parse(Retezec.Substring(2, 2));
                    Sec = byte.Parse(Retezec.Substring(4, 2));
                    try
                    {
                        mSec = int.Parse(Retezec.Substring(7, 3));
                    }
                    catch (Exception ex)
                    { }
                    //textBox4.Text = Hod + ":" + Min + ":" + Sec + "," + mSec;
                    DateTime Dnes = DateTime.Now;
                    Retezec = Dnes.Year + "-" + ("" + Dnes.Month).PadLeft(2, '0') + "-" + ("" + Dnes.Day).PadLeft(2, '0') + "T" + ("" + Hod).PadLeft(2, '0') +
                              ":" + ("" + Min).PadLeft(2, '0') + ":" + ("" + Sec).PadLeft(2, '0') + "." + ("" + mSec).PadLeft(7, '0') + "Z";//((string)
                    CasGPS = DateTime.ParseExact(Retezec,
                                                 "yyyy-MM-dd'T'HH:mm:ss.fffffff'Z'",
                                                 CultureInfo.InvariantCulture,
                                                 DateTimeStyles.AssumeUniversal |
                                                 DateTimeStyles.AdjustToUniversal);
                    // rychlost GPS
                    if (Elementy[7] != "")
                    {
                        speed = (int)Math.Round(double.Parse(Elementy[7].Replace('.', ',')) * 1.852);
                    }
                    GPSSoubor.WriteLine(Cas.ToShortDateString() + " " + Cas.ToLongTimeString() + "\t" + Radek);

                    break;

                case "GGA":
                    if (Elementy[2] != "")
                    {
                        string PolohaSTR = Elementy[3] + Elementy[2] + " " + Elementy[5] + Elementy[4];
                        // poloha
                        Poloha = new poloha(PolohaSTR);
                        //string debug = Poloha.ToString();
                        // platnost dat polohy

                        KvalitaSignaluGPS = (kvalitaSignaluGPS)int.Parse(Elementy[6]);
                        // výpočet rychlosti delty polohy

                        if (PredchoziPozice == "")
                        {
                            PredchoziPozice = PolohaSTR;
                            Zacatek         = DateTime.Now;
                        }
                        else
                        {
                            TimeSpan delka          = DateTime.Now - Zacatek;
                            string   AktualniPozice = PolohaSTR;
                            double   Vzdalenost     = VypocetVzdalenosti(PredchoziPozice, AktualniPozice);
                            RychlostGeoid   = (double)(Vzdalenost / delka.TotalSeconds);
                            PredchoziPozice = PolohaSTR;
                            Zacatek         = DateTime.Now;
                        }
                    }
                    GPSSoubor.WriteLine(Cas.ToShortDateString() + " " + Cas.ToLongTimeString() + "\t" + Radek);
                    break;

                case "GLL":
                    break;

                case "GSV":

                    break;

                case "VTG":

                    break;
                }
//                    string Debug = Elementy[0];
            }
        }
        GPSSoubor.Flush();
        GPSSoubor.Close();
    }
Ejemplo n.º 8
0
    public object ParseLine(Value value)
    {
        string Radek = (string)value.data;

        string[] Elementy = Radek.Split(',');// Parsuj(Radek,',');
        DateTime Cas      = Time;

        value.date = Cas;
        value.data = null;
        if (Radek.Contains("$GP"))
        {
            Elementy[0] = Elementy[0].Replace("$GP", "");
            switch (Elementy[0])
            {
            case "GSA":
                break;

            case "RMC":
                // reálný čas

                byte   Hod, Min, Sec = 0;
                int    mSec    = 0;
                string Retezec = Elementy[1];
                Hod = (byte)(byte.Parse(Retezec.Substring(0, 2)) + RozdilProtiUTC);
                Min = byte.Parse(Retezec.Substring(2, 2));
                Sec = byte.Parse(Retezec.Substring(4, 2));
                try
                {
                    mSec = int.Parse(Retezec.Substring(7, 3));
                }
                catch (Exception ex)
                { }
                //textBox4.Text = Hod + ":" + Min + ":" + Sec + "," + mSec;
                DateTime Dnes = DateTime.Now;
                Retezec = Dnes.Year + "-" + ("" + Dnes.Month).PadLeft(2, '0') + "-" + ("" + Dnes.Day).PadLeft(2, '0') + "T" + ("" + Hod).PadLeft(2, '0') +
                          ":" + ("" + Min).PadLeft(2, '0') + ":" + ("" + Sec).PadLeft(2, '0') + "." + ("" + mSec).PadLeft(7, '0') + "Z";//((string)
                CasGPS = DateTime.ParseExact(Retezec,
                                             "yyyy-MM-dd'T'HH:mm:ss.fffffff'Z'",
                                             CultureInfo.InvariantCulture,
                                             DateTimeStyles.AssumeUniversal |
                                             DateTimeStyles.AdjustToUniversal);
                // rychlost GPS
                if (Elementy[7] != "")
                {
                    speed = (int)Math.Round(double.Parse(Elementy[7].Replace('.', ',')) * 1.852);
                }
                if (LogFile != null)
                {
                    LogFile.WriteLine(Cas.ToShortDateString() + " " + Cas.ToLongTimeString() + "\t" + Radek);
                }

                break;

            case "GGA":
                if (Elementy[2] != "")
                {
                    string PolohaSTR = Elementy[3] + Elementy[2] + " " + Elementy[5] + Elementy[4];
                    // poloha
                    Poloha = new poloha(PolohaSTR);
                    //string debug = Poloha.ToString();
                    // platnost dat polohy

                    KvalitaSignaluGPS = (kvalitaSignaluGPS)int.Parse(Elementy[6]);
                    // výpočet rychlosti delty polohy

                    if (PredchoziPozice == "")
                    {
                        PredchoziPozice = PolohaSTR;
                        Zacatek         = DateTime.Now;
                    }
                    else
                    {
                        TimeSpan delka          = DateTime.Now - Zacatek;
                        string   AktualniPozice = PolohaSTR;
                        double   Vzdalenost     = VypocetVzdalenosti(PredchoziPozice, AktualniPozice);
                        RychlostGeoid   = (double)(Vzdalenost / delka.TotalSeconds);
                        PredchoziPozice = PolohaSTR;
                        Zacatek         = DateTime.Now;
                    }
                    if (KvalitaSignaluGPS == kvalitaSignaluGPS.ZjistenaPozice)
                    {
                        value.data = Poloha;
                    }
                    GGA gga;
                    gga.Poloha = Poloha;
                    return(gga);
                }
                if (LogFile != null)
                {
                    LogFile.WriteLine(Cas.ToShortDateString() + " " + Cas.ToLongTimeString() + "\t" + Radek);
                }
                break;

            case "GLL":
                break;

            case "GSV":

                break;

            case "VTG":

                break;

            default:
                break;
            }
            //value.data = "";
            //                    string Debug = Elementy[0];
        }
        return(value);
    }