### CMake Project Setup and Executable Build Source: https://github.com/admiral-instruments/admiralsquidstatapi/blob/main/SquidstatLibrary/examples/C++/firmwareUpdate/CMakeLists.txt Configures a CMake project named 'firmwareUpdate' using CXX, defines source files, and creates an executable. This is a fundamental build system configuration. ```cmake project(firmwareUpdate LANGUAGES CXX) set(SOURCES firmwareUpdate.cpp) add_executable(${PROJECT_NAME} ${SOURCES}) ``` -------------------------------- ### CMake Project Setup and Executable Build Source: https://github.com/admiral-instruments/admiralsquidstatapi/blob/main/SquidstatLibrary/examples/C++/advancedExperiment/CMakeLists.txt This CMake script configures a C++ project named 'advancedExperiment'. It specifies the source files and adds a command to build an executable from them. It's the fundamental build configuration for the project. ```cmake project(advancedExperiment LANGUAGES CXX) set(SOURCES advancedExperiment.cpp) add_executable(${PROJECT_NAME} ${SOURCES}) ``` -------------------------------- ### CMake Project Setup and Build Configuration (CMake) Source: https://github.com/admiral-instruments/admiralsquidstatapi/blob/main/SquidstatLibrary/examples/C++/basicExperiment/CMakeLists.txt Configures a C++ project named 'basicExperiment' using CMake. It specifies the programming language, lists source files, and defines the executable target. This is the primary build script for the project. ```cmake project(basicExperiment LANGUAGES CXX) set(SOURCES basicExperiment.cpp) add_executable(${PROJECT_NAME} ${SOURCES}) ``` -------------------------------- ### CMake Project Setup and Executable Build Source: https://github.com/admiral-instruments/admiralsquidstatapi/blob/main/SquidstatLibrary/examples/C++/dataOutput/CMakeLists.txt This snippet configures a C++ project using CMake. It sets the project name, specifies source files, and defines the target executable. It's a standard way to manage C++ builds with CMake. ```cmake project(dataOutput LANGUAGES CXX) set(SOURCES dataOutput.cpp) add_executable(${PROJECT_NAME} ${SOURCES}) ``` -------------------------------- ### Build Single Experiment and Connect to Device Source: https://context7.com/admiral-instruments/admiralsquidstatapi/llms.txt This snippet demonstrates how to build a simple experiment using AisExperiment, append a CV element, and connect to a device. It sets up signal handlers for DC and AC data, experiment stop events, and new element notifications. The experiment is then uploaded and started on a specified channel. ```python experiment = AisExperiment() if not experiment.appendElement(cvElement, 1): print("Error adding element to experiment") app.quit() def on_dc_data(channel, data): print(f"Time: {data.timestamp}s Current: {data.current}A " f"WE Voltage: {data.workingElectrodeVoltage}V " f"CE Voltage: {data.counterElectrodeVoltage}V " f"Temp: {data.temperature}°C") def on_ac_data(channel, data): print(f"Time: {data.timestamp}s Freq: {data.frequency}Hz " f"|Z|: {data.absoluteImpedance}Ω Phase: {data.phaseAngle}° " f"Re(Z): {data.realImpedance}Ω Im(Z): {data.imagImpedance}Ω") def on_experiment_stopped(channel, reason): print(f"Experiment stopped on channel {channel}: {reason}") app.quit() def on_new_element(channel, info): print(f"Step {info.stepNumber}: {info.stepName} " f"(substep {info.substepNumber}, cycle {info.cycle})") def start_experiment(deviceName): handler = tracker.getInstrumentHandler(deviceName) # Connect data signals handler.activeDCDataReady.connect(on_dc_data) handler.activeACDataReady.connect(on_ac_data) handler.experimentStopped.connect(on_experiment_stopped) handler.experimentNewElementStarting.connect(on_new_element) handler.deviceError.connect(lambda ch, err: print(f"Error: {err}")) # Upload and start experiment error = handler.uploadExperimentToChannel(CHANNEL, experiment) if error.value() != AisErrorCode.Success: print(f"Upload failed: {error.message()}") app.quit() error = handler.startUploadedExperiment(CHANNEL) if error.value() != AisErrorCode.Success: print(f"Start failed: {error.message()}") app.quit() tracker.newDeviceConnected.connect(start_experiment) error = tracker.connectToDeviceOnComPort(COMPORT) if error.value() != AisErrorCode.Success: print(error.message()) sys.exit() sys.exit(app.exec()) ``` -------------------------------- ### CMake Project Setup and Executable Creation Source: https://github.com/admiral-instruments/admiralsquidstatapi/blob/main/SquidstatLibrary/examples/C++/advancedControlFlow/CMakeLists.txt This snippet configures a CMake project named 'advancedControlFlow' to use C++ (CXX) and specifies the source files. It then defines an executable target with the same name as the project, using the provided source files. ```cmake project(advancedControlFlow LANGUAGES CXX) set(SOURCES advancedControlFlow.cpp) add_executable(${PROJECT_NAME} ${SOURCES}) ``` -------------------------------- ### CMake Project Setup and Executable Build Source: https://github.com/admiral-instruments/admiralsquidstatapi/blob/main/SquidstatLibrary/examples/C++/linkedChannels/CMakeLists.txt Configures the CMake project, specifying C++ as the language and listing source files. It then defines a target executable based on these sources. This is a fundamental step for building any C++ project with CMake. ```cmake project(linkedChannels LANGUAGES CXX) set(SOURCES linkedChannels.cpp) add_executable(${PROJECT_NAME} ${SOURCES}) ``` -------------------------------- ### Build Multi-Element Experiment with CSV Data Export Source: https://context7.com/admiral-instruments/admiralsquidstatapi/llms.txt This example shows how to construct a multi-step experiment involving a Constant Potential (CV) step followed by a Constant Current (CC) step. It also demonstrates exporting DC data to individual CSV files, with each file named according to the experiment step number and name. The data logged includes timestamp, CE voltage, WE voltage, current, and temperature. ```python from PySide6.QtCore import QTextStream, QFile, QStandardPaths, QIODevice from SquidstatPyLibrary import ( AisDeviceTracker, AisExperiment, AisConstantPotElement, AisConstantCurrentElement ) CHANNEL = 0 # Build multi-element experiment cvElement = AisConstantPotElement(1, 1, 30) # 1V for 30s ccElement = AisConstantCurrentElement(0.001, 1, 60) # 1mA for 60s experiment = AisExperiment() experiment.setExperimentName("Two-Step Test") experiment.setDescription("CV followed by CC") success = experiment.appendElement(cvElement, 1) success &= experiment.appendElement(ccElement, 1) if not success: print("Failed to build experiment") sys.exit() current_file = None def on_new_element(channel, info): global current_file filename = f"{info.stepNumber}_{info.stepName}.csv" filepath = QStandardPaths.writableLocation(QStandardPaths.DesktopLocation) + "/" + filename current_file = QFile(filepath) if current_file.open(QIODevice.WriteOnly | QIODevice.Text): out = QTextStream(current_file) out << "Timestamp,CE_Voltage,WE_Voltage,Current,Temperature\n" current_file.close() print(f"Created file: {filepath}") def on_dc_data(channel, data): if current_file is None: return if current_file.open(QIODevice.Append | QIODevice.WriteOnly | QIODevice.Text): out = QTextStream(current_file) out << f"{data.timestamp},{data.counterElectrodeVoltage}," out << f"{data.workingElectrodeVoltage},{data.current},{data.temperature}\n" current_file.close() def start_experiment(deviceName): handler = tracker.getInstrumentHandler(deviceName) handler.experimentNewElementStarting.connect(on_new_element) handler.activeDCDataReady.connect(on_dc_data) handler.experimentStopped.connect(lambda ch, r: app.quit()) error = handler.uploadExperimentToChannel(CHANNEL, experiment) if error.value() == AisErrorCode.Success: handler.startUploadedExperiment(CHANNEL) ``` -------------------------------- ### Control Manual Experiment Mode with PySide6 Source: https://context7.com/admiral-instruments/admiralsquidstatapi/llms.txt This Python code snippet demonstrates how to control an electrochemical experiment in manual mode using the AisInstrumentHandler from SquidstatPyLibrary and QTimer from PySide6 for timed event scheduling. It allows for dynamic changes to experiment parameters like current, voltage, and open circuit potential over time. Ensure PySide6 and SquidstatPyLibrary are installed. ```python from PySide6.QtCore import QTimer from SquidstatPyLibrary import AisInstrumentHandler, AisErrorCode CHANNEL = 0 def start_manual_experiment(handler): # Start in open circuit potential mode error = handler.startManualExperiment(CHANNEL) if error.value() != AisErrorCode.Success: print(f"Failed to start: {error.message()}") return # Set sampling interval (optional) handler.setManualModeSamplingInterval(CHANNEL, 0.5) # 500ms # Switch to constant current after 5 seconds def set_current(): print("Switching to 0.1A constant current") error = handler.setManualModeConstantCurrent(CHANNEL, 0.1) if error.value() != AisErrorCode.Success: print(error.message()) QTimer.singleShot(5000, set_current) # Switch to constant voltage after 15 seconds def set_voltage(): print("Switching to 1V constant voltage") error = handler.setManualModeConstantVoltage(CHANNEL, 1.0) if error.value() != AisErrorCode.Success: print(error.message()) QTimer.singleShot(15000, set_voltage) # Set current range manually (disable autoranging) current_ranges = handler.getManualModeCurrentRangeList(CHANNEL) print(f"Available current ranges: {current_ranges}") handler.setManualModeCurrentRange(CHANNEL, 5) # Set specific range # Re-enable autoranging handler.setManualModeCurrentAutorange(CHANNEL) # Set voltage range manually voltage_ranges = handler.getManualModeVoltageRangeList(CHANNEL) handler.setManualModeVoltageRange(CHANNEL, 2) # Switch back to OCP after 25 seconds def set_ocp(): print("Switching to open circuit") handler.setManualModeOCP(CHANNEL) QTimer.singleShot(25000, set_ocp) # Stop after 30 seconds def stop(): handler.stopExperiment(CHANNEL) QTimer.singleShot(30000, stop) ``` -------------------------------- ### Manage Channels and Experiment Status with Python Source: https://context7.com/admiral-instruments/admiralsquidstatapi/llms.txt This Python code snippet demonstrates how to manage channels and monitor experiment status using the AisInstrumentHandler. It covers checking channel availability, controlling experiment execution (pause, resume, skip, stop), and retrieving experiment start times. This function is essential for orchestrating multiple experiments or monitoring device state. ```python from SquidstatPyLibrary import AisInstrumentHandler, AisErrorCode def manage_channels(handler): # Get device capabilities num_channels = handler.getNumberOfChannels() print(f"Device has {num_channels} channels") # Check channel status for ch in range(num_channels): if handler.isChannelBusy(ch): if handler.isChannelPaused(ch): print(f"Channel {ch}: PAUSED") else: print(f"Channel {ch}: BUSY") else: print(f"Channel {ch}: FREE") # Get free channels free = handler.getFreeChannels() print(f"Free channels: {free}") # Experiment control channel = 0 # Pause running experiment error = handler.pauseExperiment(channel) if error.value() == AisErrorCode.Success: print("Experiment paused") # Resume paused experiment error = handler.resumeExperiment(channel) if error.value() == AisErrorCode.Success: print("Experiment resumed") # Skip to next step/element error = handler.skipExperimentStep(channel) if error.value() == AisErrorCode.Success: print("Skipped to next step") # Stop experiment error = handler.stopExperiment(channel) if error.value() == AisErrorCode.Success: print("Experiment stopped") # Get experiment start time start_time = handler.getExperimentUTCStartTime(channel) print(f"Experiment started at Unix timestamp: {start_time}") ``` -------------------------------- ### Use Linked Channels for High-Current Applications with Python Source: https://context7.com/admiral-instruments/admiralsquidstatapi/llms.txt This Python code snippet illustrates how to link multiple channels of a Squidstat instrument to achieve higher current outputs, specifically for Cycler models. It shows how to set up linked channels, create a high-current experiment element, upload it to the master channel, and initiate bipolar mode if supported. Requires SquidstatPyLibrary to be installed. ```python from SquidstatPyLibrary import AisConstantCurrentElement, AisExperiment, AisErrorCode def use_linked_channels(handler): # Link channels 0 and 1 for combined output master_channel = handler.setLinkedChannels([0, 1]) print(f"Master channel: {master_channel}") # Check linked channels linked = handler.getLinkedChannels(master_channel) print(f"Linked channels: {linked}") # Create high-current experiment (10A total across linked channels) ccElement = AisConstantCurrentElement(10, 1, 30) experiment = AisExperiment() experiment.appendElement(ccElement, 1) # Upload and control via master channel ONLY error = handler.uploadExperimentToChannel(master_channel, experiment) if error.value() == AisErrorCode.Success: handler.startUploadedExperiment(master_channel) # Bipolar mode for negative voltages (Cycler only: channels 1+2 or 3+4) bipolar_master = handler.setBipolarLinkedChannels([0, 1]) if bipolar_master >= 0: is_bipolar = handler.hasBipolarMode(bipolar_master) print(f"Bipolar mode enabled: {is_bipolar}") ``` -------------------------------- ### CMake Project Configuration and Build Source: https://github.com/admiral-instruments/admiralsquidstatapi/blob/main/SquidstatLibrary/examples/C++/nonblockingExperiment/CMakeLists.txt Configures a CMake project named 'nonblockingExperiment' to use C++ (CXX). It specifies source files and defines a post-build custom command for Windows systems to copy dynamic-link libraries (DLLs) to the executable's directory. This ensures that all required dependencies are available at runtime. ```cmake project(nonblockingExperiment LANGUAGES CXX) set(SOURCES nonblockingExperiment.cpp) add_executable(${PROJECT_NAME} ${SOURCES}) if(WIN32) add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/windows/bin/SquidstatLibraryd.dll $; ${CMAKE_SOURCE_DIR}/windows/thirdParty/Qt/bin/Qt5Cored.dll $; ${CMAKE_SOURCE_DIR}/windows/thirdParty/Qt/bin/Qt5SerialPortd.dll $ COMMENT "Copy dll file to" $; ${CMAKE_SOURCE_DIR}/windows/thirdParty/Qt/bin/Qt5Cored.dll $; ${CMAKE_SOURCE_DIR}/windows/thirdParty/Qt/bin/Qt5SerialPortd.dll $ COMMENT "Copy dll file to" $ 10mA cvElement.setMinAbsoluteCurrent(0.0001); // Stop if |I| < 0.1mA cvElement.setMaxCapacity(1000); // Stop at 1000 C cumulative charge cvElement.setMindIdt(0.00001); // Stop if dI/dt < 10µA/s cvElement.setApproxMaxCurrent(0.005); // Manual current range selection cvElement.setVoltageRange(2); // Manual voltage range mainExperiment.appendElement(cvElement, 1); // Add cyclic voltammetry (will have multiple internal steps per cycle) AisCyclicVoltammetryElement cvmElement(0, 1, -1, 0.1, 5, 1, 0); // start, vertex1, vertex2, scanRate, cycles, samplingInterval, quietTime mainExperiment.appendElement(cvmElement, 2); // Run CV twice // Get experiment info QString name = mainExperiment.getExperimentName(); QString desc = mainExperiment.getDescription(); QStringList categories = mainExperiment.getCategory(); ``` -------------------------------- ### CMake Project Configuration and Build Source: https://github.com/admiral-instruments/admiralsquidstatapi/blob/main/SquidstatLibrary/examples/C++/pulseData/CMakeLists.txt This snippet defines a CMake project named 'pulseData' using C++ and specifies the source files. It then creates an executable target for the project. Dependencies are managed through CMake commands. ```cmake project(pulseData LANGUAGES CXX) set(SOURCES pulseData.cpp) add_executable(${PROJECT_NAME} ${SOURCES}) ``` -------------------------------- ### C++: Define and Initialize Electrochemical Experiment Elements Source: https://context7.com/admiral-instruments/admiralsquidstatapi/llms.txt This snippet demonstrates how to include and instantiate various experiment element classes from the Admiral SquidStat API. It covers potentiostatic, galvanostatic, DC techniques, pulse voltammetry, and AC impedance spectroscopy. Each class constructor takes specific parameters relevant to the experiment type. ```cpp // Potentiostatic control #include "experiments/builder_elements/AisConstantPotElement.h" #include "experiments/builder_elements/AisDCPotentialSweepElement.h" #include "experiments/builder_elements/AisSteppedVoltageElement.h" #include "experiments/builder_elements/AisCyclicVoltammetryElement.h" // Galvanostatic control #include "experiments/builder_elements/AisConstantCurrentElement.h" #include "experiments/builder_elements/AisDCCurrentSweepElement.h" #include "experiments/builder_elements/AisSteppedCurrentElement.h" // Other DC techniques #include "experiments/builder_elements/AisOpenCircuitElement.h" #include "experiments/builder_elements/AisConstantPowerElement.h" #include "experiments/builder_elements/AisConstantResistanceElement.h" // Pulse voltammetry #include "experiments/builder_elements/AisDiffPulseVoltammetryElement.h" #include "experiments/builder_elements/AisNormalPulseVoltammetryElement.h" #include "experiments/builder_elements/AisSquareWaveVoltammetryElement.h" #include "experiments/builder_elements/AisStaircasePotentialVoltammetryElement.h" // AC impedance spectroscopy #include "experiments/builder_elements/AisEISPotentiostaticElement.h" #include "experiments/builder_elements/AisEISGalvanostaticElement.h" #include "experiments/builder_elements/AisMottSchottkyElement.h" // Example: Create various experiment types AisConstantPotElement cp(1.0, 1.0, 30.0); // V, samplingInterval, duration AisConstantCurrentElement cc(0.001, 1.0, 60.0); // A, samplingInterval, duration AisOpenCircuitElement ocp(1.0, 10.0); // samplingInterval, duration AisCyclicVoltammetryElement cv(0, 1, -1, 0.1, 5, 1, 0); // start, v1, v2, rate, cycles, interval, quiet AisEISPotentiostaticElement eis(0.5, 0.01, 100000, 0.1, 10, 1); // V, amplitude, fMax, fMin, intervals, samplingInterval ``` -------------------------------- ### Windows Platform Configuration (CMake) Source: https://github.com/admiral-instruments/admiralsquidstatapi/blob/main/SquidstatLibrary/examples/C++/CMakeLists.txt Configures include directories and links libraries specifically for the Windows platform. It points to local include paths and specific .lib files for QtCore and SquidstatLibrary. ```cmake if(WIN32) include_directories( ../../windows/include ../../windows/thirdParty/Qt/include/QtCore ../../windows/thirdParty/Qt/include/ ) link_libraries(${CMAKE_SOURCE_DIR}/windows/thirdParty/Qt/bin/Qt5Cored.lib ${CMAKE_SOURCE_DIR}/windows/bin/SquidstatLibraryd.lib) endif() ``` -------------------------------- ### Process Pulse Voltammetry Data - C++ Source: https://context7.com/admiral-instruments/admiralsquidstatapi/llms.txt Processes and extracts data for Differential Pulse Voltammetry (DPV) and Square Wave Voltammetry (SWV) experiments. It includes creating experiment elements, setting pulse parameters, loading DC data, and calculating peak currents. The code demonstrates handling pulse completion and retrieving key metrics like delta I at specific voltages. ```cpp #include "AisDataManipulator.h" #include "experiments/builder_elements/AisDiffPulseVoltammetryElement.h" #include "experiments/builder_elements/AisSquareWaveVoltammetryElement.h" void processPulseData() { // Create DPV element AisDiffPulseVoltammetryElement dpvElement( -0.5, // startVoltage 0.5, // endVoltage 0.05, // pulseHeight 0.05, // stepSize 0.2, // pulseWidth 0.5, // pulsePeriod 1.0 // samplingInterval ); // Create data manipulator for DPV AisDataManipulator manipulator(dpvElement); // Configure pulse parameters AisErrorCode error = manipulator.setPulseType( AisPulseType::DifferentialPulse, 0.2, // pulseWidth 0.5 // pulsePeriod ); // Process incoming DC data in signal handler auto processDCData = [&](uint8_t channel, const AisDCData& data) { manipulator.loadPrimaryData(data); if (manipulator.isPulseCompleted()) { double baseCurrent = manipulator.getBaseCurrent(); double pulseCurrent = manipulator.getPulseCurrent(); double baseVoltage = manipulator.getBaseVoltage(); double pulseVoltage = manipulator.getPulseVoltage(); double deltaI = pulseCurrent - baseCurrent; qDebug() << "ΔI:" << deltaI << "A at V:" << pulseVoltage; } }; // Square wave voltammetry with frequency AisSquareWaveVoltammetryElement swvElement(-0.5, 0.5, 0.025, 0.005, 25, 1); AisDataManipulator swvManipulator(swvElement); error = swvManipulator.setPulseType(AisPulseType::SquareWave, 25.0); // 25 Hz double frequency = swvManipulator.getFrequency(); qDebug() << "SWV frequency:" << frequency << "Hz"; } ``` -------------------------------- ### Configure Logging - C++ Source: https://context7.com/admiral-instruments/admiralsquidstatapi/llms.txt Manages the logging configuration for the Admiral device tracker. This function demonstrates how to enable or disable log file generation, set a custom directory for log files, and provides the default log path. Logging is enabled by default. ```cpp void configureLogging(AisDeviceTracker* tracker) { // Enable/disable log file generation (enabled by default) tracker->saveLogToFile(true); // Set custom log file directory // Default: Documents/Admiral Instrument/API QString customLogPath = "/var/log/admiral_instruments"; tracker->setLogFilePath(customLogPath); qDebug() << "Logs will be saved to:" << customLogPath; // Disable logging tracker->saveLogToFile(false); } ``` -------------------------------- ### Linux Platform Configuration (CMake) Source: https://github.com/admiral-instruments/admiralsquidstatapi/blob/main/SquidstatLibrary/examples/C++/CMakeLists.txt Configures include directories and finds/links libraries for Linux. It searches for Qt5Core, Qt5SerialPort, ICU, and SquidstatLibrary shared object files (.so) and sets the position-independent code flag. ```cmake if(NOT WIN32 AND NOT APPLE AND CMAKE_SYSTEM_NAME MATCHES "Linux") include_directories( ../../Linux/include ../../Linux/thirdParty/Qt/include/QtCore ../../Linux/thirdParty/Qt/include/ ) find_library(Qt5ore NAME libQt5Core.so.5 HINTS ${CMAKE_SOURCE_DIR}/Linux/bin ) find_library(Qt5SerialPort NAME libQt5SerialPort.so.5 libicudata.so.56 libicui18n.so.56 libicuuc.so.56 HINTS ${CMAKE_SOURCE_DIR}/Linux/bin ) find_library(libcudata NAME libicudata.so.56 libicui18n.so.56 libicuuc.so.56 HINTS ${CMAKE_SOURCE_DIR}/Linux/bin ) find_library(libcui18n NAME libicui18n.so.56 libicuuc.so.56 HINTS ${CMAKE_SOURCE_DIR}/Linux/bin ) find_library(libicuuc NAME libicuuc.so.56 HINTS ${CMAKE_SOURCE_DIR}/Linux/bin ) find_library(SquidstatLibrarylib_debug NAME SquidstatLibraryd HINTS ${CMAKE_SOURCE_DIR}/Linux/bin ) find_library(SquidstatLibrarylib_release NAME SquidstatLibrary HINTS ${CMAKE_SOURCE_DIR}/Linux/bin ) link_libraries(${SquidstatLibrarylib_debug} ${Qt5ore} ${Qt5SerialPort} ${libcudata} ${libcui18n} ${libicuuc}) add_compile_options(-fPIC) endif() ``` -------------------------------- ### Connect and Discover Admiral Potentiostats (C++) Source: https://context7.com/admiral-instruments/admiralsquidstatapi/llms.txt Connects to Admiral Instruments potentiostats via USB COM ports using C++ and Qt framework. It establishes signals for device connection and disconnection events. Outputs connection status to the console. ```cpp #include "AisDeviceTracker.h" #include #include int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); auto tracker = AisDeviceTracker::Instance(); // Connect signals QObject::connect(tracker, &AisDeviceTracker::newDeviceConnected, [](const QString& deviceName) { qDebug() << "Device connected:" << deviceName; }); QObject::connect(tracker, &AisDeviceTracker::deviceDisconnected, [](const QString& deviceName) { qDebug() << "Device disconnected:" << deviceName; }); // Connect to device AisErrorCode error = tracker->connectToDeviceOnComPort("COM15"); if (error != AisErrorCode::Success) { qDebug() << "Connection failed:" << error.message(); return 1; } return app.exec(); } ``` -------------------------------- ### Set Channel Safety Limits with Admiral SquidStat API (C++) Source: https://context7.com/admiral-instruments/admiralsquidstatapi/llms.txt This C++ code configures safety limits for a specific channel using the Admiral SquidStat API. It demonstrates setting maximum and minimum voltage, current, and temperature limits, as well as how to reset all limits to their default values. Error handling for API calls is included. Note that temperature limits may not be supported on all models. ```cpp #include "AisInstrumentHandler.h" void setChannelLimits(const AisInstrumentHandler& handler, uint8_t channel) { // Set voltage limits (experiment stops if exceeded) AisErrorCode error = handler.setChannelMaximumVoltage(channel, 5.0); // 5V max if (error != AisErrorCode::Success) { qDebug() << "Failed to set max voltage:" << error.message(); } error = handler.setChannelMinimumVoltage(channel, -2.0); // -2V min if (error != AisErrorCode::Success) { qDebug() << "Failed to set min voltage:" << error.message(); } // Set current limits error = handler.setChannelMaximumCurrent(channel, 0.1); // 100mA max error = handler.setChannelMinimumCurrent(channel, -0.05); // -50mA min // Set temperature limit (Cycler models) error = handler.setChannelMaximumTemperature(channel, 60.0); // 60°C max if (error == AisErrorCode::FeatureNotSupported) { qDebug() << "Temperature limiting not available on this model"; } // Reset all limits to defaults error = handler.resetChannelLimits(channel); if (error == AisErrorCode::Success) { qDebug() << "All limits reset"; } // Note: For Cycler models, limits don't apply to AC elements // For other devices, not recommended for AC elements } ``` -------------------------------- ### Configure IR Compensation with Admiral SquidStat API (C++) Source: https://context7.com/admiral-instruments/admiralsquidstatapi/llms.txt This C++ code shows how to configure IR compensation settings using the Admiral SquidStat API to enhance measurement accuracy. It includes setting the uncompensated resistance and the desired compensation level, as well as configuring the compensation range with specified stability and bandwidth parameters. Error handling for the API calls is demonstrated. ```cpp void configureCompensation(const AisInstrumentHandler& handler, uint8_t channel) { // Set IR compensation double uncompensatedResistance = 100.0; // 100 Ohms double compensationLevel = 85.0; // 85% compensation AisErrorCode error = handler.setIRComp(channel, uncompensatedResistance, compensationLevel); if (error == AisErrorCode::Success) { qDebug() << "IR compensation set successfully"; } // Set compensation range with stability and bandwidth AisCompRange compRange(5, 7); // stability factor 5, bandwidth index 7 // stability: 0-10 (higher = more stable but slower) // bandwidth: 0-10 (higher = wider bandwidth) error = handler.setCompRange(channel, compRange); if (error == AisErrorCode::Success) { qDebug() << "Compensation range configured"; } } ``` -------------------------------- ### Manage Firmware Updates - C++ Source: https://context7.com/admiral-instruments/admiralsquidstatapi/llms.txt Handles device firmware updates and monitors their progress. This includes connecting to the device, initiating updates on specific COM ports, updating all available devices, and receiving notifications about the update status. Error handling for connection failures and up-to-date firmware is included. ```cpp void manageFirmware(AisDeviceTracker* tracker) { // Monitor firmware update progress QObject::connect(tracker, &AisDeviceTracker::firmwareUpdateNotification, [](const QString& message) { qDebug() << "Firmware update:" << message; }); // Update firmware on specific port AisErrorCode error = tracker->updateFirmwareOnComPort("COM15"); if (error == AisErrorCode::Success) { qDebug() << "Firmware update initiated"; } else if (error == AisErrorCode::FirmwareUptodate) { qDebug() << "Firmware already up to date"; } else if (error == AisErrorCode::ConnectionFailed) { qDebug() << "Could not connect to device"; } // Update all available devices automatically int numUpdated = tracker->updateFirmwareOnAllAvailableDevices(); qDebug() << "Updated firmware on" << numUpdated << "device(s)"; } ``` -------------------------------- ### Configure Fan Speed - C++ Source: https://context7.com/admiral-instruments/admiralsquidstatapi/llms.txt Configures the fan speed for Admiral instruments, offering options for maximum speed during experiments to reduce data variance and variable speed based on temperature. Feature availability depends on the specific instrument model and serial number. ```cpp void configureFan(const AisInstrumentHandler& handler) { // Set fan to maximum speed when experiment active // Reduces data variance from fan cycling // Available on: Plus (SN≥1700), Penta, Decka, Venta AisErrorCode error = handler.setFanSpeedMaximum(); if (error == AisErrorCode::Success) { qDebug() << "Fan will run at max speed during experiments"; } else if (error == AisErrorCode::FeatureNotSupported) { qDebug() << "Max fan mode not available on this model"; } // Set fan to variable speed based on temperature // Available on: Cycler (always), Plus (SN≥1700), Penta, Decka, Venta error = handler.setFanSpeedVariable(); if (error == AisErrorCode::Success) { qDebug() << "Fan will adjust based on temperature"; } // Note: Ace, Prime, Solo, Plus (SN<1700) always use max fan mode } ``` -------------------------------- ### Connect and Discover Admiral Potentiostats (Python) Source: https://context7.com/admiral-instruments/admiralsquidstatapi/llms.txt Connects to Admiral Instruments potentiostats via USB COM ports and handles device connection/disconnection notifications. It uses PySide6 for GUI event loop and SquidstatPyLibrary for device tracking. Outputs device connection status. ```python from PySide6.QtWidgets import QApplication from SquidstatPyLibrary import AisDeviceTracker, AisErrorCode import sys app = QApplication() tracker = AisDeviceTracker.Instance() # Signal handlers def on_device_connected(deviceName): print(f"Connected: {deviceName}") handler = tracker.getInstrumentHandler(deviceName) # Use handler to control the device def on_device_disconnected(deviceName): print(f"Disconnected: {deviceName}") tracker.newDeviceConnected.connect(on_device_connected) tracker.deviceDisconnected.connect(on_device_disconnected) # Connect to specific COM port error = tracker.connectToDeviceOnComPort("COM15") if error.value() != AisErrorCode.Success: print(f"Connection failed: {error.message()}") sys.exit(1) # Or automatically connect all plugged devices num_devices = tracker.connectAllPluggedInDevices() print(f"Connected {num_devices} device(s)") # Get list of connected devices devices = tracker.getConnectedDevices() for device_name in devices: print(f"Available: {device_name}") app.exec() ``` -------------------------------- ### Subdirectory Inclusion (CMake) Source: https://github.com/admiral-instruments/admiralsquidstatapi/blob/main/SquidstatLibrary/examples/C++/CMakeLists.txt Includes various subdirectories into the build process, each likely containing modules or features of the Admiral Squidstat API. ```cmake add_subdirectory(advancedControlFlow) add_subdirectory(advancedExperiment) add_subdirectory(basicExperiment) add_subdirectory(dataOutput) add_subdirectory(firmwareUpdate) add_subdirectory(linkedChannels) add_subdirectory(manualExperiment) add_subdirectory(nonblockingExperiment) add_subdirectory(pulseData) ``` -------------------------------- ### C++: Implement Robust Electrochemical Experiment Control with Error Handling Source: https://context7.com/admiral-instruments/admiralsquidstatapi/llms.txt This C++ snippet illustrates a robust error handling mechanism for controlling electrochemical experiments using the Admiral SquidStat API. It checks for various error codes during experiment upload and execution, providing specific feedback and retry logic for common issues like busy channels. ```cpp void robustExperimentControl(const AisInstrumentHandler& handler, uint8_t channel, std::shared_ptr experiment) { // Upload experiment with error checking AisErrorCode error = handler.uploadExperimentToChannel(channel, experiment); switch (error.value()) { case AisErrorCode::Success: qDebug() << "Upload successful"; break; case AisErrorCode::InvalidChannel: qDebug() << "Invalid channel number:" << channel; return; case AisErrorCode::BusyChannel: qDebug() << "Channel busy, stopping existing experiment"; handler.stopExperiment(channel); // Retry upload error = handler.uploadExperimentToChannel(channel, experiment); break; case AisErrorCode::ExperimentIsEmpty: qDebug() << "Experiment contains no elements"; return; case AisErrorCode::DeviceNotFound: qDebug() << "Device disconnected"; return; case AisErrorCode::InvalidParameters: qDebug() << "Invalid experiment parameters"; return; default: qDebug() << "Upload failed:" << error.message(); return; } // Start experiment error = handler.startUploadedExperiment(channel); if (error != AisErrorCode::Success) { qDebug() << "Failed to start:" << error.message(); if (error == AisErrorCode::ExperimentNotUploaded) { qDebug() << "No experiment uploaded to channel"; } else if (error == AisErrorCode::DeviceCommunicationFailed) { qDebug() << "Communication error, check connection"; } } } ``` -------------------------------- ### Device Connection and Discovery Source: https://context7.com/admiral-instruments/admiralsquidstatapi/llms.txt Connect to Admiral Instruments potentiostats via USB COM ports and receive notifications for device connections and disconnections. ```APIDOC ## Device Connection and Discovery ### Description Connect to Admiral Instruments potentiostats via USB COM ports and receive notifications when devices are connected or disconnected. ### Method N/A (This section describes API usage patterns and examples, not a specific HTTP endpoint) ### Endpoint N/A ### Parameters N/A ### Request Example ```python from PySide6.QtWidgets import QApplication from SquidstatPyLibrary import AisDeviceTracker, AisErrorCode app = QApplication() tracker = AisDeviceTracker.Instance() # Signal handlers def on_device_connected(deviceName): print(f"Connected: {deviceName}") handler = tracker.getInstrumentHandler(deviceName) # Use handler to control the device def on_device_disconnected(deviceName): print(f"Disconnected: {deviceName}") tracker.newDeviceConnected.connect(on_device_connected) tracker.deviceDisconnected.connect(on_device_disconnected) # Connect to specific COM port error = tracker.connectToDeviceOnComPort("COM15") if error.value() != AisErrorCode.Success: print(f"Connection failed: {error.message()}") sys.exit(1) # Or automatically connect all plugged devices num_devices = tracker.connectAllPluggedInDevices() print(f"Connected {num_devices} device(s)") # Get list of connected devices devices = tracker.getConnectedDevices() for device_name in devices: print(f"Available: {device_name}") app.exec() ``` ```cpp #include "AisDeviceTracker.h" #include #include int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); auto tracker = AisDeviceTracker::Instance(); // Connect signals QObject::connect(tracker, &AisDeviceTracker::newDeviceConnected, [](const QString& deviceName) { qDebug() << "Device connected:" << deviceName; }); QObject::connect(tracker, &AisDeviceTracker::deviceDisconnected, [](const QString& deviceName) { qDebug() << "Device disconnected:" << deviceName; }); // Connect to device AisErrorCode error = tracker->connectToDeviceOnComPort("COM15"); if (error != AisErrorCode::Success) { qDebug() << "Connection failed:" << error.message(); return 1; } return app.exec(); } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.