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 };
00090
00091
00097 template<class seqT>
00098 class MultiplexerT : public Multiplexer
00099 {
00100 public:
00101 MultiplexerT(int deviceID, DeviceSystemIntf* system,
00102 const simth::PropertyList& pl);
00103
00104 void process()
00105 { Multiplexer::process<seqT>(); };
00106 };
00107
00108
00109 template<>
00110 class MultiplexerT<CMatrixSeq> : public Multiplexer
00111 {
00112 typedef CMatrixSeq seqT;
00113 public:
00114 MultiplexerT(int deviceID, DeviceSystemIntf* system,
00115 const simth::PropertyList& pl);
00116 void process()
00117 { Multiplexer::process<seqT>(); };
00118 };
00119
00120
00121
00122
00123
00124
00125
00126 namespace MultiplexVector {
00127 void init(const std::string& fileName,
00128 Device** dev,
00129 DeviceSystemIntf* sysPtr,
00130 int ID,
00131 const std::string& regionQualifier);
00132
00133 simth::Device* init(int ID,
00134 simth::DeviceSystemIntf* sysPtr,
00135 const simth::PropertyList& pl,
00136 const std::string& cpptype);
00137
00150 template<class seqT_in, class seqT_out>
00151 inline void seqs_to_vector(const std::vector< seqT_in* >& iseqs,
00152 seqT_out& oseq,
00153 unsigned iports)
00154 {
00155 unsigned iLength = oseq.size();
00156 for (unsigned n = 0; n < iLength; n++)
00157 for (unsigned iport = 0; iport < iports; iport++)
00158 {
00159 cs::c_assign(oseq[n], iport,
00160 iseqs[iport]->operator[](n));
00161 }
00162 }
00163
00173 template<class seqT_in, class seqT_out>
00174 inline void seqs_to_vector(const std::vector< seqT_in* >& iseqs,
00175 seqT_out& oseq)
00176 {
00177 seqs_to_vector(iseqs, oseq, iseqs.size());
00178 }
00179
00190 template<class seqT_in, class seqT_out>
00191 inline void vector_to_seqs(const seqT_in & iseq,
00192 std::vector< seqT_out* > & oseqs,
00193 unsigned oports)
00194 {
00195 unsigned oLength = iseq.size();
00196 for (unsigned n = 0; n < oLength; n++)
00197 for (unsigned oport = 0; oport < oports; oport++)
00198 {
00199 if (oseqs[oport])
00200 oseqs[oport]->operator[](n) =
00201 cs::c_access(iseq[n], oport);
00202 }
00203 }
00204
00214 template<class seqT_in, class seqT_out>
00215 inline void vector_to_seqs(const seqT_in & iseq,
00216 std::vector< seqT_out* > & oseqs)
00217 {
00218 vector_to_seqs(iseq, oseqs, oseqs.size());
00219 }
00220
00221 }
00222
00242 template<class seqT_in, class seqT_out>
00243 class ToVector : public Device
00244 {
00245 protected:
00246 unsigned int iports;
00247
00248
00249 public:
00250 ToVector(int deviceID, DeviceSystemIntf* system,
00251 const simth::PropertyList& pl)
00252 : Device (deviceID, system, pl)
00253 , iports(pl.PropertyList::getProperty<unsigned>("input_ports"))
00254 {
00255 insertInputInterface< seqT_in >(iports);
00256 insertOutputInterface< seqT_out> ();
00257 };
00258
00259 void updateInputLengths()
00260 {
00261 setInputLength(outputLength());
00262 };
00263 void updateOutputLengths()
00264 {
00265 for (unsigned i = 0; i < iports; i++)
00266 {
00267 if (!isInputSequence(i))
00268 return;
00269 }
00270 setOutputLength(inputLength());
00271 };
00272
00273 void process();
00274
00275 void print(std::ostream & ) const {};
00276 };
00277
00278
00298 template<class seqT_in, class seqT_out>
00299 class FromVector : public Device
00300 {
00301 protected:
00302 unsigned int oports;
00303
00304 public:
00305 FromVector(int deviceID, DeviceSystemIntf* system,
00306 const simth::PropertyList& pl);
00307
00308 void updateInputLengths()
00309 {
00310 for (unsigned i = 0; i < oports; i++)
00311 {
00312 if (outputLength(i) == 0)
00313 return;
00314 }
00315 setInputLength(outputLength());
00316 };
00317 void updateOutputLengths()
00318 {
00319 setOutputLength(inputLength());
00320 };
00321
00322 void process();
00323
00324 void print(std::ostream & ) const {};
00325 };
00326
00341 template<class seqT_in, class seqT_out>
00342 class FromDiag : public Device
00343 {
00344 protected:
00345 unsigned int n;
00346
00347 public:
00348 FromDiag(int deviceID, DeviceSystemIntf* system,
00349 const simth::PropertyList& pl,
00350 unsigned int n);
00351
00352 void updateInputLengths()
00353 {
00354 setInputLength(outputLength());
00355 };
00356 void updateOutputLengths()
00357 {
00358 setOutputLength(inputLength());
00359 };
00360
00361 void process();
00362
00363 void print(std::ostream & ) const {};
00364 };
00365
00366
00367
00388 template<class seqT_in, class seqT_out>
00389 class FromMat : public Device
00390 {
00391 protected:
00392 unsigned int rows, cols;
00393
00394 public:
00395 FromMat(int deviceID, DeviceSystemIntf* system,
00396 const simth::PropertyList& pl);
00397
00398 void updateInputLengths()
00399 {
00400 setInputLength(outputLength());
00401 };
00402 void updateOutputLengths()
00403 {
00404 setOutputLength(inputLength());
00405 };
00406
00407 void process();
00408
00409 void print(std::ostream & ) const {};
00410 };
00411
00412 }
00413
00414 #endif