3 //**************************************************************************
4 //* This file is property of and copyright by the ALICE HLT Project *
5 //* ALICE Experiment at CERN, All rights reserved. *
7 //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 //* for The ALICE HLT Project. *
10 //* Permission to use, copy, modify and distribute this software and its *
11 //* documentation strictly for non-commercial purposes is hereby granted *
12 //* without fee, provided that the above copyright notice appears in all *
13 //* copies and that both the copyright notice and this permission notice *
14 //* appear in the supporting documentation. The authors make no claims *
15 //* about the suitability of this software for any purpose. It is *
16 //* provided "as is" without express or implied warranty. *
17 //**************************************************************************
19 /** @file AliHLTControlTask.cxx
20 @author Matthias Richter
22 @brief Special task to produce the control events.
25 #include "AliHLTControlTask.h"
26 #include "AliHLTComponentHandler.h"
29 /** ROOT macro for the implementation of ROOT specific class methods */
30 ClassImp(AliHLTControlTask)
32 AliHLTControlTask::AliHLTControlTask()
38 // see header file for class documentation
40 // refer to README to build package
42 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
45 AliHLTControlTask::~AliHLTControlTask()
47 // see header file for class documentation
51 int AliHLTControlTask::CreateComponent(AliHLTConfiguration* /*pConf*/, AliHLTComponentHandler* pCH, AliHLTComponent*& pComponent) const
53 // see header file for class documentation
55 if ((pComponent=new AliHLTControlEventComponent(this))) {
56 const AliHLTAnalysisEnvironment* pEnv=pCH->GetEnvironment();
57 if ((iResult=pComponent->Init(pEnv, NULL, 0, NULL))>=0) {
58 //HLTDebug("component %s (%p) created", pComponent->GetComponentID(), pComponent);
60 HLTError("Initialization of component \"%s\" failed with error %d", pComponent->GetComponentID(), iResult);
67 void AliHLTControlTask::SetBlocks(const AliHLTComponentBlockDataList& list)
69 // see header file for class documentation
70 fBlocks.assign(list.begin(), list.end());
71 AliHLTComponentBlockDataList::iterator element=fBlocks.begin();
72 for (;element!=fBlocks.end(); element++) fSize+=element->fSize;
74 // allocate buffer for the payload of all blocks
75 fpData=new AliHLTUInt8_t[fSize];
76 AliHLTUInt8_t offset=0;
79 for (element=fBlocks.begin();element!=fBlocks.end(); element++) {
80 memcpy(fpData+offset, element->fPtr, element->fSize);
81 element->fPtr=fpData+offset;
82 offset+=element->fSize;
86 void AliHLTControlTask::ResetBlocks()
88 // see header file for class documentation
90 if (fpData) delete [] fpData;
95 AliHLTControlTask::AliHLTControlEventComponent::AliHLTControlEventComponent(const AliHLTControlTask* pParent)
99 // see header file for class documentation
103 AliHLTControlTask::AliHLTControlEventComponent::~AliHLTControlEventComponent()
105 // see header file for class documentation
108 AliHLTComponentDataType AliHLTControlTask::AliHLTControlEventComponent::GetOutputDataType()
110 // see header file for class documentation
111 return kAliHLTMultipleDataType;
114 int AliHLTControlTask::AliHLTControlEventComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList)
116 // see header file for class documentation
118 tgtList.push_back(kAliHLTDataTypeSOR);
119 tgtList.push_back(kAliHLTDataTypeEOR);
120 return tgtList.size();
123 void AliHLTControlTask::AliHLTControlEventComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
125 // see header file for class documentation
126 if (fpParent && fpParent->fSize>0) constBase=fpParent->fSize;
131 int AliHLTControlTask::AliHLTControlEventComponent::GetEvent(const AliHLTComponentEventData& /*evtData*/,
132 AliHLTComponentTriggerData& /*trigData*/,
133 AliHLTUInt8_t* outputPtr,
134 AliHLTUInt32_t& size,
135 vector<AliHLTComponentBlockData>& outputBlocks )
137 // see header file for class documentation
138 if (!fpParent) return -ENODEV;
139 const AliHLTControlTask* pParent=fpParent;
140 // return if no event has been set
141 if (pParent->fpData==NULL ||
142 pParent->fBlocks.size()==0) {
143 //HLTInfo("no control event to send");
147 AliHLTUInt32_t capacity=size;
149 if (capacity<pParent->fSize) {
153 for (unsigned int i=0; i<pParent->fBlocks.size(); i++) {
154 HLTDebug("publishing control block %s", DataType2Text(pParent->fBlocks[i].fDataType).c_str());
155 memcpy(outputPtr+size, pParent->fBlocks[i].fPtr, pParent->fBlocks[i].fSize);
156 AliHLTComponentBlockData bd;
159 bd.fSize=pParent->fBlocks[i].fSize;
160 bd.fDataType=pParent->fBlocks[i].fDataType;
161 bd.fSpecification=pParent->fBlocks[i].fSpecification;
162 outputBlocks.push_back( bd );