Esempio n. 1
0
    public void Test()
    {
        long StopBytes  = 0;
        var  watch      = Stopwatch.StartNew();
        long StartBytes = System.GC.GetTotalMemory(true);

        while (true) // work to end of times
        {
            line = file.ReadLine();
            if (line == null)
            {
                Run = false;
                break;
            }
            Value value  = CarInterface.GrepDataString(line);
            var   result = ParseLine(value);
            if ((result != null) && (result.GetType() == typeof(GGA)) && (((GGA)result).Poloha.Kvalita != kvalitaSignaluGPS.NeurcenaPozice))
            {
                value.data = result;
                PositionList.Add(value);
            }
        }
        StopBytes = System.GC.GetTotalMemory(true);
        GC.KeepAlive(PositionList);
        watch.Stop();
        var elapsedMs = watch.ElapsedMilliseconds;

        MessageBox.Show("Loaded " + PositionList.Count + " items\n"
                        + "Size is " + Math.Round(((long)(StopBytes - StartBytes)) / 1024.0, 2) + " kB\n"
                        + "Loading time is " + elapsedMs + " ms", "Loaded", MessageBoxButtons.OK, MessageBoxIcon.Information);
    }
Esempio n. 2
0
    public void Test()
    {
        long StopBytes  = 0;
        var  watch      = Stopwatch.StartNew();
        long StartBytes = System.GC.GetTotalMemory(true);

        while (true) // work to end of times
        {
            line = file.ReadLine();
            if (line == null)
            {
                Run = false;
                break;
            }
            ramec = new Ramec(line);
            Value value  = CarInterface.GrepDataString(line);
            var   result = ParseFrame(ramec);
            if ((result != null) && (result.GetType() == typeof(CAN_0x02C1)))
            {
                if (winkersPrevious != winkers)
                {
                    value.data = winkers;
                    winkerChangeList.Add(value);
                    winkersPrevious = winkers;
                }
            }
        }
        GC.KeepAlive(listOfFrame);
        watch.Stop();
        var elapsedMs = watch.ElapsedMilliseconds;

        MessageBox.Show("Loaded " + winkerChangeList.Count + " items\n"
                        + "Size is " + Math.Round(((long)(StopBytes - StartBytes)) / 1024.0, 2) + " kB\n"
                        + "Loading time is " + elapsedMs / 1000 + " sec", "Loaded", MessageBoxButtons.OK, MessageBoxIcon.Information);
    }
Esempio n. 3
0
    DateTime Cas;              // Time of arrive packet

    public Ramec(string Radek) // parse string from format "0x0000 01 02 03 04\r\n"
    {
        // 24.01.2016 8:48:02	0x0439	0B	31	00	00	00	00
        // 24.01.2016 8:48:02:123	0x0439	0B	31	00	00	00	00
        // 0x0439	0B	31	00	00	00	00
        this.Cas = DateTime.Now;                                                      // Now arrived
        Radek    = (string)(CarInterface.GrepDataString(Radek)).data;
        this.ID  = Convert.ToUInt16(Radek.Substring(Radek.IndexOf("0x") + 2, 4), 16); // get ID, from hex
        Radek    = Radek.Substring(7);
        byte i = 0;

        this.CTL = (byte)(Regex.Matches(Radek, " ").Count + 1); // get num of Data bytes
        if (this.CTL == 1)
        {
            this.CTL = (byte)(Regex.Matches(Radek, "\t").Count + 1);                // get num of Data bytes
        }
        this.Data = new byte[this.CTL];
        for (; i < this.CTL; i++) // parse data Bytes from hex
        {
            this.Data[i] = Convert.ToByte(Radek.Substring(i * 3, 2), 16);
        }
    }
Esempio n. 4
0
    void proc()
    {
        long counter = 0;

        switch (source)
        {
        case Source.File:
        {
            while (Run)         // work to end of times
            {
                line = file.ReadLine();
                if (line == null)
                {
                    Run = false;
                    break;
                }
                if (LogFile != null)
                {
                    LogFile.WriteLine(line);
                }
                counter++;
                Value value = CarInterface.GrepDataString(line);
                line = (string)value.data;
                ParseLine(line);
            }
            MessageBox.Show("Data načtena. (celkem " + counter + " CAN bus rámců)", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
            break;
        }

        case Source.SerialPort:
        {
            port.NewLine = "\r\n";         // define string of end of line (\r and \n)
            try
            {
                port.Open();         // try to open serial port
            }
            catch (Exception ex)     // problem with opening serial port
            {
                throw new Exception("Problém s otevřením sériového portu. " + ex.Message);
            }
            while (Run)         // work to end of times
            {
                //ramec = new Ramec(port.ReadLine());
                if (LogFile != null)
                {
                    LogFile.WriteLine(line);
                }
                //ParseFrame(ramec);
            }
            break;
        }

        default:
            break;
        }
        if (LogFile != null)
        {
            LogFile.Flush();
            LogFile.Close();
        }
    }