-
-
Notifications
You must be signed in to change notification settings - Fork 203
Expand file tree
/
Copy pathopenApi.ts
More file actions
609 lines (606 loc) · 18.1 KB
/
Copy pathopenApi.ts
File metadata and controls
609 lines (606 loc) · 18.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
import { OpenApiDescription } from '../swagger'
const radarIdParam = {
name: 'radar_id',
in: 'path',
required: true,
schema: { type: 'string' },
description: "Radar identifier (e.g., 'nav1034A')",
example: 'nav1034A'
}
const radarApiDoc = {
openapi: '3.0.0',
info: {
title: 'Signal K Radar API',
version: '3.1.0',
description:
'REST API for controlling marine radars. Supports Navico (Simrad, B&G, Lowrance), ' +
'Furuno, Raymarine, and Garmin radar systems. Provides endpoints for discovering radars, ' +
'reading and setting control values, and accessing radar data via WebSocket streams.'
},
tags: [
{ name: 'Radars', description: 'Radar discovery and capabilities' },
{ name: 'Controls', description: 'Read and modify radar control settings' },
{ name: 'Targets', description: 'ARPA target acquisition and tracking' }
],
components: {
schemas: {
RadarInfo: {
type: 'object',
properties: {
id: {
type: 'string',
description: 'Radar identifier.'
},
name: {
type: 'string',
description: 'User-defined name or auto-detected model name'
},
brand: {
type: 'string',
description:
'Radar manufacturer brand (Navico, Furuno, Raymarine, Garmin, Emulator)'
},
model: {
type: 'string',
description: 'Radar model name if detected'
},
spokesPerRevolution: {
type: 'integer',
description: 'Number of spokes per full rotation'
},
maxSpokeLength: {
type: 'integer',
description: 'Maximum number of samples per spoke'
}
},
required: ['id', 'name', 'brand']
},
Capabilities: {
type: 'object',
properties: {
maxRange: {
type: 'integer',
description: 'Maximum supported range in meters'
},
minRange: {
type: 'integer',
description: 'Minimum supported range in meters'
},
supportedRanges: {
type: 'array',
items: { type: 'integer' },
description: 'All supported range values in meters'
},
spokesPerRevolution: {
type: 'integer',
description: 'Number of spokes per full rotation'
},
maxSpokeLength: {
type: 'integer',
description: 'Maximum number of samples per spoke'
},
pixelValues: {
type: 'integer',
description: 'Number of distinct pixel intensity values'
},
legend: {
type: 'object',
description: 'Color mapping for interpreting spoke data'
},
hasDoppler: { type: 'boolean' },
hasDualRange: { type: 'boolean' },
hasDualRadar: { type: 'boolean' },
hasSparseSpokes: { type: 'boolean' },
noTransmitSectors: {
type: 'integer',
description: 'Number of configurable no-transmit sectors'
},
stationary: {
type: 'boolean',
description:
'Whether radar is configured as stationary (shore-based)'
},
controls: {
type: 'object',
description: 'Map of control IDs to their definitions',
additionalProperties: {
$ref: '#/components/schemas/ControlDefinition'
}
}
},
required: [
'maxRange',
'minRange',
'supportedRanges',
'spokesPerRevolution',
'maxSpokeLength',
'pixelValues',
'legend',
'hasDoppler',
'hasDualRange',
'hasDualRadar',
'hasSparseSpokes',
'noTransmitSectors',
'stationary',
'controls'
]
},
ControlDefinition: {
type: 'object',
properties: {
id: { type: 'integer', description: 'Numeric control identifier' },
name: { type: 'string', description: 'Human-readable control name' },
dataType: {
type: 'string',
enum: [
'number',
'enum',
'string',
'button',
'sector',
'zone',
'rect'
],
description: 'Control data type'
},
category: {
type: 'string',
description:
'Control category (e.g., display, installation, targets)'
},
minValue: { type: 'number' },
maxValue: { type: 'number' },
stepValue: { type: 'number' },
units: {
type: 'string',
description: 'SI unit (m, rad, s, m/s, rad/s)'
},
description: { type: 'string' },
descriptions: {
type: 'object',
description: 'Value descriptions for enum types',
additionalProperties: { type: 'string' }
},
hasAuto: { type: 'boolean' },
hasAutoAdjustable: { type: 'boolean' },
hasEnabled: {
type: 'boolean',
description:
'Whether the control has an enabled/disabled toggle (sector, zone, rect)'
},
isReadOnly: {
type: 'boolean',
description: 'Whether the control is read-only'
},
maxDistance: {
type: 'number',
description: 'Maximum distance for zone controls (meters)'
},
validValues: {
type: 'array',
items: { type: 'integer' },
description:
'Subset of values that can be set by clients (enum controls)'
}
},
required: ['id', 'name', 'dataType', 'category']
},
ControlValue: {
type: 'object',
description:
'Control value. Fields present depend on the control dataType.',
properties: {
value: {
description: 'The control value (numeric or string)'
},
auto: {
type: 'boolean',
description: 'Whether automatic mode is enabled'
},
autoValue: {
type: 'number',
description: 'Adjustment when auto=true'
},
timestamp: {
type: 'string',
format: 'date-time',
description: 'ISO 8601 timestamp when value was last changed'
},
enabled: {
type: 'boolean',
description: 'Whether the control is enabled (sector, zone, rect)'
},
endValue: {
type: 'number',
description: 'End angle in radians (sector, zone)'
},
startDistance: {
type: 'number',
description: 'Inner radius in meters (zone)'
},
endDistance: {
type: 'number',
description: 'Outer radius in meters (zone)'
},
x1: {
type: 'number',
description: 'First corner X in meters (rect)'
},
y1: {
type: 'number',
description: 'First corner Y in meters (rect)'
},
x2: {
type: 'number',
description: 'Second corner X in meters (rect)'
},
y2: {
type: 'number',
description: 'Second corner Y in meters (rect)'
},
width: {
type: 'number',
description: 'Perpendicular width in meters (rect)'
},
allowed: {
type: 'boolean',
description:
'Whether changing this control is currently allowed (read-only)'
},
error: {
type: 'string',
description:
'Error message if the control change failed (read-only)'
}
}
},
ArpaTarget: {
type: 'object',
properties: {
id: {
type: 'integer',
description: 'Target ID (unique within radar)'
},
status: {
type: 'string',
enum: ['tracking', 'acquiring', 'lost'],
description: 'Current tracking status'
},
position: {
type: 'object',
properties: {
bearing: {
type: 'number',
description: 'Bearing from radar in radians [0, 2π)'
},
distance: {
type: 'number',
description: 'Distance from radar in meters'
},
latitude: { type: 'number' },
longitude: { type: 'number' }
},
required: ['bearing', 'distance']
},
motion: {
type: 'object',
description:
'Target motion. Omitted if not yet known; present with speed=0 for stationary targets.',
properties: {
course: {
type: 'number',
description: 'Course over ground in radians [0, 2π)'
},
speed: { type: 'number', description: 'Speed in m/s' }
},
required: ['course', 'speed']
},
danger: {
type: 'object',
description:
'Collision danger assessment. Omitted when vessels are diverging.',
properties: {
cpa: {
type: 'number',
description: 'Closest Point of Approach in meters'
},
tcpa: {
type: 'number',
description: 'Time to CPA in seconds'
}
},
required: ['cpa', 'tcpa']
},
acquisition: {
type: 'string',
enum: ['auto', 'manual'],
description: 'How target was acquired'
},
sourceZone: {
type: 'integer',
description:
'Guard zone that acquired this target (1 or 2). Omitted for manual acquisition.'
},
firstSeen: {
type: 'string',
format: 'date-time',
description: 'ISO 8601 timestamp when target was first seen'
},
lastSeen: {
type: 'string',
format: 'date-time',
description: 'ISO 8601 timestamp when target was last updated'
}
},
required: [
'id',
'status',
'position',
'acquisition',
'firstSeen',
'lastSeen'
]
},
AcquireTargetRequest: {
type: 'object',
properties: {
bearing: {
type: 'number',
description: 'Target bearing in radians [0, 2π)'
},
distance: {
type: 'number',
description: 'Target distance in meters'
}
},
required: ['bearing', 'distance']
},
AcquireTargetResponse: {
type: 'object',
properties: {
targetId: {
type: 'integer',
description: 'Assigned target ID (0 until confirmed by tracker)'
},
radarId: {
type: 'string',
description: 'Radar tracking this target'
}
},
required: ['targetId', 'radarId']
}
}
},
paths: {
'/': {
get: {
tags: ['Radars'],
summary: 'List all active radars',
description:
'Returns all radars detected on the network. Each entry includes WebSocket URLs for spoke data and control streams.',
responses: {
'200': {
description: 'Map of radar IDs to radar information',
content: {
'application/json': {
schema: {
type: 'object',
additionalProperties: {
$ref: '#/components/schemas/RadarInfo'
}
}
}
}
}
}
}
},
'/{radar_id}': {
get: {
tags: ['Radars'],
summary: 'Get radar information',
description: 'Returns static information about a radar.',
parameters: [radarIdParam],
responses: {
'200': {
description: 'Radar information',
content: {
'application/json': {
schema: { $ref: '#/components/schemas/RadarInfo' }
}
}
},
'404': { description: 'Radar not found' }
}
}
},
'/{radar_id}/capabilities': {
get: {
tags: ['Radars'],
summary: 'Get radar capabilities',
description:
'Returns static information about a radar including supported ranges, spoke resolution, Doppler support, and available controls.',
parameters: [radarIdParam],
responses: {
'200': {
description: 'Radar capabilities and control definitions',
content: {
'application/json': {
schema: { $ref: '#/components/schemas/Capabilities' }
}
}
},
'404': { description: 'Radar not found' }
}
}
},
'/{radar_id}/controls': {
get: {
tags: ['Controls'],
summary: 'Get all control values',
description:
'Returns current values for all controls of the specified radar.',
parameters: [radarIdParam],
responses: {
'200': {
description: 'All control values keyed by control name',
content: {
'application/json': {
schema: {
type: 'object',
additionalProperties: {
$ref: '#/components/schemas/ControlValue'
}
}
}
}
},
'404': { description: 'Radar not found' }
}
}
},
'/controls/{control_id}': {
get: {
tags: ['Controls'],
summary: 'Get a single control value',
description: 'Returns the current value of a specific radar control.',
parameters: [
radarIdParam,
{
name: 'control_id',
in: 'path',
required: true,
schema: { type: 'string' },
description: "Control identifier (e.g., 'gain', 'range', 'sea')",
example: 'gain'
}
],
responses: {
'200': {
description: 'Control value',
content: {
'application/json': {
schema: { $ref: '#/components/schemas/ControlValue' }
}
}
},
'404': { description: 'Control or radar not found' }
}
},
put: {
tags: ['Controls'],
summary: 'Set a control value',
description:
'Sets the value of a specific radar control. Request body varies by control type.',
parameters: [
radarIdParam,
{
name: 'control_id',
in: 'path',
required: true,
schema: { type: 'string' },
example: 'gain'
}
],
requestBody: {
content: {
'application/json': {
schema: { $ref: '#/components/schemas/ControlValue' }
}
}
},
responses: {
'200': { description: 'Control updated' },
'400': { description: 'Invalid value' },
'404': { description: 'Control or radar not found' }
}
}
},
'/{radar_id}/targets': {
get: {
tags: ['Targets'],
summary: 'Get tracked targets',
description:
'Returns all currently tracked ARPA/MARPA targets for this radar.',
parameters: [radarIdParam],
responses: {
'200': {
description: 'Array of tracked targets',
content: {
'application/json': {
schema: {
type: 'array',
items: { $ref: '#/components/schemas/ArpaTarget' }
}
}
}
},
'404': { description: 'Radar not found' },
'501': {
description: 'Provider does not support (M)ARPA target tracking'
}
}
},
post: {
tags: ['Targets'],
summary: 'Acquire target manually',
description:
'Manually acquire a target at the specified bearing and distance.',
parameters: [radarIdParam],
requestBody: {
content: {
'application/json': {
schema: { $ref: '#/components/schemas/AcquireTargetRequest' }
}
}
},
responses: {
'200': {
description: 'Target acquired',
content: {
'application/json': {
schema: { $ref: '#/components/schemas/AcquireTargetResponse' }
}
}
},
'400': { description: 'Invalid position' },
'404': { description: 'Radar not found' },
'501': {
description: 'Provider does not support (M)ARPA target tracking'
}
}
}
},
'/{radar_id}/targets/{target_id}': {
delete: {
tags: ['Targets'],
summary: 'Cancel target tracking',
description: 'Stop tracking the specified target.',
parameters: [
radarIdParam,
{
name: 'target_id',
in: 'path',
required: true,
schema: { type: 'integer' },
description: 'Target identifier',
example: 1
}
],
responses: {
'200': { description: 'Target tracking cancelled' },
'400': { description: 'Invalid target ID' },
'404': { description: 'Radar or target not found' },
'501': {
description: 'Provider does not support (M)ARPA target tracking'
}
}
}
}
}
}
export const radarApiRecord = {
name: 'radar',
path: '/signalk/v2/api/vessels/self/radars',
apiDoc: radarApiDoc as unknown as OpenApiDescription
}