com.shinolab.autd3-sdk 0.10.0 → 0.14.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/AsyncOps.cs +28 -0
- package/Client.cs +111 -447
- package/Commands.cs +315 -354
- package/Datagram.cs +16 -87
- package/Native.cs +38 -217
- 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 +0 -26
- package/Samples~/FocusSine/FocusSineSample.cs +16 -11
- package/Stm.cs +126 -223
- package/THIRD-PARTY-LICENSES.md +156 -110
- package/Udp.cs +55 -245
- package/package.json +4 -4
package/AsyncOps.cs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
using System;
|
|
2
2
|
using System.Runtime.InteropServices;
|
|
3
|
+
using System.Threading;
|
|
3
4
|
using System.Threading.Tasks;
|
|
4
5
|
|
|
5
6
|
namespace AUTD3
|
|
@@ -26,6 +27,33 @@ namespace AUTD3
|
|
|
26
27
|
return tcs.Task;
|
|
27
28
|
}
|
|
28
29
|
|
|
30
|
+
internal static async Task<IntPtr> InvokeAsync(Action<IntPtr, CompletionCallback, IntPtr> call, CancellationToken cancellationToken)
|
|
31
|
+
{
|
|
32
|
+
if (!cancellationToken.CanBeCanceled)
|
|
33
|
+
{
|
|
34
|
+
return await InvokeAsync((cb, ud) => call(IntPtr.Zero, cb, ud)).ConfigureAwait(false);
|
|
35
|
+
}
|
|
36
|
+
var token = NativeClient.autd3_cancel_token_new();
|
|
37
|
+
try
|
|
38
|
+
{
|
|
39
|
+
using (cancellationToken.Register(() => NativeClient.autd3_cancel_token_cancel(token)))
|
|
40
|
+
{
|
|
41
|
+
try
|
|
42
|
+
{
|
|
43
|
+
return await InvokeAsync((cb, ud) => call(token, cb, ud)).ConfigureAwait(false);
|
|
44
|
+
}
|
|
45
|
+
catch (Autd3Exception e) when (e.Code == Autd3ErrorCode.Aborted && cancellationToken.IsCancellationRequested)
|
|
46
|
+
{
|
|
47
|
+
throw new OperationCanceledException(e.Message, e, cancellationToken);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
finally
|
|
52
|
+
{
|
|
53
|
+
NativeClient.autd3_cancel_token_free(token);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
29
57
|
[MonoPInvokeCallback(typeof(CompletionCallback))]
|
|
30
58
|
private static void OnComplete(int code, IntPtr value, IntPtr msg, IntPtr userData)
|
|
31
59
|
{
|