LECPServer中文 ↗Free download

WebApi and PLC Node data reading and writing

On this page
  1. plc_read_node
  2. plc_read_nodes
  3. plc_write_node
  4. plc_write_nodes

After configuring the http service, you can communicate with LECPServer through WebApi.

There are 4 interface action of communication commands, which are

  • plc_read_node read a single node
  • plc_read_nodes read multiple nodes
  • plc_write_node write a single node
  • plc_write_nodes write multiple nodes

The details of the interface are as follows


plc_read_node

Basic Information

read a single node

  • Interface status: normal
  • Interface URL: http://xxxxx:xxx
  • Request method: POST
  • Content-Type: application/json

Parameter description

name type description
action string command plc_read_node
node string Node name, in the form NODE.[dev].[node_name], such as NODE.MODBUS.C00

Return value description

name type description
errcode int Exception number, returns 0 if successful
errmsg string Exception information, if successful, return ""
rtval object array Return the values of the node as an array, the length of the array is the setting length of PLC node in LECPServer

Example

// send
{
	"action": "plc_read_node",
	"node": "NODES.MODBUS.C0000"
}

// response
{
	"errcode": 0,
	"errmsg": "",
	"rtval": [
		true,
		true,
		false,
		false,
		false
	]
}

plc_read_nodes

read multiple nodes

Basic Information

  • Interface status: normal
  • Interface URL: http://xxxxx:xxx
  • Request method: POST
  • Content-Type: application/json

Parameter description

name type description
action string command plc_read_nodes
node string array Nodes name, in the form of [ NODE.[dev].[node_name], NODE.[dev].[node_name]], such as [ "NODE.MODBUS.C00" , ""NODE.MODBUS.H00""]

Return value description

name type description
errcode int Exception number, returns 0 if successful
errmsg string Exception information, if successful, return ""
rtval object array Returns the values ​​of all nodes in a two-dimensional array, the length of the array is the setting length of PLC node in LECPServer

Example

// send
{
	"action": "plc_read_nodes",
	"node": [
		"NODES.MODBUS.C0000",
		"NODES.MODBUS.H0000"
	]
}

// response
{
	"errcode": 0,
	"errmsg": "",
	"rtval": [
		true,
		true,
		false,
		false,
		false
	]
}

plc_write_node

write a single node

Basic Information

  • Interface status: normal
  • Interface URL: http://xxxxx:xxx
  • Request method: POST
  • Content-Type: application/json

Parameter description

name type description
action string command plc_write_node
node string Node name, in the form NODE.[dev].[node_name], such as NODE.MODBUS.C00
value object array The value of the node, as array, the length of the array is needs to be the same as the setting length of PLC node in LECPServer

Return value description

name type description
errcode int Exception number, returns 0 if successful
errmsg string Exception information, if successful, return ""

Example

// send
{
	"action": "plc_write_node",
	"node": "NODES.MODBUS.C0000",
	"value": [
		true,
		true,
		false,
		false,
		false
	]
}

// response
{
	"errcode": 0,
	"errmsg": ""
}

plc_write_nodes

write multiple nodes

Basic Information

  • Interface status: normal
  • Interface URL: http://xxxxx:xxx
  • Request method: POST
  • Content-Type: application/json

Parameter description

name type description
action string 命令字 plc_write_nodes
node string array Nodes name, in the form of [ NODE.[dev].[node_name], NODE.[dev].[node_name]], such as [ "NODE.MODBUS.C00" , ""NODE.MODBUS.H00""]
value object array The value of the nodes, expressed as a two-dimensional array, such as [[v1-1,v1-2,v1-3,v1-4], [v2-1,v2-2,v2-3,v2,4]], The length of each subarray needs to be consistent with the PLC Node setting length of LECPServer

Return value description

name type description
errcode int Exception number, returns 0 if successful
errmsg string Exception information, if successful, return ""

Example

// send
{
	"action": "plc_write_nodes",
	"node": [
		"NODES.MODBUS.C0000",
		"NODES.MODBUS.H0000"
	],
	"value": [
		[
			true,
			true,
			false,
			false,
			false
		],
		[
			99,
			99,
			99,
			99,
			99
		]
	]
}

// response
{
	"errcode": 0,
	"errmsg": ""
}