#ifndef MATHMODUL_H#define MATHMODUL_H#ifdef Q_WS_WIN#define MY_EXPORT __declspec(dllexport)#else#define MY_EXPORT#endif#include <QtGui>extern "C" MY_EXPORT void MathModel(double L, double H, double W, double Vu, double B, double M0, double Au, double Ro, double C, double Tr, double T0, double Tu, int steps, double n);static double V,Q,Qc,Qj,Qu,F,j;static QVector<QPointF> Tp, hp;MY_EXPORT QVector<QPointF> getData(QString);#endif // MATHMODUL_H
#include "mathmodul.h"#include <qmath.h>MY_EXPORT void MathModel(double L, double H, double W, double Vu, double B, double M0, double Au, double Ro, double C, double Tr, double T0, double Tu, double steps, double n){ double dz = L/steps; F = 1+0.125*pow(H/W,2)-0.625*(H/W); j = Vu/H; Q = H*W*Vu*F/2; Qj = H*W*M0*pow(j,n+1); Qu = Au*W*(1/B-Tu+Tr); for(int i = 0; i < steps; i++){ Tp.push_back(QPointF(i*dz, Tr+(1/B) * log((B*Qj+W*Au) / (B*Qu) * (1-exp(-B*Qu*(i*dz)) / (Ro*C*Q))) + exp(B*(T0-Tr-(Qu*(i*dz) / (Ro*C*Q)))) )); hp.push_back(QPointF(i*dz, M0*exp(-B*Tp[i].x()-Tr)*pow(j,n-1)) ); } Qc = H*W*Vu*F*Ro*3600/2; }MY_EXPORT QVector<QPointF> getData(QString WTR){ if(WTR == "Tp") return Tp; if(WTR == "hp") return hp; return QVector<QPointF>();}
typedef QVector<QPointF> (*getData) (QString);typedef void (*setVars) (double, double, double, double, double, double, double, double, double, double, double, double, double, double);QLibrary myLib("MathModul");//Проблемы с .dll файлами весьма частое явление if(!myLib.load()){ QMessageBox::warning(this,"Что-то не так", QString(tr("Внимание!!! Файл %1 не может быть загружен\n Проверьте его наличие в папке с программой.")).arg("MathModul"), tr("Okay")); return; } setVars setVariables = (setVars) myLib.resolve("MathModel"); getData getVector = (getData) myLib.resolve("getData"); setVariables(100,2,3,4,1,23,4,1,2.223,232.32,0.33,-23.777,1,10); QVector<QPointF> vect = getVector("Tp");
C++ (Qt)#ifndef MATHMODUL_H#define MATHMODUL_H #include <QtGui> #if defined(MYSHAREDLIB_LIBRARY)# define MY_EXPORT Q_DECL_EXPORT#else# define MY_EXPORT Q_DECL_IMPORT#endif class MY_EXPORT MathModule{public: static void MathModel(double L, double H, double W, double Vu, double B, double M0, double Au, double Ro, double C, double Tr, double T0, double Tu, int steps, double n); static double V,Q,Qc,Qj,Qu,F,j; static QVector<QPointF> Tp, hp; static QVector<QPointF> getData(QString);}; #endif // MATHMODUL_H