static void Scan(AUTD3Cnt autd, PicoCnt pico, Conditions cond, string prefix, bool trig, Action <AUTD3Cnt, int> func, bool compress = false) { var dataFolder = Utils.CreateFolderTimeStamped(prefix); cond.Save(dataFolder); for (int i = 0; i <= byte.MaxValue; i++) { Console.Write("{0}: {1, 3:d0}/{2, 3:d0} ({3, 3:f0}%)", prefix, i, byte.MaxValue, 100.0 * i / byte.MaxValue); Console.SetCursorPosition(0, Console.CursorTop); func(autd, i); Thread.Sleep(500); pico.MeasureAndSave(trig, Path.Join(dataFolder, $"{prefix}{i}"), compress); autd.TransTest(0, 0, 0); Thread.Sleep(60 * 1000); } Console.WriteLine(); autd.Stop(); }
static void Main(string[] args) { int NUM_AUTD_X = 3; int NUM_AUTD_Y = 3; float W = 192f; float H = 151.4f; float xc = W * NUM_AUTD_X / 2f; float yc = H * NUM_AUTD_Y / 2f; float Z = 200; var compress = true; var cond = new Conditions() { SampleRateHz = 10_000_000, SampleLen = 10_000, Temp = 22.8f, Humidity = 13f, Amplifer = 10, X = 0, Y = 0, Z = Z }; using var robo = new RobotController(); if (!robo.Connect("172.16.99.57")) { Console.WriteLine("Failed to connect to robot."); return; } robo.MoveTo(0, 0, Z); using var pico = new PicoCnt(); pico.SetChannel(0, 50, 1, null); pico.SetChannel(1, 5000, 10, 1000); pico.SetCondition(cond); using var autd = new AUTD3Cnt(); for (int y = 0; y < NUM_AUTD_Y; y++) { for (int x = 0; x < NUM_AUTD_X; x++) { autd.AddDevice(x * W, y * H, 0); } } var ifname = AUTD3Cnt.GetIfname(); autd.Open(ifname); autd.Clear(); autd.Calibrate(); autd.StaticMod(0xFF); Scan(autd, 10, pico, robo, cond, NUM_AUTD_X, NUM_AUTD_Y, Z, compress); Console.WriteLine("Finish."); autd.Stop(); robo.Finish(); } }