static void PointSelectTester() { ConfocalControlLibrary.PositionWriter gw = new ConfocalControlLibrary.PositionWriter( "Card/ao0", "Card/ao1", 5000);//, "/card/ctr2"); double x = 0, y = 0; while (true) { Console.Write("Enter X: "); if (double.TryParse(Console.ReadLine(), out x)) { Console.Write("Enter Y: "); if (double.TryParse(Console.ReadLine(), out y)) { gw.SetPosition(x, y); } else { gw.WriterTask.Dispose(); return; } } else { gw.WriterTask.Dispose(); return; } } gw.WriterTask.Dispose(); }
static void DoUserDefinedScan() { int N = 100; Console.Write("Enter number of pxiels (nxn) n (Enter = " + N + "): "); string line = Console.ReadLine(); if (line.Trim().Length == 0 || !int.TryParse(line, out N)) { if (line.Trim().Length != 0) { Console.WriteLine("Eror. Enter a number,"); Console.ReadKey(); return; } } double delay = 0.06; Console.Write("Enter delay time [ms] (Enter=" + delay + "): "); line = Console.ReadLine(); if (line.Trim().Length == 0 || !double.TryParse(line, out delay)) { if (line.Trim().Length != 0) { Console.WriteLine("Eror. Enter a number,"); Console.ReadKey(); return; } } int sfreq = 50000; // creating the scan. ConfocalControlLibrary.Scan s = new ConfocalControlLibrary.Scan(-0.5, -0.5, 1, 1, N, delay, ConfocalControlLibrary.ScanType.Ramp, sfreq); s.TriggerDelay = 0.2; s.MoveToXYPositionAfterScan(0, 0); System.DateTime start = DateTime.Now; s.Validate(); //while (!s.PositionAtEnd) // s.NextScanVoltages(sfreq, 100000); Console.WriteLine("Calculated scan in : " + (DateTime.Now - start)); Console.WriteLine("Calculated scan of " + s.getTotalNumberOfVoltagePoints(sfreq) + " voltage points in : " + (DateTime.Now - start)); ConfocalControlLibrary.IntensityReader reader = new ConfocalControlLibrary.IntensityReader("Card/ctr0", true, sfreq, "/card/PFI0"); ConfocalControlLibrary.IntensityCollector Collector = new ConfocalControlLibrary.IntensityCollector(reader, 2000, 3); ConfocalControlLibrary.PositionWriter writer = new ConfocalControlLibrary.PositionWriter( "card/ao0", "card/ao1", sfreq);//, "/card/ctr2"); ConfocalControlLibrary.ImageScanner scanner = new ConfocalControlLibrary.ImageScanner(reader, writer); // start the reader. reader.Start(); writer.SetPosition(0, 0); int pntsRead = 0; reader.OnRead += (r, data) => { if (!scanner.IsRecording) { return; } double avg = data.CounterData.Cast <uint>().Sum(v => v) / data.CounterData.Length; Console.Write(avg + ","); pntsRead += 1; }; Console.WriteLine("Scanning for: " + s.ScanTime.ToString()); scanner.Scan(s); System.Threading.Thread.Sleep(1); start = DateTime.Now; DateTime lastElapsed = start; while (scanner.IsScanning) { System.Threading.Thread.Sleep(1); TimeSpan elapsed = DateTime.Now - lastElapsed; if (elapsed.TotalSeconds > 1) { lastElapsed = DateTime.Now; Console.WriteLine(DateTime.Now - start + " (avg. read. " + pntsRead + ")"); } } Console.WriteLine("Done."); Console.WriteLine("Should be at 0,0"); Console.WriteLine("Waiting 3 secs."); writer.Dispose(); reader.Dispose(); Console.ReadKey(); }
static void DoScanTest() { int sfreq = 5000; ConfocalControlLibrary.IntensityReader reader = new ConfocalControlLibrary.IntensityReader("Card/ctr0", true, sfreq, "/card/PFI0"); ConfocalControlLibrary.IntensityCollector Collector = new ConfocalControlLibrary.IntensityCollector(reader, 2000, 3); ConfocalControlLibrary.PositionWriter writer = new ConfocalControlLibrary.PositionWriter( "card/ao0", "card/ao1", sfreq);//, "/card/ctr2"); ConfocalControlLibrary.ImageScanner scanner = new ConfocalControlLibrary.ImageScanner(reader, writer); // start the reader. reader.Start(); System.Threading.Thread.Sleep(200); writer.SetPosition(0, 0); ConfocalControlLibrary.Scan s = new ConfocalControlLibrary.Scan(-0.5, -0.5, 1, 1, 100, 1, ConfocalControlLibrary.ScanType.Step, sfreq); System.DateTime start = DateTime.Now; s.Validate(); //while (!s.PositionAtEnd) // s.NextScanVoltages(sfreq, 100000); Console.WriteLine("Calculated scan in : " + (DateTime.Now - start)); reader.OnRead += (r, data) => { if (!scanner.IsRecording) { return; } double avg = data.CounterData.Cast <uint>().Sum(v => v) / data.CounterData.Length; Console.Write(avg + ","); }; //start scan scanner.Scan(s); System.Threading.Thread.Sleep(100); start = DateTime.Now; DateTime lastElapsed = start; while (scanner.IsScanning) { System.Threading.Thread.Sleep(1); TimeSpan elapsed = DateTime.Now - lastElapsed; if (elapsed.TotalSeconds > 1) { lastElapsed = DateTime.Now; Console.WriteLine(DateTime.Now - start); } } Console.WriteLine("Done."); System.Threading.Thread.Sleep(1000); writer.SetPosition(0, 0); System.Threading.Thread.Sleep(10); Console.WriteLine("At 0,0"); Console.ReadKey(); GC.Collect(0); }