com.shinolab.autd3-sdk.core 0.9.0 → 0.10.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/AssemblyInfo.cs +0 -4
- package/Command.cs +1 -1
- package/Config.cs +7 -21
- package/Coords.cs +4 -0
- package/Geometry.cs +42 -3
- package/IsExternalInit.cs +6 -0
- package/IsExternalInit.cs.meta +11 -0
- package/Native.cs +61 -52
- package/Plugins/linux-x64/libautd3_core.so +0 -0
- package/Plugins/osx-arm64/libautd3_core.dylib +0 -0
- package/Plugins/win-x64/autd3_core.dll +0 -0
- package/SamplingConfig.cs +59 -33
- package/THIRD-PARTY-LICENSES.md +31 -180
- package/Types.cs +106 -83
- package/Units.cs +16 -4
- package/package.json +1 -1
package/AssemblyInfo.cs
CHANGED
|
@@ -4,8 +4,4 @@ using System.Runtime.CompilerServices;
|
|
|
4
4
|
[assembly: InternalsVisibleTo("AUTD3.Pattern")]
|
|
5
5
|
[assembly: InternalsVisibleTo("AUTD3.Pattern.Holo")]
|
|
6
6
|
[assembly: InternalsVisibleTo("AUTD3.Modulation")]
|
|
7
|
-
[assembly: InternalsVisibleTo("AUTD3.Link.Echocat")]
|
|
8
|
-
[assembly: InternalsVisibleTo("AUTD3.Link.Remote")]
|
|
9
|
-
[assembly: InternalsVisibleTo("AUTD3.Link.TwinCAT")]
|
|
10
|
-
[assembly: InternalsVisibleTo("AUTD3.Link.Nop")]
|
|
11
7
|
[assembly: InternalsVisibleTo("AUTD3.Tests")]
|
package/Command.cs
CHANGED
package/Config.cs
CHANGED
|
@@ -37,27 +37,16 @@ namespace AUTD3
|
|
|
37
37
|
{
|
|
38
38
|
internal byte Mode { get; }
|
|
39
39
|
internal ulong Value { get; }
|
|
40
|
-
internal uint MarginNs { get; }
|
|
41
40
|
|
|
42
|
-
private TransitionMode(byte mode, ulong value
|
|
41
|
+
private TransitionMode(byte mode, ulong value)
|
|
43
42
|
{
|
|
44
43
|
Mode = mode;
|
|
45
44
|
Value = value;
|
|
46
|
-
MarginNs = marginNs;
|
|
47
45
|
}
|
|
48
46
|
|
|
49
47
|
public static TransitionMode SyncIdx => new TransitionMode(0x00, 0);
|
|
50
48
|
|
|
51
|
-
public static TransitionMode SysTime(
|
|
52
|
-
{
|
|
53
|
-
if (margin is not { } m) return new TransitionMode(0x01, sysTime.SysTime);
|
|
54
|
-
var nanos = (double)m.Ticks * 100.0;
|
|
55
|
-
if (nanos < 0.0 || nanos > uint.MaxValue)
|
|
56
|
-
{
|
|
57
|
-
throw new Autd3Exception("transition margin is out of range (0..=4294967295 ns)");
|
|
58
|
-
}
|
|
59
|
-
return new TransitionMode(0x01, sysTime.SysTime, (uint)nanos);
|
|
60
|
-
}
|
|
49
|
+
public static TransitionMode SysTime(SysTime sysTime) => new TransitionMode(0x01, sysTime.Nanos);
|
|
61
50
|
|
|
62
51
|
public static TransitionMode Gpio(GpioIn gpio) => new TransitionMode(0x02, (byte)gpio);
|
|
63
52
|
|
|
@@ -66,16 +55,13 @@ namespace AUTD3
|
|
|
66
55
|
public static TransitionMode Later => new TransitionMode(0xFE, 0);
|
|
67
56
|
|
|
68
57
|
public static TransitionMode Immediate => new TransitionMode(0xFF, 0);
|
|
58
|
+
|
|
59
|
+
public bool IsLater => Mode == 0xFE;
|
|
69
60
|
}
|
|
70
61
|
|
|
71
|
-
public enum
|
|
62
|
+
public enum FpgaBusWait : byte
|
|
72
63
|
{
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
SeqMismatch = 0x02,
|
|
76
|
-
DispatchError = 0x03,
|
|
77
|
-
Processed = 0x04,
|
|
78
|
-
Failsafe = 0x05,
|
|
79
|
-
SyncResync = 0x06,
|
|
64
|
+
Cycles2 = 2,
|
|
65
|
+
Cycles3 = 3,
|
|
80
66
|
}
|
|
81
67
|
}
|
package/Coords.cs
CHANGED
|
@@ -23,6 +23,8 @@ namespace AUTD3
|
|
|
23
23
|
internal static Quaternion FromRotation(SnQuaternion q) => new Quaternion(-q.X, -q.Y, q.Z, q.W);
|
|
24
24
|
|
|
25
25
|
internal static Quaternion IdentityRotation => Quaternion.identity;
|
|
26
|
+
|
|
27
|
+
internal static Vector3 FromLengths(Length x, Length y, Length z) => new Vector3(x.M, y.M, z.M);
|
|
26
28
|
#else
|
|
27
29
|
internal static SnVector3 Point(Vector3 v) => v;
|
|
28
30
|
|
|
@@ -37,6 +39,8 @@ namespace AUTD3
|
|
|
37
39
|
internal static Quaternion FromRotation(SnQuaternion q) => q;
|
|
38
40
|
|
|
39
41
|
internal static Quaternion IdentityRotation => Quaternion.Identity;
|
|
42
|
+
|
|
43
|
+
internal static Vector3 FromLengths(Length x, Length y, Length z) => new Vector3(x.Mm, y.Mm, z.Mm);
|
|
40
44
|
#endif
|
|
41
45
|
|
|
42
46
|
internal static float[] PointArray(Vector3 v)
|
package/Geometry.cs
CHANGED
|
@@ -18,10 +18,11 @@ namespace AUTD3
|
|
|
18
18
|
{
|
|
19
19
|
native[i] = devices[i].ToNative();
|
|
20
20
|
}
|
|
21
|
-
var
|
|
21
|
+
var err = new byte[NativeAbi.ErrorBufferLength];
|
|
22
|
+
var handle = NativeCore.autd3_core_geometry_new(native, (UIntPtr)native.Length, err, (UIntPtr)err.Length);
|
|
22
23
|
if (handle == IntPtr.Zero)
|
|
23
24
|
{
|
|
24
|
-
throw new Autd3Exception(
|
|
25
|
+
throw new Autd3Exception(NativeUtil.Utf8(err), Autd3ErrorCode.InvalidArgument);
|
|
25
26
|
}
|
|
26
27
|
_handle = new GeometryHandle(handle);
|
|
27
28
|
}
|
|
@@ -31,6 +32,16 @@ namespace AUTD3
|
|
|
31
32
|
_handle = handle;
|
|
32
33
|
}
|
|
33
34
|
|
|
35
|
+
internal Geometry Clone()
|
|
36
|
+
{
|
|
37
|
+
var handle = NativeCore.autd3_core_geometry_clone(Handle);
|
|
38
|
+
if (handle == IntPtr.Zero)
|
|
39
|
+
{
|
|
40
|
+
throw new Autd3Exception("failed to clone geometry");
|
|
41
|
+
}
|
|
42
|
+
return new Geometry(new GeometryHandle(handle));
|
|
43
|
+
}
|
|
44
|
+
|
|
34
45
|
public static Geometry FromJson(string json)
|
|
35
46
|
{
|
|
36
47
|
var err = new byte[NativeAbi.ErrorBufferLength];
|
|
@@ -66,6 +77,17 @@ namespace AUTD3
|
|
|
66
77
|
|
|
67
78
|
public bool IsEmpty => NumDevices == 0;
|
|
68
79
|
|
|
80
|
+
public bool[][] OutputMaskBuffer()
|
|
81
|
+
{
|
|
82
|
+
var masks = new bool[NumDevices][];
|
|
83
|
+
for (var dev = 0; dev < masks.Length; dev++)
|
|
84
|
+
{
|
|
85
|
+
masks[dev] = new bool[this[dev].NumTransducers];
|
|
86
|
+
Array.Fill(masks[dev], true);
|
|
87
|
+
}
|
|
88
|
+
return masks;
|
|
89
|
+
}
|
|
90
|
+
|
|
69
91
|
public Vector3 Center
|
|
70
92
|
{
|
|
71
93
|
get
|
|
@@ -160,13 +182,30 @@ namespace AUTD3
|
|
|
160
182
|
get
|
|
161
183
|
{
|
|
162
184
|
var n = NumTransducers;
|
|
185
|
+
var flat = new float[n * 3];
|
|
186
|
+
if (NativeCore.autd3_core_device_positions(_geometry, _dev, flat, (UIntPtr)flat.Length) != 0)
|
|
187
|
+
{
|
|
188
|
+
throw new Autd3Exception("failed to read the transducer positions");
|
|
189
|
+
}
|
|
163
190
|
var result = new Vector3[n];
|
|
164
191
|
for (var i = 0; i < n; i++)
|
|
165
|
-
|
|
192
|
+
{
|
|
193
|
+
result[i] = Coords.FromPoint(new System.Numerics.Vector3(flat[i * 3], flat[i * 3 + 1], flat[i * 3 + 2]));
|
|
194
|
+
}
|
|
166
195
|
return result;
|
|
167
196
|
}
|
|
168
197
|
}
|
|
169
198
|
|
|
199
|
+
public Vector3 ToLocal(Vector3 point)
|
|
200
|
+
{
|
|
201
|
+
var xyz = new float[3];
|
|
202
|
+
if (NativeCore.autd3_core_device_to_local(_geometry, _dev, Coords.PointArray(point), xyz) != 0)
|
|
203
|
+
{
|
|
204
|
+
throw new Autd3Exception("failed to convert the point to the device frame");
|
|
205
|
+
}
|
|
206
|
+
return Coords.FromPointArray(xyz);
|
|
207
|
+
}
|
|
208
|
+
|
|
170
209
|
public Vector3[] Directions
|
|
171
210
|
{
|
|
172
211
|
get
|
package/Native.cs
CHANGED
|
@@ -21,7 +21,7 @@ namespace AUTD3
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
24
|
-
internal static extern IntPtr autd3_core_geometry_new(Autd3Device[] devices, UIntPtr len);
|
|
24
|
+
internal static extern IntPtr autd3_core_geometry_new(Autd3Device[] devices, UIntPtr len, byte[] outErr, UIntPtr outErrLen);
|
|
25
25
|
|
|
26
26
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
27
27
|
internal static extern IntPtr autd3_core_geometry_from_json([MarshalAs(UnmanagedType.LPUTF8Str)] string json, byte[] outErr, UIntPtr outErrLen);
|
|
@@ -68,11 +68,62 @@ namespace AUTD3
|
|
|
68
68
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
69
69
|
internal static extern int autd3_core_transducer_direction(GeometryHandle geometry, UIntPtr dev, UIntPtr tr, [Out] float[] outXyz);
|
|
70
70
|
|
|
71
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
72
|
+
internal static extern IntPtr autd3_core_geometry_clone(GeometryHandle geometry);
|
|
73
|
+
|
|
71
74
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
72
75
|
internal static extern void autd3_core_geometry_free(IntPtr geometry);
|
|
73
76
|
|
|
74
77
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
75
|
-
internal static extern
|
|
78
|
+
internal static extern int autd3_core_device_positions(GeometryHandle geometry, UIntPtr dev, [Out] float[] dst, UIntPtr len);
|
|
79
|
+
|
|
80
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
81
|
+
internal static extern int autd3_core_device_to_local(GeometryHandle geometry, UIntPtr dev, float[] point, [Out] float[] outXyz);
|
|
82
|
+
|
|
83
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
84
|
+
internal static extern byte autd3_core_phase_from_rad(float radian);
|
|
85
|
+
|
|
86
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
87
|
+
internal static extern ulong autd3_core_params_ultrasound_period_ns();
|
|
88
|
+
|
|
89
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
90
|
+
internal static extern uint autd3_core_params_ultrasound_freq_hz();
|
|
91
|
+
|
|
92
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
93
|
+
internal static extern UIntPtr autd3_core_params_mod_buffer_samples();
|
|
94
|
+
|
|
95
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
96
|
+
internal static extern UIntPtr autd3_core_params_buffer_size_min();
|
|
97
|
+
|
|
98
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
99
|
+
internal static extern UIntPtr autd3_core_params_emission_max_indices();
|
|
100
|
+
|
|
101
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
102
|
+
internal static extern byte autd3_core_params_num_foci_max();
|
|
103
|
+
|
|
104
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
105
|
+
internal static extern ushort autd3_core_params_pulse_width_period();
|
|
106
|
+
|
|
107
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
108
|
+
internal static extern UIntPtr autd3_core_params_max_inflight();
|
|
109
|
+
|
|
110
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
111
|
+
internal static extern UIntPtr autd3_core_params_num_transducers();
|
|
112
|
+
|
|
113
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
114
|
+
internal static extern uint autd3_core_params_grid_x();
|
|
115
|
+
|
|
116
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
117
|
+
internal static extern uint autd3_core_params_grid_y();
|
|
118
|
+
|
|
119
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
120
|
+
internal static extern float autd3_core_params_pitch_mm();
|
|
121
|
+
|
|
122
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
123
|
+
internal static extern float autd3_core_params_device_width_mm();
|
|
124
|
+
|
|
125
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
126
|
+
internal static extern float autd3_core_params_device_height_mm();
|
|
76
127
|
|
|
77
128
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
78
129
|
internal static extern IntPtr autd3_core_sampling_config_divide(ushort divide);
|
|
@@ -90,13 +141,7 @@ namespace AUTD3
|
|
|
90
141
|
internal static extern IntPtr autd3_core_sampling_config_period_nearest(ulong nanos);
|
|
91
142
|
|
|
92
143
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
93
|
-
internal static extern int
|
|
94
|
-
|
|
95
|
-
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
96
|
-
internal static extern int autd3_core_sampling_config_freq_value(IntPtr config, out float outValue);
|
|
97
|
-
|
|
98
|
-
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
99
|
-
internal static extern int autd3_core_sampling_config_period_value(IntPtr config, out ulong outValue);
|
|
144
|
+
internal static extern int autd3_core_sampling_config_resolve(IntPtr config, out ushort @out, byte[] outErr, UIntPtr outErrLen);
|
|
100
145
|
|
|
101
146
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
102
147
|
internal static extern void autd3_core_sampling_config_free(IntPtr config);
|
|
@@ -105,7 +150,7 @@ namespace AUTD3
|
|
|
105
150
|
internal static class NativeAbi
|
|
106
151
|
{
|
|
107
152
|
internal const ushort Major = 0;
|
|
108
|
-
internal const ushort Minor =
|
|
153
|
+
internal const ushort Minor = 10;
|
|
109
154
|
internal const ushort Patch = 0;
|
|
110
155
|
|
|
111
156
|
internal const int ErrorBufferLength = 1024;
|
|
@@ -124,7 +169,7 @@ namespace AUTD3
|
|
|
124
169
|
}
|
|
125
170
|
}
|
|
126
171
|
|
|
127
|
-
internal static class
|
|
172
|
+
internal static class OptionNative
|
|
128
173
|
{
|
|
129
174
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
130
175
|
internal delegate int SetDurationFn(IntPtr option, ulong ns);
|
|
@@ -132,34 +177,17 @@ namespace AUTD3
|
|
|
132
177
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
133
178
|
internal delegate int GetDurationFn(IntPtr option, out ulong ns);
|
|
134
179
|
|
|
135
|
-
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
136
|
-
internal delegate int SetOptionalDurationFn(IntPtr option, [MarshalAs(UnmanagedType.I1)] bool hasValue, ulong ns);
|
|
137
|
-
|
|
138
|
-
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
139
|
-
internal delegate int GetOptionalDurationFn(IntPtr option, [MarshalAs(UnmanagedType.I1)] out bool hasValue, out ulong ns);
|
|
140
|
-
|
|
141
|
-
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
142
|
-
internal delegate IntPtr OpenFn(IntPtr option, byte[] outErr, UIntPtr outErrLen);
|
|
143
|
-
|
|
144
180
|
internal static void Apply(string field, int code)
|
|
145
181
|
{
|
|
146
182
|
if (code != 0)
|
|
147
183
|
{
|
|
148
|
-
throw new Autd3Exception($"`{field}` is out of the range the native library accepts");
|
|
184
|
+
throw new Autd3Exception($"`{field}` is out of the range the native library accepts", Autd3ErrorCode.InvalidArgument);
|
|
149
185
|
}
|
|
150
186
|
}
|
|
151
187
|
|
|
152
|
-
internal static void
|
|
188
|
+
internal static void SetRequiredDuration(IntPtr option, string field, TimeSpan value, SetDurationFn set)
|
|
153
189
|
{
|
|
154
|
-
|
|
155
|
-
{
|
|
156
|
-
Apply(field, set(option, ToNanos(v)));
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
internal static void SetOptionalDuration(IntPtr option, string field, TimeSpan? value, SetOptionalDurationFn set)
|
|
161
|
-
{
|
|
162
|
-
Apply(field, set(option, value.HasValue, value.HasValue ? ToNanos(value.Value) : 0UL));
|
|
190
|
+
Apply(field, value < TimeSpan.Zero ? -1 : set(option, ToNanos(value)));
|
|
163
191
|
}
|
|
164
192
|
|
|
165
193
|
internal static TimeSpan GetDuration(IntPtr option, GetDurationFn get)
|
|
@@ -168,27 +196,8 @@ namespace AUTD3
|
|
|
168
196
|
return FromNanos(ns);
|
|
169
197
|
}
|
|
170
198
|
|
|
171
|
-
internal static
|
|
172
|
-
|
|
173
|
-
Apply("preset", get(option, out var hasValue, out var ns));
|
|
174
|
-
return hasValue ? FromNanos(ns) : (TimeSpan?)null;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
internal static IntPtr TakeOpener(string link, IntPtr option, OpenFn open)
|
|
178
|
-
{
|
|
179
|
-
var err = new byte[NativeAbi.ErrorBufferLength];
|
|
180
|
-
var opener = open(option, err, (UIntPtr)err.Length);
|
|
181
|
-
if (opener == IntPtr.Zero)
|
|
182
|
-
{
|
|
183
|
-
var reason = NativeUtil.Utf8(err);
|
|
184
|
-
throw new Autd3Exception(reason.Length == 0
|
|
185
|
-
? $"failed to create {link} link"
|
|
186
|
-
: $"failed to create {link} link: {reason}");
|
|
187
|
-
}
|
|
188
|
-
return opener;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
internal static ulong ToNanos(TimeSpan value) => (ulong)value.Ticks * 100UL;
|
|
199
|
+
internal static ulong ToNanos(TimeSpan value) =>
|
|
200
|
+
(ulong)value.Ticks > ulong.MaxValue / 100UL ? ulong.MaxValue : (ulong)value.Ticks * 100UL;
|
|
192
201
|
|
|
193
202
|
internal static TimeSpan FromNanos(ulong ns) => TimeSpan.FromTicks((long)(ns / 100));
|
|
194
203
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/SamplingConfig.cs
CHANGED
|
@@ -2,11 +2,11 @@ using System;
|
|
|
2
2
|
|
|
3
3
|
namespace AUTD3
|
|
4
4
|
{
|
|
5
|
-
public readonly struct SamplingConfig
|
|
5
|
+
public readonly struct SamplingConfig : IEquatable<SamplingConfig>
|
|
6
6
|
{
|
|
7
7
|
private enum Kind : byte
|
|
8
8
|
{
|
|
9
|
-
|
|
9
|
+
Unset,
|
|
10
10
|
Divide,
|
|
11
11
|
Freq,
|
|
12
12
|
FreqNearest,
|
|
@@ -18,6 +18,7 @@ namespace AUTD3
|
|
|
18
18
|
private readonly ushort _divide;
|
|
19
19
|
private readonly float _freq;
|
|
20
20
|
private readonly ulong _periodNs;
|
|
21
|
+
private readonly ushort _resolved;
|
|
21
22
|
|
|
22
23
|
private SamplingConfig(Kind kind, ushort divide, float freq, ulong periodNs)
|
|
23
24
|
{
|
|
@@ -25,25 +26,28 @@ namespace AUTD3
|
|
|
25
26
|
_divide = divide;
|
|
26
27
|
_freq = freq;
|
|
27
28
|
_periodNs = periodNs;
|
|
29
|
+
_resolved = 0;
|
|
30
|
+
_resolved = Resolve(out _);
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
public SamplingConfig(ushort divide)
|
|
31
34
|
{
|
|
32
35
|
if (divide == 0)
|
|
33
36
|
{
|
|
34
|
-
throw new Autd3Exception("sampling divide must be >= 1");
|
|
37
|
+
throw new Autd3Exception("sampling divide must be >= 1", Autd3ErrorCode.InvalidArgument);
|
|
35
38
|
}
|
|
36
39
|
_kind = Kind.Divide;
|
|
37
40
|
_divide = divide;
|
|
38
41
|
_freq = 0f;
|
|
39
42
|
_periodNs = 0;
|
|
43
|
+
_resolved = divide;
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
public SamplingConfig(Freq freq) : this(Kind.Freq, 0, freq.Hz, 0)
|
|
43
47
|
{
|
|
44
48
|
}
|
|
45
49
|
|
|
46
|
-
public SamplingConfig(TimeSpan period) : this(Kind.Period, 0, 0f, (
|
|
50
|
+
public SamplingConfig(TimeSpan period) : this(Kind.Period, 0, 0f, PeriodNanos(period))
|
|
47
51
|
{
|
|
48
52
|
}
|
|
49
53
|
|
|
@@ -51,58 +55,77 @@ namespace AUTD3
|
|
|
51
55
|
{
|
|
52
56
|
}
|
|
53
57
|
|
|
54
|
-
public SamplingConfig(Nearest<TimeSpan> period) : this(Kind.PeriodNearest, 0, 0f, (
|
|
58
|
+
public SamplingConfig(Nearest<TimeSpan> period) : this(Kind.PeriodNearest, 0, 0f, PeriodNanos(period.Value))
|
|
55
59
|
{
|
|
56
60
|
}
|
|
57
61
|
|
|
62
|
+
private static ulong PeriodNanos(TimeSpan period)
|
|
63
|
+
{
|
|
64
|
+
if (period < TimeSpan.Zero)
|
|
65
|
+
{
|
|
66
|
+
throw new Autd3Exception("a sampling period must not be negative", Autd3ErrorCode.InvalidArgument);
|
|
67
|
+
}
|
|
68
|
+
return OptionNative.ToNanos(period);
|
|
69
|
+
}
|
|
70
|
+
|
|
58
71
|
public static SamplingConfig Freq4k => new SamplingConfig(4000 * Units.Hz);
|
|
59
72
|
|
|
60
73
|
public static SamplingConfig Freq40k => new SamplingConfig(40000 * Units.Hz);
|
|
61
74
|
|
|
62
75
|
public ushort Divide()
|
|
63
76
|
{
|
|
64
|
-
|
|
65
|
-
try
|
|
77
|
+
if (_resolved != 0)
|
|
66
78
|
{
|
|
67
|
-
|
|
68
|
-
{
|
|
69
|
-
throw new Autd3Exception("sampling config cannot be resolved to a divider");
|
|
70
|
-
}
|
|
71
|
-
return value;
|
|
79
|
+
return _resolved;
|
|
72
80
|
}
|
|
73
|
-
|
|
81
|
+
var divide = Resolve(out var error);
|
|
82
|
+
if (divide == 0)
|
|
74
83
|
{
|
|
75
|
-
|
|
84
|
+
throw new Autd3Exception(error, Autd3ErrorCode.InvalidArgument);
|
|
76
85
|
}
|
|
86
|
+
return divide;
|
|
77
87
|
}
|
|
78
88
|
|
|
79
|
-
public Freq Freq()
|
|
89
|
+
public Freq Freq() => (float)Params.UltrasoundFreqHz / Divide() * Units.Hz;
|
|
90
|
+
|
|
91
|
+
public TimeSpan Period() => TimeSpan.FromTicks(Params.UltrasoundPeriod.Ticks * Divide());
|
|
92
|
+
|
|
93
|
+
public bool Equals(SamplingConfig other)
|
|
80
94
|
{
|
|
81
|
-
var
|
|
82
|
-
|
|
83
|
-
{
|
|
84
|
-
if (NativeCore.autd3_core_sampling_config_freq_value(handle, out var value) != 0)
|
|
85
|
-
{
|
|
86
|
-
throw new Autd3Exception("sampling config cannot be resolved to a frequency");
|
|
87
|
-
}
|
|
88
|
-
return value * Units.Hz;
|
|
89
|
-
}
|
|
90
|
-
finally
|
|
91
|
-
{
|
|
92
|
-
NativeCore.autd3_core_sampling_config_free(handle);
|
|
93
|
-
}
|
|
95
|
+
var lhs = TryDivide();
|
|
96
|
+
return lhs != 0 && lhs == other.TryDivide();
|
|
94
97
|
}
|
|
95
98
|
|
|
96
|
-
public
|
|
99
|
+
public override bool Equals(object? obj) => obj is SamplingConfig other && Equals(other);
|
|
100
|
+
|
|
101
|
+
public override int GetHashCode() => TryDivide();
|
|
102
|
+
|
|
103
|
+
public static bool operator ==(SamplingConfig left, SamplingConfig right) => left.Equals(right);
|
|
104
|
+
|
|
105
|
+
public static bool operator !=(SamplingConfig left, SamplingConfig right) => !left.Equals(right);
|
|
106
|
+
|
|
107
|
+
private ushort TryDivide() => _resolved != 0 ? _resolved : Resolve(out _);
|
|
108
|
+
|
|
109
|
+
private const string UnsetMessage = "the sampling config is not set (default(SamplingConfig) has no value)";
|
|
110
|
+
|
|
111
|
+
private ushort Resolve(out string error)
|
|
97
112
|
{
|
|
113
|
+
error = string.Empty;
|
|
114
|
+
if (_kind == Kind.Unset)
|
|
115
|
+
{
|
|
116
|
+
error = UnsetMessage;
|
|
117
|
+
return 0;
|
|
118
|
+
}
|
|
98
119
|
var handle = CreateHandle();
|
|
99
120
|
try
|
|
100
121
|
{
|
|
101
|
-
|
|
122
|
+
var err = new byte[NativeAbi.ErrorBufferLength];
|
|
123
|
+
if (NativeCore.autd3_core_sampling_config_resolve(handle, out var value, err, (UIntPtr)err.Length) != 0)
|
|
102
124
|
{
|
|
103
|
-
|
|
125
|
+
error = NativeUtil.Utf8(err);
|
|
126
|
+
return 0;
|
|
104
127
|
}
|
|
105
|
-
return
|
|
128
|
+
return value;
|
|
106
129
|
}
|
|
107
130
|
finally
|
|
108
131
|
{
|
|
@@ -112,9 +135,12 @@ namespace AUTD3
|
|
|
112
135
|
|
|
113
136
|
internal IntPtr CreateHandle()
|
|
114
137
|
{
|
|
138
|
+
if (_kind == Kind.Unset)
|
|
139
|
+
{
|
|
140
|
+
throw new Autd3Exception(UnsetMessage, Autd3ErrorCode.InvalidArgument);
|
|
141
|
+
}
|
|
115
142
|
var handle = _kind switch
|
|
116
143
|
{
|
|
117
|
-
Kind.Default => NativeCore.autd3_core_sampling_config_freq(4000f),
|
|
118
144
|
Kind.Divide => NativeCore.autd3_core_sampling_config_divide(_divide),
|
|
119
145
|
Kind.Freq => NativeCore.autd3_core_sampling_config_freq(_freq),
|
|
120
146
|
Kind.FreqNearest => NativeCore.autd3_core_sampling_config_freq_nearest(_freq),
|
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 (36)
|
|
9
9
|
- Apache License 2.0 (3)
|
|
10
10
|
- Unicode License v3 (1)
|
|
11
11
|
|
|
@@ -437,79 +437,9 @@ Used by:
|
|
|
437
437
|
|
|
438
438
|
Used by:
|
|
439
439
|
|
|
440
|
-
-
|
|
441
|
-
|
|
442
|
-
```
|
|
443
|
-
Copyright (c) 2014 Alex Crichton
|
|
444
|
-
|
|
445
|
-
Permission is hereby granted, free of charge, to any
|
|
446
|
-
person obtaining a copy of this software and associated
|
|
447
|
-
documentation files (the "Software"), to deal in the
|
|
448
|
-
Software without restriction, including without
|
|
449
|
-
limitation the rights to use, copy, modify, merge,
|
|
450
|
-
publish, distribute, sublicense, and/or sell copies of
|
|
451
|
-
the Software, and to permit persons to whom the Software
|
|
452
|
-
is furnished to do so, subject to the following
|
|
453
|
-
conditions:
|
|
454
|
-
|
|
455
|
-
The above copyright notice and this permission notice
|
|
456
|
-
shall be included in all copies or substantial portions
|
|
457
|
-
of the Software.
|
|
458
|
-
|
|
459
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
|
460
|
-
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
461
|
-
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
462
|
-
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
|
463
|
-
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
464
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
465
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
|
466
|
-
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
467
|
-
DEALINGS IN THE SOFTWARE.
|
|
468
|
-
|
|
469
|
-
```
|
|
470
|
-
|
|
471
|
-
## MIT License
|
|
472
|
-
|
|
473
|
-
Used by:
|
|
474
|
-
|
|
475
|
-
- core_affinity 0.8.3 — https://github.com/Elzair/core_affinity_rs
|
|
476
|
-
|
|
477
|
-
```
|
|
478
|
-
Copyright (c) 2014 The Rust Project Developers
|
|
479
|
-
|
|
480
|
-
Permission is hereby granted, free of charge, to any
|
|
481
|
-
person obtaining a copy of this software and associated
|
|
482
|
-
documentation files (the "Software"), to deal in the
|
|
483
|
-
Software without restriction, including without
|
|
484
|
-
limitation the rights to use, copy, modify, merge,
|
|
485
|
-
publish, distribute, sublicense, and/or sell copies of
|
|
486
|
-
the Software, and to permit persons to whom the Software
|
|
487
|
-
is furnished to do so, subject to the following
|
|
488
|
-
conditions:
|
|
489
|
-
|
|
490
|
-
The above copyright notice and this permission notice
|
|
491
|
-
shall be included in all copies or substantial portions
|
|
492
|
-
of the Software.
|
|
493
|
-
|
|
494
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
|
495
|
-
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
496
|
-
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
497
|
-
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
|
498
|
-
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
499
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
500
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
|
501
|
-
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
502
|
-
DEALINGS IN THE SOFTWARE.
|
|
503
|
-
```
|
|
504
|
-
|
|
505
|
-
## MIT License
|
|
506
|
-
|
|
507
|
-
Used by:
|
|
508
|
-
|
|
509
|
-
- bitflags 2.13.0 — https://github.com/bitflags/bitflags
|
|
510
|
-
- log 0.4.33 — https://github.com/rust-lang/log
|
|
440
|
+
- bitflags 2.13.2 — https://github.com/bitflags/bitflags
|
|
511
441
|
- num-complex 0.4.6 — https://github.com/rust-num/num-complex
|
|
512
|
-
- num-integer 0.1.
|
|
442
|
+
- num-integer 0.1.47 — https://github.com/rust-num/num-integer
|
|
513
443
|
- num-rational 0.4.2 — https://github.com/rust-num/num-rational
|
|
514
444
|
- num-traits 0.2.19 — https://github.com/rust-num/num-traits
|
|
515
445
|
|
|
@@ -575,65 +505,6 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
|
|
575
505
|
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
576
506
|
DEALINGS IN THE SOFTWARE.
|
|
577
507
|
|
|
578
|
-
```
|
|
579
|
-
|
|
580
|
-
## MIT License
|
|
581
|
-
|
|
582
|
-
Used by:
|
|
583
|
-
|
|
584
|
-
- winapi 0.3.9 — https://github.com/retep998/winapi-rs
|
|
585
|
-
|
|
586
|
-
```
|
|
587
|
-
Copyright (c) 2015-2018 The winapi-rs Developers
|
|
588
|
-
|
|
589
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
590
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
591
|
-
in the Software without restriction, including without limitation the rights
|
|
592
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
593
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
594
|
-
furnished to do so, subject to the following conditions:
|
|
595
|
-
|
|
596
|
-
The above copyright notice and this permission notice shall be included in all
|
|
597
|
-
copies or substantial portions of the Software.
|
|
598
|
-
|
|
599
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
600
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
601
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
602
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
603
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
604
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
605
|
-
SOFTWARE.
|
|
606
|
-
|
|
607
|
-
```
|
|
608
|
-
|
|
609
|
-
## MIT License
|
|
610
|
-
|
|
611
|
-
Used by:
|
|
612
|
-
|
|
613
|
-
- num_cpus 1.17.0 — https://github.com/seanmonstar/num_cpus
|
|
614
|
-
|
|
615
|
-
```
|
|
616
|
-
Copyright (c) 2015-2025 Sean McArthur
|
|
617
|
-
|
|
618
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
619
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
620
|
-
in the Software without restriction, including without limitation the rights
|
|
621
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
622
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
623
|
-
furnished to do so, subject to the following conditions:
|
|
624
|
-
|
|
625
|
-
The above copyright notice and this permission notice shall be included in
|
|
626
|
-
all copies or substantial portions of the Software.
|
|
627
|
-
|
|
628
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
629
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
630
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
631
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
632
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
633
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
634
|
-
THE SOFTWARE.
|
|
635
|
-
|
|
636
|
-
|
|
637
508
|
```
|
|
638
509
|
|
|
639
510
|
## MIT License
|
|
@@ -713,10 +584,11 @@ DEALINGS IN THE SOFTWARE.
|
|
|
713
584
|
|
|
714
585
|
Used by:
|
|
715
586
|
|
|
716
|
-
-
|
|
587
|
+
- zerocopy-derive 0.8.52 — https://github.com/google/zerocopy
|
|
588
|
+
- zerocopy 0.8.52 — https://github.com/google/zerocopy
|
|
717
589
|
|
|
718
590
|
```
|
|
719
|
-
Copyright
|
|
591
|
+
Copyright 2023 The Fuchsia Authors
|
|
720
592
|
|
|
721
593
|
Permission is hereby granted, free of charge, to any
|
|
722
594
|
person obtaining a copy of this software and associated
|
|
@@ -742,42 +614,37 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
|
|
742
614
|
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
743
615
|
DEALINGS IN THE SOFTWARE.
|
|
744
616
|
|
|
617
|
+
|
|
745
618
|
```
|
|
746
619
|
|
|
747
620
|
## MIT License
|
|
748
621
|
|
|
749
622
|
Used by:
|
|
750
623
|
|
|
751
|
-
-
|
|
752
|
-
- zerocopy 0.8.52 — https://github.com/google/zerocopy
|
|
624
|
+
- crc 3.4.0 — https://github.com/mrhooray/crc-rs.git
|
|
753
625
|
|
|
754
626
|
```
|
|
755
|
-
|
|
627
|
+
MIT License
|
|
756
628
|
|
|
757
|
-
|
|
758
|
-
person obtaining a copy of this software and associated
|
|
759
|
-
documentation files (the "Software"), to deal in the
|
|
760
|
-
Software without restriction, including without
|
|
761
|
-
limitation the rights to use, copy, modify, merge,
|
|
762
|
-
publish, distribute, sublicense, and/or sell copies of
|
|
763
|
-
the Software, and to permit persons to whom the Software
|
|
764
|
-
is furnished to do so, subject to the following
|
|
765
|
-
conditions:
|
|
629
|
+
Copyright (c) 2017 crc-rs Developers
|
|
766
630
|
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
631
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
632
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
633
|
+
in the Software without restriction, including without limitation the rights
|
|
634
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
635
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
636
|
+
furnished to do so, subject to the following conditions:
|
|
770
637
|
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
774
|
-
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
|
775
|
-
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
776
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
777
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
|
778
|
-
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
779
|
-
DEALINGS IN THE SOFTWARE.
|
|
638
|
+
The above copyright notice and this permission notice shall be included in all
|
|
639
|
+
copies or substantial portions of the Software.
|
|
780
640
|
|
|
641
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
642
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
643
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
644
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
645
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
646
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
647
|
+
SOFTWARE.
|
|
781
648
|
|
|
782
649
|
```
|
|
783
650
|
|
|
@@ -785,12 +652,12 @@ DEALINGS IN THE SOFTWARE.
|
|
|
785
652
|
|
|
786
653
|
Used by:
|
|
787
654
|
|
|
788
|
-
-
|
|
655
|
+
- crc-catalog 2.5.0 — https://github.com/akhilles/crc-catalog.git
|
|
789
656
|
|
|
790
657
|
```
|
|
791
658
|
MIT License
|
|
792
659
|
|
|
793
|
-
Copyright (c)
|
|
660
|
+
Copyright (c) 2019 Akhil Velagapudi
|
|
794
661
|
|
|
795
662
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
796
663
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -854,8 +721,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
854
721
|
|
|
855
722
|
Used by:
|
|
856
723
|
|
|
857
|
-
- autd3-rs-core 0.
|
|
858
|
-
- autd3-cpu-wire 0.
|
|
724
|
+
- autd3-rs-core 0.10.0 — https://github.com/shinolab/autd3-sdk
|
|
725
|
+
- autd3-cpu-wire 0.10.0 — https://github.com/shinolab/autd3-sdk
|
|
859
726
|
|
|
860
727
|
```
|
|
861
728
|
MIT License
|
|
@@ -886,23 +753,9 @@ SOFTWARE.
|
|
|
886
753
|
|
|
887
754
|
Used by:
|
|
888
755
|
|
|
889
|
-
- autd3-ffi-abi 0.
|
|
890
|
-
- autd3-ffi-core 0.
|
|
891
|
-
- chrono 0.4.45 — https://github.com/chronotope/chrono
|
|
756
|
+
- autd3-ffi-abi 0.10.0 — https://github.com/shinolab/autd3-sdk
|
|
757
|
+
- autd3-ffi-core 0.10.0 — https://github.com/shinolab/autd3-sdk
|
|
892
758
|
- wide 1.5.0 — https://github.com/Lokathor/wide
|
|
893
|
-
- winapi-i686-pc-windows-gnu 0.4.0 — https://github.com/retep998/winapi-rs
|
|
894
|
-
- winapi-x86_64-pc-windows-gnu 0.4.0 — https://github.com/retep998/winapi-rs
|
|
895
|
-
- windows-collections 0.3.2 — https://github.com/microsoft/windows-rs
|
|
896
|
-
- windows-core 0.62.2 — https://github.com/microsoft/windows-rs
|
|
897
|
-
- windows-future 0.3.2 — https://github.com/microsoft/windows-rs
|
|
898
|
-
- windows-implement 0.60.2 — https://github.com/microsoft/windows-rs
|
|
899
|
-
- windows-interface 0.59.3 — https://github.com/microsoft/windows-rs
|
|
900
|
-
- windows-link 0.2.1 — https://github.com/microsoft/windows-rs
|
|
901
|
-
- windows-numerics 0.3.1 — https://github.com/microsoft/windows-rs
|
|
902
|
-
- windows-result 0.4.1 — https://github.com/microsoft/windows-rs
|
|
903
|
-
- windows-strings 0.5.1 — https://github.com/microsoft/windows-rs
|
|
904
|
-
- windows-threading 0.2.1 — https://github.com/microsoft/windows-rs
|
|
905
|
-
- windows 0.62.2 — https://github.com/microsoft/windows-rs
|
|
906
759
|
|
|
907
760
|
```
|
|
908
761
|
MIT License
|
|
@@ -930,12 +783,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
930
783
|
|
|
931
784
|
Used by:
|
|
932
785
|
|
|
933
|
-
- hermit-abi 0.5.2 — https://github.com/hermit-os/hermit-rs
|
|
934
786
|
- itoa 1.0.18 — https://github.com/dtolnay/itoa
|
|
935
787
|
- pin-project-lite 0.2.17 — https://github.com/taiki-e/pin-project-lite
|
|
936
788
|
- proc-macro2 1.0.106 — https://github.com/dtolnay/proc-macro2
|
|
937
789
|
- quote 1.0.46 — https://github.com/dtolnay/quote
|
|
938
|
-
- rustversion 1.0.22 — https://github.com/dtolnay/rustversion
|
|
939
790
|
- serde 1.0.228 — https://github.com/serde-rs/serde
|
|
940
791
|
- serde_core 1.0.228 — https://github.com/serde-rs/serde
|
|
941
792
|
- serde_derive 1.0.228 — https://github.com/serde-rs/serde
|
package/Types.cs
CHANGED
|
@@ -3,21 +3,56 @@ using System.Numerics;
|
|
|
3
3
|
|
|
4
4
|
namespace AUTD3
|
|
5
5
|
{
|
|
6
|
+
public enum Autd3ErrorCode
|
|
7
|
+
{
|
|
8
|
+
Error = -1,
|
|
9
|
+
Timeout = -2,
|
|
10
|
+
Device = -3,
|
|
11
|
+
Network = -4,
|
|
12
|
+
InvalidArgument = -5,
|
|
13
|
+
UnsupportedFirmware = -6,
|
|
14
|
+
Aborted = -7,
|
|
15
|
+
}
|
|
16
|
+
|
|
6
17
|
public sealed class Autd3Exception : Exception
|
|
7
18
|
{
|
|
8
|
-
public
|
|
19
|
+
public Autd3ErrorCode Code { get; }
|
|
20
|
+
|
|
21
|
+
public Autd3Exception(string message) : this(message, Autd3ErrorCode.Error)
|
|
9
22
|
{
|
|
10
23
|
}
|
|
24
|
+
|
|
25
|
+
public Autd3Exception(string message, Autd3ErrorCode code) : base(message)
|
|
26
|
+
{
|
|
27
|
+
Code = code;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
internal static Autd3Exception FromNative(int code, string message) =>
|
|
31
|
+
new Autd3Exception(message, Enum.IsDefined(typeof(Autd3ErrorCode), code) ? (Autd3ErrorCode)code : Autd3ErrorCode.Error);
|
|
32
|
+
|
|
33
|
+
internal static Autd3Exception FromNative(int code, byte[] err) => FromNative(code, NativeUtil.Utf8(err));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public static class Params
|
|
37
|
+
{
|
|
38
|
+
public static readonly TimeSpan UltrasoundPeriod = OptionNative.FromNanos(NativeCore.autd3_core_params_ultrasound_period_ns());
|
|
39
|
+
public static readonly uint UltrasoundFreqHz = NativeCore.autd3_core_params_ultrasound_freq_hz();
|
|
40
|
+
public static readonly int ModBufferSamples = (int)NativeCore.autd3_core_params_mod_buffer_samples();
|
|
41
|
+
public static readonly int BufferSizeMin = (int)NativeCore.autd3_core_params_buffer_size_min();
|
|
42
|
+
public static readonly int EmissionMaxIndices = (int)NativeCore.autd3_core_params_emission_max_indices();
|
|
43
|
+
public static readonly byte NumFociMax = NativeCore.autd3_core_params_num_foci_max();
|
|
44
|
+
public static readonly ushort PulseWidthPeriod = NativeCore.autd3_core_params_pulse_width_period();
|
|
45
|
+
public static readonly int MaxInflight = (int)NativeCore.autd3_core_params_max_inflight();
|
|
11
46
|
}
|
|
12
47
|
|
|
13
48
|
public readonly struct Autd3
|
|
14
49
|
{
|
|
15
|
-
public
|
|
16
|
-
public
|
|
17
|
-
public
|
|
18
|
-
public
|
|
19
|
-
public
|
|
20
|
-
public
|
|
50
|
+
public static readonly int NumTransducers = (int)NativeCore.autd3_core_params_num_transducers();
|
|
51
|
+
public static readonly uint GridX = NativeCore.autd3_core_params_grid_x();
|
|
52
|
+
public static readonly uint GridY = NativeCore.autd3_core_params_grid_y();
|
|
53
|
+
public static readonly float PitchMm = NativeCore.autd3_core_params_pitch_mm();
|
|
54
|
+
public static readonly float DeviceWidth = NativeCore.autd3_core_params_device_width_mm();
|
|
55
|
+
public static readonly float DeviceHeight = NativeCore.autd3_core_params_device_height_mm();
|
|
21
56
|
|
|
22
57
|
public Vector3 Origin { get; }
|
|
23
58
|
public Quaternion Rotation { get; }
|
|
@@ -88,13 +123,10 @@ namespace AUTD3
|
|
|
88
123
|
public static Phase Zero => new Phase(0x00);
|
|
89
124
|
public static Phase Pi => new Phase(0x80);
|
|
90
125
|
|
|
91
|
-
public float Rad() =>
|
|
126
|
+
public float Rad() => Value / 256f * 2f * MathF.PI;
|
|
92
127
|
|
|
93
|
-
public static explicit operator Phase(Angle angle)
|
|
94
|
-
|
|
95
|
-
var p = (int)MathF.Round(angle.Rad / (2f * MathF.PI) * 256f);
|
|
96
|
-
return new Phase((byte)(p & 0xFF));
|
|
97
|
-
}
|
|
128
|
+
public static explicit operator Phase(Angle angle) =>
|
|
129
|
+
new Phase(NativeCore.autd3_core_phase_from_rad(angle.Rad));
|
|
98
130
|
|
|
99
131
|
public static explicit operator Phase(Complex value) =>
|
|
100
132
|
(Phase)new Angle(MathF.Atan2((float)value.Imaginary, (float)value.Real));
|
|
@@ -114,137 +146,128 @@ namespace AUTD3
|
|
|
114
146
|
new Phase((byte)(lhs.Value / rhs));
|
|
115
147
|
}
|
|
116
148
|
|
|
117
|
-
public readonly struct
|
|
149
|
+
public readonly struct Interface
|
|
118
150
|
{
|
|
119
|
-
|
|
120
|
-
|
|
151
|
+
private const byte KindNic = 0;
|
|
152
|
+
private const byte KindSimulator = 1;
|
|
153
|
+
private const byte KindAddr = 2;
|
|
154
|
+
|
|
155
|
+
private readonly byte _kind;
|
|
156
|
+
private readonly string? _value;
|
|
121
157
|
|
|
122
|
-
|
|
158
|
+
private Interface(byte kind, string? value)
|
|
123
159
|
{
|
|
124
|
-
|
|
125
|
-
|
|
160
|
+
_kind = kind;
|
|
161
|
+
_value = value;
|
|
126
162
|
}
|
|
127
163
|
|
|
128
|
-
public static
|
|
129
|
-
}
|
|
164
|
+
public static Interface Auto => default;
|
|
130
165
|
|
|
131
|
-
|
|
132
|
-
{
|
|
133
|
-
private readonly string? _name;
|
|
166
|
+
public static Interface Simulator => new Interface(KindSimulator, null);
|
|
134
167
|
|
|
135
|
-
|
|
136
|
-
{
|
|
137
|
-
_name = name;
|
|
138
|
-
}
|
|
168
|
+
public static Interface Name(string name) => new Interface(KindNic, name);
|
|
139
169
|
|
|
140
|
-
public static Interface
|
|
170
|
+
public static Interface Addr(string addr) => new Interface(KindAddr, addr);
|
|
171
|
+
|
|
172
|
+
public string? NameValue => _kind == KindNic ? _value : null;
|
|
173
|
+
|
|
174
|
+
public bool IsAuto => _kind == KindNic && _value == null;
|
|
141
175
|
|
|
142
|
-
public
|
|
176
|
+
public bool IsSimulator => _kind == KindSimulator;
|
|
143
177
|
|
|
144
|
-
|
|
178
|
+
public string? AddrValue => _kind == KindAddr ? _value : null;
|
|
145
179
|
}
|
|
146
180
|
|
|
147
181
|
public readonly struct DeviceState : IEquatable<DeviceState>
|
|
148
182
|
{
|
|
149
183
|
private readonly byte _kind;
|
|
150
|
-
private readonly byte _bits;
|
|
151
184
|
|
|
152
|
-
private DeviceState(byte kind
|
|
185
|
+
private DeviceState(byte kind)
|
|
153
186
|
{
|
|
154
187
|
_kind = kind;
|
|
155
|
-
_bits = bits;
|
|
156
188
|
}
|
|
157
189
|
|
|
158
|
-
public static DeviceState
|
|
159
|
-
public static DeviceState
|
|
160
|
-
public static DeviceState
|
|
161
|
-
public static DeviceState Lost => new DeviceState(3, 0);
|
|
162
|
-
public static DeviceState Other(byte bits) => new DeviceState(4, bits);
|
|
190
|
+
public static DeviceState Ready => new DeviceState(0);
|
|
191
|
+
public static DeviceState Syncing => new DeviceState(1);
|
|
192
|
+
public static DeviceState Lost => new DeviceState(2);
|
|
163
193
|
|
|
164
|
-
internal static DeviceState FromNative(byte kind
|
|
194
|
+
internal static DeviceState FromNative(byte kind) => new DeviceState(kind);
|
|
165
195
|
|
|
166
196
|
public override string ToString() => _kind switch
|
|
167
197
|
{
|
|
168
|
-
0 => "
|
|
169
|
-
1 => "
|
|
170
|
-
2 => "
|
|
171
|
-
|
|
172
|
-
_ => _bits switch
|
|
173
|
-
{
|
|
174
|
-
0x00 => "NONE",
|
|
175
|
-
0x01 => "INIT",
|
|
176
|
-
0x02 => "PRE-OP",
|
|
177
|
-
0x03 => "BOOT",
|
|
178
|
-
_ => $"UNKNOWN (0x{_bits:x2})",
|
|
179
|
-
},
|
|
198
|
+
0 => "READY",
|
|
199
|
+
1 => "SYNCING",
|
|
200
|
+
2 => "LOST",
|
|
201
|
+
_ => $"UNKNOWN ({_kind})",
|
|
180
202
|
};
|
|
181
203
|
|
|
182
|
-
public bool Equals(DeviceState other) => _kind == other._kind
|
|
204
|
+
public bool Equals(DeviceState other) => _kind == other._kind;
|
|
183
205
|
|
|
184
206
|
public override bool Equals(object? obj) => obj is DeviceState other && Equals(other);
|
|
185
207
|
|
|
186
|
-
public override int GetHashCode() =>
|
|
208
|
+
public override int GetHashCode() => _kind;
|
|
187
209
|
|
|
188
210
|
public static bool operator ==(DeviceState left, DeviceState right) => left.Equals(right);
|
|
189
211
|
|
|
190
212
|
public static bool operator !=(DeviceState left, DeviceState right) => !left.Equals(right);
|
|
191
213
|
}
|
|
192
214
|
|
|
193
|
-
public readonly struct
|
|
215
|
+
public readonly struct SysTime : IEquatable<SysTime>, IComparable<SysTime>
|
|
194
216
|
{
|
|
195
|
-
private static readonly DateTime EcatEpoch = new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
|
196
|
-
|
|
197
217
|
private readonly ulong _ns;
|
|
198
218
|
|
|
199
|
-
private
|
|
219
|
+
private SysTime(ulong ns)
|
|
200
220
|
{
|
|
201
221
|
_ns = ns;
|
|
202
222
|
}
|
|
203
223
|
|
|
204
|
-
public static
|
|
224
|
+
public static SysTime Zero => new SysTime(0);
|
|
205
225
|
|
|
206
|
-
public static
|
|
226
|
+
public static SysTime FromNanos(ulong ns) => new SysTime(ns);
|
|
207
227
|
|
|
208
|
-
public ulong
|
|
228
|
+
public ulong Nanos => _ns;
|
|
209
229
|
|
|
210
|
-
public static
|
|
211
|
-
|
|
212
|
-
public static DcSysTime FromUtc(DateTime utc)
|
|
230
|
+
public static SysTime operator +(SysTime lhs, TimeSpan rhs)
|
|
213
231
|
{
|
|
214
|
-
|
|
215
|
-
if (ticks < 0)
|
|
232
|
+
if (rhs < TimeSpan.Zero)
|
|
216
233
|
{
|
|
217
|
-
throw new
|
|
234
|
+
throw new ArgumentOutOfRangeException(nameof(rhs));
|
|
218
235
|
}
|
|
219
|
-
|
|
236
|
+
var ns = OptionNative.ToNanos(rhs);
|
|
237
|
+
return new SysTime(ns > ulong.MaxValue - lhs._ns ? ulong.MaxValue : lhs._ns + ns);
|
|
220
238
|
}
|
|
221
239
|
|
|
222
|
-
public
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
240
|
+
public static SysTime operator -(SysTime lhs, TimeSpan rhs)
|
|
241
|
+
{
|
|
242
|
+
if (rhs < TimeSpan.Zero)
|
|
243
|
+
{
|
|
244
|
+
throw new ArgumentOutOfRangeException(nameof(rhs));
|
|
245
|
+
}
|
|
246
|
+
var ns = OptionNative.ToNanos(rhs);
|
|
247
|
+
return new SysTime(ns > lhs._ns ? 0 : lhs._ns - ns);
|
|
248
|
+
}
|
|
226
249
|
|
|
227
|
-
public static
|
|
228
|
-
|
|
250
|
+
public static TimeSpan operator -(SysTime lhs, SysTime rhs) =>
|
|
251
|
+
OptionNative.FromNanos(rhs._ns > lhs._ns ? 0 : lhs._ns - rhs._ns);
|
|
229
252
|
|
|
230
|
-
public bool Equals(
|
|
253
|
+
public bool Equals(SysTime other) => _ns == other._ns;
|
|
231
254
|
|
|
232
|
-
public override bool Equals(object? obj) => obj is
|
|
255
|
+
public override bool Equals(object? obj) => obj is SysTime other && Equals(other);
|
|
233
256
|
|
|
234
257
|
public override int GetHashCode() => _ns.GetHashCode();
|
|
235
258
|
|
|
236
|
-
public int CompareTo(
|
|
259
|
+
public int CompareTo(SysTime other) => _ns.CompareTo(other._ns);
|
|
237
260
|
|
|
238
|
-
public static bool operator ==(
|
|
261
|
+
public static bool operator ==(SysTime left, SysTime right) => left.Equals(right);
|
|
239
262
|
|
|
240
|
-
public static bool operator !=(
|
|
263
|
+
public static bool operator !=(SysTime left, SysTime right) => !left.Equals(right);
|
|
241
264
|
|
|
242
|
-
public static bool operator <(
|
|
265
|
+
public static bool operator <(SysTime left, SysTime right) => left._ns < right._ns;
|
|
243
266
|
|
|
244
|
-
public static bool operator >(
|
|
267
|
+
public static bool operator >(SysTime left, SysTime right) => left._ns > right._ns;
|
|
245
268
|
|
|
246
|
-
public static bool operator <=(
|
|
269
|
+
public static bool operator <=(SysTime left, SysTime right) => left._ns <= right._ns;
|
|
247
270
|
|
|
248
|
-
public static bool operator >=(
|
|
271
|
+
public static bool operator >=(SysTime left, SysTime right) => left._ns >= right._ns;
|
|
249
272
|
}
|
|
250
273
|
}
|
package/Units.cs
CHANGED
|
@@ -31,8 +31,6 @@ namespace AUTD3
|
|
|
31
31
|
|
|
32
32
|
public static Angle Zero => new Angle(0f);
|
|
33
33
|
|
|
34
|
-
public static Angle Pi => new Angle(MathF.PI);
|
|
35
|
-
|
|
36
34
|
public static Angle FromRad(float radian) => new Angle(radian);
|
|
37
35
|
|
|
38
36
|
public static Angle FromDeg(float degree) => new Angle(degree * (MathF.PI / 180f));
|
|
@@ -75,6 +73,10 @@ namespace AUTD3
|
|
|
75
73
|
|
|
76
74
|
public float Hz => HzValue;
|
|
77
75
|
|
|
76
|
+
public static Freq FromHz(uint hz) => new Freq(FreqMode.IntExact, hz, hz);
|
|
77
|
+
|
|
78
|
+
public static Freq FromHz(float hz) => new Freq(FreqMode.FloatExact, hz, 0);
|
|
79
|
+
|
|
78
80
|
internal byte ModeCode => (byte)Mode;
|
|
79
81
|
|
|
80
82
|
public static Freq operator +(Freq lhs, Freq rhs) =>
|
|
@@ -153,8 +155,14 @@ namespace AUTD3
|
|
|
153
155
|
HzPerUnitInt = hzPerUnitInt;
|
|
154
156
|
}
|
|
155
157
|
|
|
156
|
-
public static Freq operator *(int value, FreqUnit unit)
|
|
157
|
-
|
|
158
|
+
public static Freq operator *(int value, FreqUnit unit)
|
|
159
|
+
{
|
|
160
|
+
if (value < 0)
|
|
161
|
+
{
|
|
162
|
+
throw new Autd3Exception($"an integer frequency must not be negative, but {value} was given", Autd3ErrorCode.InvalidArgument);
|
|
163
|
+
}
|
|
164
|
+
return new Freq(Freq.FreqMode.IntExact, value * unit.HzPerUnit, checked((uint)value * unit.HzPerUnitInt));
|
|
165
|
+
}
|
|
158
166
|
|
|
159
167
|
public static Freq operator *(float value, FreqUnit unit) =>
|
|
160
168
|
new Freq(Freq.FreqMode.FloatExact, value * unit.HzPerUnit, 0);
|
|
@@ -179,6 +187,10 @@ namespace AUTD3
|
|
|
179
187
|
public static readonly FreqUnit kHz = new FreqUnit(1000f, 1000u);
|
|
180
188
|
public static readonly SecUnit s = default;
|
|
181
189
|
|
|
190
|
+
public static Vector3 Point(Length x, Length y, Length z) => Coords.FromLengths(x, y, z);
|
|
191
|
+
|
|
192
|
+
public static Vector3 Offset(Length x, Length y, Length z) => Coords.FromLengths(x, y, z);
|
|
193
|
+
|
|
182
194
|
public static Nearest<Freq> Nearest(Freq freq) => new Nearest<Freq>(freq);
|
|
183
195
|
|
|
184
196
|
public static Nearest<TimeSpan> Nearest(TimeSpan period) => new Nearest<TimeSpan>(period);
|
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.core"
|
|
7
7
|
},
|
|
8
|
-
"version": "0.
|
|
8
|
+
"version": "0.10.0",
|
|
9
9
|
"displayName": "AUTD3 Core",
|
|
10
10
|
"description": "AUTD3 core types, geometry and units (Unity binding).",
|
|
11
11
|
"unity": "6000.0",
|