Skip to content

Commit fa353f5

Browse files
committed
Update adapter with type-dependent version
1 parent 5e62817 commit fa353f5

7 files changed

Lines changed: 109 additions & 89 deletions

File tree

adapters/describe.json

Lines changed: 107 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -36,108 +36,110 @@
3636
"properties": {
3737
"connections": {
3838
"items": {
39-
"properties": {
40-
"baudrate": {
41-
"description": "Baud rate (serial only)",
42-
"enum": [
43-
1200,
44-
2400,
45-
4800,
46-
9600,
47-
19200,
48-
38400,
49-
57600,
50-
115200
51-
],
52-
"title": "Baud Rate",
53-
"type": "integer",
54-
"x-enumLabels": [
55-
"1200",
56-
"2400",
57-
"4800",
58-
"9600",
59-
"19200",
60-
"38400",
61-
"57600",
62-
"115200"
63-
]
64-
},
65-
"databits": {
66-
"description": "Data bits (serial only)",
67-
"enum": [
68-
5,
69-
6,
70-
7,
71-
8
72-
],
73-
"title": "Data Bits",
74-
"type": "integer",
75-
"x-enumLabels": [
76-
"5",
77-
"6",
78-
"7",
79-
"8"
80-
]
39+
"else": {
40+
"properties": {
41+
"baudrate": {
42+
"description": "Baud rate (serial only)",
43+
"enum": [
44+
1200,
45+
2400,
46+
4800,
47+
9600,
48+
19200,
49+
38400,
50+
57600,
51+
115200
52+
],
53+
"title": "Baud Rate",
54+
"type": "integer",
55+
"x-enumLabels": [
56+
"1200",
57+
"2400",
58+
"4800",
59+
"9600",
60+
"19200",
61+
"38400",
62+
"57600",
63+
"115200"
64+
]
65+
},
66+
"databits": {
67+
"description": "Data bits (serial only)",
68+
"enum": [
69+
5,
70+
6,
71+
7,
72+
8
73+
],
74+
"title": "Data Bits",
75+
"type": "integer",
76+
"x-enumLabels": [
77+
"5",
78+
"6",
79+
"7",
80+
"8"
81+
]
82+
},
83+
"parity": {
84+
"description": "Parity: N=none, E=even, O=odd (serial only)",
85+
"enum": [
86+
"N",
87+
"E",
88+
"O"
89+
],
90+
"title": "Parity",
91+
"type": "string",
92+
"x-enumLabels": [
93+
"None",
94+
"Even",
95+
"Odd"
96+
]
97+
},
98+
"portName": {
99+
"description": "Serial port name (serial only)",
100+
"title": "Serial Port Name",
101+
"type": "string"
102+
},
103+
"stopbits": {
104+
"description": "Stop bits: 1, 1.5 (=3), or 2 (serial only)",
105+
"enum": [
106+
1,
107+
2,
108+
3
109+
],
110+
"title": "Stop Bits",
111+
"type": "integer",
112+
"x-enumLabels": [
113+
"1",
114+
"2",
115+
"1.5"
116+
]
117+
}
118+
}
119+
},
120+
"if": {
121+
"properties": {
122+
"type": {
123+
"const": "tcp"
124+
}
81125
},
126+
"required": [
127+
"type"
128+
]
129+
},
130+
"properties": {
82131
"id": {
83132
"description": "Connection index (0, 1, or 2)",
84133
"maximum": 2,
85134
"minimum": 0,
86135
"title": "Connection ID",
87136
"type": "integer"
88137
},
89-
"ip": {
90-
"description": "IP address (TCP only)",
91-
"title": "IP Address",
92-
"type": "string"
93-
},
94-
"parity": {
95-
"description": "Parity: N=none, E=even, O=odd (serial only)",
96-
"enum": [
97-
"N",
98-
"E",
99-
"O"
100-
],
101-
"title": "Parity",
102-
"type": "string",
103-
"x-enumLabels": [
104-
"None",
105-
"Even",
106-
"Odd"
107-
]
108-
},
109138
"persistent": {
110139
"description": "Keep connection open between reads",
111140
"title": "Keep Connection Persistent",
112141
"type": "boolean"
113142
},
114-
"port": {
115-
"description": "TCP port (TCP only)",
116-
"maximum": 65535,
117-
"minimum": 1,
118-
"title": "TCP Port",
119-
"type": "integer"
120-
},
121-
"portName": {
122-
"description": "Serial port name (serial only)",
123-
"title": "Serial Port Name",
124-
"type": "string"
125-
},
126-
"stopbits": {
127-
"description": "Stop bits: 1, 1.5 (=3), or 2 (serial only)",
128-
"enum": [
129-
1,
130-
2,
131-
3
132-
],
133-
"title": "Stop Bits",
134-
"type": "integer",
135-
"x-enumLabels": [
136-
"1",
137-
"2",
138-
"1.5"
139-
]
140-
},
141143
"timeout": {
142144
"description": "Timeout in milliseconds",
143145
"minimum": 0,
@@ -162,6 +164,22 @@
162164
"id",
163165
"type"
164166
],
167+
"then": {
168+
"properties": {
169+
"ip": {
170+
"description": "IP address (TCP only)",
171+
"title": "IP Address",
172+
"type": "string"
173+
},
174+
"port": {
175+
"description": "TCP port (TCP only)",
176+
"maximum": 65535,
177+
"minimum": 1,
178+
"title": "TCP Port",
179+
"type": "integer"
180+
}
181+
}
182+
},
165183
"type": "object"
166184
},
167185
"type": "array"

adapters/dummymodbusadapter

13.6 KB
Binary file not shown.

adapters/dummymodbusadapter.exe

11.3 KB
Binary file not shown.

adapters/json-rpc-spec.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ Each property in `schema` includes the following additional fields (standard JSO
120120
| `title` | Standard JSON Schema annotation. UI-friendly label for the field, suitable for use in form inputs and dialog labels |
121121
| `x-enumLabels` | Custom extension. Present on enum properties only. A string array, parallel to `enum`, giving a UI-friendly display name for each allowed value |
122122

123+
The connection schema uses JSON Schema Draft 7 `if`/`then`/`else` to express type-dependent fields. When `type` equals `"tcp"`, the fields in `then.properties` apply (TCP-specific). Otherwise the fields in `else.properties` apply (serial-specific). A UI can use this to enable or disable the relevant fields based on the selected connection type.
124+
123125
---
124126

125127
### `adapter.configure`

adapters/modbusadapter

9.59 KB
Binary file not shown.

adapters/modbusadapter.exe

11.3 KB
Binary file not shown.

adapters/schemadump.exe

2.59 MB
Binary file not shown.

0 commit comments

Comments
 (0)