Permalink
Browse files

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

  • Loading branch information...
1 parent 4ad643f commit e1ac596182ae2e6ca0a86d3286df621e62e8eddc @cail committed Mar 15, 2013
Showing with 12 additions and 3 deletions.
  1. +10 −1 src/elm/SensorRegistry.cs
  2. +2 −2 src/elm/common/DerivedSensor.cs
@@ -161,14 +161,23 @@ public IEnumerable<Sensor> Sensors
/// </summary>
public Sensor Sensor(string id)
{
+ return Sensor(id, null);
+ }
+
+ public Sensor Sensor(string id, Sensor notthis)
+ {
Sensor value;
if (sensors.TryGetValue(id, out value))
return value;
else if (sensorNames.TryGetValue(id, out value))
+ {
+ if (value == notthis)
+ value = sensors.Values.FirstOrDefault( (s) => s.Name == id && s != notthis);
return value;
- else
+ }else
return null;
}
+
public SensorListener[] ActiveSensors
{
get{
@@ -51,9 +51,9 @@ public DerivedSensor(string id, string a, string b, bool triggerA, bool triggerB
protected virtual void LoadBaseSensors()
{
if (this.aid != null && this.a == null)
- this.a = base.registry.Sensor(this.aid);
+ this.a = base.registry.Sensor(this.aid, this);
if (this.bid != null && this.b == null)
- this.b = base.registry.Sensor(this.bid);
+ this.b = base.registry.Sensor(this.bid, this);
}
protected override void Activate()

0 comments on commit e1ac596

Please sign in to comment.