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();
58 "-disable-component-stat"
60 int argc=sizeof(argv)/sizeof(const char*);
61 if ((iResult=pComponent->Init(pEnv, NULL, argc, argv))>=0) {
62 //HLTDebug("component %s (%p) created", pComponent->GetComponentID(), pComponent);
64 HLTError("Initialization of component \"%s\" failed with error %d", pComponent->GetComponentID(), iResult);
71 void AliHLTControlTask::SetBlocks(const AliHLTComponentBlockDataList& list)
73 // see header file for class documentation
74 fBlocks.assign(list.begin(), list.end());
75 AliHLTComponentBlockDataList::iterator element=fBlocks.begin();
76 for (;element!=fBlocks.end(); element++) fSize+=element->fSize;
78 // allocate buffer for the payload of all blocks
79 fpData=new AliHLTUInt8_t[fSize];
80 AliHLTUInt8_t offset=0;
83 for (element=fBlocks.begin();element!=fBlocks.end(); element++) {
84 memcpy(fpData+offset, element->fPtr, element->fSize);
85 element->fPtr=fpData+offset;
86 offset+=element->fSize;
90 void AliHLTControlTask::ResetBlocks()
92 // see header file for class documentation
94 if (fpData) delete [] fpData;
99 AliHLTControlTask::AliHLTControlEventComponent::AliHLTControlEventComponent(const AliHLTControlTask* pParent)
103 // see header file for class documentation
107 AliHLTControlTask::AliHLTControlEventComponent::~AliHLTControlEventComponent()
109 // see header file for class documentation
112 AliHLTComponentDataType AliHLTControlTask::AliHLTControlEventComponent::GetOutputDataType()
114 // see header file for class documentation
115 return kAliHLTMultipleDataType;
118 int AliHLTControlTask::AliHLTControlEventComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList)
120 // see header file for class documentation
122 tgtList.push_back(kAliHLTDataTypeSOR);
123 tgtList.push_back(kAliHLTDataTypeEOR);
124 return tgtList.size();
127 void AliHLTControlTask::AliHLTControlEventComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
129 // see header file for class documentation
130 if (fpParent && fpParent->fSize>0) constBase=fpParent->fSize;
135 int AliHLTControlTask::AliHLTControlEventComponent::GetEvent(const AliHLTComponentEventData& /*evtData*/,
136 AliHLTComponentTriggerData& /*trigData*/,
137 AliHLTUInt8_t* outputPtr,
138 AliHLTUInt32_t& size,
139 vector<AliHLTComponentBlockData>& outputBlocks )
141 // see header file for class documentation
142 if (!fpParent) return -ENODEV;
143 const AliHLTControlTask* pParent=fpParent;
145 AliHLTUInt32_t capacity=size;
147 if (capacity<pParent->fSize) {
151 // return if no event has been set
152 if (pParent->fpData==NULL ||
153 pParent->fBlocks.size()==0) {
154 //HLTInfo("no control event to send");
158 for (unsigned int i=0; i<pParent->fBlocks.size(); i++) {
159 HLTDebug("publishing control block %s", DataType2Text(pParent->fBlocks[i].fDataType).c_str());
160 memcpy(outputPtr+size, pParent->fBlocks[i].fPtr, pParent->fBlocks[i].fSize);
161 AliHLTComponentBlockData bd;
164 bd.fSize=pParent->fBlocks[i].fSize;
165 bd.fDataType=pParent->fBlocks[i].fDataType;
166 bd.fSpecification=pParent->fBlocks[i].fSpecification;
167 outputBlocks.push_back( bd );