Some time fixes

This commit is contained in:
Igor Nurullaev
2019-09-03 20:23:57 +03:00
parent 833a96679b
commit fc040718c0
2 changed files with 17 additions and 7 deletions

View File

@@ -1,7 +1,6 @@
from flask import Blueprint, request, jsonify
from web_server_models import copters, WebCopter
from server import Client
from time import time
selfcheck_api = Blueprint('selfcheck_api', __name__, template_folder='templates')
@@ -12,13 +11,13 @@ def selfcheck_selected():
ip = request.args.get("ip")
for copter in copters:
if copter.ip == ip:
copter.refresh()
time = copter.refresh()
data = {
'anim_id': copter.anim_id,
'batt_voltage': copter.batt_voltage,
'cell_voltage': copter.cell_voltage,
'selfcheck': copter.selfcheck,
'time': round(float(copter.time) - time(), 3),
'time': round(float(copter.time) - time, 3),
'name': copter.name,
}
# data = {"anim_id": "No animation", "batt_voltage": 3.259999990463257, "cell_voltage": 1.0850000381469727,
@@ -30,19 +29,20 @@ def selfcheck_selected():
def selfcheck_all():
data = []
for copter in copters:
copter.refresh()
time = copter.refresh()
data.append({
'anim_id': copter.anim_id,
'batt_voltage': copter.batt_voltage,
'cell_voltage': copter.cell_voltage,
'selfcheck': copter.selfcheck,
'ip': copter.ip,
'time': copter.time,
'time': round(float(copter.time) - time, 3),
'name': copter.name,
})
#return jsonify([{"anim_id": "No animation", "batt_voltage": 12.333000183105469, "cell_voltage": 4.111999988555908,
# return jsonify([{"anim_id": "No animation", "batt_voltage": 12.333000183105469, "cell_voltage": 4.111999988555908,
# "ip": "192.168.1.191", "name": "Clever8", "selfcheck": "OK", "time": 1554720157.469769},
# {"anim_id": "No animation", "batt_voltage": 12.244999885559082, "cell_voltage": 4.0879998207092285,
# {"anim_id": "Cool animation", "batt_voltage": 12.244999885559082,
# "cell_voltage": 4.0879998207092285,
# "ip": "192.168.1.134", "name": "Clever7", "selfcheck": "OK", "time": 1554720082.641047}])
return jsonify(data)
@@ -96,3 +96,11 @@ def calibrate_level_selected():
if copter.ip == ip:
copter.client.send_message("calibrate_level")
return jsonify({'m': 'ok'})
def all_checks(copter_item):
return False
def takeoff_checks(copter_item):
return False

View File

@@ -1,4 +1,5 @@
from server import Client
from time import time
copters = []
delay = 0
@@ -31,6 +32,7 @@ class WebCopter:
self.client.get_response("cell_voltage", save, callback_args=(self, 'cell_voltage'))
self.client.get_response("selfcheck", save, callback_args=(self, 'selfcheck'))
self.client.get_response("time", save, callback_args=(self, 'time'))
return time()
def save(m, self, param_name):