Skip to content
This repository
Browse code

fix in cyclic sensor dependency on itself (when overriding sensors)

  • Loading branch information...
commit e1ac596182ae2e6ca0a86d3286df621e62e8eddc 1 parent 4ad643f
cail authored March 15, 2013
11  src/elm/SensorRegistry.cs
@@ -161,14 +161,23 @@ public IEnumerable<Sensor> Sensors
161 161
     /// </summary>
162 162
     public Sensor Sensor(string id)
163 163
     {
  164
+        return Sensor(id, null);
  165
+    }
  166
+    
  167
+    public Sensor Sensor(string id, Sensor notthis)
  168
+    {
164 169
         Sensor value;
165 170
         if (sensors.TryGetValue(id, out value))
166 171
             return value;
167 172
         else if (sensorNames.TryGetValue(id, out value))
  173
+        {
  174
+            if (value == notthis)
  175
+                value = sensors.Values.FirstOrDefault( (s) => s.Name == id && s != notthis);
168 176
             return value;
169  
-        else
  177
+        }else
170 178
             return null;
171 179
     }
  180
+    
172 181
     public SensorListener[] ActiveSensors
173 182
     {
174 183
         get{
4  src/elm/common/DerivedSensor.cs
@@ -51,9 +51,9 @@ public DerivedSensor(string id, string a, string b, bool triggerA, bool triggerB
51 51
         protected virtual void LoadBaseSensors()
52 52
         {
53 53
             if (this.aid != null && this.a == null)
54  
-                this.a = base.registry.Sensor(this.aid);
  54
+                this.a = base.registry.Sensor(this.aid, this);
55 55
             if (this.bid != null && this.b == null)
56  
-                this.b = base.registry.Sensor(this.bid);
  56
+                this.b = base.registry.Sensor(this.bid, this);
57 57
         }
58 58
 
59 59
         protected override void Activate()

0 notes on commit e1ac596

Please sign in to comment.
Something went wrong with that request. Please try again.