11 #include "toolbox/mem/Reference.h"
12 #include "toolbox/mem/MemoryPoolFactory.h"
13 #include "toolbox/mem/exception/Exception.h"
15 #include "i2o/Method.h"
16 #include "i2o/utils/AddressMap.h"
18 #include "xcept/tools.h"
20 #include "interface/evb/i2oEVBMsgs.h"
21 #include "interface/shared/i2oXFunctionCodes.h"
33 BUProxy::BUProxy(xdaq::ApplicationDescriptor *fuAppDesc,
34 xdaq::ApplicationDescriptor *buAppDesc,
35 xdaq::ApplicationContext *fuAppContext, toolbox::mem::Pool *i2oPool) :
36 fuAppDesc_(fuAppDesc), buAppDesc_(buAppDesc), fuAppContext_(fuAppContext),
53 Logger
log = fuAppContext_->getLogger();
56 size_t msgSize =
sizeof(I2O_BU_ALLOCATE_MESSAGE_FRAME)
57 +
sizeof(BU_ALLOCATE) * (fuResourceIds.size() - 1);
59 toolbox::mem::Reference *bufRef =
60 toolbox::mem::getMemoryPoolFactory()->getFrame(i2oPool_,
63 I2O_MESSAGE_FRAME *stdMsg;
64 I2O_PRIVATE_MESSAGE_FRAME *pvtMsg;
65 I2O_BU_ALLOCATE_MESSAGE_FRAME *
msg;
67 stdMsg = (I2O_MESSAGE_FRAME*) bufRef->getDataLocation();
68 pvtMsg = (I2O_PRIVATE_MESSAGE_FRAME*) stdMsg;
69 msg = (I2O_BU_ALLOCATE_MESSAGE_FRAME*) stdMsg;
71 stdMsg->MessageSize = msgSize >> 2;
72 stdMsg->InitiatorAddress = i2o::utils::getAddressMap()->getTid(
74 stdMsg->TargetAddress = i2o::utils::getAddressMap()->getTid(buAppDesc_);
75 stdMsg->Function = I2O_PRIVATE_MESSAGE;
76 stdMsg->VersionOffset = 0;
79 pvtMsg->XFunctionCode = I2O_BU_ALLOCATE;
80 pvtMsg->OrganizationID = XDAQ_ORGANIZATION_ID;
82 msg->n = fuResourceIds.size();
84 for (
UInt_t i = 0;
i < fuResourceIds.size();
i++) {
85 msg->allocate[
i].fuTransactionId = fuResourceIds[
i];
86 msg->allocate[
i].fset = 1;
89 bufRef->setDataSize(msgSize);
91 fuAppContext_->postFrame(bufRef, fuAppDesc_, buAppDesc_);
93 string errmsg =
"Failed to allocate buffer reference.";
94 LOG4CPLUS_ERROR(log, errmsg);
96 }
catch (xdaq::exception::ApplicationDescriptorNotFound& e) {
97 string errmsg =
"Failed to get tid.";
98 LOG4CPLUS_ERROR(log, errmsg);
101 string errmsg =
"Failed to post 'Allocate' message.";
102 LOG4CPLUS_ERROR(log, errmsg);
109 Logger
log = fuAppContext_->getLogger();
112 size_t msgSize =
sizeof(I2O_BU_DISCARD_MESSAGE_FRAME);
114 toolbox::mem::Reference *bufRef =
115 toolbox::mem::getMemoryPoolFactory()->getFrame(i2oPool_,
118 I2O_MESSAGE_FRAME *stdMsg =
119 (I2O_MESSAGE_FRAME*) bufRef->getDataLocation();
120 I2O_PRIVATE_MESSAGE_FRAME *pvtMsg = (I2O_PRIVATE_MESSAGE_FRAME*) stdMsg;
121 I2O_BU_DISCARD_MESSAGE_FRAME *
msg =
122 (I2O_BU_DISCARD_MESSAGE_FRAME*) stdMsg;
124 stdMsg->MessageSize = msgSize >> 2;
125 stdMsg->InitiatorAddress = i2o::utils::getAddressMap()->getTid(
127 stdMsg->TargetAddress = i2o::utils::getAddressMap()->getTid(buAppDesc_);
128 stdMsg->Function = I2O_PRIVATE_MESSAGE;
129 stdMsg->VersionOffset = 0;
130 stdMsg->MsgFlags = 0;
132 pvtMsg->XFunctionCode = I2O_BU_DISCARD;
133 pvtMsg->OrganizationID = XDAQ_ORGANIZATION_ID;
136 msg->buResourceId[0] = buResourceId;
138 bufRef->setDataSize(msgSize);
140 fuAppContext_->postFrame(bufRef, fuAppDesc_, buAppDesc_);
142 string errmsg =
"Failed to allocate buffer reference.";
143 LOG4CPLUS_ERROR(log, errmsg);
145 }
catch (xdaq::exception::ApplicationDescriptorNotFound& e) {
146 string errmsg =
"Failed to get tid.";
147 LOG4CPLUS_ERROR(log, errmsg);
150 string errmsg =
"Failed to post 'Discard' message.";
151 LOG4CPLUS_ERROR(log, errmsg);
void sendDiscard(UInt_t buResourceId)
void sendAllocate(const UIntVec_t &fuResourceIds)
std::vector< UInt_t > UIntVec_t