private void LoadCollection() { try { openFileDialog = new OpenFileDialog(); // ------------------------------------ openFileDialog.Filter = "Json file (.json)|*.json|All Files(.*)|*.*"; openFileDialog.FileName = "Путь до файла"; openFileDialog.Title = "Загрузить данные с файла"; openFileDialog.FilterIndex = 0; openFileDialog.DefaultExt = FileManager.FilePath; // ------------------------------------ bool?isOk = openFileDialog.ShowDialog() ?? false; if (isOk.Value) { Sensors.Clear(); FileManager.FilePath = Path.GetDirectoryName(openFileDialog.FileName); LogView = $"Load data from {FileManager.FilePath}"; List <Sensor> collection = FileManager.Read(FileManager.FilePath); collection.ForEach(sensor => Sensors.Add(new SensorViewModel(sensor))); UpdateCharts(); } } catch (Exception ex) { var log = ExceptionHandler.Handler(ex); Log.WriteLog(log); MessageBox.Show(log, "Error! ", MessageBoxButton.OK, MessageBoxImage.Error); LogView = $"Error! {log}"; } }
/// <summary> /// Clears the configurations. /// </summary> private void ClearConfig() { Positions.Clear(); Relays.Clear(); Sections.Clear(); Sensors.Clear(); Switchs.Clear(); }
public void ClearAll() { Parallel.ForEach(Sensors, sensor => { sensor.Dispose(); while (!sensor.IsDisposed) { Thread.Sleep(PediatricSoftConstants.StateHandlerSleepTime); } }); Sensors.Clear(); RaisePropertyChanged("SensorCount"); }
private void GenerateCollection() { try { LogView = $"Generate new Charts"; Sensors.Clear(); Generator.GetSensors().ForEach(item => Sensors.Add(new SensorViewModel(item))); UpdateCharts(); //Строим графики } catch (Exception ex) { var log = ExceptionHandler.Handler(ex); Log.WriteLog(log); MessageBox.Show(log, "Error! ", MessageBoxButton.OK, MessageBoxImage.Error); LogView = $"Error! {log}"; } }
private void Disconnect() { IsConnected = false; _sensorsReader?.StopPolling(); Sensors?.Clear(); if (_iotHubDeviceGateways?.Values == null) { return; } foreach (var iotHubDeviceGateway in _iotHubDeviceGateways.Values) { iotHubDeviceGateway?.Disconnect(); } }
static public void ReloadConfiguration() { Sensors.Clear(); SensorsConfiguration = SensorsConfiguration.Load(); foreach (var sensorConfiguration in SensorsConfiguration.Sensors) { switch (sensorConfiguration.SensorType) { case Configuration.SensorType.GrovePi: var grovePiSensorConfiguration = sensorConfiguration as GrovePiSensorConfiguration; Sensors.Add(GrovePiSensorBuilder.CreateSensor( grovePiSensorConfiguration.GroveSensorType, grovePiSensorConfiguration.GrovePort, grovePiSensorConfiguration.Name, grovePiSensorConfiguration.SensorId, grovePiSensorConfiguration.RgbDisplay )); break; case Configuration.SensorType.OpenWeatherMap: var openWeatherMapSensorConfiguration = sensorConfiguration as OpenWeatherMapSensorConfiguration; Sensors.Add(WeatherSensorBuilder.GetSensor( openWeatherMapSensorConfiguration.SensorWeatherType, openWeatherMapSensorConfiguration.Name, openWeatherMapSensorConfiguration.SensorId, openWeatherMapSensorConfiguration.RgbDisplay )); break; default: throw new Exception("Unsupported SensorType in SensorsManager"); } } }
private void Port_UpdateCommandSended(object sender, EventArgs e) { Sensors.Clear(); }