@science-corporation/synapse 1.1.0 → 2.2.2

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 (130) hide show
  1. package/README.md +7 -0
  2. package/package.json +3 -2
  3. package/src/config.ts +4 -6
  4. package/src/device.ts +35 -6
  5. package/src/nodes/index.ts +2 -3
  6. package/src/nodes/spike_binner.ts +30 -0
  7. package/src/nodes/spike_detector.ts +30 -0
  8. package/synapse-api/.github/pull_request_template.md +10 -0
  9. package/synapse-api/README.md +1 -1
  10. package/synapse-api/api/app.proto +55 -0
  11. package/synapse-api/api/channel.proto +15 -1
  12. package/synapse-api/api/datatype.proto +98 -1
  13. package/synapse-api/api/device.proto +65 -0
  14. package/synapse-api/api/node.proto +25 -21
  15. package/synapse-api/api/nodes/application.proto +24 -0
  16. package/synapse-api/api/nodes/broadband_source.proto +1 -0
  17. package/synapse-api/api/nodes/disk_writer.proto +17 -0
  18. package/synapse-api/api/nodes/optical_stimulation.proto +29 -0
  19. package/synapse-api/api/nodes/signal_config.proto +2 -0
  20. package/synapse-api/api/nodes/spike_binner.proto +7 -0
  21. package/synapse-api/api/nodes/spike_detector.proto +19 -0
  22. package/synapse-api/api/performance.proto +29 -0
  23. package/synapse-api/api/query.proto +27 -1
  24. package/synapse-api/api/status.proto +6 -1
  25. package/synapse-api/api/synapse.proto +9 -31
  26. package/synapse-api/api/tap.proto +35 -0
  27. package/synapse-api/api/time.proto +53 -0
  28. package/dist/api/api.d.ts +0 -6233
  29. package/dist/api/api.d.ts.map +0 -1
  30. package/dist/api/api.js +0 -14553
  31. package/dist/api/api.js.map +0 -1
  32. package/dist/api/proto.json +0 -1077
  33. package/dist/browser.d.ts +0 -4
  34. package/dist/browser.d.ts.map +0 -1
  35. package/dist/browser.js +0 -22
  36. package/dist/browser.js.map +0 -1
  37. package/dist/config.d.ts +0 -17
  38. package/dist/config.d.ts.map +0 -1
  39. package/dist/config.js +0 -113
  40. package/dist/config.js.map +0 -1
  41. package/dist/demo.d.ts +0 -2
  42. package/dist/demo.d.ts.map +0 -1
  43. package/dist/demo.js +0 -285
  44. package/dist/demo.js.map +0 -1
  45. package/dist/device.d.ts +0 -32
  46. package/dist/device.d.ts.map +0 -1
  47. package/dist/device.js +0 -160
  48. package/dist/device.js.map +0 -1
  49. package/dist/index.d.ts +0 -7
  50. package/dist/index.d.ts.map +0 -1
  51. package/dist/index.js +0 -30
  52. package/dist/index.js.map +0 -1
  53. package/dist/node.d.ts +0 -10
  54. package/dist/node.d.ts.map +0 -1
  55. package/dist/node.js +0 -14
  56. package/dist/node.js.map +0 -1
  57. package/dist/nodes/broadband_source.d.ts +0 -11
  58. package/dist/nodes/broadband_source.d.ts.map +0 -1
  59. package/dist/nodes/broadband_source.js +0 -28
  60. package/dist/nodes/broadband_source.js.map +0 -1
  61. package/dist/nodes/disk_writer.d.ts +0 -11
  62. package/dist/nodes/disk_writer.d.ts.map +0 -1
  63. package/dist/nodes/disk_writer.js +0 -28
  64. package/dist/nodes/disk_writer.js.map +0 -1
  65. package/dist/nodes/electrical_stimulation.d.ts +0 -11
  66. package/dist/nodes/electrical_stimulation.d.ts.map +0 -1
  67. package/dist/nodes/electrical_stimulation.js +0 -28
  68. package/dist/nodes/electrical_stimulation.js.map +0 -1
  69. package/dist/nodes/index.d.ts +0 -11
  70. package/dist/nodes/index.d.ts.map +0 -1
  71. package/dist/nodes/index.js +0 -25
  72. package/dist/nodes/index.js.map +0 -1
  73. package/dist/nodes/optical_stimulation.d.ts +0 -11
  74. package/dist/nodes/optical_stimulation.d.ts.map +0 -1
  75. package/dist/nodes/optical_stimulation.js +0 -28
  76. package/dist/nodes/optical_stimulation.js.map +0 -1
  77. package/dist/nodes/spectral_filter.d.ts +0 -11
  78. package/dist/nodes/spectral_filter.d.ts.map +0 -1
  79. package/dist/nodes/spectral_filter.js +0 -28
  80. package/dist/nodes/spectral_filter.js.map +0 -1
  81. package/dist/nodes/spike_detect.d.ts +0 -11
  82. package/dist/nodes/spike_detect.d.ts.map +0 -1
  83. package/dist/nodes/spike_detect.js +0 -28
  84. package/dist/nodes/spike_detect.js.map +0 -1
  85. package/dist/nodes/spike_source.d.ts +0 -11
  86. package/dist/nodes/spike_source.d.ts.map +0 -1
  87. package/dist/nodes/spike_source.js +0 -28
  88. package/dist/nodes/spike_source.js.map +0 -1
  89. package/dist/nodes/stream_in.d.ts +0 -15
  90. package/dist/nodes/stream_in.d.ts.map +0 -1
  91. package/dist/nodes/stream_in.js +0 -66
  92. package/dist/nodes/stream_in.js.map +0 -1
  93. package/dist/nodes/stream_out.d.ts +0 -23
  94. package/dist/nodes/stream_out.d.ts.map +0 -1
  95. package/dist/nodes/stream_out.js +0 -105
  96. package/dist/nodes/stream_out.js.map +0 -1
  97. package/dist/utils/client.d.ts +0 -10
  98. package/dist/utils/client.d.ts.map +0 -1
  99. package/dist/utils/client.js +0 -39
  100. package/dist/utils/client.js.map +0 -1
  101. package/dist/utils/discover.d.ts +0 -10
  102. package/dist/utils/discover.d.ts.map +0 -1
  103. package/dist/utils/discover.js +0 -49
  104. package/dist/utils/discover.js.map +0 -1
  105. package/dist/utils/enum.d.ts +0 -2
  106. package/dist/utils/enum.d.ts.map +0 -1
  107. package/dist/utils/enum.js +0 -13
  108. package/dist/utils/enum.js.map +0 -1
  109. package/dist/utils/index.d.ts +0 -2
  110. package/dist/utils/index.d.ts.map +0 -1
  111. package/dist/utils/index.js +0 -6
  112. package/dist/utils/index.js.map +0 -1
  113. package/dist/utils/ip.d.ts +0 -2
  114. package/dist/utils/ip.d.ts.map +0 -1
  115. package/dist/utils/ip.js +0 -52
  116. package/dist/utils/ip.js.map +0 -1
  117. package/dist/utils/status.d.ts +0 -28
  118. package/dist/utils/status.d.ts.map +0 -1
  119. package/dist/utils/status.js +0 -54
  120. package/dist/utils/status.js.map +0 -1
  121. package/src/api/api.d.ts +0 -6233
  122. package/src/api/api.js +0 -15524
  123. package/src/api/proto.json +0 -1077
  124. package/src/demo.ts +0 -325
  125. package/src/nodes/spike_detect.ts +0 -30
  126. package/src/nodes/stream_in.ts +0 -78
  127. package/src/nodes/stream_out.ts +0 -109
  128. package/synapse-api/api/nodes/spike_detect.proto +0 -16
  129. package/synapse-api/api/nodes/stream_in.proto +0 -14
  130. package/synapse-api/api/nodes/stream_out.proto +0 -42
@@ -0,0 +1,19 @@
1
+ syntax = "proto3";
2
+
3
+ package synapse;
4
+
5
+ message TemplateMatcher {
6
+ repeated uint32 template_uV = 1;
7
+ }
8
+
9
+ message Thresholder {
10
+ uint32 threshold_uV = 1;
11
+ }
12
+
13
+ message SpikeDetectorConfig {
14
+ oneof config {
15
+ Thresholder thresholder = 1;
16
+ TemplateMatcher template_matcher = 2;
17
+ }
18
+ uint32 samples_per_spike = 3;
19
+ }
@@ -0,0 +1,29 @@
1
+ syntax = "proto3";
2
+
3
+ package synapse;
4
+
5
+ // Statistics about the performance of a function call or block of computation
6
+ message FunctionProfile {
7
+ string name = 1;
8
+
9
+ // How often has this been called
10
+ uint64 call_count = 2;
11
+
12
+ // What was the minimal time it took for this function to execute
13
+ uint64 min_duration_ns = 3;
14
+
15
+ // Maximum execution for this function
16
+ uint64 max_duration_ns = 4;
17
+
18
+ // Average (mean) of this function over all samples
19
+ uint64 average_duration_ns = 5;
20
+
21
+ // Median execution time over all samples
22
+ uint64 median_duration_ns = 6;
23
+
24
+ // p99 duration
25
+ uint64 p99_duration_ns = 7;
26
+
27
+ // The last measurement duration
28
+ uint64 latest_duration_ns = 8;
29
+ }
@@ -4,6 +4,8 @@ package synapse;
4
4
 
5
5
  import "api/channel.proto";
6
6
  import "api/status.proto";
7
+ import "api/tap.proto";
8
+ import "api/device.proto";
7
9
 
8
10
  message SampleQuery {
9
11
  repeated Channel channels = 1;
@@ -46,20 +48,44 @@ message QueryRequest {
46
48
  kImpedance = 1;
47
49
  kSample = 2;
48
50
  kSelfTest = 3;
51
+ kListTaps = 4;
52
+ kGetSettings = 5;
49
53
  }
50
54
  QueryType query_type = 1;
51
55
  oneof query {
52
56
  ImpedanceQuery impedance_query = 2;
53
57
  SampleQuery sample_query = 3;
54
58
  SelfTestQuery self_test_query = 4;
59
+ ListTapsQuery list_taps_query = 5;
60
+ GetSettingsQuery get_settings_query = 6;
55
61
  }
56
62
  }
57
63
 
64
+ message StreamQueryRequest {
65
+ QueryRequest request = 1;
66
+
67
+ // Other options to fill in specific to a stream
68
+ }
69
+
58
70
  message QueryResponse {
59
71
  Status status = 1;
60
72
  repeated uint32 data = 2;
61
73
  oneof response {
62
74
  ImpedanceResponse impedance_response = 3;
63
75
  SelfTestResponse self_test_response = 4;
76
+ ListTapsResponse list_taps_response = 5;
77
+ GetSettingsResponse get_settings_response = 6;
78
+ }
79
+ }
80
+
81
+ message StreamQueryResponse {
82
+ StatusCode code = 1;
83
+ string message = 2;
84
+ uint64 timestamp_ns = 3;
85
+
86
+ // We need to switch on the test being run
87
+ oneof response {
88
+ ImpedanceResponse impedance = 4;
89
+ SelfTestResponse self_test = 5;
64
90
  }
65
- }
91
+ }
@@ -41,8 +41,13 @@ message Status {
41
41
  string message = 1;
42
42
  StatusCode code = 2;
43
43
  DeviceState state = 3;
44
- repeated NodeSocket sockets = 4;
44
+ // repeated NodeSocket sockets = 4;
45
+ reserved 4;
45
46
  DevicePower power = 5;
46
47
  DeviceStorage storage = 6;
47
48
  SignalChainStatus signal_chain = 7;
49
+
50
+ // If the device supports a time sync server (see time.proto)
51
+ // Then the UDP echo server will be available at this port
52
+ uint32 time_sync_port = 8; // Port number (0-65535) for the UDP time sync server
48
53
  }
@@ -3,41 +3,13 @@ syntax = "proto3";
3
3
  package synapse;
4
4
 
5
5
  import "google/protobuf/empty.proto";
6
- import "api/node.proto";
6
+
7
7
  import "api/query.proto";
8
8
  import "api/status.proto";
9
9
  import "api/files.proto";
10
10
  import "api/logging.proto";
11
-
12
- message Peripheral {
13
- enum Type {
14
- kUnknown = 0;
15
- kBroadbandSource = 1;
16
- kElectricalStimulation = 2;
17
- kOpticalStimulation = 3;
18
- kSpikeSource = 4;
19
- }
20
- string name = 1;
21
- string vendor = 2;
22
- uint32 peripheral_id = 3;
23
- Type type = 4;
24
- string address = 5;
25
- }
26
-
27
- message DeviceInfo {
28
- string name = 1;
29
- string serial = 2;
30
- uint32 synapse_version = 3;
31
- uint32 firmware_version = 4;
32
- Status status = 5;
33
- repeated Peripheral peripherals = 6;
34
- DeviceConfiguration configuration = 7;
35
- }
36
-
37
- message DeviceConfiguration {
38
- repeated NodeConfig nodes = 1;
39
- repeated NodeConnection connections = 2;
40
- }
11
+ import "api/app.proto";
12
+ import "api/device.proto";
41
13
 
42
14
  service SynapseDevice {
43
15
  rpc Info(google.protobuf.Empty) returns (DeviceInfo) {}
@@ -45,11 +17,17 @@ service SynapseDevice {
45
17
  rpc Start(google.protobuf.Empty) returns (Status) {}
46
18
  rpc Stop(google.protobuf.Empty) returns (Status) {}
47
19
  rpc Query(QueryRequest) returns (QueryResponse) {}
20
+ rpc StreamQuery(StreamQueryRequest) returns (stream StreamQueryResponse) {}
21
+
22
+ rpc DeployApp(stream AppPackageChunk) returns (stream AppDeployResponse) {}
48
23
 
49
24
  rpc ListFiles(google.protobuf.Empty) returns (ListFilesResponse) {}
50
25
  rpc WriteFile(WriteFileRequest) returns (WriteFileResponse) {}
51
26
  rpc ReadFile(ReadFileRequest) returns (stream ReadFileResponse) {}
52
27
  rpc DeleteFile(DeleteFileRequest) returns (DeleteFileResponse) {}
28
+
53
29
  rpc GetLogs(LogQueryRequest) returns (LogQueryResponse) {}
54
30
  rpc TailLogs(TailLogsRequest) returns (stream LogEntry) {}
31
+
32
+ rpc UpdateDeviceSettings(UpdateDeviceSettingsRequest) returns (UpdateDeviceSettingsResponse) {}
55
33
  }
@@ -0,0 +1,35 @@
1
+ syntax = "proto3";
2
+
3
+ package synapse;
4
+
5
+ enum TapType {
6
+ TAP_TYPE_UNSPECIFIED = 0;
7
+
8
+ // The tap will be producing data
9
+ TAP_TYPE_PRODUCER = 1;
10
+
11
+ // The tap type will be consuming data
12
+ TAP_TYPE_CONSUMER = 2;
13
+ }
14
+
15
+ message TapConnection {
16
+ // Unique name id for this tap
17
+ string name = 1;
18
+
19
+ // What is the zmq endpoint to connect to
20
+ string endpoint = 2;
21
+
22
+ // What is the protobuf message to expect over this
23
+ string message_type = 3;
24
+
25
+ // Is this tap meant to be producing or consuming
26
+ TapType tap_type = 4;
27
+ }
28
+
29
+ message ListTapsQuery {
30
+
31
+ }
32
+
33
+ message ListTapsResponse {
34
+ repeated TapConnection taps = 1;
35
+ }
@@ -0,0 +1,53 @@
1
+ syntax = "proto3";
2
+
3
+ package synapse;
4
+
5
+ /**
6
+ * Used for precise time synchronization over UDP between clients and a server
7
+ * In most cases, the server is the Synapse device.enum
8
+ *
9
+ * How it works:
10
+ * 1. Client generates a random client_id on first connection
11
+ * 2. Client increments the sequence number on each packet (to detect drops)
12
+ * 3. Client records the send time and sends the packet to the server over udp.
13
+ * - The server port will be available through the Status message
14
+ * - Try to timestamp the packet as close as possible to the send to minimize
15
+ * the calculated offset error. Future improvements could support hardware timestamps
16
+ * 4. Server records the receive time
17
+ * 5. Server immediately echos it back to the client, recording the send time
18
+ * 6. Client records the receive time when the packet returns
19
+ *
20
+ * With these times, the client can calculate
21
+ * - Round Trip Time: (client_receive_time_ns - client_send_time_ns)
22
+ * - Network Latency (assumes symmetric paths): rtt / 2
23
+ * - Clock offset: https://en.wikipedia.org/wiki/Network_Time_Protocol#Clock_synchronization_algorithm
24
+ *
25
+ * Implementation notes:
26
+ * - All timestamps are monotonic nanoseconds since Unix epoch
27
+ * - The server acts as a passive reflector
28
+ * - Multiple sync packets (8 or so) should be sent with a short period (200 ms) between
29
+ */
30
+ message TimeSyncPacket {
31
+ fixed32 client_id = 1;
32
+ fixed32 sequence = 2;
33
+
34
+ fixed64 client_send_time_ns = 3;
35
+ fixed64 server_receive_time_ns = 4;
36
+ fixed64 server_send_time_ns = 5;
37
+ fixed64 client_receive_time_ns = 6;
38
+ }
39
+
40
+ // Defines the time synchronization method for device timestamps
41
+ enum TimeSource {
42
+ TIME_SOURCE_UNKNOWN = 0;
43
+
44
+ // Use std::chrono::steady_clock (monotonic, immune to system time changes)
45
+ // Note: The epoch is implementation-defined (often system boot time)
46
+ TIME_SOURCE_STEADY_CLOCK = 1;
47
+
48
+ // Calculate timestamps based on sample counter and sampling rate
49
+ // counter_diff = (counter - first_counter)
50
+ // timestamp_ns = (counter_diff * 1e9 / sample_rate) + initial_steady_clock_value
51
+ // Where initial_steady_clock_value = get_steady_clock_now() at start
52
+ TIME_SOURCE_SAMPLE_COUNTER = 2;
53
+ }