Skip to content
Base_DAQ.h 1.83 KiB
Newer Older
Valerio Pastore's avatar
Valerio Pastore committed
#ifndef BASEDAQ_H_
#define BASEDAQ_H_


#include <Base_Monitor.h>
#include <Base_Protocol.h>
#include <Base_Archiver.h>
#include <Base_Provider.h>
Valerio Pastore's avatar
Valerio Pastore committed
#include <Base_Packet.h>
Valerio Pastore's avatar
Valerio Pastore committed

namespace inaf::oasbo::DAQ{
class BaseDAQ {
Valerio Pastore's avatar
Valerio Pastore committed
public:
	enum Status {
	    STOP = -1,
	    READY = 0,
	    IDLE = 1,
	    RUN = 2
	};
Valerio Pastore's avatar
Valerio Pastore committed

protected:
	Status currentState;
	Status nextState;
Valerio Pastore's avatar
Valerio Pastore committed
	bool changeStateFlag = false;
	ConnectionProtocols::BaseProtocol *socket;
	Archivers::BaseArchiver *archiver;
	Providers::BaseProvider *provider;
	Monitors::BaseMonitor *monitor;
Valerio Pastore's avatar
Valerio Pastore committed
public:
	void setProtocol(ConnectionProtocols::BaseProtocol &socket){this->socket = &socket;}
	void setArchiver(Archivers::BaseArchiver &archiver){this->archiver = &archiver;}
	void setProvider(Providers::BaseProvider &provider){this->provider = &provider;}
	void setMonitor(Monitors::BaseMonitor &monitor){this->monitor = &monitor;}
	void setCurrentState(Status currentState){this->currentState = currentState;}
	void setNextState(Status nextState){this->nextState = nextState;}
Valerio Pastore's avatar
Valerio Pastore committed
	void setChangeStateFlag(bool flag){this->changeStateFlag = flag;}

	ConnectionProtocols::BaseProtocol * getSocketPtr(){return this->socket;}
	Archivers::BaseArchiver *getArchiverPtr(){return this->archiver;}
	Providers::BaseProvider * getProviderPtr(){return this->provider;}
	Monitors::BaseMonitor * getMonitorPtr(){return this->monitor;}
	Status getCurrentState(){return this->currentState;}
	Status getNextState(){return this->nextState;}
Valerio Pastore's avatar
Valerio Pastore committed
	int getChangeStateFlag(){return this->changeStateFlag;}

	virtual void init() = 0;
	virtual void start(Status initialState,PacketLib::BasePacket &) = 0;
Valerio Pastore's avatar
Valerio Pastore committed
	virtual void stop() = 0;
	virtual void switchState(const Status) = 0;
Valerio Pastore's avatar
Valerio Pastore committed
	virtual int deliverPacket(PacketLib::BasePacket &) = 0;
Valerio Pastore's avatar
Valerio Pastore committed

	virtual ~BaseDAQ(){
		delete socket;
		delete provider;
		delete archiver;
		delete monitor;
	}
};
Valerio Pastore's avatar
Valerio Pastore committed
#endif /* BASEDAQ_H_ */