@science-corporation/synapse 0.10.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/README.md +40 -18
  2. package/dist/api/api.d.ts +3186 -1788
  3. package/dist/api/api.js +9243 -6074
  4. package/dist/api/api.js.map +1 -1
  5. package/dist/api/proto.json +273 -77
  6. package/dist/api-science-device/api.d.ts +3 -0
  7. package/dist/api-science-device/api.d.ts.map +1 -0
  8. package/dist/api-science-device/api.js +3822 -0
  9. package/dist/api-science-device/api.js.map +1 -0
  10. package/dist/api-science-device/proto.json +258 -0
  11. package/dist/browser.d.ts +4 -0
  12. package/dist/browser.d.ts.map +1 -0
  13. package/dist/browser.js +22 -0
  14. package/dist/browser.js.map +1 -0
  15. package/dist/config.d.ts +5 -4
  16. package/dist/config.d.ts.map +1 -1
  17. package/dist/config.js +27 -17
  18. package/dist/config.js.map +1 -1
  19. package/dist/demo.js +48 -125
  20. package/dist/demo.js.map +1 -1
  21. package/dist/device.d.ts +20 -8
  22. package/dist/device.d.ts.map +1 -1
  23. package/dist/device.js +66 -23
  24. package/dist/device.js.map +1 -1
  25. package/dist/index.d.ts +4 -2
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +5 -3
  28. package/dist/index.js.map +1 -1
  29. package/dist/nodejs.d.ts +8 -0
  30. package/dist/nodejs.d.ts.map +1 -0
  31. package/dist/nodejs.js +32 -0
  32. package/dist/nodejs.js.map +1 -0
  33. package/dist/nodes/broadband_source.d.ts +11 -0
  34. package/dist/nodes/broadband_source.d.ts.map +1 -0
  35. package/dist/nodes/{optical_broadband.js → broadband_source.js} +9 -9
  36. package/dist/nodes/broadband_source.js.map +1 -0
  37. package/dist/nodes/disk_writer.d.ts +11 -0
  38. package/dist/nodes/disk_writer.d.ts.map +1 -0
  39. package/dist/nodes/{electrical_broadband.js → disk_writer.js} +9 -9
  40. package/dist/nodes/disk_writer.js.map +1 -0
  41. package/dist/nodes/index.d.ts +4 -2
  42. package/dist/nodes/index.d.ts.map +1 -1
  43. package/dist/nodes/index.js +7 -5
  44. package/dist/nodes/index.js.map +1 -1
  45. package/dist/nodes/spike_source.d.ts +11 -0
  46. package/dist/nodes/spike_source.d.ts.map +1 -0
  47. package/dist/nodes/spike_source.js +28 -0
  48. package/dist/nodes/spike_source.js.map +1 -0
  49. package/dist/nodes/stream_in.js +1 -1
  50. package/dist/nodes/stream_in.js.map +1 -1
  51. package/dist/nodes/stream_out.d.ts +2 -2
  52. package/dist/nodes/stream_out.d.ts.map +1 -1
  53. package/dist/nodes/stream_out.js +2 -2
  54. package/dist/nodes/stream_out.js.map +1 -1
  55. package/dist/science-device-api/api.d.ts +3 -0
  56. package/dist/science-device-api/api.d.ts.map +1 -0
  57. package/dist/science-device-api/api.js +3822 -0
  58. package/dist/science-device-api/api.js.map +1 -0
  59. package/dist/types/index.d.ts +3 -0
  60. package/dist/types/index.d.ts.map +1 -0
  61. package/dist/types/index.js +19 -0
  62. package/dist/types/index.js.map +1 -0
  63. package/dist/types.d.ts +5 -0
  64. package/dist/types.d.ts.map +1 -0
  65. package/dist/types.js +19 -0
  66. package/dist/types.js.map +1 -0
  67. package/dist/utils/client.d.ts +8 -1
  68. package/dist/utils/client.d.ts.map +1 -1
  69. package/dist/utils/client.js +30 -16
  70. package/dist/utils/client.js.map +1 -1
  71. package/dist/utils/device-management.d.ts +37 -0
  72. package/dist/utils/device-management.d.ts.map +1 -0
  73. package/dist/utils/device-management.js +126 -0
  74. package/dist/utils/device-management.js.map +1 -0
  75. package/dist/utils/discover.d.ts +3 -8
  76. package/dist/utils/discover.d.ts.map +1 -1
  77. package/dist/utils/discover.js +17 -32
  78. package/dist/utils/discover.js.map +1 -1
  79. package/dist/utils/enum.d.ts +1 -1
  80. package/dist/utils/enum.d.ts.map +1 -1
  81. package/dist/utils/enum.js.map +1 -1
  82. package/dist/utils/index.d.ts +1 -1
  83. package/dist/utils/index.d.ts.map +1 -1
  84. package/dist/utils/index.js +3 -0
  85. package/dist/utils/index.js.map +1 -1
  86. package/dist/utils/ndtp.d.ts +40 -0
  87. package/dist/utils/ndtp.d.ts.map +1 -0
  88. package/dist/utils/ndtp.js +140 -0
  89. package/dist/utils/ndtp.js.map +1 -0
  90. package/dist/utils/status.d.ts +28 -0
  91. package/dist/utils/status.d.ts.map +1 -0
  92. package/dist/utils/status.js +54 -0
  93. package/dist/utils/status.js.map +1 -0
  94. package/package.json +31 -5
  95. package/scripts/postinstall.sh +95 -0
  96. package/src/api/api.d.ts +3186 -1788
  97. package/src/api/api.js +9640 -6257
  98. package/src/api/proto.json +273 -77
  99. package/src/browser.ts +4 -0
  100. package/src/config.ts +33 -20
  101. package/src/demo.ts +44 -34
  102. package/src/device.ts +83 -36
  103. package/src/index.ts +5 -2
  104. package/src/nodes/broadband_source.ts +30 -0
  105. package/src/nodes/disk_writer.ts +30 -0
  106. package/src/nodes/index.ts +5 -2
  107. package/src/nodes/spike_source.ts +30 -0
  108. package/src/nodes/stream_in.ts +1 -1
  109. package/src/nodes/stream_out.ts +4 -4
  110. package/src/utils/client.ts +38 -13
  111. package/src/utils/discover.ts +25 -45
  112. package/src/utils/enum.ts +1 -1
  113. package/src/utils/index.ts +1 -1
  114. package/src/utils/status.ts +57 -0
  115. package/synapse-api/.github/workflows/proto-check.yaml +33 -0
  116. package/synapse-api/README.md +1 -1
  117. package/synapse-api/api/logging.proto +44 -0
  118. package/synapse-api/api/node.proto +9 -9
  119. package/synapse-api/api/nodes/broadband_source.proto +20 -0
  120. package/synapse-api/api/nodes/signal_config.proto +22 -0
  121. package/synapse-api/api/nodes/signal_status.proto +18 -0
  122. package/synapse-api/api/nodes/spectral_filter.proto +0 -1
  123. package/synapse-api/api/nodes/spike_source.proto +15 -0
  124. package/synapse-api/api/query.proto +19 -0
  125. package/synapse-api/api/synapse.proto +5 -2
  126. package/synapse-api/build.sh +17 -0
  127. package/dist/channel_mask.d.ts +0 -7
  128. package/dist/channel_mask.d.ts.map +0 -1
  129. package/dist/channel_mask.js +0 -14
  130. package/dist/channel_mask.js.map +0 -1
  131. package/dist/nodes/electrical_broadband.d.ts +0 -11
  132. package/dist/nodes/electrical_broadband.d.ts.map +0 -1
  133. package/dist/nodes/electrical_broadband.js.map +0 -1
  134. package/dist/nodes/optical_broadband.d.ts +0 -11
  135. package/dist/nodes/optical_broadband.d.ts.map +0 -1
  136. package/dist/nodes/optical_broadband.js.map +0 -1
  137. package/src/nodes/electrical_broadband.ts +0 -30
  138. package/src/nodes/optical_broadband.ts +0 -30
  139. package/synapse-api/api/nodes/electrical_broadband.proto +0 -19
  140. package/synapse-api/api/nodes/optical_broadband.proto +0 -11
@@ -2,19 +2,11 @@
2
2
  "nested": {
3
3
  "synapse": {
4
4
  "nested": {
5
- "SpectralFilterMethod": {
6
- "values": {
7
- "kSpectralFilterUnknown": 0,
8
- "kLowPass": 1,
9
- "kHighPass": 2,
10
- "kBandPass": 3,
11
- "kBandStop": 4
12
- }
13
- },
14
- "SpectralFilterConfig": {
5
+ "ElectrodeConfig": {
15
6
  "fields": {
16
- "method": {
17
- "type": "SpectralFilterMethod",
7
+ "channels": {
8
+ "rule": "repeated",
9
+ "type": "Channel",
18
10
  "id": 1
19
11
  },
20
12
  "lowCutoffHz": {
@@ -24,63 +16,108 @@
24
16
  "highCutoffHz": {
25
17
  "type": "float",
26
18
  "id": 3
27
- },
28
- "sampleRateHz": {
29
- "type": "float",
30
- "id": 4
31
19
  }
32
20
  }
33
21
  },
34
- "ElectricalStimulationConfig": {
22
+ "PixelConfig": {
35
23
  "fields": {
36
- "peripheralId": {
24
+ "pixelMask": {
25
+ "rule": "repeated",
37
26
  "type": "uint32",
38
27
  "id": 1
28
+ }
29
+ }
30
+ },
31
+ "SignalConfig": {
32
+ "oneofs": {
33
+ "signalType": {
34
+ "oneof": [
35
+ "electrode",
36
+ "pixel"
37
+ ]
38
+ }
39
+ },
40
+ "fields": {
41
+ "electrode": {
42
+ "type": "ElectrodeConfig",
43
+ "id": 1
39
44
  },
40
- "channels": {
41
- "rule": "repeated",
42
- "type": "Channel",
45
+ "pixel": {
46
+ "type": "PixelConfig",
43
47
  "id": 2
44
- },
45
- "bitWidth": {
48
+ }
49
+ }
50
+ },
51
+ "Channel": {
52
+ "fields": {
53
+ "id": {
46
54
  "type": "uint32",
47
- "id": 3
55
+ "id": 1
48
56
  },
49
- "sampleRate": {
57
+ "electrodeId": {
50
58
  "type": "uint32",
51
- "id": 4
59
+ "id": 2
52
60
  },
53
- "lsb": {
61
+ "referenceId": {
54
62
  "type": "uint32",
55
- "id": 5
63
+ "id": 3
56
64
  }
57
65
  }
58
66
  },
59
- "ElectricalStimulationStatus": {
67
+ "SpectralFilterMethod": {
68
+ "values": {
69
+ "kSpectralFilterUnknown": 0,
70
+ "kLowPass": 1,
71
+ "kHighPass": 2,
72
+ "kBandPass": 3,
73
+ "kBandStop": 4
74
+ }
75
+ },
76
+ "SpectralFilterConfig": {
60
77
  "fields": {
61
- "lsbUV": {
62
- "type": "float",
78
+ "method": {
79
+ "type": "SpectralFilterMethod",
63
80
  "id": 1
81
+ },
82
+ "lowCutoffHz": {
83
+ "type": "float",
84
+ "id": 2
85
+ },
86
+ "highCutoffHz": {
87
+ "type": "float",
88
+ "id": 3
64
89
  }
65
90
  }
66
91
  },
67
- "Channel": {
92
+ "SpikeSourceConfig": {
68
93
  "fields": {
69
- "id": {
94
+ "peripheralId": {
70
95
  "type": "uint32",
71
96
  "id": 1
72
97
  },
73
- "electrodeId": {
98
+ "sampleRateHz": {
74
99
  "type": "uint32",
75
100
  "id": 2
76
101
  },
77
- "referenceId": {
78
- "type": "uint32",
102
+ "spikeWindowMs": {
103
+ "type": "float",
79
104
  "id": 3
105
+ },
106
+ "gain": {
107
+ "type": "float",
108
+ "id": 4
109
+ },
110
+ "thresholdUV": {
111
+ "type": "float",
112
+ "id": 5
113
+ },
114
+ "electrodes": {
115
+ "type": "ElectrodeConfig",
116
+ "id": 6
80
117
  }
81
118
  }
82
119
  },
83
- "ElectricalBroadbandConfig": {
120
+ "ElectricalStimulationConfig": {
84
121
  "fields": {
85
122
  "peripheralId": {
86
123
  "type": "uint32",
@@ -99,21 +136,13 @@
99
136
  "type": "uint32",
100
137
  "id": 4
101
138
  },
102
- "gain": {
103
- "type": "float",
139
+ "lsb": {
140
+ "type": "uint32",
104
141
  "id": 5
105
- },
106
- "lowCutoffHz": {
107
- "type": "float",
108
- "id": 6
109
- },
110
- "highCutoffHz": {
111
- "type": "float",
112
- "id": 7
113
142
  }
114
143
  }
115
144
  },
116
- "ElectricalBroadbandStatus": {
145
+ "ElectricalStimulationStatus": {
117
146
  "fields": {
118
147
  "lsbUV": {
119
148
  "type": "float",
@@ -214,31 +243,69 @@
214
243
  }
215
244
  }
216
245
  },
217
- "OpticalBroadbandConfig": {
246
+ "ElectrodeStatus": {
247
+ "fields": {
248
+ "lsbUV": {
249
+ "type": "float",
250
+ "id": 1
251
+ }
252
+ }
253
+ },
254
+ "PixelStatus": {
255
+ "fields": {}
256
+ },
257
+ "SignalStatus": {
258
+ "oneofs": {
259
+ "signalType": {
260
+ "oneof": [
261
+ "electrode",
262
+ "pixel"
263
+ ]
264
+ }
265
+ },
266
+ "fields": {
267
+ "electrode": {
268
+ "type": "ElectrodeStatus",
269
+ "id": 1
270
+ },
271
+ "pixel": {
272
+ "type": "PixelStatus",
273
+ "id": 2
274
+ }
275
+ }
276
+ },
277
+ "BroadbandSourceConfig": {
218
278
  "fields": {
219
279
  "peripheralId": {
220
280
  "type": "uint32",
221
281
  "id": 1
222
282
  },
223
- "pixelMask": {
224
- "rule": "repeated",
283
+ "bitWidth": {
225
284
  "type": "uint32",
226
285
  "id": 2
227
286
  },
228
- "bitWidth": {
287
+ "sampleRateHz": {
229
288
  "type": "uint32",
230
289
  "id": 3
231
290
  },
232
- "frameRate": {
233
- "type": "uint32",
291
+ "gain": {
292
+ "type": "float",
234
293
  "id": 4
235
294
  },
236
- "gain": {
237
- "type": "uint32",
295
+ "signal": {
296
+ "type": "SignalConfig",
238
297
  "id": 5
239
298
  }
240
299
  }
241
300
  },
301
+ "BroadbandSourceStatus": {
302
+ "fields": {
303
+ "status": {
304
+ "type": "SignalStatus",
305
+ "id": 1
306
+ }
307
+ }
308
+ },
242
309
  "OpticalStimulationConfig": {
243
310
  "fields": {
244
311
  "peripheralId": {
@@ -291,10 +358,10 @@
291
358
  "Type": {
292
359
  "values": {
293
360
  "kUnknown": 0,
294
- "kElectricalRecord": 1,
361
+ "kBroadbandSource": 1,
295
362
  "kElectricalStimulation": 2,
296
363
  "kOpticalStimulation": 3,
297
- "kOpticalRecord": 4
364
+ "kSpikeSource": 4
298
365
  }
299
366
  }
300
367
  }
@@ -384,6 +451,15 @@
384
451
  "DeleteFile": {
385
452
  "requestType": "DeleteFileRequest",
386
453
  "responseType": "DeleteFileResponse"
454
+ },
455
+ "GetLogs": {
456
+ "requestType": "LogQueryRequest",
457
+ "responseType": "LogQueryResponse"
458
+ },
459
+ "TailLogs": {
460
+ "requestType": "TailLogsRequest",
461
+ "responseType": "LogEntry",
462
+ "responseStream": true
387
463
  }
388
464
  }
389
465
  },
@@ -392,11 +468,11 @@
392
468
  "kNodeTypeUnknown": 0,
393
469
  "kStreamIn": 1,
394
470
  "kStreamOut": 2,
395
- "kElectricalBroadband": 3,
471
+ "kBroadbandSource": 3,
396
472
  "kElectricalStimulation": 4,
397
- "kOpticalBroadband": 5,
398
- "kOpticalStimulation": 6,
399
- "kSpikeDetect": 7,
473
+ "kOpticalStimulation": 5,
474
+ "kSpikeDetect": 6,
475
+ "kSpikeSource": 7,
400
476
  "kSpectralFilter": 8,
401
477
  "kDiskWriter": 9
402
478
  }
@@ -407,13 +483,13 @@
407
483
  "oneof": [
408
484
  "streamOut",
409
485
  "streamIn",
410
- "electricalBroadband",
486
+ "broadbandSource",
411
487
  "electricalStimulation",
412
- "opticalBroadband",
413
488
  "opticalStimulation",
414
489
  "spikeDetect",
415
490
  "spectralFilter",
416
- "diskWriter"
491
+ "diskWriter",
492
+ "spikeSource"
417
493
  ]
418
494
  }
419
495
  },
@@ -434,18 +510,14 @@
434
510
  "type": "StreamInConfig",
435
511
  "id": 4
436
512
  },
437
- "electricalBroadband": {
438
- "type": "ElectricalBroadbandConfig",
513
+ "broadbandSource": {
514
+ "type": "BroadbandSourceConfig",
439
515
  "id": 5
440
516
  },
441
517
  "electricalStimulation": {
442
518
  "type": "ElectricalStimulationConfig",
443
519
  "id": 6
444
520
  },
445
- "opticalBroadband": {
446
- "type": "OpticalBroadbandConfig",
447
- "id": 7
448
- },
449
521
  "opticalStimulation": {
450
522
  "type": "OpticalStimulationConfig",
451
523
  "id": 8
@@ -461,6 +533,10 @@
461
533
  "diskWriter": {
462
534
  "type": "DiskWriterConfig",
463
535
  "id": 11
536
+ },
537
+ "spikeSource": {
538
+ "type": "SpikeSourceConfig",
539
+ "id": 12
464
540
  }
465
541
  }
466
542
  },
@@ -469,7 +545,7 @@
469
545
  "status": {
470
546
  "oneof": [
471
547
  "streamOut",
472
- "electricalBroadband",
548
+ "broadbandSource",
473
549
  "streamIn",
474
550
  "electricalStimulation"
475
551
  ]
@@ -488,8 +564,8 @@
488
564
  "type": "StreamOutStatus",
489
565
  "id": 3
490
566
  },
491
- "electricalBroadband": {
492
- "type": "ElectricalBroadbandStatus",
567
+ "broadbandSource": {
568
+ "type": "BroadbandSourceStatus",
493
569
  "id": 4
494
570
  },
495
571
  "streamIn": {
@@ -565,6 +641,14 @@
565
641
  }
566
642
  }
567
643
  },
644
+ "SelfTestQuery": {
645
+ "fields": {
646
+ "peripheralId": {
647
+ "type": "uint32",
648
+ "id": 1
649
+ }
650
+ }
651
+ },
568
652
  "ImpedanceMeasurement": {
569
653
  "fields": {
570
654
  "electrodeId": {
@@ -590,12 +674,47 @@
590
674
  }
591
675
  }
592
676
  },
677
+ "SelfTestItem": {
678
+ "fields": {
679
+ "testName": {
680
+ "type": "string",
681
+ "id": 1
682
+ },
683
+ "passed": {
684
+ "type": "bool",
685
+ "id": 2
686
+ },
687
+ "testData": {
688
+ "rule": "repeated",
689
+ "type": "uint32",
690
+ "id": 3
691
+ },
692
+ "testReport": {
693
+ "type": "string",
694
+ "id": 4
695
+ }
696
+ }
697
+ },
698
+ "SelfTestResponse": {
699
+ "fields": {
700
+ "allPassed": {
701
+ "type": "bool",
702
+ "id": 1
703
+ },
704
+ "tests": {
705
+ "rule": "repeated",
706
+ "type": "SelfTestItem",
707
+ "id": 2
708
+ }
709
+ }
710
+ },
593
711
  "QueryRequest": {
594
712
  "oneofs": {
595
713
  "query": {
596
714
  "oneof": [
597
715
  "impedanceQuery",
598
- "sampleQuery"
716
+ "sampleQuery",
717
+ "selfTestQuery"
599
718
  ]
600
719
  }
601
720
  },
@@ -611,6 +730,10 @@
611
730
  "sampleQuery": {
612
731
  "type": "SampleQuery",
613
732
  "id": 3
733
+ },
734
+ "selfTestQuery": {
735
+ "type": "SelfTestQuery",
736
+ "id": 4
614
737
  }
615
738
  },
616
739
  "nested": {
@@ -618,7 +741,8 @@
618
741
  "values": {
619
742
  "kNone": 0,
620
743
  "kImpedance": 1,
621
- "kSample": 2
744
+ "kSample": 2,
745
+ "kSelfTest": 3
622
746
  }
623
747
  }
624
748
  }
@@ -627,7 +751,8 @@
627
751
  "oneofs": {
628
752
  "response": {
629
753
  "oneof": [
630
- "impedanceResponse"
754
+ "impedanceResponse",
755
+ "selfTestResponse"
631
756
  ]
632
757
  }
633
758
  },
@@ -644,6 +769,10 @@
644
769
  "impedanceResponse": {
645
770
  "type": "ImpedanceResponse",
646
771
  "id": 3
772
+ },
773
+ "selfTestResponse": {
774
+ "type": "SelfTestResponse",
775
+ "id": 4
647
776
  }
648
777
  }
649
778
  },
@@ -840,6 +969,73 @@
840
969
  "id": 2
841
970
  }
842
971
  }
972
+ },
973
+ "LogLevel": {
974
+ "values": {
975
+ "LOG_LEVEL_UNKNOWN": 0,
976
+ "LOG_LEVEL_DEBUG": 1,
977
+ "LOG_LEVEL_INFO": 2,
978
+ "LOG_LEVEL_WARNING": 3,
979
+ "LOG_LEVEL_ERROR": 4,
980
+ "LOG_LEVEL_CRITICAL": 5
981
+ }
982
+ },
983
+ "LogEntry": {
984
+ "fields": {
985
+ "timestampNs": {
986
+ "type": "uint64",
987
+ "id": 1
988
+ },
989
+ "level": {
990
+ "type": "LogLevel",
991
+ "id": 2
992
+ },
993
+ "source": {
994
+ "type": "string",
995
+ "id": 3
996
+ },
997
+ "message": {
998
+ "type": "string",
999
+ "id": 4
1000
+ }
1001
+ }
1002
+ },
1003
+ "LogQueryRequest": {
1004
+ "fields": {
1005
+ "startTimeNs": {
1006
+ "type": "uint64",
1007
+ "id": 1
1008
+ },
1009
+ "endTimeNs": {
1010
+ "type": "uint64",
1011
+ "id": 2
1012
+ },
1013
+ "sinceMs": {
1014
+ "type": "uint64",
1015
+ "id": 3
1016
+ },
1017
+ "minLevel": {
1018
+ "type": "LogLevel",
1019
+ "id": 4
1020
+ }
1021
+ }
1022
+ },
1023
+ "LogQueryResponse": {
1024
+ "fields": {
1025
+ "entries": {
1026
+ "rule": "repeated",
1027
+ "type": "LogEntry",
1028
+ "id": 1
1029
+ }
1030
+ }
1031
+ },
1032
+ "TailLogsRequest": {
1033
+ "fields": {
1034
+ "minLevel": {
1035
+ "type": "LogLevel",
1036
+ "id": 1
1037
+ }
1038
+ }
843
1039
  }
844
1040
  }
845
1041
  },
package/src/browser.ts ADDED
@@ -0,0 +1,4 @@
1
+ // Browser-safe exports (types and enums only)
2
+ export type { CallOptions } from "./utils/client";
3
+ export { IStatus, Status, StatusCode } from "./utils/status";
4
+ export * from "./api/api";
package/src/config.ts CHANGED
@@ -1,19 +1,22 @@
1
1
  import Node from "./node";
2
2
  import { synapse } from "./api/api";
3
- import ElectricalBroadband from "./nodes/electrical_broadband";
3
+ import BroadbandSource from "./nodes/broadband_source";
4
+ import DiskWriter from "./nodes/disk_writer";
4
5
  import ElectricalStimulation from "./nodes/electrical_stimulation";
5
- import OpticalBroadband from "./nodes/optical_broadband";
6
6
  import OpticalStimulation from "./nodes/optical_stimulation";
7
7
  import SpectralFilter from "./nodes/spectral_filter";
8
8
  import SpikeDetect from "./nodes/spike_detect";
9
+ import SpikeSource from "./nodes/spike_source";
9
10
  import StreamIn from "./nodes/stream_in";
10
11
  import StreamOut from "./nodes/stream_out";
12
+ import { Status, StatusCode } from "./utils/status";
11
13
 
12
14
  type Connection = [number, number];
13
15
  const kNodeTypeObjectMap = {
14
- [synapse.NodeType.kElectricalBroadband]: ElectricalBroadband,
16
+ [synapse.NodeType.kBroadbandSource]: BroadbandSource,
17
+ [synapse.NodeType.kDiskWriter]: DiskWriter,
15
18
  [synapse.NodeType.kElectricalStimulation]: ElectricalStimulation,
16
- [synapse.NodeType.kOpticalBroadband]: OpticalBroadband,
19
+ [synapse.NodeType.kSpikeSource]: SpikeSource,
17
20
  [synapse.NodeType.kOpticalStimulation]: OpticalStimulation,
18
21
  [synapse.NodeType.kSpectralFilter]: SpectralFilter,
19
22
  [synapse.NodeType.kSpikeDetect]: SpikeDetect,
@@ -29,37 +32,47 @@ class Config {
29
32
  return this.nodes.length + 1;
30
33
  }
31
34
 
32
- add(nodes: Node[]) {
35
+ add(nodes: Node[]): Status {
33
36
  for (const node of nodes) {
34
- if (!this.addNode(node)) {
35
- return false;
37
+ const status = this.addNode(node);
38
+ if (!status.ok()) {
39
+ return status;
36
40
  }
37
41
  }
38
- return true;
42
+ return new Status();
39
43
  }
40
44
 
41
- connect(fromNode: Node, toNode: Node): boolean {
42
- if (fromNode.id === null || toNode.id === null) {
43
- return false;
45
+ connect(fromNode: Node, toNode: Node): Status {
46
+ if (!fromNode.id || !toNode.id) {
47
+ return new Status(StatusCode.INVALID_ARGUMENT, "source and destination nodes must have ids");
44
48
  }
45
49
  this.connections.push([fromNode.id, toNode.id]);
46
- return true;
50
+ return new Status();
47
51
  }
48
52
 
49
- addNode(node: Node): boolean {
50
- if (!!node.id) {
51
- return false;
53
+ addNode(node: Node, id?: number): Status {
54
+ if (node.id) {
55
+ return new Status(StatusCode.INVALID_ARGUMENT, "node must not have an id");
52
56
  }
53
- node.id = this._genNodeId();
57
+
58
+ if (id === undefined) {
59
+ id = this._genNodeId();
60
+ }
61
+
62
+ if (this.nodes.find((n) => n.id === id)) {
63
+ return new Status(StatusCode.INVALID_ARGUMENT, "node id must be unique");
64
+ }
65
+
66
+ node.id = id;
54
67
  this.nodes.push(node);
55
- return true;
68
+ return new Status();
56
69
  }
57
70
 
58
- setDevice(device): boolean {
71
+ setDevice(device): Status {
59
72
  for (const node of this.nodes) {
60
73
  node.device = device;
61
74
  }
62
- return true;
75
+ return new Status();
63
76
  }
64
77
 
65
78
  static fromProto(proto: synapse.IDeviceConfiguration): Config {
@@ -74,7 +87,7 @@ class Config {
74
87
  }
75
88
 
76
89
  const node = NodeType.fromProto(nodeProto);
77
- if (!!nodeProto.id) {
90
+ if (nodeProto.id) {
78
91
  node.id = nodeProto.id;
79
92
  config.nodes.push(node);
80
93
  } else {