CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
evf::SMProxy Class Reference

#include <SMProxy.h>

Public Member Functions

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) throw (evf::Exception)
 
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) throw (evf::Exception)
 
UInt_t sendErrorEvent (UInt_t fuResourceId, UInt_t runNumber, UInt_t evtNumber, UInt_t fuProcessId, UInt_t fuGuid, UChar_t *data, UInt_t dataSize) throw (evf::Exception)
 
UInt_t sendInitMessage (UInt_t fuResourceId, UInt_t outModId, UInt_t fuProcessId, UInt_t fuGuid, UChar_t *data, UInt_t dataSize) throw (evf::Exception)
 
 SMProxy (xdaq::ApplicationDescriptor *fuAppDesc, xdaq::ApplicationDescriptor *smAppDesc, xdaq::ApplicationContext *fuAppContext, toolbox::mem::Pool *i2oPool)
 
virtual ~SMProxy ()
 

Private Member Functions

MemRef_tcreateFragmentChain (UShort_t i2oFunctionCode, UInt_t headerSize, UChar_t *data, UInt_t dataSize, UInt_t &totalSize) throw (evf::Exception)
 

Private Attributes

UInt_t dataHeaderSize_
 
UInt_t dqmHeaderSize_
 
xdaq::ApplicationContext * fuAppContext_
 
xdaq::ApplicationDescriptor * fuAppDesc_
 
std::string fuClassName_
 
std::string fuUrl_
 
toolbox::mem::Pool * i2oPool_
 
UInt_t initHeaderSize_
 
Logger log_
 
xdaq::ApplicationDescriptor * smAppDesc_
 

Detailed Description

Definition at line 16 of file SMProxy.h.

Constructor & Destructor Documentation

SMProxy::SMProxy ( xdaq::ApplicationDescriptor *  fuAppDesc,
xdaq::ApplicationDescriptor *  smAppDesc,
xdaq::ApplicationContext *  fuAppContext,
toolbox::mem::Pool *  i2oPool 
)

Definition at line 36 of file SMProxy.cc.

References fuAppDesc_, fuClassName_, fuUrl_, and MAX_I2O_SM_URLCHARS.

40  : log_(fuAppContext->getLogger())
41  , fuAppDesc_(fuAppDesc)
42  , smAppDesc_(smAppDesc)
43  , fuAppContext_(fuAppContext)
44  , i2oPool_(i2oPool)
48 {
49  fuUrl_=fuAppDesc_->getContextDescriptor()->getURL();
50  if (fuUrl_.size()>=MAX_I2O_SM_URLCHARS)
51  fuUrl_=fuUrl_.substr(0,MAX_I2O_SM_URLCHARS-1);
52 
53  fuClassName_=fuAppDesc_->getClassName();
56 }
xdaq::ApplicationDescriptor * fuAppDesc_
Definition: SMProxy.h:81
std::string fuUrl_
Definition: SMProxy.h:90
toolbox::mem::Pool * i2oPool_
Definition: SMProxy.h:84
xdaq::ApplicationDescriptor * smAppDesc_
Definition: SMProxy.h:82
UInt_t dqmHeaderSize_
Definition: SMProxy.h:88
std::string fuClassName_
Definition: SMProxy.h:91
UInt_t dataHeaderSize_
Definition: SMProxy.h:87
xdaq::ApplicationContext * fuAppContext_
Definition: SMProxy.h:83
Logger log_
Definition: SMProxy.h:80
UInt_t initHeaderSize_
Definition: SMProxy.h:86
#define MAX_I2O_SM_URLCHARS
Definition: i2oEvfMsgs.h:53
SMProxy::~SMProxy ( )
virtual

Definition at line 60 of file SMProxy.cc.

61 {
62 
63 }

Member Function Documentation

MemRef_t * SMProxy::createFragmentChain ( UShort_t  i2oFunctionCode,
UInt_t  headerSize,
UChar_t data,
UInt_t  dataSize,
UInt_t totalSize 
)
throw (evf::Exception
)
private

Definition at line 245 of file SMProxy.cc.

References filterCSVwithJSON::copy, runTheMatrix::data, _I2O_SM_MULTIPART_MESSAGE_FRAME::dataSize, edm::hlt::Exception, _I2O_SM_MULTIPART_MESSAGE_FRAME::frameCount, _I2O_SM_MULTIPART_MESSAGE_FRAME::hltClassName, _I2O_SM_MULTIPART_MESSAGE_FRAME::hltInstance, _I2O_SM_MULTIPART_MESSAGE_FRAME::hltLocalId, _I2O_SM_MULTIPART_MESSAGE_FRAME::hltTid, _I2O_SM_MULTIPART_MESSAGE_FRAME::hltURL, i, I2O_MAX_SIZE, runTheMatrix::msg, _I2O_SM_MULTIPART_MESSAGE_FRAME::numFrames, and _I2O_SM_MULTIPART_MESSAGE_FRAME::originalSize.

251 {
252  totalSize=0;
253 
254  UInt_t fragmentDataSizeMax=I2O_MAX_SIZE-headerSize;
255  UInt_t fragmentCount=(dataSize/fragmentDataSizeMax);
256  if (dataSize%fragmentDataSizeMax) ++fragmentCount;
257 
258  UInt_t currentPosition =0;
259  UInt_t remainingDataSize=dataSize;
260 
261  MemRef_t *head(0);
262  MemRef_t *tail(0);
263 
264  try {
265 
266  for (UInt_t iFragment=0;iFragment<fragmentCount;iFragment++) {
267 
268  UInt_t fragmentDataSize=fragmentDataSizeMax;
269  UInt_t fragmentSize =fragmentDataSize+headerSize;
270 
271  if (remainingDataSize<fragmentDataSizeMax) {
272  fragmentDataSize=remainingDataSize;
273  fragmentSize=fragmentDataSize+headerSize;
274  if (fragmentSize&0x7) fragmentSize = ((fragmentSize >> 3) + 1) << 3;
275  }
276 
277  // allocate the fragment buffer from the pool
278  toolbox::mem::Reference *bufRef =
279  toolbox::mem::getMemoryPoolFactory()->getFrame(i2oPool_,fragmentSize);
280 
281  // set up pointers to the allocated message buffer
282  I2O_MESSAGE_FRAME *stdMsg;
283  I2O_PRIVATE_MESSAGE_FRAME *pvtMsg;
285 
286  stdMsg=(I2O_MESSAGE_FRAME*)bufRef->getDataLocation();
287  pvtMsg=(I2O_PRIVATE_MESSAGE_FRAME*)stdMsg;
288  msg =(I2O_SM_MULTIPART_MESSAGE_FRAME*)stdMsg;
289 
290  stdMsg->VersionOffset =0;
291  stdMsg->MsgFlags =0; // normal message (not multicast)
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_);
296 
297  pvtMsg->XFunctionCode =i2oFunctionCode;
298  pvtMsg->OrganizationID =XDAQ_ORGANIZATION_ID;
299 
300  msg->dataSize =fragmentDataSize;
301  msg->hltLocalId =fuAppDesc_->getLocalId();
302  msg->hltInstance =fuAppDesc_->getInstance();
303  msg->hltTid =i2o::utils::getAddressMap()->getTid(fuAppDesc_);
304  msg->numFrames =fragmentCount;
305  msg->frameCount =iFragment;
306  msg->originalSize =dataSize;
307 
308  for (UInt_t i=0;i<fuUrl_.size();i++)
309  msg->hltURL[i]=fuUrl_[i];
310  msg->hltURL[fuUrl_.size()]='\0';
311 
312  for (UInt_t i=0;i<fuClassName_.size();i++)
313  msg->hltClassName[i]=fuClassName_[i];
314  msg->hltClassName[fuClassName_.size()]='\0';
315 
316  if (iFragment==0) {
317  head=bufRef;
318  tail=bufRef;
319  }
320  else {
321  tail->setNextReference(bufRef);
322  tail=bufRef;
323  }
324 
325  if (fragmentDataSize!=0) {
326  UChar_t* targetAddr=(UChar_t*)msg+headerSize;
327  std::copy(data+currentPosition,
328  data+currentPosition+fragmentDataSize,
329  targetAddr);
330  }
331 
332  bufRef->setDataSize(fragmentSize);
333  remainingDataSize-=fragmentDataSize;
334  currentPosition +=fragmentDataSize;
335  totalSize +=fragmentSize;
336 
337  } // for (iFragment ...)
338  }
340  if (0!=head) head->release();
341  totalSize=0;
342  string errmsg="Failed to allocate buffer reference.";
343  LOG4CPLUS_FATAL(log_,errmsg);
344  XCEPT_RETHROW(evf::Exception,errmsg,e);
345  }
346  catch(xdaq::exception::ApplicationDescriptorNotFound& e) {
347  if (0!=head) head->release();
348  totalSize=0;
349  string errmsg="Failed to get tid.";
350  LOG4CPLUS_FATAL(log_,errmsg);
351  XCEPT_RETHROW(evf::Exception,errmsg,e);
352  }
353 
354  return head;
355 }
int i
Definition: DBlmapReader.cc:9
xdaq::ApplicationDescriptor * fuAppDesc_
Definition: SMProxy.h:81
std::string fuUrl_
Definition: SMProxy.h:90
toolbox::mem::Reference MemRef_t
Definition: FUTypes.h:10
toolbox::mem::Pool * i2oPool_
Definition: SMProxy.h:84
xdaq::ApplicationDescriptor * smAppDesc_
Definition: SMProxy.h:82
std::string fuClassName_
Definition: SMProxy.h:91
unsigned char UChar_t
Definition: FUTypes.h:14
Logger log_
Definition: SMProxy.h:80
unsigned int UInt_t
Definition: FUTypes.h:12
#define I2O_MAX_SIZE
Definition: i2oEvfMsgs.h:46
char hltURL[MAX_I2O_SM_URLCHARS]
Definition: i2oEvfMsgs.h:64
char hltClassName[MAX_I2O_SM_URLCHARS]
Definition: i2oEvfMsgs.h:65
UInt_t SMProxy::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 
)
throw (evf::Exception
)

Definition at line 110 of file SMProxy.cc.

References runTheMatrix::data, _I2O_SM_DATA_MESSAGE_FRAME::eventID, edm::hlt::Exception, _I2O_SM_DATA_MESSAGE_FRAME::fuGUID, _I2O_SM_DATA_MESSAGE_FRAME::fuProcID, I2O_SM_DATA, runTheMatrix::msg, _I2O_SM_DATA_MESSAGE_FRAME::outModID, _I2O_SM_DATA_MESSAGE_FRAME::rbBufferID, _I2O_SM_DATA_MESSAGE_FRAME::runID, and inputsource_file_cfi::runNumber.

119 {
120  UInt_t totalSize=0;
123  data,
124  dataSize,
125  totalSize);
126 
128  MemRef_t* next=bufRef;
129  do {
130  msg=(I2O_SM_DATA_MESSAGE_FRAME*)next->getDataLocation();
131  msg->rbBufferID=fuResourceId;
132  msg->runID =runNumber;
133  msg->eventID =evtNumber;
134  msg->outModID=outModId;
135  msg->fuProcID=fuProcessId;
136  msg->fuGUID=fuGuid;
137  }
138  while ((next=next->getNextReference()));
139 
140  try {
141  fuAppContext_->postFrame(bufRef,fuAppDesc_,smAppDesc_);
142  }
143  catch (xdaq::exception::Exception &e) {
144  string errmsg="Failed to post DATA Message.";
145  LOG4CPLUS_FATAL(log_,errmsg);
146  XCEPT_RETHROW(evf::Exception,errmsg,e);
147  }
148 
149  return totalSize;
150 }
xdaq::ApplicationDescriptor * fuAppDesc_
Definition: SMProxy.h:81
toolbox::mem::Reference MemRef_t
Definition: FUTypes.h:10
xdaq::ApplicationDescriptor * smAppDesc_
Definition: SMProxy.h:82
UInt_t dataHeaderSize_
Definition: SMProxy.h:87
xdaq::ApplicationContext * fuAppContext_
Definition: SMProxy.h:83
MemRef_t * createFragmentChain(UShort_t i2oFunctionCode, UInt_t headerSize, UChar_t *data, UInt_t dataSize, UInt_t &totalSize)
Definition: SMProxy.cc:245
Logger log_
Definition: SMProxy.h:80
unsigned int UInt_t
Definition: FUTypes.h:12
#define I2O_SM_DATA
Definition: i2oEvfMsgs.h:22
UInt_t SMProxy::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 
)
throw (evf::Exception
)

Definition at line 197 of file SMProxy.cc.

References runTheMatrix::data, _I2O_SM_DQM_MESSAGE_FRAME::eventAtUpdateID, edm::hlt::Exception, _I2O_SM_DQM_MESSAGE_FRAME::folderID, _I2O_SM_DQM_MESSAGE_FRAME::fuGUID, _I2O_SM_DQM_MESSAGE_FRAME::fuProcID, I2O_SM_DQM, runTheMatrix::msg, _I2O_SM_DQM_MESSAGE_FRAME::rbBufferID, _I2O_SM_DQM_MESSAGE_FRAME::runID, and inputsource_file_cfi::runNumber.

206 {
207  UInt_t totalSize=0;
210  data,
211  dataSize,
212  totalSize);
213 
215  MemRef_t* next=bufRef;
216  do {
217  msg=(I2O_SM_DQM_MESSAGE_FRAME*)next->getDataLocation();
218  msg->rbBufferID =fuDqmId;
219  msg->runID =runNumber;
220  msg->eventAtUpdateID=evtAtUpdate;
221  msg->folderID =folderId;
222  msg->fuProcID =fuProcessId;
223  msg->fuGUID =fuGuid;
224  }
225  while ((next=next->getNextReference()));
226 
227  try {
228  fuAppContext_->postFrame(bufRef,fuAppDesc_,smAppDesc_);
229  }
230  catch (xdaq::exception::Exception &e) {
231  string errmsg="Failed to post DQM Message.";
232  LOG4CPLUS_FATAL(log_,errmsg);
233  XCEPT_RETHROW(evf::Exception,errmsg,e);
234  }
235 
236  return totalSize;
237 }
xdaq::ApplicationDescriptor * fuAppDesc_
Definition: SMProxy.h:81
#define I2O_SM_DQM
Definition: i2oEvfMsgs.h:25
toolbox::mem::Reference MemRef_t
Definition: FUTypes.h:10
xdaq::ApplicationDescriptor * smAppDesc_
Definition: SMProxy.h:82
UInt_t dqmHeaderSize_
Definition: SMProxy.h:88
xdaq::ApplicationContext * fuAppContext_
Definition: SMProxy.h:83
MemRef_t * createFragmentChain(UShort_t i2oFunctionCode, UInt_t headerSize, UChar_t *data, UInt_t dataSize, UInt_t &totalSize)
Definition: SMProxy.cc:245
Logger log_
Definition: SMProxy.h:80
unsigned int UInt_t
Definition: FUTypes.h:12
UInt_t SMProxy::sendErrorEvent ( UInt_t  fuResourceId,
UInt_t  runNumber,
UInt_t  evtNumber,
UInt_t  fuProcessId,
UInt_t  fuGuid,
UChar_t data,
UInt_t  dataSize 
)
throw (evf::Exception
)

Definition at line 154 of file SMProxy.cc.

References runTheMatrix::data, _I2O_SM_DATA_MESSAGE_FRAME::eventID, edm::hlt::Exception, _I2O_SM_DATA_MESSAGE_FRAME::fuGUID, _I2O_SM_DATA_MESSAGE_FRAME::fuProcID, I2O_SM_ERROR, runTheMatrix::msg, _I2O_SM_DATA_MESSAGE_FRAME::outModID, _I2O_SM_DATA_MESSAGE_FRAME::rbBufferID, _I2O_SM_DATA_MESSAGE_FRAME::runID, and inputsource_file_cfi::runNumber.

162 {
163  UInt_t totalSize=0;
166  data,
167  dataSize,
168  totalSize);
169 
171  MemRef_t* next=bufRef;
172  do {
173  msg=(I2O_SM_DATA_MESSAGE_FRAME*)next->getDataLocation();
174  msg->rbBufferID=fuResourceId;
175  msg->runID =runNumber;
176  msg->eventID =evtNumber;
177  msg->outModID=0xffffffff;
178  msg->fuProcID=fuProcessId;
179  msg->fuGUID=fuGuid;
180  }
181  while ((next=next->getNextReference()));
182 
183  try {
184  fuAppContext_->postFrame(bufRef,fuAppDesc_,smAppDesc_);
185  }
186  catch (xdaq::exception::Exception &e) {
187  string errmsg="Failed to post ERROR Message.";
188  LOG4CPLUS_FATAL(log_,errmsg);
189  XCEPT_RETHROW(evf::Exception,errmsg,e);
190  }
191 
192  return totalSize;
193 }
#define I2O_SM_ERROR
Definition: i2oEvfMsgs.h:23
xdaq::ApplicationDescriptor * fuAppDesc_
Definition: SMProxy.h:81
toolbox::mem::Reference MemRef_t
Definition: FUTypes.h:10
xdaq::ApplicationDescriptor * smAppDesc_
Definition: SMProxy.h:82
UInt_t dataHeaderSize_
Definition: SMProxy.h:87
xdaq::ApplicationContext * fuAppContext_
Definition: SMProxy.h:83
MemRef_t * createFragmentChain(UShort_t i2oFunctionCode, UInt_t headerSize, UChar_t *data, UInt_t dataSize, UInt_t &totalSize)
Definition: SMProxy.cc:245
Logger log_
Definition: SMProxy.h:80
unsigned int UInt_t
Definition: FUTypes.h:12
UInt_t SMProxy::sendInitMessage ( UInt_t  fuResourceId,
UInt_t  outModId,
UInt_t  fuProcessId,
UInt_t  fuGuid,
UChar_t data,
UInt_t  dataSize 
)
throw (evf::Exception
)

Definition at line 71 of file SMProxy.cc.

References runTheMatrix::data, edm::hlt::Exception, _I2O_SM_PREAMBLE_MESSAGE_FRAME::fuGUID, _I2O_SM_PREAMBLE_MESSAGE_FRAME::fuProcID, I2O_SM_PREAMBLE, runTheMatrix::msg, _I2O_SM_PREAMBLE_MESSAGE_FRAME::outModID, and _I2O_SM_PREAMBLE_MESSAGE_FRAME::rbBufferID.

78 {
79  UInt_t totalSize=0;
82  data,
83  dataSize,
84  totalSize);
85 
87  MemRef_t* next=bufRef;
88  do {
89  msg=(I2O_SM_PREAMBLE_MESSAGE_FRAME*)next->getDataLocation();
90  msg->rbBufferID=fuResourceId;
91  msg->outModID=outModId;
92  msg->fuProcID=fuProcessId;
93  msg->fuGUID=fuGuid;
94  }
95  while ((next=next->getNextReference()));
96 
97  try {
98  fuAppContext_->postFrame(bufRef,fuAppDesc_,smAppDesc_);
99  }
100  catch (xdaq::exception::Exception &e) {
101  string msg="Failed to post INIT Message.";
102  XCEPT_RETHROW(evf::Exception,msg,e);
103  }
104 
105  return totalSize;
106 }
xdaq::ApplicationDescriptor * fuAppDesc_
Definition: SMProxy.h:81
#define I2O_SM_PREAMBLE
Definition: i2oEvfMsgs.h:21
toolbox::mem::Reference MemRef_t
Definition: FUTypes.h:10
xdaq::ApplicationDescriptor * smAppDesc_
Definition: SMProxy.h:82
xdaq::ApplicationContext * fuAppContext_
Definition: SMProxy.h:83
MemRef_t * createFragmentChain(UShort_t i2oFunctionCode, UInt_t headerSize, UChar_t *data, UInt_t dataSize, UInt_t &totalSize)
Definition: SMProxy.cc:245
UInt_t initHeaderSize_
Definition: SMProxy.h:86
unsigned int UInt_t
Definition: FUTypes.h:12

Member Data Documentation

UInt_t evf::SMProxy::dataHeaderSize_
private

Definition at line 87 of file SMProxy.h.

UInt_t evf::SMProxy::dqmHeaderSize_
private

Definition at line 88 of file SMProxy.h.

xdaq::ApplicationContext* evf::SMProxy::fuAppContext_
private

Definition at line 83 of file SMProxy.h.

xdaq::ApplicationDescriptor* evf::SMProxy::fuAppDesc_
private

Definition at line 81 of file SMProxy.h.

Referenced by SMProxy().

std::string evf::SMProxy::fuClassName_
private

Definition at line 91 of file SMProxy.h.

Referenced by SMProxy().

std::string evf::SMProxy::fuUrl_
private

Definition at line 90 of file SMProxy.h.

Referenced by SMProxy().

toolbox::mem::Pool* evf::SMProxy::i2oPool_
private

Definition at line 84 of file SMProxy.h.

UInt_t evf::SMProxy::initHeaderSize_
private

Definition at line 86 of file SMProxy.h.

Logger evf::SMProxy::log_
private

Definition at line 80 of file SMProxy.h.

xdaq::ApplicationDescriptor* evf::SMProxy::smAppDesc_
private

Definition at line 82 of file SMProxy.h.