@science-corporation/synapse 0.9.0 → 0.10.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.
@@ -24,6 +24,10 @@
24
24
  "highCutoffHz": {
25
25
  "type": "float",
26
26
  "id": 3
27
+ },
28
+ "sampleRateHz": {
29
+ "type": "float",
30
+ "id": 4
27
31
  }
28
32
  }
29
33
  },
@@ -52,6 +56,14 @@
52
56
  }
53
57
  }
54
58
  },
59
+ "ElectricalStimulationStatus": {
60
+ "fields": {
61
+ "lsbUV": {
62
+ "type": "float",
63
+ "id": 1
64
+ }
65
+ }
66
+ },
55
67
  "Channel": {
56
68
  "fields": {
57
69
  "id": {
@@ -101,6 +113,14 @@
101
113
  }
102
114
  }
103
115
  },
116
+ "ElectricalBroadbandStatus": {
117
+ "fields": {
118
+ "lsbUV": {
119
+ "type": "float",
120
+ "id": 1
121
+ }
122
+ }
123
+ },
104
124
  "SpikeDetectConfig": {
105
125
  "fields": {
106
126
  "mode": {
@@ -140,6 +160,19 @@
140
160
  "dataType": {
141
161
  "type": "DataType",
142
162
  "id": 1
163
+ },
164
+ "shape": {
165
+ "rule": "repeated",
166
+ "type": "uint32",
167
+ "id": 2
168
+ }
169
+ }
170
+ },
171
+ "StreamInStatus": {
172
+ "fields": {
173
+ "throughputMbps": {
174
+ "type": "float",
175
+ "id": 1
143
176
  }
144
177
  }
145
178
  },
@@ -153,6 +186,14 @@
153
186
  "kImage": 5
154
187
  }
155
188
  },
189
+ "DiskWriterConfig": {
190
+ "fields": {
191
+ "filename": {
192
+ "type": "string",
193
+ "id": 1
194
+ }
195
+ }
196
+ },
156
197
  "StreamOutConfig": {
157
198
  "fields": {
158
199
  "label": {
@@ -165,6 +206,14 @@
165
206
  }
166
207
  }
167
208
  },
209
+ "StreamOutStatus": {
210
+ "fields": {
211
+ "throughputMbps": {
212
+ "type": "float",
213
+ "id": 1
214
+ }
215
+ }
216
+ },
168
217
  "OpticalBroadbandConfig": {
169
218
  "fields": {
170
219
  "peripheralId": {
@@ -232,6 +281,10 @@
232
281
  "type": {
233
282
  "type": "Type",
234
283
  "id": 4
284
+ },
285
+ "address": {
286
+ "type": "string",
287
+ "id": 5
235
288
  }
236
289
  },
237
290
  "nested": {
@@ -344,7 +397,8 @@
344
397
  "kOpticalBroadband": 5,
345
398
  "kOpticalStimulation": 6,
346
399
  "kSpikeDetect": 7,
347
- "kSpectralFilter": 8
400
+ "kSpectralFilter": 8,
401
+ "kDiskWriter": 9
348
402
  }
349
403
  },
350
404
  "NodeConfig": {
@@ -358,7 +412,8 @@
358
412
  "opticalBroadband",
359
413
  "opticalStimulation",
360
414
  "spikeDetect",
361
- "spectralFilter"
415
+ "spectralFilter",
416
+ "diskWriter"
362
417
  ]
363
418
  }
364
419
  },
@@ -402,6 +457,48 @@
402
457
  "spectralFilter": {
403
458
  "type": "SpectralFilterConfig",
404
459
  "id": 10
460
+ },
461
+ "diskWriter": {
462
+ "type": "DiskWriterConfig",
463
+ "id": 11
464
+ }
465
+ }
466
+ },
467
+ "NodeStatus": {
468
+ "oneofs": {
469
+ "status": {
470
+ "oneof": [
471
+ "streamOut",
472
+ "electricalBroadband",
473
+ "streamIn",
474
+ "electricalStimulation"
475
+ ]
476
+ }
477
+ },
478
+ "fields": {
479
+ "type": {
480
+ "type": "NodeType",
481
+ "id": 1
482
+ },
483
+ "id": {
484
+ "type": "uint32",
485
+ "id": 2
486
+ },
487
+ "streamOut": {
488
+ "type": "StreamOutStatus",
489
+ "id": 3
490
+ },
491
+ "electricalBroadband": {
492
+ "type": "ElectricalBroadbandStatus",
493
+ "id": 4
494
+ },
495
+ "streamIn": {
496
+ "type": "StreamInStatus",
497
+ "id": 5
498
+ },
499
+ "electricalStimulation": {
500
+ "type": "ElectricalStimulationStatus",
501
+ "id": 6
405
502
  }
406
503
  }
407
504
  },
@@ -558,7 +655,8 @@
558
655
  "kFailedPrecondition": 3,
559
656
  "kUnimplemented": 4,
560
657
  "kInternalError": 5,
561
- "kPermissionDenied": 6
658
+ "kPermissionDenied": 6,
659
+ "kQueryFailed": 7
562
660
  }
563
661
  },
564
662
  "DeviceState": {
@@ -594,6 +692,15 @@
594
692
  }
595
693
  }
596
694
  },
695
+ "SignalChainStatus": {
696
+ "fields": {
697
+ "nodes": {
698
+ "rule": "repeated",
699
+ "type": "NodeStatus",
700
+ "id": 1
701
+ }
702
+ }
703
+ },
597
704
  "Status": {
598
705
  "fields": {
599
706
  "message": {
@@ -620,6 +727,10 @@
620
727
  "storage": {
621
728
  "type": "DeviceStorage",
622
729
  "id": 6
730
+ },
731
+ "signalChain": {
732
+ "type": "SignalChainStatus",
733
+ "id": 7
623
734
  }
624
735
  }
625
736
  },
package/src/device.ts CHANGED
@@ -5,6 +5,10 @@ import Config from "./config";
5
5
  import { create } from "./utils/client";
6
6
  import { getName } from "./utils/enum";
7
7
 
8
+ export interface CallOptions {
9
+ deadline?: Date;
10
+ }
11
+
8
12
  class Device {
9
13
  rpc: any | null = null;
10
14
  channel: Channel | null = null;
@@ -17,12 +21,11 @@ class Device {
17
21
  }
18
22
  }
19
23
 
20
- async configure(config: Config): Promise<boolean> {
24
+ async configure(config: Config, options: CallOptions = {}): Promise<boolean> {
21
25
  return new Promise((resolve, reject) => {
22
26
  config.setDevice(this);
23
-
24
27
  const proto = config.toProto();
25
- this.rpc.configure(proto, (err, res) => {
28
+ this.rpc.configure(proto, options, (err, res) => {
26
29
  if (err) {
27
30
  reject(err);
28
31
  } else {
@@ -36,21 +39,25 @@ class Device {
36
39
  });
37
40
  }
38
41
 
39
- async info(): Promise<synapse.DeviceInfo> {
42
+ async info(options: CallOptions = {}): Promise<synapse.DeviceInfo> {
40
43
  return new Promise((resolve, reject) => {
41
- this.rpc.info({}, (err, res) => {
44
+ this.rpc.info({}, options, (err, res) => {
42
45
  if (err) {
43
46
  reject(err);
44
47
  } else {
45
- resolve(res!);
48
+ if (this._handleStatusResponse(res.status)) {
49
+ resolve(res!);
50
+ } else {
51
+ reject(`Error starting device: (code: ${getName(synapse.StatusCode, res.code)}) ${res.message}`);
52
+ }
46
53
  }
47
54
  });
48
55
  });
49
56
  }
50
57
 
51
- async start(): Promise<boolean> {
58
+ async start(options: CallOptions = {}): Promise<boolean> {
52
59
  return new Promise((resolve, reject) => {
53
- this.rpc.start({}, (err, res) => {
60
+ this.rpc.start({}, options, (err, res) => {
54
61
  if (err) {
55
62
  reject(err);
56
63
  } else {
@@ -64,9 +71,9 @@ class Device {
64
71
  });
65
72
  }
66
73
 
67
- async stop(): Promise<boolean> {
74
+ async stop(options: CallOptions = {}): Promise<boolean> {
68
75
  return new Promise((resolve, reject) => {
69
- this.rpc.stop({}, (err, res) => {
76
+ this.rpc.stop({}, options, (err, res) => {
70
77
  if (err) {
71
78
  reject(err);
72
79
  } else {
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { default as Config } from "./config";
2
- export { default as Device } from "./device";
2
+ export { default as Device, CallOptions } from "./device";
3
3
  export * from "./nodes";
4
4
  export { synapse } from "./api/api";
@@ -3,11 +3,6 @@ import dgram from "dgram";
3
3
  import { synapse } from "../api/api";
4
4
  import Node from "../node";
5
5
 
6
- export interface StreamInArgs {
7
- dataType: synapse.DataType;
8
- shape?: number[];
9
- }
10
-
11
6
  class StreamIn extends Node {
12
7
  type = synapse.NodeType.kStreamIn;
13
8
  config: synapse.IStreamInConfig;
@@ -0,0 +1 @@
1
+ Copyright 2024 Science Corporation. All rights reserved.
@@ -11,6 +11,7 @@ import "api/nodes/spike_detect.proto";
11
11
  import "api/nodes/spectral_filter.proto";
12
12
  import "api/nodes/stream_out.proto";
13
13
  import "api/nodes/stream_in.proto";
14
+ import "api/nodes/disk_writer.proto";
14
15
 
15
16
  enum NodeType {
16
17
  kNodeTypeUnknown = 0;
@@ -22,6 +23,7 @@ enum NodeType {
22
23
  kOpticalStimulation = 6;
23
24
  kSpikeDetect = 7;
24
25
  kSpectralFilter = 8;
26
+ kDiskWriter = 9;
25
27
  }
26
28
 
27
29
  message NodeConfig {
@@ -36,6 +38,18 @@ message NodeConfig {
36
38
  OpticalStimulationConfig optical_stimulation = 8;
37
39
  SpikeDetectConfig spike_detect = 9;
38
40
  SpectralFilterConfig spectral_filter = 10;
41
+ DiskWriterConfig disk_writer = 11;
42
+ }
43
+ }
44
+
45
+ message NodeStatus {
46
+ NodeType type = 1;
47
+ uint32 id = 2;
48
+ oneof status {
49
+ StreamOutStatus stream_out = 3;
50
+ ElectricalBroadbandStatus electrical_broadband = 4;
51
+ StreamInStatus stream_in = 5;
52
+ ElectricalStimulationStatus electrical_stimulation = 6;
39
53
  }
40
54
  }
41
55
 
@@ -0,0 +1,7 @@
1
+ syntax = "proto3";
2
+
3
+ package synapse;
4
+
5
+ message DiskWriterConfig {
6
+ string filename = 1;
7
+ }
@@ -13,3 +13,7 @@ message ElectricalBroadbandConfig {
13
13
  float low_cutoff_hz = 6;
14
14
  float high_cutoff_hz = 7;
15
15
  }
16
+
17
+ message ElectricalBroadbandStatus {
18
+ float lsb_uV = 1;
19
+ }
@@ -11,3 +11,7 @@ message ElectricalStimulationConfig {
11
11
  uint32 sample_rate = 4;
12
12
  uint32 lsb = 5;
13
13
  }
14
+
15
+ message ElectricalStimulationStatus {
16
+ float lsb_uV = 1;
17
+ }
@@ -14,4 +14,5 @@ message SpectralFilterConfig {
14
14
  SpectralFilterMethod method = 1;
15
15
  float low_cutoff_hz = 2;
16
16
  float high_cutoff_hz = 3;
17
+ float sample_rate_hz = 4;
17
18
  }
@@ -6,4 +6,9 @@ package synapse;
6
6
 
7
7
  message StreamInConfig {
8
8
  DataType data_type = 1;
9
+ repeated uint32 shape = 2;
9
10
  }
11
+
12
+ message StreamInStatus {
13
+ float throughput_mbps = 1;
14
+ }
@@ -6,3 +6,7 @@ message StreamOutConfig {
6
6
  string label = 1;
7
7
  string multicast_group = 2;
8
8
  }
9
+
10
+ message StreamOutStatus {
11
+ float throughput_mbps = 1;
12
+ }
@@ -12,6 +12,7 @@ enum StatusCode {
12
12
  kUnimplemented = 4;
13
13
  kInternalError = 5;
14
14
  kPermissionDenied = 6;
15
+ kQueryFailed = 7;
15
16
  }
16
17
 
17
18
  enum DeviceState {
@@ -32,6 +33,10 @@ message DevicePower {
32
33
  bool is_charging = 2;
33
34
  }
34
35
 
36
+ message SignalChainStatus {
37
+ repeated NodeStatus nodes = 1;
38
+ }
39
+
35
40
  message Status {
36
41
  string message = 1;
37
42
  StatusCode code = 2;
@@ -39,4 +44,5 @@ message Status {
39
44
  repeated NodeSocket sockets = 4;
40
45
  DevicePower power = 5;
41
46
  DeviceStorage storage = 6;
47
+ SignalChainStatus signal_chain = 7;
42
48
  }
@@ -20,6 +20,7 @@ message Peripheral {
20
20
  string vendor = 2;
21
21
  uint32 peripheral_id = 3;
22
22
  Type type = 4;
23
+ string address = 5;
23
24
  }
24
25
 
25
26
  message DeviceInfo {