|
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 MBSimInterface { 00029 00032 class InterfaceIntegrator : public MBSim::Integrator { 00033 00034 protected: 00035 std::ofstream integPlot; 00036 00037 public: 00038 00039 InterfaceIntegrator(); 00040 ~InterfaceIntegrator() {} 00041 00042 void integrate(MBSim::DynamicSystemSolver& system); 00043 00044 virtual void initializeUsingXML(MBXMLUtils::TiXmlElement *element); 00045 virtual MBXMLUtils::TiXmlElement* writeXMLFile(MBXMLUtils::TiXmlNode *element); 00046 00047 virtual std::string getType() const { return "InterfaceIntegrator"; } 00048 00049 void setIP(std::string IP_) {IP=IP_; } 00050 void setPort(std::string port_) {port=port_; } 00051 00052 void integratorCommunication(const char* requestIdentifier, const char* interface2mbsim, unsigned int interface2mbsimLength, std::ostringstream* mbsim2interface); 00053 bool getExitRequest() {return exitRequest; } 00054 00055 private: 00056 // get values 00057 void getz(double** z_); 00058 void getzdot(double** zdot_); 00059 void getsv(double** sv_); 00060 00061 // set values 00062 void setTime(double t_) {t=t_; } 00063 void setz(const fmatvec::Vec& z_) {z << z_; } 00064 00065 // internal routines 00066 std::string IP, port; 00067 int zSize, svSize; 00068 double t; 00069 fmatvec::Vec z, zd, sv; 00070 fmatvec::VecInt jsv; 00071 00072 bool printCommunication; 00073 00074 void dumpMemory(std::ostringstream *out, void *p, unsigned int N); 00075 void double2str(std::ostringstream *out, double *p, unsigned int N); 00076 00077 bool exitRequest; 00078 }; 00079 } 00080 00081 #endif // _SERVER_INTEGRATOR_H_
1.8.0