コード例 #1
0
ファイル: test_alarms.py プロジェクト: newbrough/coi-services
    def test_two_sided_interval(self):
        """
        test_two_sided_interval
        Test interval alarm and alarm event publishing for a closed
        inteval.
        """

        kwargs = {
            'name': 'temp_high_warning',
            'stream_name': 'fakestreamname',
            'value_id': 'temp',
            'message': 'Temperature is above normal range.',
            'type': StreamAlarmType.WARNING,
            'lower_bound': 10.0,
            'lower_rel_op': '<',
            'upper_bound': 20.0,
            'upper_rel_op': '<'
        }

        # Create alarm object.
        alarm = IonObject('IntervalAlarmDef', **kwargs)
        alarm = construct_alarm_expression(alarm)

        # This sequence will produce 5 alarms.
        # 5.5 warning
        # 10.2 all clear
        # 23.3 warning
        # 17.5 all clear
        # 8.8 warning
        self._event_count = 5
        test_vals = [
            5.5, 5.5, 5.4, 4.6, 4.5, 10.2, 10.3, 10.5, 15.5, 23.3, 23.3, 24.8,
            17.5, 16.5, 12.5, 8.8, 7.7
        ]

        pub = EventPublisher(event_type="StreamAlarmEvent",
                             node=self.container.node)

        for x in test_vals:
            event_data = None
            eval_alarm(alarm, x)
            if alarm.first_time == 1:
                event_data = make_event_data(alarm)

            elif alarm.first_time > 1:
                if alarm.status != alarm.old_status:
                    event_data = make_event_data(alarm)

            if event_data:
                pub.publish_event(origin=self._resource_id, **event_data)

        self._async_event_result.get(timeout=30)
        """ 
コード例 #2
0
ファイル: test_alarms.py プロジェクト: newbrough/coi-services
    def test_two_sided_interval(self):
        """
        test_two_sided_interval
        Test interval alarm and alarm event publishing for a closed
        inteval.
        """

        kwargs = {
            "name": "temp_high_warning",
            "stream_name": "fakestreamname",
            "value_id": "temp",
            "message": "Temperature is above normal range.",
            "type": StreamAlarmType.WARNING,
            "lower_bound": 10.0,
            "lower_rel_op": "<",
            "upper_bound": 20.0,
            "upper_rel_op": "<",
        }

        # Create alarm object.
        alarm = IonObject("IntervalAlarmDef", **kwargs)
        alarm = construct_alarm_expression(alarm)

        # This sequence will produce 5 alarms.
        # 5.5 warning
        # 10.2 all clear
        # 23.3 warning
        # 17.5 all clear
        # 8.8 warning
        self._event_count = 5
        test_vals = [5.5, 5.5, 5.4, 4.6, 4.5, 10.2, 10.3, 10.5, 15.5, 23.3, 23.3, 24.8, 17.5, 16.5, 12.5, 8.8, 7.7]

        pub = EventPublisher(event_type="StreamAlarmEvent", node=self.container.node)

        for x in test_vals:
            event_data = None
            eval_alarm(alarm, x)
            if alarm.first_time == 1:
                event_data = make_event_data(alarm)

            elif alarm.first_time > 1:
                if alarm.status != alarm.old_status:
                    event_data = make_event_data(alarm)

            if event_data:
                pub.publish_event(origin=self._resource_id, **event_data)

        self._async_event_result.get(timeout=30)

        """ 
コード例 #3
0
ファイル: test_alarms.py プロジェクト: swarbhanu/coi-services
    def test_greater_than_interval(self):
        """
        test_greater_than_interval
        Test interval alarm and alarm event publishing for a greater than
        inteval.
        """

        kwargs = {
            'name' : 'current_warning_interval',
            'stream_name' : 'fakestreamname',
            'value_id' : 'port_current',
            'message' : 'Current is above normal range.',
            'type' : StreamAlarmType.WARNING,
            'lower_bound' : 10.5,
            'lower_rel_op' : '<'
        }

        if TEST_ION_OBJECTS:
            # Create alarm object.
            alarm = IonObject('IntervalAlarmDef', **kwargs)
            alarm = construct_alarm_expression(alarm)
        else:
            alarm = IntervalAlarm(**kwargs)

        # This sequence will produce 5 alarms:
        # All clear on the first value,
        # Warning on the first 30,
        # All clear on the following 5.5,
        # Warning on the 15.1,
        # All clear on the following 3.3.
        self._event_count = 5
        test_vals = [5.5, 5.4, 5.5, 5.6, 30, 30.4, 5.5, 5.6, 15.1, 15.2,
                     15.3, 3.3, 3.4]

        pub = EventPublisher(event_type="StreamAlarmEvent",
            node=self.container.node)

        for x in test_vals:
            if TEST_ION_OBJECTS:
                (alarm, event_data) = eval_alarm(alarm, x)
                
            else:
                event_data = alarm.eval_alarm(x)

            if event_data:
                pub.publish_event(origin=self._resource_id, **event_data)
        
        self._async_event_result.get(timeout=30)
        
        """
コード例 #4
0
ファイル: test_alarms.py プロジェクト: newbrough/coi-services
    def test_greater_than_interval(self):
        """
        test_greater_than_interval
        Test interval alarm and alarm event publishing for a greater than
        inteval.
        """

        kwargs = {
            'name': 'current_warning_interval',
            'stream_name': 'fakestreamname',
            'value_id': 'port_current',
            'message': 'Current is above normal range.',
            'type': StreamAlarmType.WARNING,
            'lower_bound': 10.5,
            'lower_rel_op': '<'
        }

        # Create alarm object.
        alarm = IonObject('IntervalAlarmDef', **kwargs)
        alarm = construct_alarm_expression(alarm)

        # This sequence will produce 5 alarms:
        # Warning on the first value,
        # All clear on 30,
        # Warning on 5.5
        # All clear on 15.1
        # Warning on 3.3
        self._event_count = 5
        test_vals = [
            5.5, 5.4, 5.5, 5.6, 30, 30.4, 5.5, 5.6, 15.1, 15.2, 15.3, 3.3, 3.4
        ]

        pub = EventPublisher(event_type="StreamAlarmEvent",
                             node=self.container.node)

        for x in test_vals:
            event_data = None
            eval_alarm(alarm, x)
            if alarm.first_time == 1:
                event_data = make_event_data(alarm)

            elif alarm.first_time > 1:
                if alarm.status != alarm.old_status:
                    event_data = make_event_data(alarm)

            if event_data:
                pub.publish_event(origin=self._resource_id, **event_data)

        self._async_event_result.get(timeout=30)
        """
コード例 #5
0
ファイル: test_alarms.py プロジェクト: newbrough/coi-services
    def test_less_than_interval(self):
        """
        test_less_than_interval
        Test interval alarm and alarm event publishing for a less than
        inteval.
        """

        kwargs = {
            'name': 'reserve_power_warning',
            'stream_name': 'fakestreamname',
            'value_id': 'battery_level',
            'message': 'Battery is below normal range.',
            'type': StreamAlarmType.WARNING,
            'upper_bound': 4.0,
            'upper_rel_op': '<'
        }

        # Create alarm object.
        alarm = IonObject('IntervalAlarmDef', **kwargs)
        alarm = construct_alarm_expression(alarm)

        # This sequence will produce 5 alarms:
        # 5.5 warning
        # 3.3 all clear
        # 4.5 warning
        # 3.3 all clear
        # 4.8 warning
        self._event_count = 5
        test_vals = [
            5.5, 5.5, 5.4, 4.6, 4.5, 3.3, 3.3, 4.5, 4.5, 3.3, 3.3, 4.8
        ]

        pub = EventPublisher(event_type="StreamAlarmEvent",
                             node=self.container.node)

        for x in test_vals:
            event_data = None
            eval_alarm(alarm, x)
            if alarm.first_time == 1:
                event_data = make_event_data(alarm)

            elif alarm.first_time > 1:
                if alarm.status != alarm.old_status:
                    event_data = make_event_data(alarm)

            if event_data:
                pub.publish_event(origin=self._resource_id, **event_data)

        self._async_event_result.get(timeout=30)
        """        
コード例 #6
0
ファイル: test_alarms.py プロジェクト: swarbhanu/coi-services
    def test_two_sided_interval(self):
        """
        test_two_sided_interval
        Test interval alarm and alarm event publishing for a closed
        inteval.
        """

        kwargs = {
            'name' : 'temp_high_warning',
            'stream_name' : 'fakestreamname',
            'value_id' : 'temp',
            'message' : 'Temperature is above normal range.',
            'type' : StreamAlarmType.WARNING,
            'lower_bound' : 10.0,
            'lower_rel_op' : '<',
            'upper_bound' : 20.0,
            'upper_rel_op' : '<'            
        }

        if TEST_ION_OBJECTS:
            # Create alarm object.
            alarm = IonObject('IntervalAlarmDef', **kwargs)
            alarm = construct_alarm_expression(alarm)
        else:
            alarm = IntervalAlarm(**kwargs)

        # This sequence will produce 5 alarms.
        self._event_count = 5
        test_vals = [5.5, 5.5, 5.4, 4.6, 4.5, 10.2, 10.3, 10.5, 15.5,
                     23.3, 23.3, 24.8, 17.5, 16.5, 12.5, 8.8, 7.7]

        pub = EventPublisher(event_type="StreamAlarmEvent",
            node=self.container.node)

        for x in test_vals:
            if TEST_ION_OBJECTS:
                (alarm, event_data) = eval_alarm(alarm, x)
                
            else:
                event_data = alarm.eval_alarm(x)

            if event_data:
                pub.publish_event(origin=self._resource_id, **event_data)
        
        self._async_event_result.get(timeout=30)
 

 
        
コード例 #7
0
ファイル: test_alarms.py プロジェクト: newbrough/coi-services
    def test_greater_than_interval(self):
        """
        test_greater_than_interval
        Test interval alarm and alarm event publishing for a greater than
        inteval.
        """

        kwargs = {
            "name": "current_warning_interval",
            "stream_name": "fakestreamname",
            "value_id": "port_current",
            "message": "Current is above normal range.",
            "type": StreamAlarmType.WARNING,
            "lower_bound": 10.5,
            "lower_rel_op": "<",
        }

        # Create alarm object.
        alarm = IonObject("IntervalAlarmDef", **kwargs)
        alarm = construct_alarm_expression(alarm)

        # This sequence will produce 5 alarms:
        # Warning on the first value,
        # All clear on 30,
        # Warning on 5.5
        # All clear on 15.1
        # Warning on 3.3
        self._event_count = 5
        test_vals = [5.5, 5.4, 5.5, 5.6, 30, 30.4, 5.5, 5.6, 15.1, 15.2, 15.3, 3.3, 3.4]

        pub = EventPublisher(event_type="StreamAlarmEvent", node=self.container.node)

        for x in test_vals:
            event_data = None
            eval_alarm(alarm, x)
            if alarm.first_time == 1:
                event_data = make_event_data(alarm)

            elif alarm.first_time > 1:
                if alarm.status != alarm.old_status:
                    event_data = make_event_data(alarm)

            if event_data:
                pub.publish_event(origin=self._resource_id, **event_data)

        self._async_event_result.get(timeout=30)

        """
コード例 #8
0
ファイル: test_alarms.py プロジェクト: newbrough/coi-services
    def test_less_than_interval(self):
        """
        test_less_than_interval
        Test interval alarm and alarm event publishing for a less than
        inteval.
        """

        kwargs = {
            "name": "reserve_power_warning",
            "stream_name": "fakestreamname",
            "value_id": "battery_level",
            "message": "Battery is below normal range.",
            "type": StreamAlarmType.WARNING,
            "upper_bound": 4.0,
            "upper_rel_op": "<",
        }

        # Create alarm object.
        alarm = IonObject("IntervalAlarmDef", **kwargs)
        alarm = construct_alarm_expression(alarm)

        # This sequence will produce 5 alarms:
        # 5.5 warning
        # 3.3 all clear
        # 4.5 warning
        # 3.3 all clear
        # 4.8 warning
        self._event_count = 5
        test_vals = [5.5, 5.5, 5.4, 4.6, 4.5, 3.3, 3.3, 4.5, 4.5, 3.3, 3.3, 4.8]

        pub = EventPublisher(event_type="StreamAlarmEvent", node=self.container.node)

        for x in test_vals:
            event_data = None
            eval_alarm(alarm, x)
            if alarm.first_time == 1:
                event_data = make_event_data(alarm)

            elif alarm.first_time > 1:
                if alarm.status != alarm.old_status:
                    event_data = make_event_data(alarm)

            if event_data:
                pub.publish_event(origin=self._resource_id, **event_data)

        self._async_event_result.get(timeout=30)

        """        
コード例 #9
0
ファイル: test_alarms.py プロジェクト: swarbhanu/coi-services
    def test_less_than_interval(self):
        """
        test_less_than_interval
        Test interval alarm and alarm event publishing for a less than
        inteval.
        """

        kwargs = {
            'name' : 'reserve_power_warning',
            'stream_name' : 'fakestreamname',
            'value_id' : 'battery_level',
            'message' : 'Battery is below normal range.',
            'type' : StreamAlarmType.WARNING,
            'upper_bound' : 4.0,
            'upper_rel_op' : '<'            
        }

        if TEST_ION_OBJECTS:
            # Create alarm object.
            alarm = IonObject('IntervalAlarmDef', **kwargs)
            alarm = construct_alarm_expression(alarm)
        else:
            alarm = IntervalAlarm(**kwargs)

        # This sequence will produce 5 alarms:
        self._event_count = 5
        test_vals = [5.5, 5.5, 5.4, 4.6, 4.5, 3.3, 3.3, 4.5, 4.5, 3.3, 3.3, 4.8]

        pub = EventPublisher(event_type="StreamAlarmEvent",
            node=self.container.node)

        for x in test_vals:
            if TEST_ION_OBJECTS:
                (alarm, event_data) = eval_alarm(alarm, x)
                
            else:
                event_data = alarm.eval_alarm(x)

            if event_data:
                pub.publish_event(origin=self._resource_id, **event_data)
        
        self._async_event_result.get(timeout=30)