com.shinolab.autd3-sdk 0.6.1 → 0.7.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 +11 -50
- package/Commands.cs +16 -17
- package/Datagram.cs +15 -48
- package/Legacy.cs +21 -72
- package/Native.cs +108 -108
- package/Plugins/linux-x64/libautd3capi.so +0 -0
- package/Plugins/osx-arm64/libautd3capi.dylib +0 -0
- package/Plugins/win-x64/autd3capi.dll +0 -0
- package/SafeHandles.cs +95 -0
- package/SafeHandles.cs.meta +11 -0
- package/Stm.cs +17 -16
- package/THIRD-PARTY-LICENSES.md +36 -5
- package/package.json +4 -4
package/Client.cs
CHANGED
|
@@ -103,18 +103,17 @@ namespace AUTD3
|
|
|
103
103
|
|
|
104
104
|
public sealed class Checker : IDisposable
|
|
105
105
|
{
|
|
106
|
-
private
|
|
106
|
+
private readonly CheckerHandle _handle;
|
|
107
107
|
|
|
108
108
|
internal Checker(IntPtr handle)
|
|
109
109
|
{
|
|
110
|
-
_handle = handle;
|
|
110
|
+
_handle = new CheckerHandle(handle);
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
public async Task<LinkStatus> CheckAsync()
|
|
114
114
|
{
|
|
115
|
-
var handle = _handle;
|
|
116
115
|
var status = await AsyncOps.InvokeAsync((cb, ud) =>
|
|
117
|
-
NativeClient.autd3_checker_check(
|
|
116
|
+
NativeClient.autd3_checker_check(_handle, cb, ud)).ConfigureAwait(false);
|
|
118
117
|
try
|
|
119
118
|
{
|
|
120
119
|
var count = (int)NativeClient.autd3_link_status_num_devices(status);
|
|
@@ -135,24 +134,7 @@ namespace AUTD3
|
|
|
135
134
|
}
|
|
136
135
|
}
|
|
137
136
|
|
|
138
|
-
public void Dispose()
|
|
139
|
-
{
|
|
140
|
-
var handle = Interlocked.Exchange(ref _handle, IntPtr.Zero);
|
|
141
|
-
if (handle != IntPtr.Zero)
|
|
142
|
-
{
|
|
143
|
-
NativeClient.autd3_checker_free(handle);
|
|
144
|
-
}
|
|
145
|
-
GC.SuppressFinalize(this);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
~Checker()
|
|
149
|
-
{
|
|
150
|
-
var handle = Interlocked.Exchange(ref _handle, IntPtr.Zero);
|
|
151
|
-
if (handle != IntPtr.Zero)
|
|
152
|
-
{
|
|
153
|
-
NativeClient.autd3_checker_free(handle);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
137
|
+
public void Dispose() => _handle.Dispose();
|
|
156
138
|
}
|
|
157
139
|
|
|
158
140
|
public sealed class Response
|
|
@@ -224,15 +206,14 @@ namespace AUTD3
|
|
|
224
206
|
{
|
|
225
207
|
public const int MaxInflight = 127;
|
|
226
208
|
|
|
227
|
-
private
|
|
228
|
-
|
|
229
|
-
internal IntPtr Handle => _handle;
|
|
230
|
-
|
|
209
|
+
private readonly ClientHandle _handle;
|
|
231
210
|
private readonly Geometry _geometry;
|
|
232
211
|
|
|
233
|
-
|
|
212
|
+
internal ClientHandle Handle => _handle;
|
|
213
|
+
|
|
214
|
+
internal Client(IntPtr handle, Geometry geometry)
|
|
234
215
|
{
|
|
235
|
-
_handle = handle;
|
|
216
|
+
_handle = new ClientHandle(handle);
|
|
236
217
|
_geometry = geometry;
|
|
237
218
|
}
|
|
238
219
|
|
|
@@ -279,10 +260,7 @@ namespace AUTD3
|
|
|
279
260
|
|
|
280
261
|
public int NumDevices => (int)NativeClient.autd3_client_num_devices(Handle);
|
|
281
262
|
|
|
282
|
-
|
|
283
|
-
public DatagramBuilder DatagramBuilder() => new DatagramBuilder(_geometry, Handle);
|
|
284
|
-
|
|
285
|
-
|
|
263
|
+
public DatagramBuilder DatagramBuilder() => new DatagramBuilder(_geometry, this);
|
|
286
264
|
|
|
287
265
|
public Task SendCheckedAsync(Frame frame) =>
|
|
288
266
|
AsyncOps.InvokeAsync((cb, ud) =>
|
|
@@ -358,23 +336,6 @@ namespace AUTD3
|
|
|
358
336
|
public Task CloseAsync() =>
|
|
359
337
|
AsyncOps.InvokeAsync((cb, ud) => NativeClient.autd3_client_close(Handle, cb, ud));
|
|
360
338
|
|
|
361
|
-
public void Dispose()
|
|
362
|
-
{
|
|
363
|
-
var handle = Interlocked.Exchange(ref _handle, IntPtr.Zero);
|
|
364
|
-
if (handle != IntPtr.Zero)
|
|
365
|
-
{
|
|
366
|
-
NativeClient.autd3_client_free(handle);
|
|
367
|
-
}
|
|
368
|
-
GC.SuppressFinalize(this);
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
~Client()
|
|
372
|
-
{
|
|
373
|
-
var handle = Interlocked.Exchange(ref _handle, IntPtr.Zero);
|
|
374
|
-
if (handle != IntPtr.Zero)
|
|
375
|
-
{
|
|
376
|
-
NativeClient.autd3_client_free(handle);
|
|
377
|
-
}
|
|
378
|
-
}
|
|
339
|
+
public void Dispose() => _handle.Dispose();
|
|
379
340
|
}
|
|
380
341
|
}
|
package/Commands.cs
CHANGED
|
@@ -16,53 +16,53 @@ namespace AUTD3
|
|
|
16
16
|
|
|
17
17
|
static NativeCommand() => NativeAbi.Verify(Lib, autd3_abi_version());
|
|
18
18
|
|
|
19
|
-
[DllImport(Lib)]
|
|
19
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
20
20
|
private static extern uint autd3_abi_version();
|
|
21
21
|
|
|
22
|
-
[DllImport(Lib)]
|
|
22
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
23
23
|
internal static extern IntPtr autd3_op_clear();
|
|
24
24
|
|
|
25
|
-
[DllImport(Lib)]
|
|
25
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
26
26
|
internal static extern IntPtr autd3_op_synchronize();
|
|
27
27
|
|
|
28
|
-
[DllImport(Lib)]
|
|
28
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
29
29
|
internal static extern IntPtr autd3_op_nop();
|
|
30
30
|
|
|
31
|
-
[DllImport(Lib)]
|
|
31
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
32
32
|
internal static extern IntPtr autd3_op_force_fan([MarshalAs(UnmanagedType.I1)] bool value);
|
|
33
33
|
|
|
34
|
-
[DllImport(Lib)]
|
|
34
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
35
35
|
internal static extern IntPtr autd3_op_set_silencer_completion_time(ulong intensityNs, ulong phaseNs, [MarshalAs(UnmanagedType.I1)] bool strict);
|
|
36
36
|
|
|
37
|
-
[DllImport(Lib)]
|
|
37
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
38
38
|
internal static extern IntPtr autd3_op_set_silencer_update_rate(ushort intensity, ushort phase);
|
|
39
39
|
|
|
40
|
-
[DllImport(Lib)]
|
|
40
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
41
41
|
internal static extern IntPtr autd3_op_set_silencer_disable();
|
|
42
42
|
|
|
43
|
-
[DllImport(Lib)]
|
|
43
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
44
44
|
internal static extern IntPtr autd3_op_set_gpio_out(GpioOutNative[] outputs);
|
|
45
45
|
|
|
46
|
-
[DllImport(Lib)]
|
|
46
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
47
47
|
internal static extern IntPtr autd3_op_emulate_gpio_in(byte[] values);
|
|
48
48
|
|
|
49
|
-
[DllImport(Lib)]
|
|
49
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
50
50
|
internal static extern IntPtr autd3_op_set_output_mask(byte[] masks, UIntPtr[] lens, UIntPtr numDevices);
|
|
51
51
|
|
|
52
|
-
[DllImport(Lib)]
|
|
52
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
53
53
|
internal static extern IntPtr autd3_op_set_phase_correction(byte[] phases, UIntPtr[] lens, UIntPtr numDevices);
|
|
54
54
|
|
|
55
|
-
[DllImport(Lib)]
|
|
55
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
56
56
|
internal static extern IntPtr autd3_op_set_pulse_width_table(ushort[] table);
|
|
57
57
|
|
|
58
|
-
[DllImport(Lib)]
|
|
58
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
59
59
|
internal static extern void autd3_set_pulse_width_table_default_table([Out] ushort[] outTable);
|
|
60
60
|
|
|
61
|
-
[DllImport(Lib)]
|
|
61
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
62
62
|
[return: MarshalAs(UnmanagedType.I1)]
|
|
63
63
|
internal static extern bool autd3_pulse_width_from_duty(float duty, [Out] ushort[] outValue);
|
|
64
64
|
|
|
65
|
-
[DllImport(Lib)]
|
|
65
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
66
66
|
[return: MarshalAs(UnmanagedType.I1)]
|
|
67
67
|
internal static extern bool autd3_pulse_width_new(ushort pulseWidth, [Out] ushort[] outValue);
|
|
68
68
|
}
|
|
@@ -136,7 +136,6 @@ namespace AUTD3
|
|
|
136
136
|
|
|
137
137
|
public FixedCompletionTime(TimeSpan? intensity = null, TimeSpan? phase = null, bool strictMode = true)
|
|
138
138
|
{
|
|
139
|
-
// defaults: intensity = 25us * 10 = 250us, phase = 25us * 40 = 1000us
|
|
140
139
|
Intensity = intensity ?? TimeSpan.FromTicks(2500);
|
|
141
140
|
Phase = phase ?? TimeSpan.FromTicks(10000);
|
|
142
141
|
StrictMode = strictMode;
|
package/Datagram.cs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
using System;
|
|
2
|
-
using System.Threading;
|
|
3
2
|
using System.Collections;
|
|
4
3
|
using System.Collections.Generic;
|
|
5
4
|
|
|
@@ -117,26 +116,27 @@ namespace AUTD3
|
|
|
117
116
|
{
|
|
118
117
|
private readonly Geometry _geometry;
|
|
119
118
|
private readonly int _numDevices;
|
|
120
|
-
private readonly
|
|
119
|
+
private readonly Client? _client;
|
|
121
120
|
|
|
122
|
-
private
|
|
121
|
+
private readonly DatagramBuilderHandle _handle;
|
|
123
122
|
|
|
124
|
-
internal
|
|
123
|
+
internal DatagramBuilderHandle Handle => _handle;
|
|
125
124
|
|
|
126
|
-
public DatagramBuilder(Geometry geometry) : this(geometry,
|
|
125
|
+
public DatagramBuilder(Geometry geometry) : this(geometry, null)
|
|
127
126
|
{
|
|
128
127
|
}
|
|
129
128
|
|
|
130
|
-
internal DatagramBuilder(Geometry geometry,
|
|
129
|
+
internal DatagramBuilder(Geometry geometry, Client? client)
|
|
131
130
|
{
|
|
132
131
|
_geometry = geometry;
|
|
133
132
|
_numDevices = geometry.NumDevices;
|
|
134
133
|
_client = client;
|
|
135
|
-
|
|
136
|
-
if (
|
|
134
|
+
var handle = NativeClient.autd3_datagram_builder_new(geometry.Handle);
|
|
135
|
+
if (handle == IntPtr.Zero)
|
|
137
136
|
{
|
|
138
137
|
throw new Autd3Exception("failed to create datagram builder");
|
|
139
138
|
}
|
|
139
|
+
_handle = new DatagramBuilderHandle(handle);
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
public DatagramBuilder Push(ICommand command)
|
|
@@ -181,7 +181,8 @@ namespace AUTD3
|
|
|
181
181
|
public Frames Build()
|
|
182
182
|
{
|
|
183
183
|
var err = new byte[NativeAbi.ErrorBufferLength];
|
|
184
|
-
var
|
|
184
|
+
using var client = new HandleLease(_client?.Handle);
|
|
185
|
+
var handle = NativeClient.autd3_datagram_builder_build(Handle, client.Pointer, err, (UIntPtr)err.Length);
|
|
185
186
|
if (handle == IntPtr.Zero)
|
|
186
187
|
{
|
|
187
188
|
throw new Autd3Exception(NativeUtil.Utf8(err));
|
|
@@ -189,24 +190,7 @@ namespace AUTD3
|
|
|
189
190
|
return new Frames(handle);
|
|
190
191
|
}
|
|
191
192
|
|
|
192
|
-
public void Dispose()
|
|
193
|
-
{
|
|
194
|
-
var handle = Interlocked.Exchange(ref _handle, IntPtr.Zero);
|
|
195
|
-
if (handle != IntPtr.Zero)
|
|
196
|
-
{
|
|
197
|
-
NativeClient.autd3_datagram_builder_free(handle);
|
|
198
|
-
}
|
|
199
|
-
GC.SuppressFinalize(this);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
~DatagramBuilder()
|
|
203
|
-
{
|
|
204
|
-
var handle = Interlocked.Exchange(ref _handle, IntPtr.Zero);
|
|
205
|
-
if (handle != IntPtr.Zero)
|
|
206
|
-
{
|
|
207
|
-
NativeClient.autd3_datagram_builder_free(handle);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
193
|
+
public void Dispose() => _handle.Dispose();
|
|
210
194
|
}
|
|
211
195
|
|
|
212
196
|
|
|
@@ -224,13 +208,13 @@ namespace AUTD3
|
|
|
224
208
|
|
|
225
209
|
public sealed class Frames : IDisposable, IEnumerable<Frame>
|
|
226
210
|
{
|
|
227
|
-
private
|
|
211
|
+
private readonly FramesHandle _handle;
|
|
228
212
|
|
|
229
|
-
internal
|
|
213
|
+
internal FramesHandle Handle => _handle;
|
|
230
214
|
|
|
231
215
|
internal Frames(IntPtr handle)
|
|
232
216
|
{
|
|
233
|
-
_handle = handle;
|
|
217
|
+
_handle = new FramesHandle(handle);
|
|
234
218
|
}
|
|
235
219
|
|
|
236
220
|
public int Length => (int)NativeClient.autd3_datagrams_num_frames(Handle);
|
|
@@ -258,23 +242,6 @@ namespace AUTD3
|
|
|
258
242
|
|
|
259
243
|
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
|
260
244
|
|
|
261
|
-
public void Dispose()
|
|
262
|
-
{
|
|
263
|
-
var handle = Interlocked.Exchange(ref _handle, IntPtr.Zero);
|
|
264
|
-
if (handle != IntPtr.Zero)
|
|
265
|
-
{
|
|
266
|
-
NativeClient.autd3_datagrams_free(handle);
|
|
267
|
-
}
|
|
268
|
-
GC.SuppressFinalize(this);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
~Frames()
|
|
272
|
-
{
|
|
273
|
-
var handle = Interlocked.Exchange(ref _handle, IntPtr.Zero);
|
|
274
|
-
if (handle != IntPtr.Zero)
|
|
275
|
-
{
|
|
276
|
-
NativeClient.autd3_datagrams_free(handle);
|
|
277
|
-
}
|
|
278
|
-
}
|
|
245
|
+
public void Dispose() => _handle.Dispose();
|
|
279
246
|
}
|
|
280
247
|
}
|
package/Legacy.cs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
using System;
|
|
2
|
-
using System.Threading;
|
|
3
2
|
using System.Collections;
|
|
4
3
|
using System.Collections.Generic;
|
|
5
4
|
using System.Threading.Tasks;
|
|
@@ -96,26 +95,27 @@ namespace AUTD3.Legacy
|
|
|
96
95
|
{
|
|
97
96
|
private readonly Geometry _geometry;
|
|
98
97
|
private readonly int _numDevices;
|
|
99
|
-
private readonly
|
|
98
|
+
private readonly LegacyClient? _client;
|
|
100
99
|
|
|
101
|
-
private
|
|
100
|
+
private readonly LegacyDatagramBuilderHandle _handle;
|
|
102
101
|
|
|
103
|
-
internal
|
|
102
|
+
internal LegacyDatagramBuilderHandle Handle => _handle;
|
|
104
103
|
|
|
105
|
-
public LegacyDatagramBuilder(Geometry geometry) : this(geometry,
|
|
104
|
+
public LegacyDatagramBuilder(Geometry geometry) : this(geometry, null)
|
|
106
105
|
{
|
|
107
106
|
}
|
|
108
107
|
|
|
109
|
-
internal LegacyDatagramBuilder(Geometry geometry,
|
|
108
|
+
internal LegacyDatagramBuilder(Geometry geometry, LegacyClient? client)
|
|
110
109
|
{
|
|
111
110
|
_geometry = geometry;
|
|
112
111
|
_numDevices = geometry.NumDevices;
|
|
113
112
|
_client = client;
|
|
114
|
-
|
|
115
|
-
if (
|
|
113
|
+
var handle = NativeLegacyClient.autd3_legacy_datagram_builder_new(geometry.Handle);
|
|
114
|
+
if (handle == IntPtr.Zero)
|
|
116
115
|
{
|
|
117
116
|
throw new Autd3Exception("failed to create legacy datagram builder");
|
|
118
117
|
}
|
|
118
|
+
_handle = new LegacyDatagramBuilderHandle(handle);
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
public LegacyDatagramBuilder Push(ICommand command)
|
|
@@ -170,7 +170,8 @@ namespace AUTD3.Legacy
|
|
|
170
170
|
public LegacyFrames Build()
|
|
171
171
|
{
|
|
172
172
|
var err = new byte[NativeAbi.ErrorBufferLength];
|
|
173
|
-
var
|
|
173
|
+
using var client = new HandleLease(_client?.Handle);
|
|
174
|
+
var handle = NativeLegacyClient.autd3_legacy_datagram_builder_build(Handle, client.Pointer, err, (UIntPtr)err.Length);
|
|
174
175
|
if (handle == IntPtr.Zero)
|
|
175
176
|
{
|
|
176
177
|
throw new Autd3Exception(NativeUtil.Utf8(err));
|
|
@@ -178,24 +179,7 @@ namespace AUTD3.Legacy
|
|
|
178
179
|
return new LegacyFrames(handle);
|
|
179
180
|
}
|
|
180
181
|
|
|
181
|
-
public void Dispose()
|
|
182
|
-
{
|
|
183
|
-
var handle = Interlocked.Exchange(ref _handle, IntPtr.Zero);
|
|
184
|
-
if (handle != IntPtr.Zero)
|
|
185
|
-
{
|
|
186
|
-
NativeLegacyClient.autd3_legacy_datagram_builder_free(handle);
|
|
187
|
-
}
|
|
188
|
-
GC.SuppressFinalize(this);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
~LegacyDatagramBuilder()
|
|
192
|
-
{
|
|
193
|
-
var handle = Interlocked.Exchange(ref _handle, IntPtr.Zero);
|
|
194
|
-
if (handle != IntPtr.Zero)
|
|
195
|
-
{
|
|
196
|
-
NativeLegacyClient.autd3_legacy_datagram_builder_free(handle);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
182
|
+
public void Dispose() => _handle.Dispose();
|
|
199
183
|
}
|
|
200
184
|
|
|
201
185
|
public readonly struct LegacyFrame
|
|
@@ -212,13 +196,13 @@ namespace AUTD3.Legacy
|
|
|
212
196
|
|
|
213
197
|
public sealed class LegacyFrames : IDisposable, IEnumerable<LegacyFrame>
|
|
214
198
|
{
|
|
215
|
-
private
|
|
199
|
+
private readonly LegacyFramesHandle _handle;
|
|
216
200
|
|
|
217
|
-
internal
|
|
201
|
+
internal LegacyFramesHandle Handle => _handle;
|
|
218
202
|
|
|
219
203
|
internal LegacyFrames(IntPtr handle)
|
|
220
204
|
{
|
|
221
|
-
_handle = handle;
|
|
205
|
+
_handle = new LegacyFramesHandle(handle);
|
|
222
206
|
}
|
|
223
207
|
|
|
224
208
|
public int Length => (int)NativeLegacyClient.autd3_legacy_frames_num_frames(Handle);
|
|
@@ -246,37 +230,19 @@ namespace AUTD3.Legacy
|
|
|
246
230
|
|
|
247
231
|
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
|
248
232
|
|
|
249
|
-
public void Dispose()
|
|
250
|
-
{
|
|
251
|
-
var handle = Interlocked.Exchange(ref _handle, IntPtr.Zero);
|
|
252
|
-
if (handle != IntPtr.Zero)
|
|
253
|
-
{
|
|
254
|
-
NativeLegacyClient.autd3_legacy_frames_free(handle);
|
|
255
|
-
}
|
|
256
|
-
GC.SuppressFinalize(this);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
~LegacyFrames()
|
|
260
|
-
{
|
|
261
|
-
var handle = Interlocked.Exchange(ref _handle, IntPtr.Zero);
|
|
262
|
-
if (handle != IntPtr.Zero)
|
|
263
|
-
{
|
|
264
|
-
NativeLegacyClient.autd3_legacy_frames_free(handle);
|
|
265
|
-
}
|
|
266
|
-
}
|
|
233
|
+
public void Dispose() => _handle.Dispose();
|
|
267
234
|
}
|
|
268
235
|
|
|
269
236
|
public sealed class LegacyClient : IDisposable
|
|
270
237
|
{
|
|
271
|
-
private
|
|
272
|
-
|
|
273
|
-
internal IntPtr Handle => _handle;
|
|
274
|
-
|
|
238
|
+
private readonly LegacyClientHandle _handle;
|
|
275
239
|
private readonly Geometry _geometry;
|
|
276
240
|
|
|
241
|
+
internal LegacyClientHandle Handle => _handle;
|
|
242
|
+
|
|
277
243
|
private LegacyClient(IntPtr handle, Geometry geometry)
|
|
278
244
|
{
|
|
279
|
-
_handle = handle;
|
|
245
|
+
_handle = new LegacyClientHandle(handle);
|
|
280
246
|
_geometry = geometry;
|
|
281
247
|
}
|
|
282
248
|
|
|
@@ -323,7 +289,7 @@ namespace AUTD3.Legacy
|
|
|
323
289
|
|
|
324
290
|
public int NumDevices => (int)NativeLegacyClient.autd3_legacy_client_num_devices(Handle);
|
|
325
291
|
|
|
326
|
-
public LegacyDatagramBuilder DatagramBuilder() => new LegacyDatagramBuilder(_geometry,
|
|
292
|
+
public LegacyDatagramBuilder DatagramBuilder() => new LegacyDatagramBuilder(_geometry, this);
|
|
327
293
|
|
|
328
294
|
public Task SendCheckedAsync(LegacyFrame frame) =>
|
|
329
295
|
AsyncOps.InvokeAsync((cb, ud) =>
|
|
@@ -371,23 +337,6 @@ namespace AUTD3.Legacy
|
|
|
371
337
|
public Task CloseAsync() =>
|
|
372
338
|
AsyncOps.InvokeAsync((cb, ud) => NativeLegacyClient.autd3_legacy_client_close(Handle, cb, ud));
|
|
373
339
|
|
|
374
|
-
public void Dispose()
|
|
375
|
-
{
|
|
376
|
-
var handle = Interlocked.Exchange(ref _handle, IntPtr.Zero);
|
|
377
|
-
if (handle != IntPtr.Zero)
|
|
378
|
-
{
|
|
379
|
-
NativeLegacyClient.autd3_legacy_client_free(handle);
|
|
380
|
-
}
|
|
381
|
-
GC.SuppressFinalize(this);
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
~LegacyClient()
|
|
385
|
-
{
|
|
386
|
-
var handle = Interlocked.Exchange(ref _handle, IntPtr.Zero);
|
|
387
|
-
if (handle != IntPtr.Zero)
|
|
388
|
-
{
|
|
389
|
-
NativeLegacyClient.autd3_legacy_client_free(handle);
|
|
390
|
-
}
|
|
391
|
-
}
|
|
340
|
+
public void Dispose() => _handle.Dispose();
|
|
392
341
|
}
|
|
393
342
|
}
|
package/Native.cs
CHANGED
|
@@ -14,153 +14,153 @@ namespace AUTD3
|
|
|
14
14
|
|
|
15
15
|
static NativeClient() => NativeAbi.Verify(Lib, autd3_abi_version());
|
|
16
16
|
|
|
17
|
-
[DllImport(Lib)]
|
|
17
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
18
18
|
private static extern uint autd3_abi_version();
|
|
19
19
|
|
|
20
|
-
[DllImport(Lib)]
|
|
20
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
21
21
|
internal static extern IntPtr autd3_client_config_new();
|
|
22
22
|
|
|
23
|
-
[DllImport(Lib)]
|
|
23
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
24
24
|
internal static extern int autd3_client_config_set_low_latency(IntPtr config, [MarshalAs(UnmanagedType.I1)] bool value);
|
|
25
25
|
|
|
26
|
-
[DllImport(Lib)]
|
|
26
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
27
27
|
internal static extern int autd3_client_config_set_validate_state(IntPtr config, [MarshalAs(UnmanagedType.I1)] bool value);
|
|
28
28
|
|
|
29
|
-
[DllImport(Lib)]
|
|
29
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
30
30
|
internal static extern int autd3_client_config_set_require_supported_firmware(IntPtr config, [MarshalAs(UnmanagedType.I1)] bool value);
|
|
31
31
|
|
|
32
|
-
[DllImport(Lib)]
|
|
32
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
33
33
|
internal static extern int autd3_client_config_set_timeout_cycles(IntPtr config, uint value);
|
|
34
34
|
|
|
35
|
-
[DllImport(Lib)]
|
|
35
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
36
36
|
internal static extern int autd3_client_config_set_max_inflight(IntPtr config, UIntPtr value);
|
|
37
37
|
|
|
38
|
-
[DllImport(Lib)]
|
|
38
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
39
39
|
internal static extern int autd3_client_config_set_max_resync_rounds(IntPtr config, uint value);
|
|
40
40
|
|
|
41
|
-
[DllImport(Lib)]
|
|
41
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
42
42
|
internal static extern int autd3_client_config_set_reset_resend_cycles(IntPtr config, uint value);
|
|
43
43
|
|
|
44
|
-
[DllImport(Lib)]
|
|
44
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
45
45
|
internal static extern int autd3_client_config_set_rt_priority(IntPtr config, byte mode, byte value);
|
|
46
46
|
|
|
47
|
-
[DllImport(Lib)]
|
|
47
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
48
48
|
internal static extern int autd3_client_config_set_rt_policy(IntPtr config, byte value);
|
|
49
49
|
|
|
50
|
-
[DllImport(Lib)]
|
|
50
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
51
51
|
internal static extern int autd3_client_config_set_rt_affinity(IntPtr config, [MarshalAs(UnmanagedType.I1)] bool hasAffinity, UIntPtr coreId);
|
|
52
52
|
|
|
53
|
-
[DllImport(Lib)]
|
|
53
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
54
54
|
internal static extern void autd3_client_config_free(IntPtr config);
|
|
55
55
|
|
|
56
|
-
[DllImport(Lib)]
|
|
56
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
57
57
|
internal static extern void autd3_client_opener_free(IntPtr opener);
|
|
58
58
|
|
|
59
|
-
[DllImport(Lib)]
|
|
60
|
-
internal static extern IntPtr autd3_datagram_builder_new(
|
|
59
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
60
|
+
internal static extern IntPtr autd3_datagram_builder_new(GeometryHandle geometry);
|
|
61
61
|
|
|
62
|
-
[DllImport(Lib)]
|
|
63
|
-
internal static extern int autd3_datagram_builder_push(
|
|
62
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
63
|
+
internal static extern int autd3_datagram_builder_push(DatagramBuilderHandle builder, IntPtr op);
|
|
64
64
|
|
|
65
|
-
[DllImport(Lib)]
|
|
66
|
-
internal static extern int autd3_datagram_builder_push_each(
|
|
65
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
66
|
+
internal static extern int autd3_datagram_builder_push_each(DatagramBuilderHandle builder, IntPtr[] ops, UIntPtr numDevices);
|
|
67
67
|
|
|
68
|
-
[DllImport(Lib)]
|
|
68
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
69
69
|
internal static extern void autd3_op_free(IntPtr op);
|
|
70
70
|
|
|
71
|
-
[DllImport(Lib)]
|
|
71
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
72
72
|
internal static extern void autd3_datagram_builder_free(IntPtr builder);
|
|
73
73
|
|
|
74
|
-
[DllImport(Lib)]
|
|
75
|
-
internal static extern IntPtr autd3_datagram_builder_build(
|
|
74
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
75
|
+
internal static extern IntPtr autd3_datagram_builder_build(DatagramBuilderHandle builder, IntPtr client, byte[] outErr, UIntPtr outErrLen);
|
|
76
76
|
|
|
77
|
-
[DllImport(Lib)]
|
|
78
|
-
internal static extern UIntPtr autd3_datagrams_num_frames(
|
|
77
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
78
|
+
internal static extern UIntPtr autd3_datagrams_num_frames(FramesHandle datagrams);
|
|
79
79
|
|
|
80
|
-
[DllImport(Lib)]
|
|
80
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
81
81
|
internal static extern void autd3_datagrams_free(IntPtr datagrams);
|
|
82
82
|
|
|
83
|
-
[DllImport(Lib)]
|
|
84
|
-
internal static extern void autd3_client_open(
|
|
83
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
84
|
+
internal static extern void autd3_client_open(GeometryHandle geometry, IntPtr link, IntPtr config, CompletionCallback cb, IntPtr userData);
|
|
85
85
|
|
|
86
|
-
[DllImport(Lib)]
|
|
87
|
-
internal static extern UIntPtr autd3_client_num_devices(
|
|
86
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
87
|
+
internal static extern UIntPtr autd3_client_num_devices(ClientHandle client);
|
|
88
88
|
|
|
89
|
-
[DllImport(Lib)]
|
|
90
|
-
internal static extern void autd3_client_send_checked(
|
|
89
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
90
|
+
internal static extern void autd3_client_send_checked(ClientHandle client, FramesHandle datagrams, long frame, CompletionCallback cb, IntPtr userData);
|
|
91
91
|
|
|
92
|
-
[DllImport(Lib)]
|
|
93
|
-
internal static extern void autd3_client_send(
|
|
92
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
93
|
+
internal static extern void autd3_client_send(ClientHandle client, FramesHandle datagrams, long frame, CompletionCallback cb, IntPtr userData);
|
|
94
94
|
|
|
95
|
-
[DllImport(Lib)]
|
|
95
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
96
96
|
internal static extern void autd3_response_token_await(IntPtr token, CompletionCallback cb, IntPtr userData);
|
|
97
97
|
|
|
98
|
-
[DllImport(Lib)]
|
|
98
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
99
99
|
internal static extern void autd3_response_token_free(IntPtr token);
|
|
100
100
|
|
|
101
|
-
[DllImport(Lib)]
|
|
101
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
102
102
|
[return: MarshalAs(UnmanagedType.I1)]
|
|
103
103
|
internal static extern bool autd3_response_check(byte[] data, UIntPtr len, byte[] outErr, UIntPtr outErrLen);
|
|
104
104
|
|
|
105
|
-
[DllImport(Lib)]
|
|
106
|
-
internal static extern void autd3_client_stop(
|
|
105
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
106
|
+
internal static extern void autd3_client_stop(ClientHandle client, CompletionCallback cb, IntPtr userData);
|
|
107
107
|
|
|
108
|
-
[DllImport(Lib)]
|
|
109
|
-
internal static extern void autd3_client_close(
|
|
108
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
109
|
+
internal static extern void autd3_client_close(ClientHandle client, CompletionCallback cb, IntPtr userData);
|
|
110
110
|
|
|
111
|
-
[DllImport(Lib)]
|
|
111
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
112
112
|
internal static extern void autd3_client_free(IntPtr client);
|
|
113
113
|
|
|
114
|
-
[DllImport(Lib)]
|
|
115
|
-
internal static extern void autd3_client_read_firmware_version(
|
|
114
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
115
|
+
internal static extern void autd3_client_read_firmware_version(ClientHandle client, CompletionCallback cb, IntPtr userData);
|
|
116
116
|
|
|
117
|
-
[DllImport(Lib)]
|
|
118
|
-
internal static extern void autd3_client_read_fpga_state(
|
|
117
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
118
|
+
internal static extern void autd3_client_read_fpga_state(ClientHandle client, CompletionCallback cb, IntPtr userData);
|
|
119
119
|
|
|
120
|
-
[DllImport(Lib)]
|
|
121
|
-
internal static extern void autd3_client_read_error_detail(
|
|
120
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
121
|
+
internal static extern void autd3_client_read_error_detail(ClientHandle client, CompletionCallback cb, IntPtr userData);
|
|
122
122
|
|
|
123
|
-
[DllImport(Lib)]
|
|
124
|
-
internal static extern void autd3_client_read_telemetry(
|
|
123
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
124
|
+
internal static extern void autd3_client_read_telemetry(ClientHandle client, byte counter, CompletionCallback cb, IntPtr userData);
|
|
125
125
|
|
|
126
|
-
[DllImport(Lib)]
|
|
126
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
127
127
|
internal static extern UIntPtr autd3_byte_array_len(IntPtr array);
|
|
128
128
|
|
|
129
|
-
[DllImport(Lib)]
|
|
129
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
130
130
|
internal static extern IntPtr autd3_byte_array_data(IntPtr array);
|
|
131
131
|
|
|
132
|
-
[DllImport(Lib)]
|
|
132
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
133
133
|
internal static extern void autd3_byte_array_free(IntPtr array);
|
|
134
134
|
|
|
135
|
-
[DllImport(Lib)]
|
|
135
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
136
136
|
internal static extern UIntPtr autd3_string_array_len(IntPtr array);
|
|
137
137
|
|
|
138
|
-
[DllImport(Lib)]
|
|
138
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
139
139
|
internal static extern IntPtr autd3_string_array_get(IntPtr array, UIntPtr index);
|
|
140
140
|
|
|
141
|
-
[DllImport(Lib)]
|
|
141
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
142
142
|
internal static extern void autd3_string_array_free(IntPtr array);
|
|
143
143
|
|
|
144
|
-
[DllImport(Lib)]
|
|
145
|
-
internal static extern IntPtr autd3_client_checker(
|
|
144
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
145
|
+
internal static extern IntPtr autd3_client_checker(ClientHandle client);
|
|
146
146
|
|
|
147
|
-
[DllImport(Lib)]
|
|
148
|
-
internal static extern void autd3_checker_check(
|
|
147
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
148
|
+
internal static extern void autd3_checker_check(CheckerHandle checker, CompletionCallback cb, IntPtr userData);
|
|
149
149
|
|
|
150
|
-
[DllImport(Lib)]
|
|
150
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
151
151
|
internal static extern void autd3_checker_free(IntPtr checker);
|
|
152
152
|
|
|
153
|
-
[DllImport(Lib)]
|
|
153
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
154
154
|
internal static extern ulong autd3_link_status_recoveries(IntPtr status);
|
|
155
155
|
|
|
156
|
-
[DllImport(Lib)]
|
|
156
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
157
157
|
internal static extern UIntPtr autd3_link_status_num_devices(IntPtr status);
|
|
158
158
|
|
|
159
|
-
[DllImport(Lib)]
|
|
159
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
160
160
|
[return: MarshalAs(UnmanagedType.I1)]
|
|
161
161
|
internal static extern bool autd3_link_status_device_state(IntPtr status, UIntPtr index, out byte outKind, out byte outBits);
|
|
162
162
|
|
|
163
|
-
[DllImport(Lib)]
|
|
163
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
164
164
|
internal static extern void autd3_link_status_free(IntPtr status);
|
|
165
165
|
}
|
|
166
166
|
|
|
@@ -168,85 +168,85 @@ namespace AUTD3
|
|
|
168
168
|
{
|
|
169
169
|
private const string Lib = "autd3capi";
|
|
170
170
|
|
|
171
|
-
[DllImport(Lib)]
|
|
171
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
172
172
|
internal static extern IntPtr autd3_legacy_client_config_new();
|
|
173
173
|
|
|
174
|
-
[DllImport(Lib)]
|
|
174
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
175
175
|
internal static extern int autd3_legacy_client_config_set_timeout_cycles(IntPtr config, uint value);
|
|
176
176
|
|
|
177
|
-
[DllImport(Lib)]
|
|
177
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
178
178
|
internal static extern int autd3_legacy_client_config_set_rt_priority(IntPtr config, byte mode, byte value);
|
|
179
179
|
|
|
180
|
-
[DllImport(Lib)]
|
|
180
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
181
181
|
internal static extern int autd3_legacy_client_config_set_rt_policy(IntPtr config, byte value);
|
|
182
182
|
|
|
183
|
-
[DllImport(Lib)]
|
|
183
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
184
184
|
internal static extern int autd3_legacy_client_config_set_rt_affinity(IntPtr config, [MarshalAs(UnmanagedType.I1)] bool hasAffinity, UIntPtr coreId);
|
|
185
185
|
|
|
186
|
-
[DllImport(Lib)]
|
|
186
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
187
187
|
internal static extern void autd3_legacy_client_config_free(IntPtr config);
|
|
188
188
|
|
|
189
|
-
[DllImport(Lib)]
|
|
189
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
190
190
|
internal static extern void autd3_legacy_client_opener_free(IntPtr opener);
|
|
191
191
|
|
|
192
|
-
[DllImport(Lib)]
|
|
193
|
-
internal static extern IntPtr autd3_legacy_datagram_builder_new(
|
|
192
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
193
|
+
internal static extern IntPtr autd3_legacy_datagram_builder_new(GeometryHandle geometry);
|
|
194
194
|
|
|
195
|
-
[DllImport(Lib)]
|
|
196
|
-
internal static extern int autd3_legacy_datagram_builder_push(
|
|
195
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
196
|
+
internal static extern int autd3_legacy_datagram_builder_push(LegacyDatagramBuilderHandle builder, IntPtr op);
|
|
197
197
|
|
|
198
|
-
[DllImport(Lib)]
|
|
198
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
199
199
|
internal static extern IntPtr autd3_legacy_op_change_segment(byte kind, byte bank, byte transitionMode, ulong transitionValue);
|
|
200
200
|
|
|
201
|
-
[DllImport(Lib)]
|
|
201
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
202
202
|
internal static extern void autd3_legacy_op_free(IntPtr op);
|
|
203
203
|
|
|
204
|
-
[DllImport(Lib)]
|
|
205
|
-
internal static extern int autd3_legacy_datagram_builder_push_legacy(
|
|
204
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
205
|
+
internal static extern int autd3_legacy_datagram_builder_push_legacy(LegacyDatagramBuilderHandle builder, IntPtr op);
|
|
206
206
|
|
|
207
|
-
[DllImport(Lib)]
|
|
208
|
-
internal static extern int autd3_legacy_datagram_builder_push_each(
|
|
207
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
208
|
+
internal static extern int autd3_legacy_datagram_builder_push_each(LegacyDatagramBuilderHandle builder, IntPtr[] ops, UIntPtr numDevices);
|
|
209
209
|
|
|
210
|
-
[DllImport(Lib)]
|
|
210
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
211
211
|
internal static extern void autd3_legacy_datagram_builder_free(IntPtr builder);
|
|
212
212
|
|
|
213
|
-
[DllImport(Lib)]
|
|
214
|
-
internal static extern IntPtr autd3_legacy_datagram_builder_build(
|
|
213
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
214
|
+
internal static extern IntPtr autd3_legacy_datagram_builder_build(LegacyDatagramBuilderHandle builder, IntPtr client, byte[] outErr, UIntPtr outErrLen);
|
|
215
215
|
|
|
216
|
-
[DllImport(Lib)]
|
|
217
|
-
internal static extern UIntPtr autd3_legacy_frames_num_frames(
|
|
216
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
217
|
+
internal static extern UIntPtr autd3_legacy_frames_num_frames(LegacyFramesHandle frames);
|
|
218
218
|
|
|
219
|
-
[DllImport(Lib)]
|
|
219
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
220
220
|
internal static extern void autd3_legacy_frames_free(IntPtr frames);
|
|
221
221
|
|
|
222
|
-
[DllImport(Lib)]
|
|
223
|
-
internal static extern void autd3_legacy_client_open(
|
|
222
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
223
|
+
internal static extern void autd3_legacy_client_open(GeometryHandle geometry, IntPtr link, IntPtr config, CompletionCallback cb, IntPtr userData);
|
|
224
224
|
|
|
225
|
-
[DllImport(Lib)]
|
|
226
|
-
internal static extern UIntPtr autd3_legacy_client_num_devices(
|
|
225
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
226
|
+
internal static extern UIntPtr autd3_legacy_client_num_devices(LegacyClientHandle client);
|
|
227
227
|
|
|
228
|
-
[DllImport(Lib)]
|
|
229
|
-
internal static extern void autd3_legacy_client_send(
|
|
228
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
229
|
+
internal static extern void autd3_legacy_client_send(LegacyClientHandle client, LegacyFramesHandle frames, long frame, CompletionCallback cb, IntPtr userData);
|
|
230
230
|
|
|
231
|
-
[DllImport(Lib)]
|
|
232
|
-
internal static extern void autd3_legacy_client_send_checked(
|
|
231
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
232
|
+
internal static extern void autd3_legacy_client_send_checked(LegacyClientHandle client, LegacyFramesHandle frames, long frame, CompletionCallback cb, IntPtr userData);
|
|
233
233
|
|
|
234
|
-
[DllImport(Lib)]
|
|
235
|
-
internal static extern void autd3_legacy_client_read_firmware_version(
|
|
234
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
235
|
+
internal static extern void autd3_legacy_client_read_firmware_version(LegacyClientHandle client, CompletionCallback cb, IntPtr userData);
|
|
236
236
|
|
|
237
|
-
[DllImport(Lib)]
|
|
238
|
-
internal static extern void autd3_legacy_client_read_fpga_state(
|
|
237
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
238
|
+
internal static extern void autd3_legacy_client_read_fpga_state(LegacyClientHandle client, CompletionCallback cb, IntPtr userData);
|
|
239
239
|
|
|
240
|
-
[DllImport(Lib)]
|
|
241
|
-
internal static extern IntPtr autd3_legacy_client_checker(
|
|
240
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
241
|
+
internal static extern IntPtr autd3_legacy_client_checker(LegacyClientHandle client);
|
|
242
242
|
|
|
243
|
-
[DllImport(Lib)]
|
|
244
|
-
internal static extern void autd3_legacy_client_stop(
|
|
243
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
244
|
+
internal static extern void autd3_legacy_client_stop(LegacyClientHandle client, CompletionCallback cb, IntPtr userData);
|
|
245
245
|
|
|
246
|
-
[DllImport(Lib)]
|
|
247
|
-
internal static extern void autd3_legacy_client_close(
|
|
246
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
247
|
+
internal static extern void autd3_legacy_client_close(LegacyClientHandle client, CompletionCallback cb, IntPtr userData);
|
|
248
248
|
|
|
249
|
-
[DllImport(Lib)]
|
|
249
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
250
250
|
internal static extern void autd3_legacy_client_free(IntPtr client);
|
|
251
251
|
}
|
|
252
252
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/SafeHandles.cs
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
|
|
3
|
+
namespace AUTD3
|
|
4
|
+
{
|
|
5
|
+
internal sealed class DatagramBuilderHandle : Autd3SafeHandle
|
|
6
|
+
{
|
|
7
|
+
internal DatagramBuilderHandle(IntPtr handle) : base(handle)
|
|
8
|
+
{
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
protected override bool ReleaseHandle()
|
|
12
|
+
{
|
|
13
|
+
NativeClient.autd3_datagram_builder_free(handle);
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
internal sealed class FramesHandle : Autd3SafeHandle
|
|
19
|
+
{
|
|
20
|
+
internal FramesHandle(IntPtr handle) : base(handle)
|
|
21
|
+
{
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
protected override bool ReleaseHandle()
|
|
25
|
+
{
|
|
26
|
+
NativeClient.autd3_datagrams_free(handle);
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
internal sealed class ClientHandle : Autd3SafeHandle
|
|
32
|
+
{
|
|
33
|
+
internal ClientHandle(IntPtr handle) : base(handle)
|
|
34
|
+
{
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
protected override bool ReleaseHandle()
|
|
38
|
+
{
|
|
39
|
+
NativeClient.autd3_client_free(handle);
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
internal sealed class CheckerHandle : Autd3SafeHandle
|
|
45
|
+
{
|
|
46
|
+
internal CheckerHandle(IntPtr handle) : base(handle)
|
|
47
|
+
{
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
protected override bool ReleaseHandle()
|
|
51
|
+
{
|
|
52
|
+
NativeClient.autd3_checker_free(handle);
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
internal sealed class LegacyDatagramBuilderHandle : Autd3SafeHandle
|
|
58
|
+
{
|
|
59
|
+
internal LegacyDatagramBuilderHandle(IntPtr handle) : base(handle)
|
|
60
|
+
{
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
protected override bool ReleaseHandle()
|
|
64
|
+
{
|
|
65
|
+
NativeLegacyClient.autd3_legacy_datagram_builder_free(handle);
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
internal sealed class LegacyFramesHandle : Autd3SafeHandle
|
|
71
|
+
{
|
|
72
|
+
internal LegacyFramesHandle(IntPtr handle) : base(handle)
|
|
73
|
+
{
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
protected override bool ReleaseHandle()
|
|
77
|
+
{
|
|
78
|
+
NativeLegacyClient.autd3_legacy_frames_free(handle);
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
internal sealed class LegacyClientHandle : Autd3SafeHandle
|
|
84
|
+
{
|
|
85
|
+
internal LegacyClientHandle(IntPtr handle) : base(handle)
|
|
86
|
+
{
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
protected override bool ReleaseHandle()
|
|
90
|
+
{
|
|
91
|
+
NativeLegacyClient.autd3_legacy_client_free(handle);
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
package/Stm.cs
CHANGED
|
@@ -27,43 +27,43 @@ namespace AUTD3
|
|
|
27
27
|
|
|
28
28
|
static NativeStm() => NativeAbi.Verify(Lib, autd3_abi_version());
|
|
29
29
|
|
|
30
|
-
[DllImport(Lib)]
|
|
30
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
31
31
|
private static extern uint autd3_abi_version();
|
|
32
32
|
|
|
33
|
-
[DllImport(Lib)]
|
|
33
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
34
34
|
internal static extern IntPtr autd3_stm_config_freq(float hz);
|
|
35
35
|
|
|
36
|
-
[DllImport(Lib)]
|
|
36
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
37
37
|
internal static extern IntPtr autd3_stm_config_freq_nearest(float hz);
|
|
38
38
|
|
|
39
|
-
[DllImport(Lib)]
|
|
39
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
40
40
|
internal static extern IntPtr autd3_stm_config_period(float secs);
|
|
41
41
|
|
|
42
|
-
[DllImport(Lib)]
|
|
42
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
43
43
|
internal static extern IntPtr autd3_stm_config_period_nearest(float secs);
|
|
44
44
|
|
|
45
|
-
[DllImport(Lib)]
|
|
45
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
46
46
|
internal static extern IntPtr autd3_stm_config_sampling(ushort divide);
|
|
47
47
|
|
|
48
|
-
[DllImport(Lib)]
|
|
48
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
49
49
|
internal static extern int autd3_stm_config_into_sampling_config(IntPtr config, UIntPtr size, out ushort @out);
|
|
50
50
|
|
|
51
|
-
[DllImport(Lib)]
|
|
51
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
52
52
|
internal static extern void autd3_stm_config_free(IntPtr config);
|
|
53
53
|
|
|
54
|
-
[DllImport(Lib)]
|
|
54
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
55
55
|
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);
|
|
56
56
|
|
|
57
|
-
[DllImport(Lib)]
|
|
57
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
58
58
|
internal static extern IntPtr autd3_op_write_foci_buffer(byte bank, uint indexOffset, Autd3StmControlPointNative[] points, UIntPtr numSamples, byte numFoci, byte[] intensities);
|
|
59
59
|
|
|
60
|
-
[DllImport(Lib)]
|
|
60
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
61
61
|
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);
|
|
62
62
|
|
|
63
|
-
[DllImport(Lib)]
|
|
63
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
64
64
|
internal static extern int autd3_stm_circle(float[] center, float radiusMm, UIntPtr numPoints, float[] normal, byte intensity, Autd3StmControlPointNative[] outPoints, byte[] outIntensities);
|
|
65
65
|
|
|
66
|
-
[DllImport(Lib)]
|
|
66
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
67
67
|
internal static extern int autd3_stm_line(float[] start, float[] end, UIntPtr numPoints, byte intensity, Autd3StmControlPointNative[] outPoints, byte[] outIntensities);
|
|
68
68
|
}
|
|
69
69
|
|
|
@@ -264,7 +264,7 @@ namespace AUTD3
|
|
|
264
264
|
try
|
|
265
265
|
{
|
|
266
266
|
return NativeStm.autd3_op_foci_stm(configHandle, points, (UIntPtr)_points.Length, numFoci, intensities,
|
|
267
|
-
(byte)_option.Bank, _option.SoundSpeed.
|
|
267
|
+
(byte)_option.Bank, _option.SoundSpeed.MS, _option.LoopBehavior.Rep, _option.TransitionMode.Mode, _option.TransitionMode.Value, _option.TransitionMode.MarginNs);
|
|
268
268
|
}
|
|
269
269
|
finally
|
|
270
270
|
{
|
|
@@ -288,15 +288,16 @@ namespace AUTD3
|
|
|
288
288
|
|
|
289
289
|
IntPtr ICommand.CreateOp()
|
|
290
290
|
{
|
|
291
|
-
var handles = new
|
|
291
|
+
var handles = new SafeHandle[_patterns.Length];
|
|
292
292
|
for (var i = 0; i < _patterns.Length; i++)
|
|
293
293
|
{
|
|
294
294
|
handles[i] = _patterns[i].Handle;
|
|
295
295
|
}
|
|
296
|
+
using var lease = new HandleArray(handles);
|
|
296
297
|
var configHandle = _config.CreateHandle();
|
|
297
298
|
try
|
|
298
299
|
{
|
|
299
|
-
return NativeStm.autd3_op_pattern_stm(configHandle,
|
|
300
|
+
return NativeStm.autd3_op_pattern_stm(configHandle, lease.Pointers, (UIntPtr)lease.Pointers.Length,
|
|
300
301
|
(byte)_option.Bank, (byte)_option.Mode, _option.LoopBehavior.Rep, _option.TransitionMode.Mode, _option.TransitionMode.Value, _option.TransitionMode.MarginNs);
|
|
301
302
|
}
|
|
302
303
|
finally
|
package/THIRD-PARTY-LICENSES.md
CHANGED
|
@@ -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 (
|
|
8
|
+
- MIT License (54)
|
|
9
9
|
- Apache License 2.0 (3)
|
|
10
10
|
- Unicode License v3 (1)
|
|
11
11
|
|
|
@@ -886,8 +886,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
886
886
|
|
|
887
887
|
Used by:
|
|
888
888
|
|
|
889
|
-
- autd3-rs 0.
|
|
890
|
-
- autd3-rs-core 0.
|
|
889
|
+
- autd3-rs 0.7.0 — https://github.com/shinolab/autd3-sdk
|
|
890
|
+
- autd3-rs-core 0.7.0 — https://github.com/shinolab/autd3-sdk
|
|
891
891
|
- autd3-cpu-wire 0.6.0 — https://github.com/shinolab/autd3-sdk
|
|
892
892
|
|
|
893
893
|
```
|
|
@@ -919,8 +919,8 @@ SOFTWARE.
|
|
|
919
919
|
|
|
920
920
|
Used by:
|
|
921
921
|
|
|
922
|
-
- autd3-ffi 0.
|
|
923
|
-
- autd3-ffi-abi 0.
|
|
922
|
+
- autd3-ffi 0.7.0 — https://github.com/shinolab/autd3-sdk
|
|
923
|
+
- autd3-ffi-abi 0.7.0 — https://github.com/shinolab/autd3-sdk
|
|
924
924
|
- chrono 0.4.45 — https://github.com/chronotope/chrono
|
|
925
925
|
- wide 1.5.0 — https://github.com/Lokathor/wide
|
|
926
926
|
- winapi-i686-pc-windows-gnu 0.4.0 — https://github.com/retep998/winapi-rs
|
|
@@ -1036,6 +1036,37 @@ DEALINGS IN THE SOFTWARE.
|
|
|
1036
1036
|
|
|
1037
1037
|
Used by:
|
|
1038
1038
|
|
|
1039
|
+
- tracing-core 0.1.36 — https://github.com/tokio-rs/tracing
|
|
1040
|
+
|
|
1041
|
+
```
|
|
1042
|
+
The MIT License (MIT)
|
|
1043
|
+
|
|
1044
|
+
Copyright (c) 2014 Mathijs van de Nes
|
|
1045
|
+
|
|
1046
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
1047
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
1048
|
+
in the Software without restriction, including without limitation the rights
|
|
1049
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
1050
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
1051
|
+
furnished to do so, subject to the following conditions:
|
|
1052
|
+
|
|
1053
|
+
The above copyright notice and this permission notice shall be included in all
|
|
1054
|
+
copies or substantial portions of the Software.
|
|
1055
|
+
|
|
1056
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
1057
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
1058
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
1059
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
1060
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1061
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1062
|
+
SOFTWARE.
|
|
1063
|
+
|
|
1064
|
+
```
|
|
1065
|
+
|
|
1066
|
+
## MIT License
|
|
1067
|
+
|
|
1068
|
+
Used by:
|
|
1069
|
+
|
|
1039
1070
|
- typenum 1.20.1 — https://github.com/paholg/typenum
|
|
1040
1071
|
|
|
1041
1072
|
```
|
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.
|
|
8
|
+
"version": "0.7.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.
|
|
19
|
-
"com.shinolab.autd3-sdk.pattern": "0.
|
|
20
|
-
"com.shinolab.autd3-sdk.modulation": "0.
|
|
18
|
+
"com.shinolab.autd3-sdk.core": "0.7.0",
|
|
19
|
+
"com.shinolab.autd3-sdk.pattern": "0.7.0",
|
|
20
|
+
"com.shinolab.autd3-sdk.modulation": "0.7.0"
|
|
21
21
|
},
|
|
22
22
|
"samples": [
|
|
23
23
|
{
|