Skip to content

InscoperAPI/API/Inscoper.h

Namespaces

Name
Inscoper
Inscoper namespace.

Classes

Name
class Inscoper::Bridge
The Bridge class is the main class of The Inscoper API.

Source code

#ifndef INSCOPER_H
#define INSCOPER_H

#include <Base/Box/EBoxType.h>
#include <Base/Box/UsbInfo.h>
#include <Base/Config/Config.h>
#include <Base/Description/DeviceDescription.h>
#include <Base/Device/AbstractSubDevice.h>
#include <Base/Device/Camera.h>
#include <Base/Diag/DiagResults.h>
#include <Base/Dimension/Dimension.h>
#include <Base/Image/ImageListener.h>
#include <Base/Recipe/Recipe.h>
#include <Base/Sequence/SequenceHandler.h>
#include <Base/Sequence/SequenceListener.h>
#include <Base/Status/CurrentStatusAction.h>
#include <Base/Status/ModifiableStatusParam.h>
#include <Base/Status/Status.h>
#include <Base/Utils/ErrorListener.h>
#include <Base/Utils/FunctionListener.h>
#include <Global.h>
#include <Shared/Exception/InscoperException.h>
#include <Shared/Log/ELogLevel.h>
#include <Shared/Log/ELogMode.h>
#include <Shared/Log/LogListener.h>

#include <string>
#include <vector>

namespace Inscoper {

class INSCOPER_EXPORT Bridge {
public:
  Bridge();

  virtual ~Bridge();

  //          Configuration / Initialisation      //

  void setLibraryPaths(const std::vector<std::string> &libraryPaths);

  void loadConfigFile(const std::string &path = "") INSCOPER_EXCEPTION;

  Inscoper::ConfigPtr readConfigFile(const std::string &path = "") INSCOPER_EXCEPTION;

  void loadConfig(const Inscoper::ConfigPtr &config) INSCOPER_EXCEPTION;

  void saveConfig(const std::string &path, const Inscoper::ConfigPtr &config) INSCOPER_EXCEPTION;

  void saveCurrentConfig(const std::string &path = "") INSCOPER_EXCEPTION;

  std::vector<Inscoper::RecipePtr> readRecipeFile(const std::string &path = "") INSCOPER_EXCEPTION;

  void saveRecipes(const std::string &path, const std::vector<Inscoper::RecipePtr> &recipes) INSCOPER_EXCEPTION;

  void initDevices() INSCOPER_EXCEPTION;

  void initDevice(const std::string &deviceId) INSCOPER_EXCEPTION;

  void initDevices(const std::vector<std::string> &deviceIdList) INSCOPER_EXCEPTION;

  std::vector<std::string> getLoadedDevices();

  std::vector<std::string> getInitializedDevices();

  std::vector<Inscoper::SubDeviceId> getInitializedSubDeviceIds();

  bool closeDevices();

  bool closeDevice(const std::string &deviceId);

  bool closeDevices(const std::vector<std::string> &deviceIdList);

  void close() INSCOPER_EXCEPTION;

  //                  Description                 //

  std::vector<Inscoper::DeviceDescriptionPtr> getDeviceDescriptionList() INSCOPER_EXCEPTION;

  std::vector<Inscoper::DeviceDescriptionPtr> loadDeviceDescriptionList(const std::string &filename) INSCOPER_EXCEPTION;

  void saveDeviceDescriptionList(const std::vector<Inscoper::DeviceDescriptionPtr> &deviceDescriptionList,
                                 const std::string &filename) INSCOPER_EXCEPTION;

  //                  Sequence                    //

  Inscoper::StatusPtr loadSequence(unsigned short sequenceNumber, const std::string &recipeName,
                                   const std::string &paramsFile, const Inscoper::StatusPtr &currentStatus = nullptr,
                                   int printIndex = -1,
                                   Inscoper::SequenceHandlerPtr handler = nullptr) INSCOPER_EXCEPTION;

  Inscoper::StatusPtr loadSequence(unsigned short sequenceNumber, const std::string &recipeName,
                                   const std::vector<Inscoper::DimensionPtr> &dimensionList,
                                   const Inscoper::StatusPtr &currentStatus = nullptr, int printIndex = -1,
                                   Inscoper::SequenceHandlerPtr handler = nullptr) INSCOPER_EXCEPTION;

  Inscoper::StatusPtr loadSequence(unsigned short sequenceNumber, const std::string &recipeName,
                                   const std::vector<Inscoper::StatusPtr> &statusList,
                                   const Inscoper::StatusPtr &currentStatus = nullptr, int printIndex = -1,
                                   Inscoper::SequenceHandlerPtr handler = nullptr) INSCOPER_EXCEPTION;

  Inscoper::StatusPtr loadAndRunSequence(unsigned short sequenceNumber, const std::string &recipeName,
                                         const std::vector<Inscoper::StatusPtr> &statusList,
                                         const Inscoper::StatusPtr &currentStatus = nullptr, int printIndex = -1,
                                         bool async = false) INSCOPER_EXCEPTION;

  void runSequence(unsigned short sequenceNumber, bool async = false) INSCOPER_EXCEPTION;

  void waitUntilSequenceFinished(unsigned short sequenceNumber) INSCOPER_EXCEPTION;

  void pauseSequence(unsigned short sequenceNumber) INSCOPER_EXCEPTION;

  void continueSequence(unsigned short sequenceNumber) INSCOPER_EXCEPTION;

  void stopSequence(unsigned short sequenceNumber) INSCOPER_EXCEPTION;

  void removeSequence(unsigned short sequenceNumber) INSCOPER_EXCEPTION;

  void modifySequence(unsigned short sequenceNumber,
                      const std::vector<unsigned int> &modifierIndexes) INSCOPER_EXCEPTION;

  Inscoper::StatusPtr addBackgroundSequence(unsigned short sequenceIndex, const std::string &recipeName,
                                            const std::string &paramsFile) INSCOPER_EXCEPTION;

  Inscoper::StatusPtr
  addBackgroundSequence(unsigned short sequenceIndex, const std::string &recipeName,
                        const std::vector<Inscoper::DimensionPtr> &dimensionList) INSCOPER_EXCEPTION;

  Inscoper::StatusPtr addBackgroundSequence(unsigned short sequenceIndex, const std::string &recipeName,
                                            const std::vector<Inscoper::StatusPtr> &statusList) INSCOPER_EXCEPTION;

  void removeBackgroundSequence(unsigned short sequenceIndex) INSCOPER_EXCEPTION;

  void addSequenceListener(Inscoper::SequenceListener *listener);

  void removeSequenceListener(Inscoper::SequenceListener *listener);

  //                  Devices                     //

  void addAbstractSubDevice(Inscoper::AbstractSubDevice *subDevice) INSCOPER_EXCEPTION;

  void removeAbstractSubDevice(const Inscoper::SubDeviceId &subDeviceId) INSCOPER_EXCEPTION;

  Inscoper::CameraPtr getCamera(const std::string &id) INSCOPER_EXCEPTION;

  bool isHardwareCropAvailable(const std::string &id) INSCOPER_EXCEPTION;

  void setHardwareCrop(const std::string &id, const std::vector<Inscoper::RoiCrop> &crops) INSCOPER_EXCEPTION;

  std::vector<Inscoper::RoiCrop> getHardwareCrop(const std::string &id) INSCOPER_EXCEPTION;

  void createTimeDevice(unsigned short index, const char *startRecipeId = nullptr,
                        const char *waitRecipeId = nullptr) INSCOPER_EXCEPTION;

  Inscoper::SubDeviceId getStartTimerSubDeviceId(unsigned short index) INSCOPER_EXCEPTION;

  Inscoper::SubDeviceId getWaitTimerSubDeviceId(unsigned short index) INSCOPER_EXCEPTION;

  Inscoper::DiagResultsPtr runDeviceDiagnosis(const Inscoper::DeviceDescriptionPtr &deviceDesc,
                                              const Inscoper::DriverConfigPtr &driverConfig) INSCOPER_EXCEPTION;

  void saveDiagResults(const Inscoper::DiagResultsPtr &diagResults, const std::string &filename);

  Inscoper::DiagResultsPtr loadDiagResults(const std::string &filename);

  void saveDiagResultsList(const std::vector<Inscoper::DiagResultsPtr> &diagResultsList, const std::string &filename);

  std::vector<Inscoper::DiagResultsPtr> loadDiagResultsList(const std::string &filename);

  std::vector<Inscoper::SubDeviceId> getValueConditionChildren(const Inscoper::SubDeviceId &subDeviceId,
                                                               const std::string &recipeName) INSCOPER_EXCEPTION;

  std::vector<Inscoper::SubDeviceId> getValueConditionParents(const Inscoper::SubDeviceId &subDeviceId,
                                                              const std::string &recipeName) INSCOPER_EXCEPTION;

  std::vector<Inscoper::SubDeviceId> getValueConditionSiblings(const Inscoper::SubDeviceId &subDeviceId,
                                                               const std::string &recipeName) INSCOPER_EXCEPTION;

  std::vector<Inscoper::SubDeviceId> getCallConditionSubDeviceIdList(const Inscoper::SubDeviceId &subDeviceId,
                                                                     const std::string &recipeName) INSCOPER_EXCEPTION;

  std::vector<std::string> getCustomDriverAvailableDevices(const std::string &driverName) INSCOPER_EXCEPTION;

  // Inscoper::ESubDeviceType getSubDeviceType(const Inscoper::SubDeviceId&
  // subDeviceId);

  void addFunctionListener(Inscoper::FunctionListener *listener);

  void addFunctionListener(Inscoper::FunctionListener *listener, const std::string &deviceId);

  void addFunctionListener(Inscoper::FunctionListener *listener, const Inscoper::SubDeviceId &subDeviceId);

  void addFunctionListener(Inscoper::FunctionListener *listener, const Inscoper::SubDeviceId &subDeviceId,
                           Inscoper::EFunctionType functionType);

  void removeFunctionListener(Inscoper::FunctionListener *listener);

  //                  Values                      //

  bool hasGetFunction(const Inscoper::SubDeviceId &subDeviceId) INSCOPER_EXCEPTION;

  bool hasSetFunction(const Inscoper::SubDeviceId &subDeviceId) INSCOPER_EXCEPTION;

  bool hasCheckFunction(const Inscoper::SubDeviceId &subDeviceId) INSCOPER_EXCEPTION;

  void setValue(const Inscoper::SubDeviceId &subDeviceId) INSCOPER_EXCEPTION;

  void setValue(const Inscoper::SubDeviceId &subDeviceId, const std::string &value) INSCOPER_EXCEPTION;

  void setValue(const Inscoper::SubDeviceId &subDeviceId, unsigned char value) INSCOPER_EXCEPTION;

  void setValue(const Inscoper::SubDeviceId &subDeviceId, char value) INSCOPER_EXCEPTION;

  void setValue(const Inscoper::SubDeviceId &subDeviceId, unsigned short value) INSCOPER_EXCEPTION;

  void setValue(const Inscoper::SubDeviceId &subDeviceId, short value) INSCOPER_EXCEPTION;

  void setValue(const Inscoper::SubDeviceId &subDeviceId, unsigned int value) INSCOPER_EXCEPTION;

  void setValue(const Inscoper::SubDeviceId &subDeviceId, int value) INSCOPER_EXCEPTION;

  void setValue(const Inscoper::SubDeviceId &subDeviceId, unsigned long long int value) INSCOPER_EXCEPTION;

  void setValue(const Inscoper::SubDeviceId &subDeviceId, long long int value) INSCOPER_EXCEPTION;

  void setValue(const Inscoper::SubDeviceId &subDeviceId, float value) INSCOPER_EXCEPTION;

  void setValue(const Inscoper::SubDeviceId &subDeviceId, double value) INSCOPER_EXCEPTION;

  std::string getStringValue(const Inscoper::SubDeviceId &subDeviceId) INSCOPER_EXCEPTION;

  unsigned char getUnsignedCharValue(const Inscoper::SubDeviceId &subDeviceId) INSCOPER_EXCEPTION;

  char getCharValue(const Inscoper::SubDeviceId &subDeviceId) INSCOPER_EXCEPTION;

  unsigned short getUnsignedShortValue(const Inscoper::SubDeviceId &subDeviceId) INSCOPER_EXCEPTION;

  short getShortValue(const Inscoper::SubDeviceId &subDeviceId) INSCOPER_EXCEPTION;

  unsigned int getUnsignedIntValue(const Inscoper::SubDeviceId &subDeviceId) INSCOPER_EXCEPTION;

  int getIntValue(const Inscoper::SubDeviceId &subDeviceId) INSCOPER_EXCEPTION;

  unsigned long long int getUnsignedLongValue(const Inscoper::SubDeviceId &subDeviceId) INSCOPER_EXCEPTION;

  long long int getLongValue(const Inscoper::SubDeviceId &subDeviceId) INSCOPER_EXCEPTION;

  float getFloatValue(const Inscoper::SubDeviceId &subDeviceId) INSCOPER_EXCEPTION;

  double getDoubleValue(const Inscoper::SubDeviceId &subDeviceId) INSCOPER_EXCEPTION;

  Inscoper::StatusParamPtr getValue(const Inscoper::StatusParamPtr &param) INSCOPER_EXCEPTION;

  void checkValue(const Inscoper::SubDeviceId &subDeviceId) INSCOPER_EXCEPTION;

  void checkValue(const Inscoper::SubDeviceId &subDeviceId, const std::string &value) INSCOPER_EXCEPTION;

  void checkValue(const Inscoper::SubDeviceId &subDeviceId, unsigned char value) INSCOPER_EXCEPTION;

  void checkValue(const Inscoper::SubDeviceId &subDeviceId, char value) INSCOPER_EXCEPTION;

  void checkValue(const Inscoper::SubDeviceId &subDeviceId, unsigned short value) INSCOPER_EXCEPTION;

  void checkValue(const Inscoper::SubDeviceId &subDeviceId, short value) INSCOPER_EXCEPTION;

  void checkValue(const Inscoper::SubDeviceId &subDeviceId, unsigned int value) INSCOPER_EXCEPTION;

  void checkValue(const Inscoper::SubDeviceId &subDeviceId, int value) INSCOPER_EXCEPTION;

  void checkValue(const Inscoper::SubDeviceId &subDeviceId, unsigned long long int value) INSCOPER_EXCEPTION;

  void checkValue(const Inscoper::SubDeviceId &subDeviceId, long long int value) INSCOPER_EXCEPTION;

  void checkValue(const Inscoper::SubDeviceId &subDeviceId, float value) INSCOPER_EXCEPTION;

  void checkValue(const Inscoper::SubDeviceId &subDeviceId, double value) INSCOPER_EXCEPTION;

  std::vector<Inscoper::SubDeviceId> getModifiedSubDevices(const std::string &deviceId);

  bool isAccessibleInSequence(const Inscoper::SubDeviceId &subDeviceId) INSCOPER_EXCEPTION;

  void setClampMode(bool clampMode);

  //                  Constraints                 //

  bool hasMaxValue(const Inscoper::SubDeviceId &subDeviceId) INSCOPER_EXCEPTION;

  bool hasMinValue(const Inscoper::SubDeviceId &subDeviceId) INSCOPER_EXCEPTION;

  bool hasStepValue(const Inscoper::SubDeviceId &subDeviceId) INSCOPER_EXCEPTION;

  bool hasListValue(const Inscoper::SubDeviceId &subDeviceId) INSCOPER_EXCEPTION;

  bool isReadOnly(const Inscoper::SubDeviceId &subDeviceId) INSCOPER_EXCEPTION;

  double getMaxValue(const Inscoper::SubDeviceId &subDeviceId) INSCOPER_EXCEPTION;

  double getMinValue(const Inscoper::SubDeviceId &subDeviceId) INSCOPER_EXCEPTION;

  double getStepValue(const Inscoper::SubDeviceId &subDeviceId) INSCOPER_EXCEPTION;

  INSCOPER_DEPRECATED("use 'getKeyValueMap' instead")
  std::vector<std::string> getListValue(const Inscoper::SubDeviceId &subDeviceId) INSCOPER_EXCEPTION;

  const std::map<std::string, std::string>
  getKeyValueMap(const Inscoper::SubDeviceId &subDeviceId) const INSCOPER_EXCEPTION;

  Inscoper::EParamType getParamType(const Inscoper::SubDeviceId &subDeviceId) INSCOPER_EXCEPTION;

  //                  Status                      //

  void saveStatusListToXML(const std::string &xmlfilename,
                           const std::vector<Inscoper::StatusPtr> &statusList) INSCOPER_EXCEPTION;

  void saveDimensionListToXML(const std::string &xmlfilename,
                              const std::vector<Inscoper::DimensionPtr> &dimensionList) INSCOPER_EXCEPTION;

  Inscoper::StatusPtr getCurrentStatus() INSCOPER_EXCEPTION;

  Inscoper::StatusPtr getCurrentStatus(const Inscoper::SubDeviceId &subDeviceId) INSCOPER_EXCEPTION;

  Inscoper::StatusPtr getCurrentStatus(const std::vector<Inscoper::SubDeviceId> &subDeviceList) INSCOPER_EXCEPTION;

  void getCurrentStatus(Inscoper::CurrentStatusAction *action) INSCOPER_EXCEPTION;

  void getCurrentStatus(const Inscoper::SubDeviceId &subDeviceId,
                        Inscoper::CurrentStatusAction *action) INSCOPER_EXCEPTION;

  void getCurrentStatus(const std::vector<Inscoper::SubDeviceId> &subDeviceList,
                        Inscoper::CurrentStatusAction *action) INSCOPER_EXCEPTION;

  void setCurrentStatus(const Inscoper::StatusPtr &status, bool async = false) INSCOPER_EXCEPTION;

  std::vector<Inscoper::StatusPtr> getStatusList(const std::vector<Inscoper::DimensionPtr> &dimensions);

  //                  Image                       //

  void addImageListener(Inscoper::ImageListener *listener, const char *cameraId = nullptr);

  void removeImageListener(Inscoper::ImageListener *listener, const char *cameraId = nullptr);

  void removeImageListener(const char *cameraId);

  void saveImages(const std::string &filename, const std::vector<Inscoper::ImagePtr> &images) INSCOPER_EXCEPTION;

  std::vector<Inscoper::ImagePtr> loadImages(const std::string &filename) INSCOPER_EXCEPTION;

  //                  Version                     //

  std::string getVersion();

  std::string getFirmwareVersion() INSCOPER_EXCEPTION;

  //                  Logging                     //

  void initLogger(Inscoper::ELogMode mode, Inscoper::ELogLevel level, const char *filename = nullptr,
                  Inscoper::LogListener *listener = nullptr) INSCOPER_EXCEPTION;

  void setLogLevel(Inscoper::ELogLevel level);

  void removeLogListener(Inscoper::LogListener *listener);

  Inscoper::ELogLevel getLogLevel();

  void initInscoperBoxLogger(Inscoper::ELogMode mode, Inscoper::ELogLevel level, const char *filename = nullptr,
                             Inscoper::LogListener *listener = nullptr) INSCOPER_EXCEPTION;

  void setInscoperBoxLogLevel(Inscoper::ELogLevel level);

  void removeInscoperBoxLogListener(Inscoper::LogListener *listener);

  Inscoper::ELogLevel getInscoperBoxLogLevel();

  void setLogDirectory(const std::string &path);

  //                  Others                      //

  void addErrorListener(Inscoper::ErrorListener *listener);

  void removeErrorListener(Inscoper::ErrorListener *listener);

  //                  Inscoper Boxes              //

  void updateFirmware(const std::string &firmwarePath) INSCOPER_EXCEPTION;

  bool connectToInscoperBox() INSCOPER_EXCEPTION;

  bool disconnectToInscoperBox() INSCOPER_EXCEPTION;

  bool isConnectedToInscoperBox() INSCOPER_EXCEPTION;

  void restartInscoperBox() INSCOPER_EXCEPTION;

  std::vector<Inscoper::UsbInfo> getInscoperBoxUsbView() INSCOPER_EXCEPTION;

  void resetInscoperBoxUsbView(double secondsToWaitBeforeReconnection) INSCOPER_EXCEPTION;

  Inscoper::EBoxType getInscoperBoxType() INSCOPER_EXCEPTION;

  //        Drivers (Custom, Micromanager)        //

  // bool connectToMicromanager() INSCOPER_EXCEPTION;
/*
    bool disconnectToMicromanager() INSCOPER_EXCEPTION;*/

  // bool connectToCustomDrivers() INSCOPER_EXCEPTION;

  // bool disconnectToCustomDrivers() INSCOPER_EXCEPTION;

  //                  License                     //

  bool checkLicense() INSCOPER_EXCEPTION;

  void setLicensePath(const std::string &path);

  bool hasLicenseOption(const std::string &option) INSCOPER_EXCEPTION;

  bool hasLicenseExpirationDate();

  unsigned int getLicenseDaysLeft();

  Inscoper::SubDeviceId getRunSequenceSubDeviceId();

private:
  bool _closed{false};
};

} // namespace Inscoper

#endif // INSCOPER_H

Updated on 2026-09-03 at 12:14:17 +0200