This commit is contained in:
Kseninia Mikhaylova 2024-10-10 16:37:05 +03:00
commit 96fe6de6ba
4 changed files with 53 additions and 24 deletions

View File

@ -8,23 +8,25 @@ import tkinter as tk
from func import *
window = tk.Tk()
window.geometry('520x300')
window.geometry("520x300")
label = tk.Label(window, text="Hello, world!")
label.pack()
all_files = glob.glob("data/data.txt")
all_files = glob.glob("data/*.nc")
file = all_files[0]
data = []
with open(file, "r") as fp:
lines = fp.readlines()
for l in lines:
r = l.strip().split(",")
r[1] = float(r[1])
r[2] = float(r[2])
r[3] = float(r[3])
data = [
("line", 0, 0, 277.8, 0, 5, 0),
]
# with open(file, "r") as fp:
# lines = fp.readlines()
# for l in lines:
# r = l.strip().split(",")
# r[1] = float(r[1])
# r[2] = float(r[2])
# r[3] = float(r[3])
data.append(r)
# data.append(r)
client = ModbusTcpClient(
host=MODBUS_SERVER_HOST,
@ -44,7 +46,7 @@ try:
bulb(GOTO_Y, False, client)
get_or_set_speed(10, client)
# ставим пользовательские переменные в ноль
set_user_reg_800(
[
@ -112,6 +114,6 @@ except Exception as e:
print("error", e)
finally:
client.close()
if __name__=="__main__":
window.mainloop()
if __name__ == "__main__":
window.mainloop()

View File

@ -19,8 +19,8 @@ class SocketRobotArm:
line_smooth = 9
line_tool = 1
global_speed = 100
physical_speed = 50
global_speed = 10
physical_speed = 10
# laser_id = 15
laser_id = 14
# filename = 'half-sphere-no-angle'
@ -55,6 +55,7 @@ class SocketRobotArm:
threading.Thread(target=self.run_pybullet, daemon=True).start()
print((self.port, self.host))
self.socket.connect((self.host, self.port))
self.cycle_base()
@ -126,7 +127,8 @@ class SocketRobotArm:
self.tkinter_info_label.pack()
self.tkinter_root.update()
step = 2
step = 4
empty = 1
for i in range(0, len(self.add_rcc_list), step):
if not self.tkinter_info_label:
return
@ -137,11 +139,14 @@ class SocketRobotArm:
# self.update_text(m, text=f"Отправка данных {i}...{i+step-1}")
self.tkinter_info_label.config(text=f"Отправка данных {i}...{i+step-1}")
self.tkinter_root.update()
# print(empty)
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], empty
)
)
time.sleep(0.5)
empty = 0
time.sleep(0.05)
def imitate(self):
points = self.steps_from_file()
@ -240,7 +245,7 @@ class SocketRobotArm:
def make_world_step(self, type, point):
step = {
"oneshot": "0",
"oneshot": "1",
"delay": "0.0",
"speed": str(self.line_speed),
"smooth": str(self.line_smooth),

View File

@ -7,3 +7,23 @@ X100 Y50
X100 Y0
X50 Y0
X0 Y0
X165 Y0
X330 Y0
X500 Y165
X500 Y330
X330 Y500
X165 Y500
X0 Y330
X0 Y165
Z-50 V40 X0 Y0
Z-50 V40 X165 Y0
Z-50 V40 X330 Y0
Z-50 V-40 X500 Y165
Z-50 V-40 X500 Y330
Z-50 V-40 X330 Y500
Z-50 V-40 X165 Y500
Z-50 V40 X0 Y330
Z-50 V40 X0 Y165
Z-50 V40 X0 Y0
X0 Y0

View File

@ -1,7 +1,9 @@
# Настройки клиента Modbus
MODBUS_SERVER_HOST = "192.168.70.55" # IP-адрес Modbus-сервера
# MODBUS_SERVER_HOST = "192.168.70.55" # IP-адрес Modbus-сервера
MODBUS_SERVER_HOST = "192.168.70.65" # IP-адрес Modbus-сервера
MODBUS_SERVER_PORT = 502
MODBUS_SLAVE_ID = 11
# MODBUS_SLAVE_ID = 11
MODBUS_SLAVE_ID = 22
indent = 21100
s = 800