commit 3a37b09b328056a0fc47677f513b234aa0dfa48d
parent eb5459dc5e8134ee59d8755d935b5cac03f2fb30
Author: rob <rob@tarina.org>
Date: Mon, 19 Dec 2022 14:02:44 +0200
best
Diffstat:
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/tarinactrl.py b/tarinactrl.py
@@ -17,7 +17,7 @@ cameras = config.cameras
camerasoff =[]
port = config.port
nextstatus = ''
-serverstatus = ''
+serverstatus = None
os.system('clear')
selected = 1
camselected=0
@@ -55,18 +55,24 @@ def listenforclients(host, port, q):
data = c.recv(1024)
if not data:
break
- status = data.decode()
+ ctrltime=time.time()
+ tarinatime=data.decode()
+ lag=ctrltime-float(tarinatime)
+ status = addr[0], str(lag*1000), float(tarinatime)
c.close()
q.put(status)
break
except:
q.put('')
-def printmenu(recording,selected,cameras,camselected,serverstatus):
+def printmenu(recording,selected,cameras,camselected,serverstatus,rectime):
print(term.home+term.on_red+term.clear)
print(time.time())
print(rectime)
- print(serverstatus)
+ if serverstatus != None:
+ print(serverstatus[0])
+ print(serverstatus[1])
+ print("rectime lag: "+str((rectime-serverstatus[2])*1000))
if recording != None:
print("Camera "+ str(recording)+" is recording! Shut up. And Action!")
a=0
@@ -96,7 +102,7 @@ menu = ["Quit","Add CAMERA","New SCENE","Sync SCENE","Record"]
##----------------------Main loop starts-------------------------
def main(serverstatus):
- global nextstatus, selected, cameras, menu, camselected, recording, sleep
+ global nextstatus, selected, cameras, menu, camselected, recording, sleep, rectime
newselected=camselected
with term.cbreak():
val=term.inkey(timeout=0)
@@ -191,7 +197,7 @@ def main(serverstatus):
if cameras[camselected] not in camerasoff:
camerasoff.append(cameras[camselected])
elif event == "+":
- if cameras[camselected] not in cameras:
+ if cameras[camselected] in camerasoff:
camerasoff.remove(cameras[camselected])
if camselected != newselected:
if recording != None:
@@ -212,6 +218,7 @@ def main(serverstatus):
time.sleep(sleep)
sendtocamera(c,port,'REC')
recording=newselected
+ rectime=time.time()
elif a == mastersound:
sendtocamera(c,port,'STOP')
time.sleep(sleep)
@@ -220,11 +227,11 @@ def main(serverstatus):
sendtocamera(c,port,'PLACEHOLDER')
a=a+1
camselected=newselected
- printmenu(recording,selected,cameras,camselected,serverstatus)
+ printmenu(recording,selected,cameras,camselected,serverstatus,rectime)
return serverstatus
if __name__ == '__main__':
- serverstatus=''
+ serverstatus=None
q = Queue()
p = Process(target=listenforclients, args=('0.0.0.0', port, q))
p.start()