Cat
Classes | Public Types | Public Member Functions | Protected Member Functions | Private Attributes | List of all members
UsbFTInterfaceTest Class Reference

#include <include/UsbFTInterfaceTest.h>

Inheritance diagram for UsbFTInterfaceTest:
Processus Object Attrib

Classes

class  UsbFTInterfaceTest
 

Public Types

typedef unsigned long U32
 
typedef unsigned short U16
 
typedef unsigned char U8
 
- Public Types inherited from Processus
enum  states { ERR =-1, NOT_OK, OK }
 
- Public Types inherited from Attrib
enum  Attribut {
  UNDEFINED, PASSIVE, ACTIVE, INTERFACE,
  IO, IODATA, ELEMENT, HARDWARE,
  PROCESSUS, SOFTWARE
}
 

Public Member Functions

 UsbFTInterfaceTest ()
 Standard constructor. More...
 
virtual ~UsbFTInterfaceTest ()
 
virtual StatusCode initialize ()
 Destructor. More...
 
virtual StatusCode execute ()
 
virtual StatusCode finalize ()
 
StatusCode setAddress (long int address)
 
StatusCode setParam (int size, double mean, double sigma)
 
double mean ()
 
double sigma ()
 
- Public Member Functions inherited from Processus
 Processus ()
 Standard constructor. More...
 
virtual ~Processus ()
 Destructor. More...
 
StatusCode startProcessing ()
 
StatusCode endProcessing ()
 
void clean ()
 
void setStorage (std::string storage)
 
Datadata ()
 
std::vector< double > data (unsigned int row)
 
std::vector< double > data (std::string name)
 
Histo1Dhist1d (unsigned int row)
 
Histo2Dhist2d (unsigned int row)
 
void addDataStream (std::string name, std::string title)
 
void addHisto1d (TH1D *h)
 
void addHisto2d (TH2D *h)
 
StatusCode dataFill (int i, double val)
 
StatusCode dataFill (std::string name, double val)
 
std::string storage ()
 
void setElement (Element *element)
 
Elementelement ()
 
void incNErrors ()
 
void setNErrors (unsigned int)
 
unsigned int nErrors ()
 
TFile * rootFile ()
 
void openRootFile ()
 
void closeRootFile ()
 
void startChrono ()
 
void setLogMsg (std::string logMsg)
 
std::string logMsg ()
 
void setState (int state)
 
double elapsedTime ()
 
double elapsedTime (time_t start)
 
- Public Member Functions inherited from Object
 Object ()
 Standard constructor. More...
 
virtual ~Object ()
 Destructor. More...
 
std::string name () const
 
std::string type ()
 
unsigned char id ()
 
std::string title ()
 
void msgSvc (int level, std::string msg, std::string name)
 
void msg (std::string mymsg)
 
void verbose (std::string mymsg)
 
void debug (std::string mymsg)
 
void info (std::string mymsg)
 
void warning (std::string mymsg)
 
void error (std::string mymsg)
 
void fatal (std::string mymsg)
 
void msg (std::string mymsg, std::string name)
 
void verbose (std::string mymsg, std::string name)
 
void debug (std::string mymsg, std::string name)
 
void info (std::string mymsg, std::string name)
 
void warning (std::string mymsg, std::string name)
 
void error (std::string mymsg, std::string name)
 
void fatal (std::string mymsg, std::string name)
 
void setName (std::string name)
 
void setType (std::string type)
 
void setId (unsigned char id)
 
void setTitle (std::string title)
 
void setDllName (std::string dllName)
 
std::string dllName ()
 
- Public Member Functions inherited from Attrib
 Attrib ()
 Standard constructor. More...
 
virtual ~Attrib ()
 Destructor. More...
 
bool is (int attribut)
 
void add (int attribut)
 
void remove (int attribut)
 
std::string attributs ()
 

Protected Member Functions

UsbFTInterfaceTestclone ()
 

Private Attributes

TRandom * m_rnd
 
TH1D * m_write
 
TH1D * m_read
 
TH1D * m_error
 
unsigned int m_address
 
unsigned int m_size
 
double m_mean
 
double m_sigma
 

Additional Inherited Members

- Protected Attributes inherited from Processus
Elementm_element
 
- Protected Attributes inherited from Attrib
std::string m_attribString [10]
 

Detailed Description

Author
Frederic Machefert
Date
2010-01-07

Definition at line 18 of file UsbFTInterfaceTest.h.

Member Typedef Documentation

◆ U16

typedef unsigned short UsbFTInterfaceTest::U16

Definition at line 21 of file UsbFTInterfaceTest.h.

◆ U32

typedef unsigned long UsbFTInterfaceTest::U32

Definition at line 20 of file UsbFTInterfaceTest.h.

◆ U8

typedef unsigned char UsbFTInterfaceTest::U8

Definition at line 22 of file UsbFTInterfaceTest.h.

Constructor & Destructor Documentation

◆ UsbFTInterfaceTest()

Standard constructor.

Definition at line 23 of file UsbFTInterfaceTest.cpp.

References Object::setName(), Object::setTitle(), and Object::setType().

Referenced by clone().

23  :
24  m_address(1),
25  m_size (64),
26  m_mean (30000.),
27  m_sigma(10000.)
28  {
29  setName ( "UsbFTInterfaceTest" );
30  setType ( "UsbFTInterface" );
31  setTitle( "UsbFTInterface test" );
32 }
void setName(std::string name)
Definition: Object.h:51
void setType(std::string type)
Definition: Object.h:52
void setTitle(std::string title)
Definition: Object.h:54

◆ ~UsbFTInterfaceTest()

virtual UsbFTInterfaceTest::~UsbFTInterfaceTest ( )
inlinevirtual

Definition at line 26 of file UsbFTInterfaceTest.h.

References execute(), finalize(), and initialize().

26 {};

Member Function Documentation

◆ clone()

UsbFTInterfaceTest* UsbFTInterfaceTest::clone ( )
inlineprotectedvirtual

processus termination virtual function

Implements Processus.

Definition at line 53 of file UsbFTInterfaceTest.h.

References UsbFTInterfaceTest().

53  {
54  return new UsbFTInterfaceTest (*this);
55  }
UsbFTInterfaceTest()
Standard constructor.

◆ execute()

StatusCode UsbFTInterfaceTest::execute ( )
virtual

processus execution virtual function

Implements Processus.

Definition at line 56 of file UsbFTInterfaceTest.cpp.

References Processus::dataFill(), Processus::elapsedTime(), Processus::element(), m_address, m_error, m_mean, m_read, m_rnd, m_sigma, m_size, m_write, UsbFTInterface::setWordSize(), StatusCode::SUCCESS, UsbFTInterface::usbRead(), UsbFTInterface::usbWrite(), Object::warning(), and UsbFTInterface::WS_Word.

Referenced by ~UsbFTInterfaceTest().

56  {
57 
58  // prepare vector to be written
59  std::vector<U32> write,read;
60  write.reserve(m_size);
61  read.reserve(m_size);
62  for (unsigned int i=0; i<m_size; ++i){
63  write.push_back((unsigned int)((U16)(m_rnd->Gaus(m_mean,m_sigma))));
64  }
65 
66  // fetch the usb interface
67  UsbFTInterface *usb=dynamic_cast<UsbFTInterface*>( element() );
69 
70  // write / read and measure times
71  float tw,tr;
72  clock_t start;
73  start=clock();
74  usb->usbWrite(m_address,write);
75  tw=elapsedTime(start);
76  start=clock();
77  usb->usbRead(m_address,m_size,read);
78  tr=elapsedTime(start);
79  dataFill("TimeWrite",tw);
80  dataFill("TimeRead",tr);
81 
82  // store values and check errors
83  float w,r;
84  for (unsigned int i=0; i<m_size; ++i){
85  w=write[i];
86  r=read[i];
87  dataFill("Write",w);
88  m_write->Fill(w);
89  m_read->Fill(r);
90  if (w!=r){
91  warning("Error!");
92  m_error->Fill(w);
93  dataFill("ErrorWrite",w);
94  dataFill("ErrorRead",r);
95  }
96  }
97  return StatusCode::SUCCESS;
98 }
StatusCode usbRead(unsigned long int, unsigned long int, std::vector< U32 > &)
StatusCode usbWrite(unsigned long int, std::vector< U32 >)
double elapsedTime()
Definition: Processus.h:340
Element * element()
Definition: Processus.h:231
unsigned short U16
Definition: ICECALv3.h:54
void setWordSize(unsigned long wordSize)
StatusCode dataFill(int i, double val)
Definition: Processus.h:175
void warning(std::string mymsg)
Definition: Object.h:39

◆ finalize()

StatusCode UsbFTInterfaceTest::finalize ( )
virtual

processus termination virtual function

Implements Processus.

Definition at line 103 of file UsbFTInterfaceTest.cpp.

References Processus::closeRootFile(), and StatusCode::SUCCESS.

Referenced by ~UsbFTInterfaceTest().

103  {
104  closeRootFile(); // Deletes the histos -> do not make it yourself !!!
105  return StatusCode::SUCCESS;
106 }
void closeRootFile()
Definition: Processus.cpp:160

◆ initialize()

StatusCode UsbFTInterfaceTest::initialize ( )
virtual

Destructor.

Implements Processus.

Definition at line 37 of file UsbFTInterfaceTest.cpp.

References Processus::addDataStream(), m_error, m_read, m_rnd, m_write, Processus::openRootFile(), and StatusCode::SUCCESS.

Referenced by ~UsbFTInterfaceTest().

37  {
38  openRootFile ();
39  m_write=new TH1D( "Write" , "Write" , 1000 , 0. , 65535. );
40  m_read =new TH1D( "Read" , "Read" , 1000 , 0. , 65535. );
41  m_error=new TH1D( "Error" , "Error" , 1000 , 0. , 65535. );
42  m_rnd =new TRandom();
43  addDataStream("Write","Written values");
44  addDataStream("ErrorWrite","Error - Written values if Error");
45  addDataStream("ErrorRead","Error - Read values if Error");
46  addDataStream("TimeWrite","Time to write");
47  addDataStream("TimeRead","Time to read");
48  // addHisto1d( m_write );
49  // addHisto1d( m_read );
50  return StatusCode::SUCCESS;
51 }
void openRootFile()
Definition: Processus.cpp:146
void addDataStream(std::string name, std::string title)
Definition: Processus.h:153

◆ mean()

double UsbFTInterfaceTest::mean ( )
inline

Definition at line 44 of file UsbFTInterfaceTest.h.

References m_mean.

Referenced by BOOST_PYTHON_MODULE(), and setParam().

44  {
45  return m_mean;
46  }

◆ setAddress()

StatusCode UsbFTInterfaceTest::setAddress ( long int  address)
inline

Definition at line 32 of file UsbFTInterfaceTest.h.

References m_address, and StatusCode::SUCCESS.

Referenced by BOOST_PYTHON_MODULE().

32  {
33  m_address=address;
34  return StatusCode::SUCCESS;
35  }

◆ setParam()

StatusCode UsbFTInterfaceTest::setParam ( int  size,
double  mean,
double  sigma 
)
inline

Definition at line 37 of file UsbFTInterfaceTest.h.

References m_mean, m_sigma, m_size, mean(), sigma(), cat::size, and StatusCode::SUCCESS.

Referenced by BOOST_PYTHON_MODULE().

◆ sigma()

double UsbFTInterfaceTest::sigma ( )
inline

Definition at line 48 of file UsbFTInterfaceTest.h.

References m_mean.

Referenced by BOOST_PYTHON_MODULE(), setParam(), and UsbFTInterfaceTest.UsbFTInterfaceTest::update().

48  {
49  return m_mean;
50  }

Member Data Documentation

◆ m_address

unsigned int UsbFTInterfaceTest::m_address
private

Definition at line 60 of file UsbFTInterfaceTest.h.

Referenced by execute(), and setAddress().

◆ m_error

TH1D * UsbFTInterfaceTest::m_error
private

Definition at line 59 of file UsbFTInterfaceTest.h.

Referenced by execute(), and initialize().

◆ m_mean

double UsbFTInterfaceTest::m_mean
private

Definition at line 61 of file UsbFTInterfaceTest.h.

Referenced by execute(), mean(), setParam(), and sigma().

◆ m_read

TH1D * UsbFTInterfaceTest::m_read
private

Definition at line 59 of file UsbFTInterfaceTest.h.

Referenced by execute(), and initialize().

◆ m_rnd

TRandom* UsbFTInterfaceTest::m_rnd
private

Definition at line 58 of file UsbFTInterfaceTest.h.

Referenced by execute(), and initialize().

◆ m_sigma

double UsbFTInterfaceTest::m_sigma
private

Definition at line 61 of file UsbFTInterfaceTest.h.

Referenced by execute(), and setParam().

◆ m_size

unsigned int UsbFTInterfaceTest::m_size
private

Definition at line 60 of file UsbFTInterfaceTest.h.

Referenced by execute(), and setParam().

◆ m_write

TH1D* UsbFTInterfaceTest::m_write
private

Definition at line 59 of file UsbFTInterfaceTest.h.

Referenced by execute(), and initialize().


The documentation for this class was generated from the following files: