def set_alarm(self, srv): ''' Sets or updates the alarm Updating the alarm triggers all of the alarms callbacks ''' alarm = srv.alarm # If the alarm name is `all`, clear all alarms if alarm.alarm_name == "all": rospy.loginfo("Clearing all alarms.") for alarm in self.alarms.values(): # Don't want to clear meta alarms until the end if alarm in self.meta_alarms: continue cleared_alarm = alarm.as_msg() cleared_alarm.raised = False self._alarm_pub.publish(alarm.as_msg()) alarm.update(cleared_alarm) for _alarm in self.meta_alarms.keys(): alarm = self.alarms[_alarm] cleared_alarm = alarm.as_msg() cleared_alarm.raised = False self._alarm_pub.publish(alarm.as_msg()) alarm.update(cleared_alarm) return True if alarm.alarm_name in self.alarms: self.alarms[alarm.alarm_name].update(alarm) else: self.alarms[alarm.alarm_name] = Alarm.from_msg(alarm) self._alarm_pub.publish(alarm) return True
def set_alarm(self, alarm): ''' Sets or updates the alarm Updating the alarm triggers all of the alarms callbacks ''' if alarm.alarm_name in self.handlers: res = self.handlers[alarm.alarm_name].on_set(alarm) if res is False: return False if alarm.alarm_name in self.alarms: self.alarms[alarm.alarm_name].update(alarm) else: self.alarms[alarm.alarm_name] = Alarm.from_msg(alarm) self._alarm_pub.publish(alarm) return True