예제 #1
0
        void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            string line = "";
            double signal;

            try
            {
                try
                {
                    file = new StreamReader(fileName);
                }
                catch (Exception)
                {
                    // vec je otvoren fajl
                }

                line = file.ReadLine();

                while (!(line.Contains("0.000")))
                {
                    if (line == null)
                    {
                        break;
                    }
                    try
                    {
                        line = file.ReadLine();
                    }
                    catch (Exception)
                    {
                        return;
                    }
                }

                do
                {
                    signal = (double.Parse(line.Split('\t')[channel]));
                    signal = signal / 1000;
                    while (!UlazniBuffer.Write(signal))
                    {
                        System.Threading.Thread.Sleep(sleepInterval);
                    }
                } while ((line = file.ReadLine()) != null);

                while (!UlazniBuffer.Write(double.PositiveInfinity))
                {
                    System.Threading.Thread.Sleep(sleepInterval);
                }
            }
            catch
            {
            }
            Stop();
        }
예제 #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            Int16 chan = Convert.ToInt16(textBox1.Text);

            clearChart();
            tip = inputfile.Split('.').Last();
            UlazniBuffer.Close();
            if (tip == "txt")
            {
                UlazniBuffer.Open(inputfile, chan, EKGFileType.TEXT);
            }
            else
            {
                UlazniBuffer.Open(inputfile, chan, EKGFileType.BINARY);
            }
            timer1.Start();
            i = 0;
            t = 0;
        }
예제 #3
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            double[] a = new double[15];
            UlazniBuffer.ReadMany(out a, 15);
            double x;

            if (tip == "dat")
            {
                x = (a.Last() - 1024) * 0.005;
            }
            else
            {
                x = a.Last();
            }
            t += 0.04;
            bool check = detektor.QRSCheck(x);

            if (chart1.Series[0].Points.Count < 250)
            {
                chart1.Series[0].Points.AddY(x);
                if (check)
                {
                    chart1.Series[0].Points.Last().Label      = "QRS";
                    chart1.Series[0].Points.Last().LabelAngle = 90;
                    i++;
                    RR[i]         = t;
                    BPM           = (int)(60 / (RR.Sum() / 9));
                    t             = 0;
                    BPMMetar.Text = BPM.ToString() + " BPM";
                    if (i == 9)
                    {
                        i = 0;
                    }
                }
                //ako je true dodaj marker na vrijednost kao Qrs
            }
            else
            {
                for (int i = 0; i < chart1.Series[0].Points.Count - 1; i++)
                {
                    chart1.Series[0].Points[i] = chart1.Series[0].Points[i + 1];
                }

                chart1.Series[0].Points.RemoveAt(249);
                chart1.Series[0].Points.AddY(x);
                if (check)
                {
                    chart1.Series[0].Points.Last().Label = "QRS";

                    chart1.Series[0].Points.Last().LabelAngle = 90;
                    i++;

                    RR[i]         = t;
                    BPM           = (int)(60 / (RR.Sum() / 9));
                    BPMMetar.Text = BPM.ToString() + " BPM";
                    t             = 0;
                    if (i == 9)
                    {
                        i = 0;
                    }
                }
                //Ako je true dodaj marker na vrijednost kao Qrs
            }

            chart1.Update();
        }
예제 #4
0
        void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            long fileLength = 0;

            try
            {
                file   = new FileStream(fileName, FileMode.Open);
                reader = new BinaryReader(file);
            }
            catch (Exception)
            {
                // vec je otvoren fajl, sve je OK
            }
            fileLength = file.Length;
            short flag = 0;
            long  low = 0, high = 0;

            byte[] buf = { 0, 0, 0 };

            for (int i = 0; i < fileLength / 3; i++)
            {
                for (short j = 1; j <= 2; j++)
                {
                    switch (flag)
                    {
                    case 0:
                        try
                        {
                            buf = reader.ReadBytes(3);
                        }
                        catch (Exception)
                        {
                            return;
                        }
                        low  = buf[1] & 0x0F;
                        high = buf[1] & 0xF0;
                        if (channel == j)
                        {
                            if (low > 7)
                            {
                                while (!UlazniBuffer.Write(Convert.ToDouble((buf[0] + (low << 8) - 4096))))
                                {
                                    System.Threading.Thread.Sleep(sleepInterval);
                                }
                            }
                            else
                            {
                                while (!UlazniBuffer.Write(Convert.ToDouble((buf[0] + (low << 8)))))
                                {
                                    System.Threading.Thread.Sleep(sleepInterval);
                                }
                            }
                        }
                        flag = 1;
                        break;

                    case 1:
                        if (channel == j)
                        {
                            if (high > 127)
                            {
                                while (!UlazniBuffer.Write(Convert.ToDouble(buf[2] + (high << 4) - 4096)))
                                {
                                    System.Threading.Thread.Sleep(sleepInterval);
                                }
                            }
                            else
                            {
                                while (!UlazniBuffer.Write(Convert.ToDouble((buf[2] + (high << 4)))))
                                {
                                    System.Threading.Thread.Sleep(sleepInterval);
                                }
                            }
                        }
                        flag = 0;
                        break;
                    }
                }
            }

            while (!UlazniBuffer.Write(Double.PositiveInfinity))
            {
                System.Threading.Thread.Sleep(sleepInterval);
            }

            Stop();
        }