[ { "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": "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": "glob", "kind": 6, "isExtraImport": true, "importPath": "glob", "description": "glob", "detail": "glob", "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": "collect_coordinates", "kind": 2, "importPath": "client", "description": "client", "peekOfCode": "def collect_coordinates():\n # собираем предварительные данные\n x = two_byte_convert(client.read_holding_registers(2332, 2, MODBUS_SLAVE_ID))\n y = two_byte_convert(client.read_holding_registers(2334, 2, MODBUS_SLAVE_ID))\n z = two_byte_convert(client.read_holding_registers(2336, 2, MODBUS_SLAVE_ID))\n u = two_byte_convert(client.read_holding_registers(2338, 2, MODBUS_SLAVE_ID))\n v = two_byte_convert(client.read_holding_registers(2340, 2, MODBUS_SLAVE_ID))\n w = two_byte_convert(client.read_holding_registers(2342, 2, MODBUS_SLAVE_ID))\n print(\n f\"Предварительные данные X {x * 0.001}, Y {y * 0.001}, Z {z*0.001}, U {u*0.001}, V {v*0.001}, W {w*0.001}\"", "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]\ndef set_user_reg_800(data):\n for item in data:\n d, values = item\n set_user_register(d, values)\ndef start_in_auto():\n # старт в авторежиме single loop", "detail": "client", "documentation": {} }, { "label": "to_double", "kind": 2, "importPath": "client", "description": "client", "peekOfCode": "def to_double(integr):\n return [(integr >> 16) & 0xFFFF, integr & 0xFFFF]\ndef set_user_reg_800(data):\n for item in data:\n d, values = item\n set_user_register(d, values)\ndef start_in_auto():\n # старт в авторежиме single loop\n client.write_register(20002, 1, MODBUS_SLAVE_ID)\nclient = ModbusTcpClient(", "detail": "client", "documentation": {} }, { "label": "set_user_reg_800", "kind": 2, "importPath": "client", "description": "client", "peekOfCode": "def set_user_reg_800(data):\n for item in data:\n d, values = item\n set_user_register(d, values)\ndef start_in_auto():\n # старт в авторежиме single loop\n client.write_register(20002, 1, MODBUS_SLAVE_ID)\nclient = ModbusTcpClient(\n host=MODBUS_SERVER_HOST,\n port=MODBUS_SERVER_PORT,", "detail": "client", "documentation": {} }, { "label": "start_in_auto", "kind": 2, "importPath": "client", "description": "client", "peekOfCode": "def start_in_auto():\n # старт в авторежиме single loop\n client.write_register(20002, 1, MODBUS_SLAVE_ID)\nclient = ModbusTcpClient(\n host=MODBUS_SERVER_HOST,\n port=MODBUS_SERVER_PORT,\n)\nclient.connect()\n# максимальное количество coils = 286\n# bulb(0)", "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(0)\n# get_coordinates()\n# get_or_set_speed(10)\ntry:", "detail": "client", "documentation": {} }, { "label": "get_value", "kind": 2, "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": "all_files", "kind": 5, "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": "file", "kind": 5, "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": {} } ]