Example #1
0
        public void drawzed(RealPacket packet)
        {
            // test
            float  fTime = (float)m_sw.ElapsedMilliseconds / 1000.0F;
            Random r     = new Random();

            Datalist[0].Add(fTime, packet.breath);
            Datalist[1].Add(fTime, packet.pressure);
            Datalist[2].Add(fTime, packet.LRPM);
            Datalist[3].Add(fTime, packet.RRPM);

            BreathGraph.GraphPane.AddCurve("", Datalist[0], Color.Orange, SymbolType.None);
            BreathGraph.GraphPane.XAxis.Scale.Max = fTime;
            BreathGraph.GraphPane.XAxis.Scale.Min = fTime - (8.0 * zoomFraction);
            BreathGraph.AxisChange();

            PressureGraph.GraphPane.AddCurve("", Datalist[1], Color.Green, SymbolType.None);
            PressureGraph.GraphPane.XAxis.Scale.Max = fTime;
            PressureGraph.GraphPane.XAxis.Scale.Min = fTime - (8.0 * zoomFraction);
            PressureGraph.AxisChange();

            RPMGraph.GraphPane.AddCurve("L", Datalist[2], Color.Blue, SymbolType.None);
            RPMGraph.GraphPane.AddCurve("R", Datalist[3], Color.Red, SymbolType.None);
            RPMGraph.GraphPane.XAxis.Scale.Max = fTime;
            RPMGraph.GraphPane.XAxis.Scale.Min = fTime - (8.0 * zoomFraction);
            RPMGraph.AxisChange();
        }
Example #2
0
        public void OnDataReceived(RealPacket dataIn)
        {
            //Handle multi-threading
            if (InvokeRequired)
            {
                Invoke(new PacketDelegate(OnDataReceived), new object[] { dataIn });
                return;
            }

            // Read Data
            //DrawGraph(dataIn);          // 그래프는 대기
            if (m_sw2.ElapsedMilliseconds > 200)
            {
                m_sw2.Restart();
                drawzed(dataIn);

                BreathGraph.Invalidate();
                PressureGraph.Invalidate();
                RPMGraph.Invalidate();
                dataGridView.Invalidate();
            }
            if (_bLogging)
            {
                DrawGrid(dataIn);
            }
        }
Example #3
0
        public RealPacket SetData(byte[] readBuffer)
        {
            RealPacket packet = new RealPacket();
            int        idx    = 4;

            for (int i = Packet.size - 1; i != 0; --i, --idx)           // 최적화 필요. 조건문 더 추가해야됨. 현재는 임시방편임.
            {
                switch (idx)
                {
                case 3:
                    packet.RRPM = readBuffer[i - 1] << 8 | readBuffer[i];            //최적화 필요.
                    i--;
                    break;

                case 2:
                    packet.LRPM = readBuffer[i - 1] << 8 | readBuffer[i];
                    i--;
                    break;

                case 1:
                    packet.pressure = (readBuffer[i - 3] << 24 | readBuffer[i - 2]
                                                         << 16 | readBuffer[i - 1] << 8 | readBuffer[i]) / 1000f;
                    i -= 3;
                    break;

                case 0:
                    byte[] startBytes = new byte[4];
                    Buffer.BlockCopy(readBuffer, i - 3, startBytes, 0, 4);
                    packet.breath = ConvertBreathToFloat(startBytes);
                    i             = 1;
                    break;
                }
            }
            return(packet);
        }
Example #4
0
 public void DrawGrid(RealPacket packet)
 {
     //float fTime = (float)m_sw.ElapsedMilliseconds / 1000.0F;
     dataGridView.Rows.Add(packet.breath, packet.pressure, packet.LRPM, packet.RRPM);
     dataGridView.FirstDisplayedScrollingRowIndex = dataGridView.RowCount - 1;
 }