public void ParseRadioBroadcast(String packet) { //parse the packet string[] tokens = packet.Split(','); string id = tokens[0]; string status = tokens[1]; // find sensor with id SensorRefactoredSome sensor = null; foreach (SensorRefactoredSome s in sensors) { if (s.GetId().Equals(id)) { sensor = s; break; } } //trip or reset sensor if (sensor != null) { if ("TRIPPED".Equals(status)) { sensor.Trip(); } else { sensor.Reset(); } } //get the message from the sensor and display it string message = GetSensorMessage(sensor); view.ShowMessage(message); // sound the alarm if armed if (IsArmed()) { audibleAlarm.Sound(); } // check if a sensor test is running and adjust status if (runningSensorTest) { if ("TRIPPED".Equals(status)) { sensorTestStatusMap.Add(id, PASS); } // check to see if test is complete bool done = true; foreach (string testStatus in sensorTestStatusMap.Values) { if (PENDING.Equals(testStatus)) { done = false; break; } } //terminate test if complete if (done) { TerminateSensorTest(); } } }
public void ParseRadioBroadcast(string packet) { //parse the packet string[] tokens = packet.Split(','); string id = tokens[0]; string status = tokens[1]; // find sensor with id Sensor sensor = null; for (IEnumerator enumerator = sensors.GetEnumerator(); enumerator.MoveNext();) { if (enumerator.Current == null) { enumerator.MoveNext(); } Sensor s = (Sensor)enumerator.Current; if (s.GetId() == id) { sensor = s; break; } } //trip or reset sensor if (sensor != null) { if ("TRIPPED" == status) { sensor.Trip(); } else { sensor.Reset(); } } //get the message from the sensor and display it string message = GetSensorMessage(sensor); view.ShowMessage(message); // sound the alarm if armed if (isArmed()) { audibleAlarm.Sound(); } // check if a sensor test is running and adjust status if (runningSensorTest) { if ("TRIPPED" == status) { sensorTestStatusMap.Add(id, PASS); } // check to see if test is complete bool done = true; for (IEnumerator enumerator = sensorTestStatusMap.Values.GetEnumerator(); enumerator.MoveNext();) { if (enumerator.Current == null) { enumerator.MoveNext(); } string testStatus = (string)enumerator.Current; if (PENDING == testStatus) { done = false; break; } } //terminate test if complete if (done) { terminateSensorTest(); } } }