Index: applications/doprava/k1.cpp
===================================================================
--- applications/doprava/k1.cpp (revision 341)
+++ applications/doprava/k1.cpp (revision 357)
@@ -13,9 +13,9 @@
 
 #include <estim/ekf_templ.h>
-#include <stat/loggers_ui.h>
-#include <stat/libDS_ui.h>
 
 //include dopravni model
 #include "model.h"
+#include "stat\libDS.h"
+#include "stat\loggers.h"
 
 using namespace bdm;
Index: applications/pmsm/pmsmDS.h
===================================================================
--- applications/pmsm/pmsmDS.h (revision 349)
+++ applications/pmsm/pmsmDS.h (revision 357)
@@ -17,191 +17,341 @@
 
 //! Simulator of PMSM machine with predefined profile on omega
-class pmsmDS : public DS {
+class pmsmDS : public DS
+{
 
 protected:
-	//! indeces of logged variables
-	int L_x, L_ou, L_oy, L_iu, L_optu;
-	//! Setpoints of omega in timespans given by dt_prof
-	vec profileWw;
-	//! Setpoints of Mz in timespans given by dt_prof
-	vec profileMz;
-	//! time-step for profiles
-	double dt_prof;
-	//! Number of miliseconds per discrete time step
-	int Dt;
-	//! options for logging, - log predictions of 'true' voltage
-	bool opt_modu;
-	//! options for logging, - 
+    //! indeces of logged variables
+    int L_x, L_ou, L_oy, L_iu, L_optu;
+    //! Setpoints of omega in timespans given by dt_prof
+    vec profileWw;
+    //! Setpoints of Mz in timespans given by dt_prof
+    vec profileMz;
+    //! time-step for profiles
+    double dt_prof;
+    //! Number of miliseconds per discrete time step
+    int Dt;
+    //! options for logging, - log predictions of 'true' voltage
+    bool opt_modu;
+    //! options for logging, -
 public:
-	//! Constructor with fixed sampling period
-	pmsmDS ()   {Dt=125; Drv=RV ( "{o_ua o_ub o_ia o_ib t_ua t_ub o_om o_th Mz }" );}
-	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 );
-	}
-	//! parse options: "modelu" => opt_modu=true;
-	void set_options ( string &opt ) {
-		opt_modu = ( opt.find ( "modelu" ) !=string::npos );
-	}
-	void getdata ( vec &dt ) {dt.set_subvector(0,vec ( KalmanObs,6 ));dt(6)=x[2];dt(7)=x[3];dt(8)=x[8];}
-	void write ( vec &ut ) {}
-
-	void step() {
-		static int ind=0;
-		static double dW; // increase of W
-		static double Ww; // W
-		static double Mz; // W
-		if ( t>=dt_prof*ind ) {
-			ind++;
-			// check omega profile and set dW
-			if ( ind<profileWw.length() ) {
-				//linear increase
-				if ( profileWw.length() ==1 ) {
-					Ww=profileWw ( 0 ); dW=0.0;
-				}
-				else {
-					dW = profileWw ( ind )-profileWw ( ind-1 );
-					dW *=125e-6/dt_prof;
-				}
-			}
-			else {
-				dW = 0;
-			}
-			// Check Mz profile and set Mz
-			if ( ind<profileMz.length() ) {
-				//sudden increase
-				Mz = profileMz(ind);
-			}
-			else {
-				Mz = 0;
-			}
-		}
-		Ww += dW;
-		//Simulate Dt seconds!
-		for ( int i=0;i<Dt;i++ ) {	pmsmsim_step ( Ww , Mz);}
+    //! Constructor with fixed sampling period
+    pmsmDS ()
+    {
+        Dt=125;
+        Drv=RV ( "{o_ua o_ub o_ia o_ib t_ua t_ub o_om o_th Mz }" );
+    }
+    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 );
+    }
+    //! parse options: "modelu" => opt_modu=true;
+    void set_options ( string &opt )
+    {
+        opt_modu = ( opt.find ( "modelu" ) !=string::npos );
+    }
+    void getdata ( vec &dt )
+    {
+        dt.set_subvector(0,vec ( KalmanObs,6 ));
+        dt(6)=x[2];
+        dt(7)=x[3];
+        dt(8)=x[8];
+    }
+    void write ( vec &ut ) {}
+
+    void step()
+    {
+        static int ind=0;
+        static double dW; // increase of W
+        static double Ww; // W
+        static double Mz; // W
+        if ( t>=dt_prof*ind )
+        {
+            ind++;
+            // check omega profile and set dW
+            if ( ind<profileWw.length() )
+            {
+                //linear increase
+                if ( profileWw.length() ==1 )
+                {
+                    Ww=profileWw ( 0 );
+                    dW=0.0;
+                }
+                else
+                {
+                    dW = profileWw ( ind )-profileWw ( ind-1 );
+                    dW *=125e-6/dt_prof;
+                }
+            }
+            else
+            {
+                dW = 0;
+            }
+            // Check Mz profile and set Mz
+            if ( ind<profileMz.length() )
+            {
+                //sudden increase
+                Mz = profileMz(ind);
+            }
+            else
+            {
+                Mz = 0;
+            }
+        }
+        Ww += dW;
+        //Simulate Dt seconds!
+        for ( int i=0; i<Dt; i++ )
+        {
+            pmsmsim_step ( Ww , Mz);
+        }
 // 		for ( int i=0;i<Dt;i++ ) {	pmsmsim_noreg_step ( Ww , Mz);}
-		
-		//discretization
-		double ustep=1.2;
-		KalmanObs [ 0 ] = ustep*itpp::round( KalmanObs [ 0 ]/ ustep) ;
-		KalmanObs [ 1 ] = ustep*itpp::round(KalmanObs [ 1 ]/ ustep);
-		double istep=0.085;
-		KalmanObs [ 2 ] = istep*itpp::round( KalmanObs [ 2 ]/ istep) ;
-		KalmanObs [ 3 ] = istep*itpp::round(KalmanObs [ 3 ]/ istep);
-
-	};
-
-	void log_add ( logger &L ) {
-		L_x = L.add ( rx, "x" );
-		L_oy = L.add ( ry, "o" );
-		L_ou = L.add ( ru, "o" );
-		L_iu = L.add ( ru, "t" );
-		// log differences
-		if ( opt_modu ) {
-			L_optu = L.add ( ru, "model" );
-		}
-	}
-
-	void logit ( logger &L ) {
-		L.logit ( L_x, vec ( x,4 )	);
-		L.logit ( L_oy, vec_2 ( KalmanObs[2],KalmanObs[3] ) );
-		L.logit ( L_ou, vec_2 ( KalmanObs[0],KalmanObs[1] ) );
-		L.logit ( L_iu, vec_2 ( KalmanObs[4],KalmanObs[5] ) );
-		if ( opt_modu ) {
-			double sq3=sqrt ( 3.0 );
-			double ua,ub;
-			double i1=x[0];
-			double i2=0.5* ( -i1+sq3*x[1] );
-			double i3=0.5* ( -i1-sq3*x[1] );
-			double u1=KalmanObs[0];
-			double u2=0.5* ( -u1+sq3*KalmanObs[1] );
-			double u3=0.5* ( -u1-sq3*KalmanObs[1] );
-
-			double du1=1.4* ( double ( i1>0.3 ) - double ( i1<-0.3 ) ) +0.2*i1;
-			double du2=1.4* ( double ( i2>0.3 ) - double ( i2<-0.3 ) ) +0.2*i2;
-			double du3=1.4* ( double ( i3>0.3 ) - double ( i3<-0.3 ) ) +0.2*i3;
-			ua = ( 2.0* ( u1-du1 )- ( u2-du2 )- ( u3-du3 ) ) /3.0;
-			ub = ( ( u2-du2 )- ( u3-du3 ) ) /sq3;
-			L.logit ( L_optu , vec_2 ( ua,ub ) );
-		}
-		
-	}
-
-	void set_profile ( double dt, const vec &Ww, const vec &Mz ) {dt_prof=dt; profileWw=Ww; profileMz=Mz;}
+
+        //discretization
+        double ustep=1.2;
+        KalmanObs [ 0 ] = ustep*itpp::round( KalmanObs [ 0 ]/ ustep) ;
+        KalmanObs [ 1 ] = ustep*itpp::round(KalmanObs [ 1 ]/ ustep);
+        double istep=0.085;
+        KalmanObs [ 2 ] = istep*itpp::round( KalmanObs [ 2 ]/ istep) ;
+        KalmanObs [ 3 ] = istep*itpp::round(KalmanObs [ 3 ]/ istep);
+
+    };
+
+    void log_add ( logger &L )
+    {
+        L_x = L.add ( rx, "x" );
+        L_oy = L.add ( ry, "o" );
+        L_ou = L.add ( ru, "o" );
+        L_iu = L.add ( ru, "t" );
+        // log differences
+        if ( opt_modu )
+        {
+            L_optu = L.add ( ru, "model" );
+        }
+    }
+
+    void logit ( logger &L )
+    {
+        L.logit ( L_x, vec ( x,4 )	);
+        L.logit ( L_oy, vec_2 ( KalmanObs[2],KalmanObs[3] ) );
+        L.logit ( L_ou, vec_2 ( KalmanObs[0],KalmanObs[1] ) );
+        L.logit ( L_iu, vec_2 ( KalmanObs[4],KalmanObs[5] ) );
+        if ( opt_modu )
+        {
+            double sq3=sqrt ( 3.0 );
+            double ua,ub;
+            double i1=x[0];
+            double i2=0.5* ( -i1+sq3*x[1] );
+            double i3=0.5* ( -i1-sq3*x[1] );
+            double u1=KalmanObs[0];
+            double u2=0.5* ( -u1+sq3*KalmanObs[1] );
+            double u3=0.5* ( -u1-sq3*KalmanObs[1] );
+
+            double du1=1.4* ( double ( i1>0.3 ) - double ( i1<-0.3 ) ) +0.2*i1;
+            double du2=1.4* ( double ( i2>0.3 ) - double ( i2<-0.3 ) ) +0.2*i2;
+            double du3=1.4* ( double ( i3>0.3 ) - double ( i3<-0.3 ) ) +0.2*i3;
+            ua = ( 2.0* ( u1-du1 )- ( u2-du2 )- ( u3-du3 ) ) /3.0;
+            ub = ( ( u2-du2 )- ( u3-du3 ) ) /sq3;
+            L.logit ( L_optu , vec_2 ( ua,ub ) );
+        }
+
+    }
+
+    void set_profile ( double dt, const vec &Ww, const vec &Mz )
+    {
+        dt_prof=dt;
+        profileWw=Ww;
+        profileMz=Mz;
+    }
+
+    void from_setting( const Setting &root )
+    {
+        set_parameters ( root["params"]["Rs"], root["params"]["Ls"], root["params"]["Fmag"], \
+                         root["params"]["Bf"], root["params"]["p"], root["params"]["kp"], \
+                         root["params"]["J"], root["params"]["Uc"], root["params"]["DT"], 1.0e-6 );
+
+        // Default values of profiles for omega and Mz
+        vec profW=vec("1.0");
+        vec profM=vec("0.0");
+        double tstep=1.0;
+        root.lookupValue( "tstep", tstep );
+        UI::get( profW, root, "profileW" );
+        UI::get( profM, root, "profileM" );
+        set_profile (tstep , profW, profM);
+
+        string opts;
+        if ( root.lookupValue( "options", opts ) )
+            set_options(opts);
+    }
+
+    // TODO dodelat void to_setting( Setting &root ) const;
 };
 
+UIREGISTER ( pmsmDS );
+
+
 //! This class behaves like BM but it is evaluating EKF
-class pmsmCRB : public EKFfull{
-	protected:
-		vec interr;
-		vec old_true;
-		vec secder;
-		int L_CRB;
-		int L_err;
-		int L_sec;
-	public:
-	//! constructor
-	pmsmCRB():EKFfull(){old_true=zeros(6);}
-
-	void bayes(const vec &dt){
-		static vec umin(2);
-		vec u(2); 
-		//assume we know state exactly:
-		vec true_state=vec(x,4); // read from pmsm
-		E.set_mu(true_state);
-		mu=true_state;
-			
-		//integration error
-		old_true(4)=KalmanObs[4];
-		old_true(5)=KalmanObs[5];// add U
-		u(0) = KalmanObs[0]; // use the required value for derivatives
-		u(1) = KalmanObs[1];
-		interr = (true_state - pfxu->eval(old_true));
-		
-		//second derivative
-		IMpmsm2o* pf = dynamic_cast<IMpmsm2o*>(pfxu);
-		if (pf) {secder=pf->eval2o(u-umin);}
-				
-		umin =u;
-		EKFfull::bayes(dt);
-		old_true.set_subvector(0,true_state);
-	}
-	
-	void log_add(logger &L, const string &name="" ){
-		L_CRB=L.add(rx,"crb");
-		L_err=L.add(rx,"err");
-		L_sec=L.add(rx,"d2");
-	}
-	void logit(logger &L){
-		L.logit(L_err, interr);
-		L.logit(L_CRB,diag(_R()));
-		L.logit(L_sec,secder);
-	}
+class pmsmCRB : public EKFfull
+{
+protected:
+    vec interr;
+    vec old_true;
+    vec secder;
+    int L_CRB;
+    int L_err;
+    int L_sec;
+public:
+    //! constructor
+    pmsmCRB():EKFfull()
+    {
+        old_true=zeros(6);
+    }
+
+    void bayes(const vec &dt)
+    {
+        static vec umin(2);
+        vec u(2);
+        //assume we know state exactly:
+        vec true_state=vec(x,4); // read from pmsm
+        E.set_mu(true_state);
+        mu=true_state;
+
+        //integration error
+        old_true(4)=KalmanObs[4];
+        old_true(5)=KalmanObs[5];// add U
+        u(0) = KalmanObs[0]; // use the required value for derivatives
+        u(1) = KalmanObs[1];
+        interr = (true_state - pfxu->eval(old_true));
+
+        //second derivative
+        IMpmsm2o* pf = dynamic_cast<IMpmsm2o*>(pfxu);
+        if (pf)
+        {
+            secder=pf->eval2o(u-umin);
+        }
+
+        umin =u;
+        EKFfull::bayes(dt);
+        old_true.set_subvector(0,true_state);
+    }
+
+    void log_add(logger &L, const string &name="" )
+    {
+        L_CRB=L.add(rx,"crb");
+        L_err=L.add(rx,"err");
+        L_sec=L.add(rx,"d2");
+    }
+    void logit(logger &L)
+    {
+        L.logit(L_err, interr);
+        L.logit(L_CRB,diag(_R()));
+        L.logit(L_sec,secder);
+    }
+
+    void from_setting( const Setting &root )
+    {
+        diffbifn* IM = UI::build<diffbifn>(root, "IM");
+        diffbifn* OM = UI::build<diffbifn>(root, "OM");
+
+        //parameters
+
+        //statistics
+        int dim=IM->dimension();
+        vec mu0;
+        if (!UI::get( mu0, root, "mu0") )
+            mu0=zeros(dim);
+        mat P0;
+        vec dP0;
+
+        if (UI::get(dP0,root, "dP0") )
+            P0=diag(dP0);
+        else if (!UI::get(P0,root, "P0") )
+            P0=eye(dim);
+
+        set_statistics(mu0,P0);
+
+        vec dQ;
+        UI::get( dQ, root, "dQ");
+        vec dR;
+        UI::get( dR, root, "dR");
+        set_parameters(IM, OM, diag(dQ) , diag(dR));
+
+        //connect
+        RV* drv = UI::build<RV>(root, "drv");
+        set_drv(*drv);
+        RV* rv = UI::build<RV>(root, "rv");
+        set_rv(*rv);
+    }
+
+    // TODO dodelat void to_setting( Setting &root ) const;
 };
 
+UIREGISTER ( pmsmCRB );
+
+
 //! This class behaves like BM but it is evaluating EKF
-class pmsmCRBMz : public EKFfull{
-	protected:
-		int L_CRB;
-	public:
-	//! constructor
-		pmsmCRBMz():EKFfull(){}
-
-		void bayes(const vec &dt){
+class pmsmCRBMz : public EKFfull
+{
+protected:
+    int L_CRB;
+public:
+    //! constructor
+    pmsmCRBMz():EKFfull() {}
+
+    void bayes(const vec &dt)
+    {
 //assume we know state exactly:
-			vec true_state(5);
-			true_state.set_subvector(0,vec(x,4)); // read from pmsm
-			true_state(4)=x[8];
-			
-			E.set_mu(true_state);
-			mu = true_state;
-			//hack for ut
-			EKFfull::bayes(dt);
-		}
-	
-		void log_add(logger &L, const string &name="" ){
-			L_CRB=L.add(concat(rx,RV("Mz",1,0)),"crbz");
-		}
-		void logit(logger &L){
-			L.logit(L_CRB,diag(_R()));
-		}
+        vec true_state(5);
+        true_state.set_subvector(0,vec(x,4)); // read from pmsm
+        true_state(4)=x[8];
+
+        E.set_mu(true_state);
+        mu = true_state;
+        //hack for ut
+        EKFfull::bayes(dt);
+    }
+
+    void log_add(logger &L, const string &name="" )
+    {
+        L_CRB=L.add(concat(rx,RV("Mz",1,0)),"crbz");
+    }
+    void logit(logger &L)
+    {
+        L.logit(L_CRB,diag(_R()));
+    }
+
+    void from_setting( const Setting &root )
+    {
+        diffbifn* IM = UI::build<diffbifn>(root,"IM");
+        diffbifn* OM = UI::build<diffbifn>(root,"OM");
+
+        //statistics
+        int dim=IM->dimension();
+        vec mu0;
+        vec dP0;
+        mat P0;
+        if (!UI::get(mu0, root, "mu0"))
+            mu0=zeros(dim);
+        if (!UI::get( P0, root, "P0" ))
+            if (UI::get(dP0, root, "dP0"))
+                P0=diag(dP0);
+            else
+                P0=eye(dim);
+
+        set_statistics(mu0,P0);
+
+        vec dQ;
+        UI::get(dQ, root, "dQ");
+        vec dR;
+        UI::get(dR, root, "dR");
+        set_parameters(IM, OM, diag(dQ), diag(dR));
+
+        //connect
+        RV* drv = UI::build<RV>(root, "drv");
+        set_drv(*drv);
+        RV* rv = UI::build<RV>(root, "rv");
+        set_rv(*rv);
+    }
+
+    // TODO dodelat void to_setting( Setting &root ) const;
 };
+
+UIREGISTER ( pmsmCRBMz );
Index: applications/pmsm/pmsm_estim.cpp
===================================================================
--- applications/pmsm/pmsm_estim.cpp (revision 342)
+++ applications/pmsm/pmsm_estim.cpp (revision 357)
@@ -7,8 +7,6 @@
  */
 
-#include "pmsm_ui.h"
-#include "stat/loggers_ui.h"
-#include "estim/KF_ui.h"
-#include "stat/libDS_ui.h"
+#include "user_info.h"
+#include "stat/loggers.h"
 
 using namespace bdm;
@@ -17,26 +15,15 @@
 	if ( argc>1 ) {fname = argv[1];	}
 	else { cout << "Missing configuration file.\n Usage: \n $> estimator config_file.cfg"<<endl; abort(); }
-	UIFile F ( fname );
+	UI_File F ( fname );
 
-	logger* L;
-	DS * DS;
+	logger* L = UI::build <logger>( F, "logger" );
+	DS * pDS = UI::build<DS> ( F, "system" );
 	Array<BM*> Es;			// array of estimators
+	UI::get( Es, F, "estimator" );
+	int nE = Es.length();	//number of estimators
 	int Ndat;				//number of data records
-	int nE;					//number of estimators
-
-	try {
-		UIbuild ( F.lookup ( "logger" ),L );
-		UIbuild ( F.lookup ( "system" ),DS );
-		F.lookupValue ( "experiment.ndat",Ndat );
-		Setting& S=F.lookup ( "estimator" );
-		nE = S.getLength();
-		Es.set_size(nE);
-		for(int i=0;i<nE;i++){		
-			UIbuild (S[i] ,Es(i) );
-		}
-	}
-	catch UICATCH;
-
-	DS->log_add ( *L );
+	F.lookupValue ( "experiment.ndat",Ndat );
+		
+	pDS->log_add ( *L );
 	string nic="";
 	for (int i=0; i<nE; i++){
@@ -45,8 +32,8 @@
 	L->init();
 
-	vec dt=zeros ( DS->_drv()._dsize() );   //data variable
+	vec dt=zeros ( pDS->_drv()._dsize() );   //data variable
 	Array<datalink*> Dls(nE); 
 	for (int i=0; i<nE; i++){
-		Dls(i)=new datalink( Es(i)->_drv(),DS->_drv() ); //datalink between a datasource and estimator
+		Dls(i)=new datalink( Es(i)->_drv(),pDS->_drv() ); //datalink between a datasource and estimator
 	}
 	
@@ -54,7 +41,7 @@
 	for ( int tK=1;tK<Ndat;tK++ ) {
 		// Data Source
-		DS->step();							// simulator step
-		DS->getdata ( dt );					// read data
-		DS->logit ( *L );
+		pDS->step();							// simulator step
+		pDS->getdata ( dt );					// read data
+		pDS->logit ( *L );
 		
 		// Estimators
@@ -71,5 +58,5 @@
 
 	delete L;
-	delete DS;
+	delete pDS;
 	for (int i=0; i<nE; i++){
 		delete Dls(i);
Index: applications/pmsm/TR2245/unitsteps.cpp
===================================================================
--- applications/pmsm/TR2245/unitsteps.cpp (revision 317)
+++ applications/pmsm/TR2245/unitsteps.cpp (revision 357)
@@ -17,10 +17,10 @@
 #include <stat/libFN.h>
 
-#include <stat/loggers_ui.h>
-#include <stat/libEF_ui.h>
 
 #include "../pmsm.h"
 #include "simulator.h"
 #include "../sim_profiles.h"
+#include "user_info.h"
+#include "stat/loggers.h"
 
 using namespace bdm;
@@ -30,26 +30,22 @@
 	if ( argc>1 ) {fname = argv[1];	}
 	else { fname = "unitsteps.cfg"; }
-	UIFile F ( fname );
+	UI_File F ( fname );
 
-	int Ndat;
-	int Npart;
 	double h = 1e-6;
 	int Nsimstep = 125;
 
+
+	// Kalman filter
+	int Ndat;
+	int Npart;
+	F.lookupValue ( "ndat", Ndat );
+	F.lookupValue ( "Npart",Npart );
+	mpdf* evolQ = UI::build<mpdf>( F, "Qrw" );
 	vec Qdiag;
 	vec Rdiag;
+	UI::get( Qdiag, F, "dQ" ); //( "1e-6 1e-6 0.001 0.0001" ); //zdenek: 0.01 0.01 0.0001 0.0001
+	UI::get( Rdiag, F, "dR" );// ( "1e-8 1e-8" ); //var(diff(xth)) = "0.034 0.034"
 
-	mpdf* evolQ ;
-	try {
-		// Kalman filter
-		F.lookupValue ( "ndat", Ndat );
-		F.lookupValue ( "Npart",Npart );
-
-		UIbuild ( F.lookup ( "Qrw" ),evolQ );
-		Qdiag= getvec ( F.lookup ( "dQ" ) ); //( "1e-6 1e-6 0.001 0.0001" ); //zdenek: 0.01 0.01 0.0001 0.0001
-		Rdiag=getvec ( F.lookup ( "dR" ) );// ( "1e-8 1e-8" ); //var(diff(xth)) = "0.034 0.034"
-	}
-	catch UICATCH;
-// internal model
+	// internal model
 
 IMpmsm fxu;
@@ -81,5 +77,5 @@
 	M.set_rv ( concat ( rQ,rx ) );
 
-	dirfilelog *L; UIbuild ( F.lookup ( "logger" ), L );// ( "exp/mpf_test",100 );
+	dirfilelog *L = UI::build<dirfilelog>( F, "logger" );// ( "exp/mpf_test",100 );
 	int l_X = L->add ( rx, "xt" );
 	int l_D = L->add ( concat ( ry,ru ), "" );
@@ -99,5 +95,6 @@
 	vec xtm=zeros ( 4 );
 	double Ww=0.0;
-	vec vecW=getvec ( F.lookup ( "profile" ) );
+	vec vecW;
+	UI::get( vecW, F, "profile" );
 
 	for ( int tK=1;tK<Ndat;tK++ ) {
Index: applications/pmsm/TR2245/wishart.cpp
===================================================================
--- applications/pmsm/TR2245/wishart.cpp (revision 317)
+++ applications/pmsm/TR2245/wishart.cpp (revision 357)
@@ -17,10 +17,9 @@
 #include <stat/libFN.h>
 
-#include <stat/loggers_ui.h>
-#include <stat/libEF_ui.h>
-
 #include "../pmsm.h"
 #include "simulator.h"
 #include "../sim_profiles.h"
+#include "user_info.h"
+#include "stat/loggers.h"
 
 using namespace bdm;
@@ -30,30 +29,24 @@
 	if ( argc>1 ) {fname = argv[1];	}
 	else { fname = "unitsteps.cfg"; }
-	UIFile F ( fname );
+	UI_File F ( fname );
 
+	double h = 1e-6;
 	int Ndat;
 	int Npart;
-	double h = 1e-6;
+	F.lookupValue ( "ndat", Ndat );
+	F.lookupValue ( "Npart",Npart );
 	int Nsimstep = 125;
 
+		// Kalman filter
 	vec Qdiag;
+	UI::get( Qdiag, F, "dQ" ); //( "1e-6 1e-6 0.001 0.0001" ); //zdenek: 0.01 0.01 0.0001 0.0001
+		
 	vec Rdiag;
+	UI::get( Rdiag, F, "dR" );// ( "1e-8 1e-8" ); //var(diff(xth)) = "0.034 0.034"
 
-//	mpdf* evolQ ;
-	try {
-		// Kalman filter
-		F.lookupValue ( "ndat", Ndat );
-		F.lookupValue ( "Npart",Npart );
-
-//		UIbuild ( F.lookup ( "Qrw" ),evolQ );
-		Qdiag= getvec ( F.lookup ( "dQ" ) ); //( "1e-6 1e-6 0.001 0.0001" ); //zdenek: 0.01 0.01 0.0001 0.0001
-		Rdiag=getvec ( F.lookup ( "dR" ) );// ( "1e-8 1e-8" ); //var(diff(xth)) = "0.034 0.034"
-	}
-	catch UICATCH;
-// internal model
-
-IMpmsm fxu;
-//                  Rs    Ls        dt       Fmag(Ypm)    kp   p    J     Bf(Mz)
-fxu.set_parameters ( 0.28, 0.003465, Nsimstep*h, 0.1989, 1.5 ,4.0, 0.04, 0.0 );
+	// internal model
+	IMpmsm fxu;
+	//                  Rs    Ls        dt       Fmag(Ypm)    kp   p    J     Bf(Mz)
+	fxu.set_parameters ( 0.28, 0.003465, Nsimstep*h, 0.1989, 1.5 ,4.0, 0.04, 0.0 );
 	// observation model
 	OMpmsm hxu;
@@ -84,5 +77,5 @@
 	M.set_rv ( concat ( rQ,rx ) );
 
-	dirfilelog *L; UIbuild ( F.lookup ( "logger" ), L );// ( "exp/mpf_test",100 );
+	dirfilelog *L = UI::build<dirfilelog> ( F, "logger" );// ( "exp/mpf_test",100 );
 	int l_X = L->add ( rx, "xt" );
 	int l_D = L->add ( concat ( ry,ru ), "" );
@@ -103,5 +96,6 @@
 	vec xtm=zeros ( 4 );
 	double Ww=0.0;
-	vec vecW=getvec ( F.lookup ( "profile" ) );
+	vec vecW;
+	UI::get( vecW, F ,"profile" );
 	
 	mat tQ=diag(Qdiag);
Index: applications/pmsm/TR2245/pmsm_wishart.cpp
===================================================================
--- applications/pmsm/TR2245/pmsm_wishart.cpp (revision 332)
+++ applications/pmsm/TR2245/pmsm_wishart.cpp (revision 357)
@@ -17,8 +17,6 @@
 #include <stat/libFN.h>
 
-#include <stat/loggers_ui.h>
-#include <stat/libEF_ui.h>
-
-#include "../pmsm_ui.h"
+#include "user_info.h"
+#include "../pmsmDS.h"
 
 using namespace bdm;
@@ -28,39 +26,32 @@
 	if ( argc>1 ) {fname = argv[1];	}
 	else { fname = "pmsm_wishart.cfg"; }
-	UIFile F ( fname );
+	UI_File F ( fname );
+
+	double h = 1e-6;
+	int Nsimstep = 125;
+
+	// Kalman filter
+	double k;
+	double l;
+	F.lookupValue ( "k",k);
+	F.lookupValue ( "l",l);
 
 	int Ndat;
 	int Npart;
-	double h = 1e-6;
-	int Nsimstep = 125;
+	F.lookupValue ( "ndat", Ndat );
+	F.lookupValue ( "Npart", Npart );
 
 	vec Qdiag;
 	vec Rdiag;
+	UI::get( Qdiag, F, "dQ" ); //( "1e-6 1e-6 0.001 0.0001" ); //zdenek: 0.01 0.01 0.0001 0.0001
+	UI::get( Rdiag, F, "dR" );// ( "1e-8 1e-8" ); //var(diff(xth)) = "0.034 0.034"
+		
+	pmsmDS* DS = UI::build<pmsmDS>(F,"system");
+	//	mpdf* evolQ = UI::build<mpdf>( F, "Qrw" );
 
-	pmsmDS* DS;
-
-	double k;
-	double l;
-//	mpdf* evolQ ;
-	try {
-		// Kalman filter
-		F.lookupValue ( "ndat", Ndat );
-		F.lookupValue ( "Npart",Npart );
-		
-		F.lookupValue ( "k", k);
-		F.lookupValue ( "l",l);
-
-//		UIbuild ( F.lookup ( "Qrw" ),evolQ );
-		Qdiag= getvec ( F.lookup ( "dQ" ) ); //( "1e-6 1e-6 0.001 0.0001" ); //zdenek: 0.01 0.01 0.0001 0.0001
-		Rdiag=getvec ( F.lookup ( "dR" ) );// ( "1e-8 1e-8" ); //var(diff(xth)) = "0.034 0.034"
-		
-		UIbuild(F.lookup("system"),DS);
-	}
-	catch UICATCH;
-// internal model
-
-IMpmsm fxu;
-//                  Rs    Ls        dt       Fmag(Ypm)    kp   p    J     Bf(Mz)
-fxu.set_parameters ( 0.28, 0.003465, Nsimstep*h, 0.1989, 1.5 ,4.0, 0.04, 0.0 );
+	// internal model
+	IMpmsm fxu;
+	//                  Rs    Ls        dt       Fmag(Ypm)    kp   p    J     Bf(Mz)
+	fxu.set_parameters ( 0.28, 0.003465, Nsimstep*h, 0.1989, 1.5 ,4.0, 0.04, 0.0 );
 	// observation model
 	OMpmsm hxu;
@@ -91,5 +82,5 @@
 	M.set_rv ( concat ( rQ,rx ) );
 
-	dirfilelog *L; UIbuild ( F.lookup ( "logger" ), L );// ( "exp/mpf_test",100 );
+	dirfilelog *L = UI::build<dirfilelog> ( F, "logger" );// ( "exp/mpf_test",100 );
 	
 	KFE.set_options ( "logbounds" );
Index: applications/pmsm/pmsm.h
===================================================================
--- applications/pmsm/pmsm.h (revision 349)
+++ applications/pmsm/pmsm.h (revision 357)
@@ -3,4 +3,5 @@
 
 #include <stat/libFN.h>
+#include "user_info.h"
 
 /*! \defgroup PMSM 
@@ -94,6 +95,15 @@
 
 	void dfdu_cond ( const vec &x0, const vec &u0, mat &A, bool full=true ) {it_error ( "not needed" );};
-};
-
+
+	void from_setting( const Setting &root )
+	{	
+		set_parameters ( root["params"]["Rs"], root["params"]["Ls"], 125e-6, root["params"]["Fmag"], \
+			root["params"]["kp"],  root["params"]["p"], root["params"]["J"], 0.0 );
+	};
+
+	// TODO dodelat void to_setting( Setting &root ) const;
+};
+
+UIREGISTER ( IMpmsm );
 
 //! State evolution model for a PMSM drive and its derivative with respect to \f$x\f$
@@ -182,4 +192,7 @@
 };
 
+
+UIREGISTER ( IMpmsm2o );
+
 //! State evolution model for a PMSM drive and its derivative with respect to \f$x\f$, equation for \f$\omega\f$ is omitted.$
 class IMpmsmStat : public IMpmsm {
@@ -234,4 +247,7 @@
 };
 
+UIREGISTER ( IMpmsmStat );
+
+
 //! State for PMSM with unknown Mz
 class IMpmsmMz: public IMpmsm{
@@ -256,4 +272,6 @@
 };
 
+UIREGISTER ( IMpmsmMz );
+
 //! State for PMSM with unknown Mz
 class IMpmsmStatMz: public IMpmsmStat{
@@ -278,4 +296,6 @@
 };
 
+UIREGISTER ( IMpmsmStatMz );
+
 
 //! Observation model for PMSM drive and its derivative with respect to \f$x\f$
@@ -298,4 +318,6 @@
 };
 
+UIREGISTER ( OMpmsm );
+
 //! Observation model for PMSM drive and its derivative with respect to \f$x\f$ for full vector of observations
 class OMpmsm4: public diffbifn {
@@ -314,4 +336,10 @@
 };
 
+UIREGISTER ( OMpmsm4 );
+
+
+
+
+
 /*!@}*/
 #endif //PMSM_H
Index: applications/pmsm/CMakeLists.txt
===================================================================
--- applications/pmsm/CMakeLists.txt (revision 284)
+++ applications/pmsm/CMakeLists.txt (revision 357)
@@ -13,5 +13,5 @@
 ## Build simulator
 add_subdirectory (simulator_zdenek)
-add_subdirectory (simulator_zdenek/ekf_example)
+#add_subdirectory (simulator_zdenek/ekf_example)
 
 ## Use it
Index: applications/mpdm/TR2244/CMakeLists.txt
===================================================================
--- applications/mpdm/TR2244/CMakeLists.txt (revision 357)
+++ applications/mpdm/TR2244/CMakeLists.txt (revision 357)
@@ -0,0 +1,5 @@
+# Make sure the compiler can find include files from our Bdm library.
+include_directories (${BDM_SOURCE_DIR}/bdm)
+link_directories (${BDM_BINARY_DIR}/bdm)
+
+EXEC(merger_iter_cond)
Index: applications/mpdm/SYSID09/CMakeLists.txt
===================================================================
--- applications/mpdm/SYSID09/CMakeLists.txt (revision 357)
+++ applications/mpdm/SYSID09/CMakeLists.txt (revision 357)
@@ -0,0 +1,5 @@
+# Make sure the compiler can find include files from our Bdm library.
+include_directories (${BDM_SOURCE_DIR}/bdm)
+link_directories (${BDM_BINARY_DIR}/bdm)
+
+EXEC(merg_2a)
Index: applications/mpdm/CMakeLists.txt
===================================================================
--- applications/mpdm/CMakeLists.txt (revision 299)
+++ applications/mpdm/CMakeLists.txt (revision 357)
@@ -1,8 +1,6 @@
-# Make sure the compiler can find include files from our Bdm library.
-include_directories (${BDM_SOURCE_DIR}/bdm)
-link_directories (${BDM_BINARY_DIR}/bdm)
+# Compulsory line
+cmake_minimum_required(VERSION 2.6)
 
-EXEC(merg_pred)
-EXEC(merg_giw)
-EXEC(TR2244/merger_iter_cond)
-EXEC(SYSID09/merg_2a)
+add_subdirectory (SYSID09)
+add_subdirectory (TR2244)
+
