#ifndef ROC_BOARD_H #define ROC_BOARD_H #include "base/commons.h" #include "roc/Message.h" #include "base/Board.h" namespace roc { //! Represents the role the client of a board can have enum ClientRole { roleNone = base::roleNone, //!< no defined role roleObserver = base::roleObserver, //!< pure observer, no changes roleControl = base::roleControl, //!< allowed to change state, no DAQ roleDAQ = base::roleDAQ //!< full control including DAQ }; // symbolic names for ROC-related configuration parameters extern const char* xmlRocPool; extern const char* xmlTransportWindow; extern const char* xmlTransportKind; extern const char* xmlBoardAddr; extern const char* xmlRole; extern const char* xmlRocNumber; extern const char* xmlLowWater; extern const char* xmlHighWater; extern const char* xmlMsgFormat; extern const char* xmlFlushTime; extern const char* typeUdpDevice; extern const char* typeAbbDevice; enum ERocBufferTypes { rbt_RawRocData = 234 }; enum ETransportKinds { kind_UDP = base::kind_UDP, kind_ABB = base::kind_ABB, kind_File = base::kind_File }; enum EFrontendKinds { kind_nXYTER = 1, // normal nXYTER kind_oldFEET = 2, // old GET4, keep for historical reasons kind_FEET = 3, // new GET4 v1.0, kind_newNX = 4 // new readout for nXYTER with SysCore3 }; enum EBackendKinds { kind_Optic = 1, // normal Optic readout - CBMNet v1 kind_FX20 = 2, kind_FX40 = 3, kind_FX60 = 4, kind_newOptic = 5 // new optic readout - CBMNet v2 }; class Board : public base::Board { protected: Board(); virtual ~Board(); public: // -------------------------------------------------------------------- // methods for controlling ROC and components // -------------------------------------------------------------------- static uint32_t getRoclibVersion(); uint32_t getRocFpgaType(); uint32_t getRocSvnRev(); uint32_t getRocBuildTime(); uint32_t getRocHardwareVersion(); uint32_t getRocHardwareType(); //! Return frontend kinds - kind_nXYTER (1), kind_oldFEET (2) or kind_FEET (3) uint32_t getRocFrontendKind() { return getRocHardwareType() >> 16; } //! Return backend kinds - kind_Optic (1), kind_FX20 (2), kind_FX40 (3) or kind_FX60 (4) uint32_t getRocBackendKind() { return getRocHardwareType() & 0xffff; } //! Returns backend (Optic or UDP) version virtual uint32_t getRocBackendVersion() { return 0; } //! Returns locally stored ROC number uint32_t rocNumber() const { return boardNumber(); } //! Returns number from ROC directly, store fRocNumber variable uint32_t getRocNumber() { return getBoardNumber(); } void setRocNumber(uint32_t num) { setBoardNumber(num); } int uploadCommandsList(unsigned num, const base::OperList& lst, double tmout = 0.); int downloadCommandsList(unsigned num, base::OperList& lst, double tmout = 0.); int invokeCommandsList(unsigned num, double tmout = 0.); int uploadStartDaqCmdList(bool reset_frontend = false, bool reset_fifo = true); int uploadStopDaqCmdList(); virtual int invokeDLM(unsigned num, double tmout = 0.) { return 0; } void clearRocFifo(); void restartRoc(); virtual bool restartBoard() { restartRoc(); return true; } int getRocThrottleState(uint32_t& val); virtual unsigned GetBoardId() const { return rocNumber(); } // DAQ functions //! Activate DAQ. /*! * This method will initialize the data transport chain which brings * message data from the ROC. The details depend in the underlying * transport. By the daq starting commands list 0 is always executed. * This commands list can be initialized by \sa uploadStartDaqCmdList() * By default configuration (after \sa setToDefault()) frontend is initialized * (in case of nXYTER, timestamp logic initialization) and message * FIFO will be cleared. * * \sa suspendDaq(), stopDaq(), getNextBuffer() */ // virtual bool startDaq() = 0; //! suspendDaq /*! * Sends to ROC ROC_SUSPEND_DAQ command. ROC will produce stop message * and will deliver it sometime to host PC. User can continue to take data until * this message. Normally no more messages will be delivered after stop daq message. */ // virtual bool suspendDaq() = 0; //! stopDaq /*! * Complimentary function for startDaq. * Disables any new data requests, all coming data will be discarded */ // virtual bool stopDaq() = 0; //! getNextBuffer /*! * Returns pointer on the buffer which contains received messages. * \param len returns length of buffer in bytes. * Buffer is allocated by board itself, buffer content remains valid until next * call of getNextBuffer() or when daq is stopped. * Format of messages can be defined by \ref getMsgFormat() * To extract single messages from the buffer, \ref roc::Iterator class should be used * \sa \ref roc::Iterator getMsgFormat() */ //virtual bool getNextBuffer(void* &buf, unsigned& len, double tmout = 1.) = 0; //! getMsgFormat /*! * Returns message format like formatEth2, formatOptic2 and so on */ // virtual int getMsgFormat() const = 0; //! Sets flush timeout of data transport /*! * Local transport accumulates data in buffer and until buffer is not filled, * data is not delivered further. Flush timeout defines time interval, * when any amount of data will be flushed. * \param tmout timeout value in sec. */ //virtual void setFlushTimeout(double tmout) {} //! Sets to default values common ROC registers /*! * For a moment, initializes start/stop commands lists */ virtual int setToDefault(); //! enableCalibration /*! * Preliminary functionality for nXYTER calibration * Reconfigures nXYTER in test-trigger mode and fires several test pulses * \param period can has following values: * 0 - make calibration once * >0 - perform calibration periodically * <0 - disable calibration */ virtual bool enableCalibration(double period = 10., double calibr = 0.1, int cnt = -1) { return false; } virtual bool disableCalibration() { return enableCalibration(-1., -1., 0); } static bool IsUdpAddress(const char* name); static bool IsOpticAddress(const char* name); static bool IsLmdFileAddress(const char* name); static Board* Connect(const char* name, ClientRole role = roleDAQ); static bool Close(Board* brd); }; } #endif