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"
35 BUProxy::BUProxy(xdaq::ApplicationDescriptor *fuAppDesc,
36 xdaq::ApplicationDescriptor *buAppDesc,
37 xdaq::ApplicationContext *fuAppContext,
38 toolbox::mem::Pool *i2oPool)
39 : fuAppDesc_(fuAppDesc)
40 , buAppDesc_(buAppDesc)
41 , fuAppContext_(fuAppContext)
63 Logger
log=fuAppContext_->getLogger();
67 sizeof(I2O_BU_ALLOCATE_MESSAGE_FRAME)+
68 sizeof(BU_ALLOCATE)*(fuResourceIds.size()-1);
70 toolbox::mem::Reference *bufRef=
71 toolbox::mem::getMemoryPoolFactory()->getFrame(i2oPool_,msgSize);
73 I2O_MESSAGE_FRAME *stdMsg;
74 I2O_PRIVATE_MESSAGE_FRAME *pvtMsg;
75 I2O_BU_ALLOCATE_MESSAGE_FRAME *
msg;
77 stdMsg=(I2O_MESSAGE_FRAME*)bufRef->getDataLocation();
78 pvtMsg=(I2O_PRIVATE_MESSAGE_FRAME*)stdMsg;
79 msg =(I2O_BU_ALLOCATE_MESSAGE_FRAME*)stdMsg;
81 stdMsg->MessageSize =msgSize >> 2;
82 stdMsg->InitiatorAddress=i2o::utils::getAddressMap()->getTid(fuAppDesc_);
83 stdMsg->TargetAddress =i2o::utils::getAddressMap()->getTid(buAppDesc_);
84 stdMsg->Function =I2O_PRIVATE_MESSAGE;
85 stdMsg->VersionOffset =0;
88 pvtMsg->XFunctionCode =I2O_BU_ALLOCATE;
89 pvtMsg->OrganizationID =XDAQ_ORGANIZATION_ID;
91 msg->n =fuResourceIds.size();
93 for(
UInt_t i=0;
i<fuResourceIds.size();
i++) {
94 msg->allocate[
i].fuTransactionId=fuResourceIds[
i];
95 msg->allocate[
i].fset =1;
98 bufRef->setDataSize(msgSize);
100 fuAppContext_->postFrame(bufRef,fuAppDesc_,buAppDesc_);
103 string errmsg=
"Failed to allocate buffer reference.";
104 LOG4CPLUS_ERROR(log,errmsg);
107 catch(xdaq::exception::ApplicationDescriptorNotFound& e) {
108 string errmsg=
"Failed to get tid.";
109 LOG4CPLUS_ERROR(log,errmsg);
113 string errmsg=
"Failed to post 'Allocate' message.";
114 LOG4CPLUS_ERROR(log,errmsg);
124 Logger
log=fuAppContext_->getLogger();
127 size_t msgSize=
sizeof(I2O_BU_DISCARD_MESSAGE_FRAME);
129 toolbox::mem::Reference *bufRef=
130 toolbox::mem::getMemoryPoolFactory()->getFrame(i2oPool_,msgSize);
132 I2O_MESSAGE_FRAME *stdMsg=(I2O_MESSAGE_FRAME*)bufRef->getDataLocation();
133 I2O_PRIVATE_MESSAGE_FRAME *pvtMsg=(I2O_PRIVATE_MESSAGE_FRAME*)stdMsg;
134 I2O_BU_DISCARD_MESSAGE_FRAME *
msg=(I2O_BU_DISCARD_MESSAGE_FRAME*)stdMsg;
136 stdMsg->MessageSize =msgSize >> 2;
137 stdMsg->InitiatorAddress=i2o::utils::getAddressMap()->getTid(fuAppDesc_);
138 stdMsg->TargetAddress =i2o::utils::getAddressMap()->getTid(buAppDesc_);
139 stdMsg->Function =I2O_PRIVATE_MESSAGE;
140 stdMsg->VersionOffset =0;
143 pvtMsg->XFunctionCode =I2O_BU_DISCARD;
144 pvtMsg->OrganizationID =XDAQ_ORGANIZATION_ID;
147 msg->buResourceId[0] =buResourceId;
149 bufRef->setDataSize(msgSize);
151 fuAppContext_->postFrame(bufRef,fuAppDesc_,buAppDesc_);
154 string errmsg=
"Failed to allocate buffer reference.";
155 LOG4CPLUS_ERROR(log,errmsg);
158 catch (xdaq::exception::ApplicationDescriptorNotFound& e) {
159 string errmsg=
"Failed to get tid.";
160 LOG4CPLUS_ERROR(log,errmsg);
164 string errmsg=
"Failed to post 'Discard' message.";
165 LOG4CPLUS_ERROR(log,errmsg);
std::vector< UInt_t > UIntVec_t
void sendDiscard(UInt_t buResourceId)
void sendAllocate(const UIntVec_t &fuResourceIds)
Log< T >::type log(const T &t)