|
mbsiminterface
1.0.0
|
00001 /* Copyright (C) 2013 Markus Schneider 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 * 00018 * Contact: 00019 * markus.ms.schneider@live.de 00020 * 00021 */ 00022 00023 #ifndef _INTERFACE_INTEGRATOR_H_ 00024 #define _INTERFACE_INTEGRATOR_H_ 00025 00026 #include <mbsim/integrators/integrator.h> 00027 00028 namespace MBSimControl { 00029 class Signal; 00030 class ExternSignalSource; 00031 } 00032 00033 namespace MBSimInterface { 00034 00035 class MBSimServer; 00036 00039 class InterfaceIntegrator : public MBSim::Integrator { 00040 00041 protected: 00042 std::ofstream integPlot; 00043 00044 public: 00045 00046 InterfaceIntegrator(); 00047 ~InterfaceIntegrator() {} 00048 00049 void setMBSimServer(MBSimServer* m_) {mbsimServer=m_; } 00050 00051 void integrate(MBSim::DynamicSystemSolver& system); 00052 00053 virtual void initializeUsingXML(xercesc::DOMElement *element); 00054 virtual xercesc::DOMElement* writeXMLFile(xercesc::DOMNode *element); 00055 00056 virtual std::string getType() const { return "InterfaceIntegrator"; } 00057 00058 void integratorCommunication(const char* requestIdentifier, const char* interface2mbsim, unsigned int interface2mbsimLength, std::ostringstream* mbsim2interface); 00059 bool getExitRequest() {return exitRequest; } 00060 00061 private: 00062 // get values 00063 void getz(double** z_); 00064 void getzdot(double** zdot_); 00065 void getsv(double** sv_); 00066 00067 // set values 00068 void setTime(double t_) {t=t_; } 00069 void setz(const fmatvec::Vec& z_) {z << z_; } 00070 00071 // internal routines 00072 int zSize, svSize; 00073 double t; 00074 fmatvec::Vec z, zd, sv; 00075 fmatvec::VecInt jsv; 00076 00077 bool printCommunication; 00078 00079 void dumpMemory(std::ostringstream *out, void *p, unsigned int N); 00080 void double2str(std::ostringstream *out, double *p, unsigned int N); 00081 void int2str(std::ostringstream *out, int *p, unsigned int N); 00082 00083 bool exitRequest; 00084 00085 MBSimServer* mbsimServer; 00086 std::vector<std::string> outputSignalRef, inputSignalRef, outputSignalName, inputSignalName; 00087 std::vector<MBSimControl::Signal*> outputSignal; 00088 std::vector<MBSimControl::ExternSignalSource*> inputSignal; 00089 fmatvec::VecInt outputSignalSize, inputSignalSize; 00090 void resolveInputOutputNames(); 00091 fmatvec::Vec outputVector, inputVector; 00092 }; 00093 } 00094 00095 #endif // _SERVER_INTEGRATOR_H_
1.8.0