#include "__cf_Mohamed_Alaswed_Buck.h"
#include <math.h>
#include "Mohamed_Alaswed_Buck.h"
#include "Mohamed_Alaswed_Buck_private.h"
#include "Mohamed_Alaswed_Buck_dt.h"
const int_T gblNumToFiles = 0 ; const int_T gblNumFrFiles = 0 ; const int_T
gblNumFrWksBlocks = 0 ;
#ifdef RSIM_WITH_SOLVER_MULTITASKING
const boolean_T gbl_raccel_isMultitasking = 1 ;
#else
const boolean_T gbl_raccel_isMultitasking = 0 ;
#endif
const boolean_T gbl_raccel_tid01eq = 0 ; const int_T gbl_raccel_NumST = 3 ;
const char_T * gbl_raccel_Version = "8.4 (R2013a) 13-Feb-2013" ; void
raccel_setup_MMIStateLog ( SimStruct * S ) {
#ifdef UseMMIDataLogging
rt_FillStateSigInfoFromMMI ( ssGetRTWLogInfo ( S ) , & ssGetErrorStatus ( S )
) ;
#endif
} const char * gblSlvrJacPatternFileName =
"slprj\\raccel\\Mohamed_Alaswed_Buck\\Mohamed_Alaswed_Buck_Jpattern.mat" ;
const int_T gblNumRootInportBlks = 0 ; const int_T gblNumModelInputs = 0 ;
extern rtInportTUtable * gblInportTUtables ; extern const char *
gblInportFileName ; const int_T gblInportDataTypeIdx [ ] = { - 1 } ; const
int_T gblInportDims [ ] = { - 1 } ; const int_T gblInportComplex [ ] = { - 1
} ; const int_T gblInportInterpoFlag [ ] = { - 1 } ; const int_T
gblInportContinuous [ ] = { - 1 } ;
#include "simstruc.h"
#include "fixedpoint.h"
B rtB ; X rtX ; DW rtDW ; static SimStruct model_S ; SimStruct * const rtS =
& model_S ; void MdlInitialize ( void ) { { real_T * As = ( real_T * ) rtDW .
evxxlzsqhp . AS ; real_T * Bs = ( real_T * ) rtDW . evxxlzsqhp . BS ; real_T
* Cs = ( real_T * ) rtDW . evxxlzsqhp . CS ; real_T * Ds = ( real_T * ) rtDW
. evxxlzsqhp . DS ; int_T * Chopper = ( int_T * ) rtDW . evxxlzsqhp . CHOPPER
; rtX . gly5v3vhf0 [ 0 ] = 0.00022499662505062431 ; rtX . gly5v3vhf0 [ 1 ] =
0.00014999775003374951 ; rtX . gly5v3vhf0 [ 2 ] = - 0.00022499662504930733 ;
As [ 0 ] = - 802246.28961091046 ; As [ 1 ] = 1.2033694344163658E+6 ; As [ 2 ]
= 0.0 ; As [ 3 ] = - 833.33333333333337 ; As [ 4 ] = - 414593.69817578769 ;
As [ 5 ] = - 829.18739635157544 ; As [ 6 ] = 0.0 ; As [ 7 ] =
3.9800995024875621E+6 ; As [ 8 ] = - 39.800995024875625 ; Bs [ 0 ] = 0.0 ; Bs
[ 1 ] = 0.0 ; Bs [ 2 ] = 0.0 ; Bs [ 3 ] = 0.0 ; Bs [ 4 ] = 0.0 ; Bs [ 5 ] =
414593.69817578769 ; Bs [ 6 ] = 414593.69817578769 ; Bs [ 7 ] = -
414593.69817578769 ; Bs [ 8 ] = 4.1459369817579512 ; Bs [ 9 ] = 0.0 ; Bs [ 10
] = - 3.9800995024875621E+6 ; Bs [ 11 ] = - 3.9800995024875621E+6 ; Bs [ 12 ]
= 3.9800995024875621E+6 ; Bs [ 13 ] = - 39.800995024875625 ; Bs [ 14 ] = 0.0
; Cs [ 0 ] = 0.0 ; Cs [ 1 ] = 497.51243781094524 ; Cs [ 2 ] =
0.99502487562189046 ; Cs [ 3 ] = 0.0 ; Cs [ 4 ] = 497.51243781094524 ; Cs [ 5
] = 0.99502487562189046 ; Cs [ 6 ] = 0.0 ; Cs [ 7 ] = - 497.51243781094524 ;
Cs [ 8 ] = - 0.99502487562189046 ; Cs [ 9 ] = 1.0 ; Cs [ 10 ] = 0.0 ; Cs [ 11
] = 0.0 ; Cs [ 12 ] = 0.0 ; Cs [ 13 ] = 0.0 ; Cs [ 14 ] = 0.0 ; Cs [ 15 ] =
0.0 ; Cs [ 16 ] = - 0.99502487562189057 ; Cs [ 17 ] = 9.9502487562189058E-6 ;
Cs [ 18 ] = 0.0 ; Cs [ 19 ] = 0.99999999999999989 ; Cs [ 20 ] = 0.0 ; Cs [ 21
] = - 0.66666666666666663 ; Cs [ 22 ] = 1.0 ; Cs [ 23 ] = 0.0 ; Cs [ 24 ] =
0.66666666666666652 ; Cs [ 25 ] = 1.1102230246251565E-16 ; Cs [ 26 ] = 0.0 ;
Ds [ 0 ] = - 497.51243781094524 ; Ds [ 1 ] = - 497.51243781094524 ; Ds [ 2 ]
= 497.51243781094524 ; Ds [ 3 ] = 0.99502487562189046 ; Ds [ 4 ] = 0.0 ; Ds [
5 ] = - 497.51243781094524 ; Ds [ 6 ] = - 497.51243781094524 ; Ds [ 7 ] =
497.51243781094524 ; Ds [ 8 ] = - 0.0049751243781095411 ; Ds [ 9 ] = - 1.0 ;
Ds [ 10 ] = 497.51243781094524 ; Ds [ 11 ] = 497.51243781094524 ; Ds [ 12 ] =
- 497.51243781094524 ; Ds [ 13 ] = - 0.99502487562189046 ; Ds [ 14 ] = 0.0 ;
Ds [ 15 ] = 0.0 ; Ds [ 16 ] = 0.0 ; Ds [ 17 ] = 0.0 ; Ds [ 18 ] = 0.0 ; Ds [
19 ] = 0.0 ; Ds [ 20 ] = 0.0 ; Ds [ 21 ] = 0.0 ; Ds [ 22 ] = 0.0 ; Ds [ 23 ]
= 1.0 ; Ds [ 24 ] = 0.0 ; Ds [ 25 ] = 0.99502487562189057 ; Ds [ 26 ] = -
0.0049751243781094526 ; Ds [ 27 ] = - 0.99502487562189057 ; Ds [ 28 ] =
9.9502487562189058E-6 ; Ds [ 29 ] = 0.0 ; Ds [ 30 ] = 1.1102230246251565E-16
; Ds [ 31 ] = 1.1102230246251565E-16 ; Ds [ 32 ] = - 1.1102230246251565E-16 ;
Ds [ 33 ] = 0.0 ; Ds [ 34 ] = 0.0 ; Ds [ 35 ] = 0.0 ; Ds [ 36 ] = 0.0 ; Ds [
37 ] = 0.0 ; Ds [ 38 ] = 0.0 ; Ds [ 39 ] = 0.0 ; Ds [ 40 ] = 0.0 ; Ds [ 41 ]
= 0.0 ; Ds [ 42 ] = 0.0 ; Ds [ 43 ] = 0.0 ; Ds [ 44 ] = 0.0 ; { int_T i1 ;
for ( i1 = 0 ; i1 < 9 ; i1 ++ ) { Chopper [ i1 ] = 1 ; } } { int_T *
switch_status = ( int_T * ) rtDW . evxxlzsqhp . SWITCH_STATUS ; int_T *
gState = ( int_T * ) rtDW . evxxlzsqhp . G_STATE ; real_T * yswitch = (
real_T * ) rtDW . evxxlzsqhp . Y_SWITCH ; int_T * switchTypes = ( int_T * )
rtDW . evxxlzsqhp . SWITCH_TYPES ; int_T * idxOutSw = ( int_T * ) rtDW .
evxxlzsqhp . IDX_OUT_SW ; int_T * switch_status_init = ( int_T * ) rtDW .
evxxlzsqhp . SWITCH_STATUS_INIT ; switch_status [ 0 ] = 0 ;
switch_status_init [ 0 ] = 0 ; gState [ 0 ] = ( int_T ) 0.0 ; yswitch [ 0 ] =
1 / 0.1 ; switchTypes [ 0 ] = ( int_T ) 1.0 ; idxOutSw [ 0 ] = ( ( int_T )
0.0 ) - 1 ; switch_status [ 1 ] = 0 ; switch_status_init [ 1 ] = 0 ; gState [
1 ] = ( int_T ) 0.0 ; yswitch [ 1 ] = 1 / 0.001 ; switchTypes [ 1 ] = ( int_T
) 3.0 ; idxOutSw [ 1 ] = ( ( int_T ) 0.0 ) - 1 ; switch_status [ 2 ] = 0 ;
switch_status_init [ 2 ] = 0 ; gState [ 2 ] = ( int_T ) 0.0 ; yswitch [ 2 ] =
1 / 0.01 ; switchTypes [ 2 ] = ( int_T ) 3.0 ; idxOutSw [ 2 ] = ( ( int_T )
0.0 ) - 1 ; } } } void MdlEnable ( void ) { rtDW . gvexmenpy3 = 1 ;
_ssSetSampleHit ( rtS , 2 , 1 ) ; _ssSetTaskTime ( rtS , 2 , ssGetT ( rtS ) )
; _ssSetVarNextHitTime ( rtS , 0 , ssGetT ( rtS ) ) ; } void MdlStart ( void
) { { rtDW . evxxlzsqhp . AS = ( real_T * ) calloc ( 3 * 3 , sizeof ( real_T
) ) ; rtDW . evxxlzsqhp . BS = ( real_T * ) calloc ( 3 * 5 , sizeof ( real_T
) ) ; rtDW . evxxlzsqhp . CS = ( real_T * ) calloc ( 9 * 3 , sizeof ( real_T
) ) ; rtDW . evxxlzsqhp . DS = ( real_T * ) calloc ( 9 * 5 , sizeof ( real_T
) ) ; rtDW . evxxlzsqhp . DX_COL = ( real_T * ) calloc ( 9 , sizeof ( real_T
) ) ; rtDW . evxxlzsqhp . BD_COL = ( real_T * ) calloc ( 3 , sizeof ( real_T
) ) ; rtDW . evxxlzsqhp . TMP1 = ( real_T * ) calloc ( 3 , sizeof ( real_T )
) ; rtDW . evxxlzsqhp . TMP2 = ( real_T * ) calloc ( 5 , sizeof ( real_T ) )
; rtDW . evxxlzsqhp . CHOPPER = ( int_T * ) calloc ( 9 , sizeof ( int_T ) ) ;
rtDW . evxxlzsqhp . SWITCH_STATUS = ( int_T * ) calloc ( 3 , sizeof ( int_T )
) ; rtDW . evxxlzsqhp . SW_CHG = ( int_T * ) calloc ( 3 , sizeof ( int_T ) )
; rtDW . evxxlzsqhp . G_STATE = ( int_T * ) calloc ( 3 , sizeof ( int_T ) ) ;
rtDW . evxxlzsqhp . Y_SWITCH = ( real_T * ) calloc ( 3 , sizeof ( real_T ) )
; rtDW . evxxlzsqhp . SWITCH_TYPES = ( int_T * ) calloc ( 3 , sizeof ( int_T
) ) ; rtDW . evxxlzsqhp . IDX_OUT_SW = ( int_T * ) calloc ( 3 , sizeof (
int_T ) ) ; rtDW . evxxlzsqhp . SWITCH_STATUS_INIT = ( int_T * ) calloc ( 3 ,
sizeof ( int_T ) ) ; } MdlInitialize ( ) ; MdlEnable ( ) ; } void MdlOutputs
( int_T tid ) { real_T taskTimeV ; real_T tNextAdjusted ; uint32_T numCycles
; { real_T accum ; int_T * switch_status = ( int_T * ) rtDW . evxxlzsqhp .
SWITCH_STATUS ; int_T * switch_status_init = ( int_T * ) rtDW . evxxlzsqhp .
SWITCH_STATUS_INIT ; int_T * SwitchChange = ( int_T * ) rtDW . evxxlzsqhp .
SW_CHG ; int_T * Chopper = ( int_T * ) rtDW . evxxlzsqhp . CHOPPER ; int_T *
gState = ( int_T * ) rtDW . evxxlzsqhp . G_STATE ; real_T * yswitch = (
real_T * ) rtDW . evxxlzsqhp . Y_SWITCH ; int_T * switchTypes = ( int_T * )
rtDW . evxxlzsqhp . SWITCH_TYPES ; int_T * idxOutSw = ( int_T * ) rtDW .
evxxlzsqhp . IDX_OUT_SW ; real_T * DxCol = ( real_T * ) rtDW . evxxlzsqhp .
DX_COL ; real_T * BDcol = ( real_T * ) rtDW . evxxlzsqhp . BD_COL ; real_T *
tmp1 = ( real_T * ) rtDW . evxxlzsqhp . TMP1 ; real_T * tmp2 = ( real_T * )
rtDW . evxxlzsqhp . TMP2 ; int_T newState ; int_T swChanged = 0 ; int
loopsToDo = 20 ; real_T temp ; memcpy ( switch_status_init , switch_status ,
3 * sizeof ( int_T ) ) ; do { if ( loopsToDo == 1 ) { swChanged = 0 ; { int_T
i1 ; for ( i1 = 0 ; i1 < 3 ; i1 ++ ) { swChanged = ( ( SwitchChange [ i1 ] =
switch_status_init [ i1 ] - switch_status [ i1 ] ) != 0 ) | swChanged ;
switch_status [ i1 ] = switch_status_init [ i1 ] ; } } } else { real_T * Cs =
( real_T * ) rtDW . evxxlzsqhp . CS ; real_T * Ds = ( real_T * ) rtDW .
evxxlzsqhp . DS ; { int_T i1 ; real_T * y0 = rtB . f0igiyewke ; for ( i1 = 0
; i1 < 9 ; i1 ++ ) { accum = 0.0 ; accum += * ( Cs ++ ) * rtX . gly5v3vhf0 [
0 ] ; accum += * ( Cs ++ ) * rtX . gly5v3vhf0 [ 1 ] ; accum += * ( Cs ++ ) *
rtX . gly5v3vhf0 [ 2 ] ; accum += * ( Ds ++ ) * rtP . SwitchCurrents_Value [
0 ] ; accum += * ( Ds ++ ) * rtP . SwitchCurrents_Value [ 1 ] ; accum += * (
Ds ++ ) * rtP . SwitchCurrents_Value [ 2 ] ; accum += * ( Ds ++ ) * rtP .
DC_Value ; accum += * ( Ds ++ ) * rtP . qqq_Value ; y0 [ i1 ] = accum *
Chopper [ i1 ] ; } } if ( ssIsMajorTimeStep ( rtS ) ) { rtDW . molvy3pc4q [ 0
] = rtB . f0igiyewke [ 0 ] > 0.0 ? GTZERO : ( ( rtB . f0igiyewke [ 0 ] < 0.0
) ? LTZERO : NOCHANGE ) ; rtDW . molvy3pc4q [ 1 ] = rtB . f0igiyewke [ 1 ] >
0.0 ? GTZERO : ( ( rtB . f0igiyewke [ 1 ] < 0.0 ) ? LTZERO : NOCHANGE ) ;
rtDW . molvy3pc4q [ 2 ] = rtB . f0igiyewke [ 2 ] > 0.0 ? GTZERO : ( ( rtB .
f0igiyewke [ 2 ] < 0.0 ) ? LTZERO : NOCHANGE ) ; } swChanged = 0 ; newState =
gState [ 0 ] > 0 ? 1 : 0 ; swChanged = ( ( SwitchChange [ 0 ] = newState -
switch_status [ 0 ] ) != 0 ) | swChanged ; switch_status [ 0 ] = newState ;
newState = ( rtDW . molvy3pc4q [ 1 ] == GTZERO ) ? 1 : ( ( rtDW . molvy3pc4q
[ 1 ] == LTZERO ) ? 0 : switch_status [ 1 ] ) ; swChanged = ( ( SwitchChange
[ 1 ] = newState - switch_status [ 1 ] ) != 0 ) | swChanged ; switch_status [
1 ] = newState ; newState = ( rtDW . molvy3pc4q [ 2 ] == GTZERO ) ? 1 : ( (
rtDW . molvy3pc4q [ 2 ] == LTZERO ) ? 0 : switch_status [ 2 ] ) ; swChanged =
( ( SwitchChange [ 2 ] = newState - switch_status [ 2 ] ) != 0 ) | swChanged
; switch_status [ 2 ] = newState ; } if ( swChanged ) { real_T * As = (
real_T * ) rtDW . evxxlzsqhp . AS ; real_T * Cs = ( real_T * ) rtDW .
evxxlzsqhp . CS ; real_T * Bs = ( real_T * ) rtDW . evxxlzsqhp . BS ; real_T
* Ds = ( real_T * ) rtDW . evxxlzsqhp . DS ; real_T a1 ; { int_T i1 ; for (
i1 = 0 ; i1 < 3 ; i1 ++ ) { if ( SwitchChange [ i1 ] != 0 ) { if ( idxOutSw [
i1 ] > - 1 ) { Chopper [ idxOutSw [ i1 ] ] = switch_status [ i1 ] ; } a1 =
yswitch [ i1 ] * SwitchChange [ i1 ] ; temp = 1 / ( 1 - Ds [ i1 * 6 ] * a1 )
; { int_T i2 ; for ( i2 = 0 ; i2 < 9 ; i2 ++ ) { DxCol [ i2 ] = Ds [ i2 * 5 +
i1 ] * temp * a1 ; } } DxCol [ i1 ] = temp ; BDcol [ 0 ] = Bs [ 0 + i1 ] * a1
; BDcol [ 1 ] = Bs [ 5 + i1 ] * a1 ; BDcol [ 2 ] = Bs [ 10 + i1 ] * a1 ;
memcpy ( tmp1 , & Cs [ i1 * 3 ] , 3 * sizeof ( real_T ) ) ; memset ( & Cs [
i1 * 3 ] , '\0' , 3 * sizeof ( real_T ) ) ; memcpy ( tmp2 , & Ds [ i1 * 5 ] ,
5 * sizeof ( real_T ) ) ; memset ( & Ds [ i1 * 5 ] , '\0' , 5 * sizeof (
real_T ) ) ; { int_T i2 ; for ( i2 = 0 ; i2 < 9 ; i2 ++ ) { a1 = DxCol [ i2 ]
; Cs [ i2 * 3 + 0 ] += a1 * tmp1 [ 0 ] ; Cs [ i2 * 3 + 1 ] += a1 * tmp1 [ 1 ]
; Cs [ i2 * 3 + 2 ] += a1 * tmp1 [ 2 ] ; { int_T i3 ; for ( i3 = 0 ; i3 < 5 ;
i3 ++ ) { Ds [ i2 * 5 + i3 ] += a1 * tmp2 [ i3 ] ; } } } } a1 = BDcol [ 0 ] ;
As [ 0 + 0 ] += a1 * Cs [ i1 * 3 + 0 ] ; As [ 0 + 1 ] += a1 * Cs [ i1 * 3 + 1
] ; As [ 0 + 2 ] += a1 * Cs [ i1 * 3 + 2 ] ; { int_T i2 ; for ( i2 = 0 ; i2 <
5 ; i2 ++ ) { Bs [ 0 + i2 ] += a1 * Ds [ i1 * 5 + i2 ] ; } } a1 = BDcol [ 1 ]
; As [ 3 + 0 ] += a1 * Cs [ i1 * 3 + 0 ] ; As [ 3 + 1 ] += a1 * Cs [ i1 * 3 +
1 ] ; As [ 3 + 2 ] += a1 * Cs [ i1 * 3 + 2 ] ; { int_T i2 ; for ( i2 = 0 ; i2
< 5 ; i2 ++ ) { Bs [ 5 + i2 ] += a1 * Ds [ i1 * 5 + i2 ] ; } } a1 = BDcol [ 2
] ; As [ 6 + 0 ] += a1 * Cs [ i1 * 3 + 0 ] ; As [ 6 + 1 ] += a1 * Cs [ i1 * 3
+ 1 ] ; As [ 6 + 2 ] += a1 * Cs [ i1 * 3 + 2 ] ; { int_T i2 ; for ( i2 = 0 ;
i2 < 5 ; i2 ++ ) { Bs [ 10 + i2 ] += a1 * Ds [ i1 * 5 + i2 ] ; } } } } } } }
while ( swChanged > 0 && -- loopsToDo > 0 ) ; if ( loopsToDo == 0 ) { real_T
* Cs = ( real_T * ) rtDW . evxxlzsqhp . CS ; real_T * Ds = ( real_T * ) rtDW
. evxxlzsqhp . DS ; { int_T i1 ; real_T * y0 = rtB . f0igiyewke ; for ( i1 =
0 ; i1 < 9 ; i1 ++ ) { accum = 0.0 ; accum += * ( Cs ++ ) * rtX . gly5v3vhf0
[ 0 ] ; accum += * ( Cs ++ ) * rtX . gly5v3vhf0 [ 1 ] ; accum += * ( Cs ++ )
* rtX . gly5v3vhf0 [ 2 ] ; accum += * ( Ds ++ ) * rtP . SwitchCurrents_Value
[ 0 ] ; accum += * ( Ds ++ ) * rtP . SwitchCurrents_Value [ 1 ] ; accum += *
( Ds ++ ) * rtP . SwitchCurrents_Value [ 2 ] ; accum += * ( Ds ++ ) * rtP .
DC_Value ; accum += * ( Ds ++ ) * rtP . qqq_Value ; y0 [ i1 ] = accum *
Chopper [ i1 ] ; } } } rtB . pyo3wwpxms [ 0 ] = ( real_T ) switch_status [ 0
] ; rtB . pyo3wwpxms [ 1 ] = ( real_T ) switch_status [ 1 ] ; rtB .
pyo3wwpxms [ 2 ] = ( real_T ) switch_status [ 2 ] ; } rtB . oqgrepj2dt = rtP
. donotdeletethisgain_Gain * rtB . f0igiyewke [ 3 ] ; rtB . gutoyn20ae = rtP
. donotdeletethisgain_Gain_nwj215l5x1 * rtB . f0igiyewke [ 8 ] ; rtB .
klj4h5lmub = rtP . donotdeletethisgain_Gain_cswjbtqcc2 * rtB . f0igiyewke [ 7
] ; rtB . dt4znznhaw = rtP . donotdeletethisgain_Gain_dojjjvjkoc * rtB .
f0igiyewke [ 6 ] ; rtB . kepupsvrsb = rtP .
donotdeletethisgain_Gain_kygonnkuyn * rtB . f0igiyewke [ 5 ] ; rtB .
eazp0m5pkr = rtP . donotdeletethisgain_Gain_nzgfaco2hh * rtB . f0igiyewke [ 4
] ; if ( ssIsMajorTimeStep ( rtS ) ) { rtDW . e5tlynbqxl = ( rtB . pyo3wwpxms
[ 0 ] >= rtP . Switch_Threshold ) ; } if ( rtDW . e5tlynbqxl ) { rtB .
bllluxsxpt = rtP . Rsw_Gain * rtB . f0igiyewke [ 0 ] ; } if ( ssIsSampleHit (
rtS , 2 , 0 ) ) { taskTimeV = ssGetTaskTime ( rtS , 2 ) ; tNextAdjusted = (
real_T ) ssGetTNextWasAdjusted ( rtS , 2 ) ; if ( tNextAdjusted != 0.0 ) {
rtDW . mmjmjzwnyy = _ssGetVarNextHitTime ( rtS , 0 ) ; } if ( rtDW .
gvexmenpy3 != 0 ) { rtDW . gvexmenpy3 = 0 ; if ( taskTimeV >= rtP .
PulseGenerator_PhaseDelay ) { tNextAdjusted = ( taskTimeV - rtP .
PulseGenerator_PhaseDelay ) / rtP . PulseGenerator_Period ; numCycles = (
uint32_T ) ( int32_T ) muDoubleScalarFloor ( tNextAdjusted ) ; if (
muDoubleScalarAbs ( ( real_T ) ( numCycles + 1U ) - tNextAdjusted ) <
DBL_EPSILON * tNextAdjusted ) { numCycles ++ ; } rtDW . pjxhqhg4rm = (
int32_T ) numCycles ; tNextAdjusted = ( ( real_T ) numCycles * rtP .
PulseGenerator_Period + rtP . PulseGenerator_PhaseDelay ) + rtP .
PulseGenerator_Duty * rtP . PulseGenerator_Period / 100.0 ; if ( taskTimeV <
tNextAdjusted ) { rtDW . cr3bkgymc4 = 1 ; rtDW . mmjmjzwnyy = tNextAdjusted ;
} else { rtDW . cr3bkgymc4 = 0 ; rtDW . mmjmjzwnyy = ( real_T ) ( numCycles +
1U ) * rtP . PulseGenerator_Period + rtP . PulseGenerator_PhaseDelay ; } }
else { rtDW . pjxhqhg4rm = rtP . PulseGenerator_PhaseDelay != 0.0 ? - 1 : 0 ;
rtDW . cr3bkgymc4 = 0 ; rtDW . mmjmjzwnyy = rtP . PulseGenerator_PhaseDelay ;
} } else { if ( rtDW . mmjmjzwnyy <= taskTimeV ) { if ( rtDW . cr3bkgymc4 ==
1 ) { rtDW . cr3bkgymc4 = 0 ; rtDW . mmjmjzwnyy = ( real_T ) ( rtDW .
pjxhqhg4rm + 1 ) * rtP . PulseGenerator_Period + rtP .
PulseGenerator_PhaseDelay ; } else { rtDW . pjxhqhg4rm ++ ; rtDW . cr3bkgymc4
= 1 ; rtDW . mmjmjzwnyy = ( rtP . PulseGenerator_Duty * rtP .
PulseGenerator_Period * 0.01 + ( real_T ) rtDW . pjxhqhg4rm * rtP .
PulseGenerator_Period ) + rtP . PulseGenerator_PhaseDelay ; } } }
_ssSetVarNextHitTime ( rtS , 0 , rtDW . mmjmjzwnyy ) ; if ( rtDW . cr3bkgymc4
== 1 ) { rtB . fyurugfk4w = rtP . PulseGenerator_Amp ; } else { rtB .
fyurugfk4w = 0.0 ; } } if ( ssIsSampleHit ( rtS , 1 , 0 ) ) { rtB .
akklwdtl5y = rtB . fyurugfk4w ; } if ( ssIsMajorTimeStep ( rtS ) ) { rtDW .
ebsgw1yk0e = ( rtB . pyo3wwpxms [ 2 ] >= rtP . Switch_Threshold_dxdcq4baff )
; } if ( rtDW . ebsgw1yk0e ) { rtB . drai2a1gxf = rtP . Gain_Gain_gd2kmoezzt
* rtB . f0igiyewke [ 2 ] ; rtB . camij3ofwr = rtB . drai2a1gxf ; } else { rtB
. camij3ofwr = rtP . u_Value_lwcdp54r1n ; } if ( ssIsMajorTimeStep ( rtS ) )
{ rtDW . a1wyp2dlpx = rtB . camij3ofwr >= rtP . Saturation_UpperSat ? 1 : rtB
. camij3ofwr > rtP . Saturation_LowerSat ? 0 : - 1 ; } if ( ssIsMajorTimeStep
( rtS ) ) { rtDW . aixuzu05dv = ( rtB . pyo3wwpxms [ 1 ] >= rtP .
Switch_Threshold_if4g4kiuou ) ; } if ( rtDW . aixuzu05dv ) { rtB . ds1fiffmqm
= rtP . Gain_Gain * rtB . f0igiyewke [ 1 ] ; rtB . fp02uaedgj = rtB .
ds1fiffmqm ; } else { rtB . fp02uaedgj = rtP . u_Value_fainyvkhzn ; } if (
ssIsMajorTimeStep ( rtS ) ) { rtDW . kmdxotwjss = rtB . fp02uaedgj >= rtP .
Saturation_UpperSat_gc5lhemllc ? 1 : rtB . fp02uaedgj > rtP .
Saturation_LowerSat_kulpjsxrrj ? 0 : - 1 ; } UNUSED_PARAMETER ( tid ) ; }
void MdlUpdate ( int_T tid ) { { int_T * gState = ( int_T * ) rtDW .
evxxlzsqhp . G_STATE ; * ( gState ++ ) = ( int_T ) rtB . akklwdtl5y ; * (
gState ++ ) = ( int_T ) 0.0 ; * ( gState ++ ) = ( int_T ) 0.0 ; }
UNUSED_PARAMETER ( tid ) ; } void MdlDerivatives ( void ) { { const real_T *
As = ( real_T * ) rtDW . evxxlzsqhp . AS ; const real_T * Bs = ( real_T * )
rtDW . evxxlzsqhp . BS ; real_T accum ; accum = 0.0 ; accum += * ( As ++ ) *
rtX . gly5v3vhf0 [ 0 ] ; accum += * ( As ++ ) * rtX . gly5v3vhf0 [ 1 ] ;
accum += * ( As ++ ) * rtX . gly5v3vhf0 [ 2 ] ; accum += * ( Bs ++ ) * rtP .
SwitchCurrents_Value [ 0 ] ; accum += * ( Bs ++ ) * rtP .
SwitchCurrents_Value [ 1 ] ; accum += * ( Bs ++ ) * rtP .
SwitchCurrents_Value [ 2 ] ; accum += * ( Bs ++ ) * rtP . DC_Value ; accum +=
* ( Bs ++ ) * rtP . qqq_Value ; ( ( XDot * ) ssGetdX ( rtS ) ) -> gly5v3vhf0
[ 0 ] = accum ; accum = 0.0 ; accum += * ( As ++ ) * rtX . gly5v3vhf0 [ 0 ] ;
accum += * ( As ++ ) * rtX . gly5v3vhf0 [ 1 ] ; accum += * ( As ++ ) * rtX .
gly5v3vhf0 [ 2 ] ; accum += * ( Bs ++ ) * rtP . SwitchCurrents_Value [ 0 ] ;
accum += * ( Bs ++ ) * rtP . SwitchCurrents_Value [ 1 ] ; accum += * ( Bs ++
) * rtP . SwitchCurrents_Value [ 2 ] ; accum += * ( Bs ++ ) * rtP . DC_Value
; accum += * ( Bs ++ ) * rtP . qqq_Value ; ( ( XDot * ) ssGetdX ( rtS ) ) ->
gly5v3vhf0 [ 1 ] = accum ; accum = 0.0 ; accum += * ( As ++ ) * rtX .
gly5v3vhf0 [ 0 ] ; accum += * ( As ++ ) * rtX . gly5v3vhf0 [ 1 ] ; accum += *
( As ++ ) * rtX . gly5v3vhf0 [ 2 ] ; accum += * ( Bs ++ ) * rtP .
SwitchCurrents_Value [ 0 ] ; accum += * ( Bs ++ ) * rtP .
SwitchCurrents_Value [ 1 ] ; accum += * ( Bs ++ ) * rtP .
SwitchCurrents_Value [ 2 ] ; accum += * ( Bs ++ ) * rtP . DC_Value ; accum +=
* ( Bs ++ ) * rtP . qqq_Value ; ( ( XDot * ) ssGetdX ( rtS ) ) -> gly5v3vhf0
[ 2 ] = accum ; } } void MdlProjection ( void ) { } void MdlZeroCrossings (
void ) { ZCV * _rtZCSV ; _rtZCSV = ( ( ZCV * ) ssGetSolverZcSignalVector (
rtS ) ) ; { int_T * switchTypes = ( int_T * ) rtDW . evxxlzsqhp .
SWITCH_TYPES ; ( ( ZCV * ) ssGetSolverZcSignalVector ( rtS ) ) -> copdatdktn
[ 2 ] = rtB . f0igiyewke [ 1 ] ; ( ( ZCV * ) ssGetSolverZcSignalVector ( rtS
) ) -> copdatdktn [ 3 ] = rtB . f0igiyewke [ 1 ] ; ( ( ZCV * )
ssGetSolverZcSignalVector ( rtS ) ) -> copdatdktn [ 4 ] = rtB . f0igiyewke [
2 ] ; ( ( ZCV * ) ssGetSolverZcSignalVector ( rtS ) ) -> copdatdktn [ 5 ] =
rtB . f0igiyewke [ 2 ] ; } _rtZCSV -> fqhbznlsw4 = rtB . pyo3wwpxms [ 0 ] -
rtP . Switch_Threshold ; _rtZCSV -> j0ucwgqnoz = rtB . pyo3wwpxms [ 2 ] - rtP
. Switch_Threshold_dxdcq4baff ; _rtZCSV -> gawihiv1ix = rtB . camij3ofwr -
rtP . Saturation_UpperSat ; _rtZCSV -> f4es0krnsz = rtB . camij3ofwr - rtP .
Saturation_LowerSat ; _rtZCSV -> ju4ecf12ms = rtB . pyo3wwpxms [ 1 ] - rtP .
Switch_Threshold_if4g4kiuou ; _rtZCSV -> flr2hrbkdv = rtB . fp02uaedgj - rtP
. Saturation_UpperSat_gc5lhemllc ; _rtZCSV -> bvupsdlqui = rtB . fp02uaedgj -
rtP . Saturation_LowerSat_kulpjsxrrj ; } void MdlTerminate ( void ) { { free
( rtDW . evxxlzsqhp . AS ) ; free ( rtDW . evxxlzsqhp . BS ) ; free ( rtDW .
evxxlzsqhp . CS ) ; free ( rtDW . evxxlzsqhp . DS ) ; free ( rtDW .
evxxlzsqhp . DX_COL ) ; free ( rtDW . evxxlzsqhp . BD_COL ) ; free ( rtDW .
evxxlzsqhp . TMP1 ) ; free ( rtDW . evxxlzsqhp . TMP2 ) ; free ( rtDW .
evxxlzsqhp . CHOPPER ) ; free ( rtDW . evxxlzsqhp . G_STATE ) ; free ( rtDW .
evxxlzsqhp . SWITCH_STATUS ) ; free ( rtDW . evxxlzsqhp . SW_CHG ) ; free (
rtDW . evxxlzsqhp . SWITCH_STATUS_INIT ) ; } } void MdlInitializeSizes ( void
) { ssSetNumContStates ( rtS , 3 ) ; ssSetNumY ( rtS , 0 ) ; ssSetNumU ( rtS
, 0 ) ; ssSetDirectFeedThrough ( rtS , 0 ) ; ssSetNumSampleTimes ( rtS , 3 )
; ssSetNumBlocks ( rtS , 68 ) ; ssSetNumBlockIO ( rtS , 15 ) ;
ssSetNumBlockParams ( rtS , 28 ) ; } void MdlInitializeSampleTimes ( void ) {
ssSetSampleTime ( rtS , 0 , 0.0 ) ; ssSetSampleTime ( rtS , 1 , 0.0 ) ;
ssSetSampleTime ( rtS , 2 , - 2.0 ) ; ssSetOffsetTime ( rtS , 0 , 0.0 ) ;
ssSetOffsetTime ( rtS , 1 , 1.0 ) ; ssSetOffsetTime ( rtS , 2 , 0.0 ) ; }
void raccel_set_checksum ( SimStruct * rtS ) { ssSetChecksumVal ( rtS , 0 ,
610294073U ) ; ssSetChecksumVal ( rtS , 1 , 1961652090U ) ; ssSetChecksumVal
( rtS , 2 , 978557847U ) ; ssSetChecksumVal ( rtS , 3 , 1799125910U ) ; }
SimStruct * raccel_register_model ( void ) { static struct _ssMdlInfo mdlInfo
; ( void ) memset ( ( char * ) rtS , 0 , sizeof ( SimStruct ) ) ; ( void )
memset ( ( char * ) & mdlInfo , 0 , sizeof ( struct _ssMdlInfo ) ) ;
ssSetMdlInfoPtr ( rtS , & mdlInfo ) ; { static time_T mdlPeriod [
NSAMPLE_TIMES ] ; static time_T mdlOffset [ NSAMPLE_TIMES ] ; static time_T
mdlTaskTimes [ NSAMPLE_TIMES ] ; static int_T mdlTsMap [ NSAMPLE_TIMES ] ;
static int_T mdlSampleHits [ NSAMPLE_TIMES ] ; static boolean_T
mdlTNextWasAdjustedPtr [ NSAMPLE_TIMES ] ; static int_T mdlPerTaskSampleHits
[ NSAMPLE_TIMES * NSAMPLE_TIMES ] ; static time_T mdlTimeOfNextSampleHit [
NSAMPLE_TIMES ] ; { int_T i ; for ( i = 0 ; i < NSAMPLE_TIMES ; i ++ ) {
mdlPeriod [ i ] = 0.0 ; mdlOffset [ i ] = 0.0 ; mdlTaskTimes [ i ] = 0.0 ;
mdlTsMap [ i ] = i ; mdlSampleHits [ i ] = 1 ; } } ssSetSampleTimePtr ( rtS ,
& mdlPeriod [ 0 ] ) ; ssSetOffsetTimePtr ( rtS , & mdlOffset [ 0 ] ) ;
ssSetSampleTimeTaskIDPtr ( rtS , & mdlTsMap [ 0 ] ) ; ssSetTPtr ( rtS , &
mdlTaskTimes [ 0 ] ) ; ssSetSampleHitPtr ( rtS , & mdlSampleHits [ 0 ] ) ;
ssSetTNextWasAdjustedPtr ( rtS , & mdlTNextWasAdjustedPtr [ 0 ] ) ;
ssSetPerTaskSampleHitsPtr ( rtS , & mdlPerTaskSampleHits [ 0 ] ) ;
ssSetTimeOfNextSampleHitPtr ( rtS , & mdlTimeOfNextSampleHit [ 0 ] ) ; }
ssSetSolverMode ( rtS , SOLVER_MODE_SINGLETASKING ) ; { ssSetBlockIO ( rtS ,
( ( void * ) & rtB ) ) ; ( void ) memset ( ( ( void * ) & rtB ) , 0 , sizeof
( B ) ) ; } ssSetDefaultParam ( rtS , ( real_T * ) & rtP ) ; { real_T * x = (
real_T * ) & rtX ; ssSetContStates ( rtS , x ) ; ( void ) memset ( ( void * )
x , 0 , sizeof ( X ) ) ; } { void * dwork = ( void * ) & rtDW ;
ssSetRootDWork ( rtS , dwork ) ; ( void ) memset ( dwork , 0 , sizeof ( DW )
) ; } { static DataTypeTransInfo dtInfo ; ( void ) memset ( ( char_T * ) &
dtInfo , 0 , sizeof ( dtInfo ) ) ; ssSetModelMappingInfo ( rtS , & dtInfo ) ;
dtInfo . numDataTypes = 14 ; dtInfo . dataTypeSizes = & rtDataTypeSizes [ 0 ]
; dtInfo . dataTypeNames = & rtDataTypeNames [ 0 ] ; dtInfo . B = &
rtBTransTable ; dtInfo . P = & rtPTransTable ; } ssSetRootSS ( rtS , rtS ) ;
ssSetVersion ( rtS , SIMSTRUCT_VERSION_LEVEL2 ) ; ssSetModelName ( rtS ,
"Mohamed_Alaswed_Buck" ) ; ssSetPath ( rtS , "Mohamed_Alaswed_Buck" ) ;
ssSetTStart ( rtS , 0.0 ) ; ssSetTFinal ( rtS , 10.0 ) ; { static RTWLogInfo
rt_DataLoggingInfo ; ssSetRTWLogInfo ( rtS , & rt_DataLoggingInfo ) ; } { {
static int_T rt_LoggedStateWidths [ ] = { 3 } ; static int_T
rt_LoggedStateNumDimensions [ ] = { 1 } ; static int_T
rt_LoggedStateDimensions [ ] = { 3 } ; static boolean_T
rt_LoggedStateIsVarDims [ ] = { 0 } ; static BuiltInDTypeId
rt_LoggedStateDataTypeIds [ ] = { SS_DOUBLE } ; static int_T
rt_LoggedStateComplexSignals [ ] = { 0 } ; static const char_T *
rt_LoggedStateLabels [ ] = { "CSTATE" } ; static const char_T *
rt_LoggedStateBlockNames [ ] = {
"Mohamed_Alaswed_Buck/powergui/EquivalentModel1/State-Space" } ; static const
char_T * rt_LoggedStateNames [ ] = { "" } ; static boolean_T
rt_LoggedStateCrossMdlRef [ ] = { 0 } ; static RTWLogDataTypeConvert
rt_RTWLogDataTypeConvert [ ] = { { 0 , SS_DOUBLE , SS_DOUBLE , 0 , 0 , 0 ,
1.0 , 0 , 0.0 } } ; static RTWLogSignalInfo rt_LoggedStateSignalInfo = { 1 ,
rt_LoggedStateWidths , rt_LoggedStateNumDimensions , rt_LoggedStateDimensions
, rt_LoggedStateIsVarDims , ( NULL ) , ( NULL ) , rt_LoggedStateDataTypeIds ,
rt_LoggedStateComplexSignals , ( NULL ) , { rt_LoggedStateLabels } , ( NULL )
, ( NULL ) , ( NULL ) , { rt_LoggedStateBlockNames } , { rt_LoggedStateNames
} , rt_LoggedStateCrossMdlRef , rt_RTWLogDataTypeConvert } ; static void *
rt_LoggedStateSignalPtrs [ 1 ] ; rtliSetLogXSignalPtrs ( ssGetRTWLogInfo (
rtS ) , ( LogSignalPtrsType ) rt_LoggedStateSignalPtrs ) ;
rtliSetLogXSignalInfo ( ssGetRTWLogInfo ( rtS ) , & rt_LoggedStateSignalInfo
) ; rt_LoggedStateSignalPtrs [ 0 ] = ( void * ) & rtX . gly5v3vhf0 [ 0 ] ; }
rtliSetLogT ( ssGetRTWLogInfo ( rtS ) , "tout" ) ; rtliSetLogX (
ssGetRTWLogInfo ( rtS ) , "tmp_raccel_xout" ) ; rtliSetLogXFinal (
ssGetRTWLogInfo ( rtS ) , "xFinal" ) ; rtliSetSigLog ( ssGetRTWLogInfo ( rtS
) , "" ) ; rtliSetLogVarNameModifier ( ssGetRTWLogInfo ( rtS ) , "none" ) ;
rtliSetLogFormat ( ssGetRTWLogInfo ( rtS ) , 0 ) ; rtliSetLogMaxRows (
ssGetRTWLogInfo ( rtS ) , 1000 ) ; rtliSetLogDecimation ( ssGetRTWLogInfo (
rtS ) , 1 ) ; rtliSetLogY ( ssGetRTWLogInfo ( rtS ) , "" ) ;
rtliSetLogYSignalInfo ( ssGetRTWLogInfo ( rtS ) , ( NULL ) ) ;
rtliSetLogYSignalPtrs ( ssGetRTWLogInfo ( rtS ) , ( NULL ) ) ; } { static
struct _ssStatesInfo2 statesInfo2 ; ssSetStatesInfo2 ( rtS , & statesInfo2 )
; } { static ssSolverInfo slvrInfo ; static boolean_T contStatesDisabled [ 3
] ; static real_T absTol [ 3 ] = { 1.0E-6 , 1.0E-6 , 1.0E-6 } ; static
uint8_T absTolControl [ 3 ] = { 0U , 0U , 0U } ; static uint8_T zcAttributes
[ 13 ] = { ( ZC_EVENT_ALL ) , ( ZC_EVENT_ALL ) , ( ZC_EVENT_ALL ) , (
ZC_EVENT_ALL ) , ( ZC_EVENT_ALL ) , ( ZC_EVENT_ALL ) , ( ZC_EVENT_ALL ) , (
ZC_EVENT_ALL ) , ( ZC_EVENT_ALL ) , ( ZC_EVENT_ALL ) , ( ZC_EVENT_ALL ) , (
ZC_EVENT_ALL ) , ( ZC_EVENT_ALL ) } ; ssSetSolverRelTol ( rtS , 0.001 ) ;
ssSetStepSize ( rtS , 0.0 ) ; ssSetMinStepSize ( rtS , 0.0 ) ;
ssSetMaxNumMinSteps ( rtS , - 1 ) ; ssSetMinStepViolatedError ( rtS , 0 ) ;
ssSetMaxStepSize ( rtS , 0.2 ) ; ssSetSolverMaxOrder ( rtS , - 1 ) ;
ssSetSolverRefineFactor ( rtS , 1 ) ; ssSetOutputTimes ( rtS , ( NULL ) ) ;
ssSetNumOutputTimes ( rtS , 0 ) ; ssSetOutputTimesOnly ( rtS , 0 ) ;
ssSetOutputTimesIndex ( rtS , 0 ) ; ssSetZCCacheNeedsReset ( rtS , 1 ) ;
ssSetDerivCacheNeedsReset ( rtS , 0 ) ; ssSetNumNonContDerivSigInfos ( rtS ,
0 ) ; ssSetNonContDerivSigInfos ( rtS , ( NULL ) ) ; ssSetSolverInfo ( rtS ,
& slvrInfo ) ; ssSetSolverName ( rtS , "ode45" ) ; ssSetVariableStepSolver (
rtS , 1 ) ; ssSetSolverConsistencyChecking ( rtS , 0 ) ;
ssSetSolverAdaptiveZcDetection ( rtS , 0 ) ; ssSetSolverRobustResetMethod (
rtS , 0 ) ; ssSetAbsTolVector ( rtS , absTol ) ; ssSetAbsTolControlVector (
rtS , absTolControl ) ; ssSetSolverAbsTol_Obsolete ( rtS , absTol ) ;
ssSetSolverAbsTolControl_Obsolete ( rtS , absTolControl ) ;
ssSetSolverStateProjection ( rtS , 0 ) ; ssSetSolverMassMatrixType ( rtS , (
ssMatrixType ) 0 ) ; ssSetSolverMassMatrixNzMax ( rtS , 0 ) ;
ssSetModelOutputs ( rtS , MdlOutputs ) ; ssSetModelLogData ( rtS ,
rt_UpdateTXYLogVars ) ; ssSetModelUpdate ( rtS , MdlUpdate ) ;
ssSetModelDerivatives ( rtS , MdlDerivatives ) ; ssSetSolverZcSignalAttrib (
rtS , zcAttributes ) ; ssSetSolverNumZcSignals ( rtS , 13 ) ;
ssSetModelZeroCrossings ( rtS , MdlZeroCrossings ) ;
ssSetSolverConsecutiveZCsStepRelTol ( rtS , 2.8421709430404007E-13 ) ;
ssSetSolverMaxConsecutiveZCs ( rtS , 1000 ) ; ssSetSolverConsecutiveZCsError
( rtS , 2 ) ; ssSetSolverMaskedZcDiagnostic ( rtS , 1 ) ;
ssSetSolverIgnoredZcDiagnostic ( rtS , 1 ) ; ssSetSolverMaxConsecutiveMinStep
( rtS , 1 ) ; ssSetSolverShapePreserveControl ( rtS , 2 ) ; ssSetTNextTid (
rtS , INT_MIN ) ; ssSetTNext ( rtS , rtMinusInf ) ; ssSetSolverNeedsReset (
rtS ) ; ssSetNumNonsampledZCs ( rtS , 13 ) ; ssSetContStateDisabled ( rtS ,
contStatesDisabled ) ; ssSetSolverMaxConsecutiveMinStep ( rtS , 1 ) ; }
ssSetChecksumVal ( rtS , 0 , 610294073U ) ; ssSetChecksumVal ( rtS , 1 ,
1961652090U ) ; ssSetChecksumVal ( rtS , 2 , 978557847U ) ; ssSetChecksumVal
( rtS , 3 , 1799125910U ) ; { static const sysRanDType rtAlwaysEnabled =
SUBSYS_RAN_BC_ENABLE ; static RTWExtModeInfo rt_ExtModeInfo ; static const
sysRanDType * systemRan [ 4 ] ; ssSetRTWExtModeInfo ( rtS , & rt_ExtModeInfo
) ; rteiSetSubSystemActiveVectorAddresses ( & rt_ExtModeInfo , systemRan ) ;
systemRan [ 0 ] = & rtAlwaysEnabled ; systemRan [ 1 ] = & rtAlwaysEnabled ;
systemRan [ 2 ] = & rtAlwaysEnabled ; systemRan [ 3 ] = & rtAlwaysEnabled ;
rteiSetModelMappingInfoPtr ( ssGetRTWExtModeInfo ( rtS ) , &
ssGetModelMappingInfo ( rtS ) ) ; rteiSetChecksumsPtr ( ssGetRTWExtModeInfo (
rtS ) , ssGetChecksums ( rtS ) ) ; rteiSetTPtr ( ssGetRTWExtModeInfo ( rtS )
, ssGetTPtr ( rtS ) ) ; } rtP . Saturation_UpperSat = rtInf ; rtP .
Saturation_UpperSat_gc5lhemllc = rtInf ; return rtS ; }
