HORIBA C++ SDK
Library for HORIBA devices
Loading...
Searching...
No Matches
HORIBA CPP SDK

Actions Status Actions Status Actions Status Actions Status Actions Status

doc

horiba-cpp-sdk is a C++ library that provides source code for the development with HORIBA devices.


⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️⬇️

Warning
This SDK is under development and not yet released.
Important
For this C++ code to work, the SDK from HORIBA has to be purchased, installed and licensed. The code in this repo and the SDK are under development and not yet released for public use!

⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️


📦 About this repository

horiba-cpp-sdk is a library that provides source code for the development of custom applications that include interaction with HORIBA devices, namely monochromators and multichannel detectors (e.g. CCD cameras). Future versions of this package will include access to more devices. The SDK exists for several programming languages:

☑️ Prerequisites

  • CMake 3.22
  • C++20 compiler, see Dependency Setup for mor information.
  • ICL.exe installed as part of the HORIBA SDK, licensed and activated. The HORIBA SDK can be purchased by contacting the Horiba Support and sending a message to the Scientific business segment, specifying no division and selecting the sales department
  • To make sure that the USB devices do not get disconnected, uncheck the following boxes in the properties

    generic usb hub properties

🛠️ Getting Started

Warning
This example only works under Windows.

Prerequisites

  1. Create a new folder with the following structure:

    horiba_basic_example
    ├── CMakeLists.txt
    └── main.cpp
  2. Get the CPM.cmake CMakeLists script from https://github.com/cpm-cmake/CPM.cmake/releases/tag/v0.38.7 and put it in the cmake folder

    Or get the latest using the following command:

    mkdir -p cmake
    wget -O cmake/CPM.cmake https://github.com/cpm-cmake/CPM.cmake/releases/latest/download/get_cpm.cmake
  3. Create a CMakeLists.txt in the root folder:

    CMakeLists.txt

    cmake_minimum_required(VERSION 3.22)
    set(CMAKE_CXX_STANDARD 20)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    project(horiba_cpp_example)
    include(cmake/CPM.cmake)
    CPMAddPackage(
    NAME horiba-cpp-sdk
    GITHUB_REPOSITORY HORIBAEzSpecSDK/cpp-sdk
    GIT_TAG v0.2.1
    OPTIONS
    # Uncomment if you enable hardening options
    "horiba_cpp_sdk_ENABLE_HARDENING OFF"
    "horiba_cpp_sdk_ENABLE_GLOBAL_HARDENING OFF"
    )
    add_executable(horiba_cpp_example main.cpp)
    target_link_libraries(horiba_cpp_example PRIVATE
    horiba_cpp_sdk::horiba_cpp_sdk
    )
  4. Put the following into the main.cpp:

    main.cpp

    #include <chrono>
    #include <iostream>
    #include <thread>
    #include <nlohmann/json.hpp>
    auto main(int argc, char *argv[]) -> int {
    using namespace nlohmann;
    using namespace horiba::devices;
    using namespace horiba::os;
    using namespace horiba::communication;
    using namespace std;
    auto icl_process = std::make_shared<WindowsProcess>(R"(C:\Program Files\HORIBA Scientific\SDK\)", R"(icl.exe)");
    auto icl_device_manager = ICLDeviceManager(icl_process);
    icl_device_manager.start();
    icl_device_manager.discover_devices();
    const auto ccds = icl_device_manager.charge_coupled_devices();
    const auto ccd = ccds[0];
    const auto monos = icl_device_manager.monochromators();
    const auto mono = monos[0];
    const auto timeout = chrono::seconds(180);
    try {
    ccd->open();
    mono->open();
    mono->wait_until_ready(timeout);
    mono->home();
    mono->wait_until_ready(timeout);
    auto target_wavelength = 123.0;
    mono->move_to_target_wavelength(target_wavelength);
    mono->wait_until_ready(timeout);
    ccd->set_acquisition_format(1, ChargeCoupledDevice::AcquisitionFormat::SPECTRA);
    ccd->set_acquisition_count(1);
    ccd->set_exposure_time(2);
    ccd->set_region_of_interest();
    if (ccd->get_acquisition_ready()) {
    auto open_shutter = true;
    ccd->set_acquisition_start(open_shutter);
    // wait a short time for the acquisition to start
    std::this_thread::sleep_for(std::chrono::milliseconds(200));
    while (ccd->get_acquisition_busy()) {
    std::this_thread::sleep_for(std::chrono::milliseconds(500));
    }
    auto raw_data =
    std::any_cast<nlohmann::json>(ccd->get_acquisition_data());
    cout << raw_data.dump() << endl;
    }
    } catch (const exception &e) {
    cout << e.what() << endl;
    ccd->close();
    mono->close();
    icl_device_manager.stop();
    return 1;
    }
    try {
    ccd->close();
    mono->close();
    icl_device_manager.stop();
    } catch (const exception &e) {
    cout << e.what() << endl;
    }
    return 0;
    }
    Device Manager using the ICL to communicate with connected Horiba devices.
    Definition icl_device_manager.h:22
    Definition command.h:9
    Definition device_manager.h:7
    Definition ccds_discovery.h:11
    Definition process.h:4
  5. Run cmake -S . -B ./build -G Ninja (replace Ninja with "Unix Makefiles" if you don't have Ninja or with "Visual Studio 17 2022" if you use Visual Studio 2022)
  6. Run cmake --build build
  7. Launch the example with ./build/horiba_cpp_example

🏗️ Architecture

The functionality is distributed over two parts, the instrument control layer (ICL) and the github source code. This split is shown in the following image:

The ICL itself is sold and distributed by HORIBA. The source code to communicate with the ICL and drive the instruments is located in this repo for C++, but can be also found for Python, C#, C++ and LabVIEW as described above. The communication between SDK and ICL is websocket based. I.e. in essence the ICL is steered by a command and control pattern where commands and their replies are JSON commands.

🔗 Examples

For more details on the usage of the library and a list of examples, see:

👩‍💻 First steps as contributor

For contributors to the library:

Credits