Example #1
0
 public MeasurementController(MeasurementSettings measurementSettings, StatusModel statusModel)
 {
     this.measurementSettings = measurementSettings;
     this.idsToTimers         = new Dictionary <int, MeasurementTimer>();
     this.downloader          = new Downloader();
     this.statusModel         = statusModel;
 }
        public DataStorageMeterListener(Guid id, DateTime started, MeasurementSettings settings)
        {
            Id = id;
            Settings = settings;
            created = started;

            initalCreate = Task.Run(async () =>
            {
                try
                {
                    using (var audioViewEntities = new AudioViewEntities())
                    {
                        if (!audioViewEntities.Projects.Where(x => x.Id == id).Any())
                        {
                            audioViewEntities.Projects.Add(new Project()
                            {
                                Id = id,
                                Created = started,
                                MinorDBLimit = settings.MinorDBLimit,
                                MajorDBLimit = settings.MajorDBLimit,
                                MajorInterval = settings.MajorInterval.Ticks,
                                MinorInterval = settings.MinorInterval.Ticks,
                                Name = settings.ProjectName,
                                Number = settings.ProjectNumber
                            });
                            await audioViewEntities.SaveChangesAsync().ConfigureAwait(false);
                        }
                    }
                }
                catch (Exception exp)
                {
                    logger.Warn(exp, "Unable to add project \"{0}\" to database, do we have internet access?", settings.ProjectName);
                }
            });
        }
Example #3
0
        public DataStorageMeterListener(Guid id, DateTime started, MeasurementSettings settings)
        {
            Id       = id;
            Settings = settings;
            created  = started;

            initalCreate = Task.Run(async() =>
            {
                try
                {
                    using (var audioViewEntities = new AudioViewEntities())
                    {
                        if (!audioViewEntities.Projects.Any(x => x.Id == id))
                        {
                            audioViewEntities.Projects.Add(new Project()
                            {
                                Id            = id,
                                Created       = started,
                                MinorDBLimit  = settings.MinorDBLimit,
                                MajorDBLimit  = settings.MajorDBLimit,
                                MajorInterval = settings.MajorInterval.Ticks,
                                MinorInterval = settings.MinorInterval.Ticks,
                                Name          = settings.ProjectName,
                                Number        = settings.ProjectNumber
                            });
                            await audioViewEntities.SaveChangesAsync().ConfigureAwait(false);
                        }
                    }
                }
                catch (Exception exp)
                {
                    logger.Warn(exp, "Unable to add project \"{0}\" to database, do we have internet access?", settings.ProjectName);
                }
            });
        }
 public OctaveBandWindowViewModel(MeasurementSettings settings, OctaveBand band, bool building)
 {
     this.band     = band;
     _settings     = settings;
     this.building = building;
     OctaveValues  = new ObservableCollection <OctaveBandGraphValue>();
 }
Example #5
0
        private void LoadSettings()
        {
            Logger.Log(LogLevel.Debug, "Loading settings...");
            var loader = new SettingsLoader <MeasurementSettings>();

            measurementSettings = loader.Load(settingsFileName);
        }
 public TCPServerListener(MeasurementSettings settings)
 {
     this.settings = settings;
     this.runServer = true;
     this.cancellationToken = new CancellationTokenSource();
     this.tcpClients = new LinkedList<TcpClient>();
     RunServerAsync();
 }
 public TCPServerListener(MeasurementSettings settings)
 {
     this.settings          = settings;
     this.runServer         = true;
     this.cancellationToken = new CancellationTokenSource();
     this.tcpClients        = new LinkedList <TcpClient>();
     RunServerAsync();
 }
 private Task <bool> TestDevice()
 {
     return(Task.Run(async() =>
     {
         logger.Debug("Testing remote device {0}:{1}", RemoteIpAddress, RemotePort);
         var settings = await RemoteMeterReader.TestConenction(RemoteIpAddress, int.Parse(RemotePort)).ConfigureAwait(false);
         this.remoteSettings = settings;
         return settings != null;
     }));
 }
Example #9
0
 private void Form_SettingsUpdatedEvent(object sender, SettingsEventArgs e)
 {
     measurementSettings = e.Settings;
     SaveSettings();
 }
Example #10
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;
        }
Example #11
0
 public SettingsEventArgs(MeasurementSettings settings)
 {
     Settings = settings;
 }