密胺计量程序

This commit is contained in:
HJW
2025-02-18 11:28:24 +08:00
commit 76d8086a78
12 changed files with 1674 additions and 0 deletions

50
send_target.py Normal file
View File

@ -0,0 +1,50 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
# @Time : 2025/2/14 14:44
# @Author : hjw
# @File : send_target.py
'''
import socket
import json
cmd_set_target = {
# 称量
"command": "set_target",
"payload": {
"target_weight": 200,
"algorithm": "pid"
}
}
cmd_get_weight = {
# 获取重量
"command": "get_weight"
# "payload": {
# "target_weight": 200,
# "algorithm": "pid"
# }
}
cmd_set_zero = {
# 去皮
"command": "set_zero"
# "payload": {
# "target_weight": 200,
# "algorithm": "pid"
# }
}
cmd_set_vibrate = { # 振动控制
"command": "set_vibrate",
"payload": {
"time": 0 # 单位S
}
}
with socket.socket() as s:
s.connect(('127.0.0.1', 5000))
s.send(json.dumps(cmd_set_target).encode())
print(s.recv(1024).decode())