Skip to content

Commit

Permalink
bump to v24.0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
s5suzuki committed May 20, 2024
1 parent f3056f0 commit 92e7749
Show file tree
Hide file tree
Showing 30 changed files with 74 additions and 67 deletions.
2 changes: 1 addition & 1 deletion derive/AUTD3Sharp.Derive.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<Platforms>AnyCPU</Platforms>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>24.0.0</Version>
<Version>24.0.0.1</Version>
<Authors>Shun Suzuki</Authors>
<Company>Shinolab</Company>
<Description>AUTD3 derive helper for AUTD3Sharp</Description>
Expand Down
10 changes: 6 additions & 4 deletions derive/GainDerive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ private GainPtr GainPtr(Geometry geometry)
});
}
[ExcludeFromCodeCoverage] private static Dictionary<int, AUTD3Sharp.Drive[]> Transform(Geometry geometry, Func<Device, Transducer, AUTD3Sharp.Drive> f)
[ExcludeFromCodeCoverage] private static Dictionary<int, AUTD3Sharp.Drive[]> Transform(Geometry geometry, Func<Device, Func<Transducer, AUTD3Sharp.Drive>> f)
{
return geometry.Devices().Select(dev => (dev.Idx, dev.Select(tr => f(dev, tr)).ToArray())).ToDictionary(x => x.Idx, x => x.Item2);
return geometry.Devices().Select(dev => (dev.Idx, dev.Select(tr => f(dev)(tr)).ToArray())).ToDictionary(x => x.Idx, x => x.Item2);
}
""" : "";
Expand Down Expand Up @@ -75,6 +75,8 @@ private GainPtr GainPtr(Geometry geometry)
.Replace("global::", "")
.Replace("<", "_")
.Replace(">", "_");
var nsBegin = ns == "" ? "" : $"{ns} {{";
var nsEnd = ns == "" ? "" : "}";
var code = $$"""
// <auto-generated/>
Expand All @@ -88,7 +90,7 @@ private GainPtr GainPtr(Geometry geometry)
using AUTD3Sharp.Driver.Datagram;
using AUTD3Sharp.NativeMethods;
{{ns}} {
{{nsBegin}}
public partial class {{typeName}} : AUTD3Sharp.Driver.Datagram.Gain.IGain, IDatagramS<GainPtr>, IDatagram
{
DatagramPtr IDatagram.Ptr(Geometry geometry) => NativeMethodsBase.AUTDGainIntoDatagram(((AUTD3Sharp.Driver.Datagram.Gain.IGain)this).GainPtr(geometry));
Expand All @@ -103,7 +105,7 @@ public partial class {{typeName}} : AUTD3Sharp.Driver.Datagram.Gain.IGain, IData
{{cacheCode}}
{{transformCode}}
}
}
{{nsEnd}}
""";
context.AddSource($"{fullType}.GainDerive.g.cs", code);
}
Expand Down
7 changes: 5 additions & 2 deletions derive/ModulationDerive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ private ModulationPtr ModulationPtr(Geometry geometry)
.Replace("global::", "")
.Replace("<", "_")
.Replace(">", "_");
var nsBegin = ns == "" ? "" : $"{ns} {{";
var nsEnd = ns == "" ? "" : "}";
var code = $$"""
// <auto-generated/>
Expand All @@ -78,11 +80,12 @@ private ModulationPtr ModulationPtr(Geometry geometry)
using System;
using System.Diagnostics.CodeAnalysis;
using AUTD3Sharp;
using AUTD3Sharp.Driver.Datagram;
using AUTD3Sharp.Driver.Datagram.Modulation;
using AUTD3Sharp.NativeMethods;
{{ns}} {
{{nsBegin}}
partial class {{typeName}} : AUTD3Sharp.Driver.Datagram.Modulation.IModulation, IDatagramST<ModulationPtr>, IDatagram
{
DatagramPtr IDatagram.Ptr(Geometry geometry) => NativeMethodsBase.AUTDModulationIntoDatagram(ModulationPtr(geometry));
Expand Down Expand Up @@ -111,7 +114,7 @@ [ExcludeFromCodeCoverage] DatagramPtr IDatagramST<ModulationPtr>.IntoSegmentTran
{{radiationPressureCode}}
{{transformCode}}
}
}
{{nsEnd}}
""";
context.AddSource($"{fullType}.ModulationDerive.g.cs", code);
}
Expand Down
2 changes: 1 addition & 1 deletion example/cs/RemoteSOEM/RemoteSOEM.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AUTD3Sharp" Version="24.0.0" />
<PackageReference Include="AUTD3Sharp" Version="24.0.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion example/cs/RemoveTwinCAT/RemoveTwinCAT.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AUTD3Sharp" Version="24.0.0" />
<PackageReference Include="AUTD3Sharp" Version="24.0.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion example/cs/SOEM/SOEM.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AUTD3Sharp" Version="24.0.0" />
<PackageReference Include="AUTD3Sharp" Version="24.0.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion example/cs/Samples/Custom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static void Test<T>(Controller<T> autd)

var m = new Sine(150 * Hz);
var g = new Custom(
(dev, tr) => (dev.Idx, tr.Idx) switch
(dev) => (tr) => (dev.Idx, tr.Idx) switch
{
(0, 0) => new Drive(new Phase(0), EmitIntensity.Max),
(0, 248) => new Drive(new Phase(0), EmitIntensity.Max),
Expand Down
2 changes: 1 addition & 1 deletion example/cs/Samples/SampleRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static void Run<T>(Controller<T> autd)
if (autd.Geometry.NumDevices >= 2) examples.Add((GroupByDeviceTest.Test, "Group (by Device) test"));

Console.WriteLine("======== AUTD3 firmware information ========");
Console.WriteLine(string.Join("\n", autd.FirmwareVersionList()));
Console.WriteLine(string.Join("\n", autd.FirmwareVersion()));
Console.WriteLine("============================================");

while (true)
Expand Down
2 changes: 1 addition & 1 deletion example/cs/Samples/Samples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="AUTD3Sharp" Version="24.0.0" />
<PackageReference Include="AUTD3Sharp" Version="24.0.0.1" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions example/cs/Samples/UserDefined.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ partial class MyFocus(Vector3d point)
{
private Dictionary<int, Drive[]> Calc(Geometry geometry)
{
return Transform(geometry, (dev, tr) =>
return Transform(geometry, dev => tr =>
{
var tp = tr.Position;
var dist = (tp - point).L2Norm;
var phase = Phase.FromRad(dist * dev.Wavenumber);
var phase = new Phase(dist * dev.Wavenumber * rad);
return new Drive { Phase = phase, Intensity = EmitIntensity.Max };
});
}
Expand Down
2 changes: 1 addition & 1 deletion example/cs/Simulator/Simulator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AUTD3Sharp" Version="24.0.0" />
<PackageReference Include="AUTD3Sharp" Version="24.0.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion example/cs/TwinCAT/TwinCAT.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AUTD3Sharp" Version="24.0.0" />
<PackageReference Include="AUTD3Sharp" Version="24.0.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion example/fs/RemoteSOEM/RemoteSOEM.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="AUTD3Sharp" Version="24.0.0" />
<PackageReference Include="AUTD3Sharp" Version="24.0.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion example/fs/RemoveTwinCAT/RemoveTwinCAT.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="AUTD3Sharp" Version="24.0.0" />
<PackageReference Include="AUTD3Sharp" Version="24.0.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion example/fs/SOEM/SOEM.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="AUTD3Sharp" Version="24.0.0" />
<PackageReference Include="AUTD3Sharp" Version="24.0.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
17 changes: 17 additions & 0 deletions example/fs/Samples/Custom.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace Samples

open AUTD3Sharp
open AUTD3Sharp.Gain
open AUTD3Sharp.Modulation
open type AUTD3Sharp.Units

module CustomTest =
let Test<'T> (autd : Controller<'T>) =
(Silencer.Default()) |> autd.Send;

let m = new Sine(150u * Hz);
let g = new Custom(fun dev -> new System.Func<Transducer, Drive>(fun tr -> match (dev.Idx, tr.Idx) with
| (0, 0) -> new Drive(new Phase(byte(0)), EmitIntensity.Max)
| (0, 248) -> new Drive(new Phase(byte(0)), EmitIntensity.Max)
| _ -> Drive.Null));
(m, g) |> autd.Send;
4 changes: 2 additions & 2 deletions example/fs/Samples/SampleRunner.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ module SampleRunner =
(STMTest.GainSTMTest, "GainSTM test");
(GainHoloTest.Test, "Multiple foci test");
(FlagTest.Test, "Flag test");
(TransTest.Test, "TransducerTest test");
(CustomTest.Test, "Custom gain test");
(GroupByTransducerTest.Test, "Group (by Transducer) test")];

let examples =
if autd.Geometry.NumDevices >= 2 then examples @ [(GroupByDeviceTest.Test, "Group (by Device) test")] else examples;


printfn "======== AUTD3 firmware information ========"
autd.FirmwareVersionList() |> Seq.iter (fun firm -> printfn $"{firm}")
autd.FirmwareVersion() |> Seq.iter (fun firm -> printfn $"{firm}")
printfn "============================================"

let rec run_example () =
Expand Down
4 changes: 2 additions & 2 deletions example/fs/Samples/Samples.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Compile Include="Wav.fs" />
<Compile Include="Transtest.fs" />
<Compile Include="Custom.fs" />
<Compile Include="Plane.fs" />
<Compile Include="Flag.fs" />
<Compile Include="STMTest.fs" />
Expand All @@ -24,7 +24,7 @@
<ItemGroup />

<ItemGroup>
<PackageReference Include="AUTD3Sharp" Version="24.0.0" />
<PackageReference Include="AUTD3Sharp" Version="24.0.0.1" />
</ItemGroup>

</Project>
17 changes: 0 additions & 17 deletions example/fs/Samples/Transtest.fs

This file was deleted.

2 changes: 1 addition & 1 deletion example/fs/Simulator/Simulator.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="AUTD3Sharp" Version="24.0.0" />
<PackageReference Include="AUTD3Sharp" Version="24.0.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion example/fs/TwinCAT/TwinCAT.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="AUTD3Sharp" Version="24.0.0" />
<PackageReference Include="AUTD3Sharp" Version="24.0.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/AUTD3Sharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>netstandard2.1</TargetFramework>
<Platforms>AnyCPU</Platforms>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>24.0.0</Version>
<Version>24.0.0.1</Version>
<Authors>Shun Suzuki</Authors>
<Company>Shinolab</Company>
<Description>AUTD3 library wrapper for .Net</Description>
Expand Down
2 changes: 1 addition & 1 deletion src/AUTD3Sharp.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<dependencies>
<group targetFramework=".NETStandard2.1">
<dependency id="NETStandard.Library" version="2.0.3" exclude="Build,Analyzers" />
<dependency id="AUTD3Sharp.Derive" version="24.0.0" >
<dependency id="AUTD3Sharp.Derive" version="24.0.0.1" >
<OutputItemType>Analyzer</OutputItemType>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</dependency>
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/Controller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ private static FirmwareVersion GetFirmwareVersion(FirmwareVersionListPtr handle,
}
}

public async Task<FirmwareVersion[]> FirmwareVersionListAsync()
public async Task<FirmwareVersion[]> FirmwareVersionAsync()
{
var handle = await Task.Run(() => NativeMethodsBase.AUTDControllerFirmwareVersionListPointer(Ptr).Validate());
var result = Enumerable.Range(0, Geometry.NumDevices).Select(i => GetFirmwareVersion(handle, (uint)i)).ToArray();
NativeMethodsBase.AUTDControllerFirmwareVersionListPointerDelete(handle);
return result;
}

public FirmwareVersion[] FirmwareVersionList()
public FirmwareVersion[] FirmwareVersion()
{
var handle = NativeMethodsBase.AUTDControllerFirmwareVersionListPointer(Ptr).Validate();
var result = Enumerable.Range(0, Geometry.NumDevices).Select(i => GetFirmwareVersion(handle, (uint)i)).ToArray();
Expand Down
6 changes: 3 additions & 3 deletions src/Driver/Datagram/PhaseFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ public sealed class PhaseFilter : IDatagram

private readonly PhaseFilterDelegate _f;

private PhaseFilter(Func<Device, Transducer, Phase> f)
private PhaseFilter(Func<Device, Func<Transducer, Phase>> f)
{
_f = (context, geometryPtr, devIdx, trIdx) =>
{
var devPtr = NativeMethodsBase.AUTDDevice(geometryPtr, devIdx);
return f(new Device((int)devIdx, devPtr), new Transducer(trIdx, devPtr)).Value;
return f(new Device((int)devIdx, devPtr))(new Transducer(trIdx, devPtr)).Value;
};
}

public static PhaseFilter Additive(Func<Device, Transducer, Phase> f) => new PhaseFilter(f);
public static PhaseFilter Additive(Func<Device, Func<Transducer, Phase>> f) => new PhaseFilter(f);

DatagramPtr IDatagram.Ptr(Geometry geometry) => NativeMethodsBase.AUTDDatagramPhaseFilterAdditive(Marshal.GetFunctionPointerForDelegate(_f), IntPtr.Zero, geometry.Ptr);
}
Expand Down
6 changes: 4 additions & 2 deletions src/Driver/Firmware/FPGA/Phase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ public Phase(byte value)
Value = value;
}

public double Radian => NativeMethodsBase.AUTDPhaseToRad(Value);
public Phase(Angle value) : this(NativeMethodsBase.AUTDPhaseFromRad(value.Radian))
{
}

public static Phase FromRad(double value) => new Phase(NativeMethodsBase.AUTDPhaseFromRad(value));
public double Radian => NativeMethodsBase.AUTDPhaseToRad(Value);
}
}
4 changes: 2 additions & 2 deletions src/Gain/TransTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ public sealed partial class Custom

private readonly TransducerTestDelegate _f;

public Custom(Func<Device, Transducer, Drive> f)
public Custom(Func<Device, Func<Transducer, Drive>> f)
{
unsafe
{
_f = (context, geometryPtr, devIdx, trIdx, raw) =>
{
var dev = new Device((int)devIdx, NativeMethodsBase.AUTDDevice(geometryPtr, devIdx));
var tr = new Transducer(trIdx, dev.Ptr);
var d = f(dev, tr);
var d = f(dev)(tr);
raw->phase = d.Phase.Value;
raw->intensity = d.Intensity.Value;
};
Expand Down
Loading

0 comments on commit 92e7749

Please sign in to comment.