Cat
Public Types | Public Member Functions | Private Attributes | List of all members
UsbI2cBus Class Reference

#include <inc/UsbI2cBus.h>

Inheritance diagram for UsbI2cBus:
Interface Element Hierarchy Object Attrib

Public Types

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

Public Member Functions

 UsbI2cBus ()
 Standard constructor. More...
 
virtual ~UsbI2cBus ()
 Destructor. More...
 
void help ()
 
virtual StatusCode init ()
 
void reset ()
 
void update ()
 
RegisterregAddress ()
 
RegisterregData ()
 
virtual StatusCode read (IOdata *)
 
virtual StatusCode write (IOdata *)
 
- Public Member Functions inherited from Interface
 Interface ()
 Standard constructor. More...
 
virtual ~Interface ()
 Destructor. More...
 
- Public Member Functions inherited from Element
 Element ()
 Standard constructor. More...
 
virtual ~Element ()
 Destructor. More...
 
void recursiveInitElement ()
 
void recursiveInitCommunications ()
 
StatusCode setConnection (Hierarchy *)
 
Hierarchyconnection ()
 
- Public Member Functions inherited from Hierarchy
 Hierarchy ()
 Standard constructor. More...
 
virtual ~Hierarchy ()
 Destructor. More...
 
void clear ()
 
void setParent (Hierarchy *parent)
 
Hierarchyparent ()
 
Hierarchyparent (std::string)
 
Hierarchyorigin ()
 
virtual void addChild (Hierarchy *element)
 
std::vector< Hierarchy * > children ()
 
Hierarchychild (std::string)
 
HierarchychildTyped (std::string)
 
unsigned long numberOfChildren ()
 
bool hasChildren ()
 
void delChild (Hierarchy *)
 
void delChild (std::string)
 
std::string path (std::string=std::string(""))
 
std::string pathTyped (std::string=std::string(""))
 
void tree (std::string indent=std::string(""))
 
void tree ()
 
- 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 ()
 

Private Attributes

Registerm_regAddress
 
Registerm_regData
 

Additional Inherited Members

- Protected Attributes inherited from Element
Hierarchym_connection
 
- Protected Attributes inherited from Attrib
std::string m_attribString [10]
 

Detailed Description

Author
Date
2006-10-23

Definition at line 16 of file UsbI2cBus.h.

Member Typedef Documentation

◆ U16

typedef unsigned short UsbI2cBus::U16

Definition at line 19 of file UsbI2cBus.h.

◆ U32

typedef unsigned long UsbI2cBus::U32

Definition at line 18 of file UsbI2cBus.h.

◆ U8

typedef unsigned char UsbI2cBus::U8

Definition at line 20 of file UsbI2cBus.h.

Constructor & Destructor Documentation

◆ UsbI2cBus()

UsbI2cBus::UsbI2cBus ( )

Standard constructor.

Definition at line 17 of file UsbI2cBus.cpp.

References Hierarchy::addChild(), IOdata::Byte, IOdata::defDataU8(), IOobject::io(), m_regAddress, m_regData, IOdata::setAddress(), Object::setName(), Object::setType(), and IOdata::setWordSize().

17  {
18  setName("UsbI2cBus");
19  setType("UsbI2cBus");
20 
21  m_regAddress=new Register();
22  m_regData=new Register();
23 
24  m_regAddress->setName("AddReg");
25  m_regData ->setName("DataReg");
26 
27  m_regAddress->io()->defDataU8(4);
28  m_regAddress->io()->setAddress(0);
29 
30  m_regData->io()->setAddress(0);
31 
34 
37 }
void setName(std::string name)
Definition: Object.h:51
void setType(std::string type)
Definition: Object.h:52
Register * m_regAddress
Definition: UsbI2cBus.h:69
StatusCode setAddress(U32 address)
Definition: IOdata.h:51
virtual void addChild(Hierarchy *element)
Definition: Hierarchy.cpp:83
StatusCode setWordSize(IOdata::WordSize wordSize)
Definition: IOdata.h:126
void defDataU8(unsigned long size)
Definition: IOdata.h:179
Register * m_regData
Definition: UsbI2cBus.h:70
IOdata * io()
Definition: IOobject.h:66

◆ ~UsbI2cBus()

UsbI2cBus::~UsbI2cBus ( )
virtual

Destructor.

Definition at line 41 of file UsbI2cBus.cpp.

41  {
42 // delete m_regData;
43 // delete m_regAddress;
44 }

Member Function Documentation

◆ help()

void UsbI2cBus::help ( )
inlinevirtual

printout help for the element

Implements Interface.

Definition at line 29 of file UsbI2cBus.h.

References Object::info(), init(), and Object::name().

Referenced by BOOST_PYTHON_MODULE().

29 { info("UsbI2cBus "+name()+". No help.","UsbI2cBus::help"); };
void info(std::string mymsg)
Definition: Object.h:38
std::string name() const
Definition: Object.h:28

◆ init()

StatusCode UsbI2cBus::init ( )
virtual

init the component

Returns
void

Implements Interface.

Definition at line 49 of file UsbI2cBus.cpp.

References StatusCode::FAILURE, Object::fatal(), Element::m_connection, Hierarchy::parent(), Element::setConnection(), StatusCode::SUCCESS, and Object::type().

Referenced by BOOST_PYTHON_MODULE(), and help().

49  {
50  if (0==m_connection){
51  if (0==this->parent()){
52  fatal("Cannot define connection for "+type()+". No parent found.",
53  "UsbI2cBus::init");
54  return StatusCode::FAILURE;
55  }
56  return setConnection(this->parent());
57  }
58  else return StatusCode::SUCCESS;
59 }
Hierarchy * m_connection
Definition: Element.h:70
StatusCode setConnection(Hierarchy *)
Definition: Element.cpp:55
Hierarchy * parent()
Definition: Hierarchy.h:28
void fatal(std::string mymsg)
Definition: Object.h:41
std::string type()
Definition: Object.h:29

◆ read()

StatusCode UsbI2cBus::read ( IOdata io)
virtual

Implements Interface.

Definition at line 64 of file UsbI2cBus.cpp.

References IOdata::address(), Element::connection(), IOdata::dataU8(), StatusCode::FAILURE, IOobject::io(), IOdata::length(), Element::m_connection, m_regAddress, m_regData, Interface::read(), IOdata::setDataU8(), StatusCode::SUCCESS, Object::warning(), and Interface::write().

Referenced by regData().

64  {
65  U8* buffer=m_regAddress->io()->dataU8();
66  buffer[0]=(U8)(io->address());
67  buffer[1]=(U8)(0);
68  buffer[2]=(U8)(0);
69  buffer[3]=(U8)(0);
70  m_regData->io()->setDataU8(io->dataU8(),io->length());
71  Interface* connection = dynamic_cast<Interface*> (m_connection);
72  if (connection->write(m_regAddress->io()).isFailure()){
73  warning("Cannot write Address register on UsbI2cBus",
74  "UsbI2cBus::read");
75  return StatusCode::FAILURE;
76  }
77  if (connection->read(m_regData->io()).isFailure()){
78  warning("Cannot read Data register on UsbI2cBus",
79  "UsbI2cBus::read"); ;
80  return StatusCode::FAILURE;
81  }
82  return StatusCode::SUCCESS;
83 }
Hierarchy * connection()
Definition: Element.cpp:84
Hierarchy * m_connection
Definition: Element.h:70
U32 address()
Definition: IOdata.h:59
virtual StatusCode read(IOdata *)=0
unsigned char U8
Definition: ICECALv3.h:55
virtual StatusCode write(IOdata *)=0
Register * m_regAddress
Definition: UsbI2cBus.h:69
unsigned char U8
Definition: UsbI2cBus.h:20
U32 length()
Definition: IOdata.h:175
U8 * dataU8()
Definition: IOdata.h:214
void setDataU8(U8 *data, U32 length)
Definition: IOdata.h:239
Register * m_regData
Definition: UsbI2cBus.h:70
void warning(std::string mymsg)
Definition: Object.h:39
IOdata * io()
Definition: IOobject.h:66

◆ regAddress()

Register* UsbI2cBus::regAddress ( )
inline

Definition at line 54 of file UsbI2cBus.h.

References m_regAddress.

Referenced by BOOST_PYTHON_MODULE(), and Proto40MHz_v1::Proto40MHz_v1().

54  {
55  return m_regAddress;
56  };
Register * m_regAddress
Definition: UsbI2cBus.h:69

◆ regData()

Register* UsbI2cBus::regData ( )
inline

Definition at line 58 of file UsbI2cBus.h.

References m_regData, read(), and write().

Referenced by BOOST_PYTHON_MODULE(), and Proto40MHz_v1::Proto40MHz_v1().

58  {
59  return m_regData;
60  };
Register * m_regData
Definition: UsbI2cBus.h:70

◆ reset()

void UsbI2cBus::reset ( )
inlinevirtual

Resets the Element so that is is in a standard and safe situation. Different from Element::init which configure the Element. Element::reset() is more an Emergency pull. It is often/usually called by the recursiveInitElement method at the start of the program.

Implements Interface.

Definition at line 45 of file UsbI2cBus.h.

References Object::info(), and Object::name().

Referenced by BOOST_PYTHON_MODULE().

45 { info("UsbI2cBus "+name()+" reset.","UsbI2cBus::reset");};
void info(std::string mymsg)
Definition: Object.h:38
std::string name() const
Definition: Object.h:28

◆ update()

void UsbI2cBus::update ( )
inlinevirtual

Update the Element configuration from the actual hardware

Implements Interface.

Definition at line 50 of file UsbI2cBus.h.

References Object::info(), and Object::name().

Referenced by BOOST_PYTHON_MODULE(), AppFrame.AppFrame::deleteHardware(), ConfFrame.ConfFrame::onChange(), GraphFrame.GraphFrame::onChange(), CfgFrame.CfgFrame::onChange(), ConfFrame.ConfFrame::onEdit(), AppFrame.AppFrame::onLoad(), ConfFrame.ConfFrame::onReLoad(), GraphFrame.GraphFrame::onReLoad(), CfgFrame.CfgFrame::onReLoad(), and AppFrame.AppFrame::onReLoad().

50  {
51  info("UsbI2cBus "+name()+". Nothing to do.","UsbI2cBus::update");
52  };
void info(std::string mymsg)
Definition: Object.h:38
std::string name() const
Definition: Object.h:28

◆ write()

StatusCode UsbI2cBus::write ( IOdata io)
virtual

Implements Interface.

Definition at line 88 of file UsbI2cBus.cpp.

References IOdata::address(), Element::connection(), IOdata::dataU8(), StatusCode::FAILURE, IOobject::io(), IOdata::length(), Element::m_connection, m_regAddress, m_regData, IOdata::setDataU8(), StatusCode::SUCCESS, Object::warning(), and Interface::write().

Referenced by regData().

88  {
89  U8* buffer=m_regAddress->io()->dataU8();
90  buffer[0]=(U8)(io->address());
91  buffer[1]=(U8)(0);
92  buffer[2]=(U8)(0);
93  buffer[3]=(U8)(0);
94  m_regData->io()->setDataU8(io->dataU8(),io->length());
95  Interface* connection = dynamic_cast<Interface*> (m_connection);
96  if (connection->write(m_regAddress->io()).isFailure()){
97  warning("Cannot write Address register on UsbI2cBus",
98  "UsbI2cBus::write");
99  return StatusCode::FAILURE;
100  }
101  if (connection->write(m_regData->io()).isFailure()){
102  warning("Cannot write Data register on UsbI2cBus","UsbI2cBus::write");
103  return StatusCode::FAILURE;
104  }
105  return StatusCode::SUCCESS;
106 }
Hierarchy * connection()
Definition: Element.cpp:84
Hierarchy * m_connection
Definition: Element.h:70
U32 address()
Definition: IOdata.h:59
unsigned char U8
Definition: ICECALv3.h:55
virtual StatusCode write(IOdata *)=0
Register * m_regAddress
Definition: UsbI2cBus.h:69
unsigned char U8
Definition: UsbI2cBus.h:20
U32 length()
Definition: IOdata.h:175
U8 * dataU8()
Definition: IOdata.h:214
void setDataU8(U8 *data, U32 length)
Definition: IOdata.h:239
Register * m_regData
Definition: UsbI2cBus.h:70
void warning(std::string mymsg)
Definition: Object.h:39
IOdata * io()
Definition: IOobject.h:66

Member Data Documentation

◆ m_regAddress

Register* UsbI2cBus::m_regAddress
private

Definition at line 69 of file UsbI2cBus.h.

Referenced by read(), regAddress(), UsbI2cBus(), and write().

◆ m_regData

Register* UsbI2cBus::m_regData
private

Definition at line 70 of file UsbI2cBus.h.

Referenced by read(), regData(), UsbI2cBus(), and write().


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