예제 #1
0
        public DeviceConfigView(VirtualOscilloscope virtualOscilloscope)
        {
            InitializeComponent();

            var viewModel = new DeviceConfigViewModel(virtualOscilloscope);

            viewModel.MessageRaised += ViewModel_MessageRaised;
            DataContext              = viewModel;
        }
예제 #2
0
 public DeviceConfigViewModel(VirtualOscilloscope virtualOscilloscope)
 {
     VirtualOscilloscope     = virtualOscilloscope;
     VoltageDIVCollection    = new ObservableCollection <string>(EnumHelper.GetAllDescriptions <EVoltageDIV>());
     TimeDIVCollection       = new ObservableCollection <string>(EnumHelper.GetAllDescriptions <ETimeDIV>());
     TriggerSweepCollection  = new ObservableCollection <string>(EnumHelper.GetAllDescriptions <ETriggerSweep>());
     TriggerSourceCollection = new ObservableCollection <string>(EnumHelper.GetAllDescriptions <ETriggerSource>());
     TriggerSlopeCollectione = new ObservableCollection <string>(EnumHelper.GetAllDescriptions <ETriggerSlope>());
     InsertModeCollection    = new ObservableCollection <string>(EnumHelper.GetAllDescriptions <EInsertMode>());
 }
 /// <summary>
 /// 创建MainWindowViewModel新实例
 /// </summary>
 public MainWindowViewModel()
 {
     try
     {
         VirtualOscilloscope = new VirtualOscilloscope(0, 100);
         deviceConfigView    = new DeviceConfigView(VirtualOscilloscope);
     }
     catch (Exception ex)
     {
         OnMessageRaised(MessageLevel.Err, ex.Message, ex);
     }
 }
예제 #4
0
        private void HostComputerForm_Load(object sender, EventArgs e)
        {
            HostComputerForm.CheckForIllegalCrossThreadCalls = false;
            BinaryMethodSelectCB.SelectedIndex = 0;

            skinTabControl1.SelectedIndex = 0;

            VO = new VirtualOscilloscope(ScopeChart);

            if (Debugger.IsAttached)
            {
                AllocConsole();
            }
            UartDataDecoding = new Thread(UsedUARTCommunication.DataDecoding);
            UartDataDecoding.Start();

            ImageRefresh     = new Thread(ImageRenew);
            ImageDealThread  = new Thread(ImageDeal);
            ScopeRenewThread = new Thread(ScopeDataRenew);

            #region 一些变量初始化
            for (int i = 0; i < 4; i++)
            {
                ScopeDataList.Add(new List <double>());
            }
            #endregion

            int           random_num = 0;
            List <Random> rdList     = new List <Random>();
            rdList.Add(new Random(12));
            rdList.Add(new Random(20));
            rdList.Add(new Random(40));
            rdList.Add(new Random(80));
            //ScopeChart.Series[1].Enabled = false;
            //ScopeChart.Series[2].Enabled = false;
            //ScopeChart.Series[3].Enabled = false;

            #region 生成Chart测试数据
            for (int i = 0; i < 100; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    random_num = rdList[j].Next(100 * (j + 1));
                    ScopeChart.Series[j].Points.AddXY(i, random_num);
                    ScopeChart.Series[j].Points[i].ToolTip = "#VALX, #VALY";
                    ScopeDataList[j].Add(random_num);
                }
                VO.TimeCount++;
            }
            # endregion
        /// <summary>
        /// 读取设备数据
        /// </summary>
        public void ReadDeviceData()
        {
            try
            {
                double[] source;
                VirtualOscilloscope.ReadDeviceData(out source);
                int sampleRate = VirtualOscilloscope.SampleRate;

                //数据滤波
                Analysis.MeanFilter(source, 21, out FilterData);

                //显示数据
                var collection = new System.Collections.ObjectModel.ObservableCollection <Data>();
                for (int i = 0; i < source.Length / SampleInterval; i++)
                {
                    collection.Add(new Data()
                    {
                        Value1 = FilterData[i * SampleInterval], Value = i * 1000.0 / sampleRate * SampleInterval
                    });
                }

                LiveDataViewModel1.Collection = collection;

                //提取边沿
                if (FilterData?.Length > 0)
                {
                    Analysis.FindEdgeByThreshold(FilterData, 0.4, 1.6, out EdgeIndexs, out DigitEdgeType);

                    if ((DigitEdgeType == DigitEdgeType.FirstFillingEdge) || (DigitEdgeType == DigitEdgeType.FirstRisingEdge))
                    {
                        collection = new ObservableCollection <Data>();

                        foreach (var item in EdgeIndexs)
                        {
                            collection.Add(new Data()
                            {
                                Value1 = LiveDataViewModel1.Collection[item / SampleInterval].Value1, Value = item * 1000.0 / sampleRate * SampleInterval
                            });
                        }
                        LiveDataViewModel1.Collection2 = collection;
                    }
                }
            }
            catch (Exception ex)
            {
                OnMessageRaised(MessageLevel.Err, ex.Message, ex);
            }
        }
예제 #6
0
 public Form1()
 {
     InitializeComponent();
     VO = new VirtualOscilloscope(TestChart);
     TestTimer.Interval = 200;
 }