public CoilChangeChart()
        {
            InitializeComponent();

            var mapper = Mappers.Xy <CoilChangeModel>()
                         .X(model => model.DateTime.Ticks) //use DateTime.Ticks as X
                         .Y(model => model.Value);         //use the value property as Y

            //lets save the mapper globally.
            Charting.For <CoilChangeModel>(mapper);

            //the values property will store our values array
            ChartValues = new GearedValues <CoilChangeModel>();
            ChartValues.WithQuality(Quality.Highest);

            //lets set how to display the X Labels
            DateTimeFormatter = value => new DateTime((long)value).ToString("mm:ss");

            //AxisStep forces the distance between each separator in the X axis
            AxisStep = TimeSpan.FromSeconds(1).Ticks;
            //AxisUnit forces lets the axis know that we are plotting seconds
            //this is not always necessary, but it can prevent wrong labeling
            AxisUnit = TimeSpan.TicksPerSecond;

            SetAxisLimits(DateTime.Now);

            //The next code simulates data changes every 300 ms

            IsReading = false;

            DataContext = this;
        }
Esempio n. 2
0
 public DataSeries(string Name, string Label = null)
 {
     this.SeriesName = Name;
     this.AxisLabel  = Label;
     this.Colour     = Color.FromRgb(0x81, 0x14, 0x26);
     this.Data       = new GearedValues <Datum <DataType> >();
 }
        public static GCandleSeries ToGCandleSeries(this OhlcData data, ResolutionSourceProvider resolver = null, string title = "")
        {
            var ohlcChartPointEvaluator = new OhlcInstantChartPointMapper(resolver ?? new ResolutionSourceProvider(data.Resolution));

            var series = new GCandleSeries
            {
                Configuration = ohlcChartPointEvaluator,
                IncreaseBrush = Brushes.Aquamarine,
                DecreaseBrush = Brushes.LightCoral,
                Fill          = Brushes.Transparent,
                Title         = title
            };

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

            var values = new GearedValues <OhlcInstantChartPoint>();

            values.AddRange(data.OrderBy(x => x.DateTimeUtc).Select(i => new OhlcInstantChartPoint(i)));

            series.Values = values;

            return(series);
        }
            private void TransferToChartValuesHelper(
                List <PacketInfo> packetInfo,
                GearedValues <DateTimePoint> packetLengthChartValues,
                GearedValues <ObservablePoint> timeDiffChartValues,
                PacketInfoWrapper prevPacketInfoWrapper)
            {
                int timeDiffStartOffset = timeDiffChartValues.Count;
                List <DateTimePoint>   dateTimePoints = new List <DateTimePoint>();
                List <ObservablePoint> timeDiffPoints = new List <ObservablePoint>();

                foreach (PacketInfo p in packetInfo)
                {
                    DateTimePoint dtp = new DateTimePoint(p.time, p.length);
                    dateTimePoints.Add(dtp);

                    if (prevPacketInfoWrapper.p != null)
                    {
                        int diffMs =
                            (int)(p.time - prevPacketInfoWrapper.p.time).TotalMilliseconds;
                        ObservablePoint point =
                            new ObservablePoint(timeDiffPoints.Count + timeDiffStartOffset, diffMs);
                        timeDiffPoints.Add(point);
                    }
                    prevPacketInfoWrapper.p = p;
                }

                packetInfo.Clear();
                packetLengthChartValues.AddRange(dateTimePoints);
                timeDiffChartValues.AddRange(timeDiffPoints);
            }
        public MainMonitoringViewModel(IMainMonitoringView view) : base(view)
        {
            Formatter = value => value.ToString("0.###");
            AttEnable = true;
            AltMode   = true;
            NavMode   = true;

            rollEstPoints  = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
            rollMeasPoints = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
            rollRefPoints  = new GearedValues <LogPoint>().WithQuality(Quality.Medium);

            pitchEstPoints  = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
            pitchMeasPoints = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
            pitchRefPoints  = new GearedValues <LogPoint>().WithQuality(Quality.Medium);

            yawEstPoints  = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
            yawMeasPoints = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
            yawRefPoints  = new GearedValues <LogPoint>().WithQuality(Quality.Medium);

            heightEstPoints  = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
            heightMeasPoints = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
            heightRefPoints  = new GearedValues <LogPoint>().WithQuality(Quality.Medium);

            navXEstPoints  = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
            navXMeasPoints = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
            navXRefPoints  = new GearedValues <LogPoint>().WithQuality(Quality.Medium);

            navYEstPoints  = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
            navYMeasPoints = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
            navYRefPoints  = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
        }
Esempio n. 6
0
 public SimWindow(string simName, int noNodes, int benefitChosen, int costChosen, double selectionIntensityChosen, double roleConProbChosen, double roleNeighborConProbChosen, double roleMethodCopyProbChosen, double percentCooperators, int delay, string graphQuality, bool isEvolving, double mutationExtremeRMC, double mutationExtremeRMNC)
 {
     InitializeComponent();
     network  = new ProsperityNetwork.ProsperitySimulation(noNodes, benefitChosen, costChosen, selectionIntensityChosen, roleConProbChosen, roleNeighborConProbChosen, roleMethodCopyProbChosen, percentCooperators, delay, isEvolving, mutationExtremeRMC, mutationExtremeRMNC);
     evolving = isEvolving;
     paused   = false;
     if (graphQuality == "Low")
     {
         quality = Quality.Low;
     }
     else if (graphQuality == "Medium")
     {
         quality = Quality.Medium;
     }
     else if (graphQuality == "Highest")
     {
         quality = Quality.Highest;
     }
     else
     {
         quality = Quality.High;
     }
     prosperityValues              = new GearedValues <double>().WithQuality(quality);
     totalCoopValues               = new GearedValues <int>().WithQuality(quality);
     avrgCoopsValues               = new GearedValues <double>().WithQuality(quality);
     avrgRoleConProbValues         = new GearedValues <double>().WithQuality(quality);
     avrgRoleNeighborConProbValues = new GearedValues <double>().WithQuality(quality);
     //SetValue(QualityProperty, graphQuality);
     Task.Factory.StartNew(network.AsyncLoopStart(simName));
     timer = new Timer(GetFromSim, null, delay + 100, delay);
     Trace.WriteLine("--- Timer Start ---");
     //getFromSim();
 }
Esempio n. 7
0
        private void getResult(ObservablePoint[] ret, GearedValues <ObservablePoint> shortWave)
        {
            if (ret.Length == 4)
            {
                t1Ret = (ret[1].X - ret[0].X).ToString("N2") + " ms";
                t2Ret = (ret[2].X - ret[1].X).ToString("N2") + " ms";
                t3Ret = (ret[3].X - ret[2].X).ToString("N2") + " ms";
                t4Ret = (ret[3].X - ret[0].X).ToString("N2") + " ms";

                var arr1 = shortWave.Skip((int)(ret[0].X / 300 * 6000)).Take((int)((ret[1].X - ret[0].X) / 300 * 6000)).Select(x => Math.Round(x.Y, 2));
                var arr2 = shortWave.Skip((int)(ret[2].X / 300 * 6000)).Take((int)((ret[3].X - ret[2].X) / 300 * 6000)).Select(x => Math.Round(x.Y, 2));
                var arr3 = shortWave.Skip((int)(ret[1].X / 300 * 6000)).Take((int)((ret[2].X - ret[1].X) / 300 * 6000)).Select(x => Math.Round(x.Y, 2));

                //double r1 = LogNormal.Estimate(arr1).Mean;
                //double r2 = LogNormal.Estimate(arr2).Mean;
                //double r3 = LogNormal.Estimate(arr3).Mean;

                double r1 = GetElevationMode(arr1.ToList());
                double r2 = GetElevationMode(arr2.ToList());
                //double r3 = GetElevationMode(arr3.ToList());
                double r3 = LogNormal.Estimate(arr3).Mean;

                //var sss = new MathNet.Numerics.Differentiation.NumericalDerivative(20, 2);
                R1Ret = r1.ToString("N2") + " Ω";
                R2Ret = r2.ToString("N2") + " Ω";

                R1AndR2Ret = r3.ToString("N2") + " Ω";;
            }
        }
Esempio n. 8
0
        public PLGraphVM()
        {
            DataSeries = new SeriesCollection();
            var strategyPLValue = new GearedValues <ObservablePoint>();

            strategyPLValue.WithQuality(Quality.Highest);
            StrategyPL = new GLineSeries()
            {
                Title           = "Strategy P/L",
                Values          = strategyPLValue,
                Fill            = Brushes.Transparent,
                Stroke          = Brushes.Blue,
                StrokeThickness = 2,
                PointGeometry   = null
            };
            var benchmarkPLValue = new GearedValues <ObservablePoint>();

            benchmarkPLValue.WithQuality(Quality.Highest);
            BenchmarkPL = new GLineSeries()
            {
                Title           = "Benchmark P/L",
                Values          = benchmarkPLValue,
                Fill            = Brushes.Transparent,
                Stroke          = Brushes.DarkGray,
                StrokeThickness = 2,
                PointGeometry   = null
            };

            DataSeries.Add(StrategyPL);
            DataSeries.Add(BenchmarkPL);
        }
Esempio n. 9
0
        public SpeedTestVm()
        {
            Values      = new GearedValues <double>().WithQuality(Quality.Highest);
            ReadCommand = new RelayCommand(Read);
            StopCommand = new RelayCommand(Stop);
            CleaCommand = new RelayCommand(Clear);


            var watcher = DeviceInformation.CreateWatcher(_aqsAllBLEDevices, _requestedBLEProperties, DeviceInformationKind.AssociationEndpoint);

            watcher.Added += (DeviceWatcher sender, DeviceInformation devInfo) =>
            {
                if (_deviceList.FirstOrDefault(d => d.Id.Equals(devInfo.Id) || d.Name.Equals(devInfo.Name)) == null)
                {
                    _deviceList.Add(devInfo);
                }
            };
            watcher.Updated += (_, __) => { }; // We need handler for this event, even an empty!
            //Watch for a device being removed by the watcher
            watcher.Removed += (DeviceWatcher sender, DeviceInformationUpdate devInfo) =>
            {
                _deviceList.Remove(FindKnownDevice(devInfo.Id));
            };
            watcher.EnumerationCompleted += (DeviceWatcher sender, object arg) => { sender.Stop(); };
            watcher.Stopped += (DeviceWatcher sender, object arg) => { _deviceList.Clear(); sender.Start(); };
            watcher.Start();


            ReadCommand.Execute(null);
        }
Esempio n. 10
0
        public AttitudeMonitoringViewModel(IAttitudeMonitoringView view) : base(view)
        {
            Formatter = value => value.ToString("0.###");
            RotVis    = true;
            VelVis    = false;
            MotorVis  = false;

            rollEstPoints  = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
            rollMeasPoints = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
            rollRefPoints  = new GearedValues <LogPoint>().WithQuality(Quality.Medium);

            pitchEstPoints  = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
            pitchMeasPoints = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
            pitchRefPoints  = new GearedValues <LogPoint>().WithQuality(Quality.Medium);

            yawEstPoints  = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
            yawMeasPoints = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
            yawRefPoints  = new GearedValues <LogPoint>().WithQuality(Quality.Medium);

            velXPoints = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
            velYPoints = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
            velZPoints = new GearedValues <LogPoint>().WithQuality(Quality.Medium);

            motorFLPoints = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
            motorFRPoints = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
            motorBLPoints = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
            motorBRPoints = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
        }
Esempio n. 11
0
        private GearedValues <ObservablePoint> CutWave(GearedValues <ObservablePoint> wave, int cutHeaderLever = 400)
        {
            GearedValues <ObservablePoint> data = new GearedValues <ObservablePoint>();

            data.AddRange(wave.Skip(cutSkip).Take(cutTake));
            return(data);
        }
Esempio n. 12
0
 public SpeedTestVm()
 {
     Values      = new GearedValues <double>().WithQuality(Quality.High);
     ReadCommand = new RelayCommand(Read);
     StopCommand = new RelayCommand(Stop);
     CleaCommand = new RelayCommand(Clear);
 }
Esempio n. 13
0
        public TimeGraph()
        {
            InitializeComponent();

            mData = new GearedValues <double>().WithQuality(Quality.Highest);

            DataContext = this;
        }
        public AltitudeMonitoringViewModel(IAltitudeMonitoringView view) : base(view)
        {
            Formatter = value => value.ToString("0.###");

            heightEstPoints  = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
            heightMeasPoints = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
            heightRefPoints  = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
        }
Esempio n. 15
0
        public MotorMonitoringViewModel(IMotorMonitoringView view) : base(view)
        {
            Formatter = value => value.ToString("0.###");

            motorFLPoints = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
            motorFRPoints = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
            motorBLPoints = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
            motorBRPoints = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
        }
Esempio n. 16
0
 public SpeedTestVm()
 {
     SensorValues      = new GearedValues <long>().WithQuality(Quality.High);
     MaxSensorValues   = new GearedValues <long>().WithQuality(Quality.High);
     NoiseOffsetValues = new GearedValues <long>().WithQuality(Quality.High);
     rawSensorValues   = new GearedValues <long>().WithQuality(Quality.High);
     songAvgValues     = new GearedValues <long>().WithQuality(Quality.High);
     ModeValues        = new GearedValues <long>().WithQuality(Quality.Low);
 }
Esempio n. 17
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;
        }
        public void Read()
        {
            GearedValues <ObservablePoint> copyValues = new GearedValues <ObservablePoint>();

            if (IsReading)
            {
                return;
            }

            //lets keep in memory only the last 20000 records,
            //to keep everything running faster

            IsReading = true;

            Action readFromTread = () =>
            {
                while (IsReading)
                {
                    Thread.Sleep(1000);

                    //when multi threading avoid indexed calls like -> Values[0]
                    //instead enumerate the collection
                    //ChartValues/GearedValues returns a thread safe copy once you enumerate it.
                    //TIPS: use foreach instead of for
                    //LINQ methods also enumerate the collections

                    chartValue.Clear();
                    chartValue.AddRange(ChartsData.ChartPositionTimeValues);
                    int len = chartValue.Count;
                    if (len > 0)
                    {
                        //copyValues.AddRange(UAClientForm.ChartPositionTimeValues);

                        ChartsData.CartesianChartPositionTimeValues.AddRange(chartValue);

                        for (int i = 0; i < len & ChartsData.ChartPositionTimeValues.Count > 1; i++)
                        {
                            ChartsData.ChartPositionTimeValues.RemoveAt(0);
                        }
                    }
                    chartValue.Clear();
                }
            };

            //2 different tasks adding a value every ms
            //add as many tasks as you want to test this feature
            Task.Factory.StartNew(readFromTread);
            //Task.Factory.StartNew(readFromTread);
            //Task.Factory.StartNew(readFromTread);
            //Task.Factory.StartNew(readFromTread);
            //Task.Factory.StartNew(readFromTread);
            //Task.Factory.StartNew(readFromTread);
            //Task.Factory.StartNew(readFromTread);
            //Task.Factory.StartNew(readFromTread);
        }
Esempio n. 19
0
        private void DrawWave(GearedValues <ObservablePoint> data)
        {
            var maxf = data.Select(x => x.Y).Max();
            var minf = data.Select(x => x.Y).Min();
            GearedValues <ObservablePoint> tempdata = new GearedValues <ObservablePoint>();

            tempdata.AddRange(data.Select(x =>
            {
                x.Y = maxf - Math.Abs(x.Y - minf);
                return(x);
            }));

            var max     = Math.Round(tempdata.Select(x => x.Y).Max(), 2);
            var min     = Math.Round(tempdata.Select(x => x.Y).Min(), 2);
            var avg     = Math.Round((Math.Abs(max) + Math.Abs(min)) / 5, 2);
            var step    = Math.Ceiling(Math.Abs(min) / avg);
            var stepmax = Math.Ceiling(Math.Abs(max) / avg);

            min            = min >= 0 ? (avg * step) : (-1 * avg * step);
            max            = max >= 0 ? (avg * stepmax) : (-1 * avg * stepmax);
            maxVal         = max;
            minVal         = min;
            Yaxis.MaxValue = max;
            Yaxis.MinValue = min;
            XFormatter     = val => (val).ToString() + "ms";
            YFormatter     = val =>
            {
                return(Math.Round((max - Math.Abs(val - min)), 1).ToString() + "Ω");
            };

            YaxisSpe.Step = Math.Abs(avg);
            series        = new SeriesCollection();
            series.Add(new GLineSeries
            {
                StrokeThickness   = 2,
                Stroke            = new SolidColorBrush(System.Windows.Media.Color.FromRgb(28, 142, 196)),
                Fill              = System.Windows.Media.Brushes.Transparent,
                LineSmoothness    = 10,//0为折现样式
                PointGeometrySize = 0,
                PointForeground   = new SolidColorBrush(System.Windows.Media.Color.FromRgb(34, 46, 49)),
                Values            = tempdata
            });
            chart_wave.Series = series;

            //Yaxis.Sections = new SectionsCollection {
            //     new AxisSection
            //        {
            //            Value = maxVal-Math.Abs(minVal),
            //             Stroke = Brushes.Red,
            //            StrokeThickness = 1.5,
            //        },

            //};
        }
Esempio n. 20
0
 private void AddSeries(GearedValues <long> values, string title, Color color, double strokeThickness, SolidColorBrush fillBrush, DoubleCollection strokeDashArray = null)
 {
     cartesianChart1.Series.Add(new GLineSeries
     {
         Values          = values,
         Title           = title,
         Stroke          = new SolidColorBrush(color),
         Fill            = fillBrush,
         StrokeThickness = strokeThickness,
         StrokeDashArray = strokeDashArray,
         PointGeometry   = null //use a null geometry when you have many series
     });
 }
Esempio n. 21
0
        public BaseGraph()
        {
            //SeriesCollection = new SeriesCollection { };
            XFormatter = value => value.ToString("0");
            YFormatter = value => value.ToString("0.##");
            values     = new GearedValues <double>();

            //modifying any series values will also animate and update the chart
            //SeriesCollection[0].Values.Add(5d);

            //DataContext = this;
            //values = new GearedValues<double>().WithQuality(quality);
        }
Esempio n. 22
0
        public AngleMonitoringViewModel(IAngleMonitoringView view) : base(view)
        {
            Formatter = value => value.ToString("0.###");

            rollMeasPoints = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
            rollRefPoints  = new GearedValues <LogPoint>().WithQuality(Quality.Medium);

            pitchMeasPoints = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
            pitchRefPoints  = new GearedValues <LogPoint>().WithQuality(Quality.Medium);

            yawMeasPoints = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
            yawRefPoints  = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
        }
Esempio n. 23
0
        public MainWindow()
        {
            InitializeComponent();

            Graph.DisableAnimations = true;
            Graph.AnimationsSpeed   = TimeSpan.FromMilliseconds(50);
            Graph.Hoverable         = false;

            GearedValues <double> gvalues1 = new GearedValues <double>();

            gvalues1.WithQuality(Quality.Low);
            GearedValues <double> gvalues2 = new GearedValues <double>();

            gvalues2.WithQuality(Quality.Low);
            GearedValues <double> gvalues3 = new GearedValues <double>();

            gvalues3.WithQuality(Quality.Low);
            GearedValues <double> gvalues4 = new GearedValues <double>();

            gvalues4.WithQuality(Quality.Low);

            SeriesCollection = new SeriesCollection
            {
                new GLineSeries
                {
                    Title          = "Total Cost 1",
                    Values         = gvalues1,
                    LineSmoothness = 1.0,
                },
                new GLineSeries
                {
                    Title          = "Total Cost 2",
                    Values         = gvalues2,
                    LineSmoothness = 1.0,
                },
                new GLineSeries
                {
                    Title          = "Total Cost 3",
                    Values         = gvalues3,
                    LineSmoothness = 1.0,
                },
                new GLineSeries
                {
                    Title          = "Total Cost 4",
                    Values         = gvalues4,
                    LineSmoothness = 1.0,
                },
            };
            DataContext = this;
            Loaded     += MainWindow_Loaded;
        }
Esempio n. 24
0
        private Tuple <int, int> CutWave(GearedValues <ObservablePoint> wave, int cutHeaderLever = 400)
        {
            double needSelectData = Math.Round((wave.Select(x => x.Y).Max() + wave.Select(x => x.Y).Min()) / 2, 3);

            ObservablePoint[] twopoint = new ObservablePoint[2];
            double[]          tempD    = wave.Select(x => Math.Round(x.Y, 3)).ToArray();
            double            Xmin     = 0.00;
            double            Xmax     = 300.00;

            for (int i = 1; i < 6000; i++)
            {
                if ((tempD[i - 1] >= needSelectData && tempD[i] <= needSelectData) || (tempD[i] >= needSelectData && tempD[i - 1] <= needSelectData))
                {
                    twopoint[0] = wave[i];
                    Xmin        = wave[i].X;
                    break;
                }
            }
            for (int i = 5999; i > 1; i--)
            {
                if ((tempD[i - 1] >= needSelectData && tempD[i] <= needSelectData) || (tempD[i] >= needSelectData && tempD[i - 1] <= needSelectData))
                {
                    Xmax = wave[i].X;
                    break;
                }
            }


            int skip = 0;
            int take = 0;

            if (Xmin < 20)
            {
                skip = 0;
            }
            else
            {
                skip = (int)(Xmin * 20 - cutHeaderLever);
            }

            if (Xmax > 280)
            {
                take = (int)((300 - Xmin) * 20);
            }
            else
            {
                take = (int)((Xmax - Xmin) * 20 + cutHeaderLever);
            }

            return(new Tuple <int, int>(skip, take));
        }
Esempio n. 25
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;
        }
Esempio n. 26
0
        private void DrawSpectrum()
        {
            chartVals = new GearedValues <ObservablePoint>();
            List <ObservablePoint> list = new List <ObservablePoint>();

            for (int i = 0; i < counts.Length; ++i) //
            {
                list.Add(new ObservablePoint(calibrationZero + i * calibrationSlope, counts[i]));
            }
            chartVals = list.AsGearedValues().WithQuality(Quality.Highest);

            SpecChart.Series = new SeriesCollection()
            {
                new GStepLineSeries()
                {
                    Title         = "Spectrum",
                    PointGeometry = null,
                    Values        = chartVals
                }
            };

            if (SpecChart.AxisY.Count() == 0)
            {
                SpecChart.AxisY.Add(new Axis()
                {
                    MinValue = 0
                });
            }
            else
            {
                SpecChart.AxisY[0].MinValue = 0;
            }
            if (SpecChart.AxisX.Count() == 0)
            {
                SpecChart.AxisX.Add(new Axis()
                {
                    MinValue = 0
                });
            }
            else
            {
                SpecChart.AxisX[0].MinValue = 0;
            }
        }
Esempio n. 27
0
        //will take the filename as an argument and then stream data into ISegyFile line
        //will tell the number of channels and bytes in a segy file
        //will return true if this completes and will return false if no filename is stored after the first function GetFile()

        protected override Boolean readData(string filePath)
        {
            Debug.WriteLine("Starting readData function!");
            if (filePath != null)
            {
                SEG2PickerTest newSEG2 = new SEG2PickerTest();

                //ISeismicReader seisRead;
                //seisRead = newSEGY;

                newSEG2.Read(filePath);

                //IList<SEG2Trace> trace = new List<SEG2Trace>();
                //function that will read in all SEG2 data and store it in multiple ILists

                //should return the number of traces (was a private variable so had to create a getNumOfTraces() function
                this.numChannels = newSEG2.getNumOfTraces();
                Debug.WriteLine("Number of Channels: " + numChannels);
                //int counter = 1;
                Debug.WriteLine("Number of Samples per Trace: " + newSEG2.getNumSampsPerTrace());
                Debug.WriteLine("Number of Samples per Trace: " + newSEG2.Traces[0].numSampsPerTrace);
                //cast every trace into geared amplitudes
                //foreach (var traces in trace)
                for (int m = 0; m < this.numChannels; m++)
                {
                    //Iterates the data backwards, this displays the data top -> bottom
                    IList <float> temp = new List <float>();
                    for (int j = ((int)newSEG2.getNumSampsPerTrace() - 1); j >= 0; j--)
                    //for (int j = ((int)newSEG2.Traces[m].numSampsPerTrace - 1); j >= 0; j--)
                    {
                        temp.Add(newSEG2.Traces[m].Amplitudes[j]);
                        //temp.Add(trace[m].Amplitudes[j]);
                    }
                    GearedValues <float> gearedTemp = new GearedValues <float>(temp);
                    this.graphStorage.Add(gearedTemp);
                    Debug.WriteLine("!!!!!! " + temp.Count);
                }
                return(true);
            }
            else
            {
                return(false);
            }
        } //end of readData()
Esempio n. 28
0
        private void AddValue(string longFrag, ICollection <long> valueBuffer, GearedValues <long> sensorValues, string animationTitle = null)
        {
            var value = Parse(longFrag);

            if (valueBuffer.Count >= _capacity)
            {
                sensorValues.AddRange(valueBuffer);
                valueBuffer.Clear();
            }

            valueBuffer.Add(value);
            if (animationTitle != null)
            {
                sensorValues.AddRange(valueBuffer);
                valueBuffer.Clear();

                AddAnimationTitle(sensorValues.Count, animationTitle);
            }
        }
        public StackedSeriesViewModel()
        {
            LecturePoint.RegisterInLiveCharts();

            Values1 = new GearedValues <LecturePoint>().WithQuality(Quality.High);
            Values2 = new GearedValues <LecturePoint>().WithQuality(Quality.High);
            Values3 = new GearedValues <LecturePoint>().WithQuality(Quality.High);

            Step       = TimeSpan.FromSeconds(5).Ticks;
            XFormatter = val =>
            {
                var ts = TimeSpan.FromTicks((long)val);

                return(string.Format("{0}' {1}''", ts.Minutes,
                                     ts.Seconds));
            };
            YFormatter = val => val.ToString("N2");
            From       = double.NaN;
            To         = double.NaN;
        }
        public NavigationMonitoringViewModel(INavigationMonitoringView view) : base(view)
        {
            Formatter = value => value.ToString("0.###");


            navXEstPoints  = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
            navXMeasPoints = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
            navXRefPoints  = new GearedValues <LogPoint>().WithQuality(Quality.Medium);

            navYEstPoints  = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
            navYMeasPoints = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
            navYRefPoints  = new GearedValues <LogPoint>().WithQuality(Quality.Medium);

            navXVelPoints = new GearedValues <LogPoint>().WithQuality(Quality.Medium);
            navYVelPoints = new GearedValues <LogPoint>().WithQuality(Quality.Medium);

            navTrackingEstPoints  = new GearedValues <PosistionPoint>().WithQuality(Quality.High);
            navTrackingMeasPoints = new GearedValues <PosistionPoint>().WithQuality(Quality.High);
            navTrackingRefPoints  = new GearedValues <PosistionPoint>().WithQuality(Quality.High);
        }