Exemplo n.º 1
0
        private async Task UpdateChartAsync()
        {
            updateChartThread = Thread.CurrentThread;
            while (true)
            {
                if (cts.IsCancellationRequested)
                {
                    return;
                }
                if (!ploting)
                {
                    await Task.Delay(settings.Interval);

                    continue;
                }

                var measureData = await dataMeasure.GetMeasureAsync();

                if (measureData == null)
                {
                    continue;
                }

                var md = measureData.Find(v => v.Name == Title);
                if (md != null)
                {
                    UpdateChart(md);
                }

                await Task.Delay(settings.Interval);
            }
        }
        public async Task GetData()
        {
            cancelTaskService.AddNew(new CancellationTokenSource(), "measure");
            source = cancelTaskService.Get("measure");
            cts    = source.Token;
            while (true)
            {
                if (cts.IsCancellationRequested)
                {
                    return;
                }
                Temp = await dataMeasureService.GetMeasureAsync();

                if (Temp == null)
                {
                    continue;
                }
                foreach (var v in Temp)
                {
                    if (!haveTag(MeasureStack.Children, v.Name))
                    {
                        MeasureStack.Children.Add(SetMeasureView(v));
                        OnPropertyChanged("MeasureStack");
                    }
                    else
                    {
                        if (value_labels.ContainsKey(v.Name))
                        {
                            value_labels[v.Name].Content = v.Value.ToString() + " " + v.Unit;
                            OnPropertyChanged("MeasureStack");
                        }
                        if (datelabel_labels.ContainsKey(v.Name))
                        {
                            datelabel_labels[v.Name].Content = DateTime.Now.ToString("HH:mm:ss dd.MM.y");
                            OnPropertyChanged("MeasureStack");
                        }
                    }
                }
                await Task.Delay(1000);
            }
        }
        public async Task UpdatePlotAsync()
        {
            cancelTaskService.AddNew(new System.Threading.CancellationTokenSource(), "plot");
            source = cancelTaskService.Get("plot");
            cts    = source.Token;
            while (true)
            {
                if (cts.IsCancellationRequested)
                {
                    return;
                }

                var measureData = await dataMeasureService.GetMeasureAsync();

                if (measureData == null)
                {
                    continue;
                }

                UpdateChart(measureData);

                await Task.Delay(config.GetSettings().SampleTime);
            }
        }
Exemplo n.º 4
0
        private async Task UpdateJoystickAsync()
        {
            while (true)
            {
                if (cts.IsCancellationRequested)
                {
                    return;
                }

                var measureData = await dataMeasure.GetMeasureAsync();

                if (measureData == null)
                {
                    continue;
                }

                var ys = measureData.Where(v => v.Name == "jx" || v.Name == "jy").OrderBy(v => v.Name).ToArray();
                if (ys != null && ys.Length == 2)
                {
                    Update(ys);
                }
                await Task.Delay(100);
            }
        }