com.shinolab.autd3-sdk.core 0.10.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Config.cs +55 -16
- package/Geometry.cs +13 -27
- package/Native.cs +26 -32
- 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 +22 -100
- package/THIRD-PARTY-LICENSES.md +56 -93
- package/Types.cs +66 -38
- package/Units.cs +101 -69
- package/package.json +1 -1
package/Config.cs
CHANGED
|
@@ -10,37 +10,53 @@ namespace AUTD3
|
|
|
10
10
|
I3 = 3,
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
public readonly struct LoopBehavior
|
|
13
|
+
public readonly struct LoopBehavior : IEquatable<LoopBehavior>
|
|
14
14
|
{
|
|
15
|
-
|
|
15
|
+
private readonly ushort _count;
|
|
16
16
|
|
|
17
|
-
private LoopBehavior(ushort
|
|
17
|
+
private LoopBehavior(ushort count)
|
|
18
18
|
{
|
|
19
|
-
|
|
19
|
+
_count = count;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
public
|
|
22
|
+
public ushort Rep => _count == 0 ? (ushort)0xFFFF : (ushort)(_count - 1);
|
|
23
23
|
|
|
24
|
-
public static LoopBehavior
|
|
24
|
+
public static LoopBehavior Infinite => default;
|
|
25
|
+
|
|
26
|
+
public static LoopBehavior Once => new LoopBehavior(1);
|
|
25
27
|
|
|
26
28
|
public static LoopBehavior Finite(ushort count)
|
|
27
29
|
{
|
|
28
30
|
if (count == 0)
|
|
29
31
|
{
|
|
30
|
-
throw new Autd3Exception("loop count must be >= 1");
|
|
32
|
+
throw new Autd3Exception("loop count must be >= 1", Autd3ErrorCode.InvalidArgument);
|
|
31
33
|
}
|
|
32
|
-
return new LoopBehavior(
|
|
34
|
+
return new LoopBehavior(count);
|
|
33
35
|
}
|
|
36
|
+
|
|
37
|
+
public bool Equals(LoopBehavior other) => _count == other._count;
|
|
38
|
+
|
|
39
|
+
public override bool Equals(object? obj) => obj is LoopBehavior other && Equals(other);
|
|
40
|
+
|
|
41
|
+
public override int GetHashCode() => _count;
|
|
42
|
+
|
|
43
|
+
public static bool operator ==(LoopBehavior left, LoopBehavior right) => left.Equals(right);
|
|
44
|
+
|
|
45
|
+
public static bool operator !=(LoopBehavior left, LoopBehavior right) => !left.Equals(right);
|
|
34
46
|
}
|
|
35
47
|
|
|
36
|
-
public readonly struct TransitionMode
|
|
48
|
+
public readonly struct TransitionMode : IEquatable<TransitionMode>
|
|
37
49
|
{
|
|
38
|
-
|
|
50
|
+
private const byte ImmediateMode = 0xFF;
|
|
51
|
+
|
|
52
|
+
private readonly byte _modeFromImmediate;
|
|
53
|
+
|
|
54
|
+
internal byte Mode => (byte)(_modeFromImmediate ^ ImmediateMode);
|
|
39
55
|
internal ulong Value { get; }
|
|
40
56
|
|
|
41
57
|
private TransitionMode(byte mode, ulong value)
|
|
42
58
|
{
|
|
43
|
-
|
|
59
|
+
_modeFromImmediate = (byte)(mode ^ ImmediateMode);
|
|
44
60
|
Value = value;
|
|
45
61
|
}
|
|
46
62
|
|
|
@@ -52,16 +68,39 @@ namespace AUTD3
|
|
|
52
68
|
|
|
53
69
|
public static TransitionMode Ext => new TransitionMode(0xF0, 0);
|
|
54
70
|
|
|
55
|
-
public static TransitionMode
|
|
71
|
+
public static TransitionMode Immediate => new TransitionMode(ImmediateMode, 0);
|
|
72
|
+
|
|
73
|
+
public bool Equals(TransitionMode other) => _modeFromImmediate == other._modeFromImmediate && Value == other.Value;
|
|
56
74
|
|
|
57
|
-
public
|
|
75
|
+
public override bool Equals(object? obj) => obj is TransitionMode other && Equals(other);
|
|
58
76
|
|
|
59
|
-
public
|
|
77
|
+
public override int GetHashCode() => HashCode.Combine(_modeFromImmediate, Value);
|
|
78
|
+
|
|
79
|
+
public static bool operator ==(TransitionMode left, TransitionMode right) => left.Equals(right);
|
|
80
|
+
|
|
81
|
+
public static bool operator !=(TransitionMode left, TransitionMode right) => !left.Equals(right);
|
|
60
82
|
}
|
|
61
83
|
|
|
62
84
|
public enum FpgaBusWait : byte
|
|
63
85
|
{
|
|
64
|
-
|
|
65
|
-
|
|
86
|
+
Cycles3 = 0,
|
|
87
|
+
Cycles2 = 1,
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
internal static class FpgaBusWaitNative
|
|
91
|
+
{
|
|
92
|
+
internal static byte ToCycles(FpgaBusWait wait) => wait switch
|
|
93
|
+
{
|
|
94
|
+
FpgaBusWait.Cycles2 => 2,
|
|
95
|
+
FpgaBusWait.Cycles3 => 3,
|
|
96
|
+
_ => 0,
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
internal static FpgaBusWait FromCycles(byte cycles) => cycles switch
|
|
100
|
+
{
|
|
101
|
+
2 => FpgaBusWait.Cycles2,
|
|
102
|
+
3 => FpgaBusWait.Cycles3,
|
|
103
|
+
_ => throw new Autd3Exception($"unknown fpga bus wait {cycles}"),
|
|
104
|
+
};
|
|
66
105
|
}
|
|
67
106
|
}
|
package/Geometry.cs
CHANGED
|
@@ -48,7 +48,7 @@ namespace AUTD3
|
|
|
48
48
|
var handle = NativeCore.autd3_core_geometry_from_json(json, err, (UIntPtr)err.Length);
|
|
49
49
|
if (handle == IntPtr.Zero)
|
|
50
50
|
{
|
|
51
|
-
throw new Autd3Exception(NativeUtil.Utf8(err));
|
|
51
|
+
throw new Autd3Exception(NativeUtil.Utf8(err), Autd3ErrorCode.InvalidArgument);
|
|
52
52
|
}
|
|
53
53
|
return new Geometry(new GeometryHandle(handle));
|
|
54
54
|
}
|
|
@@ -98,14 +98,24 @@ namespace AUTD3
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
public Device this[int dev]
|
|
101
|
+
public Device this[int dev]
|
|
102
|
+
{
|
|
103
|
+
get
|
|
104
|
+
{
|
|
105
|
+
if (dev < 0 || dev >= NumDevices)
|
|
106
|
+
{
|
|
107
|
+
throw new ArgumentOutOfRangeException(nameof(dev));
|
|
108
|
+
}
|
|
109
|
+
return new Device(Handle, (UIntPtr)dev);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
102
112
|
|
|
103
113
|
public IEnumerator<Device> GetEnumerator()
|
|
104
114
|
{
|
|
105
115
|
var count = NumDevices;
|
|
106
116
|
for (var i = 0; i < count; i++)
|
|
107
117
|
{
|
|
108
|
-
yield return
|
|
118
|
+
yield return new Device(Handle, (UIntPtr)i);
|
|
109
119
|
}
|
|
110
120
|
}
|
|
111
121
|
|
|
@@ -125,10 +135,6 @@ namespace AUTD3
|
|
|
125
135
|
_dev = dev;
|
|
126
136
|
}
|
|
127
137
|
|
|
128
|
-
internal GeometryHandle GeometryHandle => _geometry;
|
|
129
|
-
|
|
130
|
-
internal UIntPtr DeviceIndex => _dev;
|
|
131
|
-
|
|
132
138
|
public int Idx => (int)NativeCore.autd3_core_device_idx(_geometry, _dev);
|
|
133
139
|
|
|
134
140
|
public int NumTransducers => (int)NativeCore.autd3_core_device_num_transducers(_geometry, _dev);
|
|
@@ -169,14 +175,6 @@ namespace AUTD3
|
|
|
169
175
|
return Coords.FromPointArray(xyz);
|
|
170
176
|
}
|
|
171
177
|
|
|
172
|
-
public Vector3 Direction(int tr)
|
|
173
|
-
{
|
|
174
|
-
var xyz = new float[3];
|
|
175
|
-
if (NativeCore.autd3_core_transducer_direction(_geometry, _dev, (UIntPtr)tr, xyz) != 0)
|
|
176
|
-
throw new ArgumentOutOfRangeException(nameof(tr));
|
|
177
|
-
return Coords.FromDirArray(xyz);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
178
|
public Vector3[] Positions
|
|
181
179
|
{
|
|
182
180
|
get
|
|
@@ -206,18 +204,6 @@ namespace AUTD3
|
|
|
206
204
|
return Coords.FromPointArray(xyz);
|
|
207
205
|
}
|
|
208
206
|
|
|
209
|
-
public Vector3[] Directions
|
|
210
|
-
{
|
|
211
|
-
get
|
|
212
|
-
{
|
|
213
|
-
var n = NumTransducers;
|
|
214
|
-
var result = new Vector3[n];
|
|
215
|
-
for (var i = 0; i < n; i++)
|
|
216
|
-
result[i] = Direction(i);
|
|
217
|
-
return result;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
207
|
private Vector3 DeviceDirection(Action<GeometryHandle, UIntPtr, float[]> native)
|
|
222
208
|
{
|
|
223
209
|
var xyz = new float[3];
|
package/Native.cs
CHANGED
|
@@ -65,9 +65,6 @@ namespace AUTD3
|
|
|
65
65
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
66
66
|
internal static extern int autd3_core_transducer_position(GeometryHandle geometry, UIntPtr dev, UIntPtr tr, [Out] float[] outXyz);
|
|
67
67
|
|
|
68
|
-
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
69
|
-
internal static extern int autd3_core_transducer_direction(GeometryHandle geometry, UIntPtr dev, UIntPtr tr, [Out] float[] outXyz);
|
|
70
|
-
|
|
71
68
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
72
69
|
internal static extern IntPtr autd3_core_geometry_clone(GeometryHandle geometry);
|
|
73
70
|
|
|
@@ -108,49 +105,49 @@ namespace AUTD3
|
|
|
108
105
|
internal static extern UIntPtr autd3_core_params_max_inflight();
|
|
109
106
|
|
|
110
107
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
111
|
-
internal static extern UIntPtr
|
|
108
|
+
internal static extern UIntPtr autd3_core_params_max_devices();
|
|
112
109
|
|
|
113
110
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
114
|
-
internal static extern
|
|
111
|
+
internal static extern ushort autd3_core_params_port();
|
|
115
112
|
|
|
116
113
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
117
|
-
internal static extern
|
|
114
|
+
internal static extern float autd3_core_params_rotation_norm_tolerance();
|
|
118
115
|
|
|
119
116
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
120
|
-
internal static extern
|
|
117
|
+
internal static extern UIntPtr autd3_core_params_num_transducers();
|
|
121
118
|
|
|
122
119
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
123
|
-
internal static extern
|
|
120
|
+
internal static extern uint autd3_core_params_grid_x();
|
|
124
121
|
|
|
125
122
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
126
|
-
internal static extern
|
|
123
|
+
internal static extern uint autd3_core_params_grid_y();
|
|
127
124
|
|
|
128
125
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
129
|
-
internal static extern
|
|
126
|
+
internal static extern float autd3_core_params_pitch_mm();
|
|
130
127
|
|
|
131
128
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
132
|
-
internal static extern
|
|
129
|
+
internal static extern float autd3_core_params_device_width_mm();
|
|
133
130
|
|
|
134
131
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
135
|
-
internal static extern
|
|
132
|
+
internal static extern float autd3_core_params_device_height_mm();
|
|
136
133
|
|
|
137
134
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
138
|
-
internal static extern
|
|
135
|
+
internal static extern ushort autd3_core_sampling_config_freq_4k();
|
|
139
136
|
|
|
140
137
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
141
|
-
internal static extern
|
|
138
|
+
internal static extern ushort autd3_core_sampling_config_freq_40k();
|
|
142
139
|
|
|
143
140
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
144
|
-
internal static extern int
|
|
141
|
+
internal static extern int autd3_core_sampling_config_from_freq(float hz, out ushort @out, byte[] outErr, UIntPtr outErrLen);
|
|
145
142
|
|
|
146
143
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
147
|
-
internal static extern
|
|
144
|
+
internal static extern int autd3_core_sampling_config_from_period(ulong nanos, out ushort @out, byte[] outErr, UIntPtr outErrLen);
|
|
148
145
|
}
|
|
149
146
|
|
|
150
147
|
internal static class NativeAbi
|
|
151
148
|
{
|
|
152
149
|
internal const ushort Major = 0;
|
|
153
|
-
internal const ushort Minor =
|
|
150
|
+
internal const ushort Minor = 14;
|
|
154
151
|
internal const ushort Patch = 0;
|
|
155
152
|
|
|
156
153
|
internal const int ErrorBufferLength = 1024;
|
|
@@ -171,30 +168,27 @@ namespace AUTD3
|
|
|
171
168
|
|
|
172
169
|
internal static class OptionNative
|
|
173
170
|
{
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
178
|
-
internal delegate int GetDurationFn(IntPtr option, out ulong ns);
|
|
171
|
+
internal static Autd3Exception OutOfRange(string field) =>
|
|
172
|
+
new Autd3Exception($"`{field}` is out of the range the native library accepts", Autd3ErrorCode.InvalidArgument);
|
|
179
173
|
|
|
180
174
|
internal static void Apply(string field, int code)
|
|
181
175
|
{
|
|
182
176
|
if (code != 0)
|
|
183
177
|
{
|
|
184
|
-
throw
|
|
178
|
+
throw OutOfRange(field);
|
|
185
179
|
}
|
|
186
180
|
}
|
|
187
181
|
|
|
188
|
-
internal static
|
|
189
|
-
|
|
190
|
-
Apply(field, value < TimeSpan.Zero ? -1 : set(option, ToNanos(value)));
|
|
191
|
-
}
|
|
182
|
+
internal static ulong RequiredNanos(string field, TimeSpan value) =>
|
|
183
|
+
value < TimeSpan.Zero ? throw OutOfRange(field) : ToNanos(value);
|
|
192
184
|
|
|
193
|
-
internal static
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
185
|
+
internal static ulong OptionalNanos(string field, TimeSpan? value) =>
|
|
186
|
+
value is { } duration ? RequiredNanos(field, duration) : 0;
|
|
187
|
+
|
|
188
|
+
internal static TimeSpan? FromOptionalNanos(byte hasValue, ulong ns) =>
|
|
189
|
+
hasValue != 0 ? FromNanos(ns) : (TimeSpan?)null;
|
|
190
|
+
|
|
191
|
+
internal static byte Flag(bool value) => (byte)(value ? 1 : 0);
|
|
198
192
|
|
|
199
193
|
internal static ulong ToNanos(TimeSpan value) =>
|
|
200
194
|
(ulong)value.Ticks > ulong.MaxValue / 100UL ? ulong.MaxValue : (ulong)value.Ticks * 100UL;
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/SamplingConfig.cs
CHANGED
|
@@ -4,31 +4,9 @@ namespace AUTD3
|
|
|
4
4
|
{
|
|
5
5
|
public readonly struct SamplingConfig : IEquatable<SamplingConfig>
|
|
6
6
|
{
|
|
7
|
-
private enum Kind : byte
|
|
8
|
-
{
|
|
9
|
-
Unset,
|
|
10
|
-
Divide,
|
|
11
|
-
Freq,
|
|
12
|
-
FreqNearest,
|
|
13
|
-
Period,
|
|
14
|
-
PeriodNearest,
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
private readonly Kind _kind;
|
|
18
7
|
private readonly ushort _divide;
|
|
19
|
-
private readonly float _freq;
|
|
20
|
-
private readonly ulong _periodNs;
|
|
21
|
-
private readonly ushort _resolved;
|
|
22
8
|
|
|
23
|
-
private
|
|
24
|
-
{
|
|
25
|
-
_kind = kind;
|
|
26
|
-
_divide = divide;
|
|
27
|
-
_freq = freq;
|
|
28
|
-
_periodNs = periodNs;
|
|
29
|
-
_resolved = 0;
|
|
30
|
-
_resolved = Resolve(out _);
|
|
31
|
-
}
|
|
9
|
+
private const string UnsetMessage = "the sampling config is not set (default(SamplingConfig) has no value)";
|
|
32
10
|
|
|
33
11
|
public SamplingConfig(ushort divide)
|
|
34
12
|
{
|
|
@@ -36,27 +14,28 @@ namespace AUTD3
|
|
|
36
14
|
{
|
|
37
15
|
throw new Autd3Exception("sampling divide must be >= 1", Autd3ErrorCode.InvalidArgument);
|
|
38
16
|
}
|
|
39
|
-
_kind = Kind.Divide;
|
|
40
17
|
_divide = divide;
|
|
41
|
-
_freq = 0f;
|
|
42
|
-
_periodNs = 0;
|
|
43
|
-
_resolved = divide;
|
|
44
18
|
}
|
|
45
19
|
|
|
46
|
-
public SamplingConfig(Freq freq)
|
|
20
|
+
public SamplingConfig(Freq freq)
|
|
47
21
|
{
|
|
22
|
+
var err = new byte[NativeAbi.ErrorBufferLength];
|
|
23
|
+
_divide = Checked(NativeCore.autd3_core_sampling_config_from_freq(freq.Hz, out var divide, err, (UIntPtr)err.Length), divide, err);
|
|
48
24
|
}
|
|
49
25
|
|
|
50
|
-
public SamplingConfig(TimeSpan period)
|
|
26
|
+
public SamplingConfig(TimeSpan period)
|
|
51
27
|
{
|
|
28
|
+
var err = new byte[NativeAbi.ErrorBufferLength];
|
|
29
|
+
_divide = Checked(NativeCore.autd3_core_sampling_config_from_period(PeriodNanos(period), out var divide, err, (UIntPtr)err.Length), divide, err);
|
|
52
30
|
}
|
|
53
31
|
|
|
54
|
-
|
|
55
|
-
{
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
public SamplingConfig(Nearest<TimeSpan> period) : this(Kind.PeriodNearest, 0, 0f, PeriodNanos(period.Value))
|
|
32
|
+
private static ushort Checked(int code, ushort divide, byte[] err)
|
|
59
33
|
{
|
|
34
|
+
if (code != 0)
|
|
35
|
+
{
|
|
36
|
+
throw new Autd3Exception(NativeUtil.Utf8(err), Autd3ErrorCode.InvalidArgument);
|
|
37
|
+
}
|
|
38
|
+
return divide;
|
|
60
39
|
}
|
|
61
40
|
|
|
62
41
|
private static ulong PeriodNanos(TimeSpan period)
|
|
@@ -68,90 +47,33 @@ namespace AUTD3
|
|
|
68
47
|
return OptionNative.ToNanos(period);
|
|
69
48
|
}
|
|
70
49
|
|
|
71
|
-
public static SamplingConfig Freq4k => new SamplingConfig(
|
|
50
|
+
public static SamplingConfig Freq4k => new SamplingConfig(NativeCore.autd3_core_sampling_config_freq_4k());
|
|
72
51
|
|
|
73
|
-
public static SamplingConfig Freq40k => new SamplingConfig(
|
|
52
|
+
public static SamplingConfig Freq40k => new SamplingConfig(NativeCore.autd3_core_sampling_config_freq_40k());
|
|
74
53
|
|
|
75
54
|
public ushort Divide()
|
|
76
55
|
{
|
|
77
|
-
if (
|
|
78
|
-
{
|
|
79
|
-
return _resolved;
|
|
80
|
-
}
|
|
81
|
-
var divide = Resolve(out var error);
|
|
82
|
-
if (divide == 0)
|
|
56
|
+
if (_divide == 0)
|
|
83
57
|
{
|
|
84
|
-
throw new Autd3Exception(
|
|
58
|
+
throw new Autd3Exception(UnsetMessage, Autd3ErrorCode.InvalidArgument);
|
|
85
59
|
}
|
|
86
|
-
return
|
|
60
|
+
return _divide;
|
|
87
61
|
}
|
|
88
62
|
|
|
63
|
+
internal ushort DivideForNative() => Divide();
|
|
64
|
+
|
|
89
65
|
public Freq Freq() => (float)Params.UltrasoundFreqHz / Divide() * Units.Hz;
|
|
90
66
|
|
|
91
67
|
public TimeSpan Period() => TimeSpan.FromTicks(Params.UltrasoundPeriod.Ticks * Divide());
|
|
92
68
|
|
|
93
|
-
public bool Equals(SamplingConfig other)
|
|
94
|
-
{
|
|
95
|
-
var lhs = TryDivide();
|
|
96
|
-
return lhs != 0 && lhs == other.TryDivide();
|
|
97
|
-
}
|
|
69
|
+
public bool Equals(SamplingConfig other) => _divide == other._divide;
|
|
98
70
|
|
|
99
71
|
public override bool Equals(object? obj) => obj is SamplingConfig other && Equals(other);
|
|
100
72
|
|
|
101
|
-
public override int GetHashCode() =>
|
|
73
|
+
public override int GetHashCode() => _divide;
|
|
102
74
|
|
|
103
75
|
public static bool operator ==(SamplingConfig left, SamplingConfig right) => left.Equals(right);
|
|
104
76
|
|
|
105
77
|
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)
|
|
112
|
-
{
|
|
113
|
-
error = string.Empty;
|
|
114
|
-
if (_kind == Kind.Unset)
|
|
115
|
-
{
|
|
116
|
-
error = UnsetMessage;
|
|
117
|
-
return 0;
|
|
118
|
-
}
|
|
119
|
-
var handle = CreateHandle();
|
|
120
|
-
try
|
|
121
|
-
{
|
|
122
|
-
var err = new byte[NativeAbi.ErrorBufferLength];
|
|
123
|
-
if (NativeCore.autd3_core_sampling_config_resolve(handle, out var value, err, (UIntPtr)err.Length) != 0)
|
|
124
|
-
{
|
|
125
|
-
error = NativeUtil.Utf8(err);
|
|
126
|
-
return 0;
|
|
127
|
-
}
|
|
128
|
-
return value;
|
|
129
|
-
}
|
|
130
|
-
finally
|
|
131
|
-
{
|
|
132
|
-
NativeCore.autd3_core_sampling_config_free(handle);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
internal IntPtr CreateHandle()
|
|
137
|
-
{
|
|
138
|
-
if (_kind == Kind.Unset)
|
|
139
|
-
{
|
|
140
|
-
throw new Autd3Exception(UnsetMessage, Autd3ErrorCode.InvalidArgument);
|
|
141
|
-
}
|
|
142
|
-
var handle = _kind switch
|
|
143
|
-
{
|
|
144
|
-
Kind.Divide => NativeCore.autd3_core_sampling_config_divide(_divide),
|
|
145
|
-
Kind.Freq => NativeCore.autd3_core_sampling_config_freq(_freq),
|
|
146
|
-
Kind.FreqNearest => NativeCore.autd3_core_sampling_config_freq_nearest(_freq),
|
|
147
|
-
Kind.Period => NativeCore.autd3_core_sampling_config_period(_periodNs),
|
|
148
|
-
_ => NativeCore.autd3_core_sampling_config_period_nearest(_periodNs),
|
|
149
|
-
};
|
|
150
|
-
if (handle == IntPtr.Zero)
|
|
151
|
-
{
|
|
152
|
-
throw new Autd3Exception("failed to create sampling config");
|
|
153
|
-
}
|
|
154
|
-
return handle;
|
|
155
|
-
}
|
|
156
78
|
}
|
|
157
79
|
}
|
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 (33)
|
|
9
9
|
- Apache License 2.0 (3)
|
|
10
10
|
- Unicode License v3 (1)
|
|
11
11
|
|
|
@@ -226,7 +226,7 @@ Used by:
|
|
|
226
226
|
Used by:
|
|
227
227
|
|
|
228
228
|
- nalgebra 0.35.0 — https://github.com/dimforge/nalgebra
|
|
229
|
-
- simba 0.10.
|
|
229
|
+
- simba 0.10.2 — https://github.com/dimforge/simba
|
|
230
230
|
|
|
231
231
|
```
|
|
232
232
|
Apache License
|
|
@@ -511,7 +511,7 @@ DEALINGS IN THE SOFTWARE.
|
|
|
511
511
|
|
|
512
512
|
Used by:
|
|
513
513
|
|
|
514
|
-
- matrixmultiply 0.3.
|
|
514
|
+
- matrixmultiply 0.3.11 — https://github.com/bluss/matrixmultiply/
|
|
515
515
|
|
|
516
516
|
```
|
|
517
517
|
Copyright (c) 2016 - 2023 Ulrik Sverdrup "bluss"
|
|
@@ -548,44 +548,8 @@ DEALINGS IN THE SOFTWARE.
|
|
|
548
548
|
|
|
549
549
|
Used by:
|
|
550
550
|
|
|
551
|
-
-
|
|
552
|
-
-
|
|
553
|
-
|
|
554
|
-
```
|
|
555
|
-
Copyright (c) 2019 Tokio Contributors
|
|
556
|
-
|
|
557
|
-
Permission is hereby granted, free of charge, to any
|
|
558
|
-
person obtaining a copy of this software and associated
|
|
559
|
-
documentation files (the "Software"), to deal in the
|
|
560
|
-
Software without restriction, including without
|
|
561
|
-
limitation the rights to use, copy, modify, merge,
|
|
562
|
-
publish, distribute, sublicense, and/or sell copies of
|
|
563
|
-
the Software, and to permit persons to whom the Software
|
|
564
|
-
is furnished to do so, subject to the following
|
|
565
|
-
conditions:
|
|
566
|
-
|
|
567
|
-
The above copyright notice and this permission notice
|
|
568
|
-
shall be included in all copies or substantial portions
|
|
569
|
-
of the Software.
|
|
570
|
-
|
|
571
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
|
572
|
-
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
573
|
-
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
574
|
-
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
|
575
|
-
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
576
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
577
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
|
578
|
-
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
579
|
-
DEALINGS IN THE SOFTWARE.
|
|
580
|
-
|
|
581
|
-
```
|
|
582
|
-
|
|
583
|
-
## MIT License
|
|
584
|
-
|
|
585
|
-
Used by:
|
|
586
|
-
|
|
587
|
-
- zerocopy-derive 0.8.52 — https://github.com/google/zerocopy
|
|
588
|
-
- zerocopy 0.8.52 — https://github.com/google/zerocopy
|
|
551
|
+
- zerocopy-derive 0.8.63 — https://github.com/google/zerocopy
|
|
552
|
+
- zerocopy 0.8.63 — https://github.com/google/zerocopy
|
|
589
553
|
|
|
590
554
|
```
|
|
591
555
|
Copyright 2023 The Fuchsia Authors
|
|
@@ -683,7 +647,7 @@ SOFTWARE.
|
|
|
683
647
|
|
|
684
648
|
Used by:
|
|
685
649
|
|
|
686
|
-
- bytemuck 1.25.
|
|
650
|
+
- bytemuck 1.25.2 — https://github.com/Lokathor/bytemuck
|
|
687
651
|
|
|
688
652
|
```
|
|
689
653
|
MIT License
|
|
@@ -702,7 +666,38 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
702
666
|
|
|
703
667
|
Used by:
|
|
704
668
|
|
|
705
|
-
-
|
|
669
|
+
- wide 1.7.1 — https://github.com/Lokathor/wide
|
|
670
|
+
|
|
671
|
+
```
|
|
672
|
+
MIT License
|
|
673
|
+
|
|
674
|
+
Copyright (c) 2020 Daniel "Lokathor" Gee
|
|
675
|
+
|
|
676
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
677
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
678
|
+
in the Software without restriction, including without limitation the rights
|
|
679
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
680
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
681
|
+
furnished to do so, subject to the following conditions:
|
|
682
|
+
|
|
683
|
+
The above copyright notice and this permission notice shall be included in all
|
|
684
|
+
copies or substantial portions of the Software.
|
|
685
|
+
|
|
686
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
687
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
688
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
689
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
690
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
691
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
692
|
+
SOFTWARE.
|
|
693
|
+
|
|
694
|
+
```
|
|
695
|
+
|
|
696
|
+
## MIT License
|
|
697
|
+
|
|
698
|
+
Used by:
|
|
699
|
+
|
|
700
|
+
- safe_arch 1.2.0 — https://github.com/Lokathor/safe_arch
|
|
706
701
|
|
|
707
702
|
```
|
|
708
703
|
MIT License
|
|
@@ -721,8 +716,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
721
716
|
|
|
722
717
|
Used by:
|
|
723
718
|
|
|
724
|
-
- autd3-rs-core 0.
|
|
725
|
-
- autd3-cpu-wire 0.
|
|
719
|
+
- autd3-rs-core 0.14.0 — https://github.com/shinolab/autd3-sdk
|
|
720
|
+
- autd3-cpu-wire 0.14.0 — https://github.com/shinolab/autd3-sdk
|
|
726
721
|
|
|
727
722
|
```
|
|
728
723
|
MIT License
|
|
@@ -753,9 +748,8 @@ SOFTWARE.
|
|
|
753
748
|
|
|
754
749
|
Used by:
|
|
755
750
|
|
|
756
|
-
- autd3-ffi-abi 0.
|
|
757
|
-
- autd3-ffi-core 0.
|
|
758
|
-
- wide 1.5.0 — https://github.com/Lokathor/wide
|
|
751
|
+
- autd3-ffi-abi 0.14.0 — https://github.com/shinolab/autd3-sdk
|
|
752
|
+
- autd3-ffi-core 0.14.0 — https://github.com/shinolab/autd3-sdk
|
|
759
753
|
|
|
760
754
|
```
|
|
761
755
|
MIT License
|
|
@@ -784,18 +778,18 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
784
778
|
Used by:
|
|
785
779
|
|
|
786
780
|
- itoa 1.0.18 — https://github.com/dtolnay/itoa
|
|
787
|
-
-
|
|
788
|
-
-
|
|
789
|
-
-
|
|
790
|
-
-
|
|
791
|
-
-
|
|
792
|
-
-
|
|
793
|
-
-
|
|
794
|
-
- syn
|
|
795
|
-
- thiserror-impl 2.0.
|
|
796
|
-
- thiserror 2.0.
|
|
797
|
-
- unicode-ident 1.0.
|
|
798
|
-
- zmij 1.0.
|
|
781
|
+
- proc-macro2 1.0.107 — https://github.com/dtolnay/proc-macro2
|
|
782
|
+
- quote 1.0.47 — https://github.com/dtolnay/quote
|
|
783
|
+
- serde 1.0.229 — https://github.com/serde-rs/serde
|
|
784
|
+
- serde_core 1.0.229 — https://github.com/serde-rs/serde
|
|
785
|
+
- serde_derive 1.0.229 — https://github.com/serde-rs/serde
|
|
786
|
+
- serde_json 1.0.154 — https://github.com/serde-rs/json
|
|
787
|
+
- syn 2.0.119 — https://github.com/dtolnay/syn
|
|
788
|
+
- syn 3.0.9 — https://github.com/dtolnay/syn
|
|
789
|
+
- thiserror-impl 2.0.21 — https://github.com/dtolnay/thiserror
|
|
790
|
+
- thiserror 2.0.21 — https://github.com/dtolnay/thiserror
|
|
791
|
+
- unicode-ident 1.0.27 — https://github.com/dtolnay/unicode-ident
|
|
792
|
+
- zmij 1.0.23 — https://github.com/dtolnay/zmij
|
|
799
793
|
|
|
800
794
|
```
|
|
801
795
|
Permission is hereby granted, free of charge, to any
|
|
@@ -828,37 +822,6 @@ DEALINGS IN THE SOFTWARE.
|
|
|
828
822
|
|
|
829
823
|
Used by:
|
|
830
824
|
|
|
831
|
-
- tracing-core 0.1.36 — https://github.com/tokio-rs/tracing
|
|
832
|
-
|
|
833
|
-
```
|
|
834
|
-
The MIT License (MIT)
|
|
835
|
-
|
|
836
|
-
Copyright (c) 2014 Mathijs van de Nes
|
|
837
|
-
|
|
838
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
839
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
840
|
-
in the Software without restriction, including without limitation the rights
|
|
841
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
842
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
843
|
-
furnished to do so, subject to the following conditions:
|
|
844
|
-
|
|
845
|
-
The above copyright notice and this permission notice shall be included in all
|
|
846
|
-
copies or substantial portions of the Software.
|
|
847
|
-
|
|
848
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
849
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
850
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
851
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
852
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
853
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
854
|
-
SOFTWARE.
|
|
855
|
-
|
|
856
|
-
```
|
|
857
|
-
|
|
858
|
-
## MIT License
|
|
859
|
-
|
|
860
|
-
Used by:
|
|
861
|
-
|
|
862
825
|
- typenum 1.20.1 — https://github.com/paholg/typenum
|
|
863
826
|
|
|
864
827
|
```
|
|
@@ -890,7 +853,7 @@ SOFTWARE.
|
|
|
890
853
|
|
|
891
854
|
Used by:
|
|
892
855
|
|
|
893
|
-
- memchr 2.8.
|
|
856
|
+
- memchr 2.8.3 — https://github.com/BurntSushi/memchr
|
|
894
857
|
|
|
895
858
|
```
|
|
896
859
|
The MIT License (MIT)
|
|
@@ -921,7 +884,7 @@ THE SOFTWARE.
|
|
|
921
884
|
|
|
922
885
|
Used by:
|
|
923
886
|
|
|
924
|
-
- unicode-ident 1.0.
|
|
887
|
+
- unicode-ident 1.0.27 — https://github.com/dtolnay/unicode-ident
|
|
925
888
|
|
|
926
889
|
```
|
|
927
890
|
UNICODE LICENSE V3
|
package/Types.cs
CHANGED
|
@@ -6,11 +6,9 @@ namespace AUTD3
|
|
|
6
6
|
public enum Autd3ErrorCode
|
|
7
7
|
{
|
|
8
8
|
Error = -1,
|
|
9
|
-
Timeout = -2,
|
|
10
9
|
Device = -3,
|
|
11
10
|
Network = -4,
|
|
12
11
|
InvalidArgument = -5,
|
|
13
|
-
UnsupportedFirmware = -6,
|
|
14
12
|
Aborted = -7,
|
|
15
13
|
}
|
|
16
14
|
|
|
@@ -43,9 +41,11 @@ namespace AUTD3
|
|
|
43
41
|
public static readonly byte NumFociMax = NativeCore.autd3_core_params_num_foci_max();
|
|
44
42
|
public static readonly ushort PulseWidthPeriod = NativeCore.autd3_core_params_pulse_width_period();
|
|
45
43
|
public static readonly int MaxInflight = (int)NativeCore.autd3_core_params_max_inflight();
|
|
44
|
+
public static readonly int MaxDevices = (int)NativeCore.autd3_core_params_max_devices();
|
|
45
|
+
public static readonly ushort Port = NativeCore.autd3_core_params_port();
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
public readonly struct Autd3
|
|
48
|
+
public readonly struct Autd3 : IEquatable<Autd3>
|
|
49
49
|
{
|
|
50
50
|
public static readonly int NumTransducers = (int)NativeCore.autd3_core_params_num_transducers();
|
|
51
51
|
public static readonly uint GridX = NativeCore.autd3_core_params_grid_x();
|
|
@@ -53,20 +53,35 @@ namespace AUTD3
|
|
|
53
53
|
public static readonly float PitchMm = NativeCore.autd3_core_params_pitch_mm();
|
|
54
54
|
public static readonly float DeviceWidth = NativeCore.autd3_core_params_device_width_mm();
|
|
55
55
|
public static readonly float DeviceHeight = NativeCore.autd3_core_params_device_height_mm();
|
|
56
|
+
public static readonly float RotationNormTolerance = NativeCore.autd3_core_params_rotation_norm_tolerance();
|
|
57
|
+
|
|
58
|
+
private readonly Quaternion? _rotation;
|
|
56
59
|
|
|
57
60
|
public Vector3 Origin { get; }
|
|
58
|
-
public Quaternion Rotation
|
|
61
|
+
public Quaternion Rotation => _rotation ?? Coords.IdentityRotation;
|
|
59
62
|
|
|
60
|
-
public Autd3(Vector3 origin)
|
|
63
|
+
public Autd3(Vector3 origin)
|
|
61
64
|
{
|
|
65
|
+
Origin = origin;
|
|
66
|
+
_rotation = null;
|
|
62
67
|
}
|
|
63
68
|
|
|
64
69
|
public Autd3(Vector3 origin, Quaternion rotation)
|
|
65
70
|
{
|
|
66
71
|
Origin = origin;
|
|
67
|
-
|
|
72
|
+
_rotation = rotation;
|
|
68
73
|
}
|
|
69
74
|
|
|
75
|
+
public bool Equals(Autd3 other) => Origin.Equals(other.Origin) && Rotation.Equals(other.Rotation);
|
|
76
|
+
|
|
77
|
+
public override bool Equals(object? obj) => obj is Autd3 other && Equals(other);
|
|
78
|
+
|
|
79
|
+
public override int GetHashCode() => HashCode.Combine(Origin, Rotation);
|
|
80
|
+
|
|
81
|
+
public static bool operator ==(Autd3 left, Autd3 right) => left.Equals(right);
|
|
82
|
+
|
|
83
|
+
public static bool operator !=(Autd3 left, Autd3 right) => !left.Equals(right);
|
|
84
|
+
|
|
70
85
|
internal NativeCore.Autd3Device ToNative()
|
|
71
86
|
{
|
|
72
87
|
var o = Coords.Point(Origin);
|
|
@@ -84,34 +99,42 @@ namespace AUTD3
|
|
|
84
99
|
}
|
|
85
100
|
}
|
|
86
101
|
|
|
87
|
-
public readonly struct Intensity
|
|
102
|
+
public readonly struct Intensity : IEquatable<Intensity>, IComparable<Intensity>
|
|
88
103
|
{
|
|
89
|
-
|
|
104
|
+
private readonly byte _inverted;
|
|
105
|
+
|
|
106
|
+
public byte Value => (byte)~_inverted;
|
|
90
107
|
|
|
91
108
|
public Intensity(byte value)
|
|
92
109
|
{
|
|
93
|
-
|
|
110
|
+
_inverted = (byte)~value;
|
|
94
111
|
}
|
|
95
112
|
|
|
96
|
-
public
|
|
97
|
-
|
|
113
|
+
public bool Equals(Intensity other) => _inverted == other._inverted;
|
|
114
|
+
|
|
115
|
+
public override bool Equals(object? obj) => obj is Intensity other && Equals(other);
|
|
116
|
+
|
|
117
|
+
public override int GetHashCode() => Value;
|
|
118
|
+
|
|
119
|
+
public int CompareTo(Intensity other) => Value.CompareTo(other.Value);
|
|
120
|
+
|
|
121
|
+
public static bool operator ==(Intensity left, Intensity right) => left.Equals(right);
|
|
122
|
+
|
|
123
|
+
public static bool operator !=(Intensity left, Intensity right) => !left.Equals(right);
|
|
98
124
|
|
|
99
|
-
public static
|
|
100
|
-
new Intensity((byte)Math.Min(lhs.Value + rhs.Value, 0xFF));
|
|
125
|
+
public static bool operator <(Intensity left, Intensity right) => left.Value < right.Value;
|
|
101
126
|
|
|
102
|
-
public static
|
|
103
|
-
new Intensity((byte)Math.Max(lhs.Value - rhs.Value, 0x00));
|
|
127
|
+
public static bool operator >(Intensity left, Intensity right) => left.Value > right.Value;
|
|
104
128
|
|
|
105
|
-
public static
|
|
106
|
-
new Intensity((byte)Math.Min(lhs.Value * rhs, 0xFF));
|
|
129
|
+
public static bool operator <=(Intensity left, Intensity right) => left.Value <= right.Value;
|
|
107
130
|
|
|
108
|
-
public static
|
|
131
|
+
public static bool operator >=(Intensity left, Intensity right) => left.Value >= right.Value;
|
|
109
132
|
|
|
110
|
-
public static Intensity
|
|
111
|
-
|
|
133
|
+
public static Intensity Max => new Intensity(0xFF);
|
|
134
|
+
public static Intensity Min => new Intensity(0x00);
|
|
112
135
|
}
|
|
113
136
|
|
|
114
|
-
public readonly struct Phase
|
|
137
|
+
public readonly struct Phase : IEquatable<Phase>
|
|
115
138
|
{
|
|
116
139
|
public byte Value { get; }
|
|
117
140
|
|
|
@@ -120,6 +143,16 @@ namespace AUTD3
|
|
|
120
143
|
Value = value;
|
|
121
144
|
}
|
|
122
145
|
|
|
146
|
+
public bool Equals(Phase other) => Value == other.Value;
|
|
147
|
+
|
|
148
|
+
public override bool Equals(object? obj) => obj is Phase other && Equals(other);
|
|
149
|
+
|
|
150
|
+
public override int GetHashCode() => Value;
|
|
151
|
+
|
|
152
|
+
public static bool operator ==(Phase left, Phase right) => left.Equals(right);
|
|
153
|
+
|
|
154
|
+
public static bool operator !=(Phase left, Phase right) => !left.Equals(right);
|
|
155
|
+
|
|
123
156
|
public static Phase Zero => new Phase(0x00);
|
|
124
157
|
public static Phase Pi => new Phase(0x80);
|
|
125
158
|
|
|
@@ -136,21 +169,12 @@ namespace AUTD3
|
|
|
136
169
|
|
|
137
170
|
public static Phase operator -(Phase lhs, Phase rhs) =>
|
|
138
171
|
new Phase(unchecked((byte)(lhs.Value - rhs.Value)));
|
|
139
|
-
|
|
140
|
-
public static Phase operator *(Phase lhs, byte rhs) =>
|
|
141
|
-
new Phase(unchecked((byte)(lhs.Value * rhs)));
|
|
142
|
-
|
|
143
|
-
public static Phase operator *(byte lhs, Phase rhs) => rhs * lhs;
|
|
144
|
-
|
|
145
|
-
public static Phase operator /(Phase lhs, byte rhs) =>
|
|
146
|
-
new Phase((byte)(lhs.Value / rhs));
|
|
147
172
|
}
|
|
148
173
|
|
|
149
|
-
public readonly struct Interface
|
|
174
|
+
public readonly struct Interface : IEquatable<Interface>
|
|
150
175
|
{
|
|
151
176
|
private const byte KindNic = 0;
|
|
152
|
-
private const byte
|
|
153
|
-
private const byte KindAddr = 2;
|
|
177
|
+
private const byte KindAddr = 1;
|
|
154
178
|
|
|
155
179
|
private readonly byte _kind;
|
|
156
180
|
private readonly string? _value;
|
|
@@ -163,8 +187,6 @@ namespace AUTD3
|
|
|
163
187
|
|
|
164
188
|
public static Interface Auto => default;
|
|
165
189
|
|
|
166
|
-
public static Interface Simulator => new Interface(KindSimulator, null);
|
|
167
|
-
|
|
168
190
|
public static Interface Name(string name) => new Interface(KindNic, name);
|
|
169
191
|
|
|
170
192
|
public static Interface Addr(string addr) => new Interface(KindAddr, addr);
|
|
@@ -173,9 +195,17 @@ namespace AUTD3
|
|
|
173
195
|
|
|
174
196
|
public bool IsAuto => _kind == KindNic && _value == null;
|
|
175
197
|
|
|
176
|
-
public bool IsSimulator => _kind == KindSimulator;
|
|
177
|
-
|
|
178
198
|
public string? AddrValue => _kind == KindAddr ? _value : null;
|
|
199
|
+
|
|
200
|
+
public bool Equals(Interface other) => _kind == other._kind && string.Equals(_value, other._value, StringComparison.Ordinal);
|
|
201
|
+
|
|
202
|
+
public override bool Equals(object? obj) => obj is Interface other && Equals(other);
|
|
203
|
+
|
|
204
|
+
public override int GetHashCode() => HashCode.Combine(_kind, _value is null ? 0 : StringComparer.Ordinal.GetHashCode(_value));
|
|
205
|
+
|
|
206
|
+
public static bool operator ==(Interface left, Interface right) => left.Equals(right);
|
|
207
|
+
|
|
208
|
+
public static bool operator !=(Interface left, Interface right) => !left.Equals(right);
|
|
179
209
|
}
|
|
180
210
|
|
|
181
211
|
public readonly struct DeviceState : IEquatable<DeviceState>
|
|
@@ -189,7 +219,6 @@ namespace AUTD3
|
|
|
189
219
|
|
|
190
220
|
public static DeviceState Ready => new DeviceState(0);
|
|
191
221
|
public static DeviceState Syncing => new DeviceState(1);
|
|
192
|
-
public static DeviceState Lost => new DeviceState(2);
|
|
193
222
|
|
|
194
223
|
internal static DeviceState FromNative(byte kind) => new DeviceState(kind);
|
|
195
224
|
|
|
@@ -197,7 +226,6 @@ namespace AUTD3
|
|
|
197
226
|
{
|
|
198
227
|
0 => "READY",
|
|
199
228
|
1 => "SYNCING",
|
|
200
|
-
2 => "LOST",
|
|
201
229
|
_ => $"UNKNOWN ({_kind})",
|
|
202
230
|
};
|
|
203
231
|
|
package/Units.cs
CHANGED
|
@@ -2,7 +2,7 @@ using System;
|
|
|
2
2
|
|
|
3
3
|
namespace AUTD3
|
|
4
4
|
{
|
|
5
|
-
public readonly struct Length
|
|
5
|
+
public readonly struct Length : IEquatable<Length>
|
|
6
6
|
{
|
|
7
7
|
public float Mm { get; }
|
|
8
8
|
|
|
@@ -16,10 +16,42 @@ namespace AUTD3
|
|
|
16
16
|
public static Length FromMm(float mm) => new Length(mm);
|
|
17
17
|
|
|
18
18
|
public static Length FromM(float m) => new Length(m * 1000f);
|
|
19
|
+
|
|
20
|
+
public static Length operator +(Length lhs, Length rhs) => new Length(lhs.Mm + rhs.Mm);
|
|
21
|
+
|
|
22
|
+
public static Length operator -(Length lhs, Length rhs) => new Length(lhs.Mm - rhs.Mm);
|
|
23
|
+
|
|
24
|
+
public static Length operator -(Length value) => new Length(-value.Mm);
|
|
25
|
+
|
|
26
|
+
public static Length operator *(Length lhs, float rhs) => new Length(lhs.Mm * rhs);
|
|
27
|
+
|
|
28
|
+
public static Length operator *(float lhs, Length rhs) => new Length(lhs * rhs.Mm);
|
|
29
|
+
|
|
30
|
+
public static Length operator /(Length lhs, float rhs) => new Length(lhs.Mm / rhs);
|
|
31
|
+
|
|
32
|
+
public bool Equals(Length other) => Mm.Equals(other.Mm);
|
|
33
|
+
|
|
34
|
+
public override bool Equals(object? obj) => obj is Length other && Equals(other);
|
|
35
|
+
|
|
36
|
+
public override int GetHashCode() => Mm.GetHashCode();
|
|
37
|
+
|
|
38
|
+
public static bool operator ==(Length left, Length right) => left.Mm == right.Mm;
|
|
39
|
+
|
|
40
|
+
public static bool operator !=(Length left, Length right) => left.Mm != right.Mm;
|
|
41
|
+
|
|
42
|
+
public static bool operator <(Length left, Length right) => left.Mm < right.Mm;
|
|
43
|
+
|
|
44
|
+
public static bool operator >(Length left, Length right) => left.Mm > right.Mm;
|
|
45
|
+
|
|
46
|
+
public static bool operator <=(Length left, Length right) => left.Mm <= right.Mm;
|
|
47
|
+
|
|
48
|
+
public static bool operator >=(Length left, Length right) => left.Mm >= right.Mm;
|
|
19
49
|
}
|
|
20
50
|
|
|
21
|
-
public readonly struct Angle
|
|
51
|
+
public readonly struct Angle : IEquatable<Angle>
|
|
22
52
|
{
|
|
53
|
+
private const float DegreesPerRadian = 57.29577951308232f;
|
|
54
|
+
|
|
23
55
|
public float Rad { get; }
|
|
24
56
|
|
|
25
57
|
internal Angle(float radian)
|
|
@@ -27,16 +59,38 @@ namespace AUTD3
|
|
|
27
59
|
Rad = radian;
|
|
28
60
|
}
|
|
29
61
|
|
|
30
|
-
public float Deg => Rad *
|
|
62
|
+
public float Deg => Rad * DegreesPerRadian;
|
|
31
63
|
|
|
32
64
|
public static Angle Zero => new Angle(0f);
|
|
33
65
|
|
|
34
66
|
public static Angle FromRad(float radian) => new Angle(radian);
|
|
35
67
|
|
|
36
68
|
public static Angle FromDeg(float degree) => new Angle(degree * (MathF.PI / 180f));
|
|
69
|
+
|
|
70
|
+
public static Angle operator +(Angle lhs, Angle rhs) => new Angle(lhs.Rad + rhs.Rad);
|
|
71
|
+
|
|
72
|
+
public static Angle operator -(Angle lhs, Angle rhs) => new Angle(lhs.Rad - rhs.Rad);
|
|
73
|
+
|
|
74
|
+
public static Angle operator -(Angle value) => new Angle(-value.Rad);
|
|
75
|
+
|
|
76
|
+
public static Angle operator *(Angle lhs, float rhs) => new Angle(lhs.Rad * rhs);
|
|
77
|
+
|
|
78
|
+
public static Angle operator *(float lhs, Angle rhs) => new Angle(rhs.Rad * lhs);
|
|
79
|
+
|
|
80
|
+
public static Angle operator /(Angle lhs, float rhs) => new Angle(lhs.Rad / rhs);
|
|
81
|
+
|
|
82
|
+
public bool Equals(Angle other) => Rad.Equals(other.Rad);
|
|
83
|
+
|
|
84
|
+
public override bool Equals(object? obj) => obj is Angle other && Equals(other);
|
|
85
|
+
|
|
86
|
+
public override int GetHashCode() => Rad.GetHashCode();
|
|
87
|
+
|
|
88
|
+
public static bool operator ==(Angle left, Angle right) => left.Rad == right.Rad;
|
|
89
|
+
|
|
90
|
+
public static bool operator !=(Angle left, Angle right) => left.Rad != right.Rad;
|
|
37
91
|
}
|
|
38
92
|
|
|
39
|
-
public readonly struct Velocity
|
|
93
|
+
public readonly struct Velocity : IEquatable<Velocity>
|
|
40
94
|
{
|
|
41
95
|
public float MmS { get; }
|
|
42
96
|
|
|
@@ -50,70 +104,64 @@ namespace AUTD3
|
|
|
50
104
|
public static Velocity FromMmS(float mmPerS) => new Velocity(mmPerS);
|
|
51
105
|
|
|
52
106
|
public static Velocity FromMS(float mPerS) => new Velocity(mPerS * 1000f);
|
|
107
|
+
|
|
108
|
+
public bool Equals(Velocity other) => MmS.Equals(other.MmS);
|
|
109
|
+
|
|
110
|
+
public override bool Equals(object? obj) => obj is Velocity other && Equals(other);
|
|
111
|
+
|
|
112
|
+
public override int GetHashCode() => MmS.GetHashCode();
|
|
113
|
+
|
|
114
|
+
public static bool operator ==(Velocity left, Velocity right) => left.MmS == right.MmS;
|
|
115
|
+
|
|
116
|
+
public static bool operator !=(Velocity left, Velocity right) => left.MmS != right.MmS;
|
|
117
|
+
|
|
118
|
+
public static bool operator <(Velocity left, Velocity right) => left.MmS < right.MmS;
|
|
119
|
+
|
|
120
|
+
public static bool operator >(Velocity left, Velocity right) => left.MmS > right.MmS;
|
|
121
|
+
|
|
122
|
+
public static bool operator <=(Velocity left, Velocity right) => left.MmS <= right.MmS;
|
|
123
|
+
|
|
124
|
+
public static bool operator >=(Velocity left, Velocity right) => left.MmS >= right.MmS;
|
|
53
125
|
}
|
|
54
126
|
|
|
55
|
-
public readonly struct Freq
|
|
127
|
+
public readonly struct Freq : IEquatable<Freq>
|
|
56
128
|
{
|
|
57
|
-
public
|
|
129
|
+
public float Hz { get; }
|
|
130
|
+
|
|
131
|
+
internal Freq(float hz)
|
|
58
132
|
{
|
|
59
|
-
|
|
60
|
-
IntExact = 1,
|
|
133
|
+
Hz = hz;
|
|
61
134
|
}
|
|
62
135
|
|
|
63
|
-
public
|
|
64
|
-
internal float HzValue { get; }
|
|
65
|
-
public uint HzIntValue { get; }
|
|
136
|
+
public static Freq FromHz(float hz) => new Freq(hz);
|
|
66
137
|
|
|
67
|
-
|
|
68
|
-
{
|
|
69
|
-
Mode = mode;
|
|
70
|
-
HzValue = hz;
|
|
71
|
-
HzIntValue = hzInt;
|
|
72
|
-
}
|
|
138
|
+
public static Freq operator +(Freq lhs, Freq rhs) => new Freq(lhs.Hz + rhs.Hz);
|
|
73
139
|
|
|
74
|
-
public
|
|
140
|
+
public static Freq operator -(Freq lhs, Freq rhs) => new Freq(lhs.Hz - rhs.Hz);
|
|
75
141
|
|
|
76
|
-
public static Freq
|
|
142
|
+
public static Freq operator *(Freq lhs, float rhs) => new Freq(lhs.Hz * rhs);
|
|
77
143
|
|
|
78
|
-
public static Freq
|
|
144
|
+
public static Freq operator *(float lhs, Freq rhs) => new Freq(lhs * rhs.Hz);
|
|
79
145
|
|
|
80
|
-
|
|
146
|
+
public static Freq operator /(Freq lhs, float rhs) => new Freq(lhs.Hz / rhs);
|
|
81
147
|
|
|
82
|
-
public
|
|
83
|
-
lhs.Mode == FreqMode.IntExact && rhs.Mode == FreqMode.IntExact
|
|
84
|
-
? new Freq(FreqMode.IntExact, lhs.HzValue + rhs.HzValue, lhs.HzIntValue + rhs.HzIntValue)
|
|
85
|
-
: new Freq(FreqMode.FloatExact, lhs.HzValue + rhs.HzValue, 0);
|
|
148
|
+
public bool Equals(Freq other) => Hz.Equals(other.Hz);
|
|
86
149
|
|
|
87
|
-
public
|
|
88
|
-
lhs.Mode == FreqMode.IntExact && rhs.Mode == FreqMode.IntExact
|
|
89
|
-
? new Freq(FreqMode.IntExact, lhs.HzValue - rhs.HzValue, lhs.HzIntValue - rhs.HzIntValue)
|
|
90
|
-
: new Freq(FreqMode.FloatExact, lhs.HzValue - rhs.HzValue, 0);
|
|
150
|
+
public override bool Equals(object? obj) => obj is Freq other && Equals(other);
|
|
91
151
|
|
|
92
|
-
public
|
|
93
|
-
lhs.Mode == FreqMode.IntExact
|
|
94
|
-
? new Freq(FreqMode.IntExact, lhs.HzValue * rhs, lhs.HzIntValue * rhs)
|
|
95
|
-
: new Freq(FreqMode.FloatExact, lhs.HzValue * rhs, 0);
|
|
152
|
+
public override int GetHashCode() => Hz.GetHashCode();
|
|
96
153
|
|
|
97
|
-
public static
|
|
98
|
-
new Freq(FreqMode.FloatExact, lhs.HzValue * rhs, 0);
|
|
154
|
+
public static bool operator ==(Freq left, Freq right) => left.Hz == right.Hz;
|
|
99
155
|
|
|
100
|
-
public static
|
|
101
|
-
lhs.Mode == FreqMode.IntExact
|
|
102
|
-
? new Freq(FreqMode.IntExact, lhs.HzIntValue / rhs, lhs.HzIntValue / rhs)
|
|
103
|
-
: new Freq(FreqMode.FloatExact, lhs.HzValue / rhs, 0);
|
|
156
|
+
public static bool operator !=(Freq left, Freq right) => left.Hz != right.Hz;
|
|
104
157
|
|
|
105
|
-
public static
|
|
106
|
-
new Freq(FreqMode.FloatExact, lhs.HzValue / rhs, 0);
|
|
107
|
-
}
|
|
158
|
+
public static bool operator <(Freq left, Freq right) => left.Hz < right.Hz;
|
|
108
159
|
|
|
109
|
-
|
|
110
|
-
{
|
|
111
|
-
public T Value { get; }
|
|
160
|
+
public static bool operator >(Freq left, Freq right) => left.Hz > right.Hz;
|
|
112
161
|
|
|
113
|
-
public
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
162
|
+
public static bool operator <=(Freq left, Freq right) => left.Hz <= right.Hz;
|
|
163
|
+
|
|
164
|
+
public static bool operator >=(Freq left, Freq right) => left.Hz >= right.Hz;
|
|
117
165
|
}
|
|
118
166
|
|
|
119
167
|
public readonly struct LengthUnit
|
|
@@ -147,25 +195,13 @@ namespace AUTD3
|
|
|
147
195
|
public readonly struct FreqUnit
|
|
148
196
|
{
|
|
149
197
|
internal float HzPerUnit { get; }
|
|
150
|
-
internal uint HzPerUnitInt { get; }
|
|
151
198
|
|
|
152
|
-
internal FreqUnit(float hzPerUnit
|
|
199
|
+
internal FreqUnit(float hzPerUnit)
|
|
153
200
|
{
|
|
154
201
|
HzPerUnit = hzPerUnit;
|
|
155
|
-
HzPerUnitInt = hzPerUnitInt;
|
|
156
|
-
}
|
|
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
202
|
}
|
|
166
203
|
|
|
167
|
-
public static Freq operator *(float value, FreqUnit unit) =>
|
|
168
|
-
new Freq(Freq.FreqMode.FloatExact, value * unit.HzPerUnit, 0);
|
|
204
|
+
public static Freq operator *(float value, FreqUnit unit) => new Freq(value * unit.HzPerUnit);
|
|
169
205
|
}
|
|
170
206
|
|
|
171
207
|
public readonly struct SecUnit
|
|
@@ -183,16 +219,12 @@ namespace AUTD3
|
|
|
183
219
|
public static readonly LengthUnit mm = new LengthUnit(1f);
|
|
184
220
|
public static readonly AngleUnit rad = new AngleUnit(1f);
|
|
185
221
|
public static readonly AngleUnit deg = new AngleUnit((float)(Math.PI / 180.0));
|
|
186
|
-
public static readonly FreqUnit Hz = new FreqUnit(1f
|
|
187
|
-
public static readonly FreqUnit kHz = new FreqUnit(1000f
|
|
222
|
+
public static readonly FreqUnit Hz = new FreqUnit(1f);
|
|
223
|
+
public static readonly FreqUnit kHz = new FreqUnit(1000f);
|
|
188
224
|
public static readonly SecUnit s = default;
|
|
189
225
|
|
|
190
226
|
public static Vector3 Point(Length x, Length y, Length z) => Coords.FromLengths(x, y, z);
|
|
191
227
|
|
|
192
228
|
public static Vector3 Offset(Length x, Length y, Length z) => Coords.FromLengths(x, y, z);
|
|
193
|
-
|
|
194
|
-
public static Nearest<Freq> Nearest(Freq freq) => new Nearest<Freq>(freq);
|
|
195
|
-
|
|
196
|
-
public static Nearest<TimeSpan> Nearest(TimeSpan period) => new Nearest<TimeSpan>(period);
|
|
197
229
|
}
|
|
198
230
|
}
|
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.14.0",
|
|
9
9
|
"displayName": "AUTD3 Core",
|
|
10
10
|
"description": "AUTD3 core types, geometry and units (Unity binding).",
|
|
11
11
|
"unity": "6000.0",
|