All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
signal_manipulation.h
1 /* Copyright (C) 2004-2009 MBSim Development Team
2  *
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation; either
6  * version 2.1 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16  *
17  * Contact: markus.ms.schneider@gmail.com
18  */
19 
20 #ifndef _SIGNAL_MANIPULATION_H_
21 #define _SIGNAL_MANIPULATION_H_
22 
23 #include "mbsimControl/signal_.h"
24 #include <mbsim/functions/function.h>
25 
26 namespace MBSim {
27  typedef int Index;
28 }
29 
30 namespace MBSimControl {
31 
36  class Multiplexer : public Signal {
37  public:
38  Multiplexer(const std::string &name="") : Signal(name) { }
39  void initializeUsingXML(xercesc::DOMElement *element);
40  void init(InitStage stage, const MBSim::InitConfigSet &config);
41  void addInputSignal(Signal * signal_) { signal.push_back(signal_); }
42  void updateSignal();
43  int getSignalSize() const;
44  private:
45  std::vector<Signal*> signal;
46  std::vector<std::string> signalString;
47  };
48 
53  class Demultiplexer : public Signal {
54  public:
55  Demultiplexer(const std::string &name="") : Signal(name), signal(NULL) { }
56  void initializeUsingXML(xercesc::DOMElement *element);
57  void init(InitStage stage, const MBSim::InitConfigSet &config);
58  void setInputSignal(Signal *signal_) { signal = signal_; }
59  void setIndices(const std::vector<MBSim::Index> &index_) { index = index_; }
60  void updateSignal();
61  int getSignalSize() const { return index.size(); }
62  private:
63  Signal *signal;
64  std::vector<MBSim::Index> index;
65  std::string signalString;
66  };
67 
72  class SignalTimeDiscretization : public Signal {
73  public:
74  SignalTimeDiscretization(const std::string &name="") : Signal(name), s(NULL), tOld(-99e99) { }
75  void initializeUsingXML(xercesc::DOMElement *element);
76  void init(InitStage stage, const MBSim::InitConfigSet &config);
77  void setInputSignal(Signal *signal_) { s=signal_; }
78  void updateSignal();
79  int getSignalSize() const { return s->getSignalSize(); }
80  private:
81  Signal *s;
82  double tOld;
83  std::string signalString;
84  };
85 
90  class SignalOperation : public Signal {
91  public:
92  SignalOperation(const std::string &name="") : Signal(name), f1(NULL), f2(NULL) { }
93  ~SignalOperation() { delete f1; delete f2; }
94  void initializeUsingXML(xercesc::DOMElement *element);
95  void init(InitStage stage, const MBSim::InitConfigSet &config);
96  void setInputSignal(Signal *signal_) { signal.resize(1,signal_); }
97  void addInputSignal(Signal *signal_) { signal.push_back(signal_); }
98  void setFunction(MBSim::Function<fmatvec::VecV(fmatvec::VecV)> *f) {
99  f1=f;
100  f1->setParent(this);
101  f1->setName("Function");
102  };
103  void setFunction(MBSim::Function<fmatvec::VecV(fmatvec::VecV,fmatvec::VecV)> *f) {
104  f2=f;
105  f2->setParent(this);
106  f2->setName("Function");
107  };
108  void updateSignal() { (this->*updateSignal_)(); }
109  void updateSignal1();
110  void updateSignal2();
111  int getSignalSize() const { return f1?f1->getRetSize().first:f2->getRetSize().first; }
112  private:
113  std::vector<Signal*> signal;
114  std::vector<std::string> signalString;
117  void (SignalOperation::*updateSignal_)();
118  };
119 
120 }
121 
122 #endif /* _SIGNAL_MANIPULATION_H_ */
SignalTimeDiscretization.
Definition: signal_manipulation.h:72
SignalOperation.
Definition: signal_manipulation.h:90
Signal.
Definition: signal_.h:38
Multiplexer.
Definition: signal_manipulation.h:36
Demultiplexer.
Definition: signal_manipulation.h:53

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Home