com.shinolab.autd3-sdk 0.3.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
@@ -224,9 +224,12 @@ namespace AUTD3
224
224
 
225
225
  internal IntPtr Handle { get; private set; }
226
226
 
227
- private Client(IntPtr handle)
227
+ private readonly Geometry _geometry;
228
+
229
+ private Client(IntPtr handle, Geometry geometry)
228
230
  {
229
231
  Handle = handle;
232
+ _geometry = geometry;
230
233
  }
231
234
 
232
235
  public static async Task<Client> OpenAsync(Geometry geometry, ILink link, ClientConfig config)
@@ -246,7 +249,7 @@ namespace AUTD3
246
249
  NativeClient.autd3_client_config_free(configHandle);
247
250
  }
248
251
  var value = await task.ConfigureAwait(false);
249
- return new Client(value);
252
+ return new Client(value, geometry);
250
253
  }
251
254
 
252
255
  public static async Task<(Client Client, Checker Checker)> OpenWithCheckerAsync(Geometry geometry, ILink link, ClientConfig config)
@@ -264,7 +267,7 @@ namespace AUTD3
264
267
  public int NumDevices => (int)NativeClient.autd3_client_num_devices(Handle);
265
268
 
266
269
 
267
- public DatagramBuilder DatagramBuilder() => new DatagramBuilder(NumDevices);
270
+ public DatagramBuilder DatagramBuilder() => new DatagramBuilder(_geometry);
268
271
 
269
272
 
270
273
 
@@ -317,9 +320,6 @@ namespace AUTD3
317
320
  public Task<byte[]> ReadTelemetryAsync(Telemetry counter) =>
318
321
  ReadByteArrayAsync((cb, ud) => NativeClient.autd3_client_read_telemetry(Handle, (byte)counter, cb, ud));
319
322
 
320
- public Task<byte[]> ReadFpgaFunctionsAsync() =>
321
- ReadByteArrayAsync((cb, ud) => NativeClient.autd3_client_read_fpga_functions(Handle, cb, ud));
322
-
323
323
  internal static async Task<byte[]> ReadByteArrayAsync(Action<CompletionCallback, IntPtr> invoke)
324
324
  {
325
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);
@@ -96,9 +95,6 @@ namespace AUTD3
96
95
  [DllImport(Lib)]
97
96
  internal static extern void autd3_client_read_telemetry(IntPtr client, byte counter, CompletionCallback cb, IntPtr userData);
98
97
 
99
- [DllImport(Lib)]
100
- internal static extern void autd3_client_read_fpga_functions(IntPtr client, CompletionCallback cb, IntPtr userData);
101
-
102
98
  [DllImport(Lib)]
103
99
  internal static extern UIntPtr autd3_byte_array_len(IntPtr array);
104
100
 
Binary file
Binary file
@@ -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.3.0 — https://github.com/shinolab/autd3-sdk
890
- - autd3-ffi-abi 0.3.0 — https://github.com/shinolab/autd3-sdk
891
- - autd3-rs 0.3.0 — https://github.com/shinolab/autd3-sdk
892
- - autd3-rs-core 0.3.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
@@ -5,7 +5,7 @@
5
5
  "url": "git+https://github.com/shinolab/autd3-sdk.git",
6
6
  "directory": "bindings/unity/com.shinolab.autd3-sdk"
7
7
  },
8
- "version": "0.3.0",
8
+ "version": "0.4.0",
9
9
  "displayName": "AUTD3",
10
10
  "description": "AUTD3 client, datagrams and STM (Unity binding).",
11
11
  "unity": "6000.0",
@@ -15,9 +15,9 @@
15
15
  "url": "https://github.com/shinolab"
16
16
  },
17
17
  "dependencies": {
18
- "com.shinolab.autd3-sdk.core": "0.3.0",
19
- "com.shinolab.autd3-sdk.pattern": "0.3.0",
20
- "com.shinolab.autd3-sdk.modulation": "0.3.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"
21
21
  },
22
22
  "samples": [
23
23
  {