示例#1
0
        public NavigationMonitoringController(NavigationMonitoringViewModel navigationMonitoringViewModel,
                                              IShellService shellService,
                                              IDataUpdateService dataUpdateService,
                                              ISettingsService settingsService,
                                              IGuiUpdateService guiUpdateService)
        {
            this.navigationMonitoringViewModel = navigationMonitoringViewModel;
            this.shellService                  = shellService;
            this.dataUpdateService             = dataUpdateService;
            this.settingsService               = settingsService;
            this.guiUpdateService              = guiUpdateService;
            shellService.PropertyChanged      += ShellService_PropertyChanged;
            dataUpdateService.DataUpdateEvent += DataUpdateEventHandler;
            TabChangeCommand = new DelegateCommand(TabChange_Command);

            navXEstBuffer  = new List <LogPoint>();
            navXMeasBuffer = new List <LogPoint>();
            navXRefBuffer  = new List <LogPoint>();
            navYEstBuffer  = new List <LogPoint>();
            navYMeasBuffer = new List <LogPoint>();
            navYRefBuffer  = new List <LogPoint>();
            posBuffersFull = false;

            navXVelBuffer  = new List <LogPoint>();
            navYVelBuffer  = new List <LogPoint>();
            velBuffersFull = false;

            navTrackingEstBuffer  = new List <PosistionPoint>();
            navTrackingMeasBuffer = new List <PosistionPoint>();
            navTrackingRefBuffer  = new List <PosistionPoint>();

            GearedValues <PosistionPoint> estpoints  = new GearedValues <PosistionPoint>().WithQuality(Quality.Medium);
            GearedValues <PosistionPoint> measpoints = new GearedValues <PosistionPoint>().WithQuality(Quality.Medium);
            GearedValues <PosistionPoint> refpoints  = new GearedValues <PosistionPoint>().WithQuality(Quality.Medium);

            for (int i = 0; i < settingsService.TrackingTimeFrame * 1000; i++)
            {
                estpoints.Add(new PosistionPoint(0, 0));
                measpoints.Add(new PosistionPoint(0, 0));
                refpoints.Add(new PosistionPoint(0, 0));
            }
            navigationMonitoringViewModel.NavTrackingEstPoints  = estpoints;
            navigationMonitoringViewModel.NavTrackingMeasPoints = measpoints;
            navigationMonitoringViewModel.NavTrackingRefPoints  = refpoints;

            currentIndex = 0;

            posUpdating      = false;
            velUpdating      = false;
            trackingUpdating = false;

            coorLast      = true;
            framePosCount = 0;
            frameVelCount = 0;
        }
示例#2
0
        public void Reset()
        {
            navigationMonitoringViewModel.NavXEstPoints.Clear();
            navigationMonitoringViewModel.NavXMeasPoints.Clear();
            navigationMonitoringViewModel.NavXRefPoints.Clear();

            navigationMonitoringViewModel.NavYEstPoints.Clear();
            navigationMonitoringViewModel.NavYMeasPoints.Clear();
            navigationMonitoringViewModel.NavYRefPoints.Clear();

            navigationMonitoringViewModel.NavXVelPoints.Clear();
            navigationMonitoringViewModel.NavYVelPoints.Clear();

            GearedValues <PosistionPoint> estpoints  = new GearedValues <PosistionPoint>().WithQuality(Quality.Medium);
            GearedValues <PosistionPoint> measpoints = new GearedValues <PosistionPoint>().WithQuality(Quality.Medium);
            GearedValues <PosistionPoint> refpoints  = new GearedValues <PosistionPoint>().WithQuality(Quality.Medium);

            for (int i = 0; i < settingsService.TrackingTimeFrame * 1000; i++)
            {
                estpoints.Add(new PosistionPoint(0, 0));
                measpoints.Add(new PosistionPoint(0, 0));
                refpoints.Add(new PosistionPoint(0, 0));
            }
            navigationMonitoringViewModel.NavTrackingEstPoints  = estpoints;
            navigationMonitoringViewModel.NavTrackingMeasPoints = measpoints;
            navigationMonitoringViewModel.NavTrackingRefPoints  = refpoints;

            currentIndex = 0;

            posUpdating      = false;
            velUpdating      = false;
            trackingUpdating = false;
            framePosCount    = 0;
            frameVelCount    = 0;

            navXEstBuffer  = new List <LogPoint>();
            navXMeasBuffer = new List <LogPoint>();
            navXRefBuffer  = new List <LogPoint>();
            navYEstBuffer  = new List <LogPoint>();
            navYMeasBuffer = new List <LogPoint>();
            navYRefBuffer  = new List <LogPoint>();
            posBuffersFull = false;

            navXVelBuffer  = new List <LogPoint>();
            navYVelBuffer  = new List <LogPoint>();
            velBuffersFull = false;
        }
示例#3
0
        /*private void GetFromSim(Object stateInfo)
         * {
         *  if (!paused)
         *  {
         *      Dispatcher.Invoke(() =>
         *      {
         *          SetValue(ProsperityProperty, network.Prosperity);
         *          Trace.WriteLine("ProsperityProp set called");
         *          SetValue(CoopProperty, network.TotalCooperators);
         *          Trace.WriteLine("CoopProp set called");
         * Trace.WriteLine("Prosperity property: " + GetValue(ProsperityProperty));
         *          Trace.WriteLine("Coop property: " + GetValue(CoopProperty));
         *      });
         *  }
         * }*/

        private void GetFromSim(Object stateInfo)
        {
            if (!paused)
            {
                Dispatcher.Invoke(() =>
                {
                    prosperityValues.Add(network.Prosperity);
                    //SetValue(ProsperityProperty, prosperityValues);
                    totalCoopValues.Add(network.TotalCooperators);
                    //SetValue(CoopProperty, totalCoopValues);
                    avrgCoopsValues.Add(network.AverageCooperators);
                    //SetValue(AvrgCoopProperty, prosperityValues);
                    if (evolving)
                    {
                        avrgRoleConProbValues.Add(network.AverageRoleConProb);
                        //SetValue(RoleConProperty, avrgRoleConProbValues);
                        avrgRoleNeighborConProbValues.Add(network.AverageRoleNeighborConProb);
                        //SetValue(RoleNeighborConProperty, avrgRoleNeighborConProbValues);
                    }
                });
            }
        }
        public static GLineSeries ToSmaSeries(this OhlcData data, int length, ResolutionSourceProvider resolver = null, string title = null)
        {
            title = title ?? length + " SMA";

            var chartPointEvaluator = new InstantChartPointMapper(resolver ?? new ResolutionSourceProvider(data.Resolution));

            var series = new GLineSeries
            {
                Configuration = chartPointEvaluator,
                Fill          = Brushes.Transparent,
                PointGeometry = null,
                Title         = title
            };

            if (data == null)
            {
                return(series);
            }

            var values  = new GearedValues <InstantChartPoint>();
            var ordered = data.OrderBy(x => x.DateTimeUtc).ToList();
            var smadata = FinancialHelper.ComputeMovingAverage(ordered.Select(x => x.Close).ToList(), length);

            for (var index = 0; index < ordered.Count; index++)
            {
                var d = ordered[index];
                var v = smadata[index];
                if (double.IsNaN(v))
                {
                    continue;
                }
                values.Add(new InstantChartPoint(d.DateTimeUtc, (decimal)v));
            }

            series.Values = values;

            return(series);
        }
        // Adds a entry to the graphing form. If data transformation is required, its handled here.
        public void AddGraphingEntry(GraphingEntry entry)
        {
            if (Series1EnabledCheckbox.Checked)
            {
                series1Values.Add(entry);

                // Add series 1 set-point values if they are enabled
                if (currentYAxis1 == ControlEnums.AXISOPTIONS.POSITION)
                {
                    setLine1Values.Add(new GraphingLine(entry.uptime, positionLineY));
                }
                if (currentYAxis1 == ControlEnums.AXISOPTIONS.VELOCITY)
                {
                    setLine1Values.Add(new GraphingLine(entry.uptime, velocityLineY));
                }
                if (currentYAxis1 == ControlEnums.AXISOPTIONS.ACCELERATION)
                {
                    setLine1Values.Add(new GraphingLine(entry.uptime, accelerationLineY));
                    setLine3Values.Add(new GraphingLine(entry.uptime, -accelerationLineY));
                    setLine3.Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 33, 149, 242));
                }
            }
            if (Series2EnabledCheckbox.Checked)
            {
                series2Values.Add(entry);

                // Add series 2 set-point values if they are enabled
                if (currentYAxis2 == ControlEnums.AXISOPTIONS.POSITION)
                {
                    setLine2Values.Add(new GraphingLine(entry.uptime, positionLineY));
                }
                if (currentYAxis2 == ControlEnums.AXISOPTIONS.VELOCITY)
                {
                    setLine2Values.Add(new GraphingLine(entry.uptime, velocityLineY));
                }
                if (currentYAxis2 == ControlEnums.AXISOPTIONS.ACCELERATION)
                {
                    setLine2Values.Add(new GraphingLine(entry.uptime, accelerationLineY));
                    setLine3Values.Add(new GraphingLine(entry.uptime, -accelerationLineY));
                    setLine3.Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 243, 67, 54));
                }
            }

            // If the number of points in any series exceeds the maximum, remove the first point.
            if (series1Values.Count > numDataPoints)
            {
                series1Values.RemoveAt(0);
            }
            if (setLine1Values.Count > numDataPoints)
            {
                setLine1Values.RemoveAt(0);
            }
            if (series2Values.Count > numDataPoints)
            {
                series2Values.RemoveAt(0);
            }
            if (setLine2Values.Count > numDataPoints)
            {
                setLine2Values.RemoveAt(0);
            }
            if (setLine3Values.Count > numDataPoints)
            {
                setLine3Values.RemoveAt(0);
            }
        }
示例#6
0
        /// <summary>
        /// 添加设备图表折线图数据
        /// </summary>
        public GearedValues <LineStatistics> AddChartValue(int num)
        {
            // 定义折线图数据结构
            GearedValues <LineStatistics> LineChartData = new GearedValues <LineStatistics>();
            // 获取当前天数
            var nowday = DateTime.Now.Day.ToString();
            // 获取当前年份
            var nowyear = DateTime.Now.Year.ToString();
            // 获取当前月份
            var nowmonth = DateTime.Now.Month.ToString();

            if (UserLineCharts[0].Values.Count > 20)
            {
                AxisXMax = UserLineCharts[0].Values.Count - 1;
                AxisXMin = UserLineCharts[0].Values.Count - 20;
            }
            else
            {
                AxisXMax = 20;
                AxisXMin = 0;
            }

            switch (num)
            {
            case 0:
                //添加月达成率图表
                for (int i = 1; i < int.Parse(nowday) + 1; i++)
                {
                    // 生成当前天数之前的日期 如果有日期没有数据,则添加图表数据为0
                    string nowtime = nowyear + "/" + nowmonth + "/" + i;
                    // 查询数据库
                    string    sql  = $"SELECT DevID,Produce FROM MonthDeviceData WHERE Day = '{nowtime}' AND DevID = {num}";
                    DataTable data = SQLiteHelp.ExecuteQuery(sql);
                    if (data.Rows.Count > 0)
                    {
                        if (data.Rows[0][1].ToString() == "")
                        {
                            LineChartData.Add(new LineStatistics
                            {
                                Num   = i - 1,
                                Value = 0
                            });
                        }
                        else
                        {
                            LineChartData.Add(new LineStatistics
                            {
                                Num   = i - 1,
                                Value = double.Parse((double.Parse(data.Rows[0][1].ToString()) / MainWindow.DayPlan).ToString("N3"))
                            });
                        }
                    }
                    else
                    {
                        LineChartData.Add(new LineStatistics
                        {
                            Num   = i - 1,
                            Value = 0
                        });
                    }
                }
                break;

            case 1:
                // 添加月良率图表
                for (int i = 1; i < int.Parse(nowday) + 1; i++)
                {
                    // 生成当前天数之前的日期 如果有日期没有数据,则添加图表数据为0
                    string nowtime = nowyear + "/" + nowmonth + "/" + i;
                    // 查询数据库
                    string    sql  = $"SELECT DevID,Produce,GoodProduct FROM MonthDeviceData WHERE Day = '{nowtime}' AND DevID = {0}";
                    DataTable data = SQLiteHelp.ExecuteQuery(sql);
                    if (data.Rows.Count > 0)
                    {
                        if (data.Rows[0][1].ToString() == "")
                        {
                            LineChartData.Add(new LineStatistics
                            {
                                Num   = i - 1,
                                Value = 0
                            });
                        }
                        else
                        {
                            double good = double.Parse(data.Rows[0][2].ToString()) / double.Parse(data.Rows[0][1].ToString());
                            LineChartData.Add(new LineStatistics
                            {
                                Num   = i - 1,
                                Value = double.Parse(good.ToString("N2"))
                            });
                        }
                    }
                    else
                    {
                        LineChartData.Add(new LineStatistics
                        {
                            Num   = i - 1,
                            Value = 0
                        });
                    }
                }
                break;

            case 2:
                // 添加月时间稼动率图表
                for (int i = 1; i < int.Parse(nowday) + 1; i++)
                {
                    // 生成当前天数之前的日期 如果有日期没有数据,则添加图表数据为0
                    string nowtime = nowyear + "/" + nowmonth + "/" + i;
                    // 查询数据库
                    string    sql  = $"SELECT DevID,TimeEfficiency FROM MonthDeviceData WHERE Day = '{nowtime}' AND DevID = {0}";
                    DataTable data = SQLiteHelp.ExecuteQuery(sql);
                    if (data.Rows.Count > 0)
                    {
                        if (data.Rows[0][1].ToString() == "")
                        {
                            LineChartData.Add(new LineStatistics
                            {
                                Num   = i - 1,
                                Value = 0
                            });
                        }
                        else
                        {
                            double time = double.Parse(data.Rows[0][1].ToString());
                            LineChartData.Add(new LineStatistics
                            {
                                Num   = i - 1,
                                Value = double.Parse((time / 100).ToString("N2"))
                            });
                        }
                    }
                    else
                    {
                        LineChartData.Add(new LineStatistics
                        {
                            Num   = i - 1,
                            Value = 0
                        });
                    }
                }
                break;

            default:
                break;
            }

            return(LineChartData);
        }
示例#7
0
        /// <summary>
        /// 添加设备图表折线图数据
        /// </summary>
        public GearedValues <LineStatistics> AddChartValue(int num)
        {
            // 定义折线图数据结构
            GearedValues <LineStatistics> LineChartData = new GearedValues <LineStatistics>();
            // 获取当前天数
            var nowday = DateTime.Now.Day.ToString();
            // 获取当前年份
            var nowyear = DateTime.Now.Year.ToString();
            // 获取当前月份
            var nowmonth = DateTime.Now.Month.ToString();

            if (UserLineCharts[0].Values.Count > 20)
            {
                AxisXMax = UserLineCharts[0].Values.Count - 1;
                AxisXMin = UserLineCharts[0].Values.Count - 20;
            }
            else
            {
                AxisXMax = 20;
                AxisXMin = 0;
            }
            for (int i = 1; i < int.Parse(nowday) + 1; i++)
            {
                // 生成当前天数之前的日期 如果有日期没有数据,则添加图表数据为0
                string nowtime = nowyear + "/" + nowmonth + "/" + i;
                // 查询数据库
                string    sql  = $"SELECT DevID,Produce FROM MonthDeviceData WHERE Day = '{nowtime}' AND DevID = {num}";
                DataTable data = SQLiteHelp.ExecuteQuery(sql);
                if (data.Rows.Count > 0)
                {
                    if (data.Rows[0][1].ToString() == "")
                    {
                        LineChartData.Add(new LineStatistics
                        {
                            Num   = i - 1,
                            Value = 0
                        });
                    }
                    else
                    {
                        LineChartData.Add(new LineStatistics
                        {
                            Num   = i - 1,
                            Value = double.Parse((double.Parse(data.Rows[0][1].ToString()) / MainWindow.DayPlan).ToString("N3"))
                        });
                    }
                }
                else
                {
                    LineChartData.Add(new LineStatistics
                    {
                        Num   = i - 1,
                        Value = 0
                    });
                }
            }
            timerNotice = new System.Timers.Timer();
            //间隔触发函数
            timerNotice.Elapsed += new System.Timers.ElapsedEventHandler((o, e) =>
            {
            });
            //触发间隔
            timerNotice.Interval = MainWindow.Time;
            timerNotice.Start();
            return(LineChartData);
        }