public AddListener ( Sensor sensor, Action |
||
sensor | Sensor | |
listener | Action |
|
리턴 | void |
public virtual void Attach(SensorRegistry registry) { if (this.Registry != null) { throw new Exception("Can't attach: Invalid State"); } this.Registry = registry; Settings.Keys.ToList().ForEach((id) => { var set = Settings[id]; var sensor = Registry.Sensor(id); if (sensor == null) { return; } if (set.id != sensor.ID) { set.id = sensor.ID; Settings.Remove(id); Settings.Add(set.id, set); } Logger.trace("SensorTrack", "attach " + set.id + " period " + set.period + " length " + set.length + " gap " + set.gap); try{ Registry.AddListener(sensor, this.SensorChanged, set.period); }catch (Exception) { Logger.trace("SensorTrack", "attach failed" + sensor.ID); } }); if (this.TrackPassive) { Registry.AddPassiveListener(this.SensorChanged); } if (this.TrackAccum) { foreach (var s in Registry.Sensors.Where(s => s is IAccumulatorSensor)) { try{ Registry.AddListener(s, this.SensorChanged); }catch (Exception) { Logger.trace("SensorTrack", "attach failed" + s.ID); } } } }
public virtual void Attach(SensorRegistry registry) { if (this.Registry != null) throw new Exception("Can't attach: Invalid State"); this.Registry = registry; Settings.Keys.ToList().ForEach((id) => { var set = Settings[id]; var sensor = Registry.Sensor(id); if (sensor == null) return; if (set.id != sensor.ID) { set.id = sensor.ID; Settings.Remove(id); Settings.Add(set.id, set); } Logger.trace("SensorTrack", "attach " +set.id + " period " + set.period + " length " + set.length + " gap "+ set.gap); try{ Registry.AddListener(sensor, this.SensorChanged, set.period); }catch(Exception){ Logger.trace("SensorTrack", "attach failed" +sensor.ID); } }); if (this.TrackPassive) { Registry.AddPassiveListener(this.SensorChanged); } if (this.TrackAccum) { foreach(var s in Registry.Sensors.Where(s => s is IAccumulatorSensor)){ try{ Registry.AddListener(s, this.SensorChanged); }catch(Exception){ Logger.trace("SensorTrack", "attach failed" +s.ID); } } } }