public LiveWifiAndBluetoothShellDataViewModel(IBluetoothFinder bluetoothFinder,
                                                      IShellTemperatureRepository <ShellTemp> shellTemperatureRepository,
                                                      IShellTemperatureRepository <SdCardShellTemp> sdCardShellTemperatureRepository,
                                                      IDeviceRepository <DeviceInfo> deviceRepository,
                                                      IConfiguration configuration,
                                                      BluetoothConnectionSubject subject,
                                                      TemperatureSubject temperatureSubject,
                                                      ILogger <LiveBluetoothOnlyShellDataViewModel> logger,
                                                      OutlierDetector outlierDetector,
                                                      ClearList clear,
                                                      IRepository <ShellTemperatureComment> commentRepository,
                                                      IReadingCommentRepository <ReadingComment> readingCommentRepository,
                                                      IRepository <Positions> positionRepository,
                                                      IRepository <ShellTemperaturePosition> shellTempPositionRepository,
                                                      IRepository <SdCardShellTemperatureComment> sdCardCommentRepository)
            : base(bluetoothFinder, shellTemperatureRepository, sdCardShellTemperatureRepository, deviceRepository, configuration, subject,
                   temperatureSubject, logger, outlierDetector, clear, commentRepository, readingCommentRepository,
                   positionRepository, shellTempPositionRepository, sdCardCommentRepository)
        {
            _shellTemperatureRepository = shellTemperatureRepository;

            IList <DeviceInfo> potentialWifiDevices = FindPotentialWifiDevices();

            foreach (DeviceInfo device in potentialWifiDevices.ToList())
            {
                DateTime start = DateTime.Now.AddMinutes(-2);
                DateTime end   = DateTime.Now;

                WifiDevice wifiDevice = new WifiDevice(device.DeviceName, device.DeviceAddress, start);

                IEnumerable <ShellTemp> shellTemps = _shellTemperatureRepository.GetShellTemperatureData(start, end,
                                                                                                         device.DeviceName, device.DeviceAddress);
                ShellTemp[] dataReadings = shellTemps as ShellTemp[] ?? shellTemps.ToArray();

                if (dataReadings.Length == 0)
                {
                    potentialWifiDevices.Remove(device);
                }
                else
                {
                    SetWifiDeviceDataReadings(wifiDevice, dataReadings);
                    SetWifiDeviceDataPoints(wifiDevice);
                    InstantiateNewDevice(wifiDevice);

                    wifiDevice.State.Message = "Connected To - " + wifiDevice.DeviceName;
                }
            }

            SetSelectedDeviceWhenNull();
            if (Devices.Count == 1) // only one in devices so, must be selected
            {
                SetConnectionStatus(SelectedDevice, DeviceConnectionStatus.CONNECTED);
            }

            SetCanRemoveDevices();
        }
Example #2
0
 public LiveBluetoothOnlyShellDataViewModel(IBluetoothFinder bluetoothFinder,
                                            IShellTemperatureRepository <ShellTemp> shellTemperatureRepository,
                                            IShellTemperatureRepository <SdCardShellTemp> sdCardShellTemperatureRepository,
                                            IDeviceRepository <DeviceInfo> deviceRepository,
                                            IConfiguration configuration,
                                            BluetoothConnectionSubject subject,
                                            TemperatureSubject temperatureSubject,
                                            ILogger <LiveBluetoothOnlyShellDataViewModel> logger,
                                            OutlierDetector outlierDetector,
                                            ClearList clear,
                                            IRepository <ShellTemperatureComment> commentRepository,
                                            IReadingCommentRepository <ReadingComment> readingCommentRepository,
                                            IRepository <Positions> positionRepository,
                                            IRepository <ShellTemperaturePosition> shellTempPositionRepository,
                                            IRepository <SdCardShellTemperatureComment> sdCardCommentRepository)
     : base(bluetoothFinder, shellTemperatureRepository, sdCardShellTemperatureRepository, deviceRepository,
            configuration, subject,
            temperatureSubject, logger, outlierDetector, clear, commentRepository, readingCommentRepository,
            positionRepository, shellTempPositionRepository, sdCardCommentRepository)
 {
 }