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"
34 SMProxy::SMProxy(xdaq::ApplicationDescriptor *fuAppDesc,
35 xdaq::ApplicationDescriptor *smAppDesc,
36 xdaq::ApplicationContext *fuAppContext, toolbox::mem::Pool *i2oPool) :
37 log_(fuAppContext->getLogger()), fuAppDesc_(fuAppDesc),
38 smAppDesc_(smAppDesc), fuAppContext_(fuAppContext),
67 data, dataSize, totalSize);
78 }
while ((next = next->getNextReference()));
81 fuAppContext_->postFrame(bufRef, fuAppDesc_, smAppDesc_);
83 string msg =
"Failed to post INIT Message.";
108 }
while ((next = next->getNextReference()));
111 fuAppContext_->postFrame(bufRef, fuAppDesc_, smAppDesc_);
113 string errmsg =
"Failed to post DATA Message.";
114 LOG4CPLUS_FATAL(log_, errmsg);
127 dataSize, totalSize);
139 }
while ((next = next->getNextReference()));
142 fuAppContext_->postFrame(bufRef, fuAppDesc_, smAppDesc_);
144 string errmsg =
"Failed to post ERROR Message.";
145 LOG4CPLUS_FATAL(log_, errmsg);
158 dataSize, totalSize);
170 }
while ((next = next->getNextReference()));
173 fuAppContext_->postFrame(bufRef, fuAppDesc_, smAppDesc_);
175 string errmsg =
"Failed to post DQM Message.";
176 LOG4CPLUS_FATAL(log_, errmsg);
194 UInt_t fragmentCount = (dataSize / fragmentDataSizeMax);
195 if (dataSize % fragmentDataSizeMax)
198 UInt_t currentPosition = 0;
199 UInt_t remainingDataSize = dataSize;
206 for (
UInt_t iFragment = 0; iFragment < fragmentCount; iFragment++) {
208 UInt_t fragmentDataSize = fragmentDataSizeMax;
209 UInt_t fragmentSize = fragmentDataSize + headerSize;
211 if (remainingDataSize < fragmentDataSizeMax) {
212 fragmentDataSize = remainingDataSize;
213 fragmentSize = fragmentDataSize + headerSize;
214 if (fragmentSize & 0x7)
215 fragmentSize = ((fragmentSize >> 3) + 1) << 3;
219 toolbox::mem::Reference *bufRef =
220 toolbox::mem::getMemoryPoolFactory()->getFrame(i2oPool_,
224 I2O_MESSAGE_FRAME *stdMsg;
225 I2O_PRIVATE_MESSAGE_FRAME *pvtMsg;
228 stdMsg = (I2O_MESSAGE_FRAME*) bufRef->getDataLocation();
229 pvtMsg = (I2O_PRIVATE_MESSAGE_FRAME*) stdMsg;
232 stdMsg->VersionOffset = 0;
233 stdMsg->MsgFlags = 0;
234 stdMsg->MessageSize = fragmentSize >> 2;
235 stdMsg->Function = I2O_PRIVATE_MESSAGE;
236 stdMsg->InitiatorAddress = i2o::utils::getAddressMap()->getTid(
238 stdMsg->TargetAddress = i2o::utils::getAddressMap()->getTid(
241 pvtMsg->XFunctionCode = i2oFunctionCode;
242 pvtMsg->OrganizationID = XDAQ_ORGANIZATION_ID;
247 msg->
hltTid = i2o::utils::getAddressMap()->getTid(fuAppDesc_);
252 for (
UInt_t i = 0;
i < fuUrl_.size();
i++)
254 msg->
hltURL[fuUrl_.size()] =
'\0';
256 for (
UInt_t i = 0;
i < fuClassName_.size();
i++)
260 if (iFragment == 0) {
264 tail->setNextReference(bufRef);
268 if (fragmentDataSize != 0) {
271 data + currentPosition + fragmentDataSize, targetAddr);
274 bufRef->setDataSize(fragmentSize);
275 remainingDataSize -= fragmentDataSize;
276 currentPosition += fragmentDataSize;
277 totalSize += fragmentSize;
284 string errmsg =
"Failed to allocate buffer reference.";
285 LOG4CPLUS_FATAL(log_, errmsg);
287 }
catch (xdaq::exception::ApplicationDescriptorNotFound& e) {
291 string errmsg =
"Failed to get tid.";
292 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)
char data[epos_bytes_allocation]
#define MAX_I2O_SM_URLCHARS
UInt_t sendInitMessage(UInt_t fuResourceId, UInt_t outModId, UInt_t fuProcessId, UInt_t fuGuid, UChar_t *data, UInt_t dataSize, UInt_t nExpectedEPs)