static void CounterTester() { ConfocalControlLibrary.IntensityReader reader = new ConfocalControlLibrary.IntensityReader("Card/ctr0", true, 5000, "/card/PFI0"); reader.Timeout = 1000; //ConfocalControlLibrary.IntensityCollector Collector = new ConfocalControlLibrary.IntensityCollector(reader, 2000, 3); reader.OnRead += (sender, ev) => { Console.Write(" R " + ev.CounterData.Cast <uint>().Sum((d) => d) + " "); }; reader.Start(); Console.WriteLine("Started"); reader.Stop(); Console.WriteLine("Stopped"); reader.Start(); Console.WriteLine("Started"); reader.Stop(); Console.WriteLine("Stopped"); reader.Start(); Console.WriteLine("Started"); System.Threading.Thread.Sleep(500); reader.Stop(); Console.WriteLine("Stopped"); reader.Start(); Console.WriteLine("Started"); System.Threading.Thread.Sleep(500); reader.Stop(); Console.WriteLine("Read complete."); Console.ReadLine(); Console.Clear(); GC.Collect(0); }
static void AnanlogTester() { ConfocalControlLibrary.IntensityReader reader = new ConfocalControlLibrary.IntensityReader("Card/ai0", false, 500); ConfocalControlLibrary.IntensityCollector Collector = new ConfocalControlLibrary.IntensityCollector(reader, 1000, 3); reader.Start(); System.Threading.Thread.Sleep(1000); reader.Stop(); Collector.GetData(); int listSize = Collector.DataCollector.Count(); Console.WriteLine("Array contains " + listSize + " number of entries"); Console.WriteLine("Let's take a look inside"); //int max = Math.Min(10, Collector.DataCollector.Count); int max = 10; if (max == 0) { Console.WriteLine("Uh oh, There's nothing in here."); } else { for (int i = 0; i < max; i++) { double[] currentValue = Collector.GetData(); double displayValue = currentValue[0]; Console.WriteLine(i + ": " + displayValue); } } Console.WriteLine("Read complete."); Console.ReadLine(); // Display index matrix Console.Clear(); }
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); }