Exemplo n.º 1
0
hldvdzyyjm * localDW ) { localDW -> agffdh025d = false ; } void cqabclhqip (
SimStruct * const S , boolean_T etkm24oeau , real_T didof4byc4 , fzgld4ioxx *
localB , hldvdzyyjm * localDW , nneyi35s1a * localP , jppzrcodeg * localX ,
mgleimd2gn * localXdis ) { real_T hdawcmvty5 ; if ( ssIsSampleHit ( S , 1 , 0
) && ssIsMajorTimeStep ( S ) ) { if ( etkm24oeau ) { if ( ! localDW ->
agffdh025d ) { if ( ssGetTaskTime ( S , 1 ) != ssGetTStart ( S ) ) {
ssSetSolverNeedsReset ( S ) ; } localXdis -> g4hwiaob0z = 0 ; localDW ->
agffdh025d = true ; } } else { if ( localDW -> agffdh025d ) {
ssSetSolverNeedsReset ( S ) ; localXdis -> g4hwiaob0z = 1 ; gjooyfv3bl (
localDW ) ; } } } if ( localDW -> agffdh025d ) { hdawcmvty5 = ssGetT ( S ) ;
localB -> piz2wxjgln = localX -> g4hwiaob0z ; { real_T * * uBuffer = ( real_T
* * ) & localDW -> mapbuxhz55 . TUbufferPtrs [ 0 ] ; real_T * * tBuffer = (
real_T * * ) & localDW -> mapbuxhz55 . TUbufferPtrs [ 1 ] ; real_T simTime =
ssGetT ( S ) ; real_T tMinusDelay = simTime - localP -> P_2 ; localB ->
c1a15sku2w = Deadbeat_CUK_acc_rt_TDelayInterpolate ( tMinusDelay , 0.0 , *
tBuffer , * uBuffer , localDW -> phyjdg23m0 . CircularBufSize , & localDW ->
phyjdg23m0 . Last , localDW -> phyjdg23m0 . Tail , localDW -> phyjdg23m0 .
Head , localP -> P_3 , 0 , ( boolean_T ) ( ssIsMinorTimeStep ( S ) && (
ssGetTimeOfLastOutput ( S ) == ssGetT ( S ) ) ) ) ; } if ( ssIsSampleHit ( S
, 1 , 0 ) ) { localB -> cs4dg4krvc = localP -> P_4 ; localB -> lbagd2xbpx =
localDW -> maqntnbpoj ; } if ( hdawcmvty5 >= localB -> cs4dg4krvc ) { localB
-> a51b5puwm1 = localB -> piz2wxjgln - localB -> c1a15sku2w ; localB ->
ekk3k2wrwu = localP -> P_0 * localB -> a51b5puwm1 ; localB -> f3hneacniz =
localB -> ekk3k2wrwu ; } else { localB -> f3hneacniz = localB -> lbagd2xbpx ;
} localB -> ndc0pt2kls = didof4byc4 * didof4byc4 ; if ( ssIsMajorTimeStep ( S
) ) { localDW -> psx5wvplz4 = localB -> f3hneacniz >= localP -> P_6 ? 1 :
localB -> f3hneacniz > localP -> P_7 ? 0 : - 1 ; srUpdateBC ( localDW ->
igwl1d5vuc ) ; } } } void hdynn0hvxj ( SimStruct * const S , fzgld4ioxx *
Exemplo n.º 2
0
static void mdlStart(SimStruct *S)
{
    ssSetRWorkValue(S,0,ssGetTStart(S));
    

   real_T t_pre= getTime();
   real_T t_pre0=t_pre;
   ssSetRWorkValue(S,1,t_pre);
   ssSetRWorkValue(S,2,t_pre0);
   ssSetRWorkValue(S,3,0.02);
}
Exemplo n.º 3
0
localDW ) { localDW -> nej2n2fr4t = false ; } void bemu4fk2sq ( SimStruct *
const S , boolean_T fuz4opuchm , real_T nkqzvcukuv , bkp1n1bm33 * localB ,
mdhkgmfpbe * localDW , mvw1gbh0c1 * localP , pfdaqg4dlv * localXdis ) { if (
ssIsSampleHit ( S , 1 , 0 ) && ssIsMajorTimeStep ( S ) ) { if ( fuz4opuchm )
{ if ( ! localDW -> nej2n2fr4t ) { if ( ssGetTaskTime ( S , 1 ) !=
ssGetTStart ( S ) ) { ssSetSolverNeedsReset ( S ) ; } ( void ) memset ( & (
localXdis -> fq23fwubtb ) , 0 , 2 * sizeof ( boolean_T ) ) ; localDW ->
nej2n2fr4t = true ; } } else { if ( localDW -> nej2n2fr4t ) {
ssSetSolverNeedsReset ( S ) ; ( void ) memset ( & ( localXdis -> fq23fwubtb )
, 1 , 2 * sizeof ( boolean_T ) ) ; mctqnytrkq ( localDW ) ; } } } if (
localDW -> nej2n2fr4t ) { localB -> obmjfhqv1x = ( muDoubleScalarSin ( localP
-> P_4 * ssGetTaskTime ( S , 0 ) + localP -> P_5 ) * localP -> P_2 + localP
-> P_3 ) * nkqzvcukuv ; localB -> n024o4o5og = ( muDoubleScalarSin ( localP
-> P_8 * ssGetTaskTime ( S , 0 ) + localP -> P_9 ) * localP -> P_6 + localP
-> P_7 ) * nkqzvcukuv ; if ( ssIsMajorTimeStep ( S ) ) { srUpdateBC ( localDW
-> mdukihclqs ) ; } } } void jreinmfd0u ( bkp1n1bm33 * localB , mdhkgmfpbe *
Exemplo n.º 4
0
void ) { } static void mdlOutputs ( SimStruct * S , int_T tid ) { real_T
jzxguy1xyo ; ZCEventType zcEvent ; boolean_T is1galx1wr ; real_T iden3vpls2 ;
real_T kewj0jjgdw ; real_T c3hti1p3uf ; int8_T rtPrevAction ; int8_T rtAction
; nmsgyp54ig * _rtB ; bbqvqz25ov * _rtP ; n2g2llwf21 * _rtX ; aa2ep02qn5 *
_rtZCE ; pklu3vjy1t * _rtDW ; _rtDW = ( ( pklu3vjy1t * ) ssGetRootDWork ( S )
) ; _rtZCE = ( ( aa2ep02qn5 * ) _ssGetPrevZCSigState ( S ) ) ; _rtX = ( (
n2g2llwf21 * ) ssGetContStates ( S ) ) ; _rtP = ( ( bbqvqz25ov * )
ssGetModelRtp ( S ) ) ; _rtB = ( ( nmsgyp54ig * ) _ssGetModelBlockIO ( S ) )
; if ( ssIsSampleHit ( S , 4 , 0 ) ) { _rtB -> jbbkv4upvi = _rtDW ->
idaicj53o4 ; } if ( ssIsSampleHit ( S , 1 , 0 ) ) { is1galx1wr = ( _rtB ->
jbbkv4upvi != c22ngqieus ( S ) -> pactsh03am ) ; } jzxguy1xyo = ssGetT ( S )
; if ( ssIsSampleHit ( S , 1 , 0 ) ) { _rtB -> oojsaunz11 = _rtP -> P_5 ;
_rtB -> fmra2cutsa = _rtP -> P_6 ; } _rtB -> fs1ofsmvy2 = muDoubleScalarRem (
jzxguy1xyo + _rtB -> oojsaunz11 , _rtB -> fmra2cutsa ) * _rtP -> P_7 ; _rtB
-> kdd430tca4 = ( ( 2.0 * _rtB -> fs1ofsmvy2 - 1.0 ) + 1.0 ) * 0.5 ; if (
ssIsSampleHit ( S , 1 , 0 ) ) { if ( ssIsMajorTimeStep ( S ) ) { _rtDW ->
fiaf5yjt4n = ( _rtB -> jbbkv4upvi >= _rtB -> kdd430tca4 ) ; } _rtB ->
bonoh3t2uf = ( is1galx1wr && _rtDW -> fiaf5yjt4n ) ; } _rtB -> puvw0myvhu [ 0
] = _rtB -> bonoh3t2uf ; _rtB -> puvw0myvhu [ 1 ] = 0.0 ; _rtB -> puvw0myvhu
[ 2 ] = 0.0 ; _rtDW -> lhiprm3wjz [ 0 ] = ! ( _rtB -> puvw0myvhu [ 0 ] ==
_rtDW -> lhiprm3wjz [ 1 ] ) ; _rtDW -> lhiprm3wjz [ 1 ] = _rtB -> puvw0myvhu
[ 0 ] ; _rtB -> puvw0myvhu [ 3 ] = _rtDW -> lhiprm3wjz [ 0 ] ; if (
ssIsSampleHit ( S , 2 , 0 ) ) { ssCallAccelRunBlock ( S , 9 , 15 ,
SS_CALL_MDL_OUTPUTS ) ; ssCallAccelRunBlock ( S , 9 , 16 ,
SS_CALL_MDL_OUTPUTS ) ; } if ( ssIsSampleHit ( S , 4 , 0 ) ) { _rtB ->
ni0skqgprw = _rtB -> mgrpxotnda [ 2 ] ; } if ( ssIsSampleHit ( S , 2 , 0 ) )
{ ssCallAccelRunBlock ( S , 9 , 20 , SS_CALL_MDL_OUTPUTS ) ; } if (
ssIsSampleHit ( S , 1 , 0 ) ) { zcEvent = rt_ZCFcn ( ANY_ZERO_CROSSING , &
_rtZCE -> mpe2yble25 , ( _rtB -> fs1ofsmvy2 - _rtP -> P_11 ) ) ; if ( _rtDW
-> oosqu0tl1h == 0 ) { if ( zcEvent != NO_ZCEVENT ) { _rtB -> dgvfzxjzqp = !
( _rtB -> dgvfzxjzqp != 0.0 ) ; _rtDW -> oosqu0tl1h = 1 ; } else if ( _rtB ->
dgvfzxjzqp == 1.0 ) { if ( _rtB -> fs1ofsmvy2 != _rtP -> P_11 ) { _rtB ->
dgvfzxjzqp = 0.0 ; } } else { if ( _rtB -> fs1ofsmvy2 == _rtP -> P_11 ) {
_rtB -> dgvfzxjzqp = 1.0 ; } } } else { if ( _rtB -> fs1ofsmvy2 != _rtP ->
P_11 ) { _rtB -> dgvfzxjzqp = 0.0 ; } _rtDW -> oosqu0tl1h = 0 ; } } if (
ssIsSampleHit ( S , 2 , 0 ) ) { ssCallAccelRunBlock ( S , 9 , 23 ,
SS_CALL_MDL_OUTPUTS ) ; ssCallAccelRunBlock ( S , 9 , 33 ,
SS_CALL_MDL_OUTPUTS ) ; iden3vpls2 = _rtP -> P_13 * _rtB -> mgrpxotnda [ 8 ]
; } if ( ssIsSampleHit ( S , 4 , 0 ) ) { _rtB -> gp5orjzg5t = _rtB ->
mgrpxotnda [ 2 ] ; } if ( ssIsSampleHit ( S , 2 , 0 ) ) { kewj0jjgdw = (
iden3vpls2 - _rtB -> gp5orjzg5t ) * _rtB -> nzunlww04y ; } if ( ssIsSampleHit
( S , 4 , 0 ) ) { _rtB -> jw2hkpsksy = _rtB -> gp5orjzg5t * _rtB ->
dvca5kgoqr ; _rtB -> elobzetbdp = _rtB -> mgrpxotnda [ 8 ] ; } if (
ssIsSampleHit ( S , 2 , 0 ) ) { c3hti1p3uf = ( kewj0jjgdw + _rtB ->
jw2hkpsksy ) - _rtB -> elobzetbdp ; if ( ssIsSampleHit ( S , 4 , 0 ) ) { _rtB
-> bc5lqmbcwx = _rtB -> mgrpxotnda [ 9 ] ; } } if ( ssIsSampleHit ( S , 4 , 0
) ) { _rtB -> bpiny53cki = _rtB -> elobzetbdp + _rtB -> bc5lqmbcwx ; } if (
ssIsSampleHit ( S , 2 , 0 ) ) { iden3vpls2 = c3hti1p3uf / _rtB -> bpiny53cki
+ _rtB -> idha0n310x ; if ( iden3vpls2 > _rtP -> P_16 ) { _rtB -> ccrq35nhp3
= _rtP -> P_16 ; } else if ( iden3vpls2 < _rtP -> P_17 ) { _rtB -> ccrq35nhp3
= _rtP -> P_17 ; } else { _rtB -> ccrq35nhp3 = iden3vpls2 ; } } if (
ssIsSampleHit ( S , 4 , 0 ) ) { _rtB -> pvzuuxenvc = _rtB -> ccrq35nhp3 ; }
if ( ssIsSampleHit ( S , 2 , 0 ) ) { _rtB -> ii04l1a0ic = ( _rtB ->
mgrpxotnda [ 9 ] + _rtB -> mgrpxotnda [ 8 ] ) - _rtB -> mgrpxotnda [ 6 ] ;
ssCallAccelRunBlock ( S , 9 , 51 , SS_CALL_MDL_OUTPUTS ) ; rtPrevAction =
_rtDW -> dcumqbbyun ; if ( ssIsMajorTimeStep ( S ) ) { if ( _rtB ->
mgrpxotnda [ 9 ] < 90.199999999999989 ) { rtAction = 0 ; } else { rtAction =
1 ; } _rtDW -> dcumqbbyun = rtAction ; } else { rtAction = _rtDW ->
dcumqbbyun ; } if ( rtPrevAction != rtAction ) { switch ( rtPrevAction ) {
case 0 : ssSetSolverNeedsReset ( S ) ; break ; case 1 : ssSetSolverNeedsReset
( S ) ; break ; case 2 : ssSetSolverNeedsReset ( S ) ; break ; } } switch (
rtAction ) { case 0 : if ( rtAction != rtPrevAction ) { if ( ssGetTaskTime (
S , 2 ) != ssGetTStart ( S ) ) { ssSetSolverNeedsReset ( S ) ; } } _rtB ->
kx5rgsvmx3 = _rtP -> P_0 * _rtB -> mgrpxotnda [ 8 ] ; if ( ssIsMajorTimeStep
( S ) ) { srUpdateBC ( _rtDW -> o5k0zwtbn4 ) ; } break ; case 1 : if (
rtAction != rtPrevAction ) { if ( ssGetTaskTime ( S , 2 ) != ssGetTStart ( S
) ) { ssSetSolverNeedsReset ( S ) ; } } _rtB -> kx5rgsvmx3 = _rtP -> P_1 ; if
( ssIsMajorTimeStep ( S ) ) { srUpdateBC ( _rtDW -> ihoovge3z4 ) ; } break ;
case 2 : if ( rtAction != rtPrevAction ) { if ( ssGetTaskTime ( S , 2 ) !=
ssGetTStart ( S ) ) { ssSetSolverNeedsReset ( S ) ; } } _rtB -> pvzuuxenvc =
_rtP -> P_2 ; if ( ssIsMajorTimeStep ( S ) ) { srUpdateBC ( _rtDW ->
gunoszsdaf ) ; } break ; } } bemu4fk2sq ( S , _rtB -> kwjevd5eqt , 0.0 , &
_rtB -> bemu4fk2sq4 , & _rtDW -> bemu4fk2sq4 , ( mvw1gbh0c1 * ) & _rtP ->
bemu4fk2sq4 , & ( ( npjij2cecc * ) ssGetContStateDisabled ( S ) ) ->
bemu4fk2sq4 ) ; cqabclhqip ( S , _rtB -> donhz1jhkq , 0.0 , & _rtB ->
cqabclhqip4 , & _rtDW -> cqabclhqip4 , ( nneyi35s1a * ) & _rtP -> cqabclhqip4
, & _rtX -> cqabclhqip4 , & ( ( npjij2cecc * ) ssGetContStateDisabled ( S ) )
-> cqabclhqip4 ) ; bemu4fk2sq ( S , _rtB -> jwapqatga5 , 0.0 , & _rtB ->
n1qdzssqu3 , & _rtDW -> n1qdzssqu3 , ( mvw1gbh0c1 * ) & _rtP -> n1qdzssqu3 ,
& ( ( npjij2cecc * ) ssGetContStateDisabled ( S ) ) -> n1qdzssqu3 ) ;
cqabclhqip ( S , _rtB -> p5ierutvgv , 0.0 , & _rtB -> nfugx5ih43 , & _rtDW ->
nfugx5ih43 , ( nneyi35s1a * ) & _rtP -> nfugx5ih43 , & _rtX -> nfugx5ih43 , &
( ( npjij2cecc * ) ssGetContStateDisabled ( S ) ) -> nfugx5ih43 ) ;
UNUSED_PARAMETER ( tid ) ; } static void mdlOutputsTID5 ( SimStruct * S ,
Exemplo n.º 5
0
/* Function: main ==============================================================
 *
 *      Execute model on a generic target such as a workstation.
 */
int_T main(int_T argc, char_T *argv[])
{
    SimStruct  *S                 = NULL;
    boolean_T  calledMdlStart     = FALSE;
    boolean_T  dataLoggingActive  = FALSE;
    boolean_T  initializedExtMode = FALSE;
    const char *result;
    const char *program;
    time_t     now;
    int matFileFormat;
    const char *errorPrefix       = NULL;
    void *parforSchedulerInit     = NULL;

    program = argv[0];
    gblInstalledSigHandlers = FALSE;
    /* No re-defining of data types allowed. */
    if ((sizeof(real_T)   != 8) ||
        (sizeof(real32_T) != 4) ||
        (sizeof(int8_T)   != 1) ||
        (sizeof(uint8_T)  != 1) ||
        (sizeof(int16_T)  != 2) ||
        (sizeof(uint16_T) != 2) ||
        (sizeof(int32_T)  != 4) ||
        (sizeof(uint32_T) != 4) ||
        (sizeof(boolean_T)!= 1)) {
        ERROR_EXIT("Error: %s\n", "Re-defining data types such as REAL_T is not supported by RSIM");
    }

    rt_InitInfAndNaN(sizeof(real_T));


    /* Parse arguments */
    gblErrorStatus = ParseArgs(argc, argv);
    ERROR_EXIT("Error parsing input arguments: %s\n", gblErrorStatus);

    /* Initialize the model */
    S = raccel_register_model();
    ERROR_EXIT("Error during model registration: %s\n", ssGetErrorStatus(S));

    ssClearFirstInitCondCalled(S);
    /* Override StopTime */
    if (gblFinalTimeChanged) ssSetTFinal(S,gblFinalTime);

    MdlInitializeSizes();
    MdlInitializeSampleTimes();

    /* We don't have GOTO_EXIT_IF_ERROR here as engine is not initialized 
       via rsimInitializeEngine */
    rt_RapidReadMatFileAndUpdateParams(S);
    ERROR_EXIT("Error reading parameter data from mat-file: %s\n",
              ssGetErrorStatus(S));

    /* load solver options */
    rsimLoadSolverOpts(S);
    ERROR_EXIT("Error loading solver options: %s\n", ssGetErrorStatus(S));

# if defined(DEBUG_SOLVER)
    rsimEnableDebugOutput(sizeof(struct SimStruct_tag),
                          sizeof(struct _ssMdlInfo));
# endif

#ifdef RACCEL_PARALLEL_FOREACH
    parforSchedulerInit = rt_ParallelForEachInitScheduler(S, RACCEL_PARFOREACH_NUM_THREADS, RACCEL_NUM_PARFOREACH_SS);
#endif

    rsimInitializeEngine(S);
    ERROR_EXIT("Error initializing RSIM engine: %s\n", ssGetErrorStatus(S));

    /* initialize external model */
    if (gblExtModeEnabled) {
        rtExtModeCheckInit(ssGetNumSampleTimes(S));
        initializedExtMode = TRUE;       
    }

    raccel_setup_MMIStateLog(S);

    if (ssIsVariableStepSolver(S)) {
        (void)rt_StartDataLoggingWithStartTime(ssGetRTWLogInfo(S),
                                               ssGetTStart(S),
                                               ssGetTFinal(S),
                                               0.0,
                                               &ssGetErrorStatus(S));
    } else {
        (void)rt_StartDataLoggingWithStartTime(ssGetRTWLogInfo(S),
                                               ssGetTStart(S),
                                               ssGetTFinal(S),
                                               ssGetStepSize(S),
                                               &ssGetErrorStatus(S));
    }
    GOTO_EXIT_IF_ERROR("Error starting data logging: %s\n", 
                       ssGetErrorStatus(S));
    dataLoggingActive = TRUE;

    if (gblExtModeEnabled) {
        /* If -w flag is specified wait here for connect signal from host */
        rtExtModeWaitForStartPkt(ssGetRTWExtModeInfo(S),
                                 ssGetNumSampleTimes(S),
                                 (boolean_T *)&ssGetStopRequested(S));
        if (ssGetStopRequested(S)) goto EXIT_POINT;
    }

    /* Start the model */
    now = time(NULL);
    if(gblVerboseFlag) {
        (void)printf("\n** Starting model @ %s", ctime(&now));
        }

    /* Enable logging in the MdlStart method */
    ssSetLogOutput(S,TRUE);

    /* Enable -i option to load inport data file */
    result = rt_RapidReadInportsMatFile(gblInportFileName, &matFileFormat);
    if (result!= NULL) {
        ssSetErrorStatus(S,result);
        GOTO_EXIT_IF_ERROR("Error starting model: %s\n",  ssGetErrorStatus(S));
    }

    MdlStart();
    ssSetLogOutput(S,FALSE);

    calledMdlStart = TRUE;
    GOTO_EXIT_IF_ERROR("Error starting model: %s\n", ssGetErrorStatus(S));

    result = rt_RapidCheckRemappings();
    ssSetErrorStatus(S,result);
    GOTO_EXIT_IF_ERROR("Error: %s\n", ssGetErrorStatus(S));

    /* Create solver data */
    rsimCreateSolverData(S, gblSlvrJacPatternFileName);
    GOTO_EXIT_IF_ERROR("Error creating solver data: %s\n", ssGetErrorStatus(S));

    ssSetFirstInitCondCalled(S);

    /*********************
     * Execute the model *
     *********************/

    /* Install Signal and Run time limit handlers */
    
    rsimInstallAllHandlers(S,WriteResultsToMatFile,gblTimeLimit);
    

    gblInstalledSigHandlers = TRUE;
    GOTO_EXIT_IF_ERROR("Error: %s\n", ssGetErrorStatus(S));

    while ( ((ssGetTFinal(S)-ssGetT(S)) > (fabs(ssGetT(S))*DBL_EPSILON)) ) {

        if (gblExtModeEnabled) {
            rtExtModePauseIfNeeded(ssGetRTWExtModeInfo(S),
                                   ssGetNumSampleTimes(S),
                                   (boolean_T *)&ssGetStopRequested(S));
        }
        if (ssGetStopRequested(S)) break;

        if (gbl_raccel_isMultitasking) {
            rsimOneStepMT(S);
        } else {
            rsimOneStepST(S);
        }
        if (ssGetErrorStatus(S)) break;
    }
    if (ssGetErrorStatus(S) == NULL && !ssGetStopRequested(S)) {
        /* Do a major step at the final time */
        if (gbl_raccel_isMultitasking) {
            rsimOneStepMT(S);
        } else { 
            rsimOutputLogUpdate(S);
        }
    }

  EXIT_POINT:
    /********************
     * Cleanup and exit *
     ********************/
    if (ssGetErrorStatus(S) != NULL) {
        if (errorPrefix) {
            (void)fprintf(stderr, errorPrefix, ssGetErrorStatus(S));
        } else {
            (void)fprintf(stderr, "Error: %s\n", ssGetErrorStatus(S));
        }
    }
    if (gblInstalledSigHandlers) {
        rsimUninstallNonfatalHandlers();
        gblInstalledSigHandlers = FALSE;
    }
    if (dataLoggingActive){
        WriteResultsToMatFile(S);
    }

    
    rsimTerminateEngine(S,0);
    
        
    if (initializedExtMode) {
        rtExtModeShutdown(ssGetNumSampleTimes(S));
    }
    if (calledMdlStart) {
        MdlTerminate();
    }

#ifdef RACCEL_PARALLEL_FOREACH
    rt_ParallelForEachClearScheduler(parforSchedulerInit);
#endif

    rt_RapidFreeGbls(matFileFormat);
    return ssGetErrorStatus(S) ? EXIT_FAILURE : EXIT_SUCCESS;

} /* end main */
Exemplo n.º 6
0
static void mdlStart(SimStruct *S)
{
    ssSetRWorkValue(S,0,ssGetTStart(S));
}
Exemplo n.º 7
0
static void mdlStart(SimStruct *S)
{
    PCONFIG_DATA config;
    int_T nports_in    = 1;
    int_T nports_out   = 2;
    int_T nq;
    
    /* Store new C object in the pointers vector */
    config = (PCONFIG_DATA) calloc(1, sizeof(CONFIG_DATA));
    ssGetPWork(S)[0] = config;
    
    /* Store the number of ports and their indices */
    config->idxin_xdot = 0;
    if( intval(mxGetScalar(paramInitialConditionSource)) > 1 )
    {
        config->idxin_x0 = nports_in++;
    }
    else
    {
        config->idxin_x0 = 0;
    }
    if( intval(mxGetScalar(paramSpecificationsSource)) == 3 )
    {
        config->idxin_params = nports_in++;
    }
    else
    {
        config->idxin_params = 0;
    }
    if( intval(mxGetScalar(paramExternalReset)) > 1 )
    {
        config->idxin_reset = nports_in++;
    }
    else
    {
        config->idxin_reset = 0;
    }
    
    config->idxout_x = 1;
    if( intval(mxGetScalar(paramOutputTime)) > 0 )
    {
        config->idxout_time = nports_out++;
    }
    else
    {
        config->idxout_time = 0;
    }
    
    /* Store the number of quaternions */
    if( mxGetNumberOfElements(paramQuaternionIndex) == 2 )
    {
        config->start_idx_q = intval(mxGetPr(paramQuaternionIndex)[0]) - 1;
        config->end_idx_q = intval(mxGetPr(paramQuaternionIndex)[1]) - 1;
        nq = 1 + config->end_idx_q - config->start_idx_q;
        nq = nq / 4;
        config->nq = nq;
        if( mxGetNumberOfElements(paramOmegaDotIndex) == 2 )
        {
            config->start_idx_omegadot = intval(mxGetPr(paramOmegaDotIndex)[0]) - 1;
            config->end_idx_omegadot = intval(mxGetPr(paramOmegaDotIndex)[1]) - 1;
            config->use_omegadot = 1;
        }
    }
    
    config->initial_time = ssGetTStart(S);
    config->nstates = ssGetInputPortWidth(S, 0);
}
Exemplo n.º 8
0
static void mdlStart(SimStruct *S)
{
    real_T *y = (real_T *)ssGetOutputPortSignal(S,0);
    *y = ssGetTStart(S);
}