Cat
TestUSB.cpp
Go to the documentation of this file.
1 // $Id: TestUSB.cpp,v 1.4 2006/03/16 17:08:23 fmachefe Exp $
2 
3 // Include files
4 #include <ctime>
5 
6 // ROOT include files
7 #include "TRandom.h"
8 #include "TH2D.h"
9 #include "TH1D.h"
10 
11 // local
12 #include "TestUSB.h"
13 
14 //-----------------------------------------------------------------------------
15 // Implementation file for class : TestUSB
16 //
17 // 2004-07-23 : Fr�d�ric Machefert
18 //-----------------------------------------------------------------------------
19 
20 //=============================================================================
21 // Standard constructor, initializes variables
22 //=============================================================================
24 {
25  setName ( "TestUSB" );
26  setType ( "FEB_v1" );
27  setTitle( "USB interface test" );
28 }
29 
30 //=========================================================================
31 // virtual function intialize
32 //=========================================================================
34  m_board=dynamic_cast<FEB_v1*>( element() );
35 
36  if (!m_board){
37  warning("TestUSB","No FEB_v1 board found. Interrupt." );
38  return false;
39  }
40 
41  SeqPGA* seqPga = m_board->seqPga();
42  if (!seqPga){
43  warning("TestUSB","No SeqPga found. Interrupt." );
44  return false;
45  }
46 
47  m_reg=seqPga->setupReg();
48  m_rnd =new TRandom();
49 
50  addDataStream("Input","Input value");
51  addDataStream("Output","Output value");
52  addDataStream("Errors","Error input value");
53  addDataStream("Errors","Error output value");
54  return StatusCode::SUCCESS;
55 }
56 
57 //=========================================================================
58 // Virtual function execute
59 //=========================================================================
61  int value = 65536.*m_rnd->Uniform();
62  dataFill(0, value);
63  m_reg->io()->setU8(0,value&0xFF);
64  m_reg->io()->setU8(1,(value>>8)&0xFF);
65  m_reg->write();
66  m_reg->read();
67  int tmp = (m_reg->io()->dataU8(0))+((m_reg->io()->dataU8(1))<<8) ;
68  dataFill(1, tmp);
69  if (tmp!=value){
70  dataFill(2, value);
71  dataFill(3, tmp);
72  }
73  return StatusCode::SUCCESS;
74 }
75 
76 //=========================================================================
77 // Virtual function finalize
78 //=========================================================================
80  return StatusCode::SUCCESS;
81 }
TestUSB()
Standard constructor.
Definition: TestUSB.cpp:23
virtual StatusCode write()
Definition: IOobject.h:80
StatusCode setU8(unsigned long int, U8)
Definition: IOdata.cpp:43
void setName(std::string name)
Definition: Object.h:51
void addDataStream(std::string name, std::string title)
Definition: Processus.h:153
virtual StatusCode read()
Definition: IOobject.h:73
void setType(std::string type)
Definition: Object.h:52
Definition: FEB_v1.h:21
virtual StatusCode execute()
Definition: TestUSB.cpp:60
void setTitle(std::string title)
Definition: Object.h:54
U8 * dataU8()
Definition: IOdata.h:214
Register * setupReg()
Definition: SeqPGA.h:91
SeqPGA * seqPga()
Definition: FEB_v1.h:63
Register * m_reg
Definition: TestUSB.h:38
Element * element()
Definition: Processus.h:231
virtual StatusCode finalize()
Definition: TestUSB.cpp:79
StatusCode dataFill(int i, double val)
Definition: Processus.h:175
TRandom * m_rnd
Definition: TestUSB.h:39
void warning(std::string mymsg)
Definition: Object.h:39
Definition: SeqPGA.h:23
virtual StatusCode initialize()
Destructor.
Definition: TestUSB.cpp:33
IOdata * io()
Definition: IOobject.h:66
FEB_v1 * m_board
Definition: TestUSB.h:34