@science-corporation/synapse 0.9.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 (123) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +57 -0
  3. package/dist/api/api.d.ts +3973 -0
  4. package/dist/api/api.d.ts.map +1 -0
  5. package/dist/api/api.js +9368 -0
  6. package/dist/api/api.js.map +1 -0
  7. package/dist/api/proto.json +747 -0
  8. package/dist/channel_mask.d.ts +7 -0
  9. package/dist/channel_mask.d.ts.map +1 -0
  10. package/dist/channel_mask.js +14 -0
  11. package/dist/channel_mask.js.map +1 -0
  12. package/dist/config.d.ts +16 -0
  13. package/dist/config.d.ts.map +1 -0
  14. package/dist/config.js +103 -0
  15. package/dist/config.js.map +1 -0
  16. package/dist/demo.d.ts +2 -0
  17. package/dist/demo.d.ts.map +1 -0
  18. package/dist/demo.js +269 -0
  19. package/dist/demo.js.map +1 -0
  20. package/dist/device.d.ts +17 -0
  21. package/dist/device.d.ts.map +1 -0
  22. package/dist/device.js +112 -0
  23. package/dist/device.js.map +1 -0
  24. package/dist/index.d.ts +5 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/index.js +28 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/node.d.ts +10 -0
  29. package/dist/node.d.ts.map +1 -0
  30. package/dist/node.js +14 -0
  31. package/dist/node.js.map +1 -0
  32. package/dist/nodes/electrical_broadband.d.ts +11 -0
  33. package/dist/nodes/electrical_broadband.d.ts.map +1 -0
  34. package/dist/nodes/electrical_broadband.js +28 -0
  35. package/dist/nodes/electrical_broadband.js.map +1 -0
  36. package/dist/nodes/electrical_stimulation.d.ts +11 -0
  37. package/dist/nodes/electrical_stimulation.d.ts.map +1 -0
  38. package/dist/nodes/electrical_stimulation.js +28 -0
  39. package/dist/nodes/electrical_stimulation.js.map +1 -0
  40. package/dist/nodes/index.d.ts +9 -0
  41. package/dist/nodes/index.d.ts.map +1 -0
  42. package/dist/nodes/index.js +23 -0
  43. package/dist/nodes/index.js.map +1 -0
  44. package/dist/nodes/optical_broadband.d.ts +11 -0
  45. package/dist/nodes/optical_broadband.d.ts.map +1 -0
  46. package/dist/nodes/optical_broadband.js +28 -0
  47. package/dist/nodes/optical_broadband.js.map +1 -0
  48. package/dist/nodes/optical_stimulation.d.ts +11 -0
  49. package/dist/nodes/optical_stimulation.d.ts.map +1 -0
  50. package/dist/nodes/optical_stimulation.js +28 -0
  51. package/dist/nodes/optical_stimulation.js.map +1 -0
  52. package/dist/nodes/spectral_filter.d.ts +11 -0
  53. package/dist/nodes/spectral_filter.d.ts.map +1 -0
  54. package/dist/nodes/spectral_filter.js +28 -0
  55. package/dist/nodes/spectral_filter.js.map +1 -0
  56. package/dist/nodes/spike_detect.d.ts +11 -0
  57. package/dist/nodes/spike_detect.d.ts.map +1 -0
  58. package/dist/nodes/spike_detect.js +28 -0
  59. package/dist/nodes/spike_detect.js.map +1 -0
  60. package/dist/nodes/stream_in.d.ts +19 -0
  61. package/dist/nodes/stream_in.d.ts.map +1 -0
  62. package/dist/nodes/stream_in.js +66 -0
  63. package/dist/nodes/stream_in.js.map +1 -0
  64. package/dist/nodes/stream_out.d.ts +16 -0
  65. package/dist/nodes/stream_out.d.ts.map +1 -0
  66. package/dist/nodes/stream_out.js +87 -0
  67. package/dist/nodes/stream_out.js.map +1 -0
  68. package/dist/utils/client.d.ts +3 -0
  69. package/dist/utils/client.d.ts.map +1 -0
  70. package/dist/utils/client.js +25 -0
  71. package/dist/utils/client.js.map +1 -0
  72. package/dist/utils/discover.d.ts +15 -0
  73. package/dist/utils/discover.d.ts.map +1 -0
  74. package/dist/utils/discover.js +64 -0
  75. package/dist/utils/discover.js.map +1 -0
  76. package/dist/utils/enum.d.ts +2 -0
  77. package/dist/utils/enum.d.ts.map +1 -0
  78. package/dist/utils/enum.js +13 -0
  79. package/dist/utils/enum.js.map +1 -0
  80. package/dist/utils/index.d.ts +2 -0
  81. package/dist/utils/index.d.ts.map +1 -0
  82. package/dist/utils/index.js +3 -0
  83. package/dist/utils/index.js.map +1 -0
  84. package/package.json +42 -0
  85. package/scripts/build.sh +11 -0
  86. package/scripts/generate.sh +25 -0
  87. package/src/api/api.d.ts +3973 -0
  88. package/src/api/api.js +9991 -0
  89. package/src/api/proto.json +747 -0
  90. package/src/config.ts +110 -0
  91. package/src/demo.ts +303 -0
  92. package/src/device.ts +94 -0
  93. package/src/index.ts +4 -0
  94. package/src/node.ts +18 -0
  95. package/src/nodes/electrical_broadband.ts +30 -0
  96. package/src/nodes/electrical_stimulation.ts +30 -0
  97. package/src/nodes/index.ts +8 -0
  98. package/src/nodes/optical_broadband.ts +30 -0
  99. package/src/nodes/optical_stimulation.ts +30 -0
  100. package/src/nodes/spectral_filter.ts +30 -0
  101. package/src/nodes/spike_detect.ts +30 -0
  102. package/src/nodes/stream_in.ts +83 -0
  103. package/src/nodes/stream_out.ts +92 -0
  104. package/src/utils/client.ts +20 -0
  105. package/src/utils/discover.ts +82 -0
  106. package/src/utils/enum.ts +8 -0
  107. package/src/utils/index.ts +1 -0
  108. package/synapse-api/README.md +15 -0
  109. package/synapse-api/api/channel.proto +9 -0
  110. package/synapse-api/api/datatype.proto +12 -0
  111. package/synapse-api/api/files.proto +46 -0
  112. package/synapse-api/api/node.proto +54 -0
  113. package/synapse-api/api/nodes/electrical_broadband.proto +15 -0
  114. package/synapse-api/api/nodes/electrical_stimulation.proto +13 -0
  115. package/synapse-api/api/nodes/optical_broadband.proto +11 -0
  116. package/synapse-api/api/nodes/optical_stimulation.proto +11 -0
  117. package/synapse-api/api/nodes/spectral_filter.proto +17 -0
  118. package/synapse-api/api/nodes/spike_detect.proto +16 -0
  119. package/synapse-api/api/nodes/stream_in.proto +9 -0
  120. package/synapse-api/api/nodes/stream_out.proto +8 -0
  121. package/synapse-api/api/query.proto +46 -0
  122. package/synapse-api/api/status.proto +42 -0
  123. package/synapse-api/api/synapse.proto +51 -0
@@ -0,0 +1,30 @@
1
+ import { synapse } from "../api/api";
2
+ import Node from "../node";
3
+
4
+ class SpikeDetect extends Node {
5
+ type = synapse.NodeType.kSpikeDetect;
6
+ config: synapse.ISpikeDetectConfig;
7
+
8
+ constructor(config: synapse.ISpikeDetectConfig = {}) {
9
+ super();
10
+
11
+ this.config = config;
12
+ }
13
+
14
+ toProto(): synapse.NodeConfig {
15
+ return super.toProto({
16
+ spikeDetect: this.config,
17
+ });
18
+ }
19
+
20
+ static fromProto(proto: synapse.INodeConfig): SpikeDetect {
21
+ const { spikeDetect } = proto;
22
+ if (!spikeDetect) {
23
+ throw new Error("Invalid config, missing spikeDetect");
24
+ }
25
+
26
+ return new SpikeDetect(proto.spikeDetect);
27
+ }
28
+ }
29
+
30
+ export default SpikeDetect;
@@ -0,0 +1,83 @@
1
+ import dgram from "dgram";
2
+
3
+ import { synapse } from "../api/api";
4
+ import Node from "../node";
5
+
6
+ export interface StreamInArgs {
7
+ dataType: synapse.DataType;
8
+ shape?: number[];
9
+ }
10
+
11
+ class StreamIn extends Node {
12
+ type = synapse.NodeType.kStreamIn;
13
+ config: synapse.IStreamInConfig;
14
+ _socket: dgram.Socket;
15
+
16
+ constructor(config: synapse.IStreamInConfig = {}) {
17
+ super();
18
+ this.config = config;
19
+ }
20
+
21
+ write(data: string | Buffer): boolean {
22
+ if (this.device === null) {
23
+ return false;
24
+ }
25
+
26
+ const socket = this.device.sockets.find((s) => s.nodeId === this.id);
27
+ if (!socket) {
28
+ return false;
29
+ }
30
+
31
+ const split = socket.bind.split(":");
32
+ if (split.length !== 2) {
33
+ return false;
34
+ }
35
+
36
+ const port = parseInt(split[1]);
37
+ if (isNaN(port)) {
38
+ return false;
39
+ }
40
+
41
+ const host = split[0];
42
+ if (!host || !port) {
43
+ return false;
44
+ }
45
+
46
+ if (!this._socket) {
47
+ this._socket = dgram.createSocket("udp4");
48
+ }
49
+
50
+ try {
51
+ this._socket.send(data, port, host);
52
+ } catch (e) {
53
+ return false;
54
+ }
55
+
56
+ return true;
57
+ }
58
+
59
+ toProto(): synapse.NodeConfig {
60
+ return super.toProto({
61
+ streamIn: this.config,
62
+ });
63
+ }
64
+
65
+ _getAddr = (): string | null => {
66
+ if (this.device === null) {
67
+ return null;
68
+ }
69
+
70
+ return this.device.uri.split(":")[0];
71
+ };
72
+
73
+ static fromProto(proto: synapse.INodeConfig): StreamIn {
74
+ const { streamIn } = proto;
75
+ if (!streamIn) {
76
+ throw new Error("Invalid config, missing streamIn");
77
+ }
78
+
79
+ return new StreamIn(streamIn);
80
+ }
81
+ }
82
+
83
+ export default StreamIn;
@@ -0,0 +1,92 @@
1
+ import dgram from "dgram";
2
+
3
+ import { synapse } from "../api/api";
4
+ import Node from "../node";
5
+
6
+ const kMulticastTTL = 3;
7
+
8
+ class StreamOut extends Node {
9
+ type = synapse.NodeType.kStreamOut;
10
+ config: synapse.IStreamOutConfig;
11
+ _socket: dgram.Socket;
12
+ _onMessage: ((msg: Buffer) => void) | null;
13
+
14
+ constructor(config: synapse.IStreamOutConfig, onMessage?: (msg: Buffer) => void) {
15
+ super();
16
+
17
+ this.config = config;
18
+ this._onMessage = onMessage;
19
+ }
20
+
21
+ async start(): Promise<any> {
22
+ if (this.device === null) {
23
+ return false;
24
+ }
25
+
26
+ const socket = this.device.sockets.find((s) => s.nodeId === this.id);
27
+ if (!socket) {
28
+ return false;
29
+ }
30
+
31
+ const split = socket.bind.split(":");
32
+ if (split.length !== 2) {
33
+ return false;
34
+ }
35
+
36
+ const port = parseInt(split[1]);
37
+ if (isNaN(port)) {
38
+ return false;
39
+ }
40
+
41
+ const host = this.config.multicastGroup;
42
+ if (!host) {
43
+ return false;
44
+ }
45
+
46
+ this._socket = dgram.createSocket("udp4");
47
+
48
+ this._socket.on("error", (err: any) => {});
49
+
50
+ this._socket.on("message", (msg: Buffer, rinfo: any) => {
51
+ this._onMessage?.(msg);
52
+ });
53
+
54
+ this._socket.bind(port, host, () => {
55
+ if (!this._socket) {
56
+ return;
57
+ }
58
+
59
+ if (this.config.multicastGroup) {
60
+ this._socket.setMulticastTTL(kMulticastTTL);
61
+ this._socket.addMembership(this.config.multicastGroup);
62
+ }
63
+ });
64
+
65
+ return true;
66
+ }
67
+
68
+ async stop(): Promise<any> {
69
+ if (this._socket) {
70
+ this._socket.close();
71
+ }
72
+
73
+ return true;
74
+ }
75
+
76
+ toProto(): synapse.NodeConfig {
77
+ return super.toProto({
78
+ streamOut: this.config,
79
+ });
80
+ }
81
+
82
+ static fromProto(proto: synapse.INodeConfig): StreamOut {
83
+ const { streamOut } = proto;
84
+ if (!streamOut) {
85
+ throw new Error("Invalid config, missing streamOut");
86
+ }
87
+
88
+ return new StreamOut(streamOut);
89
+ }
90
+ }
91
+
92
+ export default StreamOut;
@@ -0,0 +1,20 @@
1
+ import { ChannelCredentials, ChannelOptions, loadPackageDefinition } from "@grpc/grpc-js";
2
+ import { fromJSON } from "@grpc/proto-loader";
3
+
4
+ import protoJson from "../api/proto.json";
5
+
6
+ const loadClient = () => {
7
+ const definition = fromJSON(protoJson as any, {
8
+ keepCase: false,
9
+ arrays: true,
10
+ enums: Number,
11
+ defaults: true,
12
+ oneofs: true,
13
+ });
14
+ const descriptor = loadPackageDefinition(definition as any);
15
+ return (descriptor.synapse as any).SynapseDevice;
16
+ };
17
+
18
+ export const create = (address: string, credentials: ChannelCredentials, options?: ChannelOptions) => {
19
+ return new (loadClient())(address, credentials, options);
20
+ };
@@ -0,0 +1,82 @@
1
+ import dgram from "dgram";
2
+
3
+ const kDefaultTimeout = 3000;
4
+
5
+ interface DiscoverArgs {
6
+ host: string;
7
+ port: number;
8
+ timeoutMs?: number;
9
+ }
10
+
11
+ class DeviceAdvertisement {
12
+ host: string;
13
+ port: number;
14
+ serial: string;
15
+ capability: string;
16
+ name: string;
17
+ }
18
+
19
+ const kDefaultDiscoverArgs: DiscoverArgs = {
20
+ host: "224.0.0.245",
21
+ port: 6470,
22
+ timeoutMs: kDefaultTimeout,
23
+ };
24
+
25
+ export const discover = (args = kDefaultDiscoverArgs): Promise<DeviceAdvertisement[]> => {
26
+ return new Promise((resolve, reject) => {
27
+ const devices: DeviceAdvertisement[] = [];
28
+
29
+ const socket = dgram.createSocket("udp4");
30
+
31
+ socket.on("message", (msg: Buffer, rinfo: any) => {
32
+ const server = `${rinfo.address}:${rinfo.port}`;
33
+ const message = msg.toString("ascii");
34
+ const split = message.split(" ");
35
+
36
+ if (split.length < 5) {
37
+ return;
38
+ }
39
+
40
+ if (split[0] !== "ID") {
41
+ return;
42
+ }
43
+
44
+ const host = rinfo.address;
45
+ const [_, serial, capability, portstr, name] = split;
46
+ const port = parseInt(portstr);
47
+ if (isNaN(port)) {
48
+ return;
49
+ }
50
+
51
+ const service = capability.split(/(\d+)/)[0];
52
+ if (service !== "SYN") {
53
+ return;
54
+ }
55
+
56
+ devices.push({
57
+ host,
58
+ port,
59
+ serial,
60
+ capability,
61
+ name,
62
+ });
63
+ });
64
+
65
+ const payload = Buffer.from(`DISCOVER`, "ascii");
66
+
67
+ socket.send(payload, 0, payload.length, args.port, args.host, () => {
68
+ if (!args.timeoutMs) {
69
+ return;
70
+ }
71
+ setTimeout(() => socket.close(), kDefaultTimeout);
72
+ });
73
+
74
+ socket.on("error", (err: any) => {
75
+ reject(err);
76
+ });
77
+
78
+ socket.on("close", () => {
79
+ resolve(devices);
80
+ });
81
+ });
82
+ };
@@ -0,0 +1,8 @@
1
+ export const getName = (enumType: any, value: number | string): string => {
2
+ for (const key in enumType) {
3
+ if (enumType[key] === value) {
4
+ return key;
5
+ }
6
+ }
7
+ return "";
8
+ };
@@ -0,0 +1 @@
1
+ import { discover } from "./discover";
@@ -0,0 +1,15 @@
1
+ # Synapse API 1.0
2
+
3
+ The Synapse Protocol defines a standard interface for interacting with a wide range of possible neural interface devices.
4
+
5
+ Synapse uses gRPC for its control plane API and UDP for streaming data. Read the full Synapse protocol docs [here](https://science.xyz/docs/d/synapse/index).
6
+
7
+ # Python Installation
8
+
9
+ You can install the official [Synapse Python client library](https://github.com/sciencecorp/synapse-python) using:
10
+
11
+ `pip install science-synapse`
12
+
13
+ # Other Installation
14
+
15
+ You can use these protobufs in any language supported by gRPC, but we highly encourage you to use one of our existing clients in Python, C++, or TS/Node because they wrap it and add additional utilities.
@@ -0,0 +1,9 @@
1
+ syntax = "proto3";
2
+
3
+ package synapse;
4
+
5
+ message Channel {
6
+ uint32 id = 1;
7
+ uint32 electrode_id = 2;
8
+ uint32 reference_id = 3;
9
+ }
@@ -0,0 +1,12 @@
1
+ syntax = "proto3";
2
+
3
+ package synapse;
4
+
5
+ enum DataType {
6
+ kDataTypeUnknown = 0;
7
+ kAny = 1;
8
+ kBroadband = 2;
9
+ kSpiketrain = 3;
10
+ kTimestamps = 4;
11
+ kImage = 5;
12
+ }
@@ -0,0 +1,46 @@
1
+ syntax = "proto3";
2
+
3
+ package synapse;
4
+
5
+ import "api/status.proto";
6
+
7
+ message ListFilesResponse {
8
+ message File {
9
+ string name = 1;
10
+ uint32 size = 2;
11
+ uint32 created = 3;
12
+ uint32 modified = 4;
13
+ string type = 5;
14
+ }
15
+ repeated File files = 1;
16
+ }
17
+
18
+ message WriteFileRequest {
19
+ string name = 1;
20
+ bytes data = 2;
21
+ }
22
+
23
+ message WriteFileResponse {
24
+ string name = 1;
25
+ uint64 bytes_written = 2;
26
+ }
27
+
28
+ message ReadFileRequest {
29
+ string name = 1;
30
+ }
31
+
32
+ message ReadFileResponse {
33
+ string name = 1;
34
+ bytes data = 2;
35
+ uint32 start_offset = 3;
36
+ uint32 file_total_length = 4;
37
+ }
38
+
39
+ message DeleteFileRequest {
40
+ string name = 1;
41
+ }
42
+
43
+ message DeleteFileResponse {
44
+ string name = 1;
45
+ StatusCode status_code = 2;
46
+ }
@@ -0,0 +1,54 @@
1
+ syntax = "proto3";
2
+
3
+ package synapse;
4
+
5
+ import "api/datatype.proto";
6
+ import "api/nodes/electrical_broadband.proto";
7
+ import "api/nodes/electrical_stimulation.proto";
8
+ import "api/nodes/optical_broadband.proto";
9
+ import "api/nodes/optical_stimulation.proto";
10
+ import "api/nodes/spike_detect.proto";
11
+ import "api/nodes/spectral_filter.proto";
12
+ import "api/nodes/stream_out.proto";
13
+ import "api/nodes/stream_in.proto";
14
+
15
+ enum NodeType {
16
+ kNodeTypeUnknown = 0;
17
+ kStreamIn = 1;
18
+ kStreamOut = 2;
19
+ kElectricalBroadband = 3;
20
+ kElectricalStimulation = 4;
21
+ kOpticalBroadband = 5;
22
+ kOpticalStimulation = 6;
23
+ kSpikeDetect = 7;
24
+ kSpectralFilter = 8;
25
+ }
26
+
27
+ message NodeConfig {
28
+ NodeType type = 1;
29
+ uint32 id = 2;
30
+ oneof config {
31
+ StreamOutConfig stream_out = 3;
32
+ StreamInConfig stream_in = 4;
33
+ ElectricalBroadbandConfig electrical_broadband = 5;
34
+ ElectricalStimulationConfig electrical_stimulation = 6;
35
+ OpticalBroadbandConfig optical_broadband = 7;
36
+ OpticalStimulationConfig optical_stimulation = 8;
37
+ SpikeDetectConfig spike_detect = 9;
38
+ SpectralFilterConfig spectral_filter = 10;
39
+ }
40
+ }
41
+
42
+ message NodeConnection {
43
+ uint32 src_node_id = 1;
44
+ uint32 dst_node_id = 2;
45
+ }
46
+
47
+ message NodeSocket {
48
+ uint32 node_id = 1;
49
+ string bind = 2;
50
+ DataType data_type = 3;
51
+ NodeType type = 4;
52
+ string label = 5;
53
+ repeated uint32 shape = 6;
54
+ }
@@ -0,0 +1,15 @@
1
+ syntax = "proto3";
2
+
3
+ import "api/channel.proto";
4
+
5
+ package synapse;
6
+
7
+ message ElectricalBroadbandConfig {
8
+ uint32 peripheral_id = 1;
9
+ repeated Channel channels = 2;
10
+ uint32 bit_width = 3;
11
+ uint32 sample_rate = 4;
12
+ float gain = 5;
13
+ float low_cutoff_hz = 6;
14
+ float high_cutoff_hz = 7;
15
+ }
@@ -0,0 +1,13 @@
1
+ syntax = "proto3";
2
+
3
+ import "api/channel.proto";
4
+
5
+ package synapse;
6
+
7
+ message ElectricalStimulationConfig {
8
+ uint32 peripheral_id = 1;
9
+ repeated Channel channels = 2;
10
+ uint32 bit_width = 3;
11
+ uint32 sample_rate = 4;
12
+ uint32 lsb = 5;
13
+ }
@@ -0,0 +1,11 @@
1
+ syntax = "proto3";
2
+
3
+ package synapse;
4
+
5
+ message OpticalBroadbandConfig {
6
+ uint32 peripheral_id = 1;
7
+ repeated uint32 pixel_mask = 2;
8
+ uint32 bit_width = 3;
9
+ uint32 frame_rate = 4;
10
+ uint32 gain = 5;
11
+ }
@@ -0,0 +1,11 @@
1
+ syntax = "proto3";
2
+
3
+ package synapse;
4
+
5
+ message OpticalStimulationConfig {
6
+ uint32 peripheral_id = 1;
7
+ repeated uint32 pixel_mask = 2;
8
+ uint32 bit_width = 3;
9
+ uint32 frame_rate = 4;
10
+ float gain = 5;
11
+ }
@@ -0,0 +1,17 @@
1
+ syntax = "proto3";
2
+
3
+ package synapse;
4
+
5
+ enum SpectralFilterMethod {
6
+ kSpectralFilterUnknown = 0;
7
+ kLowPass = 1;
8
+ kHighPass = 2;
9
+ kBandPass = 3;
10
+ kBandStop = 4;
11
+ }
12
+
13
+ message SpectralFilterConfig {
14
+ SpectralFilterMethod method = 1;
15
+ float low_cutoff_hz = 2;
16
+ float high_cutoff_hz = 3;
17
+ }
@@ -0,0 +1,16 @@
1
+ syntax = "proto3";
2
+
3
+ package synapse;
4
+
5
+ message SpikeDetectConfig {
6
+ enum SpikeDetectMode {
7
+ kThreshold = 0;
8
+ kTemplate = 1;
9
+ kWavelet = 2;
10
+ }
11
+ SpikeDetectMode mode = 1;
12
+ uint32 threshold_uV = 2;
13
+ repeated uint32 template_uV = 3;
14
+ bool sort = 4;
15
+ uint32 bin_size_ms = 5;
16
+ }
@@ -0,0 +1,9 @@
1
+ syntax = "proto3";
2
+
3
+ import "api/datatype.proto";
4
+
5
+ package synapse;
6
+
7
+ message StreamInConfig {
8
+ DataType data_type = 1;
9
+ }
@@ -0,0 +1,8 @@
1
+ syntax = "proto3";
2
+
3
+ package synapse;
4
+
5
+ message StreamOutConfig {
6
+ string label = 1;
7
+ string multicast_group = 2;
8
+ }
@@ -0,0 +1,46 @@
1
+ syntax = "proto3";
2
+
3
+ package synapse;
4
+
5
+ import "api/channel.proto";
6
+ import "api/status.proto";
7
+
8
+ message SampleQuery {
9
+ repeated Channel channels = 1;
10
+ uint32 sample_count = 2;
11
+ }
12
+
13
+ message ImpedanceQuery {
14
+ repeated uint32 electrode_ids = 1;
15
+ }
16
+
17
+ message ImpedanceMeasurement {
18
+ uint32 electrode_id = 1;
19
+ float magnitude = 2;
20
+ float phase = 3;
21
+ }
22
+
23
+ message ImpedanceResponse {
24
+ repeated ImpedanceMeasurement measurements = 1;
25
+ }
26
+
27
+ message QueryRequest {
28
+ enum QueryType {
29
+ kNone = 0;
30
+ kImpedance = 1;
31
+ kSample = 2;
32
+ }
33
+ QueryType query_type = 1;
34
+ oneof query {
35
+ ImpedanceQuery impedance_query = 2;
36
+ SampleQuery sample_query = 3;
37
+ }
38
+ }
39
+
40
+ message QueryResponse {
41
+ Status status = 1;
42
+ repeated uint32 data = 2;
43
+ oneof response {
44
+ ImpedanceResponse impedance_response = 3;
45
+ }
46
+ }
@@ -0,0 +1,42 @@
1
+ syntax = "proto3";
2
+
3
+ package synapse;
4
+
5
+ import "api/node.proto";
6
+
7
+ enum StatusCode {
8
+ kOk = 0;
9
+ kUndefinedError = 1;
10
+ kInvalidConfiguration = 2;
11
+ kFailedPrecondition = 3;
12
+ kUnimplemented = 4;
13
+ kInternalError = 5;
14
+ kPermissionDenied = 6;
15
+ }
16
+
17
+ enum DeviceState {
18
+ kUnknown = 0;
19
+ kInitializing = 1;
20
+ kStopped = 2;
21
+ kRunning = 3;
22
+ kError = 4;
23
+ }
24
+
25
+ message DeviceStorage {
26
+ float total_gb = 1;
27
+ float used_gb = 2;
28
+ }
29
+
30
+ message DevicePower {
31
+ float battery_level_percent = 1;
32
+ bool is_charging = 2;
33
+ }
34
+
35
+ message Status {
36
+ string message = 1;
37
+ StatusCode code = 2;
38
+ DeviceState state = 3;
39
+ repeated NodeSocket sockets = 4;
40
+ DevicePower power = 5;
41
+ DeviceStorage storage = 6;
42
+ }