281 lines
12 KiB
JSON
281 lines
12 KiB
JSON
[
|
|
{
|
|
"label": "ModbusTcpClient",
|
|
"importPath": "pymodbus.client",
|
|
"description": "pymodbus.client",
|
|
"isExtraImport": true,
|
|
"detail": "pymodbus.client",
|
|
"documentation": {}
|
|
},
|
|
{
|
|
"label": "Endian",
|
|
"importPath": "pymodbus.constants",
|
|
"description": "pymodbus.constants",
|
|
"isExtraImport": true,
|
|
"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",
|
|
"description": "pymodbus.payload",
|
|
"isExtraImport": true,
|
|
"detail": "pymodbus.payload",
|
|
"documentation": {}
|
|
},
|
|
{
|
|
"label": "time",
|
|
"kind": 6,
|
|
"isExtraImport": true,
|
|
"importPath": "time",
|
|
"description": "time",
|
|
"detail": "time",
|
|
"documentation": {}
|
|
},
|
|
{
|
|
"label": "struct",
|
|
"kind": 6,
|
|
"isExtraImport": true,
|
|
"importPath": "struct",
|
|
"description": "struct",
|
|
"detail": "struct",
|
|
"documentation": {}
|
|
},
|
|
{
|
|
"label": "ModbusClient",
|
|
"importPath": "pyModbusTCP.client",
|
|
"description": "pyModbusTCP.client",
|
|
"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": "two_byte_convert",
|
|
"kind": 2,
|
|
"importPath": "client",
|
|
"description": "client",
|
|
"peekOfCode": "def two_byte_convert(result):\n # print(result)\n v0 = result.registers[0]\n value = (v0 << 16) + result.registers[1]\n if result.registers[0] > (65535 * 0.5):\n value = value - (1 << 32)\n return value\ndef bulb(addr):\n try:\n coils = client.read_coils(addr, 1, MODBUS_SLAVE_ID)",
|
|
"detail": "client",
|
|
"documentation": {}
|
|
},
|
|
{
|
|
"label": "bulb",
|
|
"kind": 2,
|
|
"importPath": "client",
|
|
"description": "client",
|
|
"peekOfCode": "def bulb(addr):\n try:\n coils = client.read_coils(addr, 1, MODBUS_SLAVE_ID)\n print(\"читаем начальное состояние\", coils.bits)\n new_bits = coils.bits\n new_bits[0] = not new_bits[0]\n print(\"пытаемся записать\", new_bits, coils.slave_id)\n result = client.write_coil(addr, new_bits[0], coils.slave_id)\n print(result)\n print(",
|
|
"detail": "client",
|
|
"documentation": {}
|
|
},
|
|
{
|
|
"label": "get_coordinates",
|
|
"kind": 2,
|
|
"importPath": "client",
|
|
"description": "client",
|
|
"peekOfCode": "def get_coordinates():\n try:\n data = [\n (\"j1\", 2268),\n (\"j2\", 2270),\n (\"j3\", 2272),\n (\"j4\", 2274),\n (\"j5\", 2276),\n (\"j6\", 2278),\n (\"x\", 2332),",
|
|
"detail": "client",
|
|
"documentation": {}
|
|
},
|
|
{
|
|
"label": "get_or_set_speed",
|
|
"kind": 2,
|
|
"importPath": "client",
|
|
"description": "client",
|
|
"peekOfCode": "def get_or_set_speed(number=None):\n result = client.read_holding_registers(20200, 1, MODBUS_SLAVE_ID)\n print(\"сейчас скорость\", result.registers[0] * 0.1)\n if number and number > 0 and number <= 1000:\n client.write_register(20200, number * 10, MODBUS_SLAVE_ID)\n result = client.read_holding_registers(20200, 1, MODBUS_SLAVE_ID)\n print(\"установлена скорость\", result.registers[0] * 0.1)\ndef set_user_register(n, values):\n client.write_registers(indent + s + k * n, values, MODBUS_SLAVE_ID)\ndef to_double(integr):",
|
|
"detail": "client",
|
|
"documentation": {}
|
|
},
|
|
{
|
|
"label": "set_user_register",
|
|
"kind": 2,
|
|
"importPath": "client",
|
|
"description": "client",
|
|
"peekOfCode": "def set_user_register(n, values):\n client.write_registers(indent + s + k * n, values, MODBUS_SLAVE_ID)\ndef to_double(integr):\n return [(integr >> 16) & 0xFFFF, integr & 0xFFFF]\nclient = ModbusTcpClient(\n host=MODBUS_SERVER_HOST,\n port=MODBUS_SERVER_PORT,\n)\nclient.connect()\n# максимальное количество coils = 286",
|
|
"detail": "client",
|
|
"documentation": {}
|
|
},
|
|
{
|
|
"label": "to_double",
|
|
"kind": 2,
|
|
"importPath": "client",
|
|
"description": "client",
|
|
"peekOfCode": "def to_double(integr):\n return [(integr >> 16) & 0xFFFF, integr & 0xFFFF]\nclient = ModbusTcpClient(\n host=MODBUS_SERVER_HOST,\n port=MODBUS_SERVER_PORT,\n)\nclient.connect()\n# максимальное количество coils = 286\n# bulb(2)\n# get_coordinates()",
|
|
"detail": "client",
|
|
"documentation": {}
|
|
},
|
|
{
|
|
"label": "MODBUS_SERVER_HOST",
|
|
"kind": 5,
|
|
"importPath": "client",
|
|
"description": "client",
|
|
"peekOfCode": "MODBUS_SERVER_HOST = \"192.168.70.55\" # IP-адрес Modbus-сервера\nMODBUS_SERVER_PORT = 502\nMODBUS_SLAVE_ID = 11\nindent = 21100\ns = 800\nk = 2\nfrom pymodbus.client import ModbusTcpClient\nfrom pymodbus.constants import Endian\nfrom pymodbus.payload import BinaryPayloadDecoder\nimport time",
|
|
"detail": "client",
|
|
"documentation": {}
|
|
},
|
|
{
|
|
"label": "MODBUS_SERVER_PORT",
|
|
"kind": 5,
|
|
"importPath": "client",
|
|
"description": "client",
|
|
"peekOfCode": "MODBUS_SERVER_PORT = 502\nMODBUS_SLAVE_ID = 11\nindent = 21100\ns = 800\nk = 2\nfrom pymodbus.client import ModbusTcpClient\nfrom pymodbus.constants import Endian\nfrom pymodbus.payload import BinaryPayloadDecoder\nimport time\nimport struct",
|
|
"detail": "client",
|
|
"documentation": {}
|
|
},
|
|
{
|
|
"label": "MODBUS_SLAVE_ID",
|
|
"kind": 5,
|
|
"importPath": "client",
|
|
"description": "client",
|
|
"peekOfCode": "MODBUS_SLAVE_ID = 11\nindent = 21100\ns = 800\nk = 2\nfrom pymodbus.client import ModbusTcpClient\nfrom pymodbus.constants import Endian\nfrom pymodbus.payload import BinaryPayloadDecoder\nimport time\nimport struct\ndef two_byte_convert(result):",
|
|
"detail": "client",
|
|
"documentation": {}
|
|
},
|
|
{
|
|
"label": "indent",
|
|
"kind": 5,
|
|
"importPath": "client",
|
|
"description": "client",
|
|
"peekOfCode": "indent = 21100\ns = 800\nk = 2\nfrom pymodbus.client import ModbusTcpClient\nfrom pymodbus.constants import Endian\nfrom pymodbus.payload import BinaryPayloadDecoder\nimport time\nimport struct\ndef two_byte_convert(result):\n # print(result)",
|
|
"detail": "client",
|
|
"documentation": {}
|
|
},
|
|
{
|
|
"label": "s",
|
|
"kind": 5,
|
|
"importPath": "client",
|
|
"description": "client",
|
|
"peekOfCode": "s = 800\nk = 2\nfrom pymodbus.client import ModbusTcpClient\nfrom pymodbus.constants import Endian\nfrom pymodbus.payload import BinaryPayloadDecoder\nimport time\nimport struct\ndef two_byte_convert(result):\n # print(result)\n v0 = result.registers[0]",
|
|
"detail": "client",
|
|
"documentation": {}
|
|
},
|
|
{
|
|
"label": "k",
|
|
"kind": 5,
|
|
"importPath": "client",
|
|
"description": "client",
|
|
"peekOfCode": "k = 2\nfrom pymodbus.client import ModbusTcpClient\nfrom pymodbus.constants import Endian\nfrom pymodbus.payload import BinaryPayloadDecoder\nimport time\nimport struct\ndef two_byte_convert(result):\n # print(result)\n v0 = result.registers[0]\n value = (v0 << 16) + result.registers[1]",
|
|
"detail": "client",
|
|
"documentation": {}
|
|
},
|
|
{
|
|
"label": "client",
|
|
"kind": 5,
|
|
"importPath": "client",
|
|
"description": "client",
|
|
"peekOfCode": "client = ModbusTcpClient(\n host=MODBUS_SERVER_HOST,\n port=MODBUS_SERVER_PORT,\n)\nclient.connect()\n# максимальное количество coils = 286\n# bulb(2)\n# get_coordinates()\n# get_or_set_speed(10)\ntry:",
|
|
"detail": "client",
|
|
"documentation": {}
|
|
},
|
|
{
|
|
"label": "get_reg_range",
|
|
"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",
|
|
"documentation": {}
|
|
},
|
|
{
|
|
"label": "MODBUS_SERVER_HOST",
|
|
"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",
|
|
"documentation": {}
|
|
},
|
|
{
|
|
"label": "MODBUS_SERVER_PORT",
|
|
"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",
|
|
"documentation": {}
|
|
}
|
|
] |