|
mbsimcontrol
4.0.0
|
00001 /* Copyright (C) 2004-2009 MBSim Development Team 00002 * 00003 * This library is free software; you can redistribute it and/or 00004 * modify it under the terms of the GNU Lesser General Public 00005 * License as published by the Free Software Foundation; either 00006 * version 2.1 of the License, or (at your option) any later version. 00007 * 00008 * This library is distributed in the hope that it will be useful, 00009 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 * Lesser General Public License for more details. 00012 * 00013 * You should have received a copy of the GNU Lesser General Public 00014 * License along with this library; if not, write to the Free Software 00015 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00016 * 00017 * Contact: markus.ms.schneider@gmail.com 00018 */ 00019 00020 #ifndef _FUNCTION_SENSOR_H_ 00021 #define _FUNCTION_SENSOR_H_ 00022 00023 #include "mbsimControl/sensor.h" 00024 #include <mbsim/functions/function.h> 00025 00026 namespace MBSimControl { 00027 00032 class FunctionSensor : public Sensor { 00033 public: 00034 FunctionSensor(const std::string &name="") : Sensor(name), function(NULL), y() {} 00035 FunctionSensor(const std::string &name, MBSim::Function<fmatvec::VecV(double)>* function_); 00036 ~FunctionSensor() { delete function; } 00037 std::string getType() const { return "FunctionSensor"; } 00038 void setFunction(MBSim::Function<fmatvec::VecV(double)>* function_); 00039 fmatvec::Vec getSignal() {return y.copy(); } 00040 void updateg(double t); 00041 void initializeUsingXML(xercesc::DOMElement *element); 00042 void init(MBSim::Element::InitStage stage); 00043 private: 00044 MBSim::Function<fmatvec::VecV(double)> * function; 00045 fmatvec::Vec y; 00046 }; 00047 00052 class Function_SSEvaluation : public Signal { 00053 public: 00054 Function_SSEvaluation(const std::string &name="") : Signal(name), signal(NULL), fun(NULL), signalString("") {} 00055 ~Function_SSEvaluation() { delete fun; } 00056 void initializeUsingXML(xercesc::DOMElement *element); 00057 void init(InitStage stage); 00058 void setSignal(Signal * s) {signal=s; } 00059 void setFunction(MBSim::Function<double(double)>* fun_) { 00060 fun=fun_; 00061 fun->setParent(this); 00062 fun->setName("Function"); 00063 } 00064 fmatvec::Vec getSignal(); 00065 private: 00066 Signal * signal; 00067 MBSim::Function<double(double)>* fun; 00068 std::string signalString; 00069 }; 00070 00075 class Function_SSSEvaluation : public Signal { 00076 public: 00077 Function_SSSEvaluation(const std::string &name="") : Signal(name), signal1(NULL), signal2(NULL), fun(NULL), signal1String(""), signal2String("") {} 00078 ~Function_SSSEvaluation() { delete fun; } 00079 void initializeUsingXML(xercesc::DOMElement *element); 00080 void init(InitStage stage); 00081 void setSignals(Signal * s1, Signal * s2) {signal1=s1; signal2=s2; } 00082 void setFunction(MBSim::Function<double(double,double)>* fun_) { 00083 fun=fun_; 00084 fun->setParent(this); 00085 fun->setName("Function"); 00086 } 00087 fmatvec::Vec getSignal(); 00088 private: 00089 Signal * signal1; 00090 Signal * signal2; 00091 MBSim::Function<double(double,double)>* fun; 00092 std::string signal1String; 00093 std::string signal2String; 00094 }; 00095 00096 } 00097 00098 #endif /* _FUNCTION_SENSOR_H_ */ 00099
1.8.0