com.shinolab.autd3-sdk 0.2.0 → 0.4.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.
package/Client.cs CHANGED
@@ -16,6 +16,9 @@ namespace AUTD3
16
16
  }
17
17
 
18
18
  public bool IsThermalAsserted => (Raw & (1 << 0)) != 0;
19
+ public bool IsPatternStopped => (Raw & (1 << 4)) != 0;
20
+ public bool IsModStopped => (Raw & (1 << 5)) != 0;
21
+ public bool IsTransitionPending => (Raw & (1 << 6)) != 0;
19
22
  public bool ReadsEnabled => (Raw & (1 << 7)) != 0;
20
23
  }
21
24
 
@@ -221,9 +224,12 @@ namespace AUTD3
221
224
 
222
225
  internal IntPtr Handle { get; private set; }
223
226
 
224
- private Client(IntPtr handle)
227
+ private readonly Geometry _geometry;
228
+
229
+ private Client(IntPtr handle, Geometry geometry)
225
230
  {
226
231
  Handle = handle;
232
+ _geometry = geometry;
227
233
  }
228
234
 
229
235
  public static async Task<Client> OpenAsync(Geometry geometry, ILink link, ClientConfig config)
@@ -243,7 +249,7 @@ namespace AUTD3
243
249
  NativeClient.autd3_client_config_free(configHandle);
244
250
  }
245
251
  var value = await task.ConfigureAwait(false);
246
- return new Client(value);
252
+ return new Client(value, geometry);
247
253
  }
248
254
 
249
255
  public static async Task<(Client Client, Checker Checker)> OpenWithCheckerAsync(Geometry geometry, ILink link, ClientConfig config)
@@ -261,7 +267,7 @@ namespace AUTD3
261
267
  public int NumDevices => (int)NativeClient.autd3_client_num_devices(Handle);
262
268
 
263
269
 
264
- public DatagramBuilder DatagramBuilder() => new DatagramBuilder(NumDevices);
270
+ public DatagramBuilder DatagramBuilder() => new DatagramBuilder(_geometry);
265
271
 
266
272
 
267
273
 
@@ -311,6 +317,9 @@ namespace AUTD3
311
317
  public Task<byte[]> ReadErrorDetailAsync() =>
312
318
  ReadByteArrayAsync((cb, ud) => NativeClient.autd3_client_read_error_detail(Handle, cb, ud));
313
319
 
320
+ public Task<byte[]> ReadTelemetryAsync(Telemetry counter) =>
321
+ ReadByteArrayAsync((cb, ud) => NativeClient.autd3_client_read_telemetry(Handle, (byte)counter, cb, ud));
322
+
314
323
  internal static async Task<byte[]> ReadByteArrayAsync(Action<CompletionCallback, IntPtr> invoke)
315
324
  {
316
325
  var array = await AsyncOps.InvokeAsync(invoke).ConfigureAwait(false);
package/Commands.cs CHANGED
@@ -42,10 +42,10 @@ namespace AUTD3
42
42
  internal static extern IntPtr autd3_op_emulate_gpio_in(byte[] values);
43
43
 
44
44
  [DllImport(Lib)]
45
- internal static extern IntPtr autd3_op_set_output_mask(byte[] masks, UIntPtr numDevices);
45
+ internal static extern IntPtr autd3_op_set_output_mask(byte[] masks, UIntPtr[] lens, UIntPtr numDevices);
46
46
 
47
47
  [DllImport(Lib)]
48
- internal static extern IntPtr autd3_op_set_phase_correction(byte[] phases, UIntPtr numDevices);
48
+ internal static extern IntPtr autd3_op_set_phase_correction(byte[] phases, UIntPtr[] lens, UIntPtr numDevices);
49
49
 
50
50
  [DllImport(Lib)]
51
51
  internal static extern IntPtr autd3_op_set_pulse_width_table(ushort[] table);
@@ -239,8 +239,6 @@ namespace AUTD3
239
239
 
240
240
  public sealed class SetOutputMask : ICommand
241
241
  {
242
- private const int NumTransducers = 249;
243
-
244
242
  private readonly bool[][] _masks;
245
243
 
246
244
  public SetOutputMask(bool[][] masks)
@@ -250,19 +248,24 @@ namespace AUTD3
250
248
 
251
249
  IntPtr ICommand.CreateOp()
252
250
  {
253
- var flat = new byte[_masks.Length * NumTransducers];
251
+ var lens = new UIntPtr[_masks.Length];
252
+ var total = 0;
254
253
  for (var d = 0; d < _masks.Length; d++)
255
254
  {
256
- if (_masks[d].Length != NumTransducers)
257
- {
258
- throw new Autd3Exception($"each device mask requires {NumTransducers} values");
259
- }
260
- for (var t = 0; t < NumTransducers; t++)
255
+ lens[d] = (UIntPtr)_masks[d].Length;
256
+ total += _masks[d].Length;
257
+ }
258
+ var flat = new byte[total];
259
+ var offset = 0;
260
+ for (var d = 0; d < _masks.Length; d++)
261
+ {
262
+ for (var t = 0; t < _masks[d].Length; t++)
261
263
  {
262
- flat[d * NumTransducers + t] = (byte)(_masks[d][t] ? 1 : 0);
264
+ flat[offset + t] = (byte)(_masks[d][t] ? 1 : 0);
263
265
  }
266
+ offset += _masks[d].Length;
264
267
  }
265
- return NativeCommand.autd3_op_set_output_mask(flat, (UIntPtr)_masks.Length);
268
+ return NativeCommand.autd3_op_set_output_mask(flat, lens, (UIntPtr)_masks.Length);
266
269
  }
267
270
  }
268
271
 
@@ -339,8 +342,6 @@ namespace AUTD3
339
342
 
340
343
  public sealed class SetPhaseCorrection : ICommand
341
344
  {
342
- private const int NumTransducers = 249;
343
-
344
345
  private readonly Phase[][] _phases;
345
346
 
346
347
  public SetPhaseCorrection(Phase[][] phases)
@@ -350,19 +351,24 @@ namespace AUTD3
350
351
 
351
352
  IntPtr ICommand.CreateOp()
352
353
  {
353
- var flat = new byte[_phases.Length * NumTransducers];
354
+ var lens = new UIntPtr[_phases.Length];
355
+ var total = 0;
354
356
  for (var d = 0; d < _phases.Length; d++)
355
357
  {
356
- if (_phases[d].Length != NumTransducers)
357
- {
358
- throw new Autd3Exception($"each device phase correction requires {NumTransducers} values");
359
- }
360
- for (var t = 0; t < NumTransducers; t++)
358
+ lens[d] = (UIntPtr)_phases[d].Length;
359
+ total += _phases[d].Length;
360
+ }
361
+ var flat = new byte[total];
362
+ var offset = 0;
363
+ for (var d = 0; d < _phases.Length; d++)
364
+ {
365
+ for (var t = 0; t < _phases[d].Length; t++)
361
366
  {
362
- flat[d * NumTransducers + t] = _phases[d][t].Value;
367
+ flat[offset + t] = _phases[d][t].Value;
363
368
  }
369
+ offset += _phases[d].Length;
364
370
  }
365
- return NativeCommand.autd3_op_set_phase_correction(flat, (UIntPtr)_phases.Length);
371
+ return NativeCommand.autd3_op_set_phase_correction(flat, lens, (UIntPtr)_phases.Length);
366
372
  }
367
373
  }
368
374
  }
package/Datagram.cs CHANGED
@@ -11,7 +11,6 @@ namespace AUTD3
11
11
  public bool LowLatency { get; }
12
12
  public uint TimeoutCycles { get; }
13
13
  public uint MaxInflight { get; }
14
- public uint SendIntervalCycles { get; }
15
14
  public uint MaxResyncRounds { get; }
16
15
  public uint ResetResendCycles { get; }
17
16
  public byte? RtPriority { get; }
@@ -26,7 +25,6 @@ namespace AUTD3
26
25
  bool lowLatency = false,
27
26
  uint timeoutCycles = 10,
28
27
  uint maxInflight = 127,
29
- uint sendIntervalCycles = 1,
30
28
  uint maxResyncRounds = 8,
31
29
  uint resetResendCycles = 2,
32
30
  byte? rtPriority = null,
@@ -36,7 +34,6 @@ namespace AUTD3
36
34
  LowLatency = lowLatency;
37
35
  TimeoutCycles = timeoutCycles;
38
36
  MaxInflight = maxInflight;
39
- SendIntervalCycles = sendIntervalCycles;
40
37
  MaxResyncRounds = maxResyncRounds;
41
38
  ResetResendCycles = resetResendCycles;
42
39
  RtPriority = rtPriority;
@@ -50,7 +47,6 @@ namespace AUTD3
50
47
  LowLatency,
51
48
  TimeoutCycles,
52
49
  (UIntPtr)MaxInflight,
53
- SendIntervalCycles,
54
50
  MaxResyncRounds,
55
51
  ResetResendCycles,
56
52
  RtPriority.HasValue,
@@ -68,19 +64,20 @@ namespace AUTD3
68
64
 
69
65
  public sealed class DatagramBuilder : IDisposable
70
66
  {
67
+ private readonly Geometry _geometry;
71
68
  private readonly int _numDevices;
72
69
 
73
70
  internal IntPtr Handle { get; private set; }
74
71
 
75
- internal DatagramBuilder(int numDevices)
76
- {
77
- _numDevices = numDevices;
78
- Handle = NativeClient.autd3_datagram_builder_new((UIntPtr)numDevices);
79
- }
80
-
81
-
82
- public DatagramBuilder(Geometry geometry) : this(geometry.NumDevices)
72
+ public DatagramBuilder(Geometry geometry)
83
73
  {
74
+ _geometry = geometry;
75
+ _numDevices = geometry.NumDevices;
76
+ Handle = NativeClient.autd3_datagram_builder_new(geometry.Handle);
77
+ if (Handle == IntPtr.Zero)
78
+ {
79
+ throw new Autd3Exception("failed to create datagram builder");
80
+ }
84
81
  }
85
82
 
86
83
  public DatagramBuilder Push(ICommand command)
@@ -90,14 +87,14 @@ namespace AUTD3
90
87
  return this;
91
88
  }
92
89
 
93
- public DatagramBuilder PushEach(Func<int, ICommand?> factory)
90
+ public DatagramBuilder PushEach(Func<Device, ICommand?> factory)
94
91
  {
95
92
  var ops = new IntPtr[_numDevices];
96
93
  try
97
94
  {
98
95
  for (var i = 0; i < _numDevices; i++)
99
96
  {
100
- var command = factory(i);
97
+ var command = factory(_geometry[i]);
101
98
  ops[i] = command == null ? IntPtr.Zero : command.CreateOp();
102
99
  }
103
100
  }
package/Native.cs CHANGED
@@ -17,7 +17,6 @@ namespace AUTD3
17
17
  [MarshalAs(UnmanagedType.I1)] bool lowLatency,
18
18
  uint timeoutCycles,
19
19
  UIntPtr maxInflight,
20
- uint sendIntervalCycles,
21
20
  uint maxResyncRounds,
22
21
  uint resetResendCycles,
23
22
  [MarshalAs(UnmanagedType.I1)] bool hasRtPriority,
@@ -30,7 +29,7 @@ namespace AUTD3
30
29
  internal static extern void autd3_client_config_free(IntPtr config);
31
30
 
32
31
  [DllImport(Lib)]
33
- internal static extern IntPtr autd3_datagram_builder_new(UIntPtr numDevices);
32
+ internal static extern IntPtr autd3_datagram_builder_new(IntPtr geometry);
34
33
 
35
34
  [DllImport(Lib)]
36
35
  internal static extern void autd3_datagram_builder_push(IntPtr builder, IntPtr op);
@@ -93,6 +92,9 @@ namespace AUTD3
93
92
  [DllImport(Lib)]
94
93
  internal static extern void autd3_client_read_error_detail(IntPtr client, CompletionCallback cb, IntPtr userData);
95
94
 
95
+ [DllImport(Lib)]
96
+ internal static extern void autd3_client_read_telemetry(IntPtr client, byte counter, CompletionCallback cb, IntPtr userData);
97
+
96
98
  [DllImport(Lib)]
97
99
  internal static extern UIntPtr autd3_byte_array_len(IntPtr array);
98
100
 
Binary file
Binary file
package/Stm.cs CHANGED
@@ -40,17 +40,20 @@ namespace AUTD3
40
40
  [DllImport(Lib)]
41
41
  internal static extern IntPtr autd3_stm_config_sampling(ushort divide);
42
42
 
43
+ [DllImport(Lib)]
44
+ internal static extern int autd3_stm_config_into_sampling_config(IntPtr config, UIntPtr size, out ushort @out);
45
+
43
46
  [DllImport(Lib)]
44
47
  internal static extern void autd3_stm_config_free(IntPtr config);
45
48
 
46
49
  [DllImport(Lib)]
47
- internal static extern IntPtr autd3_op_foci_stm(IntPtr config, Autd3StmControlPointNative[] points, UIntPtr numSamples, byte numFoci, byte[] intensities, byte bank, float soundSpeedMS, ushort loopRep, byte transitionMode, ulong transitionValue);
50
+ internal static extern IntPtr autd3_op_foci_stm(IntPtr config, Autd3StmControlPointNative[] points, UIntPtr numSamples, byte numFoci, byte[] intensities, byte bank, float soundSpeedMS, ushort loopRep, byte transitionMode, ulong transitionValue, uint transitionMarginNs);
48
51
 
49
52
  [DllImport(Lib)]
50
53
  internal static extern IntPtr autd3_op_write_foci_buffer(byte bank, uint indexOffset, Autd3StmControlPointNative[] points, UIntPtr numSamples, byte numFoci, byte[] intensities);
51
54
 
52
55
  [DllImport(Lib)]
53
- internal static extern IntPtr autd3_op_pattern_stm(IntPtr config, IntPtr[] patterns, UIntPtr numPatterns, byte bank, byte mode, ushort loopRep, byte transitionMode, ulong transitionValue);
56
+ internal static extern IntPtr autd3_op_pattern_stm(IntPtr config, IntPtr[] patterns, UIntPtr numPatterns, byte bank, byte mode, ushort loopRep, byte transitionMode, ulong transitionValue, uint transitionMarginNs);
54
57
 
55
58
  [DllImport(Lib)]
56
59
  internal static extern int autd3_stm_circle(float[] center, float radiusMm, UIntPtr numPoints, float[] normal, byte intensity, Autd3StmControlPointNative[] outPoints, byte[] outIntensities);
@@ -101,6 +104,33 @@ namespace AUTD3
101
104
  {
102
105
  }
103
106
 
107
+ public static implicit operator StmConfig(Freq freq) => new StmConfig(freq);
108
+
109
+ public static implicit operator StmConfig(Nearest<Freq> freq) => new StmConfig(freq);
110
+
111
+ public static implicit operator StmConfig(TimeSpan period) => new StmConfig(period);
112
+
113
+ public static implicit operator StmConfig(Nearest<TimeSpan> period) => new StmConfig(period);
114
+
115
+ public static implicit operator StmConfig(SamplingConfig sampling) => new StmConfig(sampling);
116
+
117
+ public SamplingConfig IntoSamplingConfig(int size)
118
+ {
119
+ var handle = CreateHandle();
120
+ try
121
+ {
122
+ if (NativeStm.autd3_stm_config_into_sampling_config(handle, (UIntPtr)Math.Max(size, 1), out var divide) != 0)
123
+ {
124
+ throw new Autd3Exception("stm config cannot be resolved to a sampling config");
125
+ }
126
+ return new SamplingConfig(divide);
127
+ }
128
+ finally
129
+ {
130
+ NativeStm.autd3_stm_config_free(handle);
131
+ }
132
+ }
133
+
104
134
  internal IntPtr CreateHandle()
105
135
  {
106
136
  var handle = _kind switch
@@ -229,7 +259,7 @@ namespace AUTD3
229
259
  try
230
260
  {
231
261
  return NativeStm.autd3_op_foci_stm(configHandle, points, (UIntPtr)_points.Length, numFoci, intensities,
232
- (byte)_option.Bank, _option.SoundSpeed.MPerS, _option.LoopBehavior.Rep, _option.TransitionMode.Mode, _option.TransitionMode.Value);
262
+ (byte)_option.Bank, _option.SoundSpeed.MPerS, _option.LoopBehavior.Rep, _option.TransitionMode.Mode, _option.TransitionMode.Value, _option.TransitionMode.MarginNs);
233
263
  }
234
264
  finally
235
265
  {
@@ -262,7 +292,7 @@ namespace AUTD3
262
292
  try
263
293
  {
264
294
  return NativeStm.autd3_op_pattern_stm(configHandle, handles, (UIntPtr)handles.Length,
265
- (byte)_option.Bank, (byte)_option.Mode, _option.LoopBehavior.Rep, _option.TransitionMode.Mode, _option.TransitionMode.Value);
295
+ (byte)_option.Bank, (byte)_option.Mode, _option.LoopBehavior.Rep, _option.TransitionMode.Mode, _option.TransitionMode.Value, _option.TransitionMode.MarginNs);
266
296
  }
267
297
  finally
268
298
  {
@@ -5,7 +5,7 @@ The following is a list of those components and the full text of their licenses.
5
5
 
6
6
  ## Overview
7
7
 
8
- - MIT License (52)
8
+ - MIT License (53)
9
9
  - Apache License 2.0 (3)
10
10
  - Unicode License v3 (1)
11
11
 
@@ -886,10 +886,11 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
886
886
 
887
887
  Used by:
888
888
 
889
- - autd3-ffi 0.2.0 — https://github.com/shinolab/autd3-sdk
890
- - autd3-ffi-abi 0.2.0 — https://github.com/shinolab/autd3-sdk
891
- - autd3-rs 0.2.0 — https://github.com/shinolab/autd3-sdk
892
- - autd3-rs-core 0.2.0 — https://github.com/shinolab/autd3-sdk
889
+ - autd3-ffi 0.4.0 — https://github.com/shinolab/autd3-sdk
890
+ - autd3-ffi-abi 0.4.0 — https://github.com/shinolab/autd3-sdk
891
+ - autd3-rs 0.4.0 — https://github.com/shinolab/autd3-sdk
892
+ - autd3-rs-core 0.4.0 — https://github.com/shinolab/autd3-sdk
893
+ - autd3-cpu-wire 0.4.0 — https://github.com/shinolab/autd3-sdk
893
894
  - chrono 0.4.45 — https://github.com/chronotope/chrono
894
895
  - wide 1.5.0 — https://github.com/Lokathor/wide
895
896
  - winapi-i686-pc-windows-gnu 0.4.0 — https://github.com/retep998/winapi-rs
@@ -933,7 +934,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
933
934
 
934
935
  Used by:
935
936
 
936
- - tokio 1.52.3 — https://github.com/tokio-rs/tokio
937
+ - tokio 1.53.0 — https://github.com/tokio-rs/tokio
937
938
 
938
939
  ```
939
940
  MIT License
package/package.json CHANGED
@@ -1,6 +1,11 @@
1
1
  {
2
2
  "name": "com.shinolab.autd3-sdk",
3
- "version": "0.2.0",
3
+ "repository": {
4
+ "type": "git",
5
+ "url": "git+https://github.com/shinolab/autd3-sdk.git",
6
+ "directory": "bindings/unity/com.shinolab.autd3-sdk"
7
+ },
8
+ "version": "0.4.0",
4
9
  "displayName": "AUTD3",
5
10
  "description": "AUTD3 client, datagrams and STM (Unity binding).",
6
11
  "unity": "6000.0",
@@ -10,9 +15,9 @@
10
15
  "url": "https://github.com/shinolab"
11
16
  },
12
17
  "dependencies": {
13
- "com.shinolab.autd3-sdk.core": "0.2.0",
14
- "com.shinolab.autd3-sdk.pattern": "0.2.0",
15
- "com.shinolab.autd3-sdk.modulation": "0.2.0"
18
+ "com.shinolab.autd3-sdk.core": "0.4.0",
19
+ "com.shinolab.autd3-sdk.pattern": "0.4.0",
20
+ "com.shinolab.autd3-sdk.modulation": "0.4.0"
16
21
  },
17
22
  "samples": [
18
23
  {