test mainloop
This commit is contained in:
parent
ae7234b6e5
commit
44d79b598d
34
client.py
34
client.py
|
@ -1,21 +1,17 @@
|
||||||
print("modbus test")
|
print("modbus test")
|
||||||
from func import *
|
|
||||||
|
|
||||||
# from func import set_user_reg_800
|
|
||||||
from pymodbus.client import ModbusTcpClient
|
from pymodbus.client import ModbusTcpClient
|
||||||
import time
|
import time
|
||||||
import glob
|
import glob
|
||||||
|
import tkinter as tk
|
||||||
|
|
||||||
client = ModbusTcpClient(
|
from func import *
|
||||||
host=MODBUS_SERVER_HOST,
|
|
||||||
port=MODBUS_SERVER_PORT,
|
window = tk.Tk()
|
||||||
)
|
window.geometry('520x300')
|
||||||
client.connect()
|
label = tk.Label(window, text="Hello, world!")
|
||||||
# максимальное количество coils = 286
|
label.pack()
|
||||||
|
|
||||||
# bulb(2)
|
|
||||||
# get_coordinates()
|
|
||||||
# get_or_set_speed(10)
|
|
||||||
|
|
||||||
all_files = glob.glob("data/data.txt")
|
all_files = glob.glob("data/data.txt")
|
||||||
file = all_files[0]
|
file = all_files[0]
|
||||||
|
@ -30,10 +26,11 @@ with open(file, "r") as fp:
|
||||||
|
|
||||||
data.append(r)
|
data.append(r)
|
||||||
|
|
||||||
|
client = ModbusTcpClient(
|
||||||
# print(data)
|
host=MODBUS_SERVER_HOST,
|
||||||
def multiply_1000(n):
|
port=MODBUS_SERVER_PORT,
|
||||||
return int(n * 1000)
|
)
|
||||||
|
client.connect()
|
||||||
|
|
||||||
|
|
||||||
GOTO_Y = 5
|
GOTO_Y = 5
|
||||||
|
@ -113,5 +110,8 @@ try:
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("error", e)
|
print("error", e)
|
||||||
|
finally:
|
||||||
client.close()
|
client.close()
|
||||||
|
|
||||||
|
if __name__=="__main__":
|
||||||
|
window.mainloop()
|
5
func.py
5
func.py
|
@ -109,4 +109,7 @@ def start_in_auto(client):
|
||||||
|
|
||||||
|
|
||||||
def stop_immediately(client):
|
def stop_immediately(client):
|
||||||
client.write_register(20004, 1, MODBUS_SLAVE_ID)
|
client.write_register(20004, 1, MODBUS_SLAVE_ID)
|
||||||
|
|
||||||
|
def multiply_1000(n):
|
||||||
|
return int(n * 1000)
|
|
@ -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]]
|
[[package]]
|
||||||
name = "attrs"
|
name = "attrs"
|
||||||
|
@ -317,6 +317,17 @@ files = [
|
||||||
{file = "svgwrite-1.4.3.zip", hash = "sha256:a8fbdfd4443302a6619a7f76bc937fc683daf2628d9b737c891ec08b8ce524c3"},
|
{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]]
|
[[package]]
|
||||||
name = "tomli"
|
name = "tomli"
|
||||||
version = "2.0.1"
|
version = "2.0.1"
|
||||||
|
@ -457,4 +468,4 @@ testing = ["coverage (>=5.0.3)", "zope.event", "zope.testing"]
|
||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "2.0"
|
lock-version = "2.0"
|
||||||
python-versions = "3.10.12"
|
python-versions = "3.10.12"
|
||||||
content-hash = "c7d6bddfce25fa53e5a29e91975eacc36d85962e2d132e0f892a2fdfb956bbef"
|
content-hash = "a224728a18ef19c1f754e77db7d8cba413724a9a4257af5704b0fad93f833c58"
|
||||||
|
|
|
@ -12,6 +12,7 @@ pymodbustcp = "^0.2.2"
|
||||||
pymodbus = "^3.7.0"
|
pymodbus = "^3.7.0"
|
||||||
pymodbus3 = "^1.0.0"
|
pymodbus3 = "^1.0.0"
|
||||||
svgpathtools = "^1.6.1"
|
svgpathtools = "^1.6.1"
|
||||||
|
tk = "^0.1.0"
|
||||||
|
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
|
|
Loading…
Reference in New Issue