Exemple #1
0
        private void dp_MouseUp(object sender, MouseButtonEventArgs e)
        {
            vl.Value = dp.Position.X;
            if (collecting == false)
            {
                if (dp.Position.X >= 0 && dp.Position.X < pulList.Count - 1)
                {
                    pulseTxt.Text = pulList[(int)dp.Position.X].ToString();
                    pulAnalyse((int)dp.Position.X, 1);
                }
                else
                {
                    pulseTxt.Text = "Out of Range";
                }

                if (dp.Position.X >= 0 && dp.Position.X < dataList.Count - 1)
                {
                    DataUnitRSO dutemp = (DataUnitRSO)dataList[(int)dp.Position.X];
                    rSO2Txt.Text = (dutemp.rSO2 / 100).ToString() + "." + (dutemp.rSO2 - ((int)dutemp.rSO2 / 100) * 100).ToString();
                }
                else
                {
                    rSO2Txt.Text = "Out of Range";
                }
            }
        }
Exemple #2
0
        public void com2_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
        {
            try
            {
                if (collecting)
                {
                    comPort2.Read(readBuffer2, 0, 4);
                    if (asciiEnable)
                    {
                        readVal2 = (int)((readBuffer2[0] - 48) * 1000 + (readBuffer2[1] - 48) * 100 + (readBuffer2[2] - 48) * 10 + (readBuffer2[3] - 48));
                    }
                    else
                    {
                        readVal2 = (int)(readBuffer2[0] * 1000 + readBuffer2[1] * 100 + readBuffer2[2] * 10 + readBuffer2[3]);
                    }

                    if ((readVal2 == endFlagRSO) && collectingRSO)
                    {
                        collectingRSO = false;
                        DataUnitRSO du = new DataUnitRSO(readValListRSO);    // 将readValList写入预置的类dataUnit中 dataUnit.addVal(readValList);
                        du.rSO2 = getrSO2(readValListRSO[0], readValListRSO[1], readValListRSO[2], readValListRSO[3]);
                        dataList.Add(du);
                        this.rSO2Txt.Dispatcher.Invoke(new Action(() => { this.rSO2Txt.Text = (du.rSO2 / 100).ToString() + "." + (du.rSO2 - ((int)du.rSO2 / 100) * 100).ToString(); })); //防止线程间冲突
                        showParamDynamicRSO(dataList.Count - 1);
                        Array.Clear(readValListRSO, 0, readValListRSO.Length);                                                                                                           //清空readValList
                    }

                    if (collectingRSO)
                    {
                        readValListRSO[countRSO] = readVal2;
                        countRSO++;
                    }

                    if (readVal2 == beginFlagRSO)
                    {
                        countRSO      = 0;
                        collectingRSO = true;
                    }
                }
            }
            catch
            {
                return;
            }
        }