CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/EventFilter/StorageManager/src/FUProxy.cc

Go to the documentation of this file.
00001 // $Id: FUProxy.cc,v 1.7 2011/04/07 08:01:40 mommsen Exp $
00003 
00004 #include "EventFilter/StorageManager/interface/Exception.h"
00005 #include "EventFilter/StorageManager/interface/FUProxy.h"
00006 #include "EventFilter/Utilities/interface/i2oEvfMsgs.h"
00007 
00008 #include <toolbox/mem/Reference.h>
00009 #include <toolbox/mem/MemoryPoolFactory.h>
00010 #include <toolbox/mem/exception/Exception.h>
00011 
00012 #include <i2o/Method.h>
00013 #include <i2o/utils/AddressMap.h>
00014 
00015 #include <xcept/tools.h>
00016 
00017 #include <iostream> 
00018 #include <sstream>
00019 
00020 namespace stor {
00021   
00022   FUProxy::FUProxy
00023   (
00024     xdaq::ApplicationDescriptor *smAppDesc,
00025     xdaq::ApplicationDescriptor *fuAppDesc,
00026     xdaq::ApplicationContext    *smAppContext,
00027     toolbox::mem::Pool          *msgPool
00028   ) 
00029   : smAppDesc_(smAppDesc),
00030     fuAppDesc_(fuAppDesc),
00031     smAppContext_(smAppContext),
00032     msgPool_(msgPool)
00033   {}
00034   
00035   void FUProxy::sendDQMDiscard(const int& rbBufferId)
00036   {
00037     sendDiscardMsg(rbBufferId, I2O_FU_DQM_DISCARD, sizeof(I2O_FU_DQM_DISCARD_MESSAGE_FRAME));
00038   }
00039   
00040   void FUProxy::sendDataDiscard(const int& rbBufferId)
00041   {
00042     sendDiscardMsg(rbBufferId, I2O_FU_DATA_DISCARD, sizeof(I2O_FU_DATA_DISCARD_MESSAGE_FRAME));
00043   }
00044   
00045   void FUProxy::sendDiscardMsg
00046   (
00047     const int& rbBufferId,
00048     const int& msgId,
00049     const size_t& msgSize
00050   )
00051   {
00052     try {
00053       toolbox::mem::Reference* bufRef=
00054         toolbox::mem::getMemoryPoolFactory()->getFrame(msgPool_,msgSize);
00055       
00056       // message pointer
00057       I2O_MESSAGE_FRAME* stdMsg = 
00058         (I2O_MESSAGE_FRAME*)bufRef->getDataLocation();
00059       I2O_PRIVATE_MESSAGE_FRAME* pvtMsg =
00060         (I2O_PRIVATE_MESSAGE_FRAME*)stdMsg;
00061       I2O_FU_DATA_DISCARD_MESSAGE_FRAME* msg =
00062         (I2O_FU_DATA_DISCARD_MESSAGE_FRAME*)stdMsg;
00063       
00064       // set message frame
00065       stdMsg->MessageSize     = msgSize >> 2;
00066       stdMsg->InitiatorAddress= i2o::utils::getAddressMap()->getTid(smAppDesc_);
00067       stdMsg->TargetAddress   = i2o::utils::getAddressMap()->getTid(fuAppDesc_);
00068       stdMsg->Function        = I2O_PRIVATE_MESSAGE;
00069       stdMsg->VersionOffset   = 0;
00070       stdMsg->MsgFlags        = 0;  
00071       
00072       // set private message frame
00073       pvtMsg->XFunctionCode   = msgId;
00074       pvtMsg->OrganizationID  = XDAQ_ORGANIZATION_ID;
00075       
00076       // set fu data discard message frame
00077       msg->rbBufferID         = rbBufferId;
00078       
00079       // set buffer size
00080       bufRef->setDataSize(msgSize);
00081       
00082       // post frame
00083       smAppContext_->postFrame(bufRef,smAppDesc_,fuAppDesc_);
00084     }
00085     catch (toolbox::mem::exception::Exception& e)
00086     {
00087       XCEPT_RETHROW(exception::IgnoredDiscard,
00088         "FUProxy failed to allocate buffer reference!", e);
00089     }
00090     catch (xcept::Exception &e)
00091     {
00092       XCEPT_RETHROW(exception::IgnoredDiscard,
00093         "FUProxy failed to post discard message!", e);
00094     }
00095   }
00096   
00097 } // namespace stor
00098 
00099 
00106 
00107