commander update
This commit is contained in:
parent
ac6d94d4a3
commit
72b08b631d
@ -38,6 +38,12 @@
|
||||
<button id="login">login</button>
|
||||
</div>
|
||||
<main>
|
||||
<div id="refresh" class="btn">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-clockwise" viewBox="0 0 16 16">
|
||||
<path fill-rule="evenodd" d="M8 3a5 5 0 1 0 4.546 2.914.5.5 0 0 1 .908-.417A6 6 0 1 1 8 2z"/>
|
||||
<path d="M8 4.466V.534a.25.25 0 0 1 .41-.192l2.36 1.966c.12.1.12.284 0 .384L8.41 4.658A.25.25 0 0 1 8 4.466"/>
|
||||
</svg>
|
||||
</div>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
@ -76,6 +82,7 @@
|
||||
var boatsLocked = [];
|
||||
|
||||
loginEl.addEventListener('click', login);
|
||||
document.getElementById('refresh').addEventListener('click', refreshAll);
|
||||
|
||||
function login(e)
|
||||
{
|
||||
@ -88,7 +95,13 @@
|
||||
function onOpen(e)
|
||||
{
|
||||
conn.send(passEl.value + ";4675;" + Math.floor(new Date().getTime()/1000.0));
|
||||
refreshAll()
|
||||
}
|
||||
|
||||
function refreshAll()
|
||||
{
|
||||
reqBoats();
|
||||
reqLockedBoats();
|
||||
reqClients();
|
||||
}
|
||||
|
||||
@ -128,6 +141,11 @@
|
||||
conn.send(passEl.value + ";boats");
|
||||
}
|
||||
|
||||
function reqLockedBoats()
|
||||
{
|
||||
conn.send(passEl.value + ";locked");
|
||||
}
|
||||
|
||||
function reqClients()
|
||||
{
|
||||
conn.send(passEl.value + ";clients");
|
||||
|
||||
@ -69,7 +69,7 @@ async def take_controll(client, boat):
|
||||
async def free_boat(boat):
|
||||
"""make boat available for next client"""
|
||||
for client in Clients:
|
||||
if client["boat"]['id'] == boat:
|
||||
if client["boat"] is not None and client["boat"]['id'] == boat:
|
||||
client["boat"] = None
|
||||
break
|
||||
for b in Boats:
|
||||
@ -81,7 +81,7 @@ async def free_boat(boat):
|
||||
async def lock_boat(boat):
|
||||
"""lock a boat so client can't take controll over it"""
|
||||
for client in Clients:
|
||||
if client["boat"]['id'] == boat:
|
||||
if client["boat"] is not None and client["boat"]['id'] == boat:
|
||||
client["boat"] = None
|
||||
break
|
||||
for b in Boats:
|
||||
@ -136,7 +136,7 @@ async def on_message(message, client):
|
||||
print("WARN: controll cmd (" + client['id'] + ") to None: " + data[2])
|
||||
elif client['boat']['lastMsg'] + BOAT_DATA_INTERVAL_MAX < datetime.timestamp(datetime.now()):
|
||||
# print("INFO: controll cmd (" + client['id'] + ") to " + client['boat']['name'] + ": " + data[2])
|
||||
sendToBoat(client['boat'], "d:" + data[2] + "\n")
|
||||
await sendToBoat(client['boat'], "d:" + data[2] + "\n")
|
||||
client['boat']['lastMsg'] = datetime.timestamp(datetime.now())
|
||||
elif data[1] == "getlog" and client['id'] == ADMIN_ID:
|
||||
await getlog(client, data)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user