Ejemplo n.º 1
0
 def is_raised(self):
     ''' Returns whether this alarm is raised or not '''
     try:
         resp = self._alarm_get(
             AlarmGetRequest(alarm_name=self._alarm_name))
         return resp.alarm.raised
     except rospy.service.ServiceException:
         rospy.logerr("No alarm sever found!")
         return False
Ejemplo n.º 2
0
    def get_alarm(self):
        ''' Returns the alarm message
        Also worth noting, the alarm this returns has it's `parameter` field
            converted to a dictionary
        '''
        resp = yield self._alarm_get(AlarmGetRequest(alarm_name=self._alarm_name))

        params = resp.alarm.parameters
        resp.alarm.parameters = params if params == '' else json.loads(params)
        defer.returnValue(resp.alarm)
Ejemplo n.º 3
0
def check_some(getter, count=50):
    for i in range(count):
        a = AlarmGetRequest()
        a.alarm_name = random.choice(names)

        rospy.loginfo("Checking '{}' alarm".format(a.alarm_name))

        resp = getter(a)
        print "raised", resp.alarm.raised
        print "in_raised: ", a.alarm_name in raised
        print "in_cleared: ", a.alarm_name in cleared
        found = False
        if a.alarm_name in raised:
            found = True
            assert resp.alarm.raised
        elif a.alarm_name in cleared:
            found = True
            assert not resp.alarm.raised

        if found:
            assert json.loads(resp.alarm.parameters) == parameters
Ejemplo n.º 4
0
Archivo: alarms.py Proyecto: uf-mil/mil
 def get_alarm(self, fetch=True):
     ''' Returns the alarm message
     Also worth noting, the alarm this returns has it's `parameter` field
         converted to a dictionary
     '''
     if not fetch:
         return self._last_alarm
     try:
         resp = self._alarm_get(
             AlarmGetRequest(alarm_name=self._alarm_name))
     except rospy.service.ServiceException:
         rospy.logerr("No alarm sever found!")
         return self._last_alarm
     self._alarm_update(resp.alarm)
     return self._last_alarm
Ejemplo n.º 5
0
    def get_alarm(self):
        ''' Returns the alarm message
        Also worth noting, the alarm this returns has it's `parameter` field
            converted to a dictionary
        '''
        try:
            resp = self._alarm_get(
                AlarmGetRequest(alarm_name=self._alarm_name))
        except rospy.service.ServiceException:
            rospy.logerr("No alarm sever found!")
            return None

        resp.alarm.parameters = parse_json_str(resp.alarm.parameters)
        self._last_alarm = resp.alarm
        return resp.alarm
Ejemplo n.º 6
0
 def is_cleared(self):
     ''' Returns whether this alarm is raised or not '''
     resp = yield self._alarm_get(AlarmGetRequest(alarm_name=self._alarm_name))
     defer.returnValue(not resp.alarm.raised)