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

#include <DCU.h>

Inheritance diagram for DCU:
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

 DCU ()
 Constructor. More...
 
 ~DCU ()
 Destructor. More...
 
virtual bool cmdline (std::vector< std::string >)
 
bool acquire (U8, U16 &, double &)
 
void reset ()
 
void update ()
 
void help ()
 
StatusCode init ()
 
bool setLIR ()
 
bool setHIR ()
 
bool readMode (U8 &mode)
 
bool convert (std::string &converted_value, U16 input_value, U8 channel)
 
U8 address ()
 
void setAddress (U8 address)
 
U8 outputSelect ()
 
void setOutputSelect (U8 outputSelect)
 
- 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

U8 m_address
 
U8 m_outputSelect
 

Additional Inherited Members

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

Detailed Description

Describe the DCU

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

Definition at line 15 of file DCU.h.

Member Typedef Documentation

◆ U16

typedef unsigned short DCU::U16

Definition at line 18 of file DCU.h.

◆ U32

typedef unsigned long DCU::U32

Definition at line 17 of file DCU.h.

◆ U8

typedef unsigned char DCU::U8

Definition at line 19 of file DCU.h.

Constructor & Destructor Documentation

◆ DCU()

DCU::DCU ( )

Constructor.

Definition at line 27 of file DCU.cpp.

References Object::debug(), m_outputSelect, Object::setId(), and Object::setType().

27  {
28  setType( "DCU" ) ;
29  setId( 0 ) ;
30  debug("DCU::DCU" , "DCU built" ) ;
31  m_outputSelect = 0xF ;
32 }
U8 m_outputSelect
Definition: DCU.h:60
void setType(std::string type)
Definition: Object.h:52
void setId(unsigned char id)
Definition: Object.h:53
void debug(std::string mymsg)
Definition: Object.h:37

◆ ~DCU()

DCU::~DCU ( )

Destructor.

Destructor

Definition at line 36 of file DCU.cpp.

36 { }

Member Function Documentation

◆ acquire()

bool DCU::acquire ( U8  channel,
U16 data,
double &  value 
)

Definition at line 98 of file DCU.cpp.

References address(), itos(), Object::verbose(), and Object::warning().

98  {
99 #ifndef _NODEVICE_
100  SPECSSLAVE *specsSlv=specsSlaveDevice();
101  if ( 0==specsSlv ){
102  warning("DCU::acquire",
103  "Could not reach proper Specs Master and/or Slave.");
104  return false;
105  }
106 
107  SpecsError status = specs_dcu_acquire (specsSlv
108 #ifdef _OLDSPECSLIB_
109  ,address()
110 #endif
111  ,channel,
112  &data,
113  &value);
114 
115  if (0!=status){
116  warning("DCU::acquire","Acquisition failure channel " +
117  itos (channel) +
118  "[code=" + itos(status) + "]" );
119  return false;
120  }
121  else {
122  verbose("DCU::acquire","Channel " + itos (channel) +
123  " -> Acquisition : " + itos(data) );
124  }
125 #else
126  verbose("DCU::acquire","Compilation in _NODEVICE_ mode.");
127 #endif
128  return true;
129 }
std::string itos(int)
Definition: Tools.cpp:46
void verbose(std::string mymsg)
Definition: Object.h:36
def data(object, stream=None)
Definition: shell.py:150
U8 address()
Definition: DCU.h:50
void warning(std::string mymsg)
Definition: Object.h:39

◆ address()

U8 DCU::address ( )
inline

Definition at line 50 of file DCU.h.

References m_address.

Referenced by acquire(), init(), readMode(), reset(), setAddress(), setHIR(), and setLIR().

50 { return m_address; }
U8 m_address
Definition: DCU.h:59

◆ cmdline()

virtual bool DCU::cmdline ( std::vector< std::string >  )
virtual

◆ convert()

bool DCU::convert ( std::string &  converted_value,
U16  input_value,
U8  channel 
)

Definition at line 288 of file DCU.cpp.

References readMode(), and Object::warning().

Referenced by help().

290  {
291  U8 mode = 0 ;
292  if ( ! ( readMode( mode ) ) ) {
293  warning("DCU::convertInputValueViaI2c","Cannot read mode" ) ;
294  return false ;
295  }
296 
297  std::string unit = "V" ;
298 
299  if ( channel == 7 ) unit = "C" ;
300 
301  double value ;
302 
303  if ( channel == 7 )
304  value = ( (double) ( input_value - 2469 ) ) / 9.22 + 25. ;
305  else
306  if ( mode == 1 )
307  value = input_value * 0.0003052 ;
308  else if ( mode == 0 )
309  value = 2.5 - input_value * 0.0003052 ;
310 
311  std::ostringstream outstr ;
312  outstr << value << " " << unit ;
313 
314  output_value = outstr.str() ;
315 
316  return true ;
317 }
bool readMode(U8 &mode)
Definition: DCU.cpp:250
unsigned char U8
Definition: ICECALv3.h:55
void warning(std::string mymsg)
Definition: Object.h:39

◆ help()

void DCU::help ( )
inlinevirtual

printout help for the element

Implements Element.

Definition at line 36 of file DCU.h.

References convert(), init(), readMode(), setHIR(), and setLIR().

36 {};

◆ init()

StatusCode DCU::init ( )
virtual

init the component

Returns
void

Implements Element.

Definition at line 161 of file DCU.cpp.

References address(), StatusCode::FAILURE, StatusCode::SUCCESS, Object::verbose(), and Object::warning().

Referenced by help().

161  {
162 #ifndef _NODEVICE_
163  SPECSSLAVE *specsSlv=specsSlaveDevice();
164  if ( 0==specsSlv ){
165  warning("DCU::init",
166  "Could not reach proper Specs Master and/or Slave.");
167  return StatusCode::FAILURE;
168  }
169  SpecsError status = specs_dcu_initialize (specsSlv
170 #ifdef _OLDSPECSLIB_
171  ,address()
172 #endif
173 );
174  if (0!=status){
175  warning("DCU::init","Could not properly init the DCU.");
176  return StatusCode::FAILURE;
177  }
178  else {
179  verbose("DCU::init","DCU init.");
180  }
181 #else
182  verbose("DCU::init","Compilation in _NODEVICE_ mode.");
183 #endif
184  return StatusCode::SUCCESS;
185 }
void verbose(std::string mymsg)
Definition: Object.h:36
U8 address()
Definition: DCU.h:50
void warning(std::string mymsg)
Definition: Object.h:39

◆ outputSelect()

U8 DCU::outputSelect ( )
inline

Definition at line 53 of file DCU.h.

References m_outputSelect.

Referenced by setOutputSelect().

53 { return m_outputSelect; }
U8 m_outputSelect
Definition: DCU.h:60

◆ readMode()

bool DCU::readMode ( U8 mode)

Definition at line 250 of file DCU.cpp.

References address(), Object::msgSvc(), Object::verbose(), and Object::warning().

Referenced by convert(), and help().

250  {
251 #ifndef _NODEVICE_
252  SPECSSLAVE *specsSlv=specsSlaveDevice();
253  if ( 0==specsSlv ){
254  warning("DCU::readMode",
255  "Could not reach proper Specs Master and/or Slave.");
256  return false;
257  }
258 
259  SpecsError status = specs_dcu_read_mode (specsSlv
260 #ifdef _OLDSPECSLIB_
261  ,address()
262 #endif
263  ,&mode);
264 
265  if (0!=status){
266  msgSvc( WARNING, "DCU::readMode","Could not properly read DCU Mode");
267  return false;
268  }
269  else {
270  switch (mode){
271  case 0:
272  verbose("DCU::readMode","DCU read Mode HIR" );
273  break;
274  default:
275  verbose("DCU::readMode","DCU read Mode LIR" );
276  }
277  }
278 #else
279  verbose("DCU::readMode",
280  "Compilation in _NODEVICE_ mode.");
281 #endif
282  return true;
283 }
void verbose(std::string mymsg)
Definition: Object.h:36
U8 address()
Definition: DCU.h:50
void msgSvc(int level, std::string msg, std::string name)
Definition: Object.h:33
void warning(std::string mymsg)
Definition: Object.h:39

◆ reset()

void DCU::reset ( )
virtual

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 Element.

Definition at line 134 of file DCU.cpp.

References address(), Object::verbose(), and Object::warning().

134  {
135 #ifndef _NODEVICE_
136  SPECSSLAVE *specsSlv=specsSlaveDevice();
137  if ( 0==specsSlv ){
138  warning"DCU::reset","Could not reach proper Specs Master and/or Slave.");
139  return;
140  }
141  SpecsError status = specs_dcu_reset (specsSlv
142 #ifdef _OLDSPECSLIB_
143  ,address()
144 #endif
145 );
146  if (0!=status){
147  warning("DCU::reset","Could not properly reset the DCU.");
148  return;
149  }
150  else {
151  verbose("DCU::reset","DCU reset.");
152  }
153 #else
154 verbose("DCU::reset","Compilation in _NODEVICE_ mode.");
155 #endif
156 }
void verbose(std::string mymsg)
Definition: Object.h:36
U8 address()
Definition: DCU.h:50
void warning(std::string mymsg)
Definition: Object.h:39

◆ setAddress()

void DCU::setAddress ( U8  address)
inline

Definition at line 51 of file DCU.h.

References address(), and m_address.

Referenced by SpecsMezzanine::SpecsMezzanine().

51 { m_address=address; }
U8 address()
Definition: DCU.h:50
U8 m_address
Definition: DCU.h:59

◆ setHIR()

bool DCU::setHIR ( )

Definition at line 220 of file DCU.cpp.

References address(), Object::msgSvc(), Object::verbose(), and Object::warning().

Referenced by help().

220  {
221 #ifndef _NODEVICE_
222  SPECSSLAVE *specsSlv=specsSlaveDevice();
223  if ( 0==specsSlv ){
224  warning("DCU::setHIR",
225  "Could not reach proper Specs Master and/or Slave.");
226  return false;
227  }
228  SpecsError status = specs_dcu_set_HIR (specsSlv
229 #ifdef _OLDSPECSLIB_
230  ,address()
231 #endif
232 );
233  if (0!=status){
234  msgSvc( WARNING, "DCU::setHIR","Could not properly set HIR Mode");
235  return false;
236  }
237  else {
238  verbose("DCU::setHIR","DCU HIR Mode set");
239  }
240 #else
241  verbose("DCU::setHIR",
242  "Compilation in _NODEVICE_ mode.");
243 #endif
244  return true;
245 }
void verbose(std::string mymsg)
Definition: Object.h:36
U8 address()
Definition: DCU.h:50
void msgSvc(int level, std::string msg, std::string name)
Definition: Object.h:33
void warning(std::string mymsg)
Definition: Object.h:39

◆ setLIR()

bool DCU::setLIR ( )

Definition at line 190 of file DCU.cpp.

References address(), Object::msgSvc(), Object::verbose(), and Object::warning().

Referenced by help().

190  {
191 #ifndef _NODEVICE_
192  SPECSSLAVE *specsSlv=specsSlaveDevice();
193  if ( 0==specsSlv ){
194  warning("DCU::setLIR",
195  "Could not reach proper Specs Master and/or Slave.");
196  return false;
197  }
198  SpecsError status = specs_dcu_set_LIR (specsSlv
199 #ifdef _OLDSPECSLIB_
200  ,address()
201 #endif
202 );
203  if (0!=status){
204  msgSvc( WARNING, "DCU::setLIR","Could not properly set LIR Mode");
205  return false;
206  }
207  else {
208  verbose("DCU::setLIR","DCU LIR Mode set");
209  }
210 #else
211  verbose("DCU::setLIR",
212  "Compilation in _NODEVICE_ mode.");
213 #endif
214  return true;
215 }
void verbose(std::string mymsg)
Definition: Object.h:36
U8 address()
Definition: DCU.h:50
void msgSvc(int level, std::string msg, std::string name)
Definition: Object.h:33
void warning(std::string mymsg)
Definition: Object.h:39

◆ setOutputSelect()

void DCU::setOutputSelect ( U8  outputSelect)
inline

Definition at line 54 of file DCU.h.

References m_outputSelect, and outputSelect().

Referenced by SpecsMezzanine::SpecsMezzanine().

U8 m_outputSelect
Definition: DCU.h:60
U8 outputSelect()
Definition: DCU.h:53

◆ update()

void DCU::update ( )
inlinevirtual

Update the Element configuration from the actual hardware

Implements Element.

Definition at line 35 of file DCU.h.

35 {};

Member Data Documentation

◆ m_address

U8 DCU::m_address
private

Definition at line 59 of file DCU.h.

Referenced by address(), and setAddress().

◆ m_outputSelect

U8 DCU::m_outputSelect
private

Definition at line 60 of file DCU.h.

Referenced by DCU(), outputSelect(), and setOutputSelect().


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