12 #include "xdaq/Application.h"
14 #include "toolbox/mem/Reference.h"
15 #include "toolbox/mem/MemoryPoolFactory.h"
16 #include "toolbox/mem/exception/Exception.h"
18 #include "i2o/Method.h"
19 #include "i2o/utils/AddressMap.h"
21 #include "xcept/tools.h"
36 SMProxy::SMProxy(xdaq::ApplicationDescriptor *fuAppDesc,
37 xdaq::ApplicationDescriptor *smAppDesc,
38 xdaq::ApplicationContext *fuAppContext,
39 toolbox::mem::Pool *i2oPool)
40 : log_(fuAppContext->getLogger())
41 , fuAppDesc_(fuAppDesc)
42 , smAppDesc_(smAppDesc)
43 , fuAppContext_(fuAppContext)
95 while ((next=next->getNextReference()));
98 fuAppContext_->postFrame(bufRef,fuAppDesc_,smAppDesc_);
101 string msg=
"Failed to post INIT Message.";
138 while ((next=next->getNextReference()));
141 fuAppContext_->postFrame(bufRef,fuAppDesc_,smAppDesc_);
144 string errmsg=
"Failed to post DATA Message.";
145 LOG4CPLUS_FATAL(log_,errmsg);
181 while ((next=next->getNextReference()));
184 fuAppContext_->postFrame(bufRef,fuAppDesc_,smAppDesc_);
187 string errmsg=
"Failed to post ERROR Message.";
188 LOG4CPLUS_FATAL(log_,errmsg);
225 while ((next=next->getNextReference()));
228 fuAppContext_->postFrame(bufRef,fuAppDesc_,smAppDesc_);
231 string errmsg=
"Failed to post DQM Message.";
232 LOG4CPLUS_FATAL(log_,errmsg);
255 UInt_t fragmentCount=(dataSize/fragmentDataSizeMax);
256 if (dataSize%fragmentDataSizeMax) ++fragmentCount;
258 UInt_t currentPosition =0;
259 UInt_t remainingDataSize=dataSize;
266 for (
UInt_t iFragment=0;iFragment<fragmentCount;iFragment++) {
268 UInt_t fragmentDataSize=fragmentDataSizeMax;
269 UInt_t fragmentSize =fragmentDataSize+headerSize;
271 if (remainingDataSize<fragmentDataSizeMax) {
272 fragmentDataSize=remainingDataSize;
273 fragmentSize=fragmentDataSize+headerSize;
274 if (fragmentSize&0x7) fragmentSize = ((fragmentSize >> 3) + 1) << 3;
278 toolbox::mem::Reference *bufRef =
279 toolbox::mem::getMemoryPoolFactory()->getFrame(i2oPool_,fragmentSize);
282 I2O_MESSAGE_FRAME *stdMsg;
283 I2O_PRIVATE_MESSAGE_FRAME *pvtMsg;
286 stdMsg=(I2O_MESSAGE_FRAME*)bufRef->getDataLocation();
287 pvtMsg=(I2O_PRIVATE_MESSAGE_FRAME*)stdMsg;
290 stdMsg->VersionOffset =0;
292 stdMsg->MessageSize =fragmentSize >> 2;
293 stdMsg->Function =I2O_PRIVATE_MESSAGE;
294 stdMsg->InitiatorAddress=i2o::utils::getAddressMap()->getTid(fuAppDesc_);
295 stdMsg->TargetAddress =i2o::utils::getAddressMap()->getTid(smAppDesc_);
297 pvtMsg->XFunctionCode =i2oFunctionCode;
298 pvtMsg->OrganizationID =XDAQ_ORGANIZATION_ID;
303 msg->
hltTid =i2o::utils::getAddressMap()->getTid(fuAppDesc_);
310 msg->
hltURL[fuUrl_.size()]=
'\0';
312 for (
UInt_t i=0;
i<fuClassName_.size();
i++)
321 tail->setNextReference(bufRef);
325 if (fragmentDataSize!=0) {
328 data+currentPosition+fragmentDataSize,
332 bufRef->setDataSize(fragmentSize);
333 remainingDataSize-=fragmentDataSize;
334 currentPosition +=fragmentDataSize;
335 totalSize +=fragmentSize;
340 if (0!=head) head->release();
342 string errmsg=
"Failed to allocate buffer reference.";
343 LOG4CPLUS_FATAL(log_,errmsg);
346 catch(xdaq::exception::ApplicationDescriptorNotFound& e) {
347 if (0!=head) head->release();
349 string errmsg=
"Failed to get tid.";
350 LOG4CPLUS_FATAL(log_,errmsg);
xdaq::ApplicationDescriptor * fuAppDesc_
toolbox::mem::Reference MemRef_t
UInt_t sendDqmEvent(UInt_t fuDqmId, UInt_t runNumber, UInt_t evtAtUpdate, UInt_t folderId, UInt_t fuProcessId, UInt_t fuGuid, UChar_t *data, UInt_t dataSize)
MemRef_t * createFragmentChain(UShort_t i2oFunctionCode, UInt_t headerSize, UChar_t *data, UInt_t dataSize, UInt_t &totalSize)
UInt_t sendErrorEvent(UInt_t fuResourceId, UInt_t runNumber, UInt_t evtNumber, UInt_t fuProcessId, UInt_t fuGuid, UChar_t *data, UInt_t dataSize)
UInt_t sendDataEvent(UInt_t fuResourceId, UInt_t runNumber, UInt_t evtNumber, UInt_t outModId, UInt_t fuProcessId, UInt_t fuGuid, UChar_t *data, UInt_t dataSize)
UInt_t sendInitMessage(UInt_t fuResourceId, UInt_t outModId, UInt_t fuProcessId, UInt_t fuGuid, UChar_t *data, UInt_t dataSize)
char hltURL[MAX_I2O_SM_URLCHARS]
char hltClassName[MAX_I2O_SM_URLCHARS]
#define MAX_I2O_SM_URLCHARS