From 459e6baa331ab639fa08ebbd6a7718b537141574 Mon Sep 17 00:00:00 2001 From: Yu Sun Date: Sun, 10 Jul 2022 03:39:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 70 +++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 53 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index b4f39d3..fe61b3e 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ - [EdgeManager(SCADA系统)](#edgemanagerscada系统) - [API](#api) - [class `EDataCapture`](#class-edatacapture) + - [0. HTTP POST: `set_node_data`](#0-http-post-set_node_data) - [开发环境](#开发环境) - [技术细节](#技术细节) - [0. `EdgeManager\EDataCapture\EDataCapture -> set_data()`为什么是以`6507524`为大小chunked的?](#0-edgemanageredatacaptureedatacapture---set_data为什么是以6507524为大小chunked的) @@ -13,21 +14,38 @@ ### class `EDataCapture` -0. HTTP POST: `set_data` +#### 0. HTTP POST: `set_node_data` **请求** +> 需保证每次传入数据的**工序单元(working subclass)和数值类型(type)** 一致。 +> +> 在此基础上尽量单次传入尽量多数据使得性能最大化。 +> +> 但仍需兼顾传输速率和超时时间。 + ```json { - 'action': 'set_data', - 'param': { - 'working_subclass': , - 'type': 'string' | 'int' | 'float' | 'bool', - 'code': , - // value的类型需与type对应 - 'value': , - 'device_code': [string], - 'batch': [string] + "action": "set_node_data", + "param": { + "working_subclass": , + "type": "string" | "int" | "float" | "bool", + "data": [ + { + "code": , + // value的类型需与type对应 + "value": , + "device_code": [string], + "batch": [string] + }, + { + "code": , + "value": , + "device_code": [string], + "batch": [string] + }, + ... + ] } } ``` @@ -38,9 +56,9 @@ ```json { - 'action': 'result_set_data', - 'errcode': 0, - 'errmsg': '' + "action": "result_set_data", + "errcode": 0, + "errmsg": "" } ``` @@ -48,12 +66,14 @@ ```json { - 'action': 'result_set_data', - 'errcode': 4002, - 'errmsg': 'ROLLBACKed: Bad data received (structure and/or values)' + "action": "result_set_data", + "errcode": 4002, + "errmsg": "ROLLBACKed: Bad data received (structure and/or values)" } ``` + + ## 开发环境 拉取代码: @@ -79,9 +99,19 @@ docker exec -it edge_manager bash 后端调试: ```bash +# In container php EdgeManager.php --server_name=GPU-server-01 --user=postgres --password=big_dick start ``` +前端调试: + +```bash +# In host +# yarn +# yarn watch +yarn serve +``` + 客户端连接: ```bash @@ -96,7 +126,13 @@ psql -h localhost -U postgres ### 0. `EdgeManager\EDataCapture\EDataCapture -> set_data()`为什么是以`6507524`为大小chunked的? -首先明确一点,根据PostgreSQL的技术架构,条件允许的情况下,**一次性插入多条记录是效率最高的**。 +首先明确一点,根据PostgreSQL的技术架构,条件允许的情况下,**一次性插入多条记录是效率最高的**,比如: + +```sql +INSERT INTO films (code, title, did, date_prod, kind) VALUES + ('B6717', 'Tampopo', 110, '1985-02-10', 'Comedy'), + ('HG120', 'The Dinner Game', 140, DEFAULT, 'Comedy'); +``` 这其中,仅插入部分字段的值,比如: