com.shinolab.autd3-sdk 0.13.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 +92 -281
- package/Commands.cs +84 -2
- package/Datagram.cs +6 -0
- package/Native.cs +30 -59
- 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/Samples~/FocusSine/FocusSineSample.cs +0 -1
- package/THIRD-PARTY-LICENSES.md +148 -37
- package/Udp.cs +19 -12
- 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
|
{
|
package/Client.cs
CHANGED
|
@@ -7,36 +7,6 @@ using System.Threading.Tasks;
|
|
|
7
7
|
|
|
8
8
|
namespace AUTD3
|
|
9
9
|
{
|
|
10
|
-
[StructLayout(LayoutKind.Sequential)]
|
|
11
|
-
internal struct ExecAtNative
|
|
12
|
-
{
|
|
13
|
-
public byte Kind;
|
|
14
|
-
public ulong Ns;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
public readonly struct ExecAt
|
|
18
|
-
{
|
|
19
|
-
internal byte Kind { get; }
|
|
20
|
-
internal ulong Ns { get; }
|
|
21
|
-
|
|
22
|
-
private ExecAt(byte kind, ulong ns)
|
|
23
|
-
{
|
|
24
|
-
Kind = kind;
|
|
25
|
-
Ns = ns;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
public static ExecAt Immediate => new ExecAt(0, 0);
|
|
29
|
-
|
|
30
|
-
public static ExecAt Lead(TimeSpan lead) =>
|
|
31
|
-
lead >= TimeSpan.Zero
|
|
32
|
-
? new ExecAt(1, OptionNative.ToNanos(lead))
|
|
33
|
-
: throw new Autd3Exception("ExecAt.Lead must not be negative", Autd3ErrorCode.InvalidArgument);
|
|
34
|
-
|
|
35
|
-
public static ExecAt At(SysTime sysTime) => new ExecAt(2, sysTime.Nanos);
|
|
36
|
-
|
|
37
|
-
internal ExecAtNative ToNative() => new ExecAtNative { Kind = Kind, Ns = Ns };
|
|
38
|
-
}
|
|
39
|
-
|
|
40
10
|
public readonly struct FpgaState
|
|
41
11
|
{
|
|
42
12
|
public byte Raw { get; }
|
|
@@ -128,59 +98,30 @@ namespace AUTD3
|
|
|
128
98
|
public readonly struct Telemetry : IEquatable<Telemetry>
|
|
129
99
|
{
|
|
130
100
|
public uint FifoDrop { get; }
|
|
131
|
-
public uint
|
|
132
|
-
public uint Processed { get; }
|
|
133
|
-
public uint SendFailure { get; }
|
|
134
|
-
public ushort Failsafe { get; }
|
|
135
|
-
public ushort PtpUnlockFailsafe { get; }
|
|
101
|
+
public uint ExecLate { get; }
|
|
136
102
|
public byte SyncResync { get; }
|
|
137
|
-
public byte BootFailure { get; }
|
|
138
103
|
public byte CpuWatchdog { get; }
|
|
139
|
-
public
|
|
104
|
+
public byte BootFailure { get; }
|
|
140
105
|
|
|
141
106
|
internal Telemetry(NativeClient.TelemetryNative native)
|
|
142
107
|
{
|
|
143
108
|
FifoDrop = native.FifoDrop;
|
|
144
|
-
|
|
145
|
-
Processed = native.Processed;
|
|
146
|
-
SendFailure = native.SendFailure;
|
|
147
|
-
Failsafe = native.Failsafe;
|
|
148
|
-
PtpUnlockFailsafe = native.PtpUnlockFailsafe;
|
|
109
|
+
ExecLate = native.ExecLate;
|
|
149
110
|
SyncResync = native.SyncResync;
|
|
150
|
-
BootFailure = native.BootFailure;
|
|
151
111
|
CpuWatchdog = native.CpuWatchdog;
|
|
152
|
-
|
|
112
|
+
BootFailure = native.BootFailure;
|
|
153
113
|
}
|
|
154
114
|
|
|
155
115
|
public override string ToString() =>
|
|
156
|
-
$"Telemetry {{ FifoDrop = {FifoDrop},
|
|
157
|
-
$"Processed = {Processed}, SendFailure = {SendFailure}, Failsafe = {Failsafe}, PtpUnlockFailsafe = {PtpUnlockFailsafe}, " +
|
|
158
|
-
$"SyncResync = {SyncResync}, BootFailure = {BootFailure}, CpuWatchdog = {CpuWatchdog}, ExecLate = {ExecLate} }}";
|
|
116
|
+
$"Telemetry {{ FifoDrop = {FifoDrop}, ExecLate = {ExecLate}, SyncResync = {SyncResync}, CpuWatchdog = {CpuWatchdog}, BootFailure = {BootFailure} }}";
|
|
159
117
|
|
|
160
118
|
public bool Equals(Telemetry other) =>
|
|
161
|
-
FifoDrop == other.FifoDrop &&
|
|
162
|
-
|
|
163
|
-
Failsafe == other.Failsafe && PtpUnlockFailsafe == other.PtpUnlockFailsafe &&
|
|
164
|
-
SyncResync == other.SyncResync && BootFailure == other.BootFailure && CpuWatchdog == other.CpuWatchdog &&
|
|
165
|
-
ExecLate == other.ExecLate;
|
|
119
|
+
FifoDrop == other.FifoDrop && ExecLate == other.ExecLate &&
|
|
120
|
+
SyncResync == other.SyncResync && CpuWatchdog == other.CpuWatchdog && BootFailure == other.BootFailure;
|
|
166
121
|
|
|
167
122
|
public override bool Equals(object? obj) => obj is Telemetry other && Equals(other);
|
|
168
123
|
|
|
169
|
-
public override int GetHashCode()
|
|
170
|
-
{
|
|
171
|
-
var hash = new HashCode();
|
|
172
|
-
hash.Add(FifoDrop);
|
|
173
|
-
hash.Add(DispatchError);
|
|
174
|
-
hash.Add(Processed);
|
|
175
|
-
hash.Add(SendFailure);
|
|
176
|
-
hash.Add(Failsafe);
|
|
177
|
-
hash.Add(PtpUnlockFailsafe);
|
|
178
|
-
hash.Add(SyncResync);
|
|
179
|
-
hash.Add(BootFailure);
|
|
180
|
-
hash.Add(CpuWatchdog);
|
|
181
|
-
hash.Add(ExecLate);
|
|
182
|
-
return hash.ToHashCode();
|
|
183
|
-
}
|
|
124
|
+
public override int GetHashCode() => HashCode.Combine(FifoDrop, ExecLate, SyncResync, CpuWatchdog, BootFailure);
|
|
184
125
|
|
|
185
126
|
public static bool operator ==(Telemetry left, Telemetry right) => left.Equals(right);
|
|
186
127
|
|
|
@@ -217,110 +158,107 @@ namespace AUTD3
|
|
|
217
158
|
public static bool operator !=(DeviceStatus left, DeviceStatus right) => !left.Equals(right);
|
|
218
159
|
}
|
|
219
160
|
|
|
220
|
-
public sealed class
|
|
161
|
+
public sealed class DeviceReply
|
|
221
162
|
{
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
163
|
+
public int Device { get; }
|
|
164
|
+
public ushort MsgId { get; }
|
|
165
|
+
public byte Status { get; }
|
|
166
|
+
public byte Flags { get; }
|
|
167
|
+
public byte UnitId { get; }
|
|
168
|
+
public ulong SysTime { get; }
|
|
169
|
+
public Telemetry Telemetry { get; }
|
|
170
|
+
public FpgaState FpgaState { get; }
|
|
171
|
+
public IReadOnlyList<byte> Data { get; }
|
|
172
|
+
|
|
173
|
+
private DeviceReply(NativeClient.DeviceReplyNative native, byte[] data)
|
|
226
174
|
{
|
|
227
|
-
|
|
228
|
-
|
|
175
|
+
Device = (int)native.Device;
|
|
176
|
+
MsgId = native.MsgId;
|
|
177
|
+
Status = native.Status;
|
|
178
|
+
Flags = native.Flags;
|
|
179
|
+
UnitId = native.UnitId;
|
|
180
|
+
SysTime = native.SysTime;
|
|
181
|
+
Telemetry = new Telemetry(native.Telemetry);
|
|
182
|
+
FpgaState = new FpgaState(native.FpgaState);
|
|
183
|
+
Data = data;
|
|
229
184
|
}
|
|
230
185
|
|
|
231
|
-
internal static
|
|
186
|
+
internal static DeviceReply FromNative(IntPtr reply)
|
|
232
187
|
{
|
|
233
|
-
|
|
188
|
+
if (NativeClient.autd3_device_reply_get(reply, out var native) != 0)
|
|
234
189
|
{
|
|
235
|
-
|
|
236
|
-
var errorCodes = new byte[count];
|
|
237
|
-
if (count > 0)
|
|
238
|
-
{
|
|
239
|
-
Marshal.Copy(NativeClient.autd3_response_error_codes(handle), errorCodes, 0, count);
|
|
240
|
-
}
|
|
241
|
-
var replyData = new byte[count][];
|
|
242
|
-
for (var i = 0; i < count; i++)
|
|
243
|
-
{
|
|
244
|
-
var len = (int)NativeClient.autd3_response_reply_data_of_len(handle, (UIntPtr)i);
|
|
245
|
-
replyData[i] = new byte[len];
|
|
246
|
-
if (len > 0)
|
|
247
|
-
{
|
|
248
|
-
Marshal.Copy(NativeClient.autd3_response_reply_data_of(handle, (UIntPtr)i), replyData[i], 0, len);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
return new Response(errorCodes, replyData);
|
|
190
|
+
throw new Autd3Exception("failed to read the reply");
|
|
252
191
|
}
|
|
253
|
-
|
|
192
|
+
var data = new byte[(int)NativeClient.autd3_device_reply_data_len(reply)];
|
|
193
|
+
if (data.Length > 0)
|
|
254
194
|
{
|
|
255
|
-
NativeClient.
|
|
195
|
+
Marshal.Copy(NativeClient.autd3_device_reply_data(reply), data, 0, data.Length);
|
|
256
196
|
}
|
|
197
|
+
return new DeviceReply(native, data);
|
|
257
198
|
}
|
|
258
199
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
public IReadOnlyList<IReadOnlyList<byte>> ReplyData => _replyData;
|
|
200
|
+
}
|
|
262
201
|
|
|
263
|
-
|
|
264
|
-
|
|
202
|
+
public sealed class Response
|
|
203
|
+
{
|
|
204
|
+
private readonly DeviceReply[] _replies;
|
|
205
|
+
private readonly DeviceStatus[] _deviceStatus;
|
|
206
|
+
private readonly int _checkCode;
|
|
207
|
+
private readonly byte[] _checkError;
|
|
265
208
|
|
|
266
|
-
|
|
209
|
+
private Response(IntPtr handle)
|
|
267
210
|
{
|
|
211
|
+
var count = (int)NativeClient.autd3_response_num_devices(handle);
|
|
212
|
+
_replies = new DeviceReply[count];
|
|
213
|
+
for (var i = 0; i < count; i++)
|
|
214
|
+
{
|
|
215
|
+
_replies[i] = DeviceReply.FromNative(NativeClient.autd3_response_reply(handle, (UIntPtr)i));
|
|
216
|
+
}
|
|
217
|
+
var native = new NativeClient.DeviceStatusNative[count];
|
|
268
218
|
var err = new byte[NativeAbi.ErrorBufferLength];
|
|
269
|
-
var code = NativeClient.
|
|
219
|
+
var code = NativeClient.autd3_response_device_status(handle, native, (UIntPtr)native.Length, err, (UIntPtr)err.Length);
|
|
270
220
|
if (code != 0)
|
|
271
221
|
{
|
|
272
222
|
throw Autd3Exception.FromNative(code, err);
|
|
273
223
|
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
internal ResponseFuture(IntPtr handle)
|
|
282
|
-
{
|
|
283
|
-
_handle = handle;
|
|
224
|
+
_deviceStatus = new DeviceStatus[count];
|
|
225
|
+
for (var i = 0; i < count; i++)
|
|
226
|
+
{
|
|
227
|
+
_deviceStatus[i] = new DeviceStatus(native[i]);
|
|
228
|
+
}
|
|
229
|
+
_checkError = new byte[NativeAbi.ErrorBufferLength];
|
|
230
|
+
_checkCode = NativeClient.autd3_response_check(handle, _checkError, (UIntPtr)_checkError.Length);
|
|
284
231
|
}
|
|
285
232
|
|
|
286
|
-
|
|
233
|
+
internal static Response FromOwned(IntPtr handle)
|
|
287
234
|
{
|
|
288
|
-
|
|
289
|
-
if (handle == IntPtr.Zero)
|
|
235
|
+
try
|
|
290
236
|
{
|
|
291
|
-
|
|
237
|
+
return new Response(handle);
|
|
238
|
+
}
|
|
239
|
+
finally
|
|
240
|
+
{
|
|
241
|
+
NativeClient.autd3_response_free(handle);
|
|
292
242
|
}
|
|
293
|
-
GC.SuppressFinalize(this);
|
|
294
|
-
var response = await AsyncOps.InvokeAsync((cb, ud) =>
|
|
295
|
-
NativeClient.autd3_response_token_await(handle, cb, ud)).ConfigureAwait(false);
|
|
296
|
-
return Response.FromNative(response);
|
|
297
243
|
}
|
|
298
244
|
|
|
299
|
-
public
|
|
245
|
+
public IReadOnlyList<DeviceReply> Replies => _replies;
|
|
246
|
+
|
|
247
|
+
public DeviceStatus[] DeviceStatus() => (DeviceStatus[])_deviceStatus.Clone();
|
|
300
248
|
|
|
301
|
-
|
|
249
|
+
public void Check()
|
|
302
250
|
{
|
|
303
|
-
|
|
304
|
-
if (handle != IntPtr.Zero)
|
|
251
|
+
if (_checkCode != 0)
|
|
305
252
|
{
|
|
306
|
-
|
|
253
|
+
throw Autd3Exception.FromNative(_checkCode, _checkError);
|
|
307
254
|
}
|
|
308
255
|
}
|
|
309
|
-
|
|
310
|
-
public void Dispose()
|
|
311
|
-
{
|
|
312
|
-
Release();
|
|
313
|
-
GC.SuppressFinalize(this);
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
~ResponseFuture() => Release();
|
|
317
256
|
}
|
|
318
257
|
|
|
319
258
|
public sealed class Client : IDisposable
|
|
320
259
|
{
|
|
321
260
|
private readonly ClientHandle _handle;
|
|
322
261
|
private readonly Geometry _geometry;
|
|
323
|
-
private volatile bool _closed;
|
|
324
262
|
|
|
325
263
|
internal ClientHandle Handle => _handle;
|
|
326
264
|
|
|
@@ -354,23 +292,6 @@ namespace AUTD3
|
|
|
354
292
|
return new Client(value, owned);
|
|
355
293
|
}
|
|
356
294
|
|
|
357
|
-
public DeviceStatus[] DeviceStatus()
|
|
358
|
-
{
|
|
359
|
-
var native = new NativeClient.DeviceStatusNative[NumDevices];
|
|
360
|
-
var err = new byte[NativeAbi.ErrorBufferLength];
|
|
361
|
-
var code = NativeClient.autd3_client_device_status(Handle, native, (UIntPtr)native.Length, err, (UIntPtr)err.Length);
|
|
362
|
-
if (code != 0)
|
|
363
|
-
{
|
|
364
|
-
throw Autd3Exception.FromNative(code, err);
|
|
365
|
-
}
|
|
366
|
-
var status = new DeviceStatus[native.Length];
|
|
367
|
-
for (var i = 0; i < native.Length; i++)
|
|
368
|
-
{
|
|
369
|
-
status[i] = new DeviceStatus(native[i]);
|
|
370
|
-
}
|
|
371
|
-
return status;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
295
|
public int NumDevices => (int)NativeClient.autd3_client_num_devices(Handle);
|
|
375
296
|
|
|
376
297
|
public Geometry Geometry => _geometry;
|
|
@@ -386,62 +307,37 @@ namespace AUTD3
|
|
|
386
307
|
return SysTime.FromNanos(ns);
|
|
387
308
|
}
|
|
388
309
|
|
|
389
|
-
public
|
|
310
|
+
public async Task SendAsync(ICommand command, CancellationToken cancellationToken = default)
|
|
390
311
|
{
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
return OptionNative.FromNanos(ns);
|
|
395
|
-
}
|
|
396
|
-
set => OptionNative.Apply("ackTimeout", NativeClient.autd3_client_set_ack_timeout(Handle, OptionNative.RequiredNanos("ackTimeout", value)));
|
|
312
|
+
using var frames = Frames.Encode(_geometry, command);
|
|
313
|
+
await AsyncOps.InvokeAsync((cancel, cb, ud) =>
|
|
314
|
+
NativeClient.autd3_client_send(Handle, frames.Handle, cancel, cb, ud), cancellationToken).ConfigureAwait(false);
|
|
397
315
|
}
|
|
398
316
|
|
|
399
|
-
public
|
|
400
|
-
|
|
401
|
-
get
|
|
402
|
-
{
|
|
403
|
-
OptionNative.Apply("lostTimeout", NativeClient.autd3_client_lost_timeout(Handle, out var ns));
|
|
404
|
-
return OptionNative.FromNanos(ns);
|
|
405
|
-
}
|
|
406
|
-
set => OptionNative.Apply("lostTimeout", NativeClient.autd3_client_set_lost_timeout(Handle, OptionNative.RequiredNanos("lostTimeout", value)));
|
|
407
|
-
}
|
|
317
|
+
public Task SendAsync(IEnumerable<ICommand> commands, CancellationToken cancellationToken = default) =>
|
|
318
|
+
SendAsync(SequenceCommand.Of(commands), cancellationToken);
|
|
408
319
|
|
|
409
|
-
public
|
|
410
|
-
|
|
411
|
-
var err = new byte[NativeAbi.ErrorBufferLength];
|
|
412
|
-
var code = NativeClient.autd3_client_send_heartbeat(Handle, err, (UIntPtr)err.Length);
|
|
413
|
-
if (code != 0)
|
|
414
|
-
{
|
|
415
|
-
throw Autd3Exception.FromNative(code, err);
|
|
416
|
-
}
|
|
417
|
-
}
|
|
320
|
+
public Task SendStreamingAsync(IEnumerable<ICommand> commands, CancellationToken cancellationToken = default) =>
|
|
321
|
+
SendStreamingAsync(SequenceCommand.Of(commands), cancellationToken);
|
|
418
322
|
|
|
419
|
-
public async Task
|
|
323
|
+
public async Task SendStreamingAsync(ICommand command, CancellationToken cancellationToken = default)
|
|
420
324
|
{
|
|
421
325
|
using var frames = Frames.Encode(_geometry, command);
|
|
422
|
-
await AsyncOps.InvokeAsync((cb, ud) =>
|
|
423
|
-
NativeClient.
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
public async Task<ResponseFuture> SendFrameAsync(Frame frame)
|
|
427
|
-
{
|
|
428
|
-
var token = await AsyncOps.InvokeAsync((cb, ud) =>
|
|
429
|
-
NativeClient.autd3_client_send(Handle, frame.Frames.Handle, frame.Index, cb, ud)).ConfigureAwait(false);
|
|
430
|
-
return new ResponseFuture(token);
|
|
326
|
+
await AsyncOps.InvokeAsync((cancel, cb, ud) =>
|
|
327
|
+
NativeClient.autd3_client_send_streaming(Handle, frames.Handle, cancel, cb, ud), cancellationToken).ConfigureAwait(false);
|
|
431
328
|
}
|
|
432
329
|
|
|
433
|
-
public async Task<
|
|
330
|
+
public async Task<Response> ReadStateAsync(CancellationToken cancellationToken = default)
|
|
434
331
|
{
|
|
435
|
-
var
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
return new ResponseFuture(token);
|
|
332
|
+
var response = await AsyncOps.InvokeAsync((cancel, cb, ud) =>
|
|
333
|
+
NativeClient.autd3_client_read_state(Handle, cancel, cb, ud), cancellationToken).ConfigureAwait(false);
|
|
334
|
+
return Response.FromOwned(response);
|
|
439
335
|
}
|
|
440
336
|
|
|
441
|
-
public async Task<IReadOnlyList<FirmwareVersion>> ReadFirmwareVersionAsync()
|
|
337
|
+
public async Task<IReadOnlyList<FirmwareVersion>> ReadFirmwareVersionAsync(CancellationToken cancellationToken = default)
|
|
442
338
|
{
|
|
443
|
-
var array = await AsyncOps.InvokeAsync((cb, ud) =>
|
|
444
|
-
NativeClient.autd3_client_read_firmware_version(Handle, cb, ud)).ConfigureAwait(false);
|
|
339
|
+
var array = await AsyncOps.InvokeAsync((cancel, cb, ud) =>
|
|
340
|
+
NativeClient.autd3_client_read_firmware_version(Handle, cancel, cb, ud), cancellationToken).ConfigureAwait(false);
|
|
445
341
|
try
|
|
446
342
|
{
|
|
447
343
|
var count = (int)NativeClient.autd3_firmware_version_array_len(array);
|
|
@@ -462,99 +358,14 @@ namespace AUTD3
|
|
|
462
358
|
}
|
|
463
359
|
}
|
|
464
360
|
|
|
465
|
-
public async Task<IReadOnlyList<FpgaState>> ReadFpgaStateAsync()
|
|
466
|
-
{
|
|
467
|
-
var bytes = await ReadByteArrayAsync((cb, ud) =>
|
|
468
|
-
NativeClient.autd3_client_read_fpga_state(Handle, cb, ud)).ConfigureAwait(false);
|
|
469
|
-
var states = new FpgaState[bytes.Length];
|
|
470
|
-
for (var i = 0; i < bytes.Length; i++)
|
|
471
|
-
{
|
|
472
|
-
states[i] = new FpgaState(bytes[i]);
|
|
473
|
-
}
|
|
474
|
-
return states;
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
public async Task<IReadOnlyList<Telemetry>> ReadTelemetryAsync()
|
|
478
|
-
{
|
|
479
|
-
var array = await AsyncOps.InvokeAsync((cb, ud) =>
|
|
480
|
-
NativeClient.autd3_client_read_telemetry(Handle, cb, ud)).ConfigureAwait(false);
|
|
481
|
-
try
|
|
482
|
-
{
|
|
483
|
-
var count = (int)NativeClient.autd3_telemetry_array_len(array);
|
|
484
|
-
var telemetry = new Telemetry[count];
|
|
485
|
-
for (var i = 0; i < count; i++)
|
|
486
|
-
{
|
|
487
|
-
if (NativeClient.autd3_telemetry_array_get(array, (UIntPtr)i, out var native) != 0)
|
|
488
|
-
{
|
|
489
|
-
throw new Autd3Exception("failed to read the telemetry");
|
|
490
|
-
}
|
|
491
|
-
telemetry[i] = new Telemetry(native);
|
|
492
|
-
}
|
|
493
|
-
return telemetry;
|
|
494
|
-
}
|
|
495
|
-
finally
|
|
496
|
-
{
|
|
497
|
-
NativeClient.autd3_telemetry_array_free(array);
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
internal static async Task<byte[]> ReadByteArrayAsync(Action<CompletionCallback, IntPtr> invoke)
|
|
502
|
-
{
|
|
503
|
-
var array = await AsyncOps.InvokeAsync(invoke).ConfigureAwait(false);
|
|
504
|
-
try
|
|
505
|
-
{
|
|
506
|
-
var len = (int)NativeClient.autd3_byte_array_len(array);
|
|
507
|
-
var bytes = new byte[len];
|
|
508
|
-
if (len > 0)
|
|
509
|
-
{
|
|
510
|
-
Marshal.Copy(NativeClient.autd3_byte_array_data(array), bytes, 0, len);
|
|
511
|
-
}
|
|
512
|
-
return bytes;
|
|
513
|
-
}
|
|
514
|
-
finally
|
|
515
|
-
{
|
|
516
|
-
NativeClient.autd3_byte_array_free(array);
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
public void Close()
|
|
521
|
-
{
|
|
522
|
-
try
|
|
523
|
-
{
|
|
524
|
-
var err = new byte[NativeAbi.ErrorBufferLength];
|
|
525
|
-
var code = NativeClient.autd3_client_close(Handle, err, (UIntPtr)err.Length);
|
|
526
|
-
if (code != 0)
|
|
527
|
-
{
|
|
528
|
-
throw Autd3Exception.FromNative(code, err);
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
finally
|
|
532
|
-
{
|
|
533
|
-
_closed = true;
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
|
|
537
361
|
public void Dispose()
|
|
538
362
|
{
|
|
539
363
|
if (_handle.IsClosed)
|
|
540
364
|
{
|
|
541
365
|
return;
|
|
542
366
|
}
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
if (!_closed)
|
|
546
|
-
{
|
|
547
|
-
Close();
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
catch (Autd3Exception)
|
|
551
|
-
{
|
|
552
|
-
}
|
|
553
|
-
finally
|
|
554
|
-
{
|
|
555
|
-
_handle.Dispose();
|
|
556
|
-
_geometry.Dispose();
|
|
557
|
-
}
|
|
367
|
+
_handle.Dispose();
|
|
368
|
+
_geometry.Dispose();
|
|
558
369
|
}
|
|
559
370
|
}
|
|
560
371
|
}
|
package/Commands.cs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Linq;
|
|
2
4
|
using System.Runtime.InteropServices;
|
|
3
5
|
|
|
4
6
|
namespace AUTD3
|
|
@@ -48,6 +50,9 @@ namespace AUTD3
|
|
|
48
50
|
internal struct FpgaConfigNative
|
|
49
51
|
{
|
|
50
52
|
public byte SyncPhaseLock;
|
|
53
|
+
public ushort SyncKp;
|
|
54
|
+
public ushort SyncKi;
|
|
55
|
+
public ushort SyncKf;
|
|
51
56
|
}
|
|
52
57
|
|
|
53
58
|
internal static class NativeCommand
|
|
@@ -419,11 +424,17 @@ namespace AUTD3
|
|
|
419
424
|
internal static class FpgaConfigDefaults
|
|
420
425
|
{
|
|
421
426
|
internal static readonly bool SyncPhaseLock;
|
|
427
|
+
internal static readonly ushort SyncKp;
|
|
428
|
+
internal static readonly ushort SyncKi;
|
|
429
|
+
internal static readonly ushort SyncKf;
|
|
422
430
|
|
|
423
431
|
static FpgaConfigDefaults()
|
|
424
432
|
{
|
|
425
433
|
OptionNative.Apply("preset", NativeCommand.autd3_fpga_config_default(out var native));
|
|
426
434
|
SyncPhaseLock = native.SyncPhaseLock != 0;
|
|
435
|
+
SyncKp = native.SyncKp;
|
|
436
|
+
SyncKi = native.SyncKi;
|
|
437
|
+
SyncKf = native.SyncKf;
|
|
427
438
|
}
|
|
428
439
|
}
|
|
429
440
|
|
|
@@ -431,10 +442,19 @@ namespace AUTD3
|
|
|
431
442
|
{
|
|
432
443
|
private readonly bool? _syncPhaseLock;
|
|
433
444
|
public bool SyncPhaseLock { get => _syncPhaseLock ?? FpgaConfigDefaults.SyncPhaseLock; init => _syncPhaseLock = value; }
|
|
445
|
+
private readonly ushort? _syncKp;
|
|
446
|
+
public ushort SyncKp { get => _syncKp ?? FpgaConfigDefaults.SyncKp; init => _syncKp = value; }
|
|
447
|
+
private readonly ushort? _syncKi;
|
|
448
|
+
public ushort SyncKi { get => _syncKi ?? FpgaConfigDefaults.SyncKi; init => _syncKi = value; }
|
|
449
|
+
private readonly ushort? _syncKf;
|
|
450
|
+
public ushort SyncKf { get => _syncKf ?? FpgaConfigDefaults.SyncKf; init => _syncKf = value; }
|
|
434
451
|
|
|
435
452
|
internal FpgaConfigNative ToNative() => new FpgaConfigNative
|
|
436
453
|
{
|
|
437
454
|
SyncPhaseLock = OptionNative.Flag(SyncPhaseLock),
|
|
455
|
+
SyncKp = SyncKp,
|
|
456
|
+
SyncKi = SyncKi,
|
|
457
|
+
SyncKf = SyncKf,
|
|
438
458
|
};
|
|
439
459
|
}
|
|
440
460
|
|
|
@@ -722,6 +742,7 @@ namespace AUTD3
|
|
|
722
742
|
IntPtr ICommand.CreateOp(Geometry geometry)
|
|
723
743
|
{
|
|
724
744
|
var ops = new IntPtr[geometry.NumDevices];
|
|
745
|
+
var created = new List<(ICommand Command, IntPtr Op)>();
|
|
725
746
|
try
|
|
726
747
|
{
|
|
727
748
|
for (var i = 0; i < ops.Length; i++)
|
|
@@ -731,13 +752,74 @@ namespace AUTD3
|
|
|
731
752
|
{
|
|
732
753
|
continue;
|
|
733
754
|
}
|
|
734
|
-
|
|
755
|
+
var index = created.FindIndex(entry => ReferenceEquals(entry.Command, command));
|
|
756
|
+
if (index < 0)
|
|
757
|
+
{
|
|
758
|
+
var op = command.CreateOp(geometry);
|
|
759
|
+
if (op == IntPtr.Zero)
|
|
760
|
+
{
|
|
761
|
+
throw new Autd3Exception("failed to create the command", Autd3ErrorCode.InvalidArgument);
|
|
762
|
+
}
|
|
763
|
+
created.Add((command, op));
|
|
764
|
+
index = created.Count - 1;
|
|
765
|
+
}
|
|
766
|
+
ops[i] = created[index].Op;
|
|
767
|
+
}
|
|
768
|
+
var handle = NativeClient.autd3_command_each(ops, (UIntPtr)ops.Length);
|
|
769
|
+
if (handle == IntPtr.Zero)
|
|
770
|
+
{
|
|
771
|
+
throw new Autd3Exception("failed to compose the commands", Autd3ErrorCode.InvalidArgument);
|
|
772
|
+
}
|
|
773
|
+
return handle;
|
|
774
|
+
}
|
|
775
|
+
catch
|
|
776
|
+
{
|
|
777
|
+
foreach (var entry in created)
|
|
778
|
+
{
|
|
779
|
+
NativeClient.autd3_op_free(entry.Op);
|
|
780
|
+
}
|
|
781
|
+
throw;
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
internal sealed class SequenceCommand : ICommand
|
|
787
|
+
{
|
|
788
|
+
private readonly ICommand[] _commands;
|
|
789
|
+
|
|
790
|
+
private SequenceCommand(ICommand[] commands)
|
|
791
|
+
{
|
|
792
|
+
_commands = commands;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
internal static SequenceCommand Of(IEnumerable<ICommand> commands)
|
|
796
|
+
{
|
|
797
|
+
if (commands == null)
|
|
798
|
+
{
|
|
799
|
+
throw new ArgumentNullException(nameof(commands));
|
|
800
|
+
}
|
|
801
|
+
var snapshot = commands.ToArray();
|
|
802
|
+
if (snapshot.Any(command => command == null))
|
|
803
|
+
{
|
|
804
|
+
throw new ArgumentNullException(nameof(commands));
|
|
805
|
+
}
|
|
806
|
+
return new SequenceCommand(snapshot);
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
IntPtr ICommand.CreateOp(Geometry geometry)
|
|
810
|
+
{
|
|
811
|
+
var ops = new IntPtr[_commands.Length];
|
|
812
|
+
try
|
|
813
|
+
{
|
|
814
|
+
for (var i = 0; i < ops.Length; i++)
|
|
815
|
+
{
|
|
816
|
+
ops[i] = _commands[i].CreateOp(geometry);
|
|
735
817
|
if (ops[i] == IntPtr.Zero)
|
|
736
818
|
{
|
|
737
819
|
throw new Autd3Exception("failed to create the command", Autd3ErrorCode.InvalidArgument);
|
|
738
820
|
}
|
|
739
821
|
}
|
|
740
|
-
var handle = NativeClient.
|
|
822
|
+
var handle = NativeClient.autd3_command_sequence(ops, (UIntPtr)ops.Length);
|
|
741
823
|
if (handle == IntPtr.Zero)
|
|
742
824
|
{
|
|
743
825
|
throw new Autd3Exception("failed to compose the commands", Autd3ErrorCode.InvalidArgument);
|
package/Datagram.cs
CHANGED
|
@@ -48,6 +48,12 @@ namespace AUTD3
|
|
|
48
48
|
return frames;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
public static Frames Encode(Geometry geometry, IEnumerable<ICommand> commands) =>
|
|
52
|
+
Encode(geometry, SequenceCommand.Of(commands));
|
|
53
|
+
|
|
54
|
+
public void EncodeInto(Geometry geometry, IEnumerable<ICommand> commands) =>
|
|
55
|
+
EncodeInto(geometry, SequenceCommand.Of(commands));
|
|
56
|
+
|
|
51
57
|
public void EncodeInto(Geometry geometry, ICommand command)
|
|
52
58
|
{
|
|
53
59
|
if (geometry == null)
|
package/Native.cs
CHANGED
|
@@ -61,6 +61,9 @@ namespace AUTD3
|
|
|
61
61
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
62
62
|
internal static extern IntPtr autd3_command_each(IntPtr[] ops, UIntPtr numDevices);
|
|
63
63
|
|
|
64
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
65
|
+
internal static extern IntPtr autd3_command_sequence(IntPtr[] ops, UIntPtr len);
|
|
66
|
+
|
|
64
67
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
65
68
|
internal static extern void autd3_op_free(IntPtr op);
|
|
66
69
|
|
|
@@ -87,16 +90,6 @@ namespace AUTD3
|
|
|
87
90
|
public byte FailsafeActive;
|
|
88
91
|
}
|
|
89
92
|
|
|
90
|
-
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
91
|
-
internal static extern int autd3_client_device_status(ClientHandle client, [Out] DeviceStatusNative[] status, UIntPtr len, byte[] outErr, UIntPtr outErrLen);
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
93
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
101
94
|
internal static extern UIntPtr autd3_client_num_devices(ClientHandle client);
|
|
102
95
|
|
|
@@ -104,49 +97,56 @@ namespace AUTD3
|
|
|
104
97
|
internal static extern int autd3_client_device_time_now(ClientHandle client, out ulong ns, byte[] outErr, UIntPtr outErrLen);
|
|
105
98
|
|
|
106
99
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
107
|
-
internal static extern
|
|
100
|
+
internal static extern IntPtr autd3_cancel_token_new();
|
|
108
101
|
|
|
109
102
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
110
|
-
internal static extern
|
|
103
|
+
internal static extern void autd3_cancel_token_cancel(IntPtr token);
|
|
111
104
|
|
|
112
105
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
113
|
-
internal static extern
|
|
106
|
+
internal static extern void autd3_cancel_token_free(IntPtr token);
|
|
114
107
|
|
|
115
108
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
116
|
-
internal static extern
|
|
109
|
+
internal static extern void autd3_client_send(ClientHandle client, FramesHandle frames, IntPtr cancel, CompletionCallback cb, IntPtr userData);
|
|
117
110
|
|
|
118
111
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
119
|
-
internal static extern
|
|
112
|
+
internal static extern void autd3_client_send_streaming(ClientHandle client, FramesHandle frames, IntPtr cancel, CompletionCallback cb, IntPtr userData);
|
|
120
113
|
|
|
121
114
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
122
|
-
internal static extern void
|
|
115
|
+
internal static extern void autd3_client_read_state(ClientHandle client, IntPtr cancel, CompletionCallback cb, IntPtr userData);
|
|
123
116
|
|
|
124
|
-
[
|
|
125
|
-
internal
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
117
|
+
[StructLayout(LayoutKind.Sequential)]
|
|
118
|
+
internal struct DeviceReplyNative
|
|
119
|
+
{
|
|
120
|
+
public UIntPtr Device;
|
|
121
|
+
public ushort MsgId;
|
|
122
|
+
public byte Status;
|
|
123
|
+
public byte Flags;
|
|
124
|
+
public byte UnitId;
|
|
125
|
+
public ulong SysTime;
|
|
126
|
+
public TelemetryNative Telemetry;
|
|
127
|
+
public byte FpgaState;
|
|
128
|
+
}
|
|
129
129
|
|
|
130
130
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
131
|
-
internal static extern
|
|
131
|
+
internal static extern int autd3_device_reply_get(IntPtr reply, out DeviceReplyNative @out);
|
|
132
132
|
|
|
133
133
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
134
|
-
internal static extern
|
|
134
|
+
internal static extern UIntPtr autd3_device_reply_data_len(IntPtr reply);
|
|
135
135
|
|
|
136
136
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
137
|
-
internal static extern
|
|
137
|
+
internal static extern IntPtr autd3_device_reply_data(IntPtr reply);
|
|
138
138
|
|
|
139
139
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
140
140
|
internal static extern UIntPtr autd3_response_num_devices(IntPtr response);
|
|
141
141
|
|
|
142
142
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
143
|
-
internal static extern IntPtr
|
|
143
|
+
internal static extern IntPtr autd3_response_reply(IntPtr response, UIntPtr device);
|
|
144
144
|
|
|
145
145
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
146
|
-
internal static extern
|
|
146
|
+
internal static extern int autd3_response_device_status(IntPtr response, [Out] DeviceStatusNative[] status, UIntPtr len, byte[] outErr, UIntPtr outErrLen);
|
|
147
147
|
|
|
148
148
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
149
|
-
internal static extern
|
|
149
|
+
internal static extern int autd3_response_check(IntPtr response, byte[] outErr, UIntPtr outErrLen);
|
|
150
150
|
|
|
151
151
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
152
152
|
internal static extern void autd3_response_free(IntPtr response);
|
|
@@ -181,46 +181,17 @@ namespace AUTD3
|
|
|
181
181
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
182
182
|
internal static extern int autd3_firmware_version_supported_series(out byte major, out byte minor);
|
|
183
183
|
|
|
184
|
-
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
185
|
-
internal static extern int autd3_client_close(ClientHandle client, byte[] outErr, UIntPtr outErrLen);
|
|
186
|
-
|
|
187
184
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
188
185
|
internal static extern void autd3_client_free(IntPtr client);
|
|
189
186
|
|
|
190
187
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
191
|
-
internal static extern void autd3_client_read_firmware_version(ClientHandle client, CompletionCallback cb, IntPtr userData);
|
|
192
|
-
|
|
193
|
-
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
194
|
-
internal static extern void autd3_client_read_fpga_state(ClientHandle client, CompletionCallback cb, IntPtr userData);
|
|
195
|
-
|
|
196
|
-
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
197
|
-
internal static extern void autd3_client_read_telemetry(ClientHandle client, CompletionCallback cb, IntPtr userData);
|
|
198
|
-
|
|
199
|
-
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
200
|
-
internal static extern UIntPtr autd3_byte_array_len(IntPtr array);
|
|
201
|
-
|
|
202
|
-
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
203
|
-
internal static extern IntPtr autd3_byte_array_data(IntPtr array);
|
|
204
|
-
|
|
205
|
-
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
206
|
-
internal static extern void autd3_byte_array_free(IntPtr array);
|
|
188
|
+
internal static extern void autd3_client_read_firmware_version(ClientHandle client, IntPtr cancel, CompletionCallback cb, IntPtr userData);
|
|
207
189
|
|
|
208
190
|
[StructLayout(LayoutKind.Sequential)]
|
|
209
191
|
internal struct TelemetryNative
|
|
210
192
|
{
|
|
211
|
-
public uint FifoDrop,
|
|
212
|
-
public
|
|
213
|
-
public byte SyncResync, BootFailure, CpuWatchdog;
|
|
214
|
-
public uint ExecLate;
|
|
193
|
+
public uint FifoDrop, ExecLate;
|
|
194
|
+
public byte SyncResync, CpuWatchdog, BootFailure;
|
|
215
195
|
}
|
|
216
|
-
|
|
217
|
-
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
218
|
-
internal static extern UIntPtr autd3_telemetry_array_len(IntPtr array);
|
|
219
|
-
|
|
220
|
-
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
221
|
-
internal static extern int autd3_telemetry_array_get(IntPtr array, UIntPtr index, out TelemetryNative @out);
|
|
222
|
-
|
|
223
|
-
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
224
|
-
internal static extern void autd3_telemetry_array_free(IntPtr array);
|
|
225
196
|
}
|
|
226
197
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/THIRD-PARTY-LICENSES.md
CHANGED
|
@@ -473,6 +473,35 @@ DEALINGS IN THE SOFTWARE.
|
|
|
473
473
|
|
|
474
474
|
Used by:
|
|
475
475
|
|
|
476
|
+
- mio 1.2.4 — https://github.com/tokio-rs/mio
|
|
477
|
+
|
|
478
|
+
```
|
|
479
|
+
Copyright (c) 2014 Carl Lerche and other MIO contributors
|
|
480
|
+
|
|
481
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
482
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
483
|
+
in the Software without restriction, including without limitation the rights
|
|
484
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
485
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
486
|
+
furnished to do so, subject to the following conditions:
|
|
487
|
+
|
|
488
|
+
The above copyright notice and this permission notice shall be included in
|
|
489
|
+
all copies or substantial portions of the Software.
|
|
490
|
+
|
|
491
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
492
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
493
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
494
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
495
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
496
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
497
|
+
THE SOFTWARE.
|
|
498
|
+
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
## MIT License
|
|
502
|
+
|
|
503
|
+
Used by:
|
|
504
|
+
|
|
476
505
|
- symlink 0.1.0 — https://gitlab.com/chris-morgan/symlink
|
|
477
506
|
|
|
478
507
|
```
|
|
@@ -621,12 +650,10 @@ DEALINGS IN THE SOFTWARE.
|
|
|
621
650
|
|
|
622
651
|
Used by:
|
|
623
652
|
|
|
624
|
-
-
|
|
625
|
-
- futures-core 0.3.34 — https://github.com/rust-lang/futures-rs
|
|
653
|
+
- thread_local 1.1.10 — https://github.com/Amanieu/thread_local-rs
|
|
626
654
|
|
|
627
655
|
```
|
|
628
|
-
Copyright (c) 2016
|
|
629
|
-
Copyright (c) 2017 The Tokio Authors
|
|
656
|
+
Copyright (c) 2016 The Rust Project Developers
|
|
630
657
|
|
|
631
658
|
Permission is hereby granted, free of charge, to any
|
|
632
659
|
person obtaining a copy of this software and associated
|
|
@@ -658,35 +685,28 @@ DEALINGS IN THE SOFTWARE.
|
|
|
658
685
|
|
|
659
686
|
Used by:
|
|
660
687
|
|
|
661
|
-
-
|
|
688
|
+
- memoffset 0.9.1 — https://github.com/Gilnaa/memoffset
|
|
662
689
|
|
|
663
690
|
```
|
|
664
|
-
Copyright (c)
|
|
665
|
-
|
|
666
|
-
Permission is hereby granted, free of charge, to any
|
|
667
|
-
person obtaining a copy of this software and associated
|
|
668
|
-
documentation files (the "Software"), to deal in the
|
|
669
|
-
Software without restriction, including without
|
|
670
|
-
limitation the rights to use, copy, modify, merge,
|
|
671
|
-
publish, distribute, sublicense, and/or sell copies of
|
|
672
|
-
the Software, and to permit persons to whom the Software
|
|
673
|
-
is furnished to do so, subject to the following
|
|
674
|
-
conditions:
|
|
691
|
+
Copyright (c) 2017 Gilad Naaman
|
|
675
692
|
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
693
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
694
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
695
|
+
in the Software without restriction, including without limitation the rights
|
|
696
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
697
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
698
|
+
furnished to do so, subject to the following conditions:
|
|
679
699
|
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
683
|
-
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
|
684
|
-
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
685
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
686
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
|
687
|
-
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
688
|
-
DEALINGS IN THE SOFTWARE.
|
|
700
|
+
The above copyright notice and this permission notice shall be included in all
|
|
701
|
+
copies or substantial portions of the Software.
|
|
689
702
|
|
|
703
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
704
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
705
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
706
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
707
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
708
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
709
|
+
SOFTWARE.
|
|
690
710
|
```
|
|
691
711
|
|
|
692
712
|
## MIT License
|
|
@@ -1077,6 +1097,38 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
1077
1097
|
|
|
1078
1098
|
Used by:
|
|
1079
1099
|
|
|
1100
|
+
- tokio-macros 2.7.2 — https://github.com/tokio-rs/tokio
|
|
1101
|
+
|
|
1102
|
+
```
|
|
1103
|
+
MIT License
|
|
1104
|
+
|
|
1105
|
+
Copyright (c) 2019 Yoshua Wuyts
|
|
1106
|
+
Copyright (c) Tokio Contributors
|
|
1107
|
+
|
|
1108
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
1109
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
1110
|
+
in the Software without restriction, including without limitation the rights
|
|
1111
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
1112
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
1113
|
+
furnished to do so, subject to the following conditions:
|
|
1114
|
+
|
|
1115
|
+
The above copyright notice and this permission notice shall be included in all
|
|
1116
|
+
copies or substantial portions of the Software.
|
|
1117
|
+
|
|
1118
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
1119
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
1120
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
1121
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
1122
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1123
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1124
|
+
SOFTWARE.
|
|
1125
|
+
|
|
1126
|
+
```
|
|
1127
|
+
|
|
1128
|
+
## MIT License
|
|
1129
|
+
|
|
1130
|
+
Used by:
|
|
1131
|
+
|
|
1080
1132
|
- wide 1.7.1 — https://github.com/Lokathor/wide
|
|
1081
1133
|
|
|
1082
1134
|
```
|
|
@@ -1127,9 +1179,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
1127
1179
|
|
|
1128
1180
|
Used by:
|
|
1129
1181
|
|
|
1130
|
-
- autd3-rs 0.
|
|
1131
|
-
- autd3-rs-core 0.
|
|
1132
|
-
- autd3-cpu-wire 0.
|
|
1182
|
+
- autd3-rs 0.14.0 — https://github.com/shinolab/autd3-sdk
|
|
1183
|
+
- autd3-rs-core 0.14.0 — https://github.com/shinolab/autd3-sdk
|
|
1184
|
+
- autd3-cpu-wire 0.14.0 — https://github.com/shinolab/autd3-sdk
|
|
1133
1185
|
|
|
1134
1186
|
```
|
|
1135
1187
|
MIT License
|
|
@@ -1160,8 +1212,8 @@ SOFTWARE.
|
|
|
1160
1212
|
|
|
1161
1213
|
Used by:
|
|
1162
1214
|
|
|
1163
|
-
- autd3-ffi 0.
|
|
1164
|
-
- autd3-ffi-abi 0.
|
|
1215
|
+
- autd3-ffi 0.14.0 — https://github.com/shinolab/autd3-sdk
|
|
1216
|
+
- autd3-ffi-abi 0.14.0 — https://github.com/shinolab/autd3-sdk
|
|
1165
1217
|
- windows-link 0.2.1 — https://github.com/microsoft/windows-rs
|
|
1166
1218
|
- windows-sys 0.61.2 — https://github.com/microsoft/windows-rs
|
|
1167
1219
|
|
|
@@ -1191,12 +1243,39 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
1191
1243
|
|
|
1192
1244
|
Used by:
|
|
1193
1245
|
|
|
1194
|
-
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1246
|
+
- tokio 1.54.1 — https://github.com/tokio-rs/tokio
|
|
1247
|
+
|
|
1248
|
+
```
|
|
1249
|
+
MIT License
|
|
1250
|
+
|
|
1251
|
+
Copyright (c) Tokio Contributors
|
|
1252
|
+
|
|
1253
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
1254
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
1255
|
+
in the Software without restriction, including without limitation the rights
|
|
1256
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
1257
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
1258
|
+
furnished to do so, subject to the following conditions:
|
|
1259
|
+
|
|
1260
|
+
The above copyright notice and this permission notice shall be included in all
|
|
1261
|
+
copies or substantial portions of the Software.
|
|
1262
|
+
|
|
1263
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
1264
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
1265
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
1266
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
1267
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1268
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1269
|
+
SOFTWARE.
|
|
1270
|
+
|
|
1271
|
+
```
|
|
1272
|
+
|
|
1273
|
+
## MIT License
|
|
1274
|
+
|
|
1275
|
+
Used by:
|
|
1276
|
+
|
|
1197
1277
|
- lazy_static 1.5.1 — https://github.com/rust-lang-nursery/lazy-static.rs
|
|
1198
1278
|
- once_cell 1.21.4 — https://github.com/matklad/once_cell
|
|
1199
|
-
- parking 2.2.1 — https://github.com/smol-rs/parking
|
|
1200
1279
|
- pin-project-lite 0.2.17 — https://github.com/taiki-e/pin-project-lite
|
|
1201
1280
|
- proc-macro2 1.0.107 — https://github.com/dtolnay/proc-macro2
|
|
1202
1281
|
- quote 1.0.47 — https://github.com/dtolnay/quote
|
|
@@ -1205,6 +1284,7 @@ Used by:
|
|
|
1205
1284
|
- thiserror-impl 2.0.21 — https://github.com/dtolnay/thiserror
|
|
1206
1285
|
- thiserror 2.0.21 — https://github.com/dtolnay/thiserror
|
|
1207
1286
|
- unicode-ident 1.0.27 — https://github.com/dtolnay/unicode-ident
|
|
1287
|
+
- wasi 0.11.1+wasi-snapshot-preview1 — https://github.com/bytecodealliance/wasi
|
|
1208
1288
|
|
|
1209
1289
|
```
|
|
1210
1290
|
Permission is hereby granted, free of charge, to any
|
|
@@ -1299,6 +1379,37 @@ SOFTWARE.
|
|
|
1299
1379
|
|
|
1300
1380
|
Used by:
|
|
1301
1381
|
|
|
1382
|
+
- nix 0.31.3 — https://github.com/nix-rust/nix
|
|
1383
|
+
|
|
1384
|
+
```
|
|
1385
|
+
The MIT License (MIT)
|
|
1386
|
+
|
|
1387
|
+
Copyright (c) 2015 Carl Lerche + nix-rust Authors
|
|
1388
|
+
|
|
1389
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
1390
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
1391
|
+
in the Software without restriction, including without limitation the rights
|
|
1392
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
1393
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
1394
|
+
furnished to do so, subject to the following conditions:
|
|
1395
|
+
|
|
1396
|
+
The above copyright notice and this permission notice shall be included in
|
|
1397
|
+
all copies or substantial portions of the Software.
|
|
1398
|
+
|
|
1399
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
1400
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
1401
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
1402
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
1403
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1404
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
1405
|
+
THE SOFTWARE.
|
|
1406
|
+
|
|
1407
|
+
```
|
|
1408
|
+
|
|
1409
|
+
## MIT License
|
|
1410
|
+
|
|
1411
|
+
Used by:
|
|
1412
|
+
|
|
1302
1413
|
- crossbeam-channel 0.5.17 — https://github.com/crossbeam-rs/crossbeam
|
|
1303
1414
|
- crossbeam-utils 0.8.23 — https://github.com/crossbeam-rs/crossbeam
|
|
1304
1415
|
|
package/Udp.cs
CHANGED
|
@@ -7,28 +7,26 @@ namespace AUTD3
|
|
|
7
7
|
internal struct TransportOptionNative
|
|
8
8
|
{
|
|
9
9
|
public ulong OpenTimeoutNs;
|
|
10
|
-
public ulong LostTimeoutNs;
|
|
11
|
-
public ulong AckTimeoutNs;
|
|
12
10
|
public ulong SendBufferBytes;
|
|
13
11
|
public byte SyncOnOpen;
|
|
12
|
+
public byte HasHeartbeatInterval;
|
|
13
|
+
public ulong HeartbeatIntervalNs;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
internal static class TransportOptionDefaults
|
|
17
17
|
{
|
|
18
18
|
internal static readonly TimeSpan OpenTimeout;
|
|
19
|
-
internal static readonly TimeSpan LostTimeout;
|
|
20
|
-
internal static readonly TimeSpan AckTimeout;
|
|
21
19
|
internal static readonly ulong? SendBufferBytes;
|
|
22
20
|
internal static readonly bool SyncOnOpen;
|
|
21
|
+
internal static readonly TimeSpan? HeartbeatInterval;
|
|
23
22
|
|
|
24
23
|
static TransportOptionDefaults()
|
|
25
24
|
{
|
|
26
25
|
OptionNative.Apply("preset", NativeClient.autd3_transport_option_default(out var native));
|
|
27
26
|
OpenTimeout = OptionNative.FromNanos(native.OpenTimeoutNs);
|
|
28
|
-
LostTimeout = OptionNative.FromNanos(native.LostTimeoutNs);
|
|
29
|
-
AckTimeout = OptionNative.FromNanos(native.AckTimeoutNs);
|
|
30
27
|
SendBufferBytes = native.SendBufferBytes == 0 ? null : native.SendBufferBytes;
|
|
31
28
|
SyncOnOpen = native.SyncOnOpen != 0;
|
|
29
|
+
HeartbeatInterval = OptionNative.FromOptionalNanos(native.HasHeartbeatInterval, native.HeartbeatIntervalNs);
|
|
32
30
|
}
|
|
33
31
|
}
|
|
34
32
|
|
|
@@ -42,10 +40,6 @@ namespace AUTD3
|
|
|
42
40
|
|
|
43
41
|
private readonly TimeSpan? _openTimeout;
|
|
44
42
|
public TimeSpan OpenTimeout { get => _openTimeout ?? TransportOptionDefaults.OpenTimeout; init => _openTimeout = value; }
|
|
45
|
-
private readonly TimeSpan? _lostTimeout;
|
|
46
|
-
public TimeSpan LostTimeout { get => _lostTimeout ?? TransportOptionDefaults.LostTimeout; init => _lostTimeout = value; }
|
|
47
|
-
private readonly TimeSpan? _ackTimeout;
|
|
48
|
-
public TimeSpan AckTimeout { get => _ackTimeout ?? TransportOptionDefaults.AckTimeout; init => _ackTimeout = value; }
|
|
49
43
|
|
|
50
44
|
private readonly bool _sendBufferBytesSet;
|
|
51
45
|
private readonly ulong? _sendBufferBytes;
|
|
@@ -63,6 +57,19 @@ namespace AUTD3
|
|
|
63
57
|
private readonly bool? _syncOnOpen;
|
|
64
58
|
public bool SyncOnOpen { get => _syncOnOpen ?? TransportOptionDefaults.SyncOnOpen; init => _syncOnOpen = value; }
|
|
65
59
|
|
|
60
|
+
private readonly bool _heartbeatIntervalSet;
|
|
61
|
+
private readonly TimeSpan? _heartbeatInterval;
|
|
62
|
+
|
|
63
|
+
public TimeSpan? HeartbeatInterval
|
|
64
|
+
{
|
|
65
|
+
get => _heartbeatIntervalSet ? _heartbeatInterval : TransportOptionDefaults.HeartbeatInterval;
|
|
66
|
+
init
|
|
67
|
+
{
|
|
68
|
+
_heartbeatInterval = value;
|
|
69
|
+
_heartbeatIntervalSet = true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
66
73
|
internal byte IfaceKind => Iface switch
|
|
67
74
|
{
|
|
68
75
|
{ AddrValue: { } } => IfaceKindAddr,
|
|
@@ -75,8 +82,6 @@ namespace AUTD3
|
|
|
75
82
|
internal TransportOptionNative ToNative() => new TransportOptionNative
|
|
76
83
|
{
|
|
77
84
|
OpenTimeoutNs = OptionNative.RequiredNanos("openTimeout", OpenTimeout),
|
|
78
|
-
LostTimeoutNs = OptionNative.RequiredNanos("lostTimeout", LostTimeout),
|
|
79
|
-
AckTimeoutNs = OptionNative.RequiredNanos("ackTimeout", AckTimeout),
|
|
80
85
|
SendBufferBytes = SendBufferBytes switch
|
|
81
86
|
{
|
|
82
87
|
null => 0,
|
|
@@ -84,6 +89,8 @@ namespace AUTD3
|
|
|
84
89
|
_ => throw OptionNative.OutOfRange("sendBufferBytes"),
|
|
85
90
|
},
|
|
86
91
|
SyncOnOpen = OptionNative.Flag(SyncOnOpen),
|
|
92
|
+
HasHeartbeatInterval = OptionNative.Flag(HeartbeatInterval.HasValue),
|
|
93
|
+
HeartbeatIntervalNs = OptionNative.OptionalNanos("heartbeatInterval", HeartbeatInterval),
|
|
87
94
|
};
|
|
88
95
|
}
|
|
89
96
|
}
|
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.14.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.14.0",
|
|
19
|
+
"com.shinolab.autd3-sdk.pattern": "0.14.0",
|
|
20
|
+
"com.shinolab.autd3-sdk.modulation": "0.14.0"
|
|
21
21
|
},
|
|
22
22
|
"samples": [
|
|
23
23
|
{
|