]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - HLT/BASE/AliHLTComponent.cxx
build system clean-up, support for custom LinkDef added
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTComponent.cxx
... / ...
CommitLineData
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 * Timm Steinbeck <timm@kip.uni-heidelberg.de> *
9 * for The ALICE HLT Project. *
10 * *
11 * Permission to use, copy, modify and distribute this software and its *
12 * documentation strictly for non-commercial purposes is hereby granted *
13 * without fee, provided that the above copyright notice appears in all *
14 * copies and that both the copyright notice and this permission notice *
15 * appear in the supporting documentation. The authors make no claims *
16 * about the suitability of this software for any purpose. It is *
17 * provided "as is" without express or implied warranty. *
18 **************************************************************************/
19
20/** @file AliHLTComponent.cxx
21 @author Matthias Richter, Timm Steinbeck
22 @date
23 @brief Base class implementation for HLT components. */
24
25#if __GNUC__>= 3
26using namespace std;
27#endif
28
29//#include "AliHLTStdIncludes.h"
30#include "AliHLTComponent.h"
31#include "AliHLTComponentHandler.h"
32#include "AliHLTMessage.h"
33#include "TString.h"
34#include "TObjArray.h"
35#include "TObjectTable.h"
36#include "TClass.h"
37#include "TStopwatch.h"
38#include "AliHLTMemoryFile.h"
39#include <cassert>
40
41/** ROOT macro for the implementation of ROOT specific class methods */
42ClassImp(AliHLTComponent);
43
44/** stopwatch macro using the stopwatch guard */
45#define ALIHLTCOMPONENT_STOPWATCH(type) AliHLTStopwatchGuard swguard(fpStopwatches!=NULL?reinterpret_cast<TStopwatch*>(fpStopwatches->At((int)type)):NULL)
46//#define ALIHLTCOMPONENT_STOPWATCH(type)
47
48/** stopwatch macro for operations of the base class */
49#define ALIHLTCOMPONENT_BASE_STOPWATCH() ALIHLTCOMPONENT_STOPWATCH(kSWBase)
50/** stopwatch macro for operations of the detector algorithm (DA) */
51#define ALIHLTCOMPONENT_DA_STOPWATCH() ALIHLTCOMPONENT_STOPWATCH(kSWDA)
52
53AliHLTComponent::AliHLTComponent()
54 :
55 fEnvironment(),
56 fCurrentEvent(0),
57 fEventCount(-1),
58 fFailedEvents(0),
59 fCurrentEventData(),
60 fpInputBlocks(NULL),
61 fCurrentInputBlock(-1),
62 fSearchDataType(kAliHLTVoidDataType),
63 fClassName(),
64 fpInputObjects(NULL),
65 fpOutputBuffer(NULL),
66 fOutputBufferSize(0),
67 fOutputBufferFilled(0),
68 fOutputBlocks(),
69 fpStopwatches(new TObjArray(kSWTypeCount)),
70 fMemFiles(),
71 fpRunDesc(NULL),
72 fpDDLList(NULL)
73
74{
75 // see header file for class documentation
76 // or
77 // refer to README to build package
78 // or
79 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
80 memset(&fEnvironment, 0, sizeof(AliHLTComponentEnvironment));
81 if (fgpComponentHandler)
82 fgpComponentHandler->ScheduleRegister(this);
83 //SetLocalLoggingLevel(kHLTLogDefault);
84}
85
86AliHLTComponent::~AliHLTComponent()
87{
88 // see header file for function documentation
89 CleanupInputObjects();
90 if (fpStopwatches!=NULL) delete fpStopwatches;
91 fpStopwatches=NULL;
92 vector<AliHLTMemoryFile*>::iterator element=fMemFiles.begin();
93 while (element!=fMemFiles.end()) {
94 if (*element) {
95 if ((*element)->IsClosed()==0) {
96 HLTWarning("memory file has not been closed, possible data loss or incomplete buffer");
97 // close but do not flush as we dont know whether the buffer is still valid
98 (*element)->Close(0);
99 }
100 delete *element;
101 *element=NULL;
102 }
103 element++;
104 }
105}
106
107AliHLTComponentHandler* AliHLTComponent::fgpComponentHandler=NULL;
108
109int AliHLTComponent::SetGlobalComponentHandler(AliHLTComponentHandler* pCH, int bOverwrite)
110{
111 // see header file for function documentation
112 int iResult=0;
113 if (fgpComponentHandler==NULL || bOverwrite!=0)
114 fgpComponentHandler=pCH;
115 else
116 iResult=-EPERM;
117 return iResult;
118}
119
120int AliHLTComponent::UnsetGlobalComponentHandler()
121{
122 // see header file for function documentation
123 return SetGlobalComponentHandler(NULL,1);
124}
125
126int AliHLTComponent::Init( AliHLTComponentEnvironment* environ, void* environParam, int argc, const char** argv )
127{
128 // see header file for function documentation
129 int iResult=0;
130 if (environ) {
131 memcpy(&fEnvironment, environ, sizeof(AliHLTComponentEnvironment));
132 fEnvironment.fParam=environParam;
133 }
134 const char** pArguments=NULL;
135 int iNofChildArgs=0;
136 TString argument="";
137 int bMissingParam=0;
138 if (argc>0) {
139 pArguments=new const char*[argc];
140 if (pArguments) {
141 for (int i=0; i<argc && iResult>=0; i++) {
142 argument=argv[i];
143 if (argument.IsNull()) continue;
144
145 // benchmark
146 if (argument.CompareTo("benchmark")==0) {
147
148 // loglevel
149 } else if (argument.CompareTo("loglevel")==0) {
150 if ((bMissingParam=(++i>=argc))) break;
151 TString parameter(argv[i]);
152 parameter.Remove(TString::kLeading, ' '); // remove all blanks
153 if (parameter.BeginsWith("0x") &&
154 parameter.Replace(0,2,"",0).IsHex()) {
155 AliHLTComponentLogSeverity loglevel=kHLTLogNone;
156 sscanf(parameter.Data(),"%x", (unsigned int*)&loglevel);
157 SetLocalLoggingLevel(loglevel);
158 } else {
159 HLTError("wrong parameter for argument %s, hex number expected", argument.Data());
160 iResult=-EINVAL;
161 }
162 } else {
163 pArguments[iNofChildArgs++]=argv[i];
164 }
165 }
166 } else {
167 iResult=-ENOMEM;
168 }
169 }
170 if (bMissingParam) {
171 HLTError("missing parameter for argument %s", argument.Data());
172 iResult=-EINVAL;
173 }
174 if (iResult>=0) {
175 iResult=DoInit(iNofChildArgs, pArguments);
176 }
177 if (iResult>=0) fEventCount=0;
178 if (pArguments) delete [] pArguments;
179 return iResult;
180}
181
182int AliHLTComponent::Deinit()
183{
184 // see header file for function documentation
185 int iResult=0;
186 iResult=DoDeinit();
187 if (fpRunDesc) {
188 HLTWarning("did not receive EOR for run %d", fpRunDesc->fRunNo);
189 AliHLTRunDesc* pRunDesc=fpRunDesc;
190 fpRunDesc=NULL;
191 delete pRunDesc;
192 }
193 return iResult;
194}
195
196int AliHLTComponent::DoInit( int argc, const char** argv )
197{
198 // see header file for function documentation
199 if (argc==0 && argv==NULL) {
200 // this is currently just to get rid of the warning "unused parameter"
201 }
202 fEventCount=0;
203 return 0;
204}
205
206int AliHLTComponent::DoDeinit()
207{
208 // see header file for function documentation
209 fEventCount=0;
210 return 0;
211}
212
213int AliHLTComponent::GetOutputDataTypes(vector<AliHLTComponentDataType>& /*tgtList*/)
214{
215 return 0;
216}
217
218void AliHLTComponent::DataType2Text( const AliHLTComponentDataType& type, char output[kAliHLTComponentDataTypefIDsize+kAliHLTComponentDataTypefOriginSize+2] ) const
219{
220 // see header file for function documentation
221 memset( output, 0, kAliHLTComponentDataTypefIDsize+kAliHLTComponentDataTypefOriginSize+2 );
222 strncat( output, type.fOrigin, kAliHLTComponentDataTypefOriginSize );
223 strcat( output, ":" );
224 strncat( output, type.fID, kAliHLTComponentDataTypefIDsize );
225}
226
227string AliHLTComponent::DataType2Text( const AliHLTComponentDataType& type )
228{
229 // see header file for function documentation
230 string out("");
231
232 if (type==kAliHLTVoidDataType) {
233 out="VOID:VOID";
234 } else {
235 // some gymnastics in order to avoid a '0' which is part of either or both
236 // ID and origin terminating the whole string. Unfortunately, string doesn't
237 // stop appending at the '0' if the number of elements to append was
238 // explicitely specified
239 string tmp("");
240 tmp.append(type.fOrigin, kAliHLTComponentDataTypefOriginSize);
241 out.append(tmp.c_str());
242 out.append(":");
243 tmp="";
244 tmp.append(type.fID, kAliHLTComponentDataTypefIDsize);
245 out.append(tmp.c_str());
246 }
247 return out;
248}
249
250
251void* AliHLTComponent::AllocMemory( unsigned long size )
252{
253 // see header file for function documentation
254 if (fEnvironment.fAllocMemoryFunc)
255 return (*fEnvironment.fAllocMemoryFunc)(fEnvironment.fParam, size );
256 HLTFatal("no memory allocation handler registered");
257 return NULL;
258}
259
260int AliHLTComponent::MakeOutputDataBlockList( const vector<AliHLTComponentBlockData>& blocks, AliHLTUInt32_t* blockCount,
261 AliHLTComponentBlockData** outputBlocks )
262{
263 // see header file for function documentation
264 if ( blockCount==NULL || outputBlocks==NULL )
265 return -EFAULT;
266 AliHLTUInt32_t count = blocks.size();
267 if ( !count )
268 {
269 *blockCount = 0;
270 *outputBlocks = NULL;
271 return 0;
272 }
273 *outputBlocks = reinterpret_cast<AliHLTComponentBlockData*>( AllocMemory( sizeof(AliHLTComponentBlockData)*count ) );
274 if ( !*outputBlocks )
275 return -ENOMEM;
276 for ( unsigned long i = 0; i < count; i++ ) {
277 (*outputBlocks)[i] = blocks[i];
278 if (blocks[i].fDataType==kAliHLTAnyDataType) {
279 (*outputBlocks)[i].fDataType=GetOutputDataType();
280 /* data type was set to the output data type by the PubSub AliRoot
281 Wrapper component, if data type of the block was ********:****.
282 Now handled by the component base class in order to have same
283 behavior when running embedded in AliRoot
284 memset((*outputBlocks)[i].fDataType.fID, '*', kAliHLTComponentDataTypefIDsize);
285 memset((*outputBlocks)[i].fDataType.fOrigin, '*', kAliHLTComponentDataTypefOriginSize);
286 */
287 }
288 }
289 *blockCount = count;
290 return 0;
291
292}
293
294int AliHLTComponent::GetEventDoneData( unsigned long size, AliHLTComponentEventDoneData** edd )
295{
296 // see header file for function documentation
297 if (fEnvironment.fGetEventDoneDataFunc)
298 return (*fEnvironment.fGetEventDoneDataFunc)(fEnvironment.fParam, fCurrentEvent, size, edd );
299 return -ENOSYS;
300}
301
302int AliHLTComponent::FindMatchingDataTypes(AliHLTComponent* pConsumer, vector<AliHLTComponentDataType>* tgtList)
303{
304 // see header file for function documentation
305 int iResult=0;
306 if (pConsumer) {
307 vector<AliHLTComponentDataType> ctlist;
308 ((AliHLTComponent*)pConsumer)->GetInputDataTypes(ctlist);
309 vector<AliHLTComponentDataType>::iterator type=ctlist.begin();
310 //AliHLTComponentDataType ouptdt=GetOutputDataType();
311 //PrintDataTypeContent(ouptdt, "publisher \'%s\'");
312 while (type!=ctlist.end() && iResult==0) {
313 //PrintDataTypeContent((*type), "consumer \'%s\'");
314 if ((*type)==GetOutputDataType() ||
315 (*type)==kAliHLTAnyDataType) {
316 if (tgtList) tgtList->push_back(*type);
317 iResult++;
318 // this loop has to be changed in case of multiple output types
319 break;
320 }
321 type++;
322 }
323 } else {
324 iResult=-EINVAL;
325 }
326 return iResult;
327}
328
329void AliHLTComponent::PrintDataTypeContent(AliHLTComponentDataType& dt, const char* format) const
330{
331 // see header file for function documentation
332 const char* fmt="publisher \'%s\'";
333 if (format) fmt=format;
334 HLTMessage(fmt, (DataType2Text(dt)).c_str());
335 HLTMessage("%x %x %x %x %x %x %x %x : %x %x %x %x",
336 dt.fID[0],
337 dt.fID[1],
338 dt.fID[2],
339 dt.fID[3],
340 dt.fID[4],
341 dt.fID[5],
342 dt.fID[6],
343 dt.fID[7],
344 dt.fOrigin[0],
345 dt.fOrigin[1],
346 dt.fOrigin[2],
347 dt.fOrigin[3]);
348}
349
350void AliHLTComponent::FillBlockData( AliHLTComponentBlockData& blockData ) const
351{
352 // see header file for function documentation
353 blockData.fStructSize = sizeof(blockData);
354 FillShmData( blockData.fShmKey );
355 blockData.fOffset = ~(AliHLTUInt32_t)0;
356 blockData.fPtr = NULL;
357 blockData.fSize = 0;
358 FillDataType( blockData.fDataType );
359 blockData.fSpecification = kAliHLTVoidDataSpec;
360}
361
362void AliHLTComponent::FillShmData( AliHLTComponentShmData& shmData ) const
363{
364 // see header file for function documentation
365 shmData.fStructSize = sizeof(shmData);
366 shmData.fShmType = gkAliHLTComponentInvalidShmType;
367 shmData.fShmID = gkAliHLTComponentInvalidShmID;
368}
369
370void AliHLTComponent::FillDataType( AliHLTComponentDataType& dataType ) const
371{
372 // see header file for function documentation
373 dataType=kAliHLTAnyDataType;
374}
375
376void AliHLTComponent::CopyDataType(AliHLTComponentDataType& tgtdt, const AliHLTComponentDataType& srcdt)
377{
378 // see header file for function documentation
379 memcpy(&tgtdt.fID[0], &srcdt.fID[0], kAliHLTComponentDataTypefIDsize);
380 memcpy(&tgtdt.fOrigin[0], &srcdt.fOrigin[0], kAliHLTComponentDataTypefOriginSize);
381}
382
383void AliHLTComponent::SetDataType(AliHLTComponentDataType& tgtdt, const char* id, const char* origin)
384{
385 // see header file for function documentation
386 tgtdt.fStructSize = sizeof(AliHLTComponentDataType);
387 memset(&tgtdt.fID[0], 0, kAliHLTComponentDataTypefIDsize);
388 memset(&tgtdt.fOrigin[0], 0, kAliHLTComponentDataTypefOriginSize);
389
390 if ((int)strlen(id)>kAliHLTComponentDataTypefIDsize) {
391 HLTWarning("data type id %s is too long, truncated to %d", id, kAliHLTComponentDataTypefIDsize);
392 }
393 strncpy(&tgtdt.fID[0], id, kAliHLTComponentDataTypefIDsize);
394
395 if ((int)strlen(origin)>kAliHLTComponentDataTypefOriginSize) {
396 HLTWarning("data type origin %s is too long, truncated to %d", origin, kAliHLTComponentDataTypefOriginSize);
397 }
398 strncpy(&tgtdt.fOrigin[0], origin, kAliHLTComponentDataTypefOriginSize);
399}
400
401void AliHLTComponent::FillEventData(AliHLTComponentEventData& evtData)
402{
403 // see header file for function documentation
404 memset(&evtData, 0, sizeof(AliHLTComponentEventData));
405 evtData.fStructSize=sizeof(AliHLTComponentEventData);
406}
407
408void AliHLTComponent::PrintComponentDataTypeInfo(const AliHLTComponentDataType& dt)
409{
410 // see header file for function documentation
411 TString msg;
412 msg.Form("AliHLTComponentDataType(%d): ID=\"", dt.fStructSize);
413 for ( int i = 0; i < kAliHLTComponentDataTypefIDsize; i++ ) {
414 if (dt.fID[i]!=0) msg+=dt.fID[i];
415 else msg+="\\0";
416 }
417 msg+="\" Origin=\"";
418 for ( int i = 0; i < kAliHLTComponentDataTypefOriginSize; i++ ) {
419 if (dt.fOrigin[i]!=0) msg+=dt.fOrigin[i];
420 else msg+="\\0";
421 }
422 msg+="\"";
423 AliHLTLogging::Message(NULL, kHLTLogNone, NULL , NULL, msg.Data());
424}
425
426int AliHLTComponent::GetEventCount() const
427{
428 // see header file for function documentation
429 return fEventCount;
430}
431
432int AliHLTComponent::IncrementEventCounter()
433{
434 // see header file for function documentation
435 if (fEventCount>=0) fEventCount++;
436 return fEventCount;
437}
438
439int AliHLTComponent::GetNumberOfInputBlocks() const
440{
441 // see header file for function documentation
442 if (fpInputBlocks!=NULL) {
443 return fCurrentEventData.fBlockCnt;
444 }
445 return 0;
446}
447
448const TObject* AliHLTComponent::GetFirstInputObject(const AliHLTComponentDataType& dt,
449 const char* classname,
450 int bForce)
451{
452 // see header file for function documentation
453 ALIHLTCOMPONENT_BASE_STOPWATCH();
454 fSearchDataType=dt;
455 if (classname) fClassName=classname;
456 else fClassName.clear();
457 int idx=FindInputBlock(fSearchDataType, 0, 1);
458 TObject* pObj=NULL;
459 if (idx>=0) {
460 HLTDebug("found block %d when searching for data type %s", idx, DataType2Text(dt).c_str());
461 if ((pObj=GetInputObject(idx, fClassName.c_str(), bForce))!=NULL) {
462 fCurrentInputBlock=idx;
463 } else {
464 }
465 }
466 return pObj;
467}
468
469const TObject* AliHLTComponent::GetFirstInputObject(const char* dtID,
470 const char* dtOrigin,
471 const char* classname,
472 int bForce)
473{
474 // see header file for function documentation
475 ALIHLTCOMPONENT_BASE_STOPWATCH();
476 AliHLTComponentDataType dt;
477 SetDataType(dt, dtID, dtOrigin);
478 return GetFirstInputObject(dt, classname, bForce);
479}
480
481const TObject* AliHLTComponent::GetNextInputObject(int bForce)
482{
483 // see header file for function documentation
484 ALIHLTCOMPONENT_BASE_STOPWATCH();
485 int idx=FindInputBlock(fSearchDataType, fCurrentInputBlock+1, 1);
486 //HLTDebug("found block %d when searching for data type %s", idx, DataType2Text(fSearchDataType).c_str());
487 TObject* pObj=NULL;
488 if (idx>=0) {
489 if ((pObj=GetInputObject(idx, fClassName.c_str(), bForce))!=NULL) {
490 fCurrentInputBlock=idx;
491 }
492 }
493 return pObj;
494}
495
496int AliHLTComponent::FindInputBlock(const AliHLTComponentDataType& dt, int startIdx, int bObject) const
497{
498 // see header file for function documentation
499 int iResult=-ENOENT;
500 if (fpInputBlocks!=NULL) {
501 int idx=startIdx<0?0:startIdx;
502 for ( ; (UInt_t)idx<fCurrentEventData.fBlockCnt && iResult==-ENOENT; idx++) {
503 if (bObject!=0) {
504 if (fpInputBlocks[idx].fPtr==NULL) continue;
505 AliHLTUInt32_t firstWord=*((AliHLTUInt32_t*)fpInputBlocks[idx].fPtr);
506 if (firstWord!=fpInputBlocks[idx].fSize-sizeof(AliHLTUInt32_t)) continue;
507 }
508 if (dt == kAliHLTAnyDataType || fpInputBlocks[idx].fDataType == dt) {
509 iResult=idx;
510 }
511 }
512 }
513 return iResult;
514}
515
516TObject* AliHLTComponent::CreateInputObject(int idx, int bForce)
517{
518 // see header file for function documentation
519 TObject* pObj=NULL;
520 if (fpInputBlocks!=NULL) {
521 if ((UInt_t)idx<fCurrentEventData.fBlockCnt) {
522 if (fpInputBlocks[idx].fPtr) {
523 AliHLTUInt32_t firstWord=*((AliHLTUInt32_t*)fpInputBlocks[idx].fPtr);
524 if (firstWord==fpInputBlocks[idx].fSize-sizeof(AliHLTUInt32_t)) {
525 HLTDebug("create object from block %d size %d", idx, fpInputBlocks[idx].fSize);
526 AliHLTMessage msg(fpInputBlocks[idx].fPtr, fpInputBlocks[idx].fSize);
527 TClass* objclass=msg.GetClass();
528 pObj=msg.ReadObject(objclass);
529 if (pObj && objclass) {
530 HLTDebug("object %p type %s created", pObj, objclass->GetName());
531 } else {
532 }
533 //} else {
534 } else if (bForce!=0) {
535 HLTError("size missmatch: block size %d, indicated %d", fpInputBlocks[idx].fSize, firstWord+sizeof(AliHLTUInt32_t));
536 }
537 } else {
538 HLTFatal("block descriptor empty");
539 }
540 } else {
541 HLTError("index %d out of range %d", idx, fCurrentEventData.fBlockCnt);
542 }
543 } else {
544 HLTError("no input blocks available");
545 }
546
547 return pObj;
548}
549
550TObject* AliHLTComponent::GetInputObject(int idx, const char* classname, int bForce)
551{
552 // see header file for function documentation
553 if (fpInputObjects==NULL) {
554 fpInputObjects=new TObjArray(fCurrentEventData.fBlockCnt);
555 }
556 TObject* pObj=NULL;
557 if (fpInputObjects) {
558 pObj=fpInputObjects->At(idx);
559 if (pObj==NULL) {
560 pObj=CreateInputObject(idx, bForce);
561 if (pObj) {
562 fpInputObjects->AddAt(pObj, idx);
563 }
564 }
565 } else {
566 HLTFatal("memory allocation failed: TObjArray of size %d", fCurrentEventData.fBlockCnt);
567 }
568 return pObj;
569}
570
571int AliHLTComponent::CleanupInputObjects()
572{
573 // see header file for function documentation
574 if (!fpInputObjects) return 0;
575 TObjArray* array=fpInputObjects;
576 fpInputObjects=NULL;
577 for (int i=0; i<array->GetEntries(); i++) {
578 TObject* pObj=array->At(i);
579 // grrr, garbage collection strikes back: When read via AliHLTMessage
580 // (CreateInputObject), and written to a TFile afterwards, the
581 // TFile::Close calls ROOOT's garbage collection. No clue why the
582 // object ended up in the key list and needs to be deleted
583 if (pObj && gObjectTable->PtrIsValid(pObj)) delete pObj;
584 }
585 delete array;
586 return 0;
587}
588
589AliHLTComponentDataType AliHLTComponent::GetDataType(const TObject* pObject)
590{
591 // see header file for function documentation
592 ALIHLTCOMPONENT_BASE_STOPWATCH();
593 AliHLTComponentDataType dt=kAliHLTVoidDataType;
594 int idx=fCurrentInputBlock;
595 if (pObject) {
596 if (fpInputObjects==NULL || (idx=fpInputObjects->IndexOf(pObject))>=0) {
597 } else {
598 HLTError("unknown object %p", pObject);
599 }
600 }
601 if (idx>=0) {
602 if ((UInt_t)idx<fCurrentEventData.fBlockCnt) {
603 dt=fpInputBlocks[idx].fDataType;
604 } else {
605 HLTFatal("severe internal error, index out of range");
606 }
607 }
608 return dt;
609}
610
611AliHLTUInt32_t AliHLTComponent::GetSpecification(const TObject* pObject)
612{
613 // see header file for function documentation
614 ALIHLTCOMPONENT_BASE_STOPWATCH();
615 AliHLTUInt32_t iSpec=kAliHLTVoidDataSpec;
616 int idx=fCurrentInputBlock;
617 if (pObject) {
618 if (fpInputObjects==NULL || (idx=fpInputObjects->IndexOf(pObject))>=0) {
619 } else {
620 HLTError("unknown object %p", pObject);
621 }
622 }
623 if (idx>=0) {
624 if ((UInt_t)idx<fCurrentEventData.fBlockCnt) {
625 iSpec=fpInputBlocks[idx].fSpecification;
626 } else {
627 HLTFatal("severe internal error, index out of range");
628 }
629 }
630 return iSpec;
631}
632
633const AliHLTComponentBlockData* AliHLTComponent::GetFirstInputBlock(const AliHLTComponentDataType& dt)
634{
635 // see header file for function documentation
636 ALIHLTCOMPONENT_BASE_STOPWATCH();
637 fSearchDataType=dt;
638 fClassName.clear();
639 int idx=FindInputBlock(fSearchDataType, 0);
640 const AliHLTComponentBlockData* pBlock=NULL;
641 if (idx>=0) {
642 // check for fpInputBlocks pointer done in FindInputBlock
643 pBlock=&fpInputBlocks[idx];
644 fCurrentInputBlock=idx;
645 }
646 return pBlock;
647}
648
649const AliHLTComponentBlockData* AliHLTComponent::GetFirstInputBlock(const char* dtID,
650 const char* dtOrigin)
651{
652 // see header file for function documentation
653 ALIHLTCOMPONENT_BASE_STOPWATCH();
654 AliHLTComponentDataType dt;
655 SetDataType(dt, dtID, dtOrigin);
656 return GetFirstInputBlock(dt);
657}
658
659const AliHLTComponentBlockData* AliHLTComponent::GetInputBlock(int index)
660{
661 // see header file for function documentation
662 ALIHLTCOMPONENT_BASE_STOPWATCH();
663 assert( 0 <= index and index < fCurrentEventData.fBlockCnt );
664 return &fpInputBlocks[index];
665}
666
667const AliHLTComponentBlockData* AliHLTComponent::GetNextInputBlock()
668{
669 // see header file for function documentation
670 ALIHLTCOMPONENT_BASE_STOPWATCH();
671 int idx=FindInputBlock(fSearchDataType, fCurrentInputBlock+1);
672 const AliHLTComponentBlockData* pBlock=NULL;
673 if (idx>=0) {
674 // check for fpInputBlocks pointer done in FindInputBlock
675 pBlock=&fpInputBlocks[idx];
676 fCurrentInputBlock=idx;
677 }
678 return pBlock;
679}
680
681int AliHLTComponent::FindInputBlock(const AliHLTComponentBlockData* pBlock) const
682{
683 // see header file for function documentation
684 int iResult=-ENOENT;
685 if (fpInputBlocks!=NULL) {
686 if (pBlock) {
687 if (pBlock>=fpInputBlocks && pBlock<fpInputBlocks+fCurrentEventData.fBlockCnt) {
688 iResult=(int)(pBlock-fpInputBlocks);
689 }
690 } else {
691 iResult=-EINVAL;
692 }
693 }
694 return iResult;
695}
696
697AliHLTUInt32_t AliHLTComponent::GetSpecification(const AliHLTComponentBlockData* pBlock)
698{
699 // see header file for function documentation
700 ALIHLTCOMPONENT_BASE_STOPWATCH();
701 AliHLTUInt32_t iSpec=kAliHLTVoidDataSpec;
702 int idx=fCurrentInputBlock;
703 if (pBlock) {
704 if (fpInputObjects==NULL || (idx=FindInputBlock(pBlock))>=0) {
705 } else {
706 HLTError("unknown Block %p", pBlock);
707 }
708 }
709 if (idx>=0) {
710 // check for fpInputBlocks pointer done in FindInputBlock
711 iSpec=fpInputBlocks[idx].fSpecification;
712 }
713 return iSpec;
714}
715
716int AliHLTComponent::PushBack(TObject* pObject, const AliHLTComponentDataType& dt, AliHLTUInt32_t spec,
717 void* pHeader, int headerSize)
718{
719 // see header file for function documentation
720 ALIHLTCOMPONENT_BASE_STOPWATCH();
721 int iResult=0;
722 if (pObject) {
723 AliHLTMessage msg(kMESS_OBJECT);
724 msg.WriteObject(pObject);
725 Int_t iMsgLength=msg.Length();
726 if (iMsgLength>0) {
727 msg.SetLength(); // sets the length to the first (reserved) word
728 iResult=InsertOutputBlock(msg.Buffer(), iMsgLength, dt, spec, pHeader, headerSize);
729 if (iResult>=0) {
730 HLTDebug("object %s (%p) size %d inserted to output", pObject->ClassName(), pObject, iMsgLength);
731 }
732 } else {
733 HLTError("object serialization failed for object %p", pObject);
734 iResult=-ENOMSG;
735 }
736 } else {
737 iResult=-EINVAL;
738 }
739 return iResult;
740}
741
742int AliHLTComponent::PushBack(TObject* pObject, const char* dtID, const char* dtOrigin, AliHLTUInt32_t spec,
743 void* pHeader, int headerSize)
744{
745 // see header file for function documentation
746 ALIHLTCOMPONENT_BASE_STOPWATCH();
747 AliHLTComponentDataType dt;
748 SetDataType(dt, dtID, dtOrigin);
749 return PushBack(pObject, dt, spec, pHeader, headerSize);
750}
751
752int AliHLTComponent::PushBack(void* pBuffer, int iSize, const AliHLTComponentDataType& dt, AliHLTUInt32_t spec,
753 void* pHeader, int headerSize)
754{
755 // see header file for function documentation
756 ALIHLTCOMPONENT_BASE_STOPWATCH();
757 return InsertOutputBlock(pBuffer, iSize, dt, spec, pHeader, headerSize);
758}
759
760int AliHLTComponent::PushBack(void* pBuffer, int iSize, const char* dtID, const char* dtOrigin, AliHLTUInt32_t spec,
761 void* pHeader, int headerSize)
762{
763 // see header file for function documentation
764 ALIHLTCOMPONENT_BASE_STOPWATCH();
765 AliHLTComponentDataType dt;
766 SetDataType(dt, dtID, dtOrigin);
767 return PushBack(pBuffer, iSize, dt, spec, pHeader, headerSize);
768}
769
770int AliHLTComponent::InsertOutputBlock(void* pBuffer, int iBufferSize, const AliHLTComponentDataType& dt, AliHLTUInt32_t spec,
771 void* pHeader, int iHeaderSize)
772{
773 // see header file for function documentation
774 int iResult=0;
775 int iBlkSize = iBufferSize + iHeaderSize;
776 if (pBuffer) {
777 if (fpOutputBuffer && iBlkSize<=(int)(fOutputBufferSize-fOutputBufferFilled)) {
778 AliHLTUInt8_t* pTgt=fpOutputBuffer+fOutputBufferFilled;
779 AliHLTComponentBlockData bd;
780 FillBlockData( bd );
781 bd.fOffset = fOutputBufferFilled;
782 bd.fPtr = pTgt;
783 bd.fSize = iBlkSize;
784 bd.fDataType = dt;
785 bd.fSpecification = spec;
786 if (pHeader!=NULL && pHeader!=pTgt) {
787 memcpy(pTgt, pHeader, iHeaderSize);
788 }
789
790 pTgt += (AliHLTUInt8_t) iHeaderSize;
791
792 if (pBuffer!=NULL && pBuffer!=pTgt) {
793 memcpy(pTgt, pBuffer, iBufferSize);
794
795 //AliHLTUInt32_t firstWord=*((AliHLTUInt32_t*)pBuffer);
796 //HLTDebug("copy %d bytes from %p to output buffer %p, first word %#x", iBufferSize, pBuffer, pTgt, firstWord);
797 }
798 fOutputBufferFilled+=bd.fSize;
799 fOutputBlocks.push_back( bd );
800 //HLTDebug("buffer inserted to output: size %d data type %s spec %#x", iBlkSize, DataType2Text(dt).c_str(), spec);
801 } else {
802 if (fpOutputBuffer) {
803 HLTError("too little space in output buffer: %d, required %d", fOutputBufferSize-fOutputBufferFilled, iBlkSize);
804 } else {
805 HLTError("output buffer not available");
806 }
807 iResult=-ENOSPC;
808 }
809 } else {
810 iResult=-EINVAL;
811 }
812 return iResult;
813}
814
815int AliHLTComponent::EstimateObjectSize(TObject* pObject) const
816{
817 // see header file for function documentation
818 if (!pObject) return -EINVAL;
819 AliHLTMessage msg(kMESS_OBJECT);
820 msg.WriteObject(pObject);
821 return msg.Length();
822}
823
824AliHLTMemoryFile* AliHLTComponent::CreateMemoryFile(int capacity, const char* dtID,
825 const char* dtOrigin,
826 AliHLTUInt32_t spec)
827{
828 // see header file for function documentation
829 ALIHLTCOMPONENT_BASE_STOPWATCH();
830 AliHLTComponentDataType dt;
831 SetDataType(dt, dtID, dtOrigin);
832 return CreateMemoryFile(capacity, dt, spec);
833}
834
835AliHLTMemoryFile* AliHLTComponent::CreateMemoryFile(int capacity,
836 const AliHLTComponentDataType& dt,
837 AliHLTUInt32_t spec)
838{
839 // see header file for function documentation
840 ALIHLTCOMPONENT_BASE_STOPWATCH();
841 AliHLTMemoryFile* pFile=NULL;
842 if (capacity>=0 && static_cast<unsigned int>(capacity)<=fOutputBufferSize-fOutputBufferFilled){
843 AliHLTUInt8_t* pTgt=fpOutputBuffer+fOutputBufferFilled;
844 pFile=new AliHLTMemoryFile((char*)pTgt, capacity);
845 if (pFile) {
846 unsigned int nofBlocks=fOutputBlocks.size();
847 if (nofBlocks+1>fMemFiles.size()) {
848 fMemFiles.resize(nofBlocks+1, NULL);
849 }
850 if (nofBlocks<fMemFiles.size()) {
851 fMemFiles[nofBlocks]=pFile;
852 AliHLTComponentBlockData bd;
853 FillBlockData( bd );
854 bd.fOffset = fOutputBufferFilled;
855 bd.fPtr = pTgt;
856 bd.fSize = capacity;
857 bd.fDataType = dt;
858 bd.fSpecification = spec;
859 fOutputBufferFilled+=bd.fSize;
860 fOutputBlocks.push_back( bd );
861 } else {
862 HLTError("can not allocate/grow object array");
863 pFile->Close(0);
864 delete pFile;
865 pFile=NULL;
866 }
867 }
868 } else {
869 HLTError("can not create memory file of size %d (%d available)", capacity, fOutputBufferSize-fOutputBufferFilled);
870 }
871 return pFile;
872}
873
874AliHLTMemoryFile* AliHLTComponent::CreateMemoryFile(const char* dtID,
875 const char* dtOrigin,
876 AliHLTUInt32_t spec,
877 float capacity)
878{
879 // see header file for function documentation
880 ALIHLTCOMPONENT_BASE_STOPWATCH();
881 AliHLTComponentDataType dt;
882 SetDataType(dt, dtID, dtOrigin);
883 int size=fOutputBufferSize-fOutputBufferFilled;
884 if (capacity<0 || capacity>1.0) {
885 HLTError("invalid parameter: capacity %f", capacity);
886 return NULL;
887 }
888 size=(int)(size*capacity);
889 return CreateMemoryFile(size, dt, spec);
890}
891
892AliHLTMemoryFile* AliHLTComponent::CreateMemoryFile(const AliHLTComponentDataType& dt,
893 AliHLTUInt32_t spec,
894 float capacity)
895{
896 // see header file for function documentation
897 ALIHLTCOMPONENT_BASE_STOPWATCH();
898 int size=fOutputBufferSize-fOutputBufferFilled;
899 if (capacity<0 || capacity>1.0) {
900 HLTError("invalid parameter: capacity %f", capacity);
901 return NULL;
902 }
903 size=(int)(size*capacity);
904 return CreateMemoryFile(size, dt, spec);
905}
906
907int AliHLTComponent::Write(AliHLTMemoryFile* pFile, const TObject* pObject,
908 const char* key, int option)
909{
910 int iResult=0;
911 if (pFile && pObject) {
912 pFile->cd();
913 iResult=pObject->Write(key, option);
914 if (iResult>0) {
915 // success
916 } else {
917 iResult=-pFile->GetErrno();
918 if (iResult==-ENOSPC) {
919 HLTError("error writing memory file, buffer too small");
920 }
921 }
922 } else {
923 iResult=-EINVAL;
924 }
925 return iResult;
926}
927
928int AliHLTComponent::CloseMemoryFile(AliHLTMemoryFile* pFile)
929{
930 int iResult=0;
931 if (pFile) {
932 vector<AliHLTMemoryFile*>::iterator element=fMemFiles.begin();
933 int i=0;
934 while (element!=fMemFiles.end() && iResult>=0) {
935 if (*element && *element==pFile) {
936 iResult=pFile->Close();
937
938 // sync memory files and descriptors
939 if (iResult>=0) {
940 fOutputBlocks[i].fSize=(*element)->GetSize()+(*element)->GetHeaderSize();
941 }
942 delete *element;
943 *element=NULL;
944 return iResult;
945 }
946 element++; i++;
947 }
948 HLTError("can not find memory file %p", pFile);
949 iResult=-ENOENT;
950 } else {
951 iResult=-EINVAL;
952 }
953 return iResult;
954}
955
956int AliHLTComponent::CreateEventDoneData(AliHLTComponentEventDoneData edd)
957{
958 // see header file for function documentation
959 int iResult=-ENOSYS;
960 //#warning function not yet implemented
961 HLTWarning("function not yet implemented");
962 return iResult;
963}
964
965int AliHLTComponent::ProcessEvent( const AliHLTComponentEventData& evtData,
966 const AliHLTComponentBlockData* blocks,
967 AliHLTComponentTriggerData& trigData,
968 AliHLTUInt8_t* outputPtr,
969 AliHLTUInt32_t& size,
970 AliHLTUInt32_t& outputBlockCnt,
971 AliHLTComponentBlockData*& outputBlocks,
972 AliHLTComponentEventDoneData*& edd )
973{
974 // see header file for function documentation
975 ALIHLTCOMPONENT_BASE_STOPWATCH();
976 int iResult=0;
977 fCurrentEvent=evtData.fEventID;
978 fCurrentEventData=evtData;
979 fpInputBlocks=blocks;
980 fCurrentInputBlock=-1;
981 fSearchDataType=kAliHLTAnyDataType;
982 fpOutputBuffer=outputPtr;
983 fOutputBufferSize=size;
984 fOutputBufferFilled=0;
985 fOutputBlocks.clear();
986
987 // find special events
988 if (fpInputBlocks) {
989 for (unsigned int i=0; i<evtData.fBlockCnt && iResult>=0; i++) {
990 if (fpInputBlocks[i].fDataType==kAliHLTDataTypeSOR) {
991 // start of run
992 if (fpRunDesc==NULL) {
993 fpRunDesc=new AliHLTRunDesc;
994 if (fpRunDesc) {
995 if ((iResult=CopyStruct(fpRunDesc, sizeof(AliHLTRunDesc), i, "AliHLTRunDesc", "SOR"))>0) {
996 HLTDebug("set run decriptor, run no %d", fpRunDesc->fRunNo);
997 }
998 } else {
999 iResult=-ENOMEM;
1000 }
1001 } else {
1002 HLTWarning("already received SOR event run no %d, ignoring SOR", fpRunDesc->fRunNo);
1003 }
1004 } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeEOR) {
1005 if (fpRunDesc!=NULL) {
1006 if (fpRunDesc) {
1007 AliHLTRunDesc rundesc;
1008 if ((iResult=CopyStruct(&rundesc, sizeof(AliHLTRunDesc), i, "AliHLTRunDesc", "SOR"))>0) {
1009 if (fpRunDesc->fRunNo!=rundesc.fRunNo) {
1010 HLTWarning("run no missmatch: SOR %d, EOR %d", fpRunDesc->fRunNo, rundesc.fRunNo);
1011 } else {
1012 HLTDebug("EOR run no %d", fpRunDesc->fRunNo);
1013 }
1014 }
1015 AliHLTRunDesc* pRunDesc=fpRunDesc;
1016 fpRunDesc=NULL;
1017 delete pRunDesc;
1018 }
1019 } else {
1020 HLTWarning("did not receive SOR, ignoring EOR");
1021 }
1022 // end of run
1023 } else if (fpInputBlocks[i].fDataType==kAliHLTDataTypeDDL) {
1024 // DDL list
1025 }
1026 }
1027 }
1028
1029 vector<AliHLTComponentBlockData> blockData;
1030 { // dont delete, sets the scope for the stopwatch guard
1031 ALIHLTCOMPONENT_DA_STOPWATCH();
1032 iResult=DoProcessing(evtData, blocks, trigData, outputPtr, size, blockData, edd);
1033 } // end of the scope of the stopwatch guard
1034 if (iResult>=0) {
1035 if (fOutputBlocks.size()>0) {
1036 //HLTDebug("got %d block(s) via high level interface", fOutputBlocks.size());
1037
1038 // sync memory files and descriptors
1039 vector<AliHLTMemoryFile*>::iterator element=fMemFiles.begin();
1040 int i=0;
1041 while (element!=fMemFiles.end() && iResult>=0) {
1042 if (*element) {
1043 if ((*element)->IsClosed()==0) {
1044 HLTWarning("memory file has not been closed, force flush");
1045 iResult=CloseMemoryFile(*element);
1046 }
1047 }
1048 element++; i++;
1049 }
1050
1051 if (iResult>=0) {
1052 // create the descriptor list
1053 if (blockData.size()>0) {
1054 HLTError("low level and high interface must not be mixed; use PushBack methods to insert data blocks");
1055 iResult=-EFAULT;
1056 } else {
1057 iResult=MakeOutputDataBlockList(fOutputBlocks, &outputBlockCnt, &outputBlocks);
1058 size=fOutputBufferFilled;
1059 }
1060 }
1061 } else {
1062 iResult=MakeOutputDataBlockList(blockData, &outputBlockCnt, &outputBlocks);
1063 }
1064 if (iResult<0) {
1065 HLTFatal("component %s (%p): can not convert output block descriptor list", GetComponentID(), this);
1066 }
1067 }
1068 if (iResult<0) {
1069 outputBlockCnt=0;
1070 outputBlocks=NULL;
1071 }
1072 CleanupInputObjects();
1073 if (iResult>=0) {
1074 IncrementEventCounter();
1075 }
1076 return iResult;
1077}
1078
1079AliHLTComponent::AliHLTStopwatchGuard::AliHLTStopwatchGuard()
1080 :
1081 fpStopwatch(NULL),
1082 fpPrec(NULL)
1083{
1084 // standard constructor (not for use)
1085}
1086
1087AliHLTComponent::AliHLTStopwatchGuard::AliHLTStopwatchGuard(TStopwatch* pStopwatch)
1088 :
1089 fpStopwatch(pStopwatch),
1090 fpPrec(NULL)
1091{
1092 // constructor
1093
1094 // check for already existing guard
1095 if (fgpCurrent) fpPrec=fgpCurrent;
1096 fgpCurrent=this;
1097
1098 // stop the preceeding guard if it controls a different stopwatch
1099 int bStart=1;
1100 if (fpPrec && fpPrec!=this) bStart=fpPrec->Hold(fpStopwatch);
1101
1102 // start the stopwatch if the current guard controls a different one
1103 if (fpStopwatch && bStart==1) fpStopwatch->Start(kFALSE);
1104}
1105
1106AliHLTComponent::AliHLTStopwatchGuard::AliHLTStopwatchGuard(const AliHLTStopwatchGuard&)
1107 :
1108 fpStopwatch(NULL),
1109 fpPrec(NULL)
1110{
1111 //
1112 // copy constructor not for use
1113 //
1114}
1115
1116AliHLTComponent::AliHLTStopwatchGuard& AliHLTComponent::AliHLTStopwatchGuard::operator=(const AliHLTStopwatchGuard&)
1117{
1118 //
1119 // assignment operator not for use
1120 //
1121 fpStopwatch=NULL;
1122 fpPrec=NULL;
1123 return *this;
1124}
1125
1126AliHLTComponent::AliHLTStopwatchGuard* AliHLTComponent::AliHLTStopwatchGuard::fgpCurrent=NULL;
1127
1128AliHLTComponent::AliHLTStopwatchGuard::~AliHLTStopwatchGuard()
1129{
1130 // destructor
1131
1132 // resume the preceeding guard if it controls a different stopwatch
1133 int bStop=1;
1134 if (fpPrec && fpPrec!=this) bStop=fpPrec->Resume(fpStopwatch);
1135
1136 // stop the stopwatch if the current guard controls a different one
1137 if (fpStopwatch && bStop==1) fpStopwatch->Stop();
1138
1139 // resume to the preceeding guard
1140 fgpCurrent=fpPrec;
1141}
1142
1143int AliHLTComponent::AliHLTStopwatchGuard::Hold(TStopwatch* pSucc)
1144{
1145 // see header file for function documentation
1146 if (fpStopwatch!=NULL && fpStopwatch!=pSucc) fpStopwatch->Stop();
1147 return fpStopwatch!=pSucc?1:0;
1148}
1149
1150int AliHLTComponent::AliHLTStopwatchGuard::Resume(TStopwatch* pSucc)
1151{
1152 // see header file for function documentation
1153 if (fpStopwatch!=NULL && fpStopwatch!=pSucc) fpStopwatch->Start(kFALSE);
1154 return fpStopwatch!=pSucc?1:0;
1155}
1156
1157int AliHLTComponent::SetStopwatch(TObject* pSW, AliHLTStopwatchType type)
1158{
1159 // see header file for function documentation
1160 int iResult=0;
1161 if (pSW!=NULL && type<kSWTypeCount) {
1162 if (fpStopwatches) {
1163 TObject* pObj=fpStopwatches->At((int)type);
1164 if (pSW==NULL // explicit reset
1165 || pObj==NULL) { // explicit set
1166 fpStopwatches->AddAt(pSW, (int)type);
1167 } else if (pObj!=pSW) {
1168 HLTWarning("stopwatch %d already set, reset first", (int)type);
1169 iResult=-EBUSY;
1170 }
1171 }
1172 } else {
1173 iResult=-EINVAL;
1174 }
1175 return iResult;
1176}
1177
1178int AliHLTComponent::SetStopwatches(TObjArray* pStopwatches)
1179{
1180 // see header file for function documentation
1181 if (pStopwatches==NULL) return -EINVAL;
1182
1183 int iResult=0;
1184 for (int i=0 ; i<(int)kSWTypeCount && pStopwatches->GetEntries(); i++)
1185 SetStopwatch(pStopwatches->At(i), (AliHLTStopwatchType)i);
1186 return iResult;
1187}
1188
1189AliHLTUInt32_t AliHLTComponent::GetRunNo() const
1190{
1191 if (fpRunDesc==NULL) return 0;
1192 return fpRunDesc->fRunNo;
1193}
1194
1195AliHLTUInt32_t AliHLTComponent::GetRunType() const
1196{
1197 if (fpRunDesc==NULL) return 0;
1198 return fpRunDesc->fRunType;
1199}
1200
1201int AliHLTComponent::CopyStruct(void* pStruct, unsigned int iStructSize, unsigned int iBlockNo,
1202 const char* structname, const char* eventname)
1203{
1204 int iResult=0;
1205 if (pStruct!=NULL && iStructSize>sizeof(AliHLTUInt32_t)) {
1206 if (fpInputBlocks!=NULL && iBlockNo<fCurrentEventData.fBlockCnt) {
1207 AliHLTUInt32_t* pTgt=(AliHLTUInt32_t*)pStruct;
1208 if (fpInputBlocks[iBlockNo].fPtr && fpInputBlocks[iBlockNo].fSize) {
1209 AliHLTUInt8_t* pSrc=((AliHLTUInt8_t*)fpInputBlocks[iBlockNo].fPtr)+fpInputBlocks[iBlockNo].fOffset;
1210 AliHLTUInt32_t copy=*((AliHLTUInt32_t*)pSrc);
1211 if (fpInputBlocks[iBlockNo].fSize!=copy) {
1212 HLTWarning("%s event: missmatch of block size (%d) and structure size (%d)", eventname, fpInputBlocks[iBlockNo].fSize, copy);
1213 if (copy>fpInputBlocks[iBlockNo].fSize) copy=fpInputBlocks[iBlockNo].fSize;
1214 }
1215 if (copy!=iStructSize) {
1216 HLTWarning("%s event: missmatch in %s version (data type version %d)", eventname, structname, ALIHLT_DATA_TYPES_VERSION);
1217 if (copy>iStructSize) {
1218 copy=iStructSize;
1219 } else {
1220 memset(pTgt, 0, iStructSize);
1221 }
1222 }
1223 memcpy(pTgt, pSrc, copy);
1224 *pTgt=iStructSize;
1225 iResult=copy;
1226 } else {
1227 HLTWarning("%s event: missing data block", eventname);
1228 }
1229 } else {
1230 iResult=-ENODATA;
1231 }
1232 } else {
1233 HLTError("invalid struct");
1234 iResult=-EINVAL;
1235 }
1236 return iResult;
1237}