Server: Add check_current_position parameter to config

This commit is contained in:
Arthur Golubtsov
2020-02-17 17:40:30 +03:00
parent 0da40e19e7
commit d87ea4c389
3 changed files with 7 additions and 1 deletions

View File

@@ -29,10 +29,12 @@ config_version = float(default='1.0')
__many__ = preset_param
[CHECKS]
# in meters
battery_min = float(default=50.0, min=0, max=100)
check_current_position = boolean(default=True)
# in meters
start_pos_delta_max = float(default=1.0, min=0)
# in meters
# in seconds
time_delta_max = float(default=1.0, min=0)
[BROADCAST]

View File

@@ -45,6 +45,7 @@ class ModelChecks:
battery_min = 50.0
start_pos_delta_max = 1.0
time_delta_max = 1.0
check_current_pos = True
@classmethod
def column_check(cls, column, pass_context=False):
@@ -111,6 +112,8 @@ def check_selfcheck(item):
@ModelChecks.column_check("current_position")
def check_pos(item):
if not ModelChecks.check_current_pos:
return True
if item == 'NO_POS':
return False
return not math.isnan(item[0])

View File

@@ -91,6 +91,7 @@ class ServerQt(Server):
def load_config(self):
super().load_config()
table.ModelChecks.battery_min = self.config.checks_battery_min
table.ModelChecks.check_current_pos = self.config.checks_check_current_position
table.ModelChecks.start_pos_delta_max = self.config.checks_start_pos_delta_max
table.ModelChecks.time_delta_max = self.config.checks_time_delta_max