|
|
@@ -169,13 +169,20 @@ class Main:
|
|
|
|
|
|
|
|
|
|
|
|
# Compare detected value with equal, not equal, more than and less values
|
|
|
|
# Compare detected value with equal, not equal, more than and less values
|
|
|
|
logging.info('detected {}'.format(detectedValue))
|
|
|
|
logging.info('detected {}'.format(detectedValue))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# String comparison
|
|
|
|
if config.alarm_string_equal and (detectedValue == config.alarm_string_equal):
|
|
|
|
if config.alarm_string_equal and (detectedValue == config.alarm_string_equal):
|
|
|
|
return 'value is "{}"'.format(detectedValue)
|
|
|
|
return 'value is "{}"'.format(detectedValue)
|
|
|
|
if config.alarm_string_not_equal and (detectedValue != config.alarm_string_not_equal):
|
|
|
|
if config.alarm_string_not_equal and (detectedValue != config.alarm_string_not_equal):
|
|
|
|
return 'value is "{}", but should be "{}"'.format(detectedValue, config.alarm_string_not_equal)
|
|
|
|
return 'value is "{}", but should be "{}"'.format(detectedValue, config.alarm_string_not_equal)
|
|
|
|
if config.alarm_value_equal and (locale.atof(detectedValue) == float(config.alarm_value_equal)):
|
|
|
|
|
|
|
|
|
|
|
|
# Numeric comparison
|
|
|
|
|
|
|
|
numeric_value = locale.atof(detectedValue)
|
|
|
|
|
|
|
|
delta_upper = numeric_value + config.delta
|
|
|
|
|
|
|
|
delta_lower = numeric_value - config.delta
|
|
|
|
|
|
|
|
if config.alarm_value_equal and (delta_lower < float(config.alarm_value_equal) or delta_upper > float(config.alarm_value_equal)):
|
|
|
|
return 'value is {}'.format(detectedValue)
|
|
|
|
return 'value is {}'.format(detectedValue)
|
|
|
|
if config.alarm_value_not_equal and (locale.atof(detectedValue) != float(config.alarm_value_not_equal)):
|
|
|
|
if config.alarm_value_not_equal and (delta_lower > float(config.alarm_value_not_equal) or delta_upper < float(config.alarm_value_not_equal)):
|
|
|
|
return 'value is {}, but should be {}'.format(detectedValue, config.alarm_value_not_equal)
|
|
|
|
return 'value is {}, but should be {}'.format(detectedValue, config.alarm_value_not_equal)
|
|
|
|
if config.alarm_value_more_than and locale.atof(detectedValue) > float(config.alarm_value_more_than):
|
|
|
|
if config.alarm_value_more_than and locale.atof(detectedValue) > float(config.alarm_value_more_than):
|
|
|
|
return 'value is {}, but should not exceed {}'.format(locale.atof(detectedValue), config.alarm_value_more_than)
|
|
|
|
return 'value is {}, but should not exceed {}'.format(locale.atof(detectedValue), config.alarm_value_more_than)
|
|
|
|