ClassImp(AliHLTControlTask)
AliHLTControlTask::AliHLTControlTask()
- :
- fEvent(kAliHLTVoidDataType),
- fSpecification(kAliHLTVoidDataSpec),
- fpData(NULL),
- fSize(0)
+ : AliHLTTask()
+ , fBlocks()
+ , fpData(NULL)
+ , fSize(0)
{
// see header file for class documentation
// or
AliHLTControlTask::~AliHLTControlTask()
{
// see header file for class documentation
+ ResetBlocks();
}
int AliHLTControlTask::CreateComponent(AliHLTConfiguration* /*pConf*/, AliHLTComponentHandler* pCH, AliHLTComponent*& pComponent) const
return -ENOMEM;
}
+void AliHLTControlTask::SetBlocks(const AliHLTComponentBlockDataList& list)
+{
+ // see header file for class documentation
+ fBlocks.assign(list.begin(), list.end());
+ AliHLTComponentBlockDataList::iterator element=fBlocks.begin();
+ for (;element!=fBlocks.end(); element++) fSize+=element->fSize;
+
+ // allocate buffer for the payload of all blocks
+ fpData=new AliHLTUInt8_t[fSize];
+ AliHLTUInt8_t offset=0;
+
+ // copy and redirect
+ for (element=fBlocks.begin();element!=fBlocks.end(); element++) {
+ memcpy(fpData+offset, element->fPtr, element->fSize);
+ element->fPtr=fpData+offset;
+ offset+=element->fSize;
+ }
+}
+
+void AliHLTControlTask::ResetBlocks()
+{
+ // see header file for class documentation
+ fBlocks.clear();
+ if (fpData) delete [] fpData;
+ fpData=NULL;
+ fSize=0;
+}
+
AliHLTControlTask::AliHLTControlEventComponent::AliHLTControlEventComponent(const AliHLTControlTask* pParent)
:
fpParent(pParent)
{
// see header file for class documentation
if (fpParent && fpParent->fSize>0) constBase=fpParent->fSize;
- else constBase=sizeof(AliHLTRunDesc);
+ else constBase=0;
inputMultiplier=0;
}
// see header file for class documentation
if (!fpParent) return -ENODEV;
const AliHLTControlTask* pParent=fpParent;
- if (size<pParent->fSize) {
- return -ENOSPC;
- }
-
- if (pParent->fpData && pParent->fSize) {
- memcpy(outputPtr, pParent->fpData, pParent->fSize);
- }
-
// return if no event has been set
- if (pParent->fEvent==kAliHLTVoidDataType) {
+ if (pParent->fpData==NULL ||
+ pParent->fBlocks.size()==0) {
//HLTInfo("no control event to send");
return 0;
}
- HLTDebug("publishing control event %s", DataType2Text(pParent->fEvent).c_str());
- AliHLTComponentBlockData bd;
- FillBlockData(bd);
- bd.fOffset=0;
- bd.fSize=pParent->fSize;
- bd.fDataType=pParent->fEvent;
- bd.fSpecification=pParent->fSpecification;
- outputBlocks.push_back( bd );
+ AliHLTUInt32_t capacity=size;
+ size=0;
+ if (capacity<pParent->fSize) {
+ return -ENOSPC;
+ }
+
+ for (unsigned int i=0; i<pParent->fBlocks.size(); i++) {
+ HLTDebug("publishing control block %s", DataType2Text(pParent->fBlocks[i].fDataType).c_str());
+ memcpy(outputPtr+size, pParent->fBlocks[i].fPtr, pParent->fBlocks[i].fSize);
+ AliHLTComponentBlockData bd;
+ FillBlockData(bd);
+ bd.fOffset=size;
+ bd.fSize=pParent->fBlocks[i].fSize;
+ bd.fDataType=pParent->fBlocks[i].fDataType;
+ bd.fSpecification=pParent->fBlocks[i].fSpecification;
+ outputBlocks.push_back( bd );
+ size+=bd.fSize;
+ }
- return bd.fSize;
+ return size;
}
class AliHLTControlEventGuard {
public:
- AliHLTControlEventGuard(AliHLTControlTask* me, AliHLTComponentDataType dt, AliHLTUInt32_t spec, AliHLTUInt8_t* pData, AliHLTUInt32_t size) :
+ AliHLTControlEventGuard(AliHLTControlTask* me, AliHLTComponentBlockDataList& list) :
fTask(me) {
if (!fTask) return;
- fTask->fEvent=dt;
- fTask->fSpecification=spec;
- fTask->fpData=pData;
- fTask->fSize=size;
+ fTask->SetBlocks(list);
+ }
+ ~AliHLTControlEventGuard() {
+ if (!fTask) return;
+ fTask->ResetBlocks();
}
- ~AliHLTControlEventGuard() {
- if (!fTask) return;
- fTask->fEvent=kAliHLTVoidDataType;
- fTask->fSpecification=kAliHLTVoidDataSpec;
- fTask->fpData=NULL;
- fTask->fSize=0;
- }
private:
/** standard constructor prohibited */
};
protected:
+ /// to be used from the guard
+ void SetBlocks(const AliHLTComponentBlockDataList& list);
+ /// to be used from the guard
+ void ResetBlocks();
private:
/** copy constructor prohibited */
/** assignment operator prohibited */
AliHLTControlTask& operator=(const AliHLTControlTask&);
- /** data type of the control event */
- AliHLTComponentDataType fEvent; //! transient
- /** specification of the control evtent */
- AliHLTUInt32_t fSpecification; //! transient
- /** payload to be sent with the control event */
+ /** list of control blocks */
+ AliHLTComponentBlockDataList fBlocks; //! transient
+ /** payload buffer for all control blocks */
AliHLTUInt8_t* fpData; //! transient
/** payload size */
AliHLTUInt32_t fSize; //!transient
ClassDef(AliHLTControlTask, 0)
- };
+};
#endif
for (unsigned int block=0; block<evtData.fBlockCnt; block++) {
if (blocks[block].fDataType==kAliHLTDataTypeSOR ||
blocks[block].fDataType==kAliHLTDataTypeEOR ||
- blocks[block].fDataType==kAliHLTDataTypeEvent) {
+ blocks[block].fDataType==kAliHLTDataTypeEvent ||
+ blocks[block].fDataType==kAliHLTDataTypeComponentStatistics ||
+ blocks[block].fDataType==kAliHLTDataTypeComponentTable ||
+ blocks[block].fDataType==kAliHLTDataTypeECSParam) {
continue;
}
unknown=block;
// see header file for class documentation
int iResult=0;
+ AliHLTComponentBlockDataList controlBlocks;
+ AliHLTComponentBlockData bd;
+
+ // run decriptor block of type kAliHLTDataTypeSOR/kAliHLTDataTypeEOR
+ AliHLTComponent::FillBlockData(bd);
AliHLTRunDesc runDesc;
memset(&runDesc, 0, sizeof(AliHLTRunDesc));
runDesc.fStructSize=sizeof(AliHLTRunDesc);
- AliHLTControlTask::AliHLTControlEventGuard g(fpControlTask, dt, kAliHLTVoidDataSpec, (AliHLTUInt8_t*)&runDesc, sizeof(AliHLTRunDesc));
+ bd.fPtr=&runDesc;
+ bd.fSize=sizeof(AliHLTRunDesc);
+ bd.fDataType=dt;
+ bd.fSpecification=kAliHLTVoidDataSpec;
+ controlBlocks.push_back(bd);
+
+ // ECS parameter dummy of type kAliHLTDataTypeECSParam
+ // to be filled at some point from the trigger framework
+ AliHLTComponent::FillBlockData(bd);
+ TString ecsParam="CTP_TRIGGER_CLASS=00:DUMMY_TRIGGER_ALL:00-01-02-03-04-05-06-07-08-09-10-11-12-13-14-15-16-17";
+ bd.fPtr=(void*)ecsParam.Data();
+ bd.fSize=ecsParam.Length()+1;
+ bd.fDataType=kAliHLTDataTypeECSParam;
+ bd.fSpecification=kAliHLTVoidDataSpec;
+ controlBlocks.push_back(bd);
+
+ AliHLTControlTask::AliHLTControlEventGuard g(fpControlTask, controlBlocks);
HLTDebug("sending event %s, run descriptor %p", AliHLTComponent::DataType2Text(dt).c_str(), &runDesc);
TObjLink *lnk=fTaskList.FirstLink();
while (lnk && iResult>=0) {
// instances of SOR and EOR events to be kept
int iSOR=-1;
int iEOR=-1;
+ // TODO 2009-09-30
+ // generalize handling of the special blocks to be forwarded on SOR and EOR
+ // just adding a new specific handling for the ECS parameter block as a quick
+ // solution
+ int iECS=-1;
// subscribe to all source tasks
fBlockDataArray.clear();
HLTDebug("source task %s (%p) does not provide any matching data type for task %s (%p)", pSrcTask->GetName(), pSrcTask, GetName(), this);
}
if ((iResult=pSrcTask->Subscribe(this, fBlockDataArray))>=0) {
- iSOR=iEOR=-1;
+ iSOR=iEOR=iECS=-1;
AliHLTComponentBlockDataList::iterator block=fBlockDataArray.begin();
for (int i=0; block!=fBlockDataArray.end(); i++) {
bool bRemove=0;
bRemove|=(*block).fDataType==kAliHLTDataTypeSOR && !(iSOR<0 && (iSOR=i)>=0);
bRemove|=(*block).fDataType==kAliHLTDataTypeEOR && !(iEOR<0 && (iEOR=i)>=0);
+ bRemove|=(*block).fDataType==kAliHLTDataTypeECSParam && !(iECS<0 && (iECS=i)>=0);
//HLTInfo("block %d, iSOR=%d iEOR=%d remove=%d", i, iSOR, iEOR, bRemove);
if (i<iSourceDataBlock) {
assert(!bRemove);
trigData.fDataSize=sizeof(AliHLTEventTriggerData);
memset(&evtTrigData, 0, trigData.fDataSize);
evtTrigData.fCommonHeaderWordCnt=gkAliHLTCommonHeaderCount;
+ // TODO 2009-09-30
+ // Whenever the trigger framework is implemented and provides more than
+ // just a dummy CT_TRIGGER_CLASS, this needs to be changed. Now for
+ // all events the first bit in the trigger mask is set
+ evtTrigData.fCommonHeader[5]=0x1;
trigData.fData=&evtTrigData;
iLastOutputDataSize=iOutputDataSize;
AliHLTUInt32_t size=iOutputDataSize;
fpDataBuffer->Forward(subscribedTaskList[iEOR], &fBlockDataArray[iEOR]);
subscribedTaskList[iEOR]=NULL; // not to be released in the loop further down
}
+ if (iECS>=0 && subscribedTaskList[iECS]!=NULL) {
+ HLTDebug("forward EOR event (%s) segment %d (source task %s %p) to data buffer %p", AliHLTComponent::DataType2Text(fBlockDataArray[iECS].fDataType).c_str(), iECS, pSrcTask->GetName(), pSrcTask, fpDataBuffer);
+ fpDataBuffer->Forward(subscribedTaskList[iECS], &fBlockDataArray[iECS]);
+ subscribedTaskList[iECS]=NULL; // not to be released in the loop further down
+ }
}
} else {
HLTError("no target buffer available");