private void UpdateAlarmActionMessages(Instrument settings) { if (!_instCtrlr.HasAlarmActionMessagesFeature) { return; } // put installed sensor codes in dictionary for faster look-up Dictionary <string, bool> sensorDictionary = new Dictionary <string, bool>(); // we will only write relevant action messages in the instrument // if there is an installed sensor with a matching sensor code foreach (InstalledComponent component in Master.Instance.SwitchService.Instrument.InstalledComponents) { Sensor sensor = component.Component as Sensor; if (sensor != null) { sensorDictionary[sensor.Type.Code] = false; } } // make a list of just alarm messages that will be written to the instrument List <AlarmActionMessages> aamSettingsList = new List <AlarmActionMessages>(); foreach (AlarmActionMessages aam in settings.AlarmActionMessages) { if (sensorDictionary.ContainsKey(aam.SensorCode) && sensorDictionary[aam.SensorCode] == false) { // there should only be one object per sensor code, but we check here anyway sensorDictionary[aam.SensorCode] = true; aamSettingsList.Add(aam); } } // the driver will handle if the list is too small or too big _instCtrlr.SetAlarmActionMessages(aamSettingsList); }