/*! \file \brief DataSource for experiments with realistic simulator of the PMSM model \author Vaclav Smidl. ----------------------------------- BDM++ - C++ library for Bayesian Decision Making under Uncertainty Using IT++ for numerical operations ----------------------------------- */ #include #include "pmsm.h" #include "simulator.h" #include //! Simulator of PMSM machine with predefined profile on omega class pmsmDS : public DS { protected: //! indeces of logged variables int L_x, L_ou, L_oy, L_iu; //! Setpoints of omega in timespans given by dt_prof vec profileWw; //! time-step for profiles double dt_prof; //! Number of miliseconds per discrete time step int Dt; public: pmsmDS ( int Dt0 ) : Dt ( Dt0 ) {} void set_parameters ( double Rs0, double Ls0, double Fmag0, double Bf0, double p0, double kp0, double J0, double Uc0, double DT0, double dt0 ) { pmsmsim_set_parameters ( Rs0, Ls0, Fmag0, Bf0, p0, kp0, J0, Uc0, DT0, dt0 ); } void getdata ( vec &dt ) {dt=vec ( KalmanObs,6 );} void write ( vec &ut ) {} void step() { static int ind=0; static double dW; // increase of W static double Ww; // W if ( t>=dt_prof*ind ) { if ( indset_parameters ( S["Rs"], S["Ls"], S["Fmag"], S["Bf"], S["p"], S["kp"], \ S["J"], S["Uc"], S["DT"], 1.0e-6 ); }; public: UIpmsmDS() :UIbuilder ( "pmsmDS" ) {}; bdmroot* build ( Setting &S ) const { pmsmDS* tmp = new pmsmDS ( S["DT"] ); //allowing recursive Settings UIcall ( S["params"], &tmp_set , tmp ); }; }; UIREGISTER(UIpmsmDS);