### Python Environment Setup and Library Installation Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/md__markdown_files_2_setup_python Instructions for setting up a Python environment (version 3.9-3.12) and installing the SquidstatPyLibrary. Includes steps for creating and activating virtual environments and installing the library using pip. ```bash python -V ``` ```bash python -m venv VIRTUAL_ENVIRONMENT_NAME ``` ```bash ./VIRTUAL_ENVIRONMENT_NAME/Scripts/activate.bat ``` ```bash pip install YOUR_DOWNLOADED_FILE.whl ``` ```bash python Experiment.py ``` -------------------------------- ### Basic Experiment Example in C++ Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/dir_f0e47f523bc80d821dbfad6dd2752356 Demonstrates how to set up and run a basic experiment using the Squidstat API in C++. This example covers fundamental experiment setup and execution. ```cpp /* * Basic Experiment * This example demonstrates how to set up and run a basic experiment. */ #include #include "SquidStat.h" int main() { // Initialize the SquidStat API SquidStatAPI api; // Connect to the device (assuming it's available on the default port) if (!api.connect()) { std::cerr << "Error connecting to SquidStat device." << std::endl; return 1; } // Define experiment parameters (simplified for brevity) ExperimentSettings settings; settings.potentialType = POTENTIAL_TYPE_LINEAR; settings.potentialStart = 0.0; // Volts settings.potentialEnd = 0.1; // Volts settings.stepDuration = 0.01; // Seconds // Create and run the experiment Experiment experiment(settings); if (experiment.run(api)) { std::cout << "Experiment completed successfully." << std::endl; // You can retrieve results here if needed // auto results = experiment.getResults(); } else { std::cerr << "Error running experiment." << std::endl; } // Disconnect from the device api.disconnect(); return 0; } ``` -------------------------------- ### C++ Example: Basic Experiment Setup and Signal Handling Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/basic_experiment_8cpp-example This C++ example demonstrates how to initialize the Squidstat API, set up a basic constant potential experiment, connect to a device, and handle various signals emitted by the instrument handler. It includes examples for active DC and AC data, experiment status updates, and error reporting. ```cpp #include "AisDeviceTracker.h" #include "AisExperiment.h" #include "AisInstrumentHandler.h" #include "experiments/builder_elements/AisConstantPotElement.h" #include #include // Define relevant device information, for easy access #define COMPORT "COM1" #define CHANNEL 0 int main() { char** test = nullptr; int args; QCoreApplication a(args, test); auto tracker = AisDeviceTracker::Instance(); // Voltage = 1V, Sampling Interval = 1s, Duration = 30s AisConstantPotElement cvElement(1, 1, 30); auto customExperiment = std::make_shared(); // Append the constant potential element, and tell it to execute that element 1 time customExperiment->appendElement(cvElement, 1); auto connectSignals = [=](const AisInstrumentHandler& handler) { QObject::connect(&handler, &AisInstrumentHandler::activeDCDataReady, [=](uint8_t channel, const AisDCData& data) { qDebug() << "Timestamp: " << data.timestamp << " Current: " << data.current << " Voltage: " << data.workingElectrodeVoltage << " CE Voltage : " << data.counterElectrodeVoltage; }); QObject::connect(&handler, &AisInstrumentHandler::activeACDataReady, [=](uint8_t channel, const AisACData& data) { qDebug() << "Timestamp: " << data.timestamp << " Frequency: " << data.frequency << "" << data.absoluteImpedance; }); // Whenever a new node in the element starts, note: some Ais Elements contain multiple logical nodes // i.e AisCyclicVoltammatryElement contains 4 nodes for each linear segment of each cycle plus a quiet time node if enabled // So this lambda would be executed atleast 4 times for each cycle QObject::connect(&handler, &AisInstrumentHandler::experimentNewElementStarting, [=](uint8_t channel, const AisExperimentNode& info) { qDebug() << "New element starting: " << info.stepName; }); // Whenever an experiment completes or is manually stopped, this will execute QObject::connect(&handler, &AisInstrumentHandler::experimentStopped, [=](uint8_t channel, const QString& reason) { qDebug() << "Experiment Stopped Signal " << channel << "Reason : " << reason; }); QObject::connect(&handler, &AisInstrumentHandler::deviceError, [=](uint8_t channel, const QString& error) { qDebug() << "Device Error: " << error; }); }; QObject::connect(tracker, &AisDeviceTracker::deviceDisconnected, [=](const QString& deviceName) { qDebug() << "New Device Connected: " << deviceName; }); QObject::connect(tracker, &AisDeviceTracker::newDeviceConnected, [=](const QString& deviceName) { qDebug() << "New Device Connected: " << deviceName; auto& handler = tracker->getInstrumentHandler(deviceName); connectSignals(handler); AisErrorCode error = handler.uploadExperimentToChannel(CHANNEL, customExperiment); if (error) { qDebug() << error.message(); return; } // Start the previously uploaded experiment on the same channel error = handler.startUploadedExperiment(CHANNEL); // Exit the application if there is any error starting the experiment if (error) { qDebug() << error.message(); return; } }); AisErrorCode error = tracker->connectToDeviceOnComPort(COMPORT); if (error != error.Success) { qDebug() << error.message(); return 0; } return a.exec(); } ``` -------------------------------- ### Squidstat API - Basic Experiment Example (C++) Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/dir_d44c64559bbebec7f509842c48db8b23 Demonstrates a basic experiment setup using the Squidstat C++ API. This example covers essential steps for configuring and running a simple experiment. ```cpp #include #include int main() { AisInstrumentHandler handler("COM3"); // Replace with your COM port handler.Connect(); AisExperiment experiment; experiment.SetDuration(10.0); experiment.SetSamplingInterval(0.01); handler.RunExperiment(experiment); handler.Disconnect(); return 0; } ``` -------------------------------- ### C++ Basic Experiment Example - Admiral Instruments SquidStat API Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/class_ais_square_wave_voltammetry_element-members Demonstrates a basic experiment setup using the C++ client library for the SquidStat API. This example is suitable for users starting with the API and covers fundamental experiment configuration. ```cpp // Placeholder for C++ Basic Experiment Example Code ``` -------------------------------- ### Python Basic Experiment Code Example Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/struct_ais_a_c_data-members Demonstrates a basic experiment setup using the Squidstat API in Python. This example serves as a starting point for Python users. ```python # Placeholder for Python Basic Experiment code example # This section would contain actual Python code for running a basic experiment. ``` -------------------------------- ### Python Basic Experiment Example - Admiral Instruments SquidStat API Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/class_ais_square_wave_voltammetry_element-members Demonstrates a basic experiment setup using the Python client library for the SquidStat API. This example is suitable for users starting with the API and covers fundamental experiment configuration. ```python # Placeholder for Python Basic Experiment Example Code ``` -------------------------------- ### C++ Basic Experiment Example with Squidstat API Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/advanced_experiment_8cpp-example This C++ code demonstrates how to build and run a basic experiment using the Squidstat API. It includes setting up device tracking, creating experiment elements, uploading, and starting the experiment. Dependencies include QtCoreApplication and AisDeviceTracker. ```C++ #include "AisDeviceTracker.h" #include "AisExperiment.h" #include "AisInstrumentHandler.h" #include "experiments/builder_elements/AisOpenCircuitElement.h" #include "experiments/builder_elements/AisConstantPotElement.h" #include "experiments/builder_elements/AisEISGalvanostaticElement.h" #include "experiments/builder_elements/AisConstantCurrentElement.h" #include #include // Define relevant device information, for easy access #define COMPORT "COM5" #define CHANNEL 0 #define INSTRUMENT_NAME "PLus1366" int main() { char** test = nullptr; int args; QCoreApplication a(args, test); auto tracker = AisDeviceTracker::Instance(); bool success = true; auto customExperiment = std::make_shared(); // Append Open Circuit Potential element AisOpenCircuitElement ocpElement(1, 10); success &= customExperiment->appendElement(ocpElement); // Append Constant Voltage elements int voltage = 0; for (int i = 0; i < 4; i++) { AisConstantPotElement cvElement(voltage, 0.1, 5); success &= customExperiment->appendElement(cvElement, 1); voltage += 0.1; // Adding 100 mV } // Append a sub-experiment with EIS and OCP AisExperiment eisSubExperiment; AisEISGalvanostaticElement galvEISElement(10, 10000, 10, 0.01, 0.1); AisOpenCircuitElement ocpElement2(1, 5); success &= eisSubExperiment.appendElement(galvEISElement, 1); success &= eisSubExperiment.appendElement(ocpElement2, 1); success &= customExperiment->appendSubExperiment(eisSubExperiment, 3); // Append Constant Current element AisConstantCurrentElement ccElement(0.1, 1, 10); success &= customExperiment->appendElement(ccElement, 2); if (!success) { qDebug() << "Error building experiment"; return 0; } // Signal connections for handler events auto connectSignals = [=](const AisInstrumentHandler& handler) { QObject::connect(&handler, &AisInstrumentHandler::activeDCDataReady, [=](uint8_t channel, const AisDCData& data) { qDebug() << "Timestamp: " << data.timestamp << " Current: " << data.current << " Voltage: " << data.workingElectrodeVoltage << " CE Voltage : " << data.counterElectrodeVoltage; }); QObject::connect(&handler, &AisInstrumentHandler::experimentNewElementStarting, [=](uint8_t channel, const AisExperimentNode& info) { qDebug() << "New element starting: " << info.stepName; }); QObject::connect(&handler, &AisInstrumentHandler::experimentStopped, [=](uint8_t channel, const QString& reason) { qDebug() << "Experiment Stopped Signal " << channel << "Reason : " << reason; }); QObject::connect(&handler, &AisInstrumentHandler::deviceError, [=](uint8_t channel, const QString& error) { qDebug() << "Device Error: " << error; }); }; // When device is connected, setup connections, and upload/start the experiment QObject::connect(tracker, &AisDeviceTracker::newDeviceConnected, [=](const QString& deviceName) { qDebug() << "New Device Connected: " << deviceName; auto& handler = tracker->getInstrumentHandler(INSTRUMENT_NAME); connectSignals(handler); AisErrorCode error = handler.uploadExperimentToChannel(CHANNEL, customExperiment); if (error) { qDebug() << error.message(); return 0; } error = handler.startUploadedExperiment(CHANNEL); if (error) { qDebug() << error.message(); return 0; } }); // Connect to the device AisErrorCode error = tracker->connectToDeviceOnComPort(COMPORT); if (error != error.Success) { qDebug() << error.message(); return 0; } return a.exec(); } ``` -------------------------------- ### Basic Experiment Example: Python Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/dir_490869fd64042495237c9383dd3806a5 Provides a Python example for running a basic experiment with the Squidstat API. This serves as a starting point for users familiar with Python. ```python # Placeholder for Python basic experiment code ``` -------------------------------- ### C++ Basic Experiment Example Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/class_ais_staircase_potential_voltammetry_element-members Demonstrates a basic experiment setup and execution using the C++ API. This example covers essential steps for running a simple electrochemical experiment. ```C++ // C++ Basic Experiment Example // This is a placeholder for the actual code. // The Squidstat API would be used here to configure and run an experiment. ``` -------------------------------- ### Basic Experiment Example (C++) Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/class_ais_staircase_potential_voltammetry_element Demonstrates a basic experiment setup and execution using the Squidstat API in C++. ```cpp #include #include ``` -------------------------------- ### Manual Experiment Setup in Python Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/dir_f0e47f523bc80d821dbfad6dd2752356 Provides a Python example for configuring and running a manual experiment with the Squidstat API. This enables fine-grained control over experimental procedures. ```python # Manual Experiment Example import squidstat_api def main(): # Initialize the SquidStat API api = squidstat_api.SquidStatAPI() # Connect to the device if not api.connect(): print("Error connecting to SquidStat device.") return # Define manual experiment parameters settings = { "potentialType": "POTENTIAL_TYPE_STEP", "potentialStart": 0.0, # Volts "potentialEnd": 0.2, # Volts "stepDuration": 1.0, # Seconds } # Create and run the experiment experiment = squidstat_api.Experiment(settings) if experiment.run(api): print("Manual experiment completed successfully.") else: print("Error running manual experiment.") # Disconnect from the device api.disconnect() if __name__ == "__main__": main() ``` -------------------------------- ### C++ Basic Experiment Example Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/class_ais_d_c_potential_sweep_element-members Demonstrates a basic experiment setup using the AisDCPotentialSweepElement in C++. This example covers initializing the element with fundamental parameters like start and end potentials, scan rate, and sampling interval, and shows how to set these properties. ```cpp /* * Basic Experiment Example in C++ */ #include "AisDCPotentialSweepElement.h" #include "SquidStatAPI.h" int main() { // Initialize the API SquidStatAPI api; // Create a DC Potential Sweep element AisDCPotentialSweepElement dcpSweep; dcpSweep.setStartingPot(0.0); // Set starting potential to 0.0 V dcpSweep.setEndingPot(0.5); // Set ending potential to 0.5 V dcpSweep.setScanRate(0.1); // Set scan rate to 0.1 V/s dcpSweep.setSamplingInterval(0.01); // Set sampling interval to 0.01 s dcpSweep.setQuietTime(5.0); // Set quiet time to 5.0 s // Add the element to a new experiment Experiment exp; exp.addElement(dcpSweep); // You can now proceed to run the experiment or further configure it. // For example, to save the experiment: // exp.saveToFile("basic_dcp_sweep.exp"); return 0; } ``` -------------------------------- ### LabVIEW: Getting Started (Beta) Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/dir_ba4995a5c0cbe9e382604dafd8ad5757 Introduction to using the Squidstat API with LabVIEW. Note: This feature is currently in Beta. ```labview // Placeholder for LabVIEW Getting Started example // LabVIEW examples are typically visual block diagrams. // This entry signifies the availability of LabVIEW support. ``` -------------------------------- ### Python Basic Experiment Example - SquidStat API Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/class_ais_stepped_voltage_element-members Demonstrates a basic experiment setup using the Python SquidStat API. This example covers the fundamental steps required to configure and run a simple experiment, likely involving setting parameters and initiating a measurement cycle. ```python # Basic Experiment ``` -------------------------------- ### C++ Example: Basic Experiment Setup for Squidstat API Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/class_ais_cyclic_voltammetry_element-members This C++ code snippet demonstrates how to set up a basic experiment using the AisCyclicVoltammetryElement from the Squidstat API. It includes initializing the element with key parameters like voltage limits and sampling interval, and setting other optional parameters. This serves as a foundational example for users looking to programmatically control experiments. ```cpp AisCyclicVoltammetryElement basicExperiment( 0.5, // startVoltage -0.2, // firstVoltageLimit 0.8, // secondVoltageLimit -0.1, // endVoltage 0.01, // dEdt 0.001 // samplingInterval ); basicExperiment.setAlphaFactor(0.5); basicExperiment.setQuietTime(1.0); basicExperiment.setNumberOfCycles(5); basicExperiment.setAutoRange(); // Additional configuration... ``` -------------------------------- ### C++ Basic Experiment Example - SquidStat API Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/class_ais_stepped_voltage_element-members Demonstrates a basic experiment setup using the C++ SquidStat API. This example covers the fundamental steps required to configure and run a simple experiment, likely involving setting parameters and initiating a measurement cycle. ```cpp /* * Basic Experiment */ ``` -------------------------------- ### Python Basic Experiment Example Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/dir_9d526db25428f9650f429384700a1a21 Demonstrates a basic experiment setup and execution using the Squidstat API in Python. ```python # Placeholder for Python Basic Experiment code ``` -------------------------------- ### Basic Experiment Example (Python) Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/class_ais_staircase_potential_voltammetry_element Demonstrates a basic experiment setup and execution using the Squidstat API in Python. ```python # Python example code would go here, similar to C++ basic experiment ``` -------------------------------- ### Start Listening and QT Event Loop (Python) Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/tcp_server_8py-example This code starts two essential processes: a thread for handling client communication (`handle_client`) and the main Qt event loop (`app.exec()`). The termination program is also started in a separate thread to monitor for shutdown signals. ```python terminal_thread = threading.Thread(target=terminate_program) terminal_thread.start() listening_thread = threading.Thread(target=handle_client, args=(handler, client_socket)) listening_thread.start() app.exec() ``` -------------------------------- ### Python Basic Experiment with Squidstat API Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/basic_experiment_8py-example This Python script demonstrates how to set up and run a basic experiment using the Squidstat API. It includes connecting to a device, defining an experiment with a constant potential element, and handling experiment start and stop signals. Dependencies include PySide6 and SquidstatPyLibrary. ```python import sys from PySide6.QtWidgets import QApplication from SquidstatPyLibrary import AisDeviceTracker from SquidstatPyLibrary import AisExperiment, AisErrorCode from SquidstatPyLibrary import AisInstrumentHandler from SquidstatPyLibrary import AisConstantPotElement # Define relavant device information, for easy access COMPORT = "COM16" CHANNEL = 0 app = QApplication() tracker = AisDeviceTracker.Instance() cvElement = AisConstantPotElement(1, 1, 30) # After this point, the experiment is empty, so we need to add some elements to it experiment = AisExperiment() # Append the constant potential element, and tell the experiment to execute that element 1 time success = experiment.appendElement(cvElement, 1) # Check if the element was added successfully if not success: print("Error adding element to experiment") app.quit() def connectSignals(handler): handler.activeDCDataReady.connect(lambda channel, data: print(f"Timestamp: {data.timestamp} Current: {data.current} Voltage: {data.workingElectrodeVoltage} CE Voltage : {data.counterElectrodeVoltage}")) handler.activeACDataReady.connect(lambda channel, data: print(f"Timestamp: {data.timestamp} Frequency: {data.frequency} Absolute Impedance: {data.absoluteImpedance}")) # Whenever a new node in the element starts, note: some Ais Elements contain multiple logical nodes # i.e AisCyclicVoltammatryElement contains 4 nodes for each linear segment of each cycle plus a quiet time node if enabled # So this lambda would be executed atleast 4 times for each cycle handler.experimentNewElementStarting.connect(lambda channel, info: print(f"New element starting: {info.stepName}")) # Whenever an experiment completes or is manually stopped, this will execute handler.experimentStopped.connect(lambda channel, reason: (print(f"Experiment Stopped Signal {channel}, {reason}"), app.quit())) handler.deviceError.connect(lambda channel, error: print(f"Device Error: {error}")) def startExperiment(deviceName): print(f"New Device Connected: {deviceName}") handler = tracker.getInstrumentHandler(deviceName) connectSignals(handler) error = handler.uploadExperimentToChannel(CHANNEL, experiment) # Exit the application if there is any error uploading experiment if error.value() != AisErrorCode.Success: print(error.message()) app.quit() error = handler.startUploadedExperiment(CHANNEL) # Exit the application if there is any error starting experiment if error.value() != AisErrorCode.Success: print(error.message()) app.quit() tracker.newDeviceConnected.connect(startExperiment) tracker.deviceDisconnected.connect(lambda deviceName: print(f"Device Disconnected: {deviceName}")) error = tracker.connectToDeviceOnComPort(COMPORT) # Check if connection was successful if error.value() != AisErrorCode.Success: print(error.message()) sys.exit() ``` -------------------------------- ### C++ Basic Experiment Example Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/dir_9d526db25428f9650f429384700a1a21 Demonstrates a basic experiment setup and execution using the Squidstat API in C++. ```cpp // Placeholder for C++ Basic Experiment code ``` -------------------------------- ### Python: Experiment Setup Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/writein_c_s_v_8py-example This Python code initializes an experiment and defines two experiment elements: a Constant Current element and an Open Circuit element. These elements specify parameters like current, duration, and sampling time for the experiment. ```python # initialize an experiment 177experiment = AisExperiment() 178 179 # define a constant current experiment at 0.1 A, with 1 s sampling time, and a duration of 10 s 180 ccElement = AisConstantCurrentElement(0.1, 1, 10) 181 # define an open circuit experiment with a duration of 10 s and a sampling time of 2 s 182 opencircuitElement = AisOpenCircuitElement(10, 2) 183 184 # add constant current as the first element in the list 185 # element runs 1 time ``` -------------------------------- ### C++ Basic Experiment Code Example Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/struct_ais_a_c_data-members Demonstrates a basic experiment setup using the Squidstat API in C++. This code is intended for users to understand fundamental experiment execution. ```c++ // Placeholder for C++ Basic Experiment code example // This section would contain actual C++ code for running a basic experiment. ``` -------------------------------- ### Create and Upload Experiment using AisExperiment Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/writein_c_s_v_8py-example This snippet demonstrates how to create a custom experiment, add elements like constant current and open circuit, upload it to a channel, and start the experiment. It includes error handling for each step. Dependencies include AisExperiment, AisConstantCurrentElement, AisOpenCircuitElement, and AisErrorCode. ```python successfullyadd = experiment.appendElement(ccElement, 1) # add open circuit as the second and thirds elements in the list # element runs 2 times successfullyadd |= experiment.appendElement(opencircuitElement, 2) if not successfullyadd: print("Error adding element to experiment") app.quit() # upload experiment to channel 1 error = handler.uploadExperimentToChannel(0, experiment) if error.value() != AisErrorCode.Success: print(error.message()) app.quit() # start experiment on channel 1 error = handler.startUploadedExperiment(0) if error.value() != AisErrorCode.Success: print(error.message()) app.quit() ``` -------------------------------- ### Python Example: Basic Experiment Setup for Squidstat API Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/class_ais_cyclic_voltammetry_element-members This Python code snippet illustrates how to configure a cyclic voltammetry experiment using the Squidstat API. It shows the instantiation of the relevant experiment element with essential parameters such as voltage range, scan rate, and sampling interval, followed by the adjustment of additional settings like quiet time and number of cycles. This example is useful for Python users beginning with the API. ```python from matplotlib.pyplot import plot, show from squidstat import AisCyclicVoltammetryElement # Example of a basic cyclic voltammetry experiment experiment = AisCyclicVolammetryElement( startVoltage=0.5, firstVoltageLimit=-0.2, secondVoltageLimit=0.8, endVoltage=-0.1, dEdt=0.01, samplingInterval=0.001 ) experiment.setQuietTime(1.0) experiment.setNumberOfCycles(5) experiment.setAutoRange() # Additional configuration... ``` -------------------------------- ### C++ Example: Basic Experiment Setup and Signal Handling Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/manual_experiment_8cpp-example This C++ code demonstrates setting up a device tracker, connecting signals to an instrument handler, and running a manual experiment with timed mode changes. It utilizes Qt's event loop and timers for asynchronous operations. Ensure Qt Core and AisDeviceTracker/AisInstrumentHandler are included. ```C++ #include "AisDeviceTracker.h" #include "AisInstrumentHandler.h" #include #include #include // For QTimer::singleShot // Define relevant device information, for easy access #define COMPORT "COM1" #define CHANNEL 0 int main() { char** test = nullptr; int args; QCoreApplication a(args, test); auto tracker = AisDeviceTracker::Instance(); // Create a lambda function to connect signals to the handler auto connectSignals = [=](const AisInstrumentHandler& handler) { QObject::connect(&handler, &AisInstrumentHandler::activeDCDataReady, [=](uint8_t channel, const AisDCData& data) { qDebug() << "Timestamp: " << data.timestamp << " Current: " << data.current << " Voltage: " << data.workingElectrodeVoltage << " CE Voltage : " << data.counterElectrodeVoltage; }); QObject::connect(&handler, &AisInstrumentHandler::deviceError, [=](uint8_t channel, const QString& error) { qDebug() << "Device Error: " << error; }); QObject::connect(&handler, &AisInstrumentHandler::experimentStopped, [=](uint8_t channel, const QString& reason) { qDebug() << reason; qDebug() << "Experiment has ended. Closing application."; QCoreApplication::quit(); }); }; // Create a lambda function to run the experiment auto runExperiment = [=](const AisInstrumentHandler& handler) { //The default starting mode is always Open Circuit Potential qDebug() << "Starting manual mode at open circuit potential"; AisErrorCode error = handler.startManualExperiment(CHANNEL); if (error != AisErrorCode::Success) { qDebug() << error.message(); QCoreApplication::quit(); } // In this section we connect singleshot QTimers to lambda functions that call our mode changing functions. // These lambdas are called asynchronously when the QTimers expire. // 5 seconds after starting experiment, change to Constant Current at .1A QTimer::singleShot(5000, [=, &handler]() { qDebug() << "Switching to constant current at .1A"; AisErrorCode error = handler.setManualModeConstantCurrent(CHANNEL, .1); if (error != AisErrorCode::Success) { qDebug() << error.message(); } }); // 15 seconds after starting experiment, change to Constant Voltage at 1V QTimer::singleShot(15000, [=, &handler]() { qDebug() << "Switching to constant voltage at 1V"; AisErrorCode error = handler.setManualModeConstantVoltage(CHANNEL, 1); if (error != AisErrorCode::Success) { qDebug() << error.message(); } }); // 25 seconds after starting experiment, change back into Open Circuit Potential mode. QTimer::singleShot(25000, [=, &handler]() { qDebug() << "Switching to open circuit potential"; AisErrorCode error = handler.setManualModeOCP(CHANNEL); if (error != AisErrorCode::Success) { qDebug() << error.message(); } }); // Stop the experiment after 30 seconds QTimer::singleShot(30000, [=, &handler]() { qDebug() << "Stopping experiment"; if (handler.stopExperiment(CHANNEL) != AisErrorCode::Success) { qDebug() << error.message(); } }); }; QObject::connect(tracker, &AisDeviceTracker::newDeviceConnected, [=](const QString& deviceName) { qDebug() << "New Device Connected: " << deviceName; // When instrument is connected, grab the handler and setup/start the experiment ``` -------------------------------- ### Setup Environment for Squidstat API (C++, Python) Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/md__markdown_files_2_run_experiment Demonstrates the initial setup required to use the Squidstat API. This includes including necessary headers or libraries and setting up the Qt event loop for C++, or initializing QApplication and importing relevant classes for Python. It also shows how to retrieve the AisDeviceTracker instance. ```cpp #include "AisDeviceTracker.h" #include "AisExperiment.h" #include "AisInstrumentHandler.h" #include "experiments/builder_elements/AisConstantPotElement.h" #include #include // Define relevant device information, for easy access #define COMPORT "COM1" #define CHANNEL 0 int main() { char** test = nullptr; int args; QCoreApplication a(args, test); auto tracker = AisDeviceTracker::Instance(); ``` ```python import sys from PySide6.QtWidgets import QApplication from SquidstatPyLibrary import AisDeviceTracker from SquidstatPyLibrary import AisExperiment, AisErrorCode from SquidstatPyLibrary import AisInstrumentHandler from SquidstatPyLibrary import AisConstantPotElement # Define relavant device information, for easy access COMPORT = "COM16" CHANNEL = 0 app = QApplication() tracker = AisDeviceTracker.Instance() ``` -------------------------------- ### Basic Experiment Setup and Execution (Python) Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/md__markdown_files_2_run_experiment This section outlines the Python code for setting up and running a basic experiment, including importing libraries, initializing the application, building the experiment object, and connecting to the Squidstat device. ```APIDOC ## Basic Experiment Setup and Execution (Python) ### Description This example demonstrates the Python code required to set up the environment, construct an experiment, and connect to the Squidstat device. It covers the essential steps for initiating a basic experiment. ### Method N/A (Code Example) ### Endpoint N/A (Code Example) ### Parameters N/A (Code Example) ### Request Example ```python import sys from PySide6.QtWidgets import QApplication from SquidstatPyLibrary import AisDeviceTracker from SquidstatPyLibrary import AisExperiment, AisErrorCode from SquidstatPyLibrary import AisInstrumentHandler from SquidstatPyLibrary import AisConstantPotElement # Define relevant device information, for easy access COMPORT = "COM16" CHANNEL = 0 app = QApplication() tracker = AisDeviceTracker.Instance() # Voltage = 1V, Sampling Interval = 1s, Duration = 30s cvElement = AisConstantPotElement(1, 1, 30) # After this point, the experiment is empty, so we need to add some elements to it experiment = AisExperiment() # Append the constant potential element, and tell the experiment to execute that element 1 time success = experiment.appendElement(cvElement, 1) # Check if the element was added successfully if not success: print("Error adding element to experiment") app.quit() error = tracker.connectToDeviceOnComPort(COMPORT) # Check if connection was successful if error.value() != AisErrorCode.Success: print(error.message()) sys.exit() ``` ### Response #### Success Response (N/A) N/A #### Response Example N/A ``` -------------------------------- ### C++ AisSteppedVoltageElement Get Start Voltage Method Example - SquidStat API Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/class_ais_stepped_voltage_element-members Illustrates the getStartVoltage() method for the AisSteppedVoltageElement class in C++. This method returns the initial voltage of the stepped voltage sequence. ```cpp getStartVoltage() const ``` -------------------------------- ### Build Project with CMake Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/md__markdown_files_2_setup Compiles all examples present in the SquidstatLibrary directory using the generated build files. ```bash cmake --build ./build ``` -------------------------------- ### Get Start Voltage Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/class_ais_square_wave_voltammetry_element Retrieves the value of the starting voltage in volts. This is the initial potential at which the voltammetry scan begins. ```cpp double AisSquareWaveVoltammetryElement::getStartVoltage() const ``` -------------------------------- ### Basic Experiment Example in C++ Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/annotated Demonstrates how to set up and run a basic experiment using the Squidstat API in C++. This includes creating experiment elements and configuring their parameters. ```cpp /* C++ Raw Example Code - Basic Experiment */ // This section would contain the actual C++ code for a basic experiment. // Example: Creating an instance of CAisExperiment and adding elements. ``` -------------------------------- ### Basic Experiment Setup and Execution (C++) Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/md__markdown_files_2_run_experiment This section details the C++ code required to set up a basic experiment, including necessary includes, event loop setup, device tracking, experiment building with elements, and connecting to the Squidstat device. ```APIDOC ## Basic Experiment Setup and Execution (C++) ### Description This example demonstrates the C++ code necessary to initialize the environment, define experiment parameters, build a simple experiment, and establish a connection to the Squidstat device. ### Method N/A (Code Example) ### Endpoint N/A (Code Example) ### Parameters N/A (Code Example) ### Request Example ```cpp #include "AisDeviceTracker.h" #include "AisExperiment.h" #include "AisInstrumentHandler.h" #include "experiments/builder_elements/AisConstantPotElement.h" #include #include // Define relevant device information, for easy access #define COMPORT "COM1" #define CHANNEL 0 int main() { char** test = nullptr; int args; QCoreApplication a(args, test); auto tracker = AisDeviceTracker::Instance(); // Voltage = 1V, Sampling Interval = 1s, Duration = 30s AisConstantPotElement cvElement(1, 1, 30); auto customExperiment = std::make_shared(); // Append the constant potential element, and tell it to execute that element 1 time customExperiment->appendElement(cvElement, 1); AisErrorCode error = tracker->connectToDeviceOnComPort(COMPORT); if (error != error.Success) { qDebug() << error.message(); return 0; } return 0; } ``` ### Response #### Success Response (N/A) N/A #### Response Example N/A ``` -------------------------------- ### Connect, Upload, and Start Experiment in C++ Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/data_output_8cpp-example Demonstrates the process of connecting to a new device, setting up signal handlers, uploading a custom experiment, and then starting the uploaded experiment on a specified channel. It includes error checking for upload and start operations. ```C++ QObject::connect(tracker, &AisDeviceTracker::newDeviceConnected, [=](const QString& deviceName) { auto& handler = tracker->getInstrumentHandler(deviceName); connectSignals(handler); AisErrorCode error = handler.uploadExperimentToChannel(0, customExperiment); if (error) { qDebug() << error.message(); return 0; } error = handler.startUploadedExperiment(CHANNEL); if (error) { qDebug() << error.message(); return 0; } }); ``` -------------------------------- ### Advanced Experiment Example in Python Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/dir_dcba106d9258d0d70453000fc6947d17 Illustrates how to configure and run an advanced experiment using the Squidstat API in Python. This example delves into more complex experimental setups. ```Python # Raw Example Code Python Advanced Experiment # This is a placeholder for the actual Python code. ``` -------------------------------- ### Advanced Experiment Example: Python Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/dir_490869fd64042495237c9383dd3806a5 Illustrates an advanced experiment setup in Python using the Squidstat API. This example covers more intricate experimental designs and data processing. ```python # Placeholder for Python advanced experiment code ``` -------------------------------- ### Get Start Frequency in C++ Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/_ais_e_i_s_potentiostatic_element_8h_source Retrieves the set value for the voltage starting frequency in an EIS potentiostatic experiment. This function is part of the AisEISPotentiostaticElement class. ```cpp double AisEISPotentiostaticElement::getStartFreq() const ``` -------------------------------- ### Basic Experiment Example in Python Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/annotated Demonstrates how to set up and run a basic experiment using the Squidstat API in Python. This includes creating experiment elements and configuring their parameters. ```python # Python Raw Example Code - Basic Experiment # This section would contain the actual Python code for a basic experiment. # Example: Creating an instance of SquidstatClient and running an experiment. ``` -------------------------------- ### Parallel Operation with Other Device Example in Python Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/dir_dcba106d9258d0d70453000fc6947d17 Shows how to operate Squidstats in parallel with other devices using Python. This example is useful for complex experimental setups requiring synchronized control. ```Python # Raw Example Code Python Parallel Operation with Other device # This is a placeholder for the actual Python code. ``` -------------------------------- ### Basic Experiment Example in Python Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/dir_dcba106d9258d0d70453000fc6947d17 Provides a Python example for setting up and running a basic electrochemical experiment with the Squidstat API. This covers essential API usage for beginners. ```Python # Raw Example Code Python Basic Experiment # This is a placeholder for the actual Python code. ``` -------------------------------- ### C++ Example Code for Squidstat API Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/class_ais_constant_resistance_element-members This section provides raw C++ code examples for various functionalities within the Squidstat API. These examples cover basic and advanced experiment setups, firmware updates, data handling, control flow, and linked channels. ```cpp // Basic Experiment // ... ``` ```cpp // Advanced Experiment // ... ``` ```cpp // Manual Experiment // ... ``` ```cpp // Updating Firmware // ... ``` ```cpp // Writing Data to File // ... ``` ```cpp // Advanced Control Flow // ... ``` ```cpp // Linked Channels // ... ``` ```cpp // Nonblocking Experiment // ... ``` ```cpp // Handle Pulse Data // ... ``` -------------------------------- ### C++: Basic Experiment Setup Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/class_ais_data_manipulator-members Demonstrates the fundamental steps to set up and run a basic experiment using the SquidStat API in C++. ```cpp // C++ basic experiment example (conceptual) // This is a placeholder as the actual code was not provided in the text. // In a real scenario, this would involve instantiating experiment objects, // configuring parameters, and initiating the experiment run. ``` -------------------------------- ### Parallel Operation with Other Device Example (Python) Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/dir_ba07606fa57ab2aace2c9d770da38b5c Illustrates how to achieve parallel operation with other devices while using the Squidstat API in Python. This example is helpful for complex setups involving multiple hardware components. ```Python # Python Parallel Operation Example # ... parallel operation code ... ``` -------------------------------- ### Basic Experiment Example in C++ Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/class_ais_diff_pulse_voltammetry_element-members Demonstrates how to set up and run a basic electrochemical experiment using the SquidStat API in C++. ```cpp /// Basic Experiment /// This example demonstrates setting up and running a basic experiment. #include "AisManager.h" #include "AisDevice.h" #include "AisExperiment.h" #include "AisDiffPulseVoltammetryElement.h" int main() { AisManager manager; AisDevice device = manager.openDevice("COM3"); // Replace with your COM port AisExperiment experiment; AisDiffPulseVoltammetryElement dpvElement( 0.0, // startVoltage 0.1, // endVoltage 0.001, // voltageStep 0.05, // pulseHeight 0.0001, // pulseWidth 0.1 // pulsePeriod ); experiment.addElement(dpvElement); device.runExperiment(experiment); // Process results or handle errors manager.closeDevice(device); return 0; } ``` -------------------------------- ### C++ Examples for Squidstat API Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/class_ais_e_i_s_galvanostatic_element-members This section provides C++ code examples for various functionalities of the Squidstat API. These include basic and advanced experiment setups, firmware updates, data handling, and control flow. ```cpp // Basic Experiment // ... implementation details ... ``` ```cpp // Advanced Experiment // ... implementation details ... ``` ```cpp // Manual Experiment // ... implementation details ... ``` ```cpp // Updating Firmware // ... implementation details ... ``` ```cpp // Writing Data to File // ... implementation details ... ``` ```cpp // Advanced Control Flow // ... implementation details ... ``` ```cpp // Linked Channels // ... implementation details ... ``` ```cpp // Nonblocking Experiment // ... implementation details ... ``` ```cpp // Handle Pulse Data // ... implementation details ... ``` -------------------------------- ### Advanced Experiment Code Examples (C++, Python) Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/dir_ba07606fa57ab2aace2c9d770da38b5c Illustrates how to implement more complex experimental setups using the Squidstat API. These examples cover advanced functionalities and configurations available in both C++ and Python. ```C++ // C++ Advanced Experiment Example // ... code for advanced experiment ... ``` ```Python # Python Advanced Experiment Example # ... code for advanced experiment ... ``` -------------------------------- ### Parallel Operation with Other Device Example in Python Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/class_ais_constant_pot_element-members Illustrates how to achieve parallel operation with another device while using the Squidstat API in Python. This example is relevant for complex experimental setups requiring multiple instruments. ```Python # Placeholder for Python parallel operation example. # Corresponds to 'Parallel Operation with Other device' in Python raw example code. ``` -------------------------------- ### Manual Experiment Example (Python) Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/class_ais_staircase_potential_voltammetry_element Provides an example of setting up and running a manual experiment with the Squidstat API in Python. ```python # Python example code would go here, similar to C++ manual experiment ``` -------------------------------- ### C++ Examples for Squidstat API Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/class_ais_d_c_current_sweep_element-members A collection of C++ code snippets demonstrating various functionalities of the Squidstat API. These examples cover basic and advanced experiment setups, firmware updates, data handling, and control flow. ```cpp /* Basic Experiment */ // Example code for a basic experiment setup. // Requires initialization of the Squidstat device and experiment parameters. ``` ```cpp /* Advanced Experiment */ // Example code for an advanced experiment configuration. // Demonstrates complex parameter settings and experimental logic. ``` ```cpp /* Manual Experiment */ // Code snippet for manually controlling experimental parameters and execution. ``` ```cpp /* Updating Firmware */ // Illustrates the process of updating the firmware on the Squidstat device. ``` ```cpp /* Writing Data to File */ // Example demonstrating how to write experimental data to a file. // Includes data formatting and file I/O operations. ``` ```cpp /* Advanced Control Flow */ // Shows advanced control flow structures for managing experiments. // Useful for implementing conditional logic within experiments. ``` ```cpp /* Linked Channels */ // Code for configuring and utilizing linked channels in an experiment. // Allows for synchronized measurements across multiple channels. ``` ```cpp /* Nonblocking Experiment */ // Example of running an experiment in a nonblocking manner. // Allows the main program to continue execution while the experiment runs. ``` ```cpp /* Handle Pulse Data */ // Demonstrates how to handle and process pulse data acquired from the device. ``` -------------------------------- ### C++ Function for Getting Starting Current Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/_ais_d_c_current_sweep_element_8h_source Implements the getStartingCurrent method for the AisDCCurrentSweepElement class in C++. This function retrieves the initial current value for a DC current sweep experiment. It returns a double representing the starting current. ```cpp double AisDCCurrentSweepElement::getStartingCurrent() const { // Implementation details for getting starting current return 0.0; // Placeholder } ``` -------------------------------- ### Squidstat API - Basic Experiment Example (Python) Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/dir_d44c64559bbebec7f509842c48db8b23 Provides a basic experiment example using the Squidstat Python API. This snippet illustrates how to initialize the API, configure an experiment, and run it. ```python from squidstat.instrument_handler import InstrumentHandler from squidstat.experiment import Experiment handler = InstrumentHandler("COM3") # Replace with your COM port handler.connect() experiment = Experiment() experiment.set_duration(10.0) experiment.set_sampling_interval(0.01) handler.run_experiment(experiment) handler.disconnect() ``` -------------------------------- ### Basic Experiment Example in C++ Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/dir_dcba106d9258d0d70453000fc6947d17 Demonstrates how to set up and run a basic electrochemical experiment using the Squidstat API in C++. This example covers fundamental API calls for experiment execution. ```C++ // Raw Example Code C++ Basic Experiment // This is a placeholder for the actual C++ code. ``` -------------------------------- ### Basic Experiment Example: C++ Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/dir_490869fd64042495237c9383dd3806a5 Demonstrates how to set up and run a basic experiment using the Squidstat API in C++. This example is useful for understanding fundamental experiment execution flows. ```cpp // Placeholder for C++ basic experiment code ``` -------------------------------- ### C++ Basic Experiment Example Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/struct_ais_experiment_node Demonstrates how to set up and run a basic experiment using the SquidStat API in C++. This includes necessary header inclusions and definitions for experiment elements. ```cpp #include #include // Basic experiment setup and execution would go here. ``` -------------------------------- ### C++ AisSteppedVoltageElement Set Start Voltage Vs OCP Method Example - SquidStat API Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/class_ais_stepped_voltage_element-members Illustrates the setStartVoltageVsOCP() method for the AisSteppedVoltageElement class in C++. This method specifies whether the start voltage is relative to the Open Circuit Potential (OCP). ```cpp setStartVoltageVsOCP(bool startVsOCP) ``` -------------------------------- ### Start Experiment: C++ and Python Source: https://admiral-instruments.github.io/AdmiralSquidstatAPI/md__markdown_files_2_run_experiment This snippet demonstrates how to upload and start an experiment on a Squidstat instrument using both C++ and Python. It includes obtaining the instrument handler, uploading the experiment to a channel, and initiating the experiment, with error checking at each step. Ensure you have established a connection to the instrument and have a valid experiment object. ```C++ auto& handler = tracker->getInstrumentHandler(deviceName); connectSignals(handler); AisErrorCode error = handler.uploadExperimentToChannel(CHANNEL, customExperiment); if (error) { qDebug() << error.message(); return; } // Start the previously uploaded experiment on the same channel error = handler.startUploadedExperiment(CHANNEL); // Exit the application if there is any error starting the experiment if (error) { qDebug() << error.message(); return; } ``` ```Python handler = tracker.getInstrumentHandler(deviceName) connectSignals(handler) error = handler.uploadExperimentToChannel(CHANNEL, experiment) # Exit the application if there is any error uploading experiment if error.value() != AisErrorCode.Success: print(error.message()) app.quit() error = handler.startUploadedExperiment(CHANNEL) # Exit the application if there is any error starting experiment if error.value() != AisErrorCode.Success: print(error.message()) app.quit() ```