CMS 3D CMS Logo

Public Member Functions | Private Attributes

evf::BUProxy Class Reference

#include <BUProxy.h>

List of all members.

Public Member Functions

 BUProxy (xdaq::ApplicationDescriptor *fuAppDesc, xdaq::ApplicationDescriptor *buAppDesc, xdaq::ApplicationContext *fuAppContext, toolbox::mem::Pool *i2oPool)
void sendAllocate (const UIntVec_t &fuResourceIds) throw (evf::Exception)
void sendDiscard (UInt_t buResourceId) throw (evf::Exception)
virtual ~BUProxy ()

Private Attributes

xdaq::ApplicationDescriptor * buAppDesc_
xdaq::ApplicationContext * fuAppContext_
xdaq::ApplicationDescriptor * fuAppDesc_
toolbox::mem::Pool * i2oPool_

Detailed Description

Proxy for BuilderUnit

Definition at line 21 of file BUProxy.h.


Constructor & Destructor Documentation

BUProxy::BUProxy ( xdaq::ApplicationDescriptor *  fuAppDesc,
xdaq::ApplicationDescriptor *  buAppDesc,
xdaq::ApplicationContext *  fuAppContext,
toolbox::mem::Pool *  i2oPool 
)

Definition at line 33 of file BUProxy.cc.

                                                                               :
        fuAppDesc_(fuAppDesc), buAppDesc_(buAppDesc), fuAppContext_(fuAppContext),
                        i2oPool_(i2oPool) {

}
BUProxy::~BUProxy ( ) [virtual]

Definition at line 42 of file BUProxy.cc.

                  {

}

Member Function Documentation

void BUProxy::sendAllocate ( const UIntVec_t fuResourceIds) throw (evf::Exception)

Send allocate message to BU

Definition at line 51 of file BUProxy.cc.

References alignCSCRings::e, Exception, i, funct::log(), lumiQueryAPI::msg, and edm::Reference.

Referenced by evf::IPCMethod::sendAllocate().

                                     {
        Logger log = fuAppContext_->getLogger();

        try {
                size_t msgSize = sizeof(I2O_BU_ALLOCATE_MESSAGE_FRAME)
                                + sizeof(BU_ALLOCATE) * (fuResourceIds.size() - 1);

                toolbox::mem::Reference *bufRef =
                                toolbox::mem::getMemoryPoolFactory()->getFrame(i2oPool_,
                                                msgSize);

                I2O_MESSAGE_FRAME *stdMsg;
                I2O_PRIVATE_MESSAGE_FRAME *pvtMsg;
                I2O_BU_ALLOCATE_MESSAGE_FRAME *msg;

                stdMsg = (I2O_MESSAGE_FRAME*) bufRef->getDataLocation();
                pvtMsg = (I2O_PRIVATE_MESSAGE_FRAME*) stdMsg;
                msg = (I2O_BU_ALLOCATE_MESSAGE_FRAME*) stdMsg;

                stdMsg->MessageSize = msgSize >> 2;
                stdMsg->InitiatorAddress = i2o::utils::getAddressMap()->getTid(
                                fuAppDesc_);
                stdMsg->TargetAddress = i2o::utils::getAddressMap()->getTid(buAppDesc_);
                stdMsg->Function = I2O_PRIVATE_MESSAGE;
                stdMsg->VersionOffset = 0;
                stdMsg->MsgFlags = 0; // Point-to-point

                pvtMsg->XFunctionCode = I2O_BU_ALLOCATE;
                pvtMsg->OrganizationID = XDAQ_ORGANIZATION_ID;

                msg->n = fuResourceIds.size();

                for (UInt_t i = 0; i < fuResourceIds.size(); i++) {
                        msg->allocate[i].fuTransactionId = fuResourceIds[i];
                        msg->allocate[i].fset = 1; // IGNORED!!!
                }

                bufRef->setDataSize(msgSize);

                fuAppContext_->postFrame(bufRef, fuAppDesc_, buAppDesc_);
        } catch (toolbox::mem::exception::Exception& e) {
                string errmsg = "Failed to allocate buffer reference.";
                LOG4CPLUS_ERROR(log, errmsg);
                XCEPT_RETHROW(evf::Exception, errmsg, e);
        } catch (xdaq::exception::ApplicationDescriptorNotFound& e) {
                string errmsg = "Failed to get tid.";
                LOG4CPLUS_ERROR(log, errmsg);
                XCEPT_RETHROW(evf::Exception, errmsg, e);
        } catch (xdaq::exception::Exception& e) {
                string errmsg = "Failed to post 'Allocate' message.";
                LOG4CPLUS_ERROR(log, errmsg);
                XCEPT_RETHROW(evf::Exception, errmsg, e);
        }
}
void BUProxy::sendDiscard ( UInt_t  buResourceId) throw (evf::Exception)

Send discard message to BU

Definition at line 108 of file BUProxy.cc.

References alignCSCRings::e, Exception, funct::log(), lumiQueryAPI::msg, and edm::Reference.

Referenced by evf::FUResourceQueue::buildResource(), and evf::IPCMethod::sendDiscard().

                                                                  {
        Logger log = fuAppContext_->getLogger();

        try {
                size_t msgSize = sizeof(I2O_BU_DISCARD_MESSAGE_FRAME);

                toolbox::mem::Reference *bufRef =
                                toolbox::mem::getMemoryPoolFactory()->getFrame(i2oPool_,
                                                msgSize);

                I2O_MESSAGE_FRAME *stdMsg =
                                (I2O_MESSAGE_FRAME*) bufRef->getDataLocation();
                I2O_PRIVATE_MESSAGE_FRAME *pvtMsg = (I2O_PRIVATE_MESSAGE_FRAME*) stdMsg;
                I2O_BU_DISCARD_MESSAGE_FRAME *msg =
                                (I2O_BU_DISCARD_MESSAGE_FRAME*) stdMsg;

                stdMsg->MessageSize = msgSize >> 2;
                stdMsg->InitiatorAddress = i2o::utils::getAddressMap()->getTid(
                                fuAppDesc_);
                stdMsg->TargetAddress = i2o::utils::getAddressMap()->getTid(buAppDesc_);
                stdMsg->Function = I2O_PRIVATE_MESSAGE;
                stdMsg->VersionOffset = 0;
                stdMsg->MsgFlags = 0; // Point-to-point

                pvtMsg->XFunctionCode = I2O_BU_DISCARD;
                pvtMsg->OrganizationID = XDAQ_ORGANIZATION_ID;

                msg->n = 1;
                msg->buResourceId[0] = buResourceId;

                bufRef->setDataSize(msgSize);

                fuAppContext_->postFrame(bufRef, fuAppDesc_, buAppDesc_);
        } catch (toolbox::mem::exception::Exception& e) {
                string errmsg = "Failed to allocate buffer reference.";
                LOG4CPLUS_ERROR(log, errmsg);
                XCEPT_RETHROW(evf::Exception, errmsg, e);
        } catch (xdaq::exception::ApplicationDescriptorNotFound& e) {
                string errmsg = "Failed to get tid.";
                LOG4CPLUS_ERROR(log, errmsg);
                XCEPT_RETHROW(evf::Exception, errmsg, e);
        } catch (xdaq::exception::Exception &e) {
                string errmsg = "Failed to post 'Discard' message.";
                LOG4CPLUS_ERROR(log, errmsg);
                XCEPT_RETHROW(evf::Exception, errmsg, e);
        }

}

Member Data Documentation

xdaq::ApplicationDescriptor* evf::BUProxy::buAppDesc_ [private]

Definition at line 51 of file BUProxy.h.

xdaq::ApplicationContext* evf::BUProxy::fuAppContext_ [private]

Definition at line 52 of file BUProxy.h.

xdaq::ApplicationDescriptor* evf::BUProxy::fuAppDesc_ [private]

Definition at line 50 of file BUProxy.h.

toolbox::mem::Pool* evf::BUProxy::i2oPool_ [private]

Definition at line 53 of file BUProxy.h.