Esempio n. 1
0
        private void ChangeDisplayItem(ReadingsStorage storage, ObservableCollection <V> list)
        {
            List <V> newReadings = new List <V>();

            storage.Each(r =>
            {
                newReadings.Add(new V(r.Item1, r.Item2.GetValue(displayValue)));
            });
            list.Clear();
            list.AddRange(newReadings);
        }
Esempio n. 2
0
        public GraphViewModel(string displayValue, ReadingsStorage lineHistory, ReadingsStorage barHistory,
                              TimeSpan span,
                              bool displayLine = true,
                              bool displayBars = true)
        {
            this.displayValue = displayValue;
            this.lineHistory  = lineHistory;
            this.barHistory   = barHistory;
            this.displayBars  = displayBars;
            this.displayLine  = displayLine;
            this.span         = span;

            barValues  = new ObservableCollection <V>();
            lineValues = new ObservableCollection <V>();
        }
Esempio n. 3
0
        private void AddReading(ReadingsStorage storage, ObservableCollection <V> list)
        {
            var latest = storage.GetLatests();

            list.Add(new V(latest.Item1, latest.Item2.GetValue(displayValue)));
        }
Esempio n. 4
0
        public MeasurementViewModel(Guid id, MeasurementSettings settings, IMeterReader reader)
        {
            MinorReadings        = new ConcurrentQueue <Tuple <DateTime, ReadingData> >();
            MajorReadings        = new ConcurrentQueue <Tuple <DateTime, ReadingData> >();
            OctaveValues         = new ObservableCollection <OctaveBandGraphValue>();
            MinorSpan            = TimeSpan.FromTicks(settings.MinorInterval.Ticks * 15);
            MajorSpan            = TimeSpan.FromTicks(settings.MajorInterval.Ticks * 15);
            readingHistory       = new ReadingsStorage(MajorSpan);
            minorIntervalHistory = new ReadingsStorage(MinorSpan);
            majorIntervalHistory = new ReadingsStorage(majorSpan);
            minorGraphViewModel  = new GraphViewModel("LAeq", readingHistory, minorIntervalHistory, MinorSpan);
            majorGraphViewModel  = new GraphViewModel("LAeq", null, majorIntervalHistory, MajorSpan, false, true);
            lastMinorInterval    = new DateTime();
            lastMajorInterval    = new DateTime();

            started       = DateTime.Now;
            popOutWindows = new LinkedList <MetroWindow>();
            this.engine   = new AudioViewEngine(settings.MinorInterval, settings.MajorInterval, reader);
            this.settings = settings;

            this.engine.ConnectionStatusEvent += connected =>
            {
                if (ConnectionStatus == connected)
                {
                    return; // No need
                }
                Task.Run(() =>
                {
                    ConnectionStatus = connected;
                    DispatcherHelper.CheckBeginInvokeOnUI(() =>
                    {
                        OnPropertyChanged(nameof(IsDisconnected));
                    });
                });
            };

            if (settings.IsLocal)
            {
                // Registering the TCP Server for remote connections
                tcpServer = new TCPServerListener(settings);
                this.engine.RegisterListener(tcpServer);

                // Register the data storange unit
                dataStorage = new DataStorageMeterListener(id, DateTime.Now, settings);
                this.engine.RegisterListener(dataStorage);
            }

            this.engine.RegisterListener(new LocalStorageListener(AudioViewSettings.Instance.AutoSaveLocation, settings.ProjectName));

            this.engine.RegisterListener(this);
            MinorClock = new AudioViewCountDownViewModel(false,
                                                         settings.MinorInterval,
                                                         settings.MinorDBLimit,
                                                         settings.MinorClockMainItem,
                                                         settings.MinorClockSecondaryItem);
            MajorClock = new AudioViewCountDownViewModel(true,
                                                         settings.MajorInterval,
                                                         settings.MajorDBLimit,
                                                         settings.MajorClockMainItem,
                                                         settings.MajorClockSecondaryItem);
            this.engine.RegisterListener(MinorClock);
            this.engine.RegisterListener(MajorClock);
            this.engine.Start();

            Title = settings.ProjectName;
        }