]>
Commit | Line | Data |
---|---|---|
afad6dde | 1 | // $Id$ |
2 | ||
3 | //************************************************************************** | |
4 | //* This file is property of and copyright by the ALICE HLT Project * | |
5 | //* ALICE Experiment at CERN, All rights reserved. * | |
6 | //* * | |
7 | //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> * | |
8 | //* for The ALICE HLT Project. * | |
9 | //* * | |
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 | //************************************************************************** | |
18 | ||
19 | /** @file AliHLTControlTask.cxx | |
20 | @author Matthias Richter | |
21 | @date | |
22 | @brief Special task to produce the control events. | |
23 | */ | |
24 | ||
25 | #include "AliHLTControlTask.h" | |
26 | #include "AliHLTComponentHandler.h" | |
27 | #include <cassert> | |
28 | ||
29 | /** ROOT macro for the implementation of ROOT specific class methods */ | |
30 | ClassImp(AliHLTControlTask) | |
31 | ||
32 | AliHLTControlTask::AliHLTControlTask() | |
3baf1595 | 33 | : AliHLTTask() |
34 | , fBlocks() | |
35 | , fpData(NULL) | |
36 | , fSize(0) | |
afad6dde | 37 | { |
38 | // see header file for class documentation | |
39 | // or | |
40 | // refer to README to build package | |
41 | // or | |
42 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
43 | } | |
44 | ||
45 | AliHLTControlTask::~AliHLTControlTask() | |
46 | { | |
47 | // see header file for class documentation | |
3baf1595 | 48 | ResetBlocks(); |
afad6dde | 49 | } |
50 | ||
51 | int AliHLTControlTask::CreateComponent(AliHLTConfiguration* /*pConf*/, AliHLTComponentHandler* pCH, AliHLTComponent*& pComponent) const | |
52 | { | |
53 | // see header file for class documentation | |
54 | int iResult=0; | |
55 | if ((pComponent=new AliHLTControlEventComponent(this))) { | |
56 | const AliHLTAnalysisEnvironment* pEnv=pCH->GetEnvironment(); | |
77a69162 | 57 | const char* argv[]={ |
58 | "-disable-component-stat" | |
59 | }; | |
60 | int argc=sizeof(argv)/sizeof(const char*); | |
61 | if ((iResult=pComponent->Init(pEnv, NULL, argc, argv))>=0) { | |
afad6dde | 62 | //HLTDebug("component %s (%p) created", pComponent->GetComponentID(), pComponent); |
63 | } else { | |
64 | HLTError("Initialization of component \"%s\" failed with error %d", pComponent->GetComponentID(), iResult); | |
65 | } | |
66 | return iResult; | |
67 | } | |
68 | return -ENOMEM; | |
69 | } | |
70 | ||
3baf1595 | 71 | void AliHLTControlTask::SetBlocks(const AliHLTComponentBlockDataList& list) |
72 | { | |
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; | |
77 | ||
78 | // allocate buffer for the payload of all blocks | |
79 | fpData=new AliHLTUInt8_t[fSize]; | |
80 | AliHLTUInt8_t offset=0; | |
81 | ||
82 | // copy and redirect | |
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; | |
87 | } | |
88 | } | |
89 | ||
90 | void AliHLTControlTask::ResetBlocks() | |
91 | { | |
92 | // see header file for class documentation | |
93 | fBlocks.clear(); | |
94 | if (fpData) delete [] fpData; | |
95 | fpData=NULL; | |
96 | fSize=0; | |
97 | } | |
98 | ||
afad6dde | 99 | AliHLTControlTask::AliHLTControlEventComponent::AliHLTControlEventComponent(const AliHLTControlTask* pParent) |
100 | : | |
101 | fpParent(pParent) | |
102 | { | |
103 | // see header file for class documentation | |
104 | assert(pParent); | |
105 | } | |
106 | ||
107 | AliHLTControlTask::AliHLTControlEventComponent::~AliHLTControlEventComponent() | |
108 | { | |
109 | // see header file for class documentation | |
110 | } | |
111 | ||
112 | AliHLTComponentDataType AliHLTControlTask::AliHLTControlEventComponent::GetOutputDataType() | |
113 | { | |
114 | // see header file for class documentation | |
115 | return kAliHLTMultipleDataType; | |
116 | } | |
117 | ||
118 | int AliHLTControlTask::AliHLTControlEventComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList) | |
119 | { | |
120 | // see header file for class documentation | |
121 | tgtList.clear(); | |
122 | tgtList.push_back(kAliHLTDataTypeSOR); | |
123 | tgtList.push_back(kAliHLTDataTypeEOR); | |
124 | return tgtList.size(); | |
125 | } | |
126 | ||
127 | void AliHLTControlTask::AliHLTControlEventComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) | |
128 | { | |
129 | // see header file for class documentation | |
130 | if (fpParent && fpParent->fSize>0) constBase=fpParent->fSize; | |
3baf1595 | 131 | else constBase=0; |
afad6dde | 132 | inputMultiplier=0; |
133 | } | |
134 | ||
135 | int AliHLTControlTask::AliHLTControlEventComponent::GetEvent(const AliHLTComponentEventData& /*evtData*/, | |
136 | AliHLTComponentTriggerData& /*trigData*/, | |
137 | AliHLTUInt8_t* outputPtr, | |
138 | AliHLTUInt32_t& size, | |
139 | vector<AliHLTComponentBlockData>& outputBlocks ) | |
140 | { | |
141 | // see header file for class documentation | |
142 | if (!fpParent) return -ENODEV; | |
143 | const AliHLTControlTask* pParent=fpParent; | |
afad6dde | 144 | |
3baf1595 | 145 | AliHLTUInt32_t capacity=size; |
146 | size=0; | |
147 | if (capacity<pParent->fSize) { | |
148 | return -ENOSPC; | |
149 | } | |
150 | ||
91e91ee8 | 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"); | |
155 | return 0; | |
156 | } | |
157 | ||
3baf1595 | 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; | |
162 | FillBlockData(bd); | |
163 | bd.fOffset=size; | |
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 ); | |
168 | size+=bd.fSize; | |
169 | } | |
afad6dde | 170 | |
3baf1595 | 171 | return size; |
afad6dde | 172 | } |