9.1 APP Design
9.1.1 Basic Structure
The basic structure of APP is defined in JSON format and contains the following core fields:
{
"code": "vip.woody.app.test1",
"name": "测试应用",
"logo": "",
"script": "",
"schema": "",
"pages": "",
"config": ""
}- Field Description
| Field | Type | Required | Description |
|---|---|---|---|
code |
String | ✅ | Application unique identifier. Installing with the same code will overwrite the existing application |
name |
String | ✅ | Application display name |
logo |
String | ❌ | Application icon, supports base64 encoding or image URL |
script |
String | ❌ | Lua backend script that controls application logic. See APP Backend for details |
schema |
String | ❌ | Application definition in encoded JSON format |
pages |
String | ❌ | Frontend page definition in encoded JSON format |
config |
String | ❌ | Configuration information after application installation |
9.1.2 Application Definition Schema
9.1.2.1 Structure Overview
Structure Overview
{
"data": [
{
"name": "products",
"readable": true,
"writable": false,
"type": "table",
"struct": [
{
"name": "device",
"type": "string"
},
{
"name": "value",
"type": "int"
},
{
"name": "delta",
"type": "int"
},
{
"name": "time",
"type": "int"
}
]
}
],
"input": [
{
"class": "cnc1",
"define": [
{
"code": "products",
"name": "产量",
"type": "int"
}
],
"title": "一类加工机床"
}
]
}9.1.2.2 data Field Definition
The data field defines the data storage structure of the application, using array format. Each element contains the following attributes:
| Field | Type | Description |
|---|---|---|
name |
String | Data table name |
readable |
Boolean | Whether readable |
writable |
Boolean | Whether writable |
type |
String | Data type, currently only supports table |
struct |
Array | Table structure definition |
- Only the access permissions of automatically generated table access APIs are controlled by the readable and writable fields. Data access in backend Lua scripts is not affected.
9.1.2.3 Table Structure Definition
struct 数组中每个字段包含:
name: Field nametype: Field type, supports the following types:stringString typeintInteger typefloatFloating point type
9.1.2.3.1 Automatically Generated API Interfaces
Based on the data definition, the system will automatically expose the following RESTful API interfaces:
Path Parameters
code: Application identifiertable: Data table nameid: Record unique identifierData List Query
GET /api/app/{code}/data/{table}
Query Parameters
| Field | Type | 默认值 | Description |
|---|---|---|---|
_start |
Number | 0 | Starting record position |
_limit |
Number | 10 | Number of records returned |
{field} |
Any | - | Equal value filter, e.g., ?value=1 |
>{field} |
Any | - | Greater than or equal filter, e.g., ?>value=1 |
<{field} |
Any | - | Less than or equal filter, e.g., ?<value=1 |
order |
String | - | Ascending sort, e.g., ?order=value |
-order |
String | - | Descending sort, e.g., ?-order=value |
- Add Record
POST /api/app/{code}/data/{table}
- Single Record Query
GET /api/app/{code}/data/{table}/{id}
- Update Record
PUT /api/app/{code}/data/{table}/{id}
- Delete Record
DELETE /api/app/{code}/data/{table}/{id}
9.1.2.4 input Field Definition
The input field defines devices within the APP and fields after device mapping. The design idea is that an App may target multiple different types of devices, such as various PLCs and CNCs. Some functions require abstracting different devices into one type of device, so a device type needs to be defined here for mapping during configuration:
{
"class": "cnc1",
"define": [
{
"code": "products",
"name": "产量",
"type": "int"
}
],
"title": "一类加工机床"
}| Field | Type | Description |
|---|---|---|
class |
String | Device type |
title |
String | Device type name |
define |
Array | Variable definition |
Variable Definition
| Field | Type | Description |
|---|---|---|
code |
String | Variable code |
name |
String | Variable name |
type |
String | Variable type |
9.1.3 Configuration Field config
The config field is used to store the configuration content after the app is installed
9.1.3.2 device Field Definition
The device field defines the mapping from devices collected by IoTBoX to devices within the APP, using array format
| Field | Type | Description |
|---|---|---|
code |
String | Machine Code |
class |
Boolean | Device type within App |
variable |
Array | Mapping variable definition |
Mapping Variable Definition
| Field | Type | Description |
|---|---|---|
dst |
String | Original variable code |
src |
Boolean | Variable code within App |
The meaning of the above configuration is: map the collection device M06 configured in IoTBoX as a cnc1 type into the App, and map the cnc_products collected by M06 as the product variable of cnc1.