claraty::CDIO Class Reference
[Hardware Package]
#include <composite_digital_io.h>
Inheritance diagram for claraty::CDIO:


Public Types | |
| enum | IO_MODE { INPUT, OUTPUT, INPUT_OUTPUT } |
Public Member Functions | |
| CDIO (DIO *dio_array, int n_dios) | |
| CDIO & | set () |
| CDIO & | set (const Bits &data) |
| CDIO & | set (unsigned long data) |
| CDIO & | clr () |
| CDIO & | toggle () |
| CDIO & | set_bit (size_t pos, bool val=true) |
| CDIO & | clr_bit (size_t pos) |
| CDIO & | toggle_bit (size_t pos) |
| CDIO & | set_bit_output (size_t pos, bool val=true) |
| CDIO & | clr_bit_output (size_t pos) |
| CDIO & | toggle_bit_output (size_t pos) |
| CDIO & | input () |
| CDIO & | output () |
| CDIO & | output (unsigned long data) |
| CDIO & | output (const Bits &data) |
| bool | get_bit (size_t pos) |
| bool | test (size_t pos) const |
| size_t | bit_size () const |
| std::string | to_str () const |
| void | print (const char *msg="") const |
| operator Bits () const | |
| operator unsigned long () const | |
| void | pulse (size_t pos) |
| unsigned long | get_mask () |
| DIO_impl & | impl () |
Private Attributes | |
| DIO * | _dio_array |
| int | _n_dios |
| int | _n_bits_total |
Detailed Description
Composite digital I/O class.
Definition at line 44 of file composite_digital_io.h.
Member Enumeration Documentation
enum claraty::DIO::IO_MODE [inherited] |
Constructor & Destructor Documentation
| claraty::CDIO::CDIO | ( | DIO * | dio_array, | |
| int | n_dios | |||
| ) |
Definition at line 48 of file composite_digital_io.cc.
00049 : DIO( compute_n_bits_total(dio_array, n_dios), // n_bits_total 00050 DIO::INPUT_OUTPUT, 00051 dio_null), // needs valid _dio_impl&, although not used 00052 _dio_array(dio_array), 00053 _n_dios (n_dios), 00054 _n_bits_total (compute_n_bits_total(dio_array, n_dios)) 00055 { 00056 }
Member Function Documentation
| CDIO & claraty::CDIO::set | ( | ) |
Reimplemented from claraty::DIO.
Definition at line 63 of file composite_digital_io.cc.
References _dio_array, and _n_dios.
Referenced by output(), and set().
00064 { 00065 for (int i=0; i<_n_dios; ++i) 00066 _dio_array[i].set(); 00067 00068 return *this; 00069 }
Reimplemented from claraty::DIO.
Definition at line 71 of file composite_digital_io.cc.
References set(), and claraty::Bits::to_ulong().
00072 { 00073 return set(data.to_ulong()); 00074 }
Here is the call graph for this function:

| CDIO & claraty::CDIO::set | ( | unsigned long | data | ) |
Reimplemented from claraty::DIO.
Definition at line 76 of file composite_digital_io.cc.
References _dio_array, _n_dios, claraty::DIO::bit_size(), and set().
00077 { 00078 unsigned long data_tmp = data; 00079 00080 for (int i=0; i<_n_dios; ++i) { 00081 _dio_array[i].set(data_tmp); // set() sanitizes data_tmp by mask_bits 00082 data_tmp >>= _dio_array[i].bit_size(); 00083 } 00084 00085 return *this; 00086 }
Here is the call graph for this function:

| CDIO & claraty::CDIO::clr | ( | ) |
Reimplemented from claraty::DIO.
Definition at line 88 of file composite_digital_io.cc.
References _dio_array, and _n_dios.
00089 { 00090 for (int i=0; i<_n_dios; ++i) 00091 _dio_array[i].clr(); 00092 return *this; 00093 }
| CDIO & claraty::CDIO::toggle | ( | ) |
Reimplemented from claraty::DIO.
Definition at line 95 of file composite_digital_io.cc.
References _dio_array, and _n_dios.
00096 { 00097 for (int i=0; i<_n_dios; ++i) 00098 _dio_array[i].toggle(); 00099 return *this; 00100 }
| CDIO & claraty::CDIO::set_bit | ( | size_t | pos, | |
| bool | val = true | |||
| ) |
Reimplemented from claraty::DIO.
Definition at line 102 of file composite_digital_io.cc.
References _dio_array, claraty::DIO::bit_size(), bit_size(), and claraty::DIO::set_bit().
00103 { 00104 if ( static_cast<int>(pos) >= bit_size()) 00105 cerr << "CDIO WARNING: out_of_range - CDIO::set_bit" << endl; 00106 00107 int i = 0, j = pos; 00108 while (j >= _dio_array[i].bit_size()) 00109 j -= _dio_array[i++].bit_size(); 00110 00111 _dio_array[i].set_bit(j, val); 00112 00113 return *this; 00114 }
Here is the call graph for this function:

| CDIO & claraty::CDIO::clr_bit | ( | size_t | pos | ) |
Reimplemented from claraty::DIO.
Definition at line 116 of file composite_digital_io.cc.
References _dio_array, claraty::DIO::bit_size(), bit_size(), and claraty::DIO::clr_bit().
00117 { 00118 if ( static_cast<int>(pos) >= bit_size()) 00119 cerr << "CDIO WARNING: out_of_range - CDIO::clr_bit" << endl; 00120 00121 int i = 0, j = pos; 00122 while (j >= _dio_array[i].bit_size()) 00123 j -= _dio_array[i++].bit_size(); 00124 00125 _dio_array[i].clr_bit(j); 00126 00127 return *this; 00128 }
Here is the call graph for this function:

| CDIO & claraty::CDIO::toggle_bit | ( | size_t | pos | ) |
Reimplemented from claraty::DIO.
Definition at line 130 of file composite_digital_io.cc.
References _dio_array, claraty::DIO::bit_size(), bit_size(), and claraty::DIO::toggle_bit().
00131 { 00132 if ( static_cast<int>(pos) >= bit_size()) 00133 cerr << "CDIO WARNING: out_of_range - CDIO::clr_bit" << endl; 00134 00135 int i = 0, j = pos; 00136 while (j >= _dio_array[i].bit_size()) 00137 j -= _dio_array[i++].bit_size(); 00138 00139 _dio_array[i].toggle_bit(j); 00140 00141 return *this; 00142 }
Here is the call graph for this function:

| CDIO & claraty::CDIO::set_bit_output | ( | size_t | pos, | |
| bool | val = true | |||
| ) |
Definition at line 145 of file composite_digital_io.cc.
References _dio_array, claraty::DIO::bit_size(), bit_size(), claraty::DIO::output(), and claraty::DIO::set_bit().
00146 { 00147 if ( static_cast<int>(pos) >= bit_size()) 00148 cerr << "CDIO WARNING: out_of_range - CDIO::set_bit" << endl; 00149 00150 int i = 0, j = pos; 00151 while (j >= _dio_array[i].bit_size()) 00152 j -= _dio_array[i++].bit_size(); 00153 00154 _dio_array[i].set_bit(j, val).output(); // output one DIO only 00155 00156 return *this; 00157 }
Here is the call graph for this function:

| CDIO & claraty::CDIO::clr_bit_output | ( | size_t | pos | ) |
Definition at line 159 of file composite_digital_io.cc.
References _dio_array, claraty::DIO::bit_size(), bit_size(), claraty::DIO::clr_bit(), and claraty::DIO::output().
00160 { 00161 if ( static_cast<int>(pos) >= bit_size()) 00162 cerr << "CDIO WARNING: out_of_range - CDIO::clr_bit" << endl; 00163 00164 int i = 0, j = pos; 00165 while (j >= _dio_array[i].bit_size()) 00166 j -= _dio_array[i++].bit_size(); 00167 00168 _dio_array[i].clr_bit(j).output(); // output one DIO only 00169 00170 return *this; 00171 }
Here is the call graph for this function:

| CDIO & claraty::CDIO::toggle_bit_output | ( | size_t | pos | ) |
Definition at line 173 of file composite_digital_io.cc.
References _dio_array, claraty::DIO::bit_size(), bit_size(), claraty::DIO::output(), and claraty::DIO::toggle_bit().
00174 { 00175 if ( static_cast<int>(pos) >= bit_size()) 00176 cerr << "CDIO WARNING: out_of_range - CDIO::clr_bit" << endl; 00177 00178 int i = 0, j = pos; 00179 while (j >= _dio_array[i].bit_size()) 00180 j -= _dio_array[i++].bit_size(); 00181 00182 _dio_array[i].toggle_bit(j).output(); // output one DIO only 00183 00184 return *this; 00185 }
Here is the call graph for this function:

| CDIO & claraty::CDIO::input | ( | ) |
Reimplemented from claraty::DIO.
Definition at line 190 of file composite_digital_io.cc.
References _dio_array, and _n_dios.
00191 { 00192 for (int i=0; i<_n_dios; ++i) 00193 _dio_array[i].input(); 00194 00195 return *this; 00196 }
| CDIO & claraty::CDIO::output | ( | ) |
Reimplemented from claraty::DIO.
Definition at line 199 of file composite_digital_io.cc.
References _dio_array, and _n_dios.
Referenced by output().
00200 { 00201 for (int i=0; i<_n_dios; ++i) 00202 _dio_array[i].output(); 00203 00204 return *this; 00205 00206 // If some of _dio_array[] happen to have the same dio_impl over 00207 // different bits, at present it does output() for each dio separately. 00208 }
| CDIO & claraty::CDIO::output | ( | unsigned long | data | ) |
Reimplemented from claraty::DIO.
Definition at line 211 of file composite_digital_io.cc.
References output(), and set().
Here is the call graph for this function:

Reimplemented from claraty::DIO.
Definition at line 218 of file composite_digital_io.cc.
References output(), and claraty::Bits::to_ulong().
00219 { 00220 return output(data.to_ulong()); 00221 }
Here is the call graph for this function:

| bool claraty::CDIO::get_bit | ( | size_t | pos | ) |
Reimplemented from claraty::DIO.
Definition at line 224 of file composite_digital_io.cc.
References _dio_array, claraty::DIO::bit_size(), bit_size(), and claraty::DIO::get_bit().
00225 { 00226 if ( static_cast<int>(pos) >= (int)bit_size()) 00227 // throw out_of_range("Bits::get_bit"); 00228 cerr << "CDIO WARNING: out_of_range - CDIO::get_bit" << endl; 00229 00230 int i = 0, j = pos; 00231 while (j >= (int)_dio_array[i].bit_size()) 00232 j -= _dio_array[i++].bit_size(); 00233 00234 // Rob Steele on Feb 26, 2007 added the return value based on the return 00235 // of get_bit since this seemed like a reasonable way to set the 00236 // return value. 00237 00238 return _dio_array[i].get_bit(j); 00239 00240 }
Here is the call graph for this function:

| bool claraty::CDIO::test | ( | size_t | pos | ) | const |
Reimplemented from claraty::DIO.
Definition at line 243 of file composite_digital_io.cc.
References _dio_array, claraty::DIO::bit_size(), bit_size(), and claraty::DIO::test().
00244 { 00245 if ( static_cast<int>(pos) >= (int)bit_size()) 00246 // throw out_of_range("Bits::get_bit"); 00247 cerr << "CDIO WARNING: out_of_range - CDIO::get_bit" << endl; 00248 00249 int i = 0, j = pos; 00250 while (j >= (int)_dio_array[i].bit_size()) 00251 j -= _dio_array[i++].bit_size(); 00252 00253 // Rob Steele on Feb 26, 2007 added the return value based on the return 00254 // of test since this seemed like a reasonable way to set the 00255 // return value. 00256 00257 return _dio_array[i].test(j); 00258 }
Here is the call graph for this function:

| size_t claraty::CDIO::bit_size | ( | ) | const |
Reimplemented from claraty::DIO.
Definition at line 262 of file composite_digital_io.cc.
References _n_bits_total.
Referenced by clr_bit(), clr_bit_output(), get_bit(), set_bit(), set_bit_output(), test(), toggle_bit(), and toggle_bit_output().
00263 { 00264 return _n_bits_total; 00265 }
| string claraty::CDIO::to_str | ( | ) | const |
Reimplemented from claraty::DIO.
Definition at line 268 of file composite_digital_io.cc.
References _dio_array, _n_bits_total, _n_dios, claraty::DIO::bit_size(), and claraty::Bits::to_str().
00269 { 00270 Bits data_bits(0, _n_bits_total); 00271 string s; 00272 00273 int n = 0; 00274 for (int i=0; i<_n_dios; ++i) { 00275 data_bits |= ( (unsigned long) _dio_array[i] << n); 00276 n += _dio_array[i].bit_size(); 00277 } 00278 s += data_bits.to_str() + "\n"; 00279 00280 for (int i=0; i<_n_dios; ++i) 00281 s += "DIO[]\n " + _dio_array[i].to_str() + "\n"; 00282 00283 return s; 00284 }
Here is the call graph for this function:

| void claraty::CDIO::print | ( | const char * | msg = "" |
) | const |
Reimplemented from claraty::DIO.
Definition at line 287 of file composite_digital_io.cc.
References _dio_array, _n_bits_total, _n_dios, claraty::DIO::bit_size(), and claraty::Bits::print().
00288 { 00289 Bits data_bits(0, _n_bits_total); 00290 00291 int n = 0; 00292 for (int i=0; i<_n_dios; ++i) { 00293 data_bits |= ( (unsigned long) _dio_array[i] << n); 00294 n += _dio_array[i].bit_size(); 00295 } 00296 data_bits.print(msg); 00297 00298 for (int i=0; i<_n_dios; ++i) 00299 _dio_array[i].print("DIO[]"); 00300 }
Here is the call graph for this function:

| claraty::DIO::operator Bits | ( | ) | const [inherited] |
Definition at line 125 of file digital_io.cc.
References claraty::DIO::_n_bits.
00126 { 00127 return Bits( (unsigned long) *this, _n_bits); 00128 }
| claraty::DIO::operator unsigned long | ( | ) | const [inherited] |
Definition at line 102 of file digital_io.cc.
References claraty::DIO_impl::_data_bits, claraty::DIO::_dio_impl, claraty::DIO_impl::_invert_signal, claraty::DIO::_mask_bits, claraty::DIO::_start_bit_impl, and claraty::Bits::to_ulong().
00103 { 00104 // conversion to unsigned long 00105 // 00106 // unsigned long x = d1.to_ulong(); 00107 // unsigned short y = d1.to_ulong(); 00108 // unsigned char z = d1.to_ulong(); 00109 // BYTE z = d1.to_ulong(); // BYTE = unsigned char 00110 // 00111 00112 // return _data_bits.to_ulong(); 00113 // It returns actual hardware signal output, not internal _data_bits 00114 // 00115 unsigned long data = _dio_impl._data_bits.to_ulong(); 00116 if (_dio_impl._invert_signal) 00117 data = ~data; 00118 data &= _mask_bits.to_ulong(); 00119 data >>= _start_bit_impl; 00120 00121 return data; 00122 }
Here is the call graph for this function:

| void claraty::DIO::pulse | ( | size_t | pos | ) | [inherited] |
Definition at line 305 of file digital_io.cc.
References claraty::DIO::clr_bit(), and claraty::DIO::set_bit().
00306 { 00307 // Clear a bit, sets it and then clear it again. This function 00308 // can be very useful in hardware I/O control. 00309 // do we want to specify the pulse duration?? 00310 // 00311 clr_bit(pos); 00312 // add delay ?? 00313 set_bit(pos); 00314 // add delay ?? 00315 clr_bit(pos); 00316 }
Here is the call graph for this function:

| unsigned long claraty::DIO::get_mask | ( | ) | [inherited] |
Definition at line 344 of file digital_io.cc.
References claraty::DIO::_mask_bits, and claraty::Bits::to_ulong().
00345 { 00346 return _mask_bits.to_ulong(); 00347 }
Here is the call graph for this function:

| DIO_impl& claraty::DIO::impl | ( | ) | [inline, inherited] |
Definition at line 133 of file digital_io.h.
References claraty::DIO::_dio_impl.
00133 { return _dio_impl;}
Member Data Documentation
DIO* claraty::CDIO::_dio_array [private] |
Definition at line 76 of file composite_digital_io.h.
Referenced by clr(), clr_bit(), clr_bit_output(), get_bit(), input(), output(), print(), set(), set_bit(), set_bit_output(), test(), to_str(), toggle(), toggle_bit(), and toggle_bit_output().
int claraty::CDIO::_n_dios [private] |
int claraty::CDIO::_n_bits_total [private] |
Definition at line 78 of file composite_digital_io.h.
Referenced by bit_size(), print(), and to_str().
The documentation for this class was generated from the following files: