From 44d79b598d43a1f785232e0c2bf9653bb65b704d Mon Sep 17 00:00:00 2001 From: Kseninia Mikhaylova Date: Fri, 23 Aug 2024 10:21:04 +0300 Subject: [PATCH] test mainloop --- client.py | 34 +++++++++++++++++----------------- func.py | 5 ++++- poetry.lock | 15 +++++++++++++-- pyproject.toml | 1 + 4 files changed, 35 insertions(+), 20 deletions(-) diff --git a/client.py b/client.py index bf9c663..6228587 100644 --- a/client.py +++ b/client.py @@ -1,21 +1,17 @@ print("modbus test") -from func import * -# from func import set_user_reg_800 from pymodbus.client import ModbusTcpClient import time import glob +import tkinter as tk -client = ModbusTcpClient( - host=MODBUS_SERVER_HOST, - port=MODBUS_SERVER_PORT, -) -client.connect() -# максимальное количество coils = 286 +from func import * + +window = tk.Tk() +window.geometry('520x300') +label = tk.Label(window, text="Hello, world!") +label.pack() -# bulb(2) -# get_coordinates() -# get_or_set_speed(10) all_files = glob.glob("data/data.txt") file = all_files[0] @@ -30,10 +26,11 @@ with open(file, "r") as fp: data.append(r) - -# print(data) -def multiply_1000(n): - return int(n * 1000) +client = ModbusTcpClient( + host=MODBUS_SERVER_HOST, + port=MODBUS_SERVER_PORT, +) +client.connect() GOTO_Y = 5 @@ -113,5 +110,8 @@ try: except Exception as e: print("error", e) - -client.close() +finally: + client.close() + +if __name__=="__main__": + window.mainloop() \ No newline at end of file diff --git a/func.py b/func.py index 0d4099c..7b377de 100644 --- a/func.py +++ b/func.py @@ -109,4 +109,7 @@ def start_in_auto(client): def stop_immediately(client): - client.write_register(20004, 1, MODBUS_SLAVE_ID) \ No newline at end of file + client.write_register(20004, 1, MODBUS_SLAVE_ID) + +def multiply_1000(n): + return int(n * 1000) \ No newline at end of file diff --git a/poetry.lock b/poetry.lock index 756dde8..c8f78f1 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. [[package]] name = "attrs" @@ -317,6 +317,17 @@ files = [ {file = "svgwrite-1.4.3.zip", hash = "sha256:a8fbdfd4443302a6619a7f76bc937fc683daf2628d9b737c891ec08b8ce524c3"}, ] +[[package]] +name = "tk" +version = "0.1.0" +description = "TensorKit is a deep learning helper between Python and C++." +optional = false +python-versions = "*" +files = [ + {file = "tk-0.1.0-py3-none-any.whl", hash = "sha256:703a69ff0d5ba2bd2f7440582ad10160e4a6561595d33457dc6caa79b9bf4930"}, + {file = "tk-0.1.0.tar.gz", hash = "sha256:60bc8923d5d35f67f5c6bd93d4f0c49d2048114ec077768f959aef36d4ed97f8"}, +] + [[package]] name = "tomli" version = "2.0.1" @@ -457,4 +468,4 @@ testing = ["coverage (>=5.0.3)", "zope.event", "zope.testing"] [metadata] lock-version = "2.0" python-versions = "3.10.12" -content-hash = "c7d6bddfce25fa53e5a29e91975eacc36d85962e2d132e0f892a2fdfb956bbef" +content-hash = "a224728a18ef19c1f754e77db7d8cba413724a9a4257af5704b0fad93f833c58" diff --git a/pyproject.toml b/pyproject.toml index a6aca3f..e80a321 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,6 +12,7 @@ pymodbustcp = "^0.2.2" pymodbus = "^3.7.0" pymodbus3 = "^1.0.0" svgpathtools = "^1.6.1" +tk = "^0.1.0" [build-system]