Exemplo n.º 1
0
    def evaluate_internal(self, condition, measurement=None):
        if measurement is None:
            while self.data is None:
                time.sleep(1)
            measurement = NumericMeasurement(self.data)
        # BothLimits should be above LowerLimit and UpperLimit as it is a child class
        type_map = {
            BothLimitsCondition: BothLimitsEvaluator,
            UpperLimitCondition: UpperLimitEvaluator,
            LowerLimitCondition: LowerLimitEvaluator,
            GreaterThanCondition: GreaterThanEvaluator,
            GreaterThanOrEqualToCondition: GreaterThanOrEqualToEvaluator,
            EqualToCondition: EqualToEvaluator,
            NotEqualToCondition: NotEqualToEvaluator,
            LessThanOrEqualToCondition: LessThanOrEqualToEvaluator,
            LessThanCondition: LessThanEvaluator
        }

        evaluator_type = None
        for key, value in type_map.iteritems():
            if isinstance(condition, key):
                evaluator_type = value
                break
        if evaluator_type is None:
            raise ValueError("Condition is of unknown type")

        evaluation = evaluator_type(lambda: self.data).evaluate(
            condition, measurement)

        get_logger().info("Condition {}, measurement {}, {}".format(
            condition, measurement,
            "nominal" if evaluation.nominal else "not nominal"))

        return evaluation
Exemplo n.º 2
0
 def sense_internal(self):
     return NumericMeasurement(ABOVE_UPPER_LIMIT_VALUE)
Exemplo n.º 3
0
 def sense_internal(self):
     return NumericMeasurement(BETWEEN_EXPECTED_AND_UPPER_LIMIT_VALUE)
Exemplo n.º 4
0
 def sense_internal(self):
     return NumericMeasurement(EXPECTED_VALUE)
Exemplo n.º 5
0
 def sense_internal(self):
     return NumericMeasurement(LOWER_LIMIT_VALUE)