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

#include <inc/SpecsMezzanine.h>

Inheritance diagram for SpecsMezzanine:
SpecsSlave SpecsInterface Interface Element Hierarchy Object Attrib

Public Member Functions

 SpecsMezzanine ()
 Standard constructor. More...
 
virtual ~SpecsMezzanine ()
 Standard Desctructor. More...
 
void addBus (Element *)
 
void help ()
 
bool led ()
 
int date ()
 
void setLed (bool)
 
bool cmdline (std::vector< std::string >)
 
- Public Member Functions inherited from SpecsSlave
 SpecsSlave ()
 
 ~SpecsSlave ()
 
void addI2c (Hierarchy *)
 
void setAddress (unsigned char)
 
SPECSSLAVE * specsSlaveDevice ()
 
bool detect ()
 
StatusCode init ()
 
void recursiveInitCommunications ()
 
void resetInternal ()
 
void reset ()
 
- Public Member Functions inherited from SpecsInterface
 SpecsInterface ()
 
virtual ~SpecsInterface ()
 
virtual void update ()
 
void setAddress (unsigned char)
 
unsigned char address ()
 
void setOutputSelect (unsigned char)
 
unsigned char outputSelect ()
 
virtual SpecsSlavespecsSlave ()
 
virtual SpecsMasterspecsMaster ()
 
virtual SPECSMASTER * specsMasterDevice ()
 
virtual StatusCode read (IOdata *io)
 
virtual StatusCode write (IOdata *io)
 
bool specsWriteI2c (unsigned char address, unsigned char nData, U8 *data)
 
bool specsWriteI2c (unsigned char address, std::vector< U8 > data)
 
bool specsReadI2c (unsigned char address, unsigned char nOctects, U8 *i2cWords)
 
bool specsReadI2c (unsigned char address, std::vector< unsigned char > &specsWords)
 
bool specsWriteI2c (unsigned char address, unsigned char subAddress, unsigned char nData, U8 *data)
 
bool specsWriteI2c (unsigned char address, unsigned char outputSel, unsigned char subAddress, unsigned char nData, U8 *data)
 
bool specsReadI2c (unsigned char address, unsigned char subAddress, unsigned char nOctets, U8 *i2cWords)
 
bool specsReadI2c (unsigned char address, unsigned char outputSel, unsigned char subAddress, unsigned char nOctets, U8 *i2cWords)
 
bool specsWriteParallel (unsigned char address, unsigned short data)
 
bool specsReadParallel (unsigned char address, U16 &data)
 
bool specsWriteRegister (unsigned char, unsigned short)
 
bool specsReadRegister (unsigned char, U16 &)
 
- 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

SpecsBusm_bus
 
DCUm_dcu
 

Additional Inherited Members

- Public Types inherited from Attrib
enum  Attribut {
  UNDEFINED, PASSIVE, ACTIVE, INTERFACE,
  IO, IODATA, ELEMENT, HARDWARE,
  PROCESSUS, SOFTWARE
}
 
- Protected Attributes inherited from SpecsSlave
SpecsI2ci2c
 
- Protected Attributes inherited from SpecsInterface
unsigned char m_address
 
unsigned char m_outputSelect
 
- Protected Attributes inherited from Element
Hierarchym_connection
 
- Protected Attributes inherited from Attrib
std::string m_attribString [10]
 

Detailed Description

Author
Frédéric Machefert
Date
2005-05-25

Definition at line 18 of file SpecsMezzanine.h.

Constructor & Destructor Documentation

◆ SpecsMezzanine()

SpecsMezzanine::SpecsMezzanine ( )

Standard constructor.

Definition at line 22 of file SpecsMezzanine.cpp.

References Hierarchy::addChild(), SpecsSlave::addI2c(), Object::debug(), m_bus, m_dcu, SpecsSlave::setAddress(), DCU::setAddress(), Object::setName(), DCU::setOutputSelect(), Hierarchy::setParent(), and Object::setType().

22  {
23  debug("SpecsMezzanine::SpecsMezzanine","SpecsMezzanine built.");
24 
25  setAddress(0x0);
26  setName("SpecsMezzanine");
27  setType("SpecsMezzanine");
28 
29  m_bus = new SpecsBus();
30  m_bus->setParent(this);
31  addChild(m_bus);
32 
33  m_dcu=new DCU();
34  m_dcu->setName("DCU");
35  m_dcu->setOutputSelect (0xF) ; // i2c short distance for DCU
36  m_dcu->setAddress (0) ;
37  addI2c(m_dcu);
38 }
void setOutputSelect(U8 outputSelect)
Definition: DCU.h:54
void setParent(Hierarchy *parent)
Definition: Hierarchy.cpp:67
void setName(std::string name)
Definition: Object.h:51
void setAddress(U8 address)
Definition: DCU.h:51
void setType(std::string type)
Definition: Object.h:52
void debug(std::string mymsg)
Definition: Object.h:37
void setAddress(unsigned char)
Definition: SpecsSlave.cpp:50
Definition: DCU.h:15
SpecsBus * m_bus
virtual void addChild(Hierarchy *element)
Definition: Hierarchy.cpp:83
void addI2c(Hierarchy *)
Definition: SpecsSlave.cpp:175

◆ ~SpecsMezzanine()

SpecsMezzanine::~SpecsMezzanine ( )
virtual

Standard Desctructor.

Destructor

Definition at line 43 of file SpecsMezzanine.cpp.

43 {}

Member Function Documentation

◆ addBus()

void SpecsMezzanine::addBus ( Element element)

Add o device on the parallel bus of the specs mezzanine

Definition at line 48 of file SpecsMezzanine.cpp.

References Hierarchy::addChild(), Object::debug(), m_bus, Object::name(), and Hierarchy::setParent().

48  {
49  element->setParent(m_bus);
50  m_bus->addChild(element);
51  debug("SpecsMezzanine::addBus",
52  element->name()+" added to the bus child tree.");
53 }
void setParent(Hierarchy *parent)
Definition: Hierarchy.cpp:67
void debug(std::string mymsg)
Definition: Object.h:37
SpecsBus * m_bus
std::string name() const
Definition: Object.h:28
virtual void addChild(Hierarchy *element)
Definition: Hierarchy.cpp:83

◆ cmdline()

bool SpecsMezzanine::cmdline ( std::vector< std::string >  cmd)

access to the command line function

Definition at line 58 of file SpecsMezzanine.cpp.

References Attrib::add(), SpecsInterface::address(), shell::data(), date(), help(), Object::info(), itos(), SpecsSlave::reset(), SpecsSlave::resetInternal(), SpecsSlave::setAddress(), setLed(), SpecsInterface::specsReadI2c(), SpecsInterface::specsReadRegister(), SpecsInterface::specsWriteI2c(), and SpecsInterface::specsWriteRegister().

58  {
59 
60  if ( cmd.size()==0){
61  info("cmdline","Date : "+itos(date()));
62  return true;
63  info("cmdline","Address [Address] : "+itos(address()));
64  return true;
65  }
66 
67  transform(cmd[0].begin(),cmd[0].end(),cmd[0].begin(),tolower);
68 
69  if (cmd[0].compare("address")==0){
70  this->setAddress(atoi(cmd[1].c_str()));
71  return true;
72  }
73 
74  if (cmd[0].compare("address")==0){
75  this->setAddress(atoi(cmd[1].c_str()));
76  return true;
77  }
78 
79  if (cmd[0].compare("reset")==0){
80  this->reset();
81  return true;
82  }
83 
84  if (cmd[0].compare("internalreset")==0){
85  this->resetInternal();
86  return true;
87  }
88 
89  if (cmd[0].compare("led")==0){
90  if ( 0==atoi(cmd[1].c_str()) ) {
91  setLed ( false );
92  }
93  else {
94  setLed ( true );
95  }
96  return true;
97  }
98 
99  if (cmd[0].compare("regwrite")==0){
100  info("cmdline",
101  "Register "+ cmd[1]+ " -> Write " + cmd[2]);
102  this->specsWriteRegister( atoi(cmd[1].c_str()),
103  atoi(cmd[2].c_str()));
104  return true;
105  }
106 
107  if (cmd[0].compare("i2cwritereg")==0){
108  int add = atoi(cmd[1].c_str());
109  int out = atoi(cmd[2].c_str());
110  int ssadd = atoi(cmd[3].c_str());
111  int nword = atoi(cmd[4].c_str());
112  U8 data[100];
113  for ( int i = 0 ; i< nword ; ++i ) {
114  data[i]=(unsigned char) (atoi(cmd[5+i].c_str()));
115  }
116  info("cmdline",
117  "I2C Register "+ cmd[2]+ "/" + itos(add) +
118  " -> Write " + cmd[4] + " words.");
119  this->specsWriteI2c( add , out , ssadd , nword, data );
120  return true;
121  }
122 
123  if (cmd[0].compare("i2creadreg")==0){
124  int add = atoi(cmd[1].c_str());
125  int out = atoi(cmd[2].c_str());
126  int ssadd = atoi(cmd[3].c_str());
127  int nword = atoi(cmd[4].c_str());
128  U8 data[100];
129  info("cmdline",
130  "I2C Register "+ cmd[2]+ "/" + itos(add) +
131  " -> Read " + cmd[3] + " words.");
132  this->specsReadI2c( add , out , ssadd , nword, data );
133  for ( int i = 0 ; i< nword ; ++i ) {
134  info(""," word ["+ itos (i) + "]" + itos(data[i]));
135  }
136  return true;
137  }
138 
139  if (cmd[0].compare("regread")==0){
140  U16 val;
141  this->specsReadRegister( atoi(cmd[1].c_str()),
142  val);
143  info("cmdline",
144  "Register "+ cmd[1]+ " -> " + itos(val) );
145  return true;
146  }
147 
148  if (cmd[0].compare("help")==0){
149  this->help();
150  return true;
151  }
152 
153  return false;
154 }
void info(std::string mymsg)
Definition: Object.h:38
std::string itos(int)
Definition: Tools.cpp:46
void reset()
Definition: SpecsSlave.cpp:204
void add(int attribut)
Definition: Attrib.h:67
bool specsReadI2c(unsigned char address, unsigned char nOctects, U8 *i2cWords)
bool specsWriteI2c(unsigned char address, unsigned char nData, U8 *data)
unsigned char address()
void resetInternal()
Definition: SpecsSlave.cpp:184
bool specsWriteRegister(unsigned char, unsigned short)
unsigned char U8
Definition: ICECALv3.h:55
def data(object, stream=None)
Definition: shell.py:150
void setAddress(unsigned char)
Definition: SpecsSlave.cpp:50
unsigned short U16
Definition: ICECALv3.h:54
bool specsReadRegister(unsigned char, U16 &)

◆ date()

int SpecsMezzanine::date ( )

Get the Specs Slave Date

Definition at line 174 of file SpecsMezzanine.cpp.

References SpecsInterface::specsReadRegister(), and Object::warning().

Referenced by cmdline().

174  {
175  unsigned char reg = 8 ;
176 #ifndef _NODEVICE_
177  U16 val ;
178  this -> specsReadRegister( reg , val );
179  val = (val&0xFF00)*100+(val&0xFF);
180  return val;
181 #else
182  warning("" , "Compilation in _NoDevice_ mode." );
183 #endif
184  return 0;
185 }
unsigned short U16
Definition: ICECALv3.h:54
void warning(std::string mymsg)
Definition: Object.h:39
bool specsReadRegister(unsigned char, U16 &)

◆ help()

void SpecsMezzanine::help ( )
virtual

Help message for the Specs Slaves

Reimplemented from SpecsInterface.

Definition at line 159 of file SpecsMezzanine.cpp.

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

Referenced by cmdline().

159  {
160  info("SpecsMezzanine","Specs Mezzanine Element help");
161  msgSvc(0,"","");
162  msgSvc(0,"","Address # : set slave address at #");
163  msgSvc(0,"","Reset : reset of the slave");
164  msgSvc(0,"","ResetInternal : internal reset of the slave");
165  msgSvc(0,"","RegWrite #0 #1 : write register #0 with value #1");
166  msgSvc(0,"","RegRead #0 #1 : read register #");
167 
168  msgSvc(0,"","");
169 }
void info(std::string mymsg)
Definition: Object.h:38
void msgSvc(int level, std::string msg, std::string name)
Definition: Object.h:33

◆ led()

bool SpecsMezzanine::led ( )

Get the state of the LEDs controlled by the Specs Slave

Definition at line 213 of file SpecsMezzanine.cpp.

References Object::debug(), SpecsInterface::specsReadRegister(), and Object::warning().

213  {
214  unsigned char reg = 4 ;
215 #ifndef _NODEVICE_
216  U16 val ;
217  this -> specsReadRegister( reg , val );
218  if ( 0 != ( val & 0x0800 ) ){
219  debug("SpecsMezzanine::led","Glue LEDs are OFF");
220  return false;
221  }
222 #else
223  warning("" , "Compilation in _NoDevice_ mode." );
224  return true;
225 #endif
226  debug("SpecsMezzanine::led","Glue LEDs are ON");
227  return true;
228 }
void debug(std::string mymsg)
Definition: Object.h:37
unsigned short U16
Definition: ICECALv3.h:54
void warning(std::string mymsg)
Definition: Object.h:39
bool specsReadRegister(unsigned char, U16 &)

◆ setLed()

void SpecsMezzanine::setLed ( bool  state)

Set the state of the LEDs controlled by the Specs Slave

Definition at line 190 of file SpecsMezzanine.cpp.

References Object::debug(), SpecsInterface::specsReadRegister(), SpecsInterface::specsWriteRegister(), and Object::warning().

Referenced by cmdline().

190  {
191  unsigned char reg = 4 ;
192 #ifndef _NODEVICE_
193  U16 val;
194  this -> specsReadRegister( reg , val );
195  if ( state ) {
196  val = ( val & 0xF7FF ) ;
197  this -> specsWriteRegister(reg, (val>>8) );
198  debug("SpecsMezzanine::led","setting Glue LEDs On");
199  }
200  else {
201  val = ( val | 0x0800 ) ;
202  this -> specsWriteRegister(reg , (val>>8) ) ;
203  debug("SpecsMezzanine::led","setting Glue LEDs OFF");
204  }
205 #else
206  warning("" , "Compilation in _NoDevice_ mode." );
207 #endif
208 }
bool specsWriteRegister(unsigned char, unsigned short)
void debug(std::string mymsg)
Definition: Object.h:37
unsigned short U16
Definition: ICECALv3.h:54
void warning(std::string mymsg)
Definition: Object.h:39
bool specsReadRegister(unsigned char, U16 &)

Member Data Documentation

◆ m_bus

SpecsBus* SpecsMezzanine::m_bus
private

Definition at line 59 of file SpecsMezzanine.h.

Referenced by addBus(), and SpecsMezzanine().

◆ m_dcu

DCU* SpecsMezzanine::m_dcu
private

Definition at line 60 of file SpecsMezzanine.h.

Referenced by SpecsMezzanine().


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