예제 #1
0
    def instantiate_rule(config):
        is_single_shot = False
        if YamlHelper.has_param(config, 'single_shot'):
            is_single_shot = YamlHelper.get_param(config, 'single_shot')
        host = YamlHelper.get_param(config, 'host')
        port = YamlHelper.get_param(config, 'port')
        username = YamlHelper.get_param(config, 'username')
        password = YamlHelper.get_param(config, 'password')
        subject = YamlHelper.get_param(config, 'subject')
        to_address = YamlHelper.get_param(config, 'to_address')
        from_address = YamlHelper.get_param(config, 'from_address')
        content = YamlHelper.get_param(config, 'content')
        positive_observations = RuleFactory.pars_positive_observations(config)
        negative_observations = RuleFactory.pars_negative_observations(config)
        positive_possible_faulty_resources = RuleFactory.pars_positive_possible_faulty_resources(
            config)
        negative_possible_faulty_resources = RuleFactory.pars_negative_possible_faulty_resources(
            config)
        recall_duration = None
        if YamlHelper.has_param(config, 'recall_duration'):
            recall_duration = rospy.Duration(
                YamlHelper.get_param(config, 'recall_duration'))

        return EMailRule(positive_observations, negative_observations,
                         positive_possible_faulty_resources,
                         negative_possible_faulty_resources, recall_duration,
                         is_single_shot, host, port, username, password,
                         subject, to_address, from_address, content)
예제 #2
0
 def pars_diag(resources):
     result = set()
     for res in resources:
         the_res = DiagnosisContainer()
         the_res.resource = YamlHelper.get_param(res, 'resource')
         if YamlHelper.has_param(res, 'occurrences'):
             the_res.occurrences = YamlHelper.get_param(res, 'occurrences')
         else:
             the_res.occurrences = None
         if YamlHelper.has_param(res, 'window_size'):
             the_res.window_size = YamlHelper.get_param(res, 'window_size')
         else:
             the_res.window_size = None
         result.add(the_res)
     return result
예제 #3
0
    def instantiate_rule(config):
        is_single_shot = False
        if YamlHelper.has_param(config, 'single_shot'):
            is_single_shot = YamlHelper.get_param(config, 'single_shot')
        process = YamlHelper.get_param(config, 'process')
        positive_observations = RuleFactory.pars_positive_observations(config)
        negative_observations = RuleFactory.pars_negative_observations(config)
        positive_possible_faulty_resources = RuleFactory.pars_positive_possible_faulty_resources(
            config)
        negative_possible_faulty_resources = RuleFactory.pars_negative_possible_faulty_resources(
            config)
        recall_duration = None
        if YamlHelper.has_param(config, 'recall_duration'):
            recall_duration = rospy.Duration(
                YamlHelper.get_param(config, 'recall_duration'))

        return ProcessRule(positive_observations, negative_observations,
                           positive_possible_faulty_resources,
                           negative_possible_faulty_resources, recall_duration,
                           is_single_shot, process)
예제 #4
0
    def instantiate_rule(config):
        is_single_shot = False
        if YamlHelper.has_param(config, 'single_shot'):
            is_single_shot = YamlHelper.get_param(config, 'single_shot')
        log_file = YamlHelper.get_param(config, 'log_file')
        log_entry = YamlHelper.get_param(config, 'log_entry')
        positive_observations = RuleFactory.pars_positive_observations(config)
        negative_observations = RuleFactory.pars_negative_observations(config)
        positive_possible_faulty_resources = RuleFactory.pars_positive_possible_faulty_resources(
            config)
        negative_possible_faulty_resources = RuleFactory.pars_negative_possible_faulty_resources(
            config)
        recall_duration = None
        if YamlHelper.has_param(config, 'recall_duration'):
            recall_duration = rospy.Duration(
                YamlHelper.get_param(config, 'recall_duration'))

        return LogFileRule(positive_observations, negative_observations,
                           positive_possible_faulty_resources,
                           negative_possible_faulty_resources, recall_duration,
                           is_single_shot, log_file, log_entry)
예제 #5
0
    def instantiate_rule(config):
        is_single_shot = False
        if YamlHelper.has_param(config, 'single_shot'):
            is_single_shot = YamlHelper.get_param(config, 'single_shot')
        service_name = YamlHelper.get_param(config, 'service_name')
        service_type = YamlHelper.get_param(config, 'service_type')
        call_msg = YamlHelper.get_param(config, 'call_msg')
        positive_observations = RuleFactory.pars_positive_observations(config)
        negative_observations = RuleFactory.pars_negative_observations(config)
        positive_possible_faulty_resources = RuleFactory.pars_positive_possible_faulty_resources(
            config)
        negative_possible_faulty_resources = RuleFactory.pars_negative_possible_faulty_resources(
            config)
        recall_duration = None
        if YamlHelper.has_param(config, 'recall_duration'):
            recall_duration = rospy.Duration(
                YamlHelper.get_param(config, 'recall_duration'))

        return ServiceRule(positive_observations, negative_observations,
                           positive_possible_faulty_resources,
                           negative_possible_faulty_resources, recall_duration,
                           is_single_shot, service_name, service_type,
                           call_msg)
예제 #6
0
    def pars_observation(observations):
        result = set()
        for obs in observations:
            the_obs = ObservationContainer()
            the_obs.type = YamlHelper.get_param(obs, 'type')
            the_obs.resource = YamlHelper.get_param(obs, 'resource')
            if YamlHelper.has_param(obs, 'observation'):
                the_obs.observation = ObservationWithNumber(
                    YamlHelper.get_param(obs, 'observation'))
            else:
                the_obs.observation = ObservationWithString(
                    YamlHelper.get_param(obs, 'observation_msg'))
            if YamlHelper.has_param(obs, 'occurrences'):
                the_obs.occurrences = YamlHelper.get_param(obs, 'occurrences')
            else:
                the_obs.occurrences = None
            if YamlHelper.has_param(obs, 'window_size'):
                the_obs.window_size = YamlHelper.get_param(obs, 'window_size')
            else:
                the_obs.window_size = None

            result.add(the_obs)
        return result
예제 #7
0
    def instantiate_rule(config):
        is_single_shot = False
        if YamlHelper.has_param(config, 'single_shot'):
            is_single_shot = YamlHelper.get_param(config, 'single_shot')
        node_name = YamlHelper.get_param(config, 'node_name')
        paramter_name = YamlHelper.get_param(config, 'paramter_name')
        paramter_value = YamlHelper.get_param(config, 'paramter_value')
        positive_observations = RuleFactory.pars_positive_observations(config)
        negative_observations = RuleFactory.pars_negative_observations(config)
        positive_possible_faulty_resources = RuleFactory.pars_positive_possible_faulty_resources(
            config)
        negative_possible_faulty_resources = RuleFactory.pars_negative_possible_faulty_resources(
            config)
        recall_duration = None
        if YamlHelper.has_param(config, 'recall_duration'):
            recall_duration = rospy.Duration(
                YamlHelper.get_param(config, 'recall_duration'))

        return DynamicParameterRule(positive_observations,
                                    negative_observations,
                                    positive_possible_faulty_resources,
                                    negative_possible_faulty_resources,
                                    recall_duration, is_single_shot, node_name,
                                    paramter_name, paramter_value)