AddPassiveListener() public method

Passive listeners are the listeners who listen for all currently active sensors
public AddPassiveListener ( Action listener ) : void
listener Action /// A ///
return void
Example #1
0
        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);
                    }
                }
            }
        }
Example #2
0
        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);
                }
            }
            }
        }