00001
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00030 #ifndef MIMOLIB_MULTIPLEXER_H
00031 #define MIMOLIB_MULTIPLEXER_H
00032
00033 #include <basicdevicefactory.h>
00034 #include <basicdevice.h>
00035 #include <phbib.h>
00036 #include <signals.h>
00037
00038 #include "matrixseq.h"
00039
00040 namespace mimo {
00041
00042 using namespace simth;
00043
00066 class Multiplexer : public Device
00067 {
00068 protected:
00069 unsigned int iports;
00070 unsigned int oports;
00071
00072 Multiplexer(int deviceID, DeviceSystemIntf* system,
00073 const simth::PropertyList& pl);
00074
00075 public:
00076 virtual void updateInputLengths();
00077 virtual void updateOutputLengths();
00078
00079 template<class seqT>
00080 void process();
00081
00082 void print(std::ostream &os) const;
00083
00084 static void init(const std::string& fileName,
00085 Device** dev,
00086 DeviceSystemIntf* sysPtr,
00087 int ID,
00088 const std::string& regionQualifier);
00089 static void init(simth::DeviceFactory& registration);
00090 };
00091
00092
00098 template<class seqT>
00099 class MultiplexerT : public Multiplexer
00100 {
00101 public:
00102 MultiplexerT(int deviceID, DeviceSystemIntf* system,
00103 const simth::PropertyList& pl);
00104
00105 void process()
00106 { Multiplexer::process<seqT>(); };
00107 };
00108
00109
00110 template<>
00111 class MultiplexerT<CMatrixSeq> : public Multiplexer
00112 {
00113 typedef CMatrixSeq seqT;
00114 public:
00115 MultiplexerT(int deviceID, DeviceSystemIntf* system,
00116 const simth::PropertyList& pl);
00117 void process()
00118 { Multiplexer::process<seqT>(); };
00119 };
00120
00121
00122
00123
00124
00125
00126
00127 namespace MultiplexVector {
00128 void init(const std::string& fileName,
00129 Device** dev,
00130 DeviceSystemIntf* sysPtr,
00131 int ID,
00132 const std::string& regionQualifier);
00133
00134 simth::Device* init(int ID,
00135 simth::DeviceSystemIntf* sysPtr,
00136 const simth::PropertyList& pl,
00137 const std::string& cpptype);
00138
00151 template<class seqT_in, class seqT_out>
00152 inline void seqs_to_vector(const std::vector< seqT_in* >& iseqs,
00153 seqT_out& oseq,
00154 unsigned iports)
00155 {
00156 unsigned iLength = oseq.size();
00157 for (unsigned n = 0; n < iLength; n++)
00158 for (unsigned iport = 0; iport < iports; iport++)
00159 {
00160 mimo::c_assign(oseq[n], iport,
00161 iseqs[iport]->operator[](n));
00162 }
00163 }
00164
00174 template<class seqT_in, class seqT_out>
00175 inline void seqs_to_vector(const std::vector< seqT_in* >& iseqs,
00176 seqT_out& oseq)
00177 {
00178 seqs_to_vector(iseqs, oseq, iseqs.size());
00179 }
00180
00191 template<class seqT_in, class seqT_out>
00192 inline void vector_to_seqs(const seqT_in & iseq,
00193 std::vector< seqT_out* > & oseqs,
00194 unsigned oports)
00195 {
00196 unsigned oLength = iseq.size();
00197 for (unsigned n = 0; n < oLength; n++)
00198 for (unsigned oport = 0; oport < oports; oport++)
00199 {
00200 if (oseqs[oport])
00201 oseqs[oport]->operator[](n) =
00202 mimo::c_access(iseq[n], oport);
00203 }
00204 }
00205
00215 template<class seqT_in, class seqT_out>
00216 inline void vector_to_seqs(const seqT_in & iseq,
00217 std::vector< seqT_out* > & oseqs)
00218 {
00219 vector_to_seqs(iseq, oseqs, oseqs.size());
00220 }
00221
00222 }
00223
00243 template<class seqT_in, class seqT_out>
00244 class ToVector : public Device
00245 {
00246 protected:
00247 unsigned int iports;
00248
00249
00250 public:
00251 ToVector(int deviceID, DeviceSystemIntf* system,
00252 const simth::PropertyList& pl)
00253 : Device (deviceID, system, pl)
00254 , iports(pl.PropertyList::getProperty<unsigned>("input_ports"))
00255 {
00256 insertInputInterface< seqT_in >(iports);
00257 insertOutputInterface< seqT_out> ();
00258 };
00259
00260 void updateInputLengths()
00261 {
00262 setInputLength(outputLength());
00263 };
00264 void updateOutputLengths()
00265 {
00266 for (unsigned i = 0; i < iports; i++)
00267 {
00268 if (!isInputSequence(i))
00269 return;
00270 }
00271 setOutputLength(inputLength());
00272 };
00273
00274 void process();
00275
00276
00277 };
00278
00279
00299 template<class seqT_in, class seqT_out>
00300 class FromVector : public Device
00301 {
00302 protected:
00303 unsigned int oports;
00304
00305 public:
00306 FromVector(int deviceID, DeviceSystemIntf* system,
00307 const simth::PropertyList& pl);
00308
00309 void updateInputLengths()
00310 {
00311 for (unsigned i = 0; i < oports; i++)
00312 {
00313 if (outputLength(i) == 0)
00314 return;
00315 }
00316 setInputLength(outputLength());
00317 };
00318 void updateOutputLengths()
00319 {
00320 setOutputLength(inputLength());
00321 };
00322
00323 void process();
00324
00325
00326 };
00327
00331 template<class seqT_in, class seqT_out>
00332 class MultiplexFromVector : public Device
00333 {
00334 protected:
00335 unsigned int dim;
00336
00337 public:
00338 MultiplexFromVector(int deviceID, DeviceSystemIntf* system,
00339 const simth::PropertyList& pl);
00340
00341 void updateInputLengths()
00342 {
00343 setInputLength(outputLength()/dim);
00344 };
00345 void updateOutputLengths()
00346 {
00347 setOutputLength(dim*inputLength());
00348 };
00349
00350 void process();
00351
00352
00353 };
00354
00369 template<class seqT_in, class seqT_out>
00370 class FromDiag : public Device
00371 {
00372 protected:
00373 unsigned int n;
00374
00375 public:
00376 FromDiag(int deviceID, DeviceSystemIntf* system,
00377 const simth::PropertyList& pl,
00378 unsigned int n);
00379
00380 void updateInputLengths()
00381 {
00382 setInputLength(outputLength());
00383 };
00384 void updateOutputLengths()
00385 {
00386 setOutputLength(inputLength());
00387 };
00388
00389 void process();
00390
00391
00392 };
00393
00394
00395
00416 template<class seqT_in, class seqT_out>
00417 class FromMat : public Device
00418 {
00419 protected:
00420 unsigned int rows, cols;
00421
00422 public:
00423 FromMat(int deviceID, DeviceSystemIntf* system,
00424 const simth::PropertyList& pl);
00425
00426 void updateInputLengths()
00427 {
00428 setInputLength(outputLength());
00429 };
00430 void updateOutputLengths()
00431 {
00432 setOutputLength(inputLength());
00433 };
00434
00435 void process();
00436
00437
00438 };
00439
00440 }
00441
00442 #endif