test prepare g code
This commit is contained in:
parent
1c343108f3
commit
81929a51e8
|
@ -15,22 +15,6 @@
|
|||
"detail": "pymodbus.constants",
|
||||
"documentation": {}
|
||||
},
|
||||
{
|
||||
"label": "Endian",
|
||||
"importPath": "pymodbus.constants",
|
||||
"description": "pymodbus.constants",
|
||||
"isExtraImport": true,
|
||||
"detail": "pymodbus.constants",
|
||||
"documentation": {}
|
||||
},
|
||||
{
|
||||
"label": "BinaryPayloadDecoder",
|
||||
"importPath": "pymodbus.payload",
|
||||
"description": "pymodbus.payload",
|
||||
"isExtraImport": true,
|
||||
"detail": "pymodbus.payload",
|
||||
"documentation": {}
|
||||
},
|
||||
{
|
||||
"label": "BinaryPayloadDecoder",
|
||||
"importPath": "pymodbus.payload",
|
||||
|
@ -58,43 +42,12 @@
|
|||
"documentation": {}
|
||||
},
|
||||
{
|
||||
"label": "ModbusClient",
|
||||
"importPath": "pyModbusTCP.client",
|
||||
"description": "pyModbusTCP.client",
|
||||
"label": "glob",
|
||||
"kind": 6,
|
||||
"isExtraImport": true,
|
||||
"detail": "pyModbusTCP.client",
|
||||
"documentation": {}
|
||||
},
|
||||
{
|
||||
"label": "ModbusTcpServer",
|
||||
"importPath": "pymodbus.server",
|
||||
"description": "pymodbus.server",
|
||||
"isExtraImport": true,
|
||||
"detail": "pymodbus.server",
|
||||
"documentation": {}
|
||||
},
|
||||
{
|
||||
"label": "MODBUS_SERVER_PORT",
|
||||
"importPath": "client",
|
||||
"description": "client",
|
||||
"isExtraImport": true,
|
||||
"detail": "client",
|
||||
"documentation": {}
|
||||
},
|
||||
{
|
||||
"label": "MODBUS_SERVER_HOST",
|
||||
"importPath": "client",
|
||||
"description": "client",
|
||||
"isExtraImport": true,
|
||||
"detail": "client",
|
||||
"documentation": {}
|
||||
},
|
||||
{
|
||||
"label": "svg2paths2",
|
||||
"importPath": "svgpathtools",
|
||||
"description": "svgpathtools",
|
||||
"isExtraImport": true,
|
||||
"detail": "svgpathtools",
|
||||
"importPath": "glob",
|
||||
"description": "glob",
|
||||
"detail": "glob",
|
||||
"documentation": {}
|
||||
},
|
||||
{
|
||||
|
@ -242,75 +195,30 @@
|
|||
"documentation": {}
|
||||
},
|
||||
{
|
||||
"label": "get_reg_range",
|
||||
"label": "get_value",
|
||||
"kind": 2,
|
||||
"importPath": "other_client",
|
||||
"description": "other_client",
|
||||
"peekOfCode": "def get_reg_range(start, stop):\n for i in range(start, stop):\n r = client.read_holding_registers(i, 1)\n if r and r != [0] and r != [65535]:\n print(f\"{i} === {r}\")\nget_reg_range(0, 100)\nget_reg_range(2100, 2600)\nget_reg_range(20000, 24000)\nget_reg_range(56000, 57000)\n# r = client.read_holding_registers(21901, 1)",
|
||||
"detail": "other_client",
|
||||
"importPath": "prepare",
|
||||
"description": "prepare",
|
||||
"peekOfCode": "def get_value(c, s):\n [x] = [item.replace(s, '') for item in c if item.startswith(s)] or [0]\n return float(x)\nwith open(file, 'r') as fp:\n lines = fp.readlines()\n # print(lines)\n prev_x = None\n prev_y = None\n prev_z = None\n for l in lines[:100]:",
|
||||
"detail": "prepare",
|
||||
"documentation": {}
|
||||
},
|
||||
{
|
||||
"label": "MODBUS_SERVER_HOST",
|
||||
"label": "all_files",
|
||||
"kind": 5,
|
||||
"importPath": "other_client",
|
||||
"description": "other_client",
|
||||
"peekOfCode": "MODBUS_SERVER_HOST = \"192.168.70.55\" # IP-адрес Modbus-сервера\nMODBUS_SERVER_PORT = 502\nclient = ModbusClient(\n host=MODBUS_SERVER_HOST,\n port=MODBUS_SERVER_PORT,\n unit_id=11,\n # debug=True\n)\nclient.open()\n# addr = 2",
|
||||
"detail": "other_client",
|
||||
"importPath": "prepare",
|
||||
"description": "prepare",
|
||||
"peekOfCode": "all_files = glob.glob(\"data/*\")\nfile = all_files[0]\ndef get_value(c, s):\n [x] = [item.replace(s, '') for item in c if item.startswith(s)] or [0]\n return float(x)\nwith open(file, 'r') as fp:\n lines = fp.readlines()\n # print(lines)\n prev_x = None\n prev_y = None",
|
||||
"detail": "prepare",
|
||||
"documentation": {}
|
||||
},
|
||||
{
|
||||
"label": "MODBUS_SERVER_PORT",
|
||||
"label": "file",
|
||||
"kind": 5,
|
||||
"importPath": "other_client",
|
||||
"description": "other_client",
|
||||
"peekOfCode": "MODBUS_SERVER_PORT = 502\nclient = ModbusClient(\n host=MODBUS_SERVER_HOST,\n port=MODBUS_SERVER_PORT,\n unit_id=11,\n # debug=True\n)\nclient.open()\n# addr = 2\n# light = client.read_coils(addr, 1)",
|
||||
"detail": "other_client",
|
||||
"documentation": {}
|
||||
},
|
||||
{
|
||||
"label": "client",
|
||||
"kind": 5,
|
||||
"importPath": "other_client",
|
||||
"description": "other_client",
|
||||
"peekOfCode": "client = ModbusClient(\n host=MODBUS_SERVER_HOST,\n port=MODBUS_SERVER_PORT,\n unit_id=11,\n # debug=True\n)\nclient.open()\n# addr = 2\n# light = client.read_coils(addr, 1)\n# print(\"состояние лампочки\", light)",
|
||||
"detail": "other_client",
|
||||
"documentation": {}
|
||||
},
|
||||
{
|
||||
"label": "res",
|
||||
"kind": 5,
|
||||
"importPath": "other_client",
|
||||
"description": "other_client",
|
||||
"peekOfCode": "res = []\ndef get_reg_range(start, stop):\n for i in range(start, stop):\n r = client.read_holding_registers(i, 1)\n if r and r != [0] and r != [65535]:\n print(f\"{i} === {r}\")\nget_reg_range(0, 100)\nget_reg_range(2100, 2600)\nget_reg_range(20000, 24000)\nget_reg_range(56000, 57000)",
|
||||
"detail": "other_client",
|
||||
"documentation": {}
|
||||
},
|
||||
{
|
||||
"label": "MODBUS_SERVER_HOST",
|
||||
"kind": 5,
|
||||
"importPath": "send_photo",
|
||||
"description": "send_photo",
|
||||
"peekOfCode": "MODBUS_SERVER_HOST = \"192.168.70.55\" # IP-адрес Modbus-сервера\nMODBUS_SERVER_PORT = 9760",
|
||||
"detail": "send_photo",
|
||||
"documentation": {}
|
||||
},
|
||||
{
|
||||
"label": "MODBUS_SERVER_PORT",
|
||||
"kind": 5,
|
||||
"importPath": "send_photo",
|
||||
"description": "send_photo",
|
||||
"peekOfCode": "MODBUS_SERVER_PORT = 9760",
|
||||
"detail": "send_photo",
|
||||
"documentation": {}
|
||||
},
|
||||
{
|
||||
"label": "server",
|
||||
"kind": 5,
|
||||
"importPath": "server",
|
||||
"description": "server",
|
||||
"peekOfCode": "server = ModbusTcpServer(address=(MODBUS_SERVER_HOST, MODBUS_SERVER_PORT))",
|
||||
"detail": "server",
|
||||
"importPath": "prepare",
|
||||
"description": "prepare",
|
||||
"peekOfCode": "file = all_files[0]\ndef get_value(c, s):\n [x] = [item.replace(s, '') for item in c if item.startswith(s)] or [0]\n return float(x)\nwith open(file, 'r') as fp:\n lines = fp.readlines()\n # print(lines)\n prev_x = None\n prev_y = None\n prev_z = None",
|
||||
"detail": "prepare",
|
||||
"documentation": {}
|
||||
}
|
||||
]
|
File diff suppressed because it is too large
Load Diff
|
@ -1,46 +0,0 @@
|
|||
from pyModbusTCP.client import ModbusClient
|
||||
|
||||
print("modbus test")
|
||||
|
||||
# Настройки клиента Modbus
|
||||
MODBUS_SERVER_HOST = "192.168.70.55" # IP-адрес Modbus-сервера
|
||||
MODBUS_SERVER_PORT = 502
|
||||
|
||||
client = ModbusClient(
|
||||
host=MODBUS_SERVER_HOST,
|
||||
port=MODBUS_SERVER_PORT,
|
||||
unit_id=11,
|
||||
# debug=True
|
||||
)
|
||||
client.open()
|
||||
|
||||
# addr = 2
|
||||
# light = client.read_coils(addr, 1)
|
||||
# print("состояние лампочки", light)
|
||||
|
||||
# print("пишем противоположное", not light[0])
|
||||
# client.write_single_coil(addr, not light[0])
|
||||
|
||||
# print("теперь состояние", client.read_coils(addr, 1))
|
||||
|
||||
# максимум по input register 2413
|
||||
# for i in range(2267, 2283):
|
||||
# for i in range(2500, 2600):
|
||||
res = []
|
||||
def get_reg_range(start, stop):
|
||||
for i in range(start, stop):
|
||||
r = client.read_holding_registers(i, 1)
|
||||
if r and r != [0] and r != [65535]:
|
||||
print(f"{i} === {r}")
|
||||
|
||||
get_reg_range(0, 100)
|
||||
get_reg_range(2100, 2600)
|
||||
get_reg_range(20000, 24000)
|
||||
get_reg_range(56000, 57000)
|
||||
|
||||
# r = client.read_holding_registers(21901, 1)
|
||||
# print(r)
|
||||
|
||||
# 21901 --- 800 регистр
|
||||
|
||||
client.close()
|
|
@ -0,0 +1,41 @@
|
|||
import glob
|
||||
|
||||
all_files = glob.glob("data/*")
|
||||
file = all_files[0]
|
||||
|
||||
def get_value(c, s):
|
||||
[x] = [item.replace(s, '') for item in c if item.startswith(s)] or [0]
|
||||
return float(x)
|
||||
|
||||
with open(file, 'r') as fp:
|
||||
lines = fp.readlines()
|
||||
# print(lines)
|
||||
prev_x = None
|
||||
prev_y = None
|
||||
prev_z = None
|
||||
for l in lines[:100]:
|
||||
data = l.strip().split(' ')
|
||||
if len(data) > 3 and data[1] in ['G01', 'G02', 'G03']:
|
||||
_, type, *args = data
|
||||
if type in ['G01']:
|
||||
parse_x = get_value(args, 'X')
|
||||
parse_y = get_value(args, 'Y')
|
||||
parse_z = get_value(args, 'Z')
|
||||
|
||||
if not prev_x: prev_x = parse_x
|
||||
if not prev_y: prev_y = parse_y
|
||||
if not prev_z: prev_z = parse_z
|
||||
|
||||
x = prev_x - parse_x
|
||||
y = prev_y - parse_y
|
||||
z = prev_z - parse_z
|
||||
|
||||
prev_x = parse_x
|
||||
prev_y = parse_y
|
||||
prev_z = parse_z
|
||||
|
||||
print('line',x,y,z)
|
||||
if type in ['G02', 'G03']:
|
||||
pass
|
||||
# print(args)
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
MODBUS_SERVER_HOST = "192.168.70.55" # IP-адрес Modbus-сервера
|
||||
MODBUS_SERVER_PORT = 9760
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
from pymodbus.server import ModbusTcpServer
|
||||
from pymodbus.constants import Endian
|
||||
from pymodbus.payload import BinaryPayloadDecoder
|
||||
|
||||
from client import MODBUS_SERVER_PORT, MODBUS_SERVER_HOST
|
||||
|
||||
server = ModbusTcpServer(address=(MODBUS_SERVER_HOST, MODBUS_SERVER_PORT))
|
|
@ -1,5 +0,0 @@
|
|||
from svgpathtools import svg2paths2
|
||||
paths, attributes, svg_attributes = svg2paths2('test.svg')
|
||||
|
||||
print(paths)
|
||||
print(attributes)
|
Loading…
Reference in New Issue