Server: Add checks parameters to server_config.ini

This commit is contained in:
Arthur Golubtsov
2019-11-09 23:34:42 +03:00
parent f7b5c7f3ba
commit 65c371bb02
2 changed files with 15 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
import sys
import re
import math
import configparser
import collections
import indexed
from server import ConfigOption
@@ -12,6 +13,9 @@ from PyQt5.QtCore import Qt as Qt
ModelDataRole = 998
ModelStateRole = 999
config = configparser.ConfigParser()
config.read("server_config.ini")
class CopterData:
class_basic_attrs = indexed.IndexedOrderedDict([('copter_id', None), ('git_ver', None), ('anim_id', None),
@@ -66,6 +70,9 @@ class Checks:
takeoff_checklist = (3, 4, 6, 7, 8)
current_position = 'NO_POS'
start_position = 'NO_POS'
battery_min = config.getfloat('CHECKS', 'battery_percentage_min')
start_pos_delta_max = config.getfloat('CHECKS', 'start_pos_delta_max')
time_delta_max = config.getfloat('CHECKS', 'time_delta_max')
@classmethod
def get_pos_delta(self):
@@ -290,7 +297,7 @@ def check_bat(item):
if item == "NO_INFO":
return False
else:
return float(item.split(' ')[1][:-1]) > 50
return float(item.split(' ')[1][:-1]) > Checks.battery_min
@col_check(4)
def check_sys_status(item):
@@ -344,7 +351,7 @@ def check_start_pos_status(item):
if delta == 'NO_POS':
return False
else:
return delta < 1.
return delta < Checks.start_pos_delta_max
return False
@@ -352,7 +359,7 @@ def check_start_pos_status(item):
def check_time_delta(item):
if not item:
return None
return abs(float(item)) < 1
return abs(float(item)) < Checks.time_delta_max
def all_checks(copter_item):

View File

@@ -12,3 +12,8 @@ broadcast_delay = 5
use_ntp = False
host = ntp1.stratum2.ru
port = 123
[CHECKS]
battery_percentage_min = 50
start_pos_delta_max = 1
time_delta_max = 1