mbsimcontrol  4.0.0
function_sensor.h
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 <fmatvec/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, fmatvec::Function<fmatvec::VecV(double)>* function_);
00036       ~FunctionSensor() { delete function; }
00037       std::string getType() const { return "FunctionSensor"; }
00038       void setFunction(fmatvec::Function<fmatvec::VecV(double)>* function_);
00039       fmatvec::Vec getSignal() {return y.copy(); }
00040       void updateg(double t);
00041       void initializeUsingXML(xercesc::DOMElement *element);
00042     private:
00043       fmatvec::Function<fmatvec::VecV(double)> * function;
00044       fmatvec::Vec y;
00045   };
00046 
00051   class Function_SSEvaluation : public Signal {
00052     public:
00053       Function_SSEvaluation(const std::string &name="") : Signal(name), signal(NULL), fun(NULL), signalString("") {}
00054       ~Function_SSEvaluation() { delete fun; }
00055       void initializeUsingXML(xercesc::DOMElement *element);
00056       void init(InitStage stage);
00057       void setSignal(Signal * s) {signal=s; }
00058       void setFunction(fmatvec::Function<double(double)>* fun_) {fun=fun_; }
00059       fmatvec::Vec getSignal();
00060     private:
00061       Signal * signal;
00062       fmatvec::Function<double(double)>* fun;
00063       std::string signalString;
00064   };
00065 
00070   class Function_SSSEvaluation : public Signal {
00071     public:
00072       Function_SSSEvaluation(const std::string &name="") : Signal(name), signal1(NULL), signal2(NULL), fun(NULL), signal1String(""), signal2String("") {}
00073       ~Function_SSSEvaluation() { delete fun; }
00074       void initializeUsingXML(xercesc::DOMElement *element);
00075       void init(InitStage stage);
00076       void setSignals(Signal * s1, Signal * s2) {signal1=s1; signal2=s2; }
00077       void setFunction(fmatvec::Function<double(double,double)>* fun_) {fun=fun_; }
00078       fmatvec::Vec getSignal();
00079     private:
00080       Signal * signal1;
00081       Signal * signal2;
00082       fmatvec::Function<double(double,double)>* fun;
00083       std::string signal1String;
00084       std::string signal2String;
00085   };
00086 
00087 }
00088 
00089 #endif /* _FUNCTION_SENSOR_H_ */
00090