onAlarmChange method

void onAlarmChange(
  1. Observable errorObservable
)

Implementation

void onAlarmChange(Observable errorObservable) {
  // get the error state of the alarm and set it to that of the form field.
  String? sourceid = errorObservable.key?.split('.')[0];
  // The errorobservable from the alarm is the value of the alarms error atrribute.
  bool alarmSounding = errorObservable.get();
  AlarmModel? currentAlarm = _alarms[sourceid];

  // turn off the validation state if the alarm has been dismissed to require a validation per alarm sounding
  if (validationHasHit == true && !alarmerror) validationHasHit = false;

  // check to see if an alarm is already sounding and ensure the field is not alarming already
  if (alarmSounding) {
    alarmerror = alarmSounding;
    alarmerrortext = currentAlarm?.errortext;
   // alarming = true;
    // execute the onalarm event string if the error state is active, this will not activate if validate is the type until validation happens.
    if (alarmerror) currentAlarm?.executeAlarmString(true);
    // tell the field which alarm has set its alarm state, this prevents multiple alarms
    didSetAlarm = sourceid ?? '';
  }
  // check that the changed alarm has set the alarming state, and that the alarm is not sounding
  else if (!alarmSounding && didSetAlarm == sourceid) {
    // set the alarming state to false
    alarmerror = alarmSounding;
    // execute the ondismiss event string
    currentAlarm?.executeAlarmString(false);
  }
}