This commit is contained in:
Neptune-1
2018-12-08 06:54:27 +03:00
parent bb083575e1
commit d86ba7ba97
2 changed files with 37 additions and 20 deletions

View File

@@ -1,8 +1,9 @@
import socket
import play_animation
import time
sock = socket.socket()
serv = '192.168.1.10'
port = 1234
serv = '192.168.1.10' # Change to server ip
port = 35001
sock.connect((serv, port))
sock.send(bytes('left','utf-8'))
command = ''
@@ -53,19 +54,8 @@ def time_synch():
return response.tx_time-time.time()
def pl_anim(c_frame):
def pl_anim():
global command
takeoff()
for frame in c_frame:
if command != 'pause':
time.sleep(0.1)
play_animation.do_next_animation(frame)
if __name__==__main__:
t_0 = Thread(target=receive)
t_0.daemon = True
t_0.start()
play_animation.read_animation_file()
dtime=time_synch() - time.time()
@@ -78,8 +68,28 @@ if __name__==__main__:
if 'synch' in command:
dtime=time_synch() - time.time()
print(dtime)
play_animation.takeoff()
for frame in play_animation.frame():
if command != 'pause':
time.sleep(0.1)
play_animation.do_next_animation(frame)
if __name__==__main__:
t_0 = Thread(target=receive)
t_0.daemon = True
t_0.start()
t_1 = Thread(target=pl_anim)
t_1.daemon = True
t_1.start()
pl_anim(play_animation.frame())

View File

@@ -25,7 +25,7 @@ cr_cet = 0
copters = 1
conn = []
conn_2 = []
file = ''
afile = ''
data = b''
addr = []
addr_2 = []
@@ -228,18 +228,25 @@ class Widget(QMainWindow, main_gui.Ui_MainWindow):
copters = self.swarm_size_spinBox.value()
def upload_animation(self):
global file
file = easygui.fileopenbox(filetypes=["*.csv"],multiple=True) # вызов окна проводника для выбора файла
global afile
afile = easygui.fileopenbox(filetypes=["*.csv"],multiple=True) # вызов окна проводника для выбора файла
def start_animation(self):
global file
for counter, sub_file in enumerate(file):
global afile
global d_time
for counter, sub_file in enumerate(afile):
f = open(sub_file, 'r')
prog = f.read()
self.sender(b'programm' + bytes(prog, 'utf-8')+b'stop', str(counter))
time.sleep(0.1)
for i in range(len(afile)):
self.sender(bytes('begin_anim('+str(time.time()+d_time+10)+')','utf-8', str(counter))
t1 = Thread(target=self.start_retime)
t1.daemon = True
t1.start()
def start_retime(self):
for i in range(11):
time.sleep(1)