This commit is contained in:
Kseninia Mikhaylova 2024-09-18 14:34:24 +03:00
parent 6d85eae4fd
commit a155303c40
5 changed files with 15403 additions and 7 deletions

View File

@ -1,7 +1,7 @@
import socket import socket
import json import json
from pprint import pprint from pprint import pprint
from tkinter import ttk import tkinter
from func import * from func import *
@ -33,28 +33,52 @@ class SocketRobotArm:
def __exit__(self, exc_type, exc_value, traceback): def __exit__(self, exc_type, exc_value, traceback):
self.close() self.close()
def update_text(self, m, text):
label = tkinter.Label(m, text=text)
label.pack()
m.update()
def connect(self): def connect(self):
self.socket.connect((self.host, self.port)) self.socket.connect((self.host, self.port))
m = tkinter.Tk()
m.geometry("500x500")
self.get_axis() self.get_axis()
self.update_text(m, text=f"Координаты осей {self.start_axis_coordinates}")
self.get_world() self.get_world()
self.update_text(m, text=f"Мировые координаты {self.start_world_coordinates}")
self.get_command_count() self.get_command_count()
self.update_text(m, text=f"Команд в очереди {self.remote_command_count}")
self.send_data(self.set_global_speed()) self.send_data(self.set_global_speed())
self.update_text(m, text=f"Установили глобальную скорость {self.global_speed}")
self.send_data(self.start_cycle())
self.update_text(m, text=f"Старт одиночного цикла")
self.add_rcc_list = ( self.add_rcc_list = (
[self.set_physical_speed(True), self.set_output_laser(True)] [self.set_physical_speed(True), self.set_output_laser(True)]
+ self.steps_from_file() + self.steps_from_file()
+ [self.set_physical_speed(False), self.set_output_laser(False)] + [self.set_physical_speed(False), self.set_output_laser(False)]
) )
my_label = tkinter.Label(m, text=f"Отправка данных")
my_label.pack()
m.update()
step = 2 step = 2
for i in range(0, len(self.add_rcc_list), step): for i in range(0, len(self.add_rcc_list), step):
print(self.add_rcc_list[i : i + step]) print(f"Отправка данных {i}...{i+step-1}")
# self.update_text(m, text=f"Отправка данных {i}...{i+step-1}")
my_label.config(text=f"Отправка данных {i}...{i+step-1}")
m.update()
self.send_data( self.send_data(
make_addrcc_data(self.add_rcc_list[i : i + step], int(not i)) make_addrcc_data(self.add_rcc_list[i : i + step], int(not i))
) )
time.sleep(0.5)
self.send_data(self.start_cycle())
def send_data(self, data): def send_data(self, data):
response = None response = None

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -6,6 +6,7 @@ all_files = glob.glob("data/*.nc")
def get_value(c, s): def get_value(c, s):
[x] = [item.replace(s, '') for item in c if item.startswith(s)] or [0] [x] = [item.replace(s, '') for item in c if item.startswith(s)] or [0]
return float(x) return float(x)
for file in all_files: for file in all_files:
with open(file, 'r') as fp: with open(file, 'r') as fp:
lines = fp.readlines() lines = fp.readlines()
@ -36,5 +37,6 @@ for file in all_files:
if(len(filtered_prep.keys())): if(len(filtered_prep.keys())):
result.append([f"{p}{filtered_prep[p]}" for p in filtered_prep]) result.append([f"{p}{filtered_prep[p]}" for p in filtered_prep])
with open(f"{file}.result", 'w') as fp: with open(f"{file}.result", 'w') as fp:
fp.write('\n'.join(' '.join(str(i) for i in x) for x in result)) print(f"save to {file}.result")
fp.write('\n'.join(' '.join(str(i) for i in x) for x in result))