00001 #ifndef ZTT_DCS_FED_SERVER_HPP
00002 #define ZTT_DCS_FED_SERVER_HPP
00003
00004 #include "dim/dis.hxx"
00005 #include "FedMessenger.hpp"
00006 #include "FedCommand.hpp"
00007 #include "ConfigureFeeCom.hpp"
00008 #include "ConfigureFero.hpp"
00009 #include "ControlFeeCom.hpp"
00010 #include "ControlFero.hpp"
00011 #include "DataAccess.hpp"
00012
00013
00014 #include <vector>
00015
00016 namespace ztt { namespace dcs {
00017
00018
00022 #define FED_SERVER_INITIALIZED 0x0
00023
00027 #define FED_SERVER_RUNNING 0x1
00028
00032 #define FED_SERVER_STOPPED 0x2
00033
00034
00035 class InterCom;
00036
00047 class FedServer : public DimServer {
00048 public:
00049
00058 FedServer(InterCom* pInterCom, boost::shared_ptr<DataAccess> pDA) :
00059 mpInterCom(pInterCom), mDataAccess(pDA),
00060 mState(FED_SERVER_INITIALIZED),iclAck(FeeIclAck::createInstance()){
00061
00062 char* msgName = new char[strlen(FED_SERVER_NAME) + 10];
00063 msgName[sprintf(msgName, "%s_MSG", FED_SERVER_NAME)] = 0;
00064 mpFedMessenger = new FedMessenger(DETECTOR, msgName, this);
00065 delete[] msgName;
00066
00067 configFeeCom.reset(new ConfigureFeeCom("ConfigureFeeCom",this));
00068 configFero.reset( new ConfigureFero("ConfigureFero",this));
00069 controlFeeCom.reset(new ControlFeeCom("ControlFeeCom",this));
00070 controlFero.reset(new ControlFero("ControlFero",this));
00071
00072 };
00073
00077 virtual ~FedServer();
00078
00087 int publishServices();
00088
00089 virtual void commandHandler();
00090
00101 int executeCommand(char* pTarget, char* pIncomingCmnd, int size);
00102
00108 FedMessenger* getMessenger();
00109
00115 int getState() const;
00116
00125 void exitHandler() {};
00126
00135 int broadcastCommand(void* cmnd, int size);
00136
00137
00138 private:
00139
00140
00141
00142 boost::shared_ptr<ConfigureFeeCom> configFeeCom;
00143 boost::shared_ptr<ConfigureFero> configFero;
00144 boost::shared_ptr<ControlFeeCom> controlFeeCom;
00145 boost::shared_ptr<ControlFero> controlFero;
00149 InterCom* const mpInterCom;
00150
00154 boost::shared_ptr<DataAccess> mDataAccess;
00155
00161 std::vector<boost::shared_ptr<DimService> > mFedServiceCollection;
00162
00166 FedMessenger* mpFedMessenger;
00167
00168
00169 boost::scoped_ptr<FeeIclAck> iclAck;
00173 int mState;
00178
00179
00180
00192
00193
00194
00195 };
00196
00197
00198 inline int FedServer::getState() const {
00199 return mState;
00200 }
00201
00202 } }
00203
00204
00205 #endif