#pragma once #include "Result.h" #include "sls_detector_defs.h" #include #include #include class multiSlsDetector; namespace sls { using ns = std::chrono::nanoseconds; using Positions = const std::vector &; using defs = slsDetectorDefs; /** * \class Detector */ class Detector { std::unique_ptr pimpl; public: /** * @param multi_id multi detector shared memory id */ Detector(int multi_id = 0); ~Detector(); // Acquisition /** * Blocking call, starts the receiver and detector. Acquired * the number of frames set. */ void acquire(); void startReceiver(Positions pos = {}); void stopReceiver(Positions pos = {}); /** * Get the acquiring flag. When true the detector blocks * any attempt to start a new acquisition. */ bool getAcquiringFlag() const; /** * Set the acquiring flag. This might have to done manually * after an acquisition was aborted. */ void setAcquiringFlag(bool value); /** Read back the run status of the receiver */ Result getReceiverStatus(Positions pos = {}); // Configuration /** * Frees the shared memory of this detector and all modules * belonging to it. */ void freeSharedMemory(); void setConfig(const std::string &fname); Result getHostname(Positions pos = {}) const; // void setHostname(Positions pos = {}); Result getStartingFrameNumber(Positions pos = {}) const; void setStartingFrameNumber(uint64_t value, Positions pos); // Bits and registers /** * Clears (sets to 0) bit number bitnr in register at addr. * @param addr address of the register * @param bitnr bit number to clear * @param pos detector position */ void clearBit(uint32_t addr, int bitnr, Positions pos = {}); /** * Sets bit number bitnr in register at addr to 1 * @param addr address of the register * @param bitnr bit number to clear * @param pos detector position */ void setBit(uint32_t addr, int bitnr, Positions pos = {}); /** * Reads 32 bit register from detector * @param addr address of the register * @returns value read from register */ Result getRegister(uint32_t addr, Positions pos = {}); /************************************************** * * * FILE, anything concerning file writing or * * reading goes here * * * * ************************************************/ /** * Returns receiver file name prefix. The actual file name * contains module id and file index as well. * @param pos detector positions * @returns file name prefix */ Result getFileName(Positions pos = {}) const; /** * Sets the receiver file name prefix * @param fname file name prefix */ void setFileName(const std::string &fname, Positions pos = {}); Result getFilePath(Positions pos = {}) const; void setFilePath(const std::string &fname, Positions pos = {}); Result getFileWrite(Positions pos = {}) const; void setFileWrite(bool value, Positions pos = {}); Result getFileOverWrite(Positions pos = {}) const; void setFileOverWrite(bool value, Positions pos = {}); // Time Result getExptime(Positions pos = {}) const; void setExptime(ns t, Positions pos = {}); Result getSubExptime(Positions pos = {}) const; void setSubExptime(ns t, Positions pos = {}); Result getPeriod(Positions pos = {}) const; void setPeriod(ns t, Positions pos = {}); // dhanya /** * Get multidetector Id * @returns multidetector Id */ int getMultiId() const; /** * Check version compatibility with detector software * @param pos detector position */ void checkDetectorVersionCompatibility(Positions pos = {}) const; /** * Check version compatibility with receiver software * @param pos detector position */ void checkReceiverVersionCompatibility(Positions pos = {}) const; /** * Get detector firmware version * @param pos detector position * @returns detector firmware version */ Result getDetectorFirmwareVersion(Positions pos = {}) const; /** * Get detector server version * @param pos detector position * @returns detector server version */ Result getDetectorServerVersion(Positions pos = {}) const; /** * Get detector serial number * @param pos detector position * @returns detector serial number */ Result getDetectorSerialNumber(Positions pos = {}) const; /** * Get Client Software version * @returns client software version */ Result getClientSoftwareVersion() const; /** * Get Receiver software version * @param pos detector position * @return receiver software version */ Result getReceiverSoftwareVersion(Positions pos = {}) const; /** * Get user details of shared memory * @returns string with user details */ std::string getUserDetails() const; /** * Frees shared memory and adds detectors to the list * Also updates local detector cache * @param name hostnames for the positions given */ void setHostname(const std::vector &name); /** * Get Detector type as an enum * @returns detector type */ defs::detectorType getDetectorTypeAsEnum() const; /** * Get Detector type as an enum * @param pos detector position * @returns detector type */ Result getDetectorTypeAsEnum(Positions pos = {}) const; /** * Returns detector type as a string * @param pos detector position * @returns detector type as string */ Result getDetectorTypeAsString(Positions pos = {}) const; }; } // namespace sls