Show
Ignore:
Timestamp:
09/16/09 22:52:57 (15 years ago)
Author:
smidl
Message:

astyle

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • applications/bdmtoolbox/mex/simulator.cpp

    r617 r622  
    1212\enddot 
    1313 
    14 Here,  
     14Here, 
    1515\li Data Source is an object (class DS) providing sequential data, \f$ [d_1, d_2, \ldots d_t] \f$. 
    1616\li Result Logger is an object (class logger) dedicated to storing important data from the experiment. 
     
    5656void mexFunction ( int n_output, mxArray *output[], int n_input, const mxArray *input[] ) { 
    5757        // Check the number of inputs and output arguments 
    58         if(n_input<1) mexErrMsgTxt("Usage:\n"   
    59                 "result=simulator(system,  experiment, logger)\n" 
    60                 "  system     = struct('class','datasource',...);  % Estimated system\n" 
    61                 "  === optional ===" 
    62                 "  experiment = struct('ndat',10);                 % number of data in experiment, full length of finite datasources, 10 otherwise \n" 
    63                 "  logger     = struct('class','mexlogger');       % How to store results, default=mexlog, i.e. matlab structure\n\n" 
    64                 "see documentation of classes datasource and mexlogger and their offsprings in BDM."); 
    65          
     58        if ( n_input<1 ) mexErrMsgTxt ( "Usage:\n" 
     59                                                "result=simulator(system,  experiment, logger)\n" 
     60                                                "  system     = struct('class','datasource',...);  % Estimated system\n" 
     61                                                "  === optional ===" 
     62                                                "  experiment = struct('ndat',10);                 % number of data in experiment, full length of finite datasources, 10 otherwise \n" 
     63                                                "  logger     = struct('class','mexlogger');       % How to store results, default=mexlog, i.e. matlab structure\n\n" 
     64                                                "see documentation of classes datasource and mexlogger and their offsprings in BDM." ); 
     65 
    6666        RV::clear_all(); 
    67         //CONFIG  
     67        //CONFIG 
    6868        UImxArray Cfg; 
    69         try{ 
    70         Cfg.addGroup(input[0],"system"); 
    71         if (n_input>2){ 
    72                 Cfg.addGroup(input[1],"experiment"); 
    73         } 
    74         if (n_input>3){ 
    75                 Cfg.addGroup(input[2],"logger"); 
    76         }/*else{ 
     69        try { 
     70                Cfg.addGroup ( input[0],"system" ); 
     71                if ( n_input>2 ) { 
     72                        Cfg.addGroup ( input[1],"experiment" ); 
     73                } 
     74                if ( n_input>3 ) { 
     75                        Cfg.addGroup ( input[2],"logger" ); 
     76                }/*else{ 
    7777                // define logger as mexlog 
    7878                Setting &S=Cfg.getRoot(); 
     
    8585                S["logger"]["maxlen"]=maxlen; 
    8686        }*/ 
    87         } catch(SettingException e){it_error("error: "+string(e.getPath()));} 
     87        } catch ( SettingException e ) { 
     88                it_error ( "error: "+string ( e.getPath() ) ); 
     89        } 
    8890 
    8991        //DBG 
    90         Cfg.writeFile("simulator.cfg"); 
     92        Cfg.writeFile ( "simulator.cfg" ); 
    9193 
    9294#else 
     
    100102        UIFile Cfg ( fname ); 
    101103#endif 
    102          
    103         shared_ptr<DS> Ds = UI::build<DS>( Cfg, "system" ); 
     104 
     105        shared_ptr<DS> Ds = UI::build<DS> ( Cfg, "system" ); 
    104106        long Ndat=10; 
    105         if (Cfg.exists("experiment")) { 
    106                 if (Cfg.lookupValue ( "experiment.ndat",Ndat )) { 
    107                         bdm_assert(Ndat<=Ds->max_length(), "Data source has less data then required"); 
     107        if ( Cfg.exists ( "experiment" ) ) { 
     108                if ( Cfg.lookupValue ( "experiment.ndat",Ndat ) ) { 
     109                        bdm_assert ( Ndat<=Ds->max_length(), "Data source has less data then required" ); 
    108110                }; 
    109111        } else { 
    110                 if (Ds->max_length() < std::numeric_limits< int >::max()) { 
     112                if ( Ds->max_length() < std::numeric_limits< int >::max() ) { 
    111113                        Ndat=Ds->max_length(); 
    112                 };// else Ndat=10; 
     114                } 
     115                ;// else Ndat=10; 
    113116        } 
    114         shared_ptr<logger> L = UI::build<logger>( Cfg, "logger",UI::optional); 
    115         if (!L) { 
    116                 #ifdef MEX 
     117        shared_ptr<logger> L = UI::build<logger> ( Cfg, "logger",UI::optional ); 
     118        if ( !L ) { 
     119#ifdef MEX 
    117120                //mex logger has only from_setting constructor - we  have to fill it... 
    118                 L=new mexlog(Ndat); 
    119                 #else 
     121                L=new mexlog ( Ndat ); 
     122#else 
    120123                L=new stdlog(); 
    121                 #endif 
     124#endif 
    122125        } 
    123          
     126 
    124127        Ds->log_add ( *L ); 
    125128        L->init(); 
     
    130133                Ds->getdata ( dt );                                     // read data 
    131134                Ds->logit ( *L ); 
    132                  
     135 
    133136                L->step(); 
    134137                Ds->step();                                                     // simulator step 
     
    139142 
    140143#ifdef MEX 
    141         mexlog* mL=dynamic_cast<mexlog*>(L.get()); 
     144        mexlog* mL=dynamic_cast<mexlog*> ( L.get() ); 
    142145 
    143         if (mL) { // user wants output!! 
     146        if ( mL ) { // user wants output!! 
    144147                if ( n_output<1 ) mexErrMsgTxt ( "Wrong number of output variables!" ); 
    145148                output[0] = mL->toCell();