コード例 #1
0
ファイル: exgetvec.cs プロジェクト: xhbmud/WfdbCsharpWrapper
        private static void UsingWrapperClasses1()
        {
            Console.WriteLine("exgetvec Using Wrapper Record Class");
            using (var record = new Record("data/100s"))
            {
                record.Open();

                var samples = record.GetSamples(10);
                foreach (var s in samples)
                {
                    for (int i = 0; i < s.Length; i++)
                    {
                        Console.Write(string.Format("{0}\t", s[i]));
                    }
                    Console.WriteLine();
                }
            }

            Wfdb.Quit();
        }
コード例 #2
0
        private static void UsingWrapperClasses1()
        {
            Console.WriteLine("exgetvec Using Wrapper Record Class");
            using (var record = new Record("data/100s"))
            {
                record.Open();

                var samples = record.GetSamples(10);
                foreach (var s in samples)
                {
                    for (int i = 0; i < s.Length; i++)
                    {
                        Console.Write(string.Format("{0}\t", s[i]));
                    }
                    Console.WriteLine();
                }
            }

            Wfdb.Quit();
        }
コード例 #3
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            string inword;
            int    cnt       = 0;
            int    totCnt    = 0;
            int    sendCnt   = 0;
            int    readCnt   = 0;
            int    iteration = 0;

            btnStart.Enabled = false;
            btnStop.Enabled  = true;
            ////using (var record = new Record("c:\\users\\Al\\Dropbox\\Medical Projects\\ECG Simulator\\EcgSim\\EcgSim\\data\\100s"))
            using (var record = new Record("data/aami-ec13/aami3a"))


            //using (var record = new Record(txtFile.Text.Substring(2, txtFile.Text.Length - 6)))
            {
                record.Open();
                //next line added by Al as test
                Frequency.InputFrequency = 125;

                var samples = record.GetSamples(1000);
                int loop    = 0;
                int val;

                string outword;
                // serOut.BaudRate = 38400;
                serOut.BaudRate = 115200;
                serOut.Open();

                Console.Write("Ser wBuf Size ");
                Console.WriteLine(serOut.WriteBufferSize);
                Console.Write("Ser rBuf Size ");
                Console.WriteLine(serOut.ReadBufferSize);

                Console.WriteLine("Iteration " + iteration);

                while (iteration++ < 100)
                {
                    foreach (var s in samples)
                    {
                        for (int i = 0; i < s.Length; i++)
                        {
                            loop++;
                            //   Console.WriteLine(loop);
                            //Console.Write(s[i].ToString());
                            //Console.Write(string.Format("D{0000}\t", s[i]));
                            //real         val = s[i];       // real

                            //if ((loop == 1) || (loop == 1000))
                            //    Console.WriteLine("BorE " + s[i]);
                            val = (s[i] - 1950) * 10;
                            if (val > 4096)
                            {
                                val = 4096;
                            }
                            if (val < 0)
                            {
                                val = 0;
                            }
                            //   val = loop;

                            outword = "D" + val.ToString("0000");
                            serOut.Write(outword);
                            //    Console.WriteLine(outword);


                            if ((readCnt = serOut.BytesToRead) > 0)
                            {
                                //     Console.Write("rCnt:");
                                //     Console.WriteLine(readCnt);
                                inword  = serOut.ReadLine();
                                cnt     = inword.Count(c => c == '>');
                                totCnt += cnt;

                                Console.Write(inword);
#if VERBOSE
                                Console.Write("$");
                                Console.Write(totCnt);
                                Console.Write("$c");
                                Console.WriteLine(sendCnt);
#endif
                                Console.Write("]");
                                //   Console.WriteLine(cnt);
                                //  Thread.Sleep(1);
                            }
                            else
                            {
                                Console.WriteLine(",");
                                Thread.Sleep(1);
                            }
                        }
                        Console.WriteLine();
                        sendCnt++;

                        do
                        {
                            if ((readCnt = serOut.BytesToRead) > 0)
                            {
                                // Console.Write("rCnt:");
                                // Console.WriteLine(readCnt);
                                Console.Write("[");

                                inword = serOut.ReadLine();

                                cnt     = inword.Count(c => c == '>');
                                totCnt += cnt;

                                Console.Write(inword);
#if VERBOSE
                                Console.Write("|");
                                Console.Write(totCnt);
                                Console.Write("|c");
                                Console.WriteLine(sendCnt);
                                Console.WriteLine(cnt);
#endif
                                Console.Write("]");
                                Console.Write(totCnt);
                                //  Console.Write("|c");
                                //  Console.WriteLine(cnt);
                                //    Thread.Sleep(1);
                            }
                            else
                            {
                                Console.Write(".");
                                Thread.Sleep(1);
                            }
                        } while ((sendCnt - totCnt) > 30);
                    }

                    Application.DoEvents();
                    if (btnStart.Enabled)
                    {
                        break;
                    }
                }
            }

            // Wait for final bytes to drain
            do
            {
                if ((readCnt = serOut.BytesToRead) > 0)
                {
                    Console.Write("rCnt:");
                    Console.WriteLine(readCnt);
                    inword = serOut.ReadLine();

                    cnt     = inword.Count(c => c == '>');
                    totCnt += cnt;
                    Console.Write(inword);
                    Console.Write("-");
                    Console.Write(totCnt);
                    Console.Write("-");
                    Console.WriteLine(sendCnt);
                    Thread.Sleep(10);
                }
                else
                {
                    Console.WriteLine("No1");
                    Thread.Sleep(1000);
                }
            } while ((sendCnt - totCnt) > 0);
            Console.WriteLine(cnt);
            Console.WriteLine("End 1");
            if ((readCnt = serOut.BytesToRead) > 0)
            {
                inword = serOut.ReadLine();
                Console.Write(inword);
            }
            else
            {
                Console.WriteLine("No2");
                Thread.Sleep(1000);
            }


            Thread.Sleep(1000);
            Console.WriteLine("End 2");
            if ((readCnt = serOut.BytesToRead) > 0)
            {
                inword = serOut.ReadLine();
                Console.Write(inword);
            }
            else
            {
                Console.WriteLine("No3.");
                Thread.Sleep(1000);
            }

            serOut.Close();
            btnStart.Enabled = true;
            btnStop.Enabled  = false;
            Wfdb.Quit();
        }