// Load sensor data manager private void LoadSensorDataReaders() { var sensorList = dbManager.dc.BaseSensorConfigs.Select(t => t); var tempDataReaders = new List <BaseSensorReader>(); var tempConfigList = new List <BaseSensorConfig>(); var tempSensorNames = new List <string>(); foreach (var sensor in sensorList) { if (!sensor.IsActive) { continue; } BaseSensorReader reader = SensorReaderFactory.CreateReader(sensor); if (reader == null) { continue; } tempDataReaders.Add(reader); tempConfigList.Add(sensor); tempSensorNames.Add(sensor.Name + "_" + reader.ToString()); } dataReaders = tempDataReaders.ToArray(); configs = tempConfigList.ToArray(); sensorNames = tempSensorNames.ToArray(); }
public static BaseSensorReader CreateReader(BaseSensorConfig config) { BaseSensorReader manager = null; switch (config.SensorType) { case SensorType.Temperature: manager = new TemperatrueSensorReader( config.Name, config.MadeTime, config.SensorType, config.IsActive, ((TempertaureSensorConfig)config).CoreIndex); break; case SensorType.Cpu_occupied: manager = new CpuSensorReader( config.Name, config.MadeTime, config.SensorType, config.IsActive, ((CpuSensorConfig)config).ProcessType); break; case SensorType.Memory_usage: manager = new MemorySensorReader( config.Name, config.MadeTime, config.SensorType, config.IsActive); break; case SensorType.Modbus: manager = new ModbusSensorReader( config.Name, config.MadeTime, config.SensorType, config.IsActive, ((ModbusSensorConfig)config).Ip, ((ModbusSensorConfig)config).Port, ((ModbusSensorConfig)config).Address); break; case SensorType.Omap: manager = new OmapSensorReader( config.Name, config.MadeTime, config.SensorType, config.IsActive, ((OmapSensorConfig)config).OmapType, ((OmapSensorConfig)config).Ip); break; } //manager = FastMapper.TypeAdapter.Adapt<BaseSensorConfig, TemperatrueSensorReader>(config); return(manager); }