public void Run() { //Set this variable to have all text socket commands printed to the console. SaleaeClient.PrintCommandsToConsole = true; //Make sure to enable the socket server in the Logic software preferences, and make sure that it is running! //This demo is designed to show some common socket commands, and interacts best with either the simulation or real Logic 8, Logic Pro 8, or Logic Pro 16. //lets run a quick demo! Console.WriteLine( "Logic Socket API demonstation application.\n" ); //Get IP address of software. Console.WriteLine( "enter host IP address, or press enter for localhost" ); String host = Console.ReadLine(); if( host.Length == 0 ) host = "127.0.0.1"; //Get port of software Console.WriteLine( "enter host port, or press enter for default ( 10429 )" ); String port_str = Console.ReadLine(); if( port_str.Length == 0 ) port_str = "10429"; int port = int.Parse( port_str ); //attempt to connect with socket. Console.WriteLine( "Connecting..." ); try { Client = new SaleaeClient( host, port ); } catch( Exception ex ) { Console.WriteLine( "Error while connecting: " + ex.Message ); Console.ReadLine(); return; } StringHelper.WriteLine( "Connected" ); Console.WriteLine( "" ); //Get a list of connected devices. (when no devices are connected, this should return 4 simulation devices) var devices = Client.GetConnectedDevices(); var active_device = devices.Single( x => x.IsActive == true ); Console.WriteLine( "currently availible devices:" ); devices.ToList().ForEach( x => Console.WriteLine( x.Name ) ); Console.WriteLine( "currently active device: " + active_device.Name ); Console.WriteLine( "" ); Console.WriteLine( "Press Enter to Continue" ); Console.ReadLine(); //list all analyzers currently added to the session. var analyzers = Client.GetAnalyzers(); if( analyzers.Any() ) { Console.WriteLine( "Current analyzers:" ); analyzers.ToList().ForEach( x => Console.WriteLine( x.AnalyzerType ) ); Console.WriteLine( "" ); Console.WriteLine( "Press Enter to Continue" ); Console.ReadLine(); } //change the active channels, but only if the active device supports that. if( active_device.DeviceType == DeviceType.Logic8 || active_device.DeviceType == DeviceType.LogicPro8 || active_device.DeviceType == DeviceType.LogicPro16 ) { Console.WriteLine( "changing active channels" ); Client.SetActiveChannels( new int[] { 2, 5, 6, 7 }, new int[] { 0, 1 } ); Console.WriteLine( "" ); Console.WriteLine( "Press Enter to Continue" ); Console.ReadLine(); //display the currently selected sample rate and performance option. var current_sample_rate = Client.GetSampleRate(); Console.WriteLine( "The previously selected sample rate was: " + current_sample_rate.DigitalSampleRate.ToString() + " SPS (digital), " + current_sample_rate.AnalogSampleRate.ToString() + " SPS (analog)" ); if( current_sample_rate.AnalogSampleRate > 0 && current_sample_rate.DigitalSampleRate > 0 ) { PerformanceOption current_performance_option = Client.GetPerformanceOption(); Console.WriteLine( "Currently selected performance option: " + current_performance_option.ToString() ); } //change the sample rate! var possible_sample_rates = Client.GetAvailableSampleRates(); if( possible_sample_rates.Any( x => x.AnalogSampleRate == 125000 ) ) { Console.WriteLine( "Changing sample rate" ); Client.SetSampleRate( possible_sample_rates.First( x => x.AnalogSampleRate == 125000 ) ); Console.WriteLine( "" ); Console.WriteLine( "Press Enter to Continue" ); Console.ReadLine(); } //set trigger. There are 4 digital channels. all need to be specified. Console.WriteLine( "setting trigger" ); Client.SetTrigger( new Trigger[] { Trigger.None, Trigger.PositivePulse, Trigger.Low, Trigger.High }, 1E-6, 5E-3 ); Console.WriteLine( "" ); Console.WriteLine( "Press Enter to Continue" ); Console.ReadLine(); } else { Console.WriteLine( "to see more cool features demoed by this example, please switch to a Logic 8, Logic Pro 8, or Logic Pro 16. Physical or simulation" ); } if( active_device.DeviceType == DeviceType.LogicPro8 || active_device.DeviceType == DeviceType.LogicPro16 || active_device.DeviceType == DeviceType.Logic16 ) { DigitalVoltageOption voltage_option = Client.GetDigitalVoltageOptions().SingleOrDefault( x => x.IsSelected == true ); if( voltage_option != null ) Console.WriteLine( "Currently selected voltage option: " + voltage_option.Description ); } //change the recording length to 250 ms. Console.WriteLine( "setting capture time" ); Client.SetCaptureSeconds( 0.25 ); Console.WriteLine( "" ); Console.WriteLine( "Press Enter to Continue" ); Console.ReadLine(); //start a capture. Console.WriteLine( "starting capture" ); Client.Capture(); Console.WriteLine( "" ); Console.WriteLine( "Press Enter to Exit" ); Console.ReadLine(); }
private static void RunProgram() { SaleaeClient client; var sampleRate = 10000000; //Set this variable to have all text socket commands printed to the console. SaleaeClient.PrintCommandsToConsole = false; //Make sure to enable the socket server in the Logic software preferences, and make sure that it is running! //This demo is designed to show some common socket commands, and interacts best with either the simulation or real Logic 8, Logic Pro 8, or Logic Pro 16. var host = "127.0.0.1"; var port = 10429; //attempt to connect with socket. Console.WriteLine("Connecting..."); try { client = new SaleaeClient(host, port); } catch (Exception ex) { Console.WriteLine("Error while connecting: " + ex.Message); Console.ReadLine(); return; } StringHelper.WriteLine("Connected"); Console.WriteLine(""); //Get a list of connected devices. (when no devices are connected, this should return 4 simulation devices) var devices = client.GetConnectedDevices(); var activeDevice = devices.Single(x => x.IsActive); Console.WriteLine("currently available devices:"); devices.ToList().ForEach(x => Console.WriteLine(x.Name)); Console.WriteLine("currently active device: " + activeDevice.Name); Console.WriteLine(""); //list all analyzers currently added to the session. var analyzers = client.GetAnalyzers(); if (analyzers.Any()) { Console.WriteLine("Current analyzers:"); analyzers.ToList().ForEach(x => Console.WriteLine(x.AnalyzerType)); Console.WriteLine(""); } //change the active channels, but only if the active device supports that. if (activeDevice.DeviceType != DeviceType.Logic8 && activeDevice.DeviceType != DeviceType.LogicPro8 && activeDevice.DeviceType != DeviceType.LogicPro16) { Console.WriteLine("No supported device connected. Press any key to exit"); Console.ReadLine(); return; } Console.Write("Enter number of channels to log: "); var numChannels = Console.ReadLine(); if (int.TryParse(numChannels, out var iNumChannels) && iNumChannels <= 8) { var channelsToActivate = new int[iNumChannels]; for (var i = 0; i < channelsToActivate.Length; i++) { channelsToActivate[i] = i; } Console.WriteLine($"Activating channels {string.Join(" ", channelsToActivate)}"); client.SetActiveChannels(channelsToActivate); Console.WriteLine(""); } else { Console.WriteLine("Invalid entry, only using channel 0"); client.SetActiveChannels(new[] { 0 }); Console.WriteLine(""); } //showing active channels var activeDigitalChannels = new List <int>(); var activeAnalogChannels = new List <int>(); client.GetActiveChannels(activeDigitalChannels, activeAnalogChannels); Console.WriteLine("Active Digital Channels: " + string.Join(", ", activeDigitalChannels.ToArray())); Console.WriteLine("Active Analog Channels: " + string.Join(", ", activeAnalogChannels.ToArray())); //display the currently selected sample rate and performance option. var currentSampleRate = client.GetSampleRate(); Console.WriteLine("The previously selected sample rate was: " + currentSampleRate.DigitalSampleRate + " SPS (digital), " + currentSampleRate.AnalogSampleRate + " SPS (analog)"); if (currentSampleRate.AnalogSampleRate > 0 && currentSampleRate.DigitalSampleRate > 0) { var currentPerformanceOption = client.GetPerformanceOption(); Console.WriteLine("Currently selected performance option: " + currentPerformanceOption); } //change the sample rate! var possibleSampleRates = client.GetAvailableSampleRates(); if (possibleSampleRates.Any(x => x.DigitalSampleRate == sampleRate)) { Console.WriteLine($"Changing digital sample rate to {sampleRate}"); client.SetSampleRate(possibleSampleRates.First(x => x.DigitalSampleRate == sampleRate)); Console.WriteLine(""); } else { Console.WriteLine("Selected sample rate not available, exiting"); return; } //set trigger. There are 4 digital channels. all need to be specified. Console.WriteLine("Setting trigger to CH0 falling edge"); var triggers = new Trigger[activeDigitalChannels.Count]; for (var i = 0; i < triggers.Length; i++) { triggers[i] = Trigger.None; } triggers[0] = Trigger.FallingEdge; client.SetTrigger(triggers); Console.WriteLine(""); if (activeDevice.DeviceType == DeviceType.LogicPro8 || activeDevice.DeviceType == DeviceType.LogicPro16 || activeDevice.DeviceType == DeviceType.Logic16) { var voltageOption = client.GetDigitalVoltageOptions().SingleOrDefault(x => x.IsSelected); if (voltageOption != null) { Console.WriteLine("Currently selected voltage option: " + voltageOption.Description); } } // get the recording time Console.WriteLine(""); Console.Write("Enter the capture time in seconds. Equal to the power cycle time: "); var captureTimeString = Console.ReadLine(); if (!double.TryParse(captureTimeString, out var captureTimeSec)) { captureTimeSec = 3; Console.WriteLine("Invalid entry"); } Console.WriteLine($"Setting capture time to {captureTimeSec}"); client.SetCaptureSeconds(captureTimeSec); Console.WriteLine(""); var fileNameIds = new string[activeDigitalChannels.Count]; var fileDirectories = new string[activeDigitalChannels.Count]; for (var i = 0; i < activeDigitalChannels.Count; i++) { var activeDigitalChannel = activeDigitalChannels[i]; var defaultFileName = $"CH{activeDigitalChannel}_output"; Console.Write( $"Enter file name identifier for channel {activeDigitalChannel} or Enter for default [{defaultFileName}]: "); var fileNameId = Console.ReadLine(); if (fileNameId == string.Empty) { fileNameId = defaultFileName; } fileNameIds[i] = fileNameId; var directoryName = $"{Directory.GetCurrentDirectory()}\\{fileNameId}_{DateTime.Now:yyyy-MM-dd}"; if (!Directory.Exists(directoryName)) { Directory.CreateDirectory(directoryName); } fileDirectories[i] = directoryName; } Console.Write("Press Enter to Begin Capture"); Console.ReadLine(); Console.WriteLine("Press ESC to stop"); var captureCounter = 1; do { while (!Console.KeyAvailable) { Console.WriteLine($"Starting capture #{captureCounter}"); client.Capture(); // once capture is complete, save the data to file for (var i = 0; i < analyzers.Count; i++) { if (fileNameIds.Length <= i) { continue; } var filePath = $"{fileDirectories[i]}\\{fileNameIds[i]}_{DateTime.Now:yyyy-MM-dd_HH-mm-ss}.csv"; client.ExportAnalyzers(analyzers[i].Index, filePath, false); Console.WriteLine($"Exported {analyzers[i].AnalyzerType} analyzer #{analyzers[i].Index} data capture #{captureCounter} to {filePath}"); } captureCounter++; } } while (Console.ReadKey(true).Key != ConsoleKey.Escape); Console.WriteLine(); Console.WriteLine("Recording complete, press any key to exit"); Console.ReadLine(); }
public void Run() { // Data saved to filenames String s_salted_filename, s_complete_filename; // Just a subdirectory off the root String s_dest_directory = "c:/traces/"; // Used in creation of "salted" filename, prevents name clashing UInt32 i_Seq = 0; DateTime dt_current; // Simple Performance Measurements TimeSpan ts_temp0, ts_temp1; //Set this variable to have all text socket commands printed to the console. SaleaeClient.PrintCommandsToConsole = false; //Make sure to enable the socket server in the Logic software preferences, and make sure that it is running! //This demo is designed to show some common socket commands, and interacts best with either the simulation or real Logic 8, Logic Pro 8, or Logic Pro 16. //lets run a quick demo! Console.WriteLine("Logic Socket API demonstation application.\n"); Console.WriteLine("enter host IP address, or press enter for localhost"); String host = Console.ReadLine(); if (host.Length == 0) host = "127.0.0.1"; Console.WriteLine("enter host port, or press enter for default ( 10429 )"); String port_str = Console.ReadLine(); if (port_str.Length == 0) port_str = "10429"; int port = int.Parse(port_str); Console.WriteLine("Connecting..."); try { Client = new SaleaeClient(host, port); } catch (Exception ex) { Console.WriteLine("Error while connecting: " + ex.Message); Console.ReadLine(); System.Environment.Exit(3); } StringHelper.WriteLine("Connected"); Console.WriteLine(""); Console.WriteLine("enter full directory path, or press enter for " + s_dest_directory); { // Gather User Directory Choice String lcl_dest = Console.ReadLine(); if (lcl_dest.Length > 0) { s_dest_directory = lcl_dest; } } if (host.Equals("127.0.0.1")) { // logic to test and make directory on local machine if (!Directory.Exists(s_dest_directory)) { Console.WriteLine("Directory " + s_dest_directory + " does not exist, attempting to make it."); Directory.CreateDirectory(s_dest_directory); if (!Directory.Exists(s_dest_directory)) { Console.WriteLine("Could not create " + s_dest_directory + ", giving up."); System.Environment.Exit(3); } } } else { // Warn User about remote machine Console.WriteLine("Make sure the directory " + s_dest_directory + " exists on target machine."); } var devices = Client.GetConnectedDevices(); var active_device = devices.Single(x => x.IsActive == true); Console.WriteLine("currently availible devices:"); devices.ToList().ForEach(x => Console.WriteLine(x.Name)); Console.WriteLine("currently active device: " + active_device.Name); Console.WriteLine(""); #if DEMO_SETTING Console.WriteLine("Press Enter to Continue"); Console.ReadLine(); #endif // Get hardware list var analyzers = Client.GetAnalyzers(); if (analyzers.Any()) { Console.WriteLine("Current analyzers:"); analyzers.ToList().ForEach(x => Console.WriteLine(x.AnalyzerType)); Console.WriteLine(""); #if DEMO_SETTING Console.WriteLine("Press Enter to Start Capture"); Console.ReadLine(); #endif } // This code sets the Saleae configurations // I prefer to set my own.. #if DEMO_SETTING if (active_device.DeviceType == DeviceType.Logic8 || active_device.DeviceType == DeviceType.LogicPro8 || active_device.DeviceType == DeviceType.LogicPro16) { Console.WriteLine("changing active channels"); //Client.SetActiveChannels( new int[] { 2, 5, 6, 7 }, new int[] { 0, 1 } ); Client.SetActiveChannels(new int[] { 0, 1 }, new int[] { }); Console.WriteLine(""); Console.WriteLine("Press Enter to Continue"); Console.ReadLine(); var possible_sample_rates = Client.GetAvailableSampleRates(); /*if( possible_sample_rates.Any( x => x.AnalogSampleRate == 125000 ) ) { Console.WriteLine( "Changing sample rate" ); Client.SetSampleRate( possible_sample_rates.First( x => x.AnalogSampleRate == 125000 ) ); Console.WriteLine( "" ); Console.WriteLine( "Press Enter to Continue" ); Console.ReadLine(); } */ // set digital sample rate to 2500000 if (possible_sample_rates.Any(x => x.DigitalSampleRate == 2500000)) { Console.WriteLine("Changing sample rate"); Client.SetSampleRate(possible_sample_rates.First(x => x.DigitalSampleRate == 2500000)); Console.WriteLine(""); Console.WriteLine("Press Enter to Continue"); Console.ReadLine(); } //set trigger. There are 4 digital channels. all need to be specified. Console.WriteLine("setting trigger"); //Client.SetTrigger(new Trigger[] { Trigger.None, Trigger.PositivePulse, Trigger.Low, Trigger.High }, 1E-6, 5E-3); Client.SetTrigger(new Trigger[] { Trigger.None, Trigger.FallingEdge }); Console.WriteLine(""); Console.WriteLine("Press Enter to Continue"); Console.ReadLine(); } else { Console.WriteLine("to see more cool features demoed by this example, please switch to a Logic 8, Logic Pro 8, or Logic Pro 16. Physical or simulation"); } Console.WriteLine("setting capture time"); Client.SetCaptureSeconds(0.25); Console.WriteLine(""); Console.WriteLine("Press Enter to Continue"); Console.ReadLine(); Console.WriteLine("starting capture"); //Client.Capture(); //Console.WriteLine( "" ); //Console.WriteLine( "Press Enter to Exit" ); //Console.ReadLine(); #endif // New Stuff Console.WriteLine("Capture starting"); // Filename sequence number i_Seq = 0; while (true) { // loop here forever (or canceled from Saleae) try { // a little more elegant exit Client.Capture(); } catch (Saleae.SocketApi.SaleaeSocketApiException) { // calling this a normal exit for now.. Console.WriteLine("End of Session"); System.Environment.Exit(1); } dt_current = DateTime.Now; Console.WriteLine("Captured, Processing Started"); // Build a file name of year_JulianDay_time_sequenceNumber // That funny parce statement sets the Julian Day count to start on January first of the current year. s_salted_filename = dt_current.ToString("yyyy") + "_" + // Year JulianDate(new DateTime(Int32.Parse(dt_current.ToString("yyyy")), 1, 1)).ToString() + "_" + // Days since January first dt_current.ToString("HHmmss") + //hours minutes seconds - 24 hour local time "_sq_" + i_Seq.ToString(); // sequence number to prevent a potential name conflict // Yep this could be combined to save a variable, but s_salted_filename is already too complex s_complete_filename = s_dest_directory + s_salted_filename + ".logicdata"; // Test for done Processing while (!Client.IsProcessingComplete()) { // Only check 4 times a second System.Threading.Thread.Sleep(250); // Let them know it hasn't gotten stuck Console.Write("."); } // Calculate and display elapsed time ts_temp0 = DateTime.Now.Subtract(dt_current); Console.WriteLine(""); Console.WriteLine("Saleae Processing took " + ts_temp0.ToString("c")); // show destination Console.WriteLine("Writing File " + s_complete_filename); // tell Saleae to write the file out Client.SaveToFile(s_complete_filename); // tell Saleae to close the tabs Client.CloseAllTabs(); // Calculate and display elapsed time ts_temp1 = DateTime.Now.Subtract(dt_current); Console.WriteLine("Total Processing and File Save took " + ts_temp1.ToString("c")); // bump the sequence i_Seq++; } }
public void Run() { //Set this variable to have all text socket commands printed to the console. SaleaeClient.PrintCommandsToConsole = true; //Make sure to enable the socket server in the Logic software preferences, and make sure that it is running! //This demo is designed to show some common socket commands, and interacts best with either the simulation or real Logic 8, Logic Pro 8, or Logic Pro 16. //lets run a quick demo! Console.WriteLine( "Logic Socket API demonstation application.\n" ); Console.WriteLine( "enter host IP address, or press enter for localhost" ); String host = Console.ReadLine(); if( host.Length == 0 ) host = "127.0.0.1"; Console.WriteLine( "enter host port, or press enter for default ( 10429 )" ); String port_str = Console.ReadLine(); if( port_str.Length == 0 ) port_str = "10429"; int port = int.Parse( port_str ); Console.WriteLine( "Connecting..." ); try { Client = new SaleaeClient( host, port ); } catch( Exception ex ) { Console.WriteLine( "Error while connecting: " + ex.Message ); Console.ReadLine(); return; } StringHelper.WriteLine( "Connected" ); Console.WriteLine( "" ); var devices = Client.GetConnectedDevices(); var active_device = devices.Single( x => x.IsActive == true ); Console.WriteLine( "currently availible devices:" ); devices.ToList().ForEach( x => Console.WriteLine( x.Name ) ); Console.WriteLine( "currently active device: " + active_device.Name ); Console.WriteLine( "" ); Console.WriteLine( "Press Enter to Continue" ); Console.ReadLine(); var analyzers = Client.GetAnalyzers(); if( analyzers.Any() ) { Console.WriteLine( "Current analyzers:" ); analyzers.ToList().ForEach( x => Console.WriteLine( x.AnalyzerType ) ); Console.WriteLine( "" ); Console.WriteLine( "Press Enter to Continue" ); Console.ReadLine(); } if( active_device.DeviceType == DeviceType.Logic8 || active_device.DeviceType == DeviceType.LogicPro8 || active_device.DeviceType == DeviceType.LogicPro16 ) { Console.WriteLine( "changing active channels" ); Client.SetActiveChannels( new int[] { 2, 5, 6, 7 }, new int[] { 0, 1 } ); Console.WriteLine( "" ); Console.WriteLine( "Press Enter to Continue" ); Console.ReadLine(); var possible_sample_rates = Client.GetAvailableSampleRates(); if( possible_sample_rates.Any( x => x.AnalogSampleRate == 125000 ) ) { Console.WriteLine( "Changing sample rate" ); Client.SetSampleRate( possible_sample_rates.First( x => x.AnalogSampleRate == 125000 ) ); Console.WriteLine( "" ); Console.WriteLine( "Press Enter to Continue" ); Console.ReadLine(); } //set trigger. There are 4 digital channels. all need to be specified. Console.WriteLine( "setting trigger" ); Client.SetTrigger( new Trigger[] { Trigger.None, Trigger.PositivePulse, Trigger.Low, Trigger.High }, 1E-6, 5E-3 ); Console.WriteLine( "" ); Console.WriteLine( "Press Enter to Continue" ); Console.ReadLine(); } else { Console.WriteLine( "to see more cool features demoed by this example, please switch to a Logic 8, Logic Pro 8, or Logic Pro 16. Physical or simulation" ); } Console.WriteLine( "setting capture time" ); Client.SetCaptureSeconds( 0.25 ); Console.WriteLine( "" ); Console.WriteLine( "Press Enter to Continue" ); Console.ReadLine(); Console.WriteLine( "starting capture" ); Client.Capture(); Console.WriteLine( "" ); Console.WriteLine( "Press Enter to Exit" ); Console.ReadLine(); }
public void Run() { // Data saved to filenames String s_salted_filename, s_complete_filename; // Just a subdirectory off the root String s_dest_directory = "c:/traces/"; // Used in creation of "salted" filename, prevents name clashing UInt32 i_Seq = 0; DateTime dt_current; // Simple Performance Measurements TimeSpan ts_temp0, ts_temp1; //Set this variable to have all text socket commands printed to the console. SaleaeClient.PrintCommandsToConsole = false; //Make sure to enable the socket server in the Logic software preferences, and make sure that it is running! //This demo is designed to show some common socket commands, and interacts best with either the simulation or real Logic 8, Logic Pro 8, or Logic Pro 16. //lets run a quick demo! Console.WriteLine("Logic Socket API demonstation application.\n"); Console.WriteLine("enter host IP address, or press enter for localhost"); String host = Console.ReadLine(); if (host.Length == 0) { host = "127.0.0.1"; } Console.WriteLine("enter host port, or press enter for default ( 10429 )"); String port_str = Console.ReadLine(); if (port_str.Length == 0) { port_str = "10429"; } int port = int.Parse(port_str); Console.WriteLine("Connecting..."); try { Client = new SaleaeClient(host, port); } catch (Exception ex) { Console.WriteLine("Error while connecting: " + ex.Message); Console.ReadLine(); System.Environment.Exit(3); } StringHelper.WriteLine("Connected"); Console.WriteLine(""); Console.WriteLine("enter full directory path, or press enter for " + s_dest_directory); { // Gather User Directory Choice String lcl_dest = Console.ReadLine(); if (lcl_dest.Length > 0) { s_dest_directory = lcl_dest; } } if (host.Equals("127.0.0.1")) { // logic to test and make directory on local machine if (!Directory.Exists(s_dest_directory)) { Console.WriteLine("Directory " + s_dest_directory + " does not exist, attempting to make it."); Directory.CreateDirectory(s_dest_directory); if (!Directory.Exists(s_dest_directory)) { Console.WriteLine("Could not create " + s_dest_directory + ", giving up."); System.Environment.Exit(3); } } } else { // Warn User about remote machine Console.WriteLine("Make sure the directory " + s_dest_directory + " exists on target machine."); } var devices = Client.GetConnectedDevices(); var active_device = devices.Single(x => x.IsActive == true); Console.WriteLine("currently availible devices:"); devices.ToList().ForEach(x => Console.WriteLine(x.Name)); Console.WriteLine("currently active device: " + active_device.Name); Console.WriteLine(""); #if DEMO_SETTING Console.WriteLine("Press Enter to Continue"); Console.ReadLine(); #endif // Get hardware list var analyzers = Client.GetAnalyzers(); if (analyzers.Any()) { Console.WriteLine("Current analyzers:"); analyzers.ToList().ForEach(x => Console.WriteLine(x.AnalyzerType)); Console.WriteLine(""); #if DEMO_SETTING Console.WriteLine("Press Enter to Start Capture"); Console.ReadLine(); #endif } // This code sets the Saleae configurations // I prefer to set my own.. #if DEMO_SETTING if (active_device.DeviceType == DeviceType.Logic8 || active_device.DeviceType == DeviceType.LogicPro8 || active_device.DeviceType == DeviceType.LogicPro16) { Console.WriteLine("changing active channels"); //Client.SetActiveChannels( new int[] { 2, 5, 6, 7 }, new int[] { 0, 1 } ); Client.SetActiveChannels(new int[] { 0, 1 }, new int[] { }); Console.WriteLine(""); Console.WriteLine("Press Enter to Continue"); Console.ReadLine(); var possible_sample_rates = Client.GetAvailableSampleRates(); /*if( possible_sample_rates.Any( x => x.AnalogSampleRate == 125000 ) ) * { * Console.WriteLine( "Changing sample rate" ); * Client.SetSampleRate( possible_sample_rates.First( x => x.AnalogSampleRate == 125000 ) ); * Console.WriteLine( "" ); * Console.WriteLine( "Press Enter to Continue" ); * Console.ReadLine(); * } */ // set digital sample rate to 2500000 if (possible_sample_rates.Any(x => x.DigitalSampleRate == 2500000)) { Console.WriteLine("Changing sample rate"); Client.SetSampleRate(possible_sample_rates.First(x => x.DigitalSampleRate == 2500000)); Console.WriteLine(""); Console.WriteLine("Press Enter to Continue"); Console.ReadLine(); } //set trigger. There are 4 digital channels. all need to be specified. Console.WriteLine("setting trigger"); //Client.SetTrigger(new Trigger[] { Trigger.None, Trigger.PositivePulse, Trigger.Low, Trigger.High }, 1E-6, 5E-3); Client.SetTrigger(new Trigger[] { Trigger.None, Trigger.FallingEdge }); Console.WriteLine(""); Console.WriteLine("Press Enter to Continue"); Console.ReadLine(); } else { Console.WriteLine("to see more cool features demoed by this example, please switch to a Logic 8, Logic Pro 8, or Logic Pro 16. Physical or simulation"); } Console.WriteLine("setting capture time"); Client.SetCaptureSeconds(0.25); Console.WriteLine(""); Console.WriteLine("Press Enter to Continue"); Console.ReadLine(); Console.WriteLine("starting capture"); //Client.Capture(); //Console.WriteLine( "" ); //Console.WriteLine( "Press Enter to Exit" ); //Console.ReadLine(); #endif // New Stuff Console.WriteLine("Capture starting"); // Filename sequence number i_Seq = 0; while (true) { // loop here forever (or canceled from Saleae) try { // a little more elegant exit Client.Capture(); } catch (Saleae.SocketApi.SaleaeSocketApiException) { // calling this a normal exit for now.. Console.WriteLine("End of Session"); System.Environment.Exit(1); } dt_current = DateTime.Now; Console.WriteLine("Captured, Processing Started"); // Build a file name of year_JulianDay_time_sequenceNumber // That funny parce statement sets the Julian Day count to start on January first of the current year. s_salted_filename = dt_current.ToString("yyyy") + "_" + // Year JulianDate(new DateTime(Int32.Parse(dt_current.ToString("yyyy")), 1, 1)).ToString() + "_" + // Days since January first dt_current.ToString("HHmmss") + //hours minutes seconds - 24 hour local time "_sq_" + i_Seq.ToString(); // sequence number to prevent a potential name conflict // Yep this could be combined to save a variable, but s_salted_filename is already too complex s_complete_filename = s_dest_directory + s_salted_filename + ".logicdata"; // Test for done Processing while (!Client.IsProcessingComplete()) { // Only check 4 times a second System.Threading.Thread.Sleep(250); // Let them know it hasn't gotten stuck Console.Write("."); } // Calculate and display elapsed time ts_temp0 = DateTime.Now.Subtract(dt_current); Console.WriteLine(""); Console.WriteLine("Saleae Processing took " + ts_temp0.ToString("c")); // show destination Console.WriteLine("Writing File " + s_complete_filename); // tell Saleae to write the file out Client.SaveToFile(s_complete_filename); // tell Saleae to close the tabs Client.CloseAllTabs(); // Calculate and display elapsed time ts_temp1 = DateTime.Now.Subtract(dt_current); Console.WriteLine("Total Processing and File Save took " + ts_temp1.ToString("c")); // bump the sequence i_Seq++; } }