Ejemplo n.º 1
1
/* Function: mdlInitializeSizes ===============================================
 * Abstract:
 *   Setup sizes of the various vectors.
 */
static void mdlInitializeSizes(SimStruct *S)
{

    DECL_AND_INIT_DIMSINFO(inputDimsInfo);
    DECL_AND_INIT_DIMSINFO(outputDimsInfo);
    ssSetNumSFcnParams(S, NPARAMS);
     if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
	 return; /* Parameter mismatch will be reported by Simulink */
     }

    ssSetNumContStates(S, NUM_CONT_STATES);
    ssSetNumDiscStates(S, NUM_DISC_STATES);

    if (!ssSetNumInputPorts(S, NUM_INPUTS)) return;
    /*Input Port 0 */

  /* Register xref_bus datatype for Input port 0 */

    #if defined(MATLAB_MEX_FILE)
    if (ssGetSimMode(S) != SS_SIMMODE_SIZES_CALL_ONLY)
    {
      DTypeId dataTypeIdReg;
      ssRegisterTypeFromNamedObject(S, "xref_bus", &dataTypeIdReg);
      if(dataTypeIdReg == INVALID_DTYPE_ID) return;
      ssSetInputPortDataType(S,0, dataTypeIdReg);
    }
    #endif
    ssSetInputPortWidth(S, 0, INPUT_0_WIDTH);
    ssSetInputPortComplexSignal(S, 0, INPUT_0_COMPLEX);
    ssSetInputPortDirectFeedThrough(S, 0, INPUT_0_FEEDTHROUGH);
    ssSetInputPortRequiredContiguous(S, 0, 1); /*direct input signal access*/
    ssSetBusInputAsStruct(S, 0,IN_0_BUS_BASED);
    ssSetInputPortBusMode(S, 0, SL_BUS_MODE);    /*Input Port 1 */

  /* Register x_bus datatype for Input port 1 */

    #if defined(MATLAB_MEX_FILE)
    if (ssGetSimMode(S) != SS_SIMMODE_SIZES_CALL_ONLY)
    {
      DTypeId dataTypeIdReg;
      ssRegisterTypeFromNamedObject(S, "x_bus", &dataTypeIdReg);
      if(dataTypeIdReg == INVALID_DTYPE_ID) return;
      ssSetInputPortDataType(S,1, dataTypeIdReg);
    }
    #endif
    ssSetInputPortWidth(S, 1, INPUT_1_WIDTH);
    ssSetInputPortComplexSignal(S, 1, INPUT_1_COMPLEX);
    ssSetInputPortDirectFeedThrough(S, 1, INPUT_1_FEEDTHROUGH);
    ssSetInputPortRequiredContiguous(S, 1, 1); /*direct input signal access*/
    ssSetBusInputAsStruct(S, 1,IN_1_BUS_BASED);
    ssSetInputPortBusMode(S, 1, SL_BUS_MODE);
    if (!ssSetNumOutputPorts(S, NUM_OUTPUTS)) return;

  /* Register u_bus datatype for Output port 0 */

  #if defined(MATLAB_MEX_FILE)
    if (ssGetSimMode(S) != SS_SIMMODE_SIZES_CALL_ONLY)
    {
      DTypeId dataTypeIdReg;
      ssRegisterTypeFromNamedObject(S, "u_bus", &dataTypeIdReg);
      if(dataTypeIdReg == INVALID_DTYPE_ID) return;
        ssSetOutputPortDataType(S,0, dataTypeIdReg);
    }
    #endif

    ssSetBusOutputObjectName(S, 0, (void *) "u_bus");
    ssSetOutputPortWidth(S, 0, OUTPUT_0_WIDTH);
    ssSetOutputPortComplexSignal(S, 0, OUTPUT_0_COMPLEX);
    ssSetBusOutputAsStruct(S, 0,OUT_0_BUS_BASED);
    ssSetOutputPortBusMode(S, 0, SL_BUS_MODE);
    if (ssRTWGenIsCodeGen(S)) {
       isSimulationTarget = GetRTWEnvironmentMode(S);
    if (isSimulationTarget==-1) {
       ssSetErrorStatus(S, " Unable to determine a valid code generation environment mode");
       return;
     }
       isSimulationTarget |= ssRTWGenIsModelReferenceSimTarget(S);
    }
  
    /* Set the number of dworks */
    if (!isDWorkPresent) {
      if (!ssSetNumDWork(S, 0)) return;
    } else {
      if (!ssSetNumDWork(S, 3)) return;
    }


   if (isDWorkPresent) {
   
    /*
     * Configure the dwork 0 (u0."BUS")
     */
#if defined(MATLAB_MEX_FILE)

    if (ssGetSimMode(S) != SS_SIMMODE_SIZES_CALL_ONLY) {
      DTypeId dataTypeIdReg;
      ssRegisterTypeFromNamedObject(S, "xref_bus", &dataTypeIdReg);
      if (dataTypeIdReg == INVALID_DTYPE_ID) return;
      ssSetDWorkDataType(S, 0, dataTypeIdReg);
    }

#endif

    ssSetDWorkUsageType(S, 0, SS_DWORK_USED_AS_DWORK);
    ssSetDWorkName(S, 0, "u0BUS");
    ssSetDWorkWidth(S, 0, DYNAMICALLY_SIZED);
    ssSetDWorkComplexSignal(S, 0, COMPLEX_NO);

    /*
     * Configure the dwork 1 (u1."BUS")
     */
#if defined(MATLAB_MEX_FILE)

    if (ssGetSimMode(S) != SS_SIMMODE_SIZES_CALL_ONLY) {
      DTypeId dataTypeIdReg;
      ssRegisterTypeFromNamedObject(S, "x_bus", &dataTypeIdReg);
      if (dataTypeIdReg == INVALID_DTYPE_ID) return;
      ssSetDWorkDataType(S, 1, dataTypeIdReg);
    }

#endif

    ssSetDWorkUsageType(S, 1, SS_DWORK_USED_AS_DWORK);
    ssSetDWorkName(S, 1, "u1BUS");
    ssSetDWorkWidth(S, 1, DYNAMICALLY_SIZED);
    ssSetDWorkComplexSignal(S, 1, COMPLEX_NO);

    /*
     * Configure the dwork 2 (y0BUS)
     */
#if defined(MATLAB_MEX_FILE)

    if (ssGetSimMode(S) != SS_SIMMODE_SIZES_CALL_ONLY) {
      DTypeId dataTypeIdReg;
      ssRegisterTypeFromNamedObject(S, "u_bus", &dataTypeIdReg);
      if (dataTypeIdReg == INVALID_DTYPE_ID) return;
      ssSetDWorkDataType(S, 2, dataTypeIdReg);
    }

#endif

    ssSetDWorkUsageType(S, 2, SS_DWORK_USED_AS_DWORK);
    ssSetDWorkName(S, 2, "y0BUS");
    ssSetDWorkWidth(S, 2, DYNAMICALLY_SIZED);
    ssSetDWorkComplexSignal(S, 2, COMPLEX_NO);
}
    ssSetNumSampleTimes(S, 1);
    ssSetNumRWork(S, 0);
    ssSetNumIWork(S, 0);
    ssSetNumPWork(S, 0);
    ssSetNumModes(S, 0);
    ssSetNumNonsampledZCs(S, 0);

    /* Take care when specifying exception free code - see sfuntmpl_doc.c */
    ssSetOptions(S, (SS_OPTION_EXCEPTION_FREE_CODE |
                     SS_OPTION_USE_TLC_WITH_ACCELERATOR | 
		     SS_OPTION_WORKS_WITH_CODE_REUSE));
}
Ejemplo n.º 2
0
 static void mdlSetWorkWidths(SimStruct *S)
 {
     int_T nq = 0;
     if( mxGetNumberOfElements(paramQuaternionIndex) == 2 )
     {
         nq = intval(mxGetPr(paramQuaternionIndex)[1]) - intval(mxGetPr(paramQuaternionIndex)[0]) + 1;
         nq = nq / 4;
     }
     ssSetNumContStates(S, 0);
     ssSetNumDiscStates(S, 0);
     ssSetNumRWork(S, 0);
     ssSetNumIWork(S, 1);
     ssSetNumPWork(S, 1);
     ssSetNumDWork(S, (nq > 0 ? 3 : 2));
     ssSetDWorkWidth(S, 0, ssGetInputPortWidth(S, 0));
     ssSetDWorkWidth(S, 1, ssGetInputPortWidth(S, 0));
     ssSetDWorkDataType(S, 0, SS_DOUBLE);
     ssSetDWorkDataType(S, 1, SS_DOUBLE);
     if( nq )
     {
         ssSetDWorkWidth(S, 2, ssGetInputPortWidth(S, 0));
         ssSetDWorkDataType(S, 2, SS_DOUBLE);
     }
     ssSetNumModes(S, 0);
 }
Ejemplo n.º 3
0
/* Function: mdlInitializeSizes ===============================================
 * Abstract:
 *    The sizes information is used by Simulink to determine the S-function
 *    block's characteristics (number of inputs, outputs, states, etc.).
 */
static void mdlInitializeSizes(SimStruct *S)
{
    /* See sfuntmpl.doc for more details on the macros below */

    ssSetNumSFcnParams(S, 0);  /* Number of expected parameters */
    if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
        /* Return if number of expected != number of actual parameters */
        return;
    }

    ssSetNumContStates(S, 1);  /* how many continuous states? */
    ssSetNumDiscStates(S, 0);

    if (!ssSetNumInputPorts(S, 1)) return;
    ssSetInputPortWidth(S, 0, 1);
    /*
     * Set direct feedthrough flag (1=yes, 0=no).
     * A port has direct feedthrough if the input is used in either
     * the mdlOutputs or mdlGetTimeOfNextVarHit functions.
     * See matlabroot/simulink/src/sfuntmpl_directfeed.txt.
     */
    ssSetInputPortDirectFeedThrough(S, 0, 1);

    if (!ssSetNumOutputPorts(S, 1)) return;
    ssSetOutputPortWidth(S, 0, 1);

    ssSetNumSampleTimes(S, 1);

    /* 
     * If your Fortran code uses REAL for the state, input, and/or output 
     * datatypes, use these DWorks as work areas to downcast continuous 
     * states from double to REAL before calling your code.  You could
     * also put the work vectors in hard-coded local (stack) variables.
     *
     * For fixed step code, keep a copy of the variables  to be output 
     * in a DWork vector so the mdlOutputs() function can provide output 
     * data when needed. You can use as many DWork vectors as you like 
     * for both input and output (or hard-code local variables).
     */
    if(!ssSetNumDWork(   S, 3)) return;

    ssSetDWorkWidth(     S, 0, ssGetOutputPortWidth(S,0));
    ssSetDWorkDataType(  S, 0, SS_SINGLE); /* use SS_DOUBLE if needed */

    ssSetDWorkWidth(     S, 1, ssGetInputPortWidth(S,0));
    ssSetDWorkDataType(  S, 1, SS_SINGLE);

    ssSetDWorkWidth(     S, 2, ssGetNumContStates(S));
    ssSetDWorkDataType(  S, 2, SS_SINGLE);

    ssSetNumNonsampledZCs(S, 0);

    /* Specify the sim state compliance to be same as a built-in block */
    /* see sfun_simstate.c for example of other possible settings */
    ssSetSimStateCompliance(S, USE_DEFAULT_SIM_STATE);

    ssSetOptions(S, 0);
}
Ejemplo n.º 4
0
static void mdlSetWorkWidths(SimStruct *S)
{
  /* Set the width of DWork(s) used for marshalling the IOs */
  if (isDWorkPresent) {

     /* Update dwork 0 */
     ssSetDWorkWidth(S, 0, ssGetInputPortWidth(S, 0));
       
     /* Update dwork 1 */
     ssSetDWorkWidth(S, 1, ssGetOutputPortWidth(S, 0));
        
    }
}
Ejemplo n.º 5
0
/* Function: mdlInitializeSizes ===============================================
 * Abstract:
 *    The sizes information is used by Simulink to determine the S-function
 *    block's characteristics (number of inputs, outputs, states, etc.).
 */
static void mdlInitializeSizes(SimStruct *S)
{
    ssSetNumSFcnParams(S, 0);  /* Number of expected parameters */
    if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
        /* Return if number of expected != number of actual parameters */
        return;
    }

    if (!ssSetNumInputPorts(S, 1)) return;
    ssSetInputPortWidth(S, 0, 1);
    ssSetInputPortRequiredContiguous(S, 0, true); /*direct input signal access*/
    ssSetInputPortDirectFeedThrough(S, 0, 0);

    if (!ssSetNumOutputPorts(S, 2)) return;
    ssSetOutputPortWidth(S, 0, 1);
    ssSetOutputPortWidth(S, 1, 1);

    ssSetNumSampleTimes(S, 1);

    /* 
     * Create a DWork data structure.
     */
    {
        int dtId;

        /*
         * Use caution to avoid name conflicts when registering the
         * data type name. The suggested naming convention is to use
         * a common prefix based on your Blockset's name for each data type 
         * registered by S-functions in your blocks set. If the S-function
         * is not part of a blockset, then use your company's name as a prefix.
         * The data type name is limited to 31 characters.
         */
       
        dtId = ssRegisterDataType(S, "ExampleCounterStateStruct");
        if (dtId == INVALID_DTYPE_ID ) return;

        /* Register the size of the udt */
        if (!ssSetDataTypeSize(S, dtId, sizeof(CounterStateStruct))) return;

        ssSetNumDWork(S,1);
        ssSetDWorkDataType(S, 0, dtId);
        ssSetDWorkWidth(S, 0, 1);
        ssSetDWorkName(S, 0, "CSStruct"); /*optional name, less than 16 chars*/
    }

    /* specify the sim state compliance to be same as a built-in block */
    ssSetSimStateCompliance(S, USE_DEFAULT_SIM_STATE);

    ssSetOptions(S,
                 SS_OPTION_WORKS_WITH_CODE_REUSE |
                 SS_OPTION_RUNTIME_EXCEPTION_FREE_CODE |
                 SS_OPTION_USE_TLC_WITH_ACCELERATOR);
}
Ejemplo n.º 6
0
// Function: mdlInitializeSizes ===============================================
// Abstract:
//    The sizes information is used by Simulink to determine the S-function
//    block's characteristics (number of inputs, s, states, etc.).
static void mdlInitializeSizes(SimStruct *S)
{
    ssSetNumSFcnParams(S, NPARAMS);
#if defined(MATLAB_MEX_FILE)
    if(ssGetNumSFcnParams(S) == ssGetSFcnParamsCount(S)){
        mdlCheckParameters(S);
        if(ssGetErrorStatus(S)!=NULL){
            return;
        }
        else{
            cout<<"All parameters have been checked and passed correctly"<<endl;
        }
    } else{
        return; // Parameter mismatch reported by Simulink
    }
#endif

    // Parameter mismatch will be reported by Simulink
    if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
        return;
    }

    // Specify I/O
    // INPUTS
    if(!ssSetNumInputPorts(S,0)) return;
    // OUTPUTS
    if (!ssSetNumOutputPorts(S,SIZE_READING_PORT)) return;
    for (int i = 0; i < SIZE_READING_PORT; i++)
    {
        ssSetOutputPortWidth   (S, i, 1);
        ssSetOutputPortDataType(S, i, 0);
    }
    
    ssSetNumSampleTimes(S, 1);

    // Reserve place for C++ object
    ssSetNumPWork(S, 1);

    // DWork vectors
    ssSetNumDWork(S, 1);
    ssSetDWorkWidth(S, 0, 1);
    ssSetDWorkDataType(S, 0, SS_DOUBLE);

    ssSetSimStateCompliance(S, USE_CUSTOM_SIM_STATE);

    ssSetOptions(S,
                 SS_OPTION_WORKS_WITH_CODE_REUSE |
                 SS_OPTION_EXCEPTION_FREE_CODE |
                 SS_OPTION_ALLOW_INPUT_SCALAR_EXPANSION |
                 SS_OPTION_USE_TLC_WITH_ACCELERATOR);

}
Ejemplo n.º 7
0
static void mdlInitializeSizes(SimStruct *S)
{
  ssSetNumSFcnParams(S, 2);
  ssSetNumContStates(S, 0);
  ssSetNumDiscStates(S, 0);
  ssSetNumInputPorts(S, 0);
  ssSetNumOutputPorts(S, 0);

  ssSetNumSampleTimes(S, 1);
  ssSetNumDWork(S, 1);  // wall t0
  ssSetDWorkWidth(S, 0, 1);
  ssSetDWorkDataType(S, 0, SS_DOUBLE);
}
Ejemplo n.º 8
0
static void mdlInitializeSizes(SimStruct *S)
{
    ssSetNumSFcnParams(S, 0);  /* Number of expected parameters */
    if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
        return;
    }

    ssSetNumContStates(S, 0);
    ssSetNumDiscStates(S, 0);

    if (!ssSetNumInputPorts(S, 1)) return;
    ssSetInputPortWidth(S, 0, 3);
    ssSetInputPortRequiredContiguous(S, 0, true);
    ssSetInputPortDirectFeedThrough(S, 0, 0);
    //ssSetInputPortDataType(S,0,SS_DOUBLE);

    if (!ssSetNumOutputPorts(S, 1)) return;
    ssSetOutputPortWidth(S, 0, 3);

    ssSetNumSampleTimes(S, 1);
    ssSetNumDWork(S, 2);
    ssSetNumRWork(S, 0);
    ssSetNumIWork(S, 0);
    ssSetNumPWork(S, 0);
    ssSetNumModes(S, 0);

    //Pointer SHM_IN
    ssSetDWorkWidth(S, DVECSHMIN, 1);
    ssSetDWorkDataType(S, DVECSHMIN, SS_POINTER);

    //Pointer SHM_OUT
    ssSetDWorkWidth(S, DVECSHMOUT, 1);
    ssSetDWorkDataType(S, DVECSHMOUT, SS_POINTER);

    ssSetOptions(S, 0);
}
Ejemplo n.º 9
0
static void mdlSetWorkWidths_c3_MPC_framework(SimStruct *S)
{
  if(sim_mode_is_rtw_gen(S)) {
    int_T chartIsInlinable =
      (int_T)sf_is_chart_inlinable("MPC_framework",3);
    ssSetStateflowIsInlinable(S,chartIsInlinable);
    ssSetEnableFcnIsTrivial(S,1);
    ssSetDisableFcnIsTrivial(S,1);
    ssSetNotMultipleInlinable(S,sf_rtw_info_uint_prop("MPC_framework",3,"gatewayCannotBeInlinedMultipleTimes"));
    if(chartIsInlinable) {
      ssSetInputPortOptimOpts(S, 0, SS_REUSABLE_AND_LOCAL);
      ssSetInputPortOptimOpts(S, 1, SS_REUSABLE_AND_LOCAL);
      ssSetInputPortOptimOpts(S, 2, SS_REUSABLE_AND_LOCAL);
      ssSetInputPortOptimOpts(S, 3, SS_REUSABLE_AND_LOCAL);
      ssSetInputPortOptimOpts(S, 4, SS_REUSABLE_AND_LOCAL);
      ssSetInputPortOptimOpts(S, 5, SS_REUSABLE_AND_LOCAL);
      ssSetInputPortOptimOpts(S, 6, SS_REUSABLE_AND_LOCAL);
      ssSetInputPortOptimOpts(S, 7, SS_REUSABLE_AND_LOCAL);
      sf_mark_chart_expressionable_inputs(S,"MPC_framework",3,8);
      sf_mark_chart_reusable_outputs(S,"MPC_framework",3,3);
    }
    if (!sf_is_chart_instance_optimized_out("MPC_framework",3)) {
      int dtId;
      char *chartInstanceTypedefName =
        sf_chart_instance_typedef_name("MPC_framework",3);
      dtId = ssRegisterDataType(S, chartInstanceTypedefName);
      if (dtId == INVALID_DTYPE_ID ) return;
      /* Register the size of the udt */
      if (!ssSetDataTypeSize(S, dtId, 8)) return;
      if(!ssSetNumDWork(S,1)) return;
      ssSetDWorkDataType(S, 0, dtId);
      ssSetDWorkWidth(S, 0, 1);
      ssSetDWorkName(S, 0, "ChartInstance"); /*optional name, less than 16 chars*/
      sf_set_rtw_identifier(S);
    }
    ssSetHasSubFunctions(S,!(chartIsInlinable));
    ssSetOptions(S,ssGetOptions(S)|SS_OPTION_WORKS_WITH_CODE_REUSE);
  }

  ssSetChecksum0(S,(1607393255U));
  ssSetChecksum1(S,(1677787762U));
  ssSetChecksum2(S,(2097080131U));
  ssSetChecksum3(S,(3166642993U));

  ssSetExplicitFCSSCtrl(S,1);
}
static void mdlInitializeSizes(SimStruct *S)
{
    ssSetNumSFcnParams(S, 5);  /* Number of expected parameters */

#ifndef TRES_SIMULINK_DISABLE_MASK_PROTECTION
    // Perform mask params validity check
    // TODO very basic error check (to be improved).
    const mxArray *mxMsdVarName = ssGetSFcnParam(S,MSG_DESCR_VARNAME);
    if ((mxGetM(mxMsdVarName) != 1) || (mxGetN(mxMsdVarName) == 0))
    {
        ssSetErrorStatus(S, "The message-set description variable cannot be empty");
        return;
    }
    const mxArray *mxNdVarName = ssGetSFcnParam(S,NTWK_DESCR_VARNAME);
    if ((mxGetM(mxNdVarName) != 1) || (mxGetN(mxNdVarName) == 0))
    {
        ssSetErrorStatus(S, "The network description variable cannot be empty (you must specify at least the network topology!)");
        return;
    }
    const mxArray *mxAddLibsPath = ssGetSFcnParam(S,OTHER_DEPS);
    if ((mxGetM(mxAddLibsPath) != 1) || (mxGetN(mxAddLibsPath) == 0))
    {
        ssSetErrorStatus(S, "The Additional Libraries (see the Simulator tab) field cannot be empty");
        return;
    }
#endif

    ssSetNumContStates(S, 0);
    ssSetNumDiscStates(S, 0);

    // Set the number of input ports to 0
    if (!ssSetNumInputPorts(S, 0)) return;

    // Set the output port to have a dynamic dimension
    if (!ssSetNumOutputPorts(S, 1)) return;
    ssSetOutputPortWidth(S, 0, DYNAMICALLY_SIZED);

    ssSetNumSampleTimes(S, 1);

    ssSetNumDWork(S, 1);  // store the `New pending activations available' flag
    ssSetDWorkWidth(S, 0, 1);
    ssSetDWorkDataType(S, 0, SS_BOOLEAN);
    ssSetNumPWork(S, 1);  // store the tres::Network
    ssSetNumRWork(S, 1);  // store the time_resolution
    ssSetNumNonsampledZCs(S, 1);    // next hit
}
Ejemplo n.º 11
0
static void mdlSetWorkWidths_c2_object_tracker_intensity(SimStruct *S)
{
  if(sim_mode_is_rtw_gen(S)) {
    int_T chartIsInlinable =
      (int_T)sf_is_chart_inlinable("object_tracker_intensity",2);
    ssSetStateflowIsInlinable(S,chartIsInlinable);
    ssSetEnableFcnIsTrivial(S,1);
    ssSetDisableFcnIsTrivial(S,1);
    ssSetNotMultipleInlinable(S,sf_rtw_info_uint_prop("object_tracker_intensity",2,"gatewayCannotBeInlinedMultipleTimes"));
    if(chartIsInlinable) {
      ssSetInputPortOptimOpts(S, 0, SS_REUSABLE_AND_LOCAL);
      ssSetInputPortOptimOpts(S, 1, SS_REUSABLE_AND_LOCAL);
      ssSetInputPortOptimOpts(S, 2, SS_REUSABLE_AND_LOCAL);
      ssSetInputPortOptimOpts(S, 3, SS_REUSABLE_AND_LOCAL);
      sf_mark_chart_expressionable_inputs(S,"object_tracker_intensity",2,4);
      sf_mark_chart_reusable_outputs(S,"object_tracker_intensity",2,3);
    }
    if (!sf_is_chart_instance_optimized_out("object_tracker_intensity",2)) {
      int dtId;
      char *chartInstanceTypedefName =
        sf_chart_instance_typedef_name("object_tracker_intensity",2);
      dtId = ssRegisterDataType(S, chartInstanceTypedefName);
      if (dtId == INVALID_DTYPE_ID ) return;
      /* Register the size of the udt */
      if (!ssSetDataTypeSize(S, dtId, 8)) return;
      if(!ssSetNumDWork(S,1)) return;
      ssSetDWorkDataType(S, 0, dtId);
      ssSetDWorkWidth(S, 0, 1);
      ssSetDWorkName(S, 0, "ChartInstance"); /*optional name, less than 16 chars*/
      sf_set_rtw_identifier(S);
    }
    ssSetHasSubFunctions(S,!(chartIsInlinable));
    ssSetOptions(S,ssGetOptions(S)|SS_OPTION_WORKS_WITH_CODE_REUSE);
  }

  ssSetChecksum0(S,(1312153194U));
  ssSetChecksum1(S,(1014398065U));
  ssSetChecksum2(S,(1024726701U));
  ssSetChecksum3(S,(2475745997U));

  ssSetExplicitFCSSCtrl(S,1);
}
Ejemplo n.º 12
0
/* Model initialize function */
void testSHM_initialize(boolean_T firstTime)
{
  (void)firstTime;

  /* Registration code */

  /* initialize non-finites */
  rt_InitInfAndNaN(sizeof(real_T));

  /* initialize real-time model */
  (void) memset((void *)testSHM_M,0,
                sizeof(RT_MODEL_testSHM));
  rtsiSetSolverName(&testSHM_M->solverInfo,"FixedStepDiscrete");
  testSHM_M->solverInfoPtr = (&testSHM_M->solverInfo);

  /* Initialize timing info */
  {
    int_T *mdlTsMap = testSHM_M->Timing.sampleTimeTaskIDArray;
    mdlTsMap[0] = 0;
    testSHM_M->Timing.sampleTimeTaskIDPtr = (&mdlTsMap[0]);
    testSHM_M->Timing.sampleTimes = (&testSHM_M->Timing.sampleTimesArray[0]);
    testSHM_M->Timing.offsetTimes = (&testSHM_M->Timing.offsetTimesArray[0]);

    /* task periods */
    testSHM_M->Timing.sampleTimes[0] = (0.001);

    /* task offsets */
    testSHM_M->Timing.offsetTimes[0] = (0.0);
  }

  rtmSetTPtr(testSHM_M, &testSHM_M->Timing.tArray[0]);

  {
    int_T *mdlSampleHits = testSHM_M->Timing.sampleHitArray;
    mdlSampleHits[0] = 1;
    testSHM_M->Timing.sampleHits = (&mdlSampleHits[0]);
  }

  rtmSetTFinal(testSHM_M, 10.0);
  testSHM_M->Timing.stepSize0 = 0.001;

  /* Setup for data logging */
  {
    static RTWLogInfo rt_DataLoggingInfo;
    testSHM_M->rtwLogInfo = &rt_DataLoggingInfo;
    rtliSetLogXSignalInfo(testSHM_M->rtwLogInfo, (NULL));
    rtliSetLogXSignalPtrs(testSHM_M->rtwLogInfo, (NULL));
    rtliSetLogT(testSHM_M->rtwLogInfo, "tout");
    rtliSetLogX(testSHM_M->rtwLogInfo, "");
    rtliSetLogXFinal(testSHM_M->rtwLogInfo, "");
    rtliSetSigLog(testSHM_M->rtwLogInfo, "");
    rtliSetLogVarNameModifier(testSHM_M->rtwLogInfo, "rt_");
    rtliSetLogFormat(testSHM_M->rtwLogInfo, 0);
    rtliSetLogMaxRows(testSHM_M->rtwLogInfo, 1000);
    rtliSetLogDecimation(testSHM_M->rtwLogInfo, 1);
    rtliSetLogY(testSHM_M->rtwLogInfo, "");
    rtliSetLogYSignalInfo(testSHM_M->rtwLogInfo, (NULL));
    rtliSetLogYSignalPtrs(testSHM_M->rtwLogInfo, (NULL));
  }

  testSHM_M->solverInfoPtr = (&testSHM_M->solverInfo);
  testSHM_M->Timing.stepSize = (0.001);
  rtsiSetFixedStepSize(&testSHM_M->solverInfo, 0.001);
  rtsiSetSolverMode(&testSHM_M->solverInfo, SOLVER_MODE_SINGLETASKING);

  /* block I/O */
  testSHM_M->ModelData.blockIO = ((void *) &testSHM_B);
  (void) memset(((void *) &testSHM_B),0,
                sizeof(BlockIO_testSHM));

  /* parameters */
  testSHM_M->ModelData.defaultParam = ((real_T *) &testSHM_P);

  /* states (dwork) */
  testSHM_M->Work.dwork = ((void *) &testSHM_DWork);
  (void) memset((void *)&testSHM_DWork, 0,
                sizeof(D_Work_testSHM));

  /* C API for Parameter Tuning and/or Signal Monitoring */
  {
    static ModelMappingInfo mapInfo;
    (void) memset((char_T *) &mapInfo,0,
                  sizeof(mapInfo));

    /* block signal monitoring map */
    mapInfo.Signals.blockIOSignals = &rtBIOSignals[0];
    mapInfo.Signals.numBlockIOSignals = 2;

    /* parameter tuning maps */
    mapInfo.Parameters.blockTuning = &rtBlockTuning[0];
    mapInfo.Parameters.variableTuning = &rtVariableTuning[0];
    mapInfo.Parameters.parametersMap = rtParametersMap;
    mapInfo.Parameters.dimensionsMap = rtDimensionsMap;
    mapInfo.Parameters.numBlockTuning = 4;
    mapInfo.Parameters.numVariableTuning = 0;
    testSHM_M->SpecialInfo.mappingInfo = (&mapInfo);
  }

  /* child S-Function registration */
  {
    RTWSfcnInfo *sfcnInfo = &testSHM_M->NonInlinedSFcns.sfcnInfo;
    testSHM_M->sfcnInfo = (sfcnInfo);
    rtssSetErrorStatusPtr(sfcnInfo, (&rtmGetErrorStatus(testSHM_M)));
    rtssSetNumRootSampTimesPtr(sfcnInfo, &testSHM_M->Sizes.numSampTimes);
    rtssSetTPtrPtr(sfcnInfo, &rtmGetTPtr(testSHM_M));
    rtssSetTStartPtr(sfcnInfo, &rtmGetTStart(testSHM_M));
    rtssSetTFinalPtr(sfcnInfo, &rtmGetTFinal(testSHM_M));
    rtssSetTimeOfLastOutputPtr(sfcnInfo, &rtmGetTimeOfLastOutput(testSHM_M));
    rtssSetStepSizePtr(sfcnInfo, &testSHM_M->Timing.stepSize);
    rtssSetStopRequestedPtr(sfcnInfo, &rtmGetStopRequested(testSHM_M));
    rtssSetDerivCacheNeedsResetPtr(sfcnInfo,
      &testSHM_M->ModelData.derivCacheNeedsReset);
    rtssSetZCCacheNeedsResetPtr(sfcnInfo,
      &testSHM_M->ModelData.zCCacheNeedsReset);
    rtssSetBlkStateChangePtr(sfcnInfo, &testSHM_M->ModelData.blkStateChange);
    rtssSetSampleHitsPtr(sfcnInfo, &testSHM_M->Timing.sampleHits);
    rtssSetPerTaskSampleHitsPtr(sfcnInfo, &testSHM_M->Timing.perTaskSampleHits);
    rtssSetSimModePtr(sfcnInfo, &testSHM_M->simMode);
    rtssSetSolverInfoPtr(sfcnInfo, &testSHM_M->solverInfoPtr);
  }

  testSHM_M->Sizes.numSFcns = (2);

  /* register each child */
  {
    (void) memset((void *)&testSHM_M->NonInlinedSFcns.childSFunctions[0],0,
                  2*sizeof(SimStruct));
    testSHM_M->childSfunctions = (&testSHM_M->
      NonInlinedSFcns.childSFunctionPtrs[0]);
    testSHM_M->childSfunctions[0] = (&testSHM_M->
      NonInlinedSFcns.childSFunctions[0]);
    testSHM_M->childSfunctions[1] = (&testSHM_M->
      NonInlinedSFcns.childSFunctions[1]);

    /* Level2 S-Function Block: testSHM/<Root>/S-Function (sSHM) */
    {
      SimStruct *rts = testSHM_M->childSfunctions[0];

      /* timing info */
      time_T *sfcnPeriod = testSHM_M->NonInlinedSFcns.Sfcn0.sfcnPeriod;
      time_T *sfcnOffset = testSHM_M->NonInlinedSFcns.Sfcn0.sfcnOffset;
      int_T *sfcnTsMap = testSHM_M->NonInlinedSFcns.Sfcn0.sfcnTsMap;
      (void) memset((void*)sfcnPeriod,0,
                    sizeof(time_T)*1);
      (void) memset((void*)sfcnOffset,0,
                    sizeof(time_T)*1);
      ssSetSampleTimePtr(rts, &sfcnPeriod[0]);
      ssSetOffsetTimePtr(rts, &sfcnOffset[0]);
      ssSetSampleTimeTaskIDPtr(rts, sfcnTsMap);

      /* Set up the mdlInfo pointer */
      {
        ssSetBlkInfo2Ptr(rts, &testSHM_M->NonInlinedSFcns.blkInfo2[0]);
        ssSetRTWSfcnInfo(rts, testSHM_M->sfcnInfo);
      }

      /* Allocate memory of model methods 2 */
      {
        ssSetModelMethods2(rts, &testSHM_M->NonInlinedSFcns.methods2[0]);
      }

      /* Allocate memory of model methods 3 */
      {
        ssSetModelMethods3(rts, &testSHM_M->NonInlinedSFcns.methods3[0]);
      }

      /* inputs */
      {
        _ssSetNumInputPorts(rts, 1);
        ssSetPortInfoForInputs(rts,
          &testSHM_M->NonInlinedSFcns.Sfcn0.inputPortInfo[0]);

        /* port 0 */
        {
          ssSetInputPortRequiredContiguous(rts, 0, 1);
          ssSetInputPortSignal(rts, 0, testSHM_B.TmpHiddenBufferAtSFunctionInpor);
          _ssSetInputPortNumDimensions(rts, 0, 1);
          ssSetInputPortWidth(rts, 0, 3);
        }
      }

      /* outputs */
      {
        ssSetPortInfoForOutputs(rts,
          &testSHM_M->NonInlinedSFcns.Sfcn0.outputPortInfo[0]);
        _ssSetNumOutputPorts(rts, 1);

        /* port 0 */
        {
          _ssSetOutputPortNumDimensions(rts, 0, 1);
          ssSetOutputPortWidth(rts, 0, 3);
          ssSetOutputPortSignal(rts, 0, ((real_T *) testSHM_B.SFunction));
        }
      }

      /* path info */
      ssSetModelName(rts, "S-Function");
      ssSetPath(rts, "testSHM/S-Function");
      ssSetRTModel(rts,testSHM_M);
      ssSetParentSS(rts, (NULL));
      ssSetRootSS(rts, rts);
      ssSetVersion(rts, SIMSTRUCT_VERSION_LEVEL2);

      /* work vectors */
      {
        struct _ssDWorkRecord *dWorkRecord = (struct _ssDWorkRecord *)
          &testSHM_M->NonInlinedSFcns.Sfcn0.dWork;
        struct _ssDWorkAuxRecord *dWorkAuxRecord = (struct _ssDWorkAuxRecord *)
          &testSHM_M->NonInlinedSFcns.Sfcn0.dWorkAux;
        ssSetSFcnDWork(rts, dWorkRecord);
        ssSetSFcnDWorkAux(rts, dWorkAuxRecord);
        _ssSetNumDWork(rts, 2);

        /* DWORK1 */
        ssSetDWorkWidth(rts, 0, 1);
        ssSetDWorkDataType(rts, 0,SS_POINTER);
        ssSetDWorkComplexSignal(rts, 0, 0);
        ssSetDWork(rts, 0, &testSHM_DWork.SFunction_DWORK1);

        /* DWORK2 */
        ssSetDWorkWidth(rts, 1, 1);
        ssSetDWorkDataType(rts, 1,SS_POINTER);
        ssSetDWorkComplexSignal(rts, 1, 0);
        ssSetDWork(rts, 1, &testSHM_DWork.SFunction_DWORK2);
      }

      /* registration */
      sSHM(rts);
      sfcnInitializeSizes(rts);
      sfcnInitializeSampleTimes(rts);

      /* adjust sample time */
      ssSetSampleTime(rts, 0, 0.001);
      ssSetOffsetTime(rts, 0, 0.0);
      sfcnTsMap[0] = 0;

      /* set compiled values of dynamic vector attributes */
      ssSetNumNonsampledZCs(rts, 0);

      /* Update connectivity flags for each port */
      _ssSetInputPortConnected(rts, 0, 1);
      _ssSetOutputPortConnected(rts, 0, 1);
      _ssSetOutputPortBeingMerged(rts, 0, 0);

      /* Update the BufferDstPort flags for each input port */
      ssSetInputPortBufferDstPort(rts, 0, -1);
    }

    /* Level2 S-Function Block: testSHM/<Root>/RTAI_SCOPE (sfun_rtai_scope) */
    {
      SimStruct *rts = testSHM_M->childSfunctions[1];

      /* timing info */
      time_T *sfcnPeriod = testSHM_M->NonInlinedSFcns.Sfcn1.sfcnPeriod;
      time_T *sfcnOffset = testSHM_M->NonInlinedSFcns.Sfcn1.sfcnOffset;
      int_T *sfcnTsMap = testSHM_M->NonInlinedSFcns.Sfcn1.sfcnTsMap;
      (void) memset((void*)sfcnPeriod,0,
                    sizeof(time_T)*1);
      (void) memset((void*)sfcnOffset,0,
                    sizeof(time_T)*1);
      ssSetSampleTimePtr(rts, &sfcnPeriod[0]);
      ssSetOffsetTimePtr(rts, &sfcnOffset[0]);
      ssSetSampleTimeTaskIDPtr(rts, sfcnTsMap);

      /* Set up the mdlInfo pointer */
      {
        ssSetBlkInfo2Ptr(rts, &testSHM_M->NonInlinedSFcns.blkInfo2[1]);
        ssSetRTWSfcnInfo(rts, testSHM_M->sfcnInfo);
      }

      /* Allocate memory of model methods 2 */
      {
        ssSetModelMethods2(rts, &testSHM_M->NonInlinedSFcns.methods2[1]);
      }

      /* Allocate memory of model methods 3 */
      {
        ssSetModelMethods3(rts, &testSHM_M->NonInlinedSFcns.methods3[1]);
      }

      /* inputs */
      {
        _ssSetNumInputPorts(rts, 3);
        ssSetPortInfoForInputs(rts,
          &testSHM_M->NonInlinedSFcns.Sfcn1.inputPortInfo[0]);

        /* port 0 */
        {
          real_T const **sfcnUPtrs = (real_T const **)
            &testSHM_M->NonInlinedSFcns.Sfcn1.UPtrs0;
          sfcnUPtrs[0] = &testSHM_B.SFunction[0];
          ssSetInputPortSignalPtrs(rts, 0, (InputPtrsType)&sfcnUPtrs[0]);
          _ssSetInputPortNumDimensions(rts, 0, 1);
          ssSetInputPortWidth(rts, 0, 1);
        }

        /* port 1 */
        {
          real_T const **sfcnUPtrs = (real_T const **)
            &testSHM_M->NonInlinedSFcns.Sfcn1.UPtrs1;
          sfcnUPtrs[0] = &testSHM_B.SFunction[1];
          ssSetInputPortSignalPtrs(rts, 1, (InputPtrsType)&sfcnUPtrs[0]);
          _ssSetInputPortNumDimensions(rts, 1, 1);
          ssSetInputPortWidth(rts, 1, 1);
        }

        /* port 2 */
        {
          real_T const **sfcnUPtrs = (real_T const **)
            &testSHM_M->NonInlinedSFcns.Sfcn1.UPtrs2;
          sfcnUPtrs[0] = &testSHM_B.SFunction[2];
          ssSetInputPortSignalPtrs(rts, 2, (InputPtrsType)&sfcnUPtrs[0]);
          _ssSetInputPortNumDimensions(rts, 2, 1);
          ssSetInputPortWidth(rts, 2, 1);
        }
      }

      /* path info */
      ssSetModelName(rts, "RTAI_SCOPE");
      ssSetPath(rts, "testSHM/RTAI_SCOPE");
      ssSetRTModel(rts,testSHM_M);
      ssSetParentSS(rts, (NULL));
      ssSetRootSS(rts, rts);
      ssSetVersion(rts, SIMSTRUCT_VERSION_LEVEL2);

      /* parameters */
      {
        mxArray **sfcnParams = (mxArray **)
          &testSHM_M->NonInlinedSFcns.Sfcn1.params;
        ssSetSFcnParamsCount(rts, 2);
        ssSetSFcnParamsPtr(rts, &sfcnParams[0]);
        ssSetSFcnParam(rts, 0, (mxArray*)&testSHM_P.RTAI_SCOPE_P1_Size[0]);
        ssSetSFcnParam(rts, 1, (mxArray*)&testSHM_P.RTAI_SCOPE_P2_Size[0]);
      }

      /* work vectors */
      ssSetPWork(rts, (void **) &testSHM_DWork.RTAI_SCOPE_PWORK);

      {
        struct _ssDWorkRecord *dWorkRecord = (struct _ssDWorkRecord *)
          &testSHM_M->NonInlinedSFcns.Sfcn1.dWork;
        struct _ssDWorkAuxRecord *dWorkAuxRecord = (struct _ssDWorkAuxRecord *)
          &testSHM_M->NonInlinedSFcns.Sfcn1.dWorkAux;
        ssSetSFcnDWork(rts, dWorkRecord);
        ssSetSFcnDWorkAux(rts, dWorkAuxRecord);
        _ssSetNumDWork(rts, 1);

        /* PWORK */
        ssSetDWorkWidth(rts, 0, 1);
        ssSetDWorkDataType(rts, 0,SS_POINTER);
        ssSetDWorkComplexSignal(rts, 0, 0);
        ssSetDWork(rts, 0, &testSHM_DWork.RTAI_SCOPE_PWORK);
      }

      /* registration */
      sfun_rtai_scope(rts);
      sfcnInitializeSizes(rts);
      sfcnInitializeSampleTimes(rts);

      /* adjust sample time */
      ssSetSampleTime(rts, 0, 0.001);
      ssSetOffsetTime(rts, 0, 0.0);
      sfcnTsMap[0] = 0;

      /* set compiled values of dynamic vector attributes */
      ssSetNumNonsampledZCs(rts, 0);

      /* Update connectivity flags for each port */
      _ssSetInputPortConnected(rts, 0, 1);
      _ssSetInputPortConnected(rts, 1, 1);
      _ssSetInputPortConnected(rts, 2, 1);

      /* Update the BufferDstPort flags for each input port */
      ssSetInputPortBufferDstPort(rts, 0, -1);
      ssSetInputPortBufferDstPort(rts, 1, -1);
      ssSetInputPortBufferDstPort(rts, 2, -1);
    }
  }
}
/* Function: mdlInitializeSizes ===============================================
 * Abstract:
 *    The sizes information is used by Simulink to determine the S-function
 *    block's characteristics (number of inputs, outputs, states, etc.).
 */
static void mdlInitializeSizes(SimStruct *S)
{

	DECL_AND_INIT_DIMSINFO(outputDimsInfo);
	ssSetNumSFcnParams(S, NPARAMS);
	if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
		return; /* Parameter mismatch will be reported by Simulink */
	}

	ssSetNumContStates(S, NUM_CONT_STATES);
	ssSetNumDiscStates(S, NUM_DISC_STATES);


	if (!ssSetNumInputPorts(S, NUM_INPUTS)) return;

	if (!ssSetNumOutputPorts(S, NUM_OUTPUTS)) return;
	/* Output Port 0 */
	ssSetOutputPortWidth(S, 0, OUTPUT_0_WIDTH);
	ssSetOutputPortDataType(S, 0, SS_DOUBLE);
	ssSetOutputPortComplexSignal(S, 0, OUTPUT_0_COMPLEX);
	/* Output Port 1 */

	/* Register SL_ROS_SUB_MSG datatype for Output port 1 */

#if defined(MATLAB_MEX_FILE)
	if (ssGetSimMode(S) != SS_SIMMODE_SIZES_CALL_ONLY)
	{
		DTypeId dataTypeIdReg;
		ssRegisterTypeFromNamedObject(S, "SL_ROS_SUB_MSG", &dataTypeIdReg);
		if(dataTypeIdReg == INVALID_DTYPE_ID) return;
		ssSetOutputPortDataType(S,1, dataTypeIdReg);
	}
#endif

	ssSetBusOutputObjectName(S, 1, (void *) "SL_ROS_SUB_MSG");
	ssSetOutputPortWidth(S, 1, OUTPUT_1_WIDTH);
	ssSetOutputPortComplexSignal(S, 1, OUTPUT_1_COMPLEX);
	ssSetBusOutputAsStruct(S, 1, OUT_1_BUS_BASED);
	ssSetOutputPortBusMode(S, 1, SL_BUS_MODE);
	if (ssRTWGenIsCodeGen(S)) {
		isSimulationTarget = GetRTWEnvironmentMode(S);
		if (isSimulationTarget == -1) {
			ssSetErrorStatus(S, " Unable to determine a valid code generation environment mode");
			return;
		}
		isSimulationTarget |= ssRTWGenIsModelReferenceSimTarget(S);
	}

	/* Set the number of dworks */
	if (!isDWorkPresent) {
		if (!ssSetNumDWork(S, 0)) return;
	}
	else {
		if (!ssSetNumDWork(S, 1)) return;
	}


	if (isDWorkPresent) {

		/*
		* Configure the dwork 0 (y1BUS)
		*/
#if defined(MATLAB_MEX_FILE)

		if (ssGetSimMode(S) != SS_SIMMODE_SIZES_CALL_ONLY) {
			DTypeId dataTypeIdReg;
			ssRegisterTypeFromNamedObject(S, "SL_ROS_SUB_MSG", &dataTypeIdReg);
			if (dataTypeIdReg == INVALID_DTYPE_ID) return;
			ssSetDWorkDataType(S, 0, dataTypeIdReg);
		}

#endif

		ssSetDWorkUsageType(S, 0, SS_DWORK_USED_AS_DWORK);
		ssSetDWorkName(S, 0, "y1BUS");
		ssSetDWorkWidth(S, 0, DYNAMICALLY_SIZED);
		ssSetDWorkComplexSignal(S, 0, COMPLEX_NO);
	}
	ssSetNumSampleTimes(S, 1);
	ssSetNumRWork(S, 0);
	ssSetNumIWork(S, 0);
	ssSetNumPWork(S, 0);
	ssSetNumModes(S, 0);
	ssSetNumNonsampledZCs(S, 0);

	ssSetSimulinkVersionGeneratedIn(S, "8.7");

	/* Take care when specifying exception free code - see sfuntmpl_doc.c */
	ssSetOptions(S, 0);
}
Ejemplo n.º 14
0
static void mdlInitializeSizes(SimStruct *S)
{
  ssSetNumSFcnParams(S, 0);
  if (S->mdlInfo->genericFcn != NULL) {
    _GenericFcn fcn = S->mdlInfo->genericFcn;
    (fcn)(S, GEN_FCN_CHK_MODELREF_SOLVER_TYPE_EARLY, 2, NULL);
  }

  ssSetRTWGeneratedSFcn(S, 2);
  ssSetNumContStates(S, 0);
  ssSetNumDiscStates(S, 0);
  if (!ssSetNumInputPorts(S, 2))
    return;
  if (!ssSetInputPortVectorDimension(S, 0, 1))
    return;
  ssSetInputPortFrameData(S, 0, FRAME_NO);
  ssSetInputPortBusMode(S, 0, SL_NON_BUS_MODE)
    if (ssGetSimMode(S) != SS_SIMMODE_SIZES_CALL_ONLY)
  {
    ssSetInputPortDataType(S, 0, SS_DOUBLE);
  }

  ssSetInputPortDirectFeedThrough(S, 0, 1);
  ssSetInputPortRequiredContiguous(S, 0, 1);
  ssSetInputPortOptimOpts(S, 0, SS_NOT_REUSABLE_AND_GLOBAL);
  ssSetInputPortOverWritable(S, 0, FALSE);
  ssSetInputPortSampleTime(S, 0, 0.0);
  ssSetInputPortOffsetTime(S, 0, 0.0);
  if (!ssSetInputPortVectorDimension(S, 1, 1))
    return;
  ssSetInputPortFrameData(S, 1, FRAME_NO);
  ssSetInputPortBusMode(S, 1, SL_NON_BUS_MODE)
    if (ssGetSimMode(S) != SS_SIMMODE_SIZES_CALL_ONLY)
  {
    ssSetInputPortDataType(S, 1, SS_DOUBLE);
  }

  ssSetInputPortDirectFeedThrough(S, 1, 1);
  ssSetInputPortRequiredContiguous(S, 1, 1);
  ssSetInputPortOptimOpts(S, 1, SS_NOT_REUSABLE_AND_GLOBAL);
  ssSetInputPortOverWritable(S, 1, FALSE);
  ssSetInputPortSampleTime(S, 1, 0.0);
  ssSetInputPortOffsetTime(S, 1, 0.0);
  if (!ssSetNumOutputPorts(S, 1))
    return;
  if (!ssSetOutputPortVectorDimension(S, 0, 1))
    return;
  ssSetOutputPortFrameData(S, 0, FRAME_NO);
  ssSetOutputPortBusMode(S, 0, SL_NON_BUS_MODE)
    if (ssGetSimMode(S) != SS_SIMMODE_SIZES_CALL_ONLY)
  {
    ssSetOutputPortDataType(S, 0, SS_DOUBLE);
  }

  ssSetOutputPortSampleTime(S, 0, 0.0);
  ssSetOutputPortOffsetTime(S, 0, 0.0);
  ssSetOutputPortOkToMerge(S, 0, SS_OK_TO_MERGE);
  ssSetOutputPortOptimOpts(S, 0, SS_NOT_REUSABLE_AND_GLOBAL);
  rt_InitInfAndNaN(sizeof(real_T));

  {
    real_T minValue = rtMinusInf;
    real_T maxValue = rtInf;
    ssSetModelRefInputSignalDesignMin(S,0,&minValue);
    ssSetModelRefInputSignalDesignMax(S,0,&maxValue);
  }

  {
    real_T minValue = rtMinusInf;
    real_T maxValue = rtInf;
    ssSetModelRefInputSignalDesignMin(S,1,&minValue);
    ssSetModelRefInputSignalDesignMax(S,1,&maxValue);
  }

  {
    real_T minValue = rtMinusInf;
    real_T maxValue = rtInf;
    ssSetModelRefOutputSignalDesignMin(S,0,&minValue);
    ssSetModelRefOutputSignalDesignMax(S,0,&maxValue);
  }

  {
    static ssRTWStorageType storageClass[3] = { SS_RTW_STORAGE_AUTO,
      SS_RTW_STORAGE_AUTO, SS_RTW_STORAGE_AUTO };

    ssSetModelRefPortRTWStorageClasses(S, storageClass);
  }

  ssSetNumSampleTimes(S, PORT_BASED_SAMPLE_TIMES);
  ssSetNumRWork(S, 0);
  ssSetNumIWork(S, 0);
  ssSetNumPWork(S, 0);
  ssSetNumModes(S, 0);
  ssSetNumZeroCrossingSignals(S, 0);
  ssSetOutputPortIsNonContinuous(S, 0, 0);
  ssSetOutputPortIsFedByBlockWithModesNoZCs(S, 0, 0);
  ssSetInputPortIsNotDerivPort(S, 0, 1);
  ssSetInputPortIsNotDerivPort(S, 1, 1);
  ssSetModelReferenceSampleTimeInheritanceRule(S,
    DISALLOW_SAMPLE_TIME_INHERITANCE);
  ssSetOptimizeModelRefInitCode(S, 0);
  ssSetModelReferenceNormalModeSupport(S, MDL_START_AND_MDL_PROCESS_PARAMS_OK);
  ssSetOptions(S, SS_OPTION_EXCEPTION_FREE_CODE |
               SS_OPTION_DISALLOW_CONSTANT_SAMPLE_TIME |
               SS_OPTION_SUPPORTS_ALIAS_DATA_TYPES |
               SS_OPTION_WORKS_WITH_CODE_REUSE |
               SS_OPTION_CALL_TERMINATE_ON_EXIT);
  if (S->mdlInfo->genericFcn != NULL) {
    ssRegModelRefChildModel(S,1,childModels);
  }

#if SS_SFCN_FOR_SIM

  if (S->mdlInfo->genericFcn != NULL &&
      ssGetSimMode(S) != SS_SIMMODE_SIZES_CALL_ONLY) {
    mr_vdmultRM_MdlInfoRegFcn(S, "vdmultRM");
  }

#endif

  if (!ssSetNumDWork(S, 1)) {
    return;
  }

#if SS_SFCN_FOR_SIM

  {
    int mdlrefDWTypeId;
    ssRegMdlRefDWorkType(S, &mdlrefDWTypeId);
    if (mdlrefDWTypeId == INVALID_DTYPE_ID )
      return;
    if (!ssSetDataTypeSize(S, mdlrefDWTypeId, sizeof(rtMdlrefDWork_mr_vdmultRM)))
      return;
    ssSetDWorkDataType(S, 0, mdlrefDWTypeId);
    ssSetDWorkWidth(S, 0, 1);
  }

#endif

  ssSetNeedAbsoluteTime(S, 1);
}
Ejemplo n.º 15
0
/* Registration function */
RT_MODEL_DI_model_T *DI_model(void)
{
    /* Registration code */

    /* initialize non-finites */
    rt_InitInfAndNaN(sizeof(real_T));

    /* initialize real-time model */
    (void) memset((void *)DI_model_M, 0,
                  sizeof(RT_MODEL_DI_model_T));

    {
        /* Setup solver object */
        rtsiSetSimTimeStepPtr(&DI_model_M->solverInfo,
                              &DI_model_M->Timing.simTimeStep);
        rtsiSetTPtr(&DI_model_M->solverInfo, &rtmGetTPtr(DI_model_M));
        rtsiSetStepSizePtr(&DI_model_M->solverInfo, &DI_model_M->Timing.stepSize0);
        rtsiSetErrorStatusPtr(&DI_model_M->solverInfo, (&rtmGetErrorStatus
                              (DI_model_M)));
        rtsiSetRTModelPtr(&DI_model_M->solverInfo, DI_model_M);
    }

    rtsiSetSimTimeStep(&DI_model_M->solverInfo, MAJOR_TIME_STEP);
    rtsiSetSolverName(&DI_model_M->solverInfo,"FixedStepDiscrete");
    DI_model_M->solverInfoPtr = (&DI_model_M->solverInfo);

    /* Initialize timing info */
    {
        int_T *mdlTsMap = DI_model_M->Timing.sampleTimeTaskIDArray;
        mdlTsMap[0] = 0;
        mdlTsMap[1] = 1;
        DI_model_M->Timing.sampleTimeTaskIDPtr = (&mdlTsMap[0]);
        DI_model_M->Timing.sampleTimes = (&DI_model_M->Timing.sampleTimesArray[0]);
        DI_model_M->Timing.offsetTimes = (&DI_model_M->Timing.offsetTimesArray[0]);

        /* task periods */
        DI_model_M->Timing.sampleTimes[0] = (0.0);
        DI_model_M->Timing.sampleTimes[1] = (0.01);

        /* task offsets */
        DI_model_M->Timing.offsetTimes[0] = (0.0);
        DI_model_M->Timing.offsetTimes[1] = (0.0);
    }

    rtmSetTPtr(DI_model_M, &DI_model_M->Timing.tArray[0]);

    {
        int_T *mdlSampleHits = DI_model_M->Timing.sampleHitArray;
        mdlSampleHits[0] = 1;
        mdlSampleHits[1] = 1;
        DI_model_M->Timing.sampleHits = (&mdlSampleHits[0]);
    }

    rtmSetTFinal(DI_model_M, 30.0);
    DI_model_M->Timing.stepSize0 = 0.01;
    DI_model_M->Timing.stepSize1 = 0.01;

    /* External mode info */
    DI_model_M->Sizes.checksums[0] = (643900350U);
    DI_model_M->Sizes.checksums[1] = (2770069371U);
    DI_model_M->Sizes.checksums[2] = (2746067867U);
    DI_model_M->Sizes.checksums[3] = (3163517665U);

    {
        static const sysRanDType rtAlwaysEnabled = SUBSYS_RAN_BC_ENABLE;
        static RTWExtModeInfo rt_ExtModeInfo;
        static const sysRanDType *systemRan[1];
        DI_model_M->extModeInfo = (&rt_ExtModeInfo);
        rteiSetSubSystemActiveVectorAddresses(&rt_ExtModeInfo, systemRan);
        systemRan[0] = &rtAlwaysEnabled;
        rteiSetModelMappingInfoPtr(DI_model_M->extModeInfo,
                                   &DI_model_M->SpecialInfo.mappingInfo);
        rteiSetChecksumsPtr(DI_model_M->extModeInfo, DI_model_M->Sizes.checksums);
        rteiSetTPtr(DI_model_M->extModeInfo, rtmGetTPtr(DI_model_M));
    }

    DI_model_M->solverInfoPtr = (&DI_model_M->solverInfo);
    DI_model_M->Timing.stepSize = (0.01);
    rtsiSetFixedStepSize(&DI_model_M->solverInfo, 0.01);
    rtsiSetSolverMode(&DI_model_M->solverInfo, SOLVER_MODE_SINGLETASKING);

    /* states (dwork) */
    DI_model_M->ModelData.dwork = ((void *) &DI_model_DW);
    (void) memset((void *)&DI_model_DW, 0,
                  sizeof(DW_DI_model_T));

    /* data type transition information */
    {
        static DataTypeTransInfo dtInfo;
        (void) memset((char_T *) &dtInfo, 0,
                      sizeof(dtInfo));
        DI_model_M->SpecialInfo.mappingInfo = (&dtInfo);
        dtInfo.numDataTypes = 14;
        dtInfo.dataTypeSizes = &rtDataTypeSizes[0];
        dtInfo.dataTypeNames = &rtDataTypeNames[0];

        /* Block I/O transition table */
        dtInfo.B = &rtBTransTable;
    }

    /* child S-Function registration */
    {
        RTWSfcnInfo *sfcnInfo = &DI_model_M->NonInlinedSFcns.sfcnInfo;
        DI_model_M->sfcnInfo = (sfcnInfo);
        rtssSetErrorStatusPtr(sfcnInfo, (&rtmGetErrorStatus(DI_model_M)));
        rtssSetNumRootSampTimesPtr(sfcnInfo, &DI_model_M->Sizes.numSampTimes);
        DI_model_M->NonInlinedSFcns.taskTimePtrs[0] = &(rtmGetTPtr(DI_model_M)[0]);
        DI_model_M->NonInlinedSFcns.taskTimePtrs[1] = &(rtmGetTPtr(DI_model_M)[1]);
        rtssSetTPtrPtr(sfcnInfo,DI_model_M->NonInlinedSFcns.taskTimePtrs);
        rtssSetTStartPtr(sfcnInfo, &rtmGetTStart(DI_model_M));
        rtssSetTFinalPtr(sfcnInfo, &rtmGetTFinal(DI_model_M));
        rtssSetTimeOfLastOutputPtr(sfcnInfo, &rtmGetTimeOfLastOutput(DI_model_M));
        rtssSetStepSizePtr(sfcnInfo, &DI_model_M->Timing.stepSize);
        rtssSetStopRequestedPtr(sfcnInfo, &rtmGetStopRequested(DI_model_M));
        rtssSetDerivCacheNeedsResetPtr(sfcnInfo,
                                       &DI_model_M->ModelData.derivCacheNeedsReset);
        rtssSetZCCacheNeedsResetPtr(sfcnInfo,
                                    &DI_model_M->ModelData.zCCacheNeedsReset);
        rtssSetBlkStateChangePtr(sfcnInfo, &DI_model_M->ModelData.blkStateChange);
        rtssSetSampleHitsPtr(sfcnInfo, &DI_model_M->Timing.sampleHits);
        rtssSetPerTaskSampleHitsPtr(sfcnInfo, &DI_model_M->Timing.perTaskSampleHits);
        rtssSetSimModePtr(sfcnInfo, &DI_model_M->simMode);
        rtssSetSolverInfoPtr(sfcnInfo, &DI_model_M->solverInfoPtr);
    }

    DI_model_M->Sizes.numSFcns = (1);

    /* register each child */
    {
        (void) memset((void *)&DI_model_M->NonInlinedSFcns.childSFunctions[0], 0,
                      1*sizeof(SimStruct));
        DI_model_M->childSfunctions =
            (&DI_model_M->NonInlinedSFcns.childSFunctionPtrs[0]);
        DI_model_M->childSfunctions[0] =
            (&DI_model_M->NonInlinedSFcns.childSFunctions[0]);

        /* Level2 S-Function Block: DI_model/<Root>/S-Function (DI_v1) */
        {
            SimStruct *rts = DI_model_M->childSfunctions[0];

            /* timing info */
            time_T *sfcnPeriod = DI_model_M->NonInlinedSFcns.Sfcn0.sfcnPeriod;
            time_T *sfcnOffset = DI_model_M->NonInlinedSFcns.Sfcn0.sfcnOffset;
            int_T *sfcnTsMap = DI_model_M->NonInlinedSFcns.Sfcn0.sfcnTsMap;
            (void) memset((void*)sfcnPeriod, 0,
                          sizeof(time_T)*1);
            (void) memset((void*)sfcnOffset, 0,
                          sizeof(time_T)*1);
            ssSetSampleTimePtr(rts, &sfcnPeriod[0]);
            ssSetOffsetTimePtr(rts, &sfcnOffset[0]);
            ssSetSampleTimeTaskIDPtr(rts, sfcnTsMap);

            /* Set up the mdlInfo pointer */
            {
                ssSetBlkInfo2Ptr(rts, &DI_model_M->NonInlinedSFcns.blkInfo2[0]);
            }

            ssSetRTWSfcnInfo(rts, DI_model_M->sfcnInfo);

            /* Allocate memory of model methods 2 */
            {
                ssSetModelMethods2(rts, &DI_model_M->NonInlinedSFcns.methods2[0]);
            }

            /* Allocate memory of model methods 3 */
            {
                ssSetModelMethods3(rts, &DI_model_M->NonInlinedSFcns.methods3[0]);
            }

            /* Allocate memory for states auxilliary information */
            {
                ssSetStatesInfo2(rts, &DI_model_M->NonInlinedSFcns.statesInfo2[0]);
            }

            /* inputs */
            {
                _ssSetNumInputPorts(rts, 1);
                ssSetPortInfoForInputs(rts,
                                       &DI_model_M->NonInlinedSFcns.Sfcn0.inputPortInfo[0]);

                /* port 0 */
                {
                    ssSetInputPortRequiredContiguous(rts, 0, 1);
                    ssSetInputPortSignal(rts, 0, (real_T*)&DI_model_RGND);
                    _ssSetInputPortNumDimensions(rts, 0, 1);
                    ssSetInputPortWidth(rts, 0, 1);
                }
            }

            /* path info */
            ssSetModelName(rts, "S-Function");
            ssSetPath(rts, "DI_model/S-Function");
            ssSetRTModel(rts,DI_model_M);
            ssSetParentSS(rts, (NULL));
            ssSetRootSS(rts, rts);
            ssSetVersion(rts, SIMSTRUCT_VERSION_LEVEL2);

            /* work vectors */
            ssSetIWork(rts, (int_T *) &DI_model_DW.SFunction_IWORK);

            {
                struct _ssDWorkRecord *dWorkRecord = (struct _ssDWorkRecord *)
                                                     &DI_model_M->NonInlinedSFcns.Sfcn0.dWork;
                struct _ssDWorkAuxRecord *dWorkAuxRecord = (struct _ssDWorkAuxRecord *)
                        &DI_model_M->NonInlinedSFcns.Sfcn0.dWorkAux;
                ssSetSFcnDWork(rts, dWorkRecord);
                ssSetSFcnDWorkAux(rts, dWorkAuxRecord);
                _ssSetNumDWork(rts, 1);

                /* IWORK */
                ssSetDWorkWidth(rts, 0, 1);
                ssSetDWorkDataType(rts, 0,SS_INTEGER);
                ssSetDWorkComplexSignal(rts, 0, 0);
                ssSetDWork(rts, 0, &DI_model_DW.SFunction_IWORK);
            }

            /* registration */
            DI_v1(rts);
            sfcnInitializeSizes(rts);
            sfcnInitializeSampleTimes(rts);

            /* adjust sample time */
            ssSetSampleTime(rts, 0, 0.0);
            ssSetOffsetTime(rts, 0, 0.0);
            sfcnTsMap[0] = 0;

            /* set compiled values of dynamic vector attributes */
            ssSetNumNonsampledZCs(rts, 0);

            /* Update connectivity flags for each port */
            _ssSetInputPortConnected(rts, 0, 0);

            /* Update the BufferDstPort flags for each input port */
            ssSetInputPortBufferDstPort(rts, 0, -1);
        }
    }

    /* Initialize Sizes */
    DI_model_M->Sizes.numContStates = (0);/* Number of continuous states */
    DI_model_M->Sizes.numY = (0);        /* Number of model outputs */
    DI_model_M->Sizes.numU = (0);        /* Number of model inputs */
    DI_model_M->Sizes.sysDirFeedThru = (0);/* The model is not direct feedthrough */
    DI_model_M->Sizes.numSampTimes = (2);/* Number of sample times */
    DI_model_M->Sizes.numBlocks = (1);   /* Number of blocks */
    return DI_model_M;
}
Ejemplo n.º 16
0
/* Function: mdlInitializeSizes ===============================================
 * Abstract:
 *    The sizes information is used by Simulink to determine the S-function
 *    block's characteristics (number of inputs, outputs, states, etc.).
 */
static void mdlInitializeSizes(SimStruct *S)
{
    /* See sfuntmpl_doc.c for more details on the macros below */

    ssSetNumSFcnParams(S, 0);  /* Number of expected parameters */
    if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
        /* Return if number of expected != number of actual parameters */
        return;
    }

    ssSetNumContStates(S, 0);
    ssSetNumDiscStates(S, 0);

    if (!ssSetNumInputPorts(S, NUM_INPUT)) return;
    
    
    //ssSetInputPortWidth(S, INPUT_PARTICLE, INPUT_PARTICLE_WIDTH);

    
    /* SHARED MEMORY */
    /* pmd_data */
    ssSetInputPortWidth(S, INPUT_PMD_DATA, 2);
    ssSetInputPortDataType(S, INPUT_PMD_DATA, SS_UINT32);
    
    /* POSITION */
    ssSetInputPortWidth(S, INPUT_POSITION, 3);
    //ssSetInputPortDataType(S, INPUT_ALTITUDE, SS_UINT32);
    
    /* DCM */
    ssSetInputPortWidth(S, INPUT_DCM, 9);
    
    /* Walls */
    ssSetInputPortWidth(S, INPUT_WALLS, 47*9);
    
    /* Measured Velocity */
    ssSetInputPortWidth(S, INPUT_MEASURED_VELOCITY, 3);
    

    
    /* general settings for input ports */
    int i = 0;
    for ( i=0; i < NUM_INPUT; i++) {
        /*direct input signal access*/
        ssSetInputPortRequiredContiguous(S, i, true);
        /*
        * Set direct feedthrough flag (1=yes, 0=no).
        * A port has direct feedthrough if the input is used in either
        * the mdlOutputs or mdlGetTimeOfNextVarHit functions.
        * See matlabroot/simulink/src/sfuntmpl_directfeed.txt.
        */
        ssSetInputPortDirectFeedThrough(S, i, 1);
    }
    
    
    
    if (!ssSetNumOutputPorts(S, NUM_OUTPUT)) return;
    
    //ssSetOutputPortMatrixDimensions(S, OUTPUT_UAVENV, OUTPUT_UAVENV_HEIGHT, OUTPUT_UAVENV_WIDTH);
    // The data type of an output port is double(real_t) by default - and thats perfectly fine here.
    

    ssSetNumSampleTimes(S, 1);
    ssSetNumRWork(S, 0);
    ssSetNumIWork(S, 0);
    ssSetNumPWork(S, 0);
    ssSetNumModes(S, 0);
    ssSetNumNonsampledZCs(S, 0);

    ssSetOptions(S, 0);
    
    ssSetNumDWork(S,1);
    ssSetDWorkWidth(S,0,1);
    
}
Ejemplo n.º 17
0
/* Registration function */
RT_MODEL_RA4_student_T *RA4_student(void)
{
  /* Registration code */

  /* initialize non-finites */
  rt_InitInfAndNaN(sizeof(real_T));

  /* initialize real-time model */
  (void) memset((void *)RA4_student_M, 0,
                sizeof(RT_MODEL_RA4_student_T));

  {
    /* Setup solver object */
    rtsiSetSimTimeStepPtr(&RA4_student_M->solverInfo,
                          &RA4_student_M->Timing.simTimeStep);
    rtsiSetTPtr(&RA4_student_M->solverInfo, &rtmGetTPtr(RA4_student_M));
    rtsiSetStepSizePtr(&RA4_student_M->solverInfo,
                       &RA4_student_M->Timing.stepSize0);
    rtsiSetErrorStatusPtr(&RA4_student_M->solverInfo, (&rtmGetErrorStatus
      (RA4_student_M)));
    rtsiSetRTModelPtr(&RA4_student_M->solverInfo, RA4_student_M);
  }

  rtsiSetSimTimeStep(&RA4_student_M->solverInfo, MAJOR_TIME_STEP);
  rtsiSetSolverName(&RA4_student_M->solverInfo,"FixedStepDiscrete");
  RA4_student_M->solverInfoPtr = (&RA4_student_M->solverInfo);

  /* Initialize timing info */
  {
    int_T *mdlTsMap = RA4_student_M->Timing.sampleTimeTaskIDArray;
    mdlTsMap[0] = 0;
    mdlTsMap[1] = 1;
    RA4_student_M->Timing.sampleTimeTaskIDPtr = (&mdlTsMap[0]);
    RA4_student_M->Timing.sampleTimes = (&RA4_student_M->
      Timing.sampleTimesArray[0]);
    RA4_student_M->Timing.offsetTimes = (&RA4_student_M->
      Timing.offsetTimesArray[0]);

    /* task periods */
    RA4_student_M->Timing.sampleTimes[0] = (0.0);
    RA4_student_M->Timing.sampleTimes[1] = (0.000244140625);

    /* task offsets */
    RA4_student_M->Timing.offsetTimes[0] = (0.0);
    RA4_student_M->Timing.offsetTimes[1] = (0.0);
  }

  rtmSetTPtr(RA4_student_M, &RA4_student_M->Timing.tArray[0]);

  {
    int_T *mdlSampleHits = RA4_student_M->Timing.sampleHitArray;
    mdlSampleHits[0] = 1;
    mdlSampleHits[1] = 1;
    RA4_student_M->Timing.sampleHits = (&mdlSampleHits[0]);
  }

  rtmSetTFinal(RA4_student_M, 1000.0);
  RA4_student_M->Timing.stepSize0 = 0.000244140625;
  RA4_student_M->Timing.stepSize1 = 0.000244140625;

  /* Setup for data logging */
  {
    static RTWLogInfo rt_DataLoggingInfo;
    rt_DataLoggingInfo.loggingInterval = NULL;
    RA4_student_M->rtwLogInfo = &rt_DataLoggingInfo;
  }

  /* Setup for data logging */
  {
    rtliSetLogXSignalInfo(RA4_student_M->rtwLogInfo, (NULL));
    rtliSetLogXSignalPtrs(RA4_student_M->rtwLogInfo, (NULL));
    rtliSetLogT(RA4_student_M->rtwLogInfo, "tout");
    rtliSetLogX(RA4_student_M->rtwLogInfo, "");
    rtliSetLogXFinal(RA4_student_M->rtwLogInfo, "");
    rtliSetLogVarNameModifier(RA4_student_M->rtwLogInfo, "rt_");
    rtliSetLogFormat(RA4_student_M->rtwLogInfo, 0);
    rtliSetLogMaxRows(RA4_student_M->rtwLogInfo, 0);
    rtliSetLogDecimation(RA4_student_M->rtwLogInfo, 1);
    rtliSetLogY(RA4_student_M->rtwLogInfo, "");
    rtliSetLogYSignalInfo(RA4_student_M->rtwLogInfo, (NULL));
    rtliSetLogYSignalPtrs(RA4_student_M->rtwLogInfo, (NULL));
  }

  /* External mode info */
  RA4_student_M->Sizes.checksums[0] = (2785597085U);
  RA4_student_M->Sizes.checksums[1] = (79388889U);
  RA4_student_M->Sizes.checksums[2] = (3150282079U);
  RA4_student_M->Sizes.checksums[3] = (1201550713U);

  {
    static const sysRanDType rtAlwaysEnabled = SUBSYS_RAN_BC_ENABLE;
    static RTWExtModeInfo rt_ExtModeInfo;
    static const sysRanDType *systemRan[2];
    RA4_student_M->extModeInfo = (&rt_ExtModeInfo);
    rteiSetSubSystemActiveVectorAddresses(&rt_ExtModeInfo, systemRan);
    systemRan[0] = &rtAlwaysEnabled;
    systemRan[1] = (sysRanDType *)&RA4_student_DW.Controller_SubsysRanBC;
    rteiSetModelMappingInfoPtr(RA4_student_M->extModeInfo,
      &RA4_student_M->SpecialInfo.mappingInfo);
    rteiSetChecksumsPtr(RA4_student_M->extModeInfo,
                        RA4_student_M->Sizes.checksums);
    rteiSetTPtr(RA4_student_M->extModeInfo, rtmGetTPtr(RA4_student_M));
  }

  RA4_student_M->solverInfoPtr = (&RA4_student_M->solverInfo);
  RA4_student_M->Timing.stepSize = (0.000244140625);
  rtsiSetFixedStepSize(&RA4_student_M->solverInfo, 0.000244140625);
  rtsiSetSolverMode(&RA4_student_M->solverInfo, SOLVER_MODE_SINGLETASKING);

  /* block I/O */
  RA4_student_M->ModelData.blockIO = ((void *) &RA4_student_B);
  (void) memset(((void *) &RA4_student_B), 0,
                sizeof(B_RA4_student_T));

  {
    RA4_student_B.UnitDelay2[0] = 0.0;
    RA4_student_B.UnitDelay2[1] = 0.0;
    RA4_student_B.UnitDelay2[2] = 0.0;
    RA4_student_B.UnitDelay1 = 0.0;
    RA4_student_B.RobotArm_sfcn_o1 = 0.0;
    RA4_student_B.RobotArm_sfcn_o2[0] = 0.0;
    RA4_student_B.RobotArm_sfcn_o2[1] = 0.0;
    RA4_student_B.RobotArm_sfcn_o2[2] = 0.0;
    RA4_student_B.RobotArm_sfcn_o4 = 0.0;
    RA4_student_B.Sum4 = 0.0;
    RA4_student_B.Sum5 = 0.0;
    RA4_student_B.Sum6 = 0.0;
    RA4_student_B.ReferenceSolenoid = 0.0;
    RA4_student_B.SFunction[0] = 0.0;
    RA4_student_B.SFunction[1] = 0.0;
    RA4_student_B.SFunction[2] = 0.0;
    RA4_student_B.SFunction[3] = 0.0;
  }

  /* parameters */
  RA4_student_M->ModelData.defaultParam = ((real_T *)&RA4_student_P);

  /* states (dwork) */
  RA4_student_M->ModelData.dwork = ((void *) &RA4_student_DW);
  (void) memset((void *)&RA4_student_DW, 0,
                sizeof(DW_RA4_student_T));
  RA4_student_DW.UnitDelay2_DSTATE[0] = 0.0;
  RA4_student_DW.UnitDelay2_DSTATE[1] = 0.0;
  RA4_student_DW.UnitDelay2_DSTATE[2] = 0.0;
  RA4_student_DW.UnitDelay1_DSTATE = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK0 = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK1 = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK2 = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK3 = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK4 = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK5 = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK6 = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK7 = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK8 = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK9 = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK10 = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK11 = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK12 = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK13 = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK14 = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK15 = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK16[0] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK16[1] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK17[0] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK17[1] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK18[0] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK18[1] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK18[2] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK18[3] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK19[0] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK19[1] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK19[2] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK19[3] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK20[0] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK20[1] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK21[0] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK21[1] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK21[2] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK21[3] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK22[0] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK22[1] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK22[2] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK22[3] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK23[0] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK23[1] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK24[0] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK24[1] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK25[0] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK25[1] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK25[2] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK25[3] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK26[0] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK26[1] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK26[2] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK26[3] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK27[0] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK27[1] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK28[0] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK28[1] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK28[2] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK28[3] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK29[0] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK29[1] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK29[2] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK29[3] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK30[0] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK30[1] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK31[0] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK31[1] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK32[0] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK32[1] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK32[2] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK32[3] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK33[0] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK33[1] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK33[2] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK33[3] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK34[0] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK34[1] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK35[0] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK35[1] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK35[2] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK35[3] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK36[0] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK36[1] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK36[2] = 0.0;
  RA4_student_DW.RobotArm_sfcn_DWORK36[3] = 0.0;

  /* data type transition information */
  {
    static DataTypeTransInfo dtInfo;
    (void) memset((char_T *) &dtInfo, 0,
                  sizeof(dtInfo));
    RA4_student_M->SpecialInfo.mappingInfo = (&dtInfo);
    dtInfo.numDataTypes = 14;
    dtInfo.dataTypeSizes = &rtDataTypeSizes[0];
    dtInfo.dataTypeNames = &rtDataTypeNames[0];

    /* Block I/O transition table */
    dtInfo.B = &rtBTransTable;

    /* Parameters transition table */
    dtInfo.P = &rtPTransTable;
  }

  /* child S-Function registration */
  {
    RTWSfcnInfo *sfcnInfo = &RA4_student_M->NonInlinedSFcns.sfcnInfo;
    RA4_student_M->sfcnInfo = (sfcnInfo);
    rtssSetErrorStatusPtr(sfcnInfo, (&rtmGetErrorStatus(RA4_student_M)));
    rtssSetNumRootSampTimesPtr(sfcnInfo, &RA4_student_M->Sizes.numSampTimes);
    RA4_student_M->NonInlinedSFcns.taskTimePtrs[0] = &(rtmGetTPtr(RA4_student_M)
      [0]);
    RA4_student_M->NonInlinedSFcns.taskTimePtrs[1] = &(rtmGetTPtr(RA4_student_M)
      [1]);
    rtssSetTPtrPtr(sfcnInfo,RA4_student_M->NonInlinedSFcns.taskTimePtrs);
    rtssSetTStartPtr(sfcnInfo, &rtmGetTStart(RA4_student_M));
    rtssSetTFinalPtr(sfcnInfo, &rtmGetTFinal(RA4_student_M));
    rtssSetTimeOfLastOutputPtr(sfcnInfo, &rtmGetTimeOfLastOutput(RA4_student_M));
    rtssSetStepSizePtr(sfcnInfo, &RA4_student_M->Timing.stepSize);
    rtssSetStopRequestedPtr(sfcnInfo, &rtmGetStopRequested(RA4_student_M));
    rtssSetDerivCacheNeedsResetPtr(sfcnInfo,
      &RA4_student_M->ModelData.derivCacheNeedsReset);
    rtssSetZCCacheNeedsResetPtr(sfcnInfo,
      &RA4_student_M->ModelData.zCCacheNeedsReset);
    rtssSetBlkStateChangePtr(sfcnInfo, &RA4_student_M->ModelData.blkStateChange);
    rtssSetSampleHitsPtr(sfcnInfo, &RA4_student_M->Timing.sampleHits);
    rtssSetPerTaskSampleHitsPtr(sfcnInfo,
      &RA4_student_M->Timing.perTaskSampleHits);
    rtssSetSimModePtr(sfcnInfo, &RA4_student_M->simMode);
    rtssSetSolverInfoPtr(sfcnInfo, &RA4_student_M->solverInfoPtr);
  }

  RA4_student_M->Sizes.numSFcns = (2);

  /* register each child */
  {
    (void) memset((void *)&RA4_student_M->NonInlinedSFcns.childSFunctions[0], 0,
                  2*sizeof(SimStruct));
    RA4_student_M->childSfunctions =
      (&RA4_student_M->NonInlinedSFcns.childSFunctionPtrs[0]);
    RA4_student_M->childSfunctions[0] =
      (&RA4_student_M->NonInlinedSFcns.childSFunctions[0]);
    RA4_student_M->childSfunctions[1] =
      (&RA4_student_M->NonInlinedSFcns.childSFunctions[1]);

    /* Level2 S-Function Block: RA4_student/<S6>/S-Function (sf_rt_scope) */
    {
      SimStruct *rts = RA4_student_M->childSfunctions[0];

      /* timing info */
      time_T *sfcnPeriod = RA4_student_M->NonInlinedSFcns.Sfcn0.sfcnPeriod;
      time_T *sfcnOffset = RA4_student_M->NonInlinedSFcns.Sfcn0.sfcnOffset;
      int_T *sfcnTsMap = RA4_student_M->NonInlinedSFcns.Sfcn0.sfcnTsMap;
      (void) memset((void*)sfcnPeriod, 0,
                    sizeof(time_T)*1);
      (void) memset((void*)sfcnOffset, 0,
                    sizeof(time_T)*1);
      ssSetSampleTimePtr(rts, &sfcnPeriod[0]);
      ssSetOffsetTimePtr(rts, &sfcnOffset[0]);
      ssSetSampleTimeTaskIDPtr(rts, sfcnTsMap);

      /* Set up the mdlInfo pointer */
      {
        ssSetBlkInfo2Ptr(rts, &RA4_student_M->NonInlinedSFcns.blkInfo2[0]);
      }

      ssSetRTWSfcnInfo(rts, RA4_student_M->sfcnInfo);

      /* Allocate memory of model methods 2 */
      {
        ssSetModelMethods2(rts, &RA4_student_M->NonInlinedSFcns.methods2[0]);
      }

      /* Allocate memory of model methods 3 */
      {
        ssSetModelMethods3(rts, &RA4_student_M->NonInlinedSFcns.methods3[0]);
      }

      /* Allocate memory for states auxilliary information */
      {
        ssSetStatesInfo2(rts, &RA4_student_M->NonInlinedSFcns.statesInfo2[0]);
        ssSetPeriodicStatesInfo(rts,
          &RA4_student_M->NonInlinedSFcns.periodicStatesInfo[0]);
      }

      /* inputs */
      {
        _ssSetNumInputPorts(rts, 1);
        ssSetPortInfoForInputs(rts,
          &RA4_student_M->NonInlinedSFcns.Sfcn0.inputPortInfo[0]);

        /* port 0 */
        {
          real_T const **sfcnUPtrs = (real_T const **)
            &RA4_student_M->NonInlinedSFcns.Sfcn0.UPtrs0;
          sfcnUPtrs[0] = (real_T*)&RA4_student_RGND;
          sfcnUPtrs[1] = (real_T*)&RA4_student_RGND;
          sfcnUPtrs[2] = (real_T*)&RA4_student_RGND;
          sfcnUPtrs[3] = (real_T*)&RA4_student_RGND;
          sfcnUPtrs[4] = (real_T*)&RA4_student_RGND;
          sfcnUPtrs[5] = (real_T*)&RA4_student_RGND;
          sfcnUPtrs[6] = (real_T*)&RA4_student_RGND;
          sfcnUPtrs[7] = (real_T*)&RA4_student_RGND;
          ssSetInputPortSignalPtrs(rts, 0, (InputPtrsType)&sfcnUPtrs[0]);
          _ssSetInputPortNumDimensions(rts, 0, 1);
          ssSetInputPortWidth(rts, 0, 8);
        }
      }

      /* outputs */
      {
        ssSetPortInfoForOutputs(rts,
          &RA4_student_M->NonInlinedSFcns.Sfcn0.outputPortInfo[0]);
        _ssSetNumOutputPorts(rts, 1);

        /* port 0 */
        {
          _ssSetOutputPortNumDimensions(rts, 0, 1);
          ssSetOutputPortWidth(rts, 0, 4);
          ssSetOutputPortSignal(rts, 0, ((real_T *) RA4_student_B.SFunction));
        }
      }

      /* path info */
      ssSetModelName(rts, "S-Function");
      ssSetPath(rts, "RA4_student/Controller/RTScope/S-Function");
      ssSetRTModel(rts,RA4_student_M);
      ssSetParentSS(rts, (NULL));
      ssSetRootSS(rts, rts);
      ssSetVersion(rts, SIMSTRUCT_VERSION_LEVEL2);

      /* parameters */
      {
        mxArray **sfcnParams = (mxArray **)
          &RA4_student_M->NonInlinedSFcns.Sfcn0.params;
        ssSetSFcnParamsCount(rts, 1);
        ssSetSFcnParamsPtr(rts, &sfcnParams[0]);
        ssSetSFcnParam(rts, 0, (mxArray*)RA4_student_P.SFunction_P1_Size);
      }

      /* registration */
      sf_rt_scope(rts);
      sfcnInitializeSizes(rts);
      sfcnInitializeSampleTimes(rts);

      /* adjust sample time */
      ssSetSampleTime(rts, 0, 0.0);
      ssSetOffsetTime(rts, 0, 0.0);
      sfcnTsMap[0] = 0;

      /* set compiled values of dynamic vector attributes */
      ssSetNumNonsampledZCs(rts, 0);

      /* Update connectivity flags for each port */
      _ssSetInputPortConnected(rts, 0, 1);
      _ssSetOutputPortConnected(rts, 0, 1);
      _ssSetOutputPortBeingMerged(rts, 0, 0);

      /* Update the BufferDstPort flags for each input port */
      ssSetInputPortBufferDstPort(rts, 0, -1);
    }

    /* RTW Generated Level2 S-Function Block: RA4_student/<S2>/Robot Arm_sfcn (Robot_sf) */
    {
      SimStruct *rts = RA4_student_M->childSfunctions[1];

      /* timing info */
      time_T *sfcnPeriod = RA4_student_M->NonInlinedSFcns.Sfcn1.sfcnPeriod;
      time_T *sfcnOffset = RA4_student_M->NonInlinedSFcns.Sfcn1.sfcnOffset;
      int_T *sfcnTsMap = RA4_student_M->NonInlinedSFcns.Sfcn1.sfcnTsMap;
      (void) memset((void*)sfcnPeriod, 0,
                    sizeof(time_T)*2);
      (void) memset((void*)sfcnOffset, 0,
                    sizeof(time_T)*2);
      ssSetSampleTimePtr(rts, &sfcnPeriod[0]);
      ssSetOffsetTimePtr(rts, &sfcnOffset[0]);
      ssSetSampleTimeTaskIDPtr(rts, sfcnTsMap);

      /* Set up the mdlInfo pointer */
      {
        ssSetBlkInfo2Ptr(rts, &RA4_student_M->NonInlinedSFcns.blkInfo2[1]);
      }

      ssSetRTWSfcnInfo(rts, RA4_student_M->sfcnInfo);

      /* Allocate memory of model methods 2 */
      {
        ssSetModelMethods2(rts, &RA4_student_M->NonInlinedSFcns.methods2[1]);
      }

      /* Allocate memory of model methods 3 */
      {
        ssSetModelMethods3(rts, &RA4_student_M->NonInlinedSFcns.methods3[1]);
      }

      /* Allocate memory for states auxilliary information */
      {
        ssSetStatesInfo2(rts, &RA4_student_M->NonInlinedSFcns.statesInfo2[1]);
        ssSetPeriodicStatesInfo(rts,
          &RA4_student_M->NonInlinedSFcns.periodicStatesInfo[1]);
      }

      /* inputs */
      {
        _ssSetNumInputPorts(rts, 2);
        ssSetPortInfoForInputs(rts,
          &RA4_student_M->NonInlinedSFcns.Sfcn1.inputPortInfo[0]);

        /* port 0 */
        {
          real_T const **sfcnUPtrs = (real_T const **)
            &RA4_student_M->NonInlinedSFcns.Sfcn1.UPtrs0;
          sfcnUPtrs[0] = RA4_student_B.UnitDelay2;
          sfcnUPtrs[1] = &RA4_student_B.UnitDelay2[1];
          sfcnUPtrs[2] = &RA4_student_B.UnitDelay2[2];
          ssSetInputPortSignalPtrs(rts, 0, (InputPtrsType)&sfcnUPtrs[0]);
          _ssSetInputPortNumDimensions(rts, 0, 1);
          ssSetInputPortWidth(rts, 0, 3);
        }

        /* port 1 */
        {
          real_T const **sfcnUPtrs = (real_T const **)
            &RA4_student_M->NonInlinedSFcns.Sfcn1.UPtrs1;
          sfcnUPtrs[0] = &RA4_student_B.UnitDelay1;
          ssSetInputPortSignalPtrs(rts, 1, (InputPtrsType)&sfcnUPtrs[0]);
          _ssSetInputPortNumDimensions(rts, 1, 1);
          ssSetInputPortWidth(rts, 1, 1);
        }
      }

      /* outputs */
      {
        ssSetPortInfoForOutputs(rts,
          &RA4_student_M->NonInlinedSFcns.Sfcn1.outputPortInfo[0]);
        _ssSetNumOutputPorts(rts, 4);

        /* port 0 */
        {
          _ssSetOutputPortNumDimensions(rts, 0, 1);
          ssSetOutputPortWidth(rts, 0, 1);
          ssSetOutputPortSignal(rts, 0, ((real_T *)
            &RA4_student_B.RobotArm_sfcn_o1));
        }

        /* port 1 */
        {
          _ssSetOutputPortNumDimensions(rts, 1, 1);
          ssSetOutputPortWidth(rts, 1, 3);
          ssSetOutputPortSignal(rts, 1, ((real_T *)
            RA4_student_B.RobotArm_sfcn_o2));
        }

        /* port 2 */
        {
          _ssSetOutputPortNumDimensions(rts, 2, 1);
          ssSetOutputPortWidth(rts, 2, 3);
          ssSetOutputPortSignal(rts, 2, ((boolean_T *)
            RA4_student_B.RobotArm_sfcn_o3));
        }

        /* port 3 */
        {
          _ssSetOutputPortNumDimensions(rts, 3, 1);
          ssSetOutputPortWidth(rts, 3, 1);
          ssSetOutputPortSignal(rts, 3, ((real_T *)
            &RA4_student_B.RobotArm_sfcn_o4));
        }
      }

      /* path info */
      ssSetModelName(rts, "Robot Arm_sfcn");
      ssSetPath(rts, "RA4_student/Robot Arm1/Robot Arm_sfcn");
      ssSetRTModel(rts,RA4_student_M);
      ssSetParentSS(rts, (NULL));
      ssSetRootSS(rts, rts);
      ssSetVersion(rts, SIMSTRUCT_VERSION_LEVEL2);

      /* work vectors */
      {
        struct _ssDWorkRecord *dWorkRecord = (struct _ssDWorkRecord *)
          &RA4_student_M->NonInlinedSFcns.Sfcn1.dWork;
        struct _ssDWorkAuxRecord *dWorkAuxRecord = (struct _ssDWorkAuxRecord *)
          &RA4_student_M->NonInlinedSFcns.Sfcn1.dWorkAux;
        ssSetSFcnDWork(rts, dWorkRecord);
        ssSetSFcnDWorkAux(rts, dWorkAuxRecord);
        _ssSetNumDWork(rts, 47);

        /* DWORK0 */
        ssSetDWorkWidth(rts, 0, 1);
        ssSetDWorkDataType(rts, 0,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 0, 0);
        ssSetDWorkUsedAsDState(rts, 0, 1);
        ssSetDWork(rts, 0, &RA4_student_DW.RobotArm_sfcn_DWORK0);

        /* DWORK1 */
        ssSetDWorkWidth(rts, 1, 1);
        ssSetDWorkDataType(rts, 1,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 1, 0);
        ssSetDWorkUsedAsDState(rts, 1, 1);
        ssSetDWork(rts, 1, &RA4_student_DW.RobotArm_sfcn_DWORK1);

        /* DWORK2 */
        ssSetDWorkWidth(rts, 2, 1);
        ssSetDWorkDataType(rts, 2,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 2, 0);
        ssSetDWorkUsedAsDState(rts, 2, 1);
        ssSetDWork(rts, 2, &RA4_student_DW.RobotArm_sfcn_DWORK2);

        /* DWORK3 */
        ssSetDWorkWidth(rts, 3, 1);
        ssSetDWorkDataType(rts, 3,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 3, 0);
        ssSetDWorkUsedAsDState(rts, 3, 1);
        ssSetDWork(rts, 3, &RA4_student_DW.RobotArm_sfcn_DWORK3);

        /* DWORK4 */
        ssSetDWorkWidth(rts, 4, 1);
        ssSetDWorkDataType(rts, 4,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 4, 0);
        ssSetDWorkUsedAsDState(rts, 4, 1);
        ssSetDWork(rts, 4, &RA4_student_DW.RobotArm_sfcn_DWORK4);

        /* DWORK5 */
        ssSetDWorkWidth(rts, 5, 1);
        ssSetDWorkDataType(rts, 5,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 5, 0);
        ssSetDWorkUsedAsDState(rts, 5, 1);
        ssSetDWork(rts, 5, &RA4_student_DW.RobotArm_sfcn_DWORK5);

        /* DWORK6 */
        ssSetDWorkWidth(rts, 6, 1);
        ssSetDWorkDataType(rts, 6,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 6, 0);
        ssSetDWorkUsedAsDState(rts, 6, 1);
        ssSetDWork(rts, 6, &RA4_student_DW.RobotArm_sfcn_DWORK6);

        /* DWORK7 */
        ssSetDWorkWidth(rts, 7, 1);
        ssSetDWorkDataType(rts, 7,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 7, 0);
        ssSetDWorkUsedAsDState(rts, 7, 1);
        ssSetDWork(rts, 7, &RA4_student_DW.RobotArm_sfcn_DWORK7);

        /* DWORK8 */
        ssSetDWorkWidth(rts, 8, 1);
        ssSetDWorkDataType(rts, 8,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 8, 0);
        ssSetDWorkUsedAsDState(rts, 8, 1);
        ssSetDWork(rts, 8, &RA4_student_DW.RobotArm_sfcn_DWORK8);

        /* DWORK9 */
        ssSetDWorkWidth(rts, 9, 1);
        ssSetDWorkDataType(rts, 9,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 9, 0);
        ssSetDWorkUsedAsDState(rts, 9, 1);
        ssSetDWork(rts, 9, &RA4_student_DW.RobotArm_sfcn_DWORK9);

        /* DWORK10 */
        ssSetDWorkWidth(rts, 10, 1);
        ssSetDWorkDataType(rts, 10,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 10, 0);
        ssSetDWork(rts, 10, &RA4_student_DW.RobotArm_sfcn_DWORK10);

        /* DWORK11 */
        ssSetDWorkWidth(rts, 11, 1);
        ssSetDWorkDataType(rts, 11,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 11, 0);
        ssSetDWork(rts, 11, &RA4_student_DW.RobotArm_sfcn_DWORK11);

        /* DWORK12 */
        ssSetDWorkWidth(rts, 12, 1);
        ssSetDWorkDataType(rts, 12,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 12, 0);
        ssSetDWork(rts, 12, &RA4_student_DW.RobotArm_sfcn_DWORK12);

        /* DWORK13 */
        ssSetDWorkWidth(rts, 13, 1);
        ssSetDWorkDataType(rts, 13,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 13, 0);
        ssSetDWork(rts, 13, &RA4_student_DW.RobotArm_sfcn_DWORK13);

        /* DWORK14 */
        ssSetDWorkWidth(rts, 14, 1);
        ssSetDWorkDataType(rts, 14,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 14, 0);
        ssSetDWork(rts, 14, &RA4_student_DW.RobotArm_sfcn_DWORK14);

        /* DWORK15 */
        ssSetDWorkWidth(rts, 15, 1);
        ssSetDWorkDataType(rts, 15,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 15, 0);
        ssSetDWork(rts, 15, &RA4_student_DW.RobotArm_sfcn_DWORK15);

        /* DWORK16 */
        ssSetDWorkWidth(rts, 16, 2);
        ssSetDWorkDataType(rts, 16,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 16, 0);
        ssSetDWork(rts, 16, &RA4_student_DW.RobotArm_sfcn_DWORK16[0]);

        /* DWORK17 */
        ssSetDWorkWidth(rts, 17, 2);
        ssSetDWorkDataType(rts, 17,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 17, 0);
        ssSetDWork(rts, 17, &RA4_student_DW.RobotArm_sfcn_DWORK17[0]);

        /* DWORK18 */
        ssSetDWorkWidth(rts, 18, 4);
        ssSetDWorkDataType(rts, 18,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 18, 0);
        ssSetDWork(rts, 18, &RA4_student_DW.RobotArm_sfcn_DWORK18[0]);

        /* DWORK19 */
        ssSetDWorkWidth(rts, 19, 4);
        ssSetDWorkDataType(rts, 19,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 19, 0);
        ssSetDWork(rts, 19, &RA4_student_DW.RobotArm_sfcn_DWORK19[0]);

        /* DWORK20 */
        ssSetDWorkWidth(rts, 20, 2);
        ssSetDWorkDataType(rts, 20,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 20, 0);
        ssSetDWork(rts, 20, &RA4_student_DW.RobotArm_sfcn_DWORK20[0]);

        /* DWORK21 */
        ssSetDWorkWidth(rts, 21, 4);
        ssSetDWorkDataType(rts, 21,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 21, 0);
        ssSetDWork(rts, 21, &RA4_student_DW.RobotArm_sfcn_DWORK21[0]);

        /* DWORK22 */
        ssSetDWorkWidth(rts, 22, 4);
        ssSetDWorkDataType(rts, 22,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 22, 0);
        ssSetDWork(rts, 22, &RA4_student_DW.RobotArm_sfcn_DWORK22[0]);

        /* DWORK23 */
        ssSetDWorkWidth(rts, 23, 2);
        ssSetDWorkDataType(rts, 23,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 23, 0);
        ssSetDWork(rts, 23, &RA4_student_DW.RobotArm_sfcn_DWORK23[0]);

        /* DWORK24 */
        ssSetDWorkWidth(rts, 24, 2);
        ssSetDWorkDataType(rts, 24,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 24, 0);
        ssSetDWork(rts, 24, &RA4_student_DW.RobotArm_sfcn_DWORK24[0]);

        /* DWORK25 */
        ssSetDWorkWidth(rts, 25, 4);
        ssSetDWorkDataType(rts, 25,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 25, 0);
        ssSetDWork(rts, 25, &RA4_student_DW.RobotArm_sfcn_DWORK25[0]);

        /* DWORK26 */
        ssSetDWorkWidth(rts, 26, 4);
        ssSetDWorkDataType(rts, 26,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 26, 0);
        ssSetDWork(rts, 26, &RA4_student_DW.RobotArm_sfcn_DWORK26[0]);

        /* DWORK27 */
        ssSetDWorkWidth(rts, 27, 2);
        ssSetDWorkDataType(rts, 27,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 27, 0);
        ssSetDWork(rts, 27, &RA4_student_DW.RobotArm_sfcn_DWORK27[0]);

        /* DWORK28 */
        ssSetDWorkWidth(rts, 28, 4);
        ssSetDWorkDataType(rts, 28,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 28, 0);
        ssSetDWork(rts, 28, &RA4_student_DW.RobotArm_sfcn_DWORK28[0]);

        /* DWORK29 */
        ssSetDWorkWidth(rts, 29, 4);
        ssSetDWorkDataType(rts, 29,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 29, 0);
        ssSetDWork(rts, 29, &RA4_student_DW.RobotArm_sfcn_DWORK29[0]);

        /* DWORK30 */
        ssSetDWorkWidth(rts, 30, 2);
        ssSetDWorkDataType(rts, 30,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 30, 0);
        ssSetDWork(rts, 30, &RA4_student_DW.RobotArm_sfcn_DWORK30[0]);

        /* DWORK31 */
        ssSetDWorkWidth(rts, 31, 2);
        ssSetDWorkDataType(rts, 31,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 31, 0);
        ssSetDWork(rts, 31, &RA4_student_DW.RobotArm_sfcn_DWORK31[0]);

        /* DWORK32 */
        ssSetDWorkWidth(rts, 32, 4);
        ssSetDWorkDataType(rts, 32,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 32, 0);
        ssSetDWork(rts, 32, &RA4_student_DW.RobotArm_sfcn_DWORK32[0]);

        /* DWORK33 */
        ssSetDWorkWidth(rts, 33, 4);
        ssSetDWorkDataType(rts, 33,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 33, 0);
        ssSetDWork(rts, 33, &RA4_student_DW.RobotArm_sfcn_DWORK33[0]);

        /* DWORK34 */
        ssSetDWorkWidth(rts, 34, 2);
        ssSetDWorkDataType(rts, 34,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 34, 0);
        ssSetDWork(rts, 34, &RA4_student_DW.RobotArm_sfcn_DWORK34[0]);

        /* DWORK35 */
        ssSetDWorkWidth(rts, 35, 4);
        ssSetDWorkDataType(rts, 35,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 35, 0);
        ssSetDWork(rts, 35, &RA4_student_DW.RobotArm_sfcn_DWORK35[0]);

        /* DWORK36 */
        ssSetDWorkWidth(rts, 36, 4);
        ssSetDWorkDataType(rts, 36,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 36, 0);
        ssSetDWork(rts, 36, &RA4_student_DW.RobotArm_sfcn_DWORK36[0]);

        /* DWORK37 */
        ssSetDWorkWidth(rts, 37, 1);
        ssSetDWorkDataType(rts, 37,SS_INT32);
        ssSetDWorkComplexSignal(rts, 37, 0);
        ssSetDWork(rts, 37, &RA4_student_DW.RobotArm_sfcn_DWORK37);

        /* DWORK38 */
        ssSetDWorkWidth(rts, 38, 1);
        ssSetDWorkDataType(rts, 38,SS_UINT16);
        ssSetDWorkComplexSignal(rts, 38, 0);
        ssSetDWork(rts, 38, &RA4_student_DW.RobotArm_sfcn_DWORK38);

        /* DWORK39 */
        ssSetDWorkWidth(rts, 39, 1);
        ssSetDWorkDataType(rts, 39,SS_UINT16);
        ssSetDWorkComplexSignal(rts, 39, 0);
        ssSetDWork(rts, 39, &RA4_student_DW.RobotArm_sfcn_DWORK39);

        /* DWORK40 */
        ssSetDWorkWidth(rts, 40, 1);
        ssSetDWorkDataType(rts, 40,SS_UINT16);
        ssSetDWorkComplexSignal(rts, 40, 0);
        ssSetDWork(rts, 40, &RA4_student_DW.RobotArm_sfcn_DWORK40);

        /* DWORK41 */
        ssSetDWorkWidth(rts, 41, 1);
        ssSetDWorkDataType(rts, 41,SS_UINT8);
        ssSetDWorkComplexSignal(rts, 41, 0);
        ssSetDWork(rts, 41, &RA4_student_DW.RobotArm_sfcn_DWORK41);

        /* DWORK42 */
        ssSetDWorkWidth(rts, 42, 1);
        ssSetDWorkDataType(rts, 42,SS_UINT8);
        ssSetDWorkComplexSignal(rts, 42, 0);
        ssSetDWork(rts, 42, &RA4_student_DW.RobotArm_sfcn_DWORK42);

        /* DWORK43 */
        ssSetDWorkWidth(rts, 43, 1);
        ssSetDWorkDataType(rts, 43,SS_UINT8);
        ssSetDWorkComplexSignal(rts, 43, 0);
        ssSetDWork(rts, 43, &RA4_student_DW.RobotArm_sfcn_DWORK43);

        /* DWORK44 */
        ssSetDWorkWidth(rts, 44, 1);
        ssSetDWorkDataType(rts, 44,SS_UINT8);
        ssSetDWorkComplexSignal(rts, 44, 0);
        ssSetDWork(rts, 44, &RA4_student_DW.RobotArm_sfcn_DWORK44);

        /* DWORK45 */
        ssSetDWorkWidth(rts, 45, 1);
        ssSetDWorkDataType(rts, 45,SS_UINT8);
        ssSetDWorkComplexSignal(rts, 45, 0);
        ssSetDWork(rts, 45, &RA4_student_DW.RobotArm_sfcn_DWORK45);

        /* DWORK46 */
        ssSetDWorkWidth(rts, 46, 1);
        ssSetDWorkDataType(rts, 46,SS_UINT8);
        ssSetDWorkComplexSignal(rts, 46, 0);
        ssSetDWork(rts, 46, &RA4_student_DW.RobotArm_sfcn_DWORK46);
      }

      /* registration */
      Robot_sf(rts);
      sfcnInitializeSizes(rts);
      sfcnInitializeSampleTimes(rts);

      /* adjust sample time */
      ssSetSampleTime(rts, 0, 0.0);
      ssSetOffsetTime(rts, 0, 0.0);
      ssSetSampleTime(rts, 1, 0.000244140625);
      ssSetOffsetTime(rts, 1, 0.0);
      sfcnTsMap[0] = 0;
      sfcnTsMap[1] = 1;

      /* set compiled values of dynamic vector attributes */
      ssSetNumNonsampledZCs(rts, 0);

      /* Update connectivity flags for each port */
      _ssSetInputPortConnected(rts, 0, 1);
      _ssSetInputPortConnected(rts, 1, 1);
      _ssSetOutputPortConnected(rts, 0, 1);
      _ssSetOutputPortConnected(rts, 1, 1);
      _ssSetOutputPortConnected(rts, 2, 1);
      _ssSetOutputPortConnected(rts, 3, 1);
      _ssSetOutputPortBeingMerged(rts, 0, 0);
      _ssSetOutputPortBeingMerged(rts, 1, 0);
      _ssSetOutputPortBeingMerged(rts, 2, 0);
      _ssSetOutputPortBeingMerged(rts, 3, 0);

      /* Update the BufferDstPort flags for each input port */
      ssSetInputPortBufferDstPort(rts, 0, -1);
      ssSetInputPortBufferDstPort(rts, 1, -1);

      /* Instance data for generated S-Function: Robot */
#include "Robot_sfcn_rtw/Robot_sid.h"

    }
  }

  /* Initialize Sizes */
  RA4_student_M->Sizes.numContStates = (0);/* Number of continuous states */
  RA4_student_M->Sizes.numY = (0);     /* Number of model outputs */
  RA4_student_M->Sizes.numU = (0);     /* Number of model inputs */
  RA4_student_M->Sizes.sysDirFeedThru = (0);/* The model is not direct feedthrough */
  RA4_student_M->Sizes.numSampTimes = (2);/* Number of sample times */
  RA4_student_M->Sizes.numBlocks = (24);/* Number of blocks */
  RA4_student_M->Sizes.numBlockIO = (11);/* Number of block outputs */
  RA4_student_M->Sizes.numBlockPrms = (16);/* Sum of parameter "widths" */
  return RA4_student_M;
}
Ejemplo n.º 18
0
/* Function: mdlInitializeSizes ===============================================
 * Abstract:
 *    The sizes information is used by Simulink to determine the S-function
 *    block's characteristics (number of inputs, outputs, states, etc.).
 */
static void mdlInitializeSizes(SimStruct *S)
{
  /* See sfuntmpl_doc.c for more details on the macros below */
    ssSetNumSFcnParams(S, 9);  /* Number of expected parameter vectors*/
    if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
        /* Return if number of expected != number of actual parameters */
        return;
    }

    //ssSetNumContStates(S, 12);
    ssSetNumDiscStates(S, 12);

    /* if (!ssSetNumInputPorts(S, 1)) return; */
	ssSetNumInputPorts(S, 1);
    ssSetInputPortWidth(S, 0, 8);//[thr ail el rud mxtr run flap gear]
    /* ssSetInputPortRequiredContiguous(S, 0, true); /*direct input signal access*/
    /*
     * Set direct feedthrough flag (1=yes, 0=no).
     * A port has direct feedthrough if the input is used in either
     * the mdlOutputs or mdlGetTimeOfNextVarHit functions.
     * See matlabroot/simulink/src/sfuntmpl_directfeed.txt.
     */
     /* ssSetInputPortDirectFeedThrough(S, 0, 1); */

    if (!ssSetNumOutputPorts(S, 6)) return;
    ssSetOutputPortWidth(S, 0, 12);//The model has 12 states:[u v w p q r h-sl-ft long lat phi theta psi]	
	
	/* Flight Controls output [thr-pos-norm left-ail-pos-rad el-pos-rad tvc-pos-rad rud-pos-rad flap-pos-norm right-ail-pos-rad 
	 * speedbrake-pos-rad spoiler-pos-rad lef-pos-rad gear-pos-norm Nose-gear-steering-pos-deg gear-unit-WOW]
	 */
	ssSetOutputPortWidth(S, 1, 13);

	/* Propulsion output piston (per engine) [prop-rpm prop-thrust-lbs mixture fuel-flow-gph advance-ratio power-hp pt-lbs_sqft 
	 * volumetric-efficiency bsfc-lbs_hphr prop-torque blade-angle prop-pitch]
	 * Propulsion output turbine (per engine) [thrust-lbs n1 n2 fuel-flow-pph fuel-flow-pps pt-lbs_sqft pitch-rad reverser-rad yaw-rad inject-cmd 
	 * set-running fuel-dump]
	 */
	ssSetOutputPortWidth(S, 2, 48);
		

	ssSetOutputPortWidth(S, 3, 11);//Calculated outputs [pilot-Nz alpha alpha-dot beta beta-dot vc-fps vc-kts 
 						           //					 Vt-fps vg-fps mach climb-rate]    
	ssSetOutputPortWidth(S, 4, 6);//JSBSim Calculated State derivatives output [u_dot v_dot w_dot p_dot q_dot r_dot]

	ssSetOutputPortWidth(S, 5, 6);//JSBSim Calculated Aerodynamic forces and monents output [X Y Z L M C]

	//ssSetNumSampleTimes(S, 1);
    if(!ssSetNumDWork(   S, 7)) return;

    ssSetDWorkWidth(     S, 0, ssGetInputPortWidth(S,0));//Work vector for input port
    ssSetDWorkDataType(  S, 0, SS_DOUBLE); /* use SS_DOUBLE if needed */

    ssSetDWorkWidth(     S, 1, ssGetNumDiscStates(S));//Work vector for states * may need to add actuator states!
    ssSetDWorkDataType(  S, 1, SS_DOUBLE);

	ssSetDWorkWidth(     S, 2, ssGetOutputPortWidth(S,4));	//Work vector derivatives
    ssSetDWorkDataType(  S, 2, SS_DOUBLE);

	ssSetDWorkWidth(     S, 3, ssGetOutputPortWidth(S,1));//Work vector for flight controls outputs
    ssSetDWorkDataType(  S, 3, SS_DOUBLE);

	ssSetDWorkWidth(     S, 4, ssGetOutputPortWidth(S,2));//Work vector for propulsion outputs
    ssSetDWorkDataType(  S, 4, SS_DOUBLE);

	ssSetDWorkWidth(     S, 5, ssGetOutputPortWidth(S,3));//Work vector for calculated outputs
    ssSetDWorkDataType(  S, 5, SS_DOUBLE);	

	ssSetDWorkWidth(     S, 6, ssGetOutputPortWidth(S,5));//Work vector for aerodynamic outputs
    ssSetDWorkDataType(  S, 6, SS_DOUBLE);


	ssSetNumPWork(S, 1); // reserve element in the pointers vector
                         // to store a C++ object

    ssSetNumNonsampledZCs(S, 0);

    ssSetOptions(S, 0);
		
}
Ejemplo n.º 19
0
/* Function: mdlInitializeSizes ===========================================
 * Abstract:
 *    The sizes information is used by Simulink to determine the S-function
 *    block's characteristics (number of inputs, outputs, states, etc.).
 */
static void mdlInitializeSizes(SimStruct *S)
{
  /* Number of expected parameters */
  ssSetNumSFcnParams(S, 0);

  /*
   * Set the number of pworks.
   */
  ssSetNumPWork(S, 1);

  /*
   * Set the number of dworks.
   */
  if (!ssSetNumDWork(S, 1))
    return;

  /*
   * Configure the dwork 1 (work2)
   */
  ssSetDWorkDataType(S, 0, SS_UINT32);
  ssSetDWorkUsageType(S, 0, SS_DWORK_USED_AS_DWORK);
  ssSetDWorkName(S, 0, "work2");
  ssSetDWorkWidth(S, 0, 1);
  ssSetDWorkComplexSignal(S, 0, COMPLEX_NO);

  /*
   * Set the number of input ports.
   */
  if (!ssSetNumInputPorts(S, 1))
    return;

  /*
   * Configure the input port 1
   */
  ssSetInputPortDataType(S, 0, SS_DOUBLE);
  ssSetInputPortWidth(S, 0, 1);
  ssSetInputPortComplexSignal(S, 0, COMPLEX_NO);
  ssSetInputPortDirectFeedThrough(S, 0, 1);
  ssSetInputPortAcceptExprInRTW(S, 0, 1);
  ssSetInputPortOverWritable(S, 0, 1);
  ssSetInputPortOptimOpts(S, 0, SS_REUSABLE_AND_LOCAL);
  ssSetInputPortRequiredContiguous(S, 0, 1);

  /*
   * Set the number of output ports.
   */
  if (!ssSetNumOutputPorts(S, 0))
    return;

  /*
   * Register reserved identifiers to avoid name conflict
   */
  if (ssRTWGenIsCodeGen(S)) {
    /*
     * Register reserved identifier for InitializeConditionsFcnSpec
     */
    ssRegMdlInfo(S, (char*)"initFaultCounter", MDL_INFO_ID_RESERVED, 0, 0, (void*)
                 ssGetPath(S));

    /*
     * Register reserved identifier for StartFcnSpec
     */
    ssRegMdlInfo(S, (char*)"openLogFile", MDL_INFO_ID_RESERVED, 0, 0, (void*)
                 ssGetPath(S));

    /*
     * Register reserved identifier for OutputFcnSpec
     */
    ssRegMdlInfo(S, (char*)"incAndLogFaultCounter", MDL_INFO_ID_RESERVED, 0, 0,
                 (void*) ssGetPath(S));

    /*
     * Register reserved identifier for TerminateFcnSpec
     */
    ssRegMdlInfo(S, (char*)"closeLogFile", MDL_INFO_ID_RESERVED, 0, 0, (void*)
                 ssGetPath(S));
  }

  /*
   * This S-function can be used in referenced model simulating in normal mode.
   */
  ssSetModelReferenceNormalModeSupport(S, MDL_START_AND_MDL_PROCESS_PARAMS_OK);

  /*
   * Set the number of sample time.
   */
  ssSetNumSampleTimes(S, 1);

  /*
   * All options have the form SS_OPTION_<name> and are documented in
   * matlabroot/simulink/include/simstruc.h. The options should be
   * bitwise or'd together as in
   *   ssSetOptions(S, (SS_OPTION_name1 | SS_OPTION_name2))
   */
  ssSetOptions(S,
               SS_OPTION_CAN_BE_CALLED_CONDITIONALLY |
               SS_OPTION_EXCEPTION_FREE_CODE |
               SS_OPTION_WORKS_WITH_CODE_REUSE |
               SS_OPTION_SFUNCTION_INLINED_FOR_RTW |
               SS_OPTION_DISALLOW_CONSTANT_SAMPLE_TIME);
}
Ejemplo n.º 20
0
/* Function to initialize sizes. */
static void mdlInitializeSizes(SimStruct *S)
{
    ssSetNumSampleTimes(S, 1);           /* Number of sample times */
    ssSetNumContStates(S, 0);            /* Number of continuous states */
    ssSetNumNonsampledZCs(S, 0);         /* Number of nonsampled ZCs */

    /* Number of output ports */
    if (!ssSetNumOutputPorts(S, 1))
        return;

    /* outport number: 0 */
    if (!ssSetOutputPortVectorDimension(S, 0, 1))
        return;
    if (ssGetSimMode(S) != SS_SIMMODE_SIZES_CALL_ONLY) {
        ssSetOutputPortDataType(S, 0, SS_DOUBLE);
    }

    ssSetOutputPortSampleTime(S, 0, 0.06);
    ssSetOutputPortOffsetTime(S, 0, 0.0);
    ssSetOutputPortOptimOpts(S, 0, SS_REUSABLE_AND_LOCAL);

    /* Number of input ports */
    if (!ssSetNumInputPorts(S, 1))
        return;

    /* inport number: 0 */
    {
        if (!ssSetInputPortVectorDimension(S, 0, 1))
            return;
        if (ssGetSimMode(S) != SS_SIMMODE_SIZES_CALL_ONLY) {
            ssSetInputPortDataType(S, 0, SS_DOUBLE);
        }

        ssSetInputPortDirectFeedThrough(S, 0, 1);
        ssSetInputPortSampleTime(S, 0, 0.06);
        ssSetInputPortOffsetTime(S, 0, 0.0);
        ssSetInputPortOverWritable(S, 0, 0);
        ssSetInputPortOptimOpts(S, 0, SS_NOT_REUSABLE_AND_GLOBAL);
    }

    ssSetRTWGeneratedSFcn(S, 1);         /* Generated S-function */

    /* DWork */
    if (!ssSetNumDWork(S, 1)) {
        return;
    }

    /* '<S1>/LinearModel': DSTATE */
    ssSetDWorkName(S, 0, "DWORK0");
    ssSetDWorkWidth(S, 0, 1);
    ssSetDWorkUsedAsDState(S, 0, 1);

    /* Tunable Parameters */
    ssSetNumSFcnParams(S, 0);

    /* Number of expected parameters */
#if defined(MATLAB_MEX_FILE)

    if (ssGetNumSFcnParams(S) == ssGetSFcnParamsCount(S)) {

#if defined(MDL_CHECK_PARAMETERS)

        mdlCheckParameters(S);

#endif                                 /* MDL_CHECK_PARAMETERS */

        if (ssGetErrorStatus(S) != (NULL) ) {
            return;
        }
    } else {
        return;                            /* Parameter mismatch will be reported by Simulink */
    }

#endif                                 /* MATLAB_MEX_FILE */

    /* Options */
    ssSetOptions(S, (SS_OPTION_RUNTIME_EXCEPTION_FREE_CODE |
                     SS_OPTION_PORT_SAMPLE_TIMES_ASSIGNED ));

#if SS_SFCN_FOR_SIM

    {
        ssSupportsMultipleExecInstances(S, false);
        ssRegisterMsgForNotSupportingMultiExecInst(S,
                "<diag_root><diag id=\"Simulink:blocks:BlockDoesNotSupportMultiExecInstances\"><arguments><arg type=\"encoded\">SABhAG0AbQBlAHIAcwB0AGUAaQBuAC8ASABhAG0AbQBlAHIAcwB0AGUAaQBuAC0AVwBpAGUAbgBlAHIAIABNAG8AZABlAGwAMQAvAFAAdwBsAGkAbgBlAGEAcgAxAAAA</arg><arg type=\"encoded\">PABfAF8AaQBpAFMAUwBfAF8APgA8AC8AXwBfAGkAaQBTAFMAXwBfAD4AAAA=</arg><arg type=\"encoded\">PABfAF8AaQB0AGUAcgBCAGwAawBfAF8APgA8AC8AXwBfAGkAdABlAHIAQgBsAGsAXwBfAD4AAAA=</arg></arguments></diag>\n</diag_root>");
        ssHasStateInsideForEachSS(S, false);
    }

#endif

}
Ejemplo n.º 21
0
/* Function: mdlInitializeSizes ===============================================
 * Abstract:
 *   Setup sizes of the various vectors.
 */
static void mdlInitializeSizes(SimStruct *S)
{
    DECL_AND_INIT_DIMSINFO(inputDimsInfo);
    DECL_AND_INIT_DIMSINFO(outputDimsInfo);
    ssSetNumSFcnParams(S, NPARAMS);  /* Number of expected parameters */
      #if defined(MATLAB_MEX_FILE)
	if (ssGetNumSFcnParams(S) == ssGetSFcnParamsCount(S)) {
	  mdlCheckParameters(S);
	  if (ssGetErrorStatus(S) != NULL) {
	    return;
	  }
	 } else {
	   return; /* Parameter mismatch will be reported by Simulink */
	 }
      #endif
    
    ssSetSimStateCompliance(S, USE_DEFAULT_SIM_STATE);
    
    ssSetNumContStates(S, NUM_CONT_STATES);
    ssSetNumDiscStates(S, NUM_DISC_STATES);

    if (!ssSetNumInputPorts(S, NUM_INPUTS)) return;
    /*Input Port 0 */
    ssSetInputPortWidth(S,  0, INPUT_0_WIDTH); /* */
    ssSetInputPortDataType(S, 0, SS_DOUBLE);
    ssSetInputPortComplexSignal(S,  0, INPUT_0_COMPLEX);
    ssSetInputPortDirectFeedThrough(S, 0, INPUT_0_FEEDTHROUGH);
    ssSetInputPortRequiredContiguous(S, 0, 1); /*direct input signal access*/

    /*Input Port 1 */
    ssSetInputPortWidth(S,  1, INPUT_1_WIDTH); /* */
    ssSetInputPortDataType(S, 1, SS_DOUBLE);
    ssSetInputPortComplexSignal(S,  1, INPUT_1_COMPLEX);
    ssSetInputPortDirectFeedThrough(S, 1, INPUT_1_FEEDTHROUGH);
    ssSetInputPortRequiredContiguous(S, 1, 1); /*direct input signal access*/

    /*Input Port 2 */
    ssSetInputPortWidth(S,  2, INPUT_2_WIDTH); /* */
    ssSetInputPortDataType(S, 2, SS_DOUBLE);
    ssSetInputPortComplexSignal(S,  2, INPUT_2_COMPLEX);
    ssSetInputPortDirectFeedThrough(S, 2, INPUT_2_FEEDTHROUGH);
    ssSetInputPortRequiredContiguous(S, 2, 1); /*direct input signal access*/

    /*Input Port 3 */
    ssSetInputPortWidth(S,  3, INPUT_3_WIDTH); /* */
    ssSetInputPortDataType(S, 3, SS_DOUBLE);
    ssSetInputPortComplexSignal(S,  3, INPUT_3_COMPLEX);
    ssSetInputPortDirectFeedThrough(S, 3, INPUT_3_FEEDTHROUGH);
    ssSetInputPortRequiredContiguous(S, 3, 1); /*direct input signal access*/

    /*Input Port 4 */
    ssSetInputPortWidth(S,  4, INPUT_4_WIDTH); /* */
    ssSetInputPortDataType(S, 4, SS_DOUBLE);
    ssSetInputPortComplexSignal(S,  4, INPUT_4_COMPLEX);
    ssSetInputPortDirectFeedThrough(S, 4, INPUT_4_FEEDTHROUGH);
    ssSetInputPortRequiredContiguous(S, 4, 1); /*direct input signal access*/

    /*Input Port 5 */
    ssSetInputPortWidth(S,  5, INPUT_5_WIDTH); /* */
    ssSetInputPortDataType(S, 5, SS_DOUBLE);
    ssSetInputPortComplexSignal(S,  5, INPUT_5_COMPLEX);
    ssSetInputPortDirectFeedThrough(S, 5, INPUT_5_FEEDTHROUGH);
    ssSetInputPortRequiredContiguous(S, 5, 1); /*direct input signal access*/


    if (!ssSetNumOutputPorts(S, NUM_OUTPUTS)) return;
    /* Output Port 0 */
    ssSetOutputPortWidth(S, 0, OUTPUT_0_WIDTH);
    ssSetOutputPortDataType(S, 0, SS_DOUBLE);
    ssSetOutputPortComplexSignal(S, 0, OUTPUT_0_COMPLEX);
    /* Output Port 1 */
    ssSetOutputPortWidth(S, 1, OUTPUT_1_WIDTH);
    ssSetOutputPortDataType(S, 1, SS_DOUBLE);
    ssSetOutputPortComplexSignal(S, 1, OUTPUT_1_COMPLEX);
    /* Output Port 2 */
    ssSetOutputPortWidth(S, 2, OUTPUT_2_WIDTH);
    ssSetOutputPortDataType(S, 2, SS_DOUBLE);
    ssSetOutputPortComplexSignal(S, 2, OUTPUT_2_COMPLEX);
    /* Output Port 3 */
    ssSetOutputPortWidth(S, 3, OUTPUT_3_WIDTH);
    ssSetOutputPortDataType(S, 3, SS_DOUBLE);
    ssSetOutputPortComplexSignal(S, 3, OUTPUT_3_COMPLEX);

    ssSetNumSampleTimes(S, 1);
    ssSetNumRWork(S, 0);
    ssSetNumIWork(S, 0);
    ssSetNumPWork(S, 0);
    ssSetNumModes(S, 0);
    ssSetNumNonsampledZCs(S, 0);
    
    /*initialzation of sizes related to DWork Vectors*/
    ssSetNumDWork(S,NDWORKS);
    /*DWork vector 1*/
    ssSetDWorkWidth(S, 0, DWORK_0_WIDTH);
    ssSetDWorkDataType(S, 0, SS_DOUBLE);
    /*DWork vector 2*/    
    ssSetDWorkWidth(S, 1, DWORK_1_WIDTH);
    ssSetDWorkDataType(S, 1, SS_DOUBLE);
    /*DWork vector 3*/
    ssSetDWorkWidth(S, 2, DWORK_2_WIDTH);
    ssSetDWorkDataType(S, 2, SS_DOUBLE);    
    
    /* Take care when specifying exception free code - see sfuntmpl_doc.c */
    ssSetOptions(S, (SS_OPTION_EXCEPTION_FREE_CODE |
                     SS_OPTION_USE_TLC_WITH_ACCELERATOR | 
		     SS_OPTION_WORKS_WITH_CODE_REUSE));

}
Ejemplo n.º 22
0
/* Model initialize function */
void Mechanics_initialize(boolean_T firstTime)
{
  (void)firstTime;

  /* Registration code */

  /* initialize non-finites */
  rt_InitInfAndNaN(sizeof(real_T));    /* initialize real-time model */
  (void) memset((char_T *)Mechanics_M,0,
                sizeof(RT_MODEL_Mechanics));

  {
    /* Setup solver object */
    rtsiSetSimTimeStepPtr(&Mechanics_M->solverInfo,
                          &Mechanics_M->Timing.simTimeStep);
    rtsiSetTPtr(&Mechanics_M->solverInfo, &rtmGetTPtr(Mechanics_M));
    rtsiSetStepSizePtr(&Mechanics_M->solverInfo, &Mechanics_M->Timing.stepSize0);
    rtsiSetdXPtr(&Mechanics_M->solverInfo, &Mechanics_M->ModelData.derivs);
    rtsiSetContStatesPtr(&Mechanics_M->solverInfo,
                         &Mechanics_M->ModelData.contStates);
    rtsiSetNumContStatesPtr(&Mechanics_M->solverInfo,
      &Mechanics_M->Sizes.numContStates);
    rtsiSetErrorStatusPtr(&Mechanics_M->solverInfo, (&rtmGetErrorStatus
      (Mechanics_M)));
    rtsiSetRTModelPtr(&Mechanics_M->solverInfo, Mechanics_M);
  }

  rtsiSetSimTimeStep(&Mechanics_M->solverInfo, MAJOR_TIME_STEP);
  Mechanics_M->ModelData.intgData.y = Mechanics_M->ModelData.odeY;
  Mechanics_M->ModelData.intgData.f[0] = Mechanics_M->ModelData.odeF[0];
  Mechanics_M->ModelData.intgData.f[1] = Mechanics_M->ModelData.odeF[1];
  Mechanics_M->ModelData.intgData.f[2] = Mechanics_M->ModelData.odeF[2];
  Mechanics_M->ModelData.contStates = ((real_T *) &Mechanics_X);
  rtsiSetSolverData(&Mechanics_M->solverInfo, (void *)
                    &Mechanics_M->ModelData.intgData);
  rtsiSetSolverName(&Mechanics_M->solverInfo,"ode3");
  Mechanics_M->solverInfoPtr = (&Mechanics_M->solverInfo);

  /* Initialize timing info */
  {
    int_T *mdlTsMap = Mechanics_M->Timing.sampleTimeTaskIDArray;
    mdlTsMap[0] = 0;
    mdlTsMap[1] = 1;
    Mechanics_M->Timing.sampleTimeTaskIDPtr = (&mdlTsMap[0]);
    Mechanics_M->Timing.sampleTimes = (&Mechanics_M->Timing.sampleTimesArray[0]);
    Mechanics_M->Timing.offsetTimes = (&Mechanics_M->Timing.offsetTimesArray[0]);

    /* task periods */
    Mechanics_M->Timing.sampleTimes[0] = (0.0);
    Mechanics_M->Timing.sampleTimes[1] = (35.0);

    /* task offsets */
    Mechanics_M->Timing.offsetTimes[0] = (0.0);
    Mechanics_M->Timing.offsetTimes[1] = (0.0);
  }

  rtmSetTPtr(Mechanics_M, &Mechanics_M->Timing.tArray[0]);

  {
    int_T *mdlSampleHits = Mechanics_M->Timing.sampleHitArray;
    mdlSampleHits[0] = 1;
    mdlSampleHits[1] = 1;
    Mechanics_M->Timing.sampleHits = (&mdlSampleHits[0]);
  }

  rtmSetTFinal(Mechanics_M, -1);
  Mechanics_M->Timing.stepSize0 = 35.0;
  Mechanics_M->Timing.stepSize1 = 35.0;

  /* Setup for data logging */
  {
    static RTWLogInfo rt_DataLoggingInfo;
    Mechanics_M->rtwLogInfo = &rt_DataLoggingInfo;
    rtliSetLogFormat(Mechanics_M->rtwLogInfo, 0);
    rtliSetLogMaxRows(Mechanics_M->rtwLogInfo, 1000);
    rtliSetLogDecimation(Mechanics_M->rtwLogInfo, 1);
    rtliSetLogVarNameModifier(Mechanics_M->rtwLogInfo, "rt_");
    rtliSetLogT(Mechanics_M->rtwLogInfo, "tout");
    rtliSetLogX(Mechanics_M->rtwLogInfo, "");
    rtliSetLogXFinal(Mechanics_M->rtwLogInfo, "");
    rtliSetSigLog(Mechanics_M->rtwLogInfo, "");
    rtliSetLogXSignalInfo(Mechanics_M->rtwLogInfo, NULL);
    rtliSetLogXSignalPtrs(Mechanics_M->rtwLogInfo, NULL);
    rtliSetLogY(Mechanics_M->rtwLogInfo, "");
    rtliSetLogYSignalInfo(Mechanics_M->rtwLogInfo, NULL);
    rtliSetLogYSignalPtrs(Mechanics_M->rtwLogInfo, NULL);
  }

  Mechanics_M->solverInfoPtr = (&Mechanics_M->solverInfo);
  Mechanics_M->Timing.stepSize = (35.0);
  rtsiSetFixedStepSize(&Mechanics_M->solverInfo, 35.0);
  rtsiSetSolverMode(&Mechanics_M->solverInfo, SOLVER_MODE_SINGLETASKING);

  /* block I/O */
  Mechanics_M->ModelData.blockIO = ((void *) &Mechanics_B);

  {
    int_T i;
    void *pVoidBlockIORegion;
    pVoidBlockIORegion = (void *)(&Mechanics_B.Arduino);
    for (i = 0; i < 18; i++) {
      ((real_T*)pVoidBlockIORegion)[i] = 0.0;
    }
  }

  /* parameters */
  Mechanics_M->ModelData.defaultParam = ((real_T *) &Mechanics_P);

  /* states (continuous) */
  {
    real_T *x = (real_T *) &Mechanics_X;
    Mechanics_M->ModelData.contStates = (x);
    (void) memset((char_T *)x,0,
                  sizeof(ContinuousStates_Mechanics));
  }

  /* states (dwork) */
  Mechanics_M->Work.dwork = ((void *) &Mechanics_DWork);
  (void) memset((char_T *) &Mechanics_DWork,0,
                sizeof(D_Work_Mechanics));

  /* child S-Function registration */
  {
    RTWSfcnInfo *sfcnInfo = &Mechanics_M->NonInlinedSFcns.sfcnInfo;
    Mechanics_M->sfcnInfo = (sfcnInfo);
    rtssSetErrorStatusPtr(sfcnInfo, (&rtmGetErrorStatus(Mechanics_M)));
    rtssSetNumRootSampTimesPtr(sfcnInfo, &Mechanics_M->Sizes.numSampTimes);
    rtssSetTPtrPtr(sfcnInfo, &rtmGetTPtr(Mechanics_M));
    rtssSetTStartPtr(sfcnInfo, &rtmGetTStart(Mechanics_M));
    rtssSetTFinalPtr(sfcnInfo, &rtmGetTFinal(Mechanics_M));
    rtssSetTimeOfLastOutputPtr(sfcnInfo, &rtmGetTimeOfLastOutput(Mechanics_M));
    rtssSetStepSizePtr(sfcnInfo, &Mechanics_M->Timing.stepSize);
    rtssSetStopRequestedPtr(sfcnInfo, &rtmGetStopRequested(Mechanics_M));
    rtssSetDerivCacheNeedsResetPtr(sfcnInfo,
      &Mechanics_M->ModelData.derivCacheNeedsReset);
    rtssSetZCCacheNeedsResetPtr(sfcnInfo,
      &Mechanics_M->ModelData.zCCacheNeedsReset);
    rtssSetBlkStateChangePtr(sfcnInfo, &Mechanics_M->ModelData.blkStateChange);
    rtssSetSampleHitsPtr(sfcnInfo, &Mechanics_M->Timing.sampleHits);
    rtssSetPerTaskSampleHitsPtr(sfcnInfo, &Mechanics_M->Timing.perTaskSampleHits);
    rtssSetSimModePtr(sfcnInfo, &Mechanics_M->simMode);
    rtssSetSolverInfoPtr(sfcnInfo, &Mechanics_M->solverInfoPtr);
  }

  Mechanics_M->Sizes.numSFcns = (1);

  /* register each child */
  {
    (void) memset((void *)&Mechanics_M->NonInlinedSFcns.childSFunctions[0],0,
                  1*sizeof(SimStruct));
    Mechanics_M->childSfunctions =
      (&Mechanics_M->NonInlinedSFcns.childSFunctionPtrs[0]);
    Mechanics_M->childSfunctions[0] =
      (&Mechanics_M->NonInlinedSFcns.childSFunctions[0]);

    /* Level2 S-Function Block: Mechanics/<Root>/Arduino (QueryInstrument) */
    {
      SimStruct *rts = Mechanics_M->childSfunctions[0];

      /* timing info */
      time_T *sfcnPeriod = Mechanics_M->NonInlinedSFcns.Sfcn0.sfcnPeriod;
      time_T *sfcnOffset = Mechanics_M->NonInlinedSFcns.Sfcn0.sfcnOffset;
      int_T *sfcnTsMap = Mechanics_M->NonInlinedSFcns.Sfcn0.sfcnTsMap;
      (void) memset((void*)sfcnPeriod,0,
                    sizeof(time_T)*1);
      (void) memset((void*)sfcnOffset,0,
                    sizeof(time_T)*1);
      ssSetSampleTimePtr(rts, &sfcnPeriod[0]);
      ssSetOffsetTimePtr(rts, &sfcnOffset[0]);
      ssSetSampleTimeTaskIDPtr(rts, sfcnTsMap);

      /* Set up the mdlInfo pointer */
      {
        ssSetBlkInfo2Ptr(rts, &Mechanics_M->NonInlinedSFcns.blkInfo2[0]);
        ssSetRTWSfcnInfo(rts, Mechanics_M->sfcnInfo);
      }

      /* Allocate memory of model methods 2 */
      {
        ssSetModelMethods2(rts, &Mechanics_M->NonInlinedSFcns.methods2[0]);
      }

      /* outputs */
      {
        ssSetPortInfoForOutputs(rts,
          &Mechanics_M->NonInlinedSFcns.Sfcn0.outputPortInfo[0]);
        _ssSetNumOutputPorts(rts, 1);

        /* port 0 */
        {
          _ssSetOutputPortNumDimensions(rts, 0, 1);
          ssSetOutputPortWidth(rts, 0, 1);
          ssSetOutputPortSignal(rts, 0, ((real_T *) &Mechanics_B.Arduino));
        }
      }

      /* path info */
      ssSetModelName(rts, "Arduino");
      ssSetPath(rts, "Mechanics/Arduino");
      ssSetRTModel(rts,Mechanics_M);
      ssSetParentSS(rts, NULL);
      ssSetRootSS(rts, rts);
      ssSetVersion(rts, SIMSTRUCT_VERSION_LEVEL2);

      /* parameters */
      {
        mxArray **sfcnParams = (mxArray **)
          &Mechanics_M->NonInlinedSFcns.Sfcn0.params;
        ssSetSFcnParamsCount(rts, 39);
        ssSetSFcnParamsPtr(rts, &sfcnParams[0]);
        ssSetSFcnParam(rts, 0, (mxArray*)&Mechanics_P.Arduino_P1_Size[0]);
        ssSetSFcnParam(rts, 1, (mxArray*)&Mechanics_P.Arduino_P2_Size[0]);
        ssSetSFcnParam(rts, 2, (mxArray*)&Mechanics_P.Arduino_P3_Size[0]);
        ssSetSFcnParam(rts, 3, (mxArray*)&Mechanics_P.Arduino_P4_Size[0]);
        ssSetSFcnParam(rts, 4, (mxArray*)&Mechanics_P.Arduino_P5_Size[0]);
        ssSetSFcnParam(rts, 5, (mxArray*)&Mechanics_P.Arduino_P6_Size[0]);
        ssSetSFcnParam(rts, 6, (mxArray*)&Mechanics_P.Arduino_P7_Size[0]);
        ssSetSFcnParam(rts, 7, (mxArray*)&Mechanics_P.Arduino_P8_Size[0]);
        ssSetSFcnParam(rts, 8, (mxArray*)&Mechanics_P.Arduino_P9_Size[0]);
        ssSetSFcnParam(rts, 9, (mxArray*)&Mechanics_P.Arduino_P10_Size[0]);
        ssSetSFcnParam(rts, 10, (mxArray*)&Mechanics_P.Arduino_P11_Size[0]);
        ssSetSFcnParam(rts, 11, (mxArray*)&Mechanics_P.Arduino_P12_Size[0]);
        ssSetSFcnParam(rts, 12, (mxArray*)&Mechanics_P.Arduino_P13_Size[0]);
        ssSetSFcnParam(rts, 13, (mxArray*)&Mechanics_P.Arduino_P14_Size[0]);
        ssSetSFcnParam(rts, 14, (mxArray*)&Mechanics_P.Arduino_P15_Size[0]);
        ssSetSFcnParam(rts, 15, (mxArray*)&Mechanics_P.Arduino_P16_Size[0]);
        ssSetSFcnParam(rts, 16, (mxArray*)&Mechanics_P.Arduino_P17_Size[0]);
        ssSetSFcnParam(rts, 17, (mxArray*)&Mechanics_P.Arduino_P18_Size[0]);
        ssSetSFcnParam(rts, 18, (mxArray*)&Mechanics_P.Arduino_P19_Size[0]);
        ssSetSFcnParam(rts, 19, (mxArray*)&Mechanics_P.Arduino_P20_Size[0]);
        ssSetSFcnParam(rts, 20, (mxArray*)&Mechanics_P.Arduino_P21_Size[0]);
        ssSetSFcnParam(rts, 21, (mxArray*)&Mechanics_P.Arduino_P22_Size[0]);
        ssSetSFcnParam(rts, 22, (mxArray*)&Mechanics_P.Arduino_P23_Size[0]);
        ssSetSFcnParam(rts, 23, (mxArray*)&Mechanics_P.Arduino_P24_Size[0]);
        ssSetSFcnParam(rts, 24, (mxArray*)&Mechanics_P.Arduino_P25_Size[0]);
        ssSetSFcnParam(rts, 25, (mxArray*)&Mechanics_P.Arduino_P26_Size[0]);
        ssSetSFcnParam(rts, 26, (mxArray*)&Mechanics_P.Arduino_P27_Size[0]);
        ssSetSFcnParam(rts, 27, (mxArray*)&Mechanics_P.Arduino_P28_Size[0]);
        ssSetSFcnParam(rts, 28, (mxArray*)&Mechanics_P.Arduino_P29_Size[0]);
        ssSetSFcnParam(rts, 29, (mxArray*)&Mechanics_P.Arduino_P30_Size[0]);
        ssSetSFcnParam(rts, 30, (mxArray*)&Mechanics_P.Arduino_P31_Size[0]);
        ssSetSFcnParam(rts, 31, (mxArray*)&Mechanics_P.Arduino_P32_Size[0]);
        ssSetSFcnParam(rts, 32, (mxArray*)&Mechanics_P.Arduino_P33_Size[0]);
        ssSetSFcnParam(rts, 33, (mxArray*)&Mechanics_P.Arduino_P34_Size[0]);
        ssSetSFcnParam(rts, 34, (mxArray*)&Mechanics_P.Arduino_P35_Size[0]);
        ssSetSFcnParam(rts, 35, (mxArray*)&Mechanics_P.Arduino_P36_Size[0]);
        ssSetSFcnParam(rts, 36, (mxArray*)&Mechanics_P.Arduino_P37_Size[0]);
        ssSetSFcnParam(rts, 37, (mxArray*)&Mechanics_P.Arduino_P38_Size[0]);
        ssSetSFcnParam(rts, 38, (mxArray*)&Mechanics_P.Arduino_P39_Size[0]);
      }

      /* work vectors */
      ssSetPWork(rts, (void **) &Mechanics_DWork.Arduino_PWORK);

      {
        struct _ssDWorkRecord *dWorkRecord = (struct _ssDWorkRecord *)
          &Mechanics_M->NonInlinedSFcns.Sfcn0.dWork;
        ssSetSFcnDWork(rts, dWorkRecord);
        _ssSetNumDWork(rts, 1);

        /* PWORK */
        ssSetDWorkWidth(rts, 0, 1);
        ssSetDWorkDataType(rts, 0,SS_POINTER);
        ssSetDWorkComplexSignal(rts, 0, 0);
        ssSetDWork(rts, 0, &Mechanics_DWork.Arduino_PWORK);
      }

      /* registration */
      QueryInstrument(rts);
      sfcnInitializeSizes(rts);
      sfcnInitializeSampleTimes(rts);

      /* adjust sample time */
      ssSetSampleTime(rts, 0, 35.0);
      ssSetOffsetTime(rts, 0, 0.0);
      sfcnTsMap[0] = 1;

      /* set compiled values of dynamic vector attributes */
      ssSetNumNonsampledZCs(rts, 0);

      /* Update connectivity flags for each port */
      _ssSetOutputPortConnected(rts, 0, 1);
      _ssSetOutputPortBeingMerged(rts, 0, 0);

      /* Update the BufferDstPort flags for each input port */
    }
  }
}
Ejemplo n.º 23
0
/* Model initialize function */
void xpcosc_initialize(boolean_T firstTime)
{
  (void)firstTime;

  /* Registration code */

  /* initialize non-finites */
  rt_InitInfAndNaN(sizeof(real_T));

  /* initialize real-time model */
  (void) memset((void *)xpcosc_rtM, 0,
                sizeof(rtModel_xpcosc));

  {
    /* Setup solver object */
    rtsiSetSimTimeStepPtr(&xpcosc_rtM->solverInfo,
                          &xpcosc_rtM->Timing.simTimeStep);
    rtsiSetTPtr(&xpcosc_rtM->solverInfo, &rtmGetTPtr(xpcosc_rtM));
    rtsiSetStepSizePtr(&xpcosc_rtM->solverInfo, &xpcosc_rtM->Timing.stepSize0);
    rtsiSetdXPtr(&xpcosc_rtM->solverInfo, &xpcosc_rtM->ModelData.derivs);
    rtsiSetContStatesPtr(&xpcosc_rtM->solverInfo,
                         &xpcosc_rtM->ModelData.contStates);
    rtsiSetNumContStatesPtr(&xpcosc_rtM->solverInfo,
      &xpcosc_rtM->Sizes.numContStates);
    rtsiSetErrorStatusPtr(&xpcosc_rtM->solverInfo, (&rtmGetErrorStatus
      (xpcosc_rtM)));
    rtsiSetRTModelPtr(&xpcosc_rtM->solverInfo, xpcosc_rtM);
  }

  rtsiSetSimTimeStep(&xpcosc_rtM->solverInfo, MAJOR_TIME_STEP);
  xpcosc_rtM->ModelData.intgData.y = xpcosc_rtM->ModelData.odeY;
  xpcosc_rtM->ModelData.intgData.f[0] = xpcosc_rtM->ModelData.odeF[0];
  xpcosc_rtM->ModelData.intgData.f[1] = xpcosc_rtM->ModelData.odeF[1];
  xpcosc_rtM->ModelData.intgData.f[2] = xpcosc_rtM->ModelData.odeF[2];
  xpcosc_rtM->ModelData.intgData.f[3] = xpcosc_rtM->ModelData.odeF[3];
  xpcosc_rtM->ModelData.contStates = ((real_T *) &xpcosc_X);
  rtsiSetSolverData(&xpcosc_rtM->solverInfo, (void *)
                    &xpcosc_rtM->ModelData.intgData);
  rtsiSetSolverName(&xpcosc_rtM->solverInfo,"ode4");
  xpcosc_rtM->solverInfoPtr = (&xpcosc_rtM->solverInfo);

  /* Initialize timing info */
  {
    int_T *mdlTsMap = xpcosc_rtM->Timing.sampleTimeTaskIDArray;
    mdlTsMap[0] = 0;
    mdlTsMap[1] = 1;
    xpcosc_rtM->Timing.sampleTimeTaskIDPtr = (&mdlTsMap[0]);
    xpcosc_rtM->Timing.sampleTimes = (&xpcosc_rtM->Timing.sampleTimesArray[0]);
    xpcosc_rtM->Timing.offsetTimes = (&xpcosc_rtM->Timing.offsetTimesArray[0]);

    /* task periods */
    xpcosc_rtM->Timing.sampleTimes[0] = (0.0);
    xpcosc_rtM->Timing.sampleTimes[1] = (0.001);

    /* task offsets */
    xpcosc_rtM->Timing.offsetTimes[0] = (0.0);
    xpcosc_rtM->Timing.offsetTimes[1] = (0.0);
  }

  rtmSetTPtr(xpcosc_rtM, &xpcosc_rtM->Timing.tArray[0]);

  {
    int_T *mdlSampleHits = xpcosc_rtM->Timing.sampleHitArray;
    mdlSampleHits[0] = 1;
    mdlSampleHits[1] = 1;
    xpcosc_rtM->Timing.sampleHits = (&mdlSampleHits[0]);
  }

  rtmSetTFinal(xpcosc_rtM, 0.2);
  xpcosc_rtM->Timing.stepSize0 = 0.001;
  xpcosc_rtM->Timing.stepSize1 = 0.001;

  /* Setup for data logging */
  {
    static RTWLogInfo rt_DataLoggingInfo;
    xpcosc_rtM->rtwLogInfo = &rt_DataLoggingInfo;
  }

  /* Setup for data logging */
  {
    /*
     * Set pointers to the data and signal info each state
     */
    {
      static int_T rt_LoggedStateWidths[] = {
        1,
        1
      };

      static int_T rt_LoggedStateNumDimensions[] = {
        1,
        1
      };

      static int_T rt_LoggedStateDimensions[] = {
        1,
        1
      };

      static boolean_T rt_LoggedStateIsVarDims[] = {
        0,
        0
      };

      static BuiltInDTypeId rt_LoggedStateDataTypeIds[] = {
        SS_DOUBLE,
        SS_DOUBLE
      };

      static int_T rt_LoggedStateComplexSignals[] = {
        0,
        0
      };

      static const char_T *rt_LoggedStateLabels[] = {
        "CSTATE",
        "CSTATE"
      };

      static const char_T *rt_LoggedStateBlockNames[] = {
        "xpcosc/Integrator1",
        "xpcosc/Integrator"
      };

      static const char_T *rt_LoggedStateNames[] = {
        "",
        ""
      };

      static boolean_T rt_LoggedStateCrossMdlRef[] = {
        0,
        0
      };

      static RTWLogDataTypeConvert rt_RTWLogDataTypeConvert[] = {
        { 0, SS_DOUBLE, SS_DOUBLE, 0, 0, 0, 1.0, 0, 0.0 },

        { 0, SS_DOUBLE, SS_DOUBLE, 0, 0, 0, 1.0, 0, 0.0 }
      };

      static RTWLogSignalInfo rt_LoggedStateSignalInfo = {
        2,
        rt_LoggedStateWidths,
        rt_LoggedStateNumDimensions,
        rt_LoggedStateDimensions,
        rt_LoggedStateIsVarDims,
        (NULL),
        rt_LoggedStateDataTypeIds,
        rt_LoggedStateComplexSignals,
        (NULL),

        { rt_LoggedStateLabels },
        (NULL),
        (NULL),
        (NULL),

        { rt_LoggedStateBlockNames },

        { rt_LoggedStateNames },
        rt_LoggedStateCrossMdlRef,
        rt_RTWLogDataTypeConvert
      };

      static void * rt_LoggedStateSignalPtrs[2];
      rtliSetLogXSignalPtrs(xpcosc_rtM->rtwLogInfo, (LogSignalPtrsType)
                            rt_LoggedStateSignalPtrs);
      rtliSetLogXSignalInfo(xpcosc_rtM->rtwLogInfo, &rt_LoggedStateSignalInfo);
      rt_LoggedStateSignalPtrs[0] = (void*)&xpcosc_X.Integrator1_CSTATE;
      rt_LoggedStateSignalPtrs[1] = (void*)&xpcosc_X.Integrator_CSTATE;
    }

    rtliSetLogT(xpcosc_rtM->rtwLogInfo, "tout");
    rtliSetLogX(xpcosc_rtM->rtwLogInfo, "xout");
    rtliSetLogXFinal(xpcosc_rtM->rtwLogInfo, "");
    rtliSetSigLog(xpcosc_rtM->rtwLogInfo, "");
    rtliSetLogVarNameModifier(xpcosc_rtM->rtwLogInfo, "rt_");
    rtliSetLogFormat(xpcosc_rtM->rtwLogInfo, 0);
    rtliSetLogMaxRows(xpcosc_rtM->rtwLogInfo, 0);
    rtliSetLogDecimation(xpcosc_rtM->rtwLogInfo, 1);

    /*
     * Set pointers to the data and signal info for each output
     */
    {
      static void * rt_LoggedOutputSignalPtrs[] = {
        &xpcosc_Y.Outport[0]
      };

      rtliSetLogYSignalPtrs(xpcosc_rtM->rtwLogInfo, ((LogSignalPtrsType)
        rt_LoggedOutputSignalPtrs));
    }

    {
      static int_T rt_LoggedOutputWidths[] = {
        2
      };

      static int_T rt_LoggedOutputNumDimensions[] = {
        1
      };

      static int_T rt_LoggedOutputDimensions[] = {
        2
      };

      static boolean_T rt_LoggedOutputIsVarDims[] = {
        0
      };

      static int_T* rt_LoggedCurrentSignalDimensions[] = {
        (NULL)
      };

      static BuiltInDTypeId rt_LoggedOutputDataTypeIds[] = {
        SS_DOUBLE
      };

      static int_T rt_LoggedOutputComplexSignals[] = {
        0
      };

      static const char_T *rt_LoggedOutputLabels[] = {
        "" };

      static const char_T *rt_LoggedOutputBlockNames[] = {
        "xpcosc/Outport" };

      static RTWLogDataTypeConvert rt_RTWLogDataTypeConvert[] = {
        { 0, SS_DOUBLE, SS_DOUBLE, 0, 0, 0, 1.0, 0, 0.0 }
      };

      static RTWLogSignalInfo rt_LoggedOutputSignalInfo[] = {
        {
          1,
          rt_LoggedOutputWidths,
          rt_LoggedOutputNumDimensions,
          rt_LoggedOutputDimensions,
          rt_LoggedOutputIsVarDims,
          rt_LoggedCurrentSignalDimensions,
          rt_LoggedOutputDataTypeIds,
          rt_LoggedOutputComplexSignals,
          (NULL),

          { rt_LoggedOutputLabels },
          (NULL),
          (NULL),
          (NULL),

          { rt_LoggedOutputBlockNames },

          { (NULL) },
          (NULL),
          rt_RTWLogDataTypeConvert
        }
      };

      rtliSetLogYSignalInfo(xpcosc_rtM->rtwLogInfo, rt_LoggedOutputSignalInfo);

      /* set currSigDims field */
      rt_LoggedCurrentSignalDimensions[0] = &rt_LoggedOutputWidths[0];
    }

    rtliSetLogY(xpcosc_rtM->rtwLogInfo, "yout");
  }

  /* external mode info */
  xpcosc_rtM->Sizes.checksums[0] = (1235351435U);
  xpcosc_rtM->Sizes.checksums[1] = (4143988505U);
  xpcosc_rtM->Sizes.checksums[2] = (362576123U);
  xpcosc_rtM->Sizes.checksums[3] = (1068881914U);

  {
    static const sysRanDType rtAlwaysEnabled = SUBSYS_RAN_BC_ENABLE;
    static RTWExtModeInfo rt_ExtModeInfo;
    static const sysRanDType *systemRan[1];
    xpcosc_rtM->extModeInfo = (&rt_ExtModeInfo);
    rteiSetSubSystemActiveVectorAddresses(&rt_ExtModeInfo, systemRan);
    systemRan[0] = &rtAlwaysEnabled;
    rteiSetModelMappingInfoPtr(xpcosc_rtM->extModeInfo,
      &xpcosc_rtM->SpecialInfo.mappingInfo);
    rteiSetChecksumsPtr(xpcosc_rtM->extModeInfo, xpcosc_rtM->Sizes.checksums);
    rteiSetTPtr(xpcosc_rtM->extModeInfo, rtmGetTPtr(xpcosc_rtM));
  }

  xpcosc_rtM->solverInfoPtr = (&xpcosc_rtM->solverInfo);
  xpcosc_rtM->Timing.stepSize = (0.001);
  rtsiSetFixedStepSize(&xpcosc_rtM->solverInfo, 0.001);
  rtsiSetSolverMode(&xpcosc_rtM->solverInfo, SOLVER_MODE_SINGLETASKING);

  /* block I/O */
  xpcosc_rtM->ModelData.blockIO = ((void *) &xpcosc_B);

  {
    xpcosc_B.Integrator1 = 0.0;
    xpcosc_B.PCI6221AD = 0.0;
    xpcosc_B.RateTransition1 = 0.0;
    xpcosc_B.SignalGenerator = 0.0;
    xpcosc_B.RateTransition = 0.0;
    xpcosc_B.Gain = 0.0;
    xpcosc_B.Integrator = 0.0;
    xpcosc_B.Gain1 = 0.0;
    xpcosc_B.Gain2 = 0.0;
    xpcosc_B.Sum = 0.0;
  }

  /* parameters */
  xpcosc_rtM->ModelData.defaultParam = ((real_T *)&xpcosc_P);

  /* states (continuous) */
  {
    real_T *x = (real_T *) &xpcosc_X;
    xpcosc_rtM->ModelData.contStates = (x);
    (void) memset((void *)&xpcosc_X, 0,
                  sizeof(ContinuousStates_xpcosc));
  }

  /* states (dwork) */
  xpcosc_rtM->Work.dwork = ((void *) &xpcosc_DWork);
  (void) memset((void *)&xpcosc_DWork, 0,
                sizeof(D_Work_xpcosc));
  xpcosc_DWork.PCI6713DA_RWORK = 0.0;

  /* external outputs */
  xpcosc_rtM->ModelData.outputs = (&xpcosc_Y);
  xpcosc_Y.Outport[0] = 0.0;
  xpcosc_Y.Outport[1] = 0.0;

  /* data type transition information */
  {
    static DataTypeTransInfo dtInfo;
    (void) memset((char_T *) &dtInfo, 0,
                  sizeof(dtInfo));
    xpcosc_rtM->SpecialInfo.mappingInfo = (&dtInfo);
    xpcosc_rtM->SpecialInfo.xpcData = ((void*) &dtInfo);
    dtInfo.numDataTypes = 14;
    dtInfo.dataTypeSizes = &rtDataTypeSizes[0];
    dtInfo.dataTypeNames = &rtDataTypeNames[0];

    /* Block I/O transition table */
    dtInfo.B = &rtBTransTable;

    /* Parameters transition table */
    dtInfo.P = &rtPTransTable;
  }

  /* Initialize DataMapInfo substructure containing ModelMap for C API */
  xpcosc_InitializeDataMapInfo(xpcosc_rtM);

  /* child S-Function registration */
  {
    RTWSfcnInfo *sfcnInfo = &xpcosc_rtM->NonInlinedSFcns.sfcnInfo;
    xpcosc_rtM->sfcnInfo = (sfcnInfo);
    rtssSetErrorStatusPtr(sfcnInfo, (&rtmGetErrorStatus(xpcosc_rtM)));
    rtssSetNumRootSampTimesPtr(sfcnInfo, &xpcosc_rtM->Sizes.numSampTimes);
    xpcosc_rtM->NonInlinedSFcns.taskTimePtrs[0] = &(rtmGetTPtr(xpcosc_rtM)[0]);
    xpcosc_rtM->NonInlinedSFcns.taskTimePtrs[1] = &(rtmGetTPtr(xpcosc_rtM)[1]);
    rtssSetTPtrPtr(sfcnInfo,xpcosc_rtM->NonInlinedSFcns.taskTimePtrs);
    rtssSetTStartPtr(sfcnInfo, &rtmGetTStart(xpcosc_rtM));
    rtssSetTFinalPtr(sfcnInfo, &rtmGetTFinal(xpcosc_rtM));
    rtssSetTimeOfLastOutputPtr(sfcnInfo, &rtmGetTimeOfLastOutput(xpcosc_rtM));
    rtssSetStepSizePtr(sfcnInfo, &xpcosc_rtM->Timing.stepSize);
    rtssSetStopRequestedPtr(sfcnInfo, &rtmGetStopRequested(xpcosc_rtM));
    rtssSetDerivCacheNeedsResetPtr(sfcnInfo,
      &xpcosc_rtM->ModelData.derivCacheNeedsReset);
    rtssSetZCCacheNeedsResetPtr(sfcnInfo,
      &xpcosc_rtM->ModelData.zCCacheNeedsReset);
    rtssSetBlkStateChangePtr(sfcnInfo, &xpcosc_rtM->ModelData.blkStateChange);
    rtssSetSampleHitsPtr(sfcnInfo, &xpcosc_rtM->Timing.sampleHits);
    rtssSetPerTaskSampleHitsPtr(sfcnInfo, &xpcosc_rtM->Timing.perTaskSampleHits);
    rtssSetSimModePtr(sfcnInfo, &xpcosc_rtM->simMode);
    rtssSetSolverInfoPtr(sfcnInfo, &xpcosc_rtM->solverInfoPtr);
  }

  xpcosc_rtM->Sizes.numSFcns = (2);

  /* register each child */
  {
    (void) memset((void *)&xpcosc_rtM->NonInlinedSFcns.childSFunctions[0], 0,
                  2*sizeof(SimStruct));
    xpcosc_rtM->childSfunctions =
      (&xpcosc_rtM->NonInlinedSFcns.childSFunctionPtrs[0]);
    xpcosc_rtM->childSfunctions[0] =
      (&xpcosc_rtM->NonInlinedSFcns.childSFunctions[0]);
    xpcosc_rtM->childSfunctions[1] =
      (&xpcosc_rtM->NonInlinedSFcns.childSFunctions[1]);

    /* Level2 S-Function Block: xpcosc/<Root>/PCI-6221 AD (adnipcim) */
    {
      SimStruct *rts = xpcosc_rtM->childSfunctions[0];

      /* timing info */
      time_T *sfcnPeriod = xpcosc_rtM->NonInlinedSFcns.Sfcn0.sfcnPeriod;
      time_T *sfcnOffset = xpcosc_rtM->NonInlinedSFcns.Sfcn0.sfcnOffset;
      int_T *sfcnTsMap = xpcosc_rtM->NonInlinedSFcns.Sfcn0.sfcnTsMap;
      (void) memset((void*)sfcnPeriod, 0,
                    sizeof(time_T)*1);
      (void) memset((void*)sfcnOffset, 0,
                    sizeof(time_T)*1);
      ssSetSampleTimePtr(rts, &sfcnPeriod[0]);
      ssSetOffsetTimePtr(rts, &sfcnOffset[0]);
      ssSetSampleTimeTaskIDPtr(rts, sfcnTsMap);

      /* Set up the mdlInfo pointer */
      {
        ssSetBlkInfo2Ptr(rts, &xpcosc_rtM->NonInlinedSFcns.blkInfo2[0]);
      }

      ssSetRTWSfcnInfo(rts, xpcosc_rtM->sfcnInfo);

      /* Allocate memory of model methods 2 */
      {
        ssSetModelMethods2(rts, &xpcosc_rtM->NonInlinedSFcns.methods2[0]);
      }

      /* Allocate memory of model methods 3 */
      {
        ssSetModelMethods3(rts, &xpcosc_rtM->NonInlinedSFcns.methods3[0]);
      }

      /* Allocate memory for states auxilliary information */
      {
        ssSetStatesInfo2(rts, &xpcosc_rtM->NonInlinedSFcns.statesInfo2[0]);
      }

      /* outputs */
      {
        ssSetPortInfoForOutputs(rts,
          &xpcosc_rtM->NonInlinedSFcns.Sfcn0.outputPortInfo[0]);
        _ssSetNumOutputPorts(rts, 1);

        /* port 0 */
        {
          _ssSetOutputPortNumDimensions(rts, 0, 1);
          ssSetOutputPortWidth(rts, 0, 1);
          ssSetOutputPortSignal(rts, 0, ((real_T *) &xpcosc_B.PCI6221AD));
        }
      }

      /* path info */
      ssSetModelName(rts, "PCI-6221 AD");
      ssSetPath(rts, "xpcosc/PCI-6221 AD");
      ssSetRTModel(rts,xpcosc_rtM);
      ssSetParentSS(rts, (NULL));
      ssSetRootSS(rts, rts);
      ssSetVersion(rts, SIMSTRUCT_VERSION_LEVEL2);

      /* parameters */
      {
        mxArray **sfcnParams = (mxArray **)
          &xpcosc_rtM->NonInlinedSFcns.Sfcn0.params;
        ssSetSFcnParamsCount(rts, 7);
        ssSetSFcnParamsPtr(rts, &sfcnParams[0]);
        ssSetSFcnParam(rts, 0, (mxArray*)xpcosc_P.PCI6221AD_P1_Size);
        ssSetSFcnParam(rts, 1, (mxArray*)xpcosc_P.PCI6221AD_P2_Size);
        ssSetSFcnParam(rts, 2, (mxArray*)xpcosc_P.PCI6221AD_P3_Size);
        ssSetSFcnParam(rts, 3, (mxArray*)xpcosc_P.PCI6221AD_P4_Size);
        ssSetSFcnParam(rts, 4, (mxArray*)xpcosc_P.PCI6221AD_P5_Size);
        ssSetSFcnParam(rts, 5, (mxArray*)xpcosc_P.PCI6221AD_P6_Size);
        ssSetSFcnParam(rts, 6, (mxArray*)xpcosc_P.PCI6221AD_P7_Size);
      }

      /* work vectors */
      ssSetIWork(rts, (int_T *) &xpcosc_DWork.PCI6221AD_IWORK[0]);
      ssSetPWork(rts, (void **) &xpcosc_DWork.PCI6221AD_PWORK);

      {
        struct _ssDWorkRecord *dWorkRecord = (struct _ssDWorkRecord *)
          &xpcosc_rtM->NonInlinedSFcns.Sfcn0.dWork;
        struct _ssDWorkAuxRecord *dWorkAuxRecord = (struct _ssDWorkAuxRecord *)
          &xpcosc_rtM->NonInlinedSFcns.Sfcn0.dWorkAux;
        ssSetSFcnDWork(rts, dWorkRecord);
        ssSetSFcnDWorkAux(rts, dWorkAuxRecord);
        _ssSetNumDWork(rts, 2);

        /* IWORK */
        ssSetDWorkWidth(rts, 0, 41);
        ssSetDWorkDataType(rts, 0,SS_INTEGER);
        ssSetDWorkComplexSignal(rts, 0, 0);
        ssSetDWork(rts, 0, &xpcosc_DWork.PCI6221AD_IWORK[0]);

        /* PWORK */
        ssSetDWorkWidth(rts, 1, 1);
        ssSetDWorkDataType(rts, 1,SS_POINTER);
        ssSetDWorkComplexSignal(rts, 1, 0);
        ssSetDWork(rts, 1, &xpcosc_DWork.PCI6221AD_PWORK);
      }

      /* registration */
      adnipcim(rts);
      sfcnInitializeSizes(rts);
      sfcnInitializeSampleTimes(rts);

      /* adjust sample time */
      ssSetSampleTime(rts, 0, 0.001);
      ssSetOffsetTime(rts, 0, 0.0);
      sfcnTsMap[0] = 1;

      /* set compiled values of dynamic vector attributes */
      ssSetNumNonsampledZCs(rts, 0);

      /* Update connectivity flags for each port */
      _ssSetOutputPortConnected(rts, 0, 1);
      _ssSetOutputPortBeingMerged(rts, 0, 0);

      /* Update the BufferDstPort flags for each input port */
    }

    /* Level2 S-Function Block: xpcosc/<Root>/PCI-6713 DA (danipci671x) */
    {
      SimStruct *rts = xpcosc_rtM->childSfunctions[1];

      /* timing info */
      time_T *sfcnPeriod = xpcosc_rtM->NonInlinedSFcns.Sfcn1.sfcnPeriod;
      time_T *sfcnOffset = xpcosc_rtM->NonInlinedSFcns.Sfcn1.sfcnOffset;
      int_T *sfcnTsMap = xpcosc_rtM->NonInlinedSFcns.Sfcn1.sfcnTsMap;
      (void) memset((void*)sfcnPeriod, 0,
                    sizeof(time_T)*1);
      (void) memset((void*)sfcnOffset, 0,
                    sizeof(time_T)*1);
      ssSetSampleTimePtr(rts, &sfcnPeriod[0]);
      ssSetOffsetTimePtr(rts, &sfcnOffset[0]);
      ssSetSampleTimeTaskIDPtr(rts, sfcnTsMap);

      /* Set up the mdlInfo pointer */
      {
        ssSetBlkInfo2Ptr(rts, &xpcosc_rtM->NonInlinedSFcns.blkInfo2[1]);
      }

      ssSetRTWSfcnInfo(rts, xpcosc_rtM->sfcnInfo);

      /* Allocate memory of model methods 2 */
      {
        ssSetModelMethods2(rts, &xpcosc_rtM->NonInlinedSFcns.methods2[1]);
      }

      /* Allocate memory of model methods 3 */
      {
        ssSetModelMethods3(rts, &xpcosc_rtM->NonInlinedSFcns.methods3[1]);
      }

      /* Allocate memory for states auxilliary information */
      {
        ssSetStatesInfo2(rts, &xpcosc_rtM->NonInlinedSFcns.statesInfo2[1]);
      }

      /* inputs */
      {
        _ssSetNumInputPorts(rts, 1);
        ssSetPortInfoForInputs(rts,
          &xpcosc_rtM->NonInlinedSFcns.Sfcn1.inputPortInfo[0]);

        /* port 0 */
        {
          real_T const **sfcnUPtrs = (real_T const **)
            &xpcosc_rtM->NonInlinedSFcns.Sfcn1.UPtrs0;
          sfcnUPtrs[0] = &xpcosc_B.RateTransition;
          ssSetInputPortSignalPtrs(rts, 0, (InputPtrsType)&sfcnUPtrs[0]);
          _ssSetInputPortNumDimensions(rts, 0, 1);
          ssSetInputPortWidth(rts, 0, 1);
        }
      }

      /* path info */
      ssSetModelName(rts, "PCI-6713 DA");
      ssSetPath(rts, "xpcosc/PCI-6713 DA");
      ssSetRTModel(rts,xpcosc_rtM);
      ssSetParentSS(rts, (NULL));
      ssSetRootSS(rts, rts);
      ssSetVersion(rts, SIMSTRUCT_VERSION_LEVEL2);

      /* parameters */
      {
        mxArray **sfcnParams = (mxArray **)
          &xpcosc_rtM->NonInlinedSFcns.Sfcn1.params;
        ssSetSFcnParamsCount(rts, 6);
        ssSetSFcnParamsPtr(rts, &sfcnParams[0]);
        ssSetSFcnParam(rts, 0, (mxArray*)xpcosc_P.PCI6713DA_P1_Size);
        ssSetSFcnParam(rts, 1, (mxArray*)xpcosc_P.PCI6713DA_P2_Size);
        ssSetSFcnParam(rts, 2, (mxArray*)xpcosc_P.PCI6713DA_P3_Size);
        ssSetSFcnParam(rts, 3, (mxArray*)xpcosc_P.PCI6713DA_P4_Size);
        ssSetSFcnParam(rts, 4, (mxArray*)xpcosc_P.PCI6713DA_P5_Size);
        ssSetSFcnParam(rts, 5, (mxArray*)xpcosc_P.PCI6713DA_P6_Size);
      }

      /* work vectors */
      ssSetRWork(rts, (real_T *) &xpcosc_DWork.PCI6713DA_RWORK);
      ssSetIWork(rts, (int_T *) &xpcosc_DWork.PCI6713DA_IWORK[0]);

      {
        struct _ssDWorkRecord *dWorkRecord = (struct _ssDWorkRecord *)
          &xpcosc_rtM->NonInlinedSFcns.Sfcn1.dWork;
        struct _ssDWorkAuxRecord *dWorkAuxRecord = (struct _ssDWorkAuxRecord *)
          &xpcosc_rtM->NonInlinedSFcns.Sfcn1.dWorkAux;
        ssSetSFcnDWork(rts, dWorkRecord);
        ssSetSFcnDWorkAux(rts, dWorkAuxRecord);
        _ssSetNumDWork(rts, 2);

        /* RWORK */
        ssSetDWorkWidth(rts, 0, 1);
        ssSetDWorkDataType(rts, 0,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 0, 0);
        ssSetDWork(rts, 0, &xpcosc_DWork.PCI6713DA_RWORK);

        /* IWORK */
        ssSetDWorkWidth(rts, 1, 2);
        ssSetDWorkDataType(rts, 1,SS_INTEGER);
        ssSetDWorkComplexSignal(rts, 1, 0);
        ssSetDWork(rts, 1, &xpcosc_DWork.PCI6713DA_IWORK[0]);
      }

      /* registration */
      danipci671x(rts);
      sfcnInitializeSizes(rts);
      sfcnInitializeSampleTimes(rts);

      /* adjust sample time */
      ssSetSampleTime(rts, 0, 0.001);
      ssSetOffsetTime(rts, 0, 0.0);
      sfcnTsMap[0] = 1;

      /* set compiled values of dynamic vector attributes */
      ssSetNumNonsampledZCs(rts, 0);

      /* Update connectivity flags for each port */
      _ssSetInputPortConnected(rts, 0, 1);

      /* Update the BufferDstPort flags for each input port */
      ssSetInputPortBufferDstPort(rts, 0, -1);
    }
  }
}
Ejemplo n.º 24
0
/* Registration function */
RT_MODEL_AD_model_T *AD_model(void)
{
  /* Registration code */

  /* initialize non-finites */
  rt_InitInfAndNaN(sizeof(real_T));

  /* initialize real-time model */
  (void) memset((void *)AD_model_M, 0,
                sizeof(RT_MODEL_AD_model_T));
  rtsiSetSolverName(&AD_model_M->solverInfo,"FixedStepDiscrete");
  AD_model_M->solverInfoPtr = (&AD_model_M->solverInfo);

  /* Initialize timing info */
  {
    int_T *mdlTsMap = AD_model_M->Timing.sampleTimeTaskIDArray;
    mdlTsMap[0] = 0;
    AD_model_M->Timing.sampleTimeTaskIDPtr = (&mdlTsMap[0]);
    AD_model_M->Timing.sampleTimes = (&AD_model_M->Timing.sampleTimesArray[0]);
    AD_model_M->Timing.offsetTimes = (&AD_model_M->Timing.offsetTimesArray[0]);

    /* task periods */
    AD_model_M->Timing.sampleTimes[0] = (0.02);

    /* task offsets */
    AD_model_M->Timing.offsetTimes[0] = (0.0);
  }

  rtmSetTPtr(AD_model_M, &AD_model_M->Timing.tArray[0]);

  {
    int_T *mdlSampleHits = AD_model_M->Timing.sampleHitArray;
    mdlSampleHits[0] = 1;
    AD_model_M->Timing.sampleHits = (&mdlSampleHits[0]);
  }

  rtmSetTFinal(AD_model_M, 10.0);
  AD_model_M->Timing.stepSize0 = 0.02;

  /* External mode info */
  AD_model_M->Sizes.checksums[0] = (3901477771U);
  AD_model_M->Sizes.checksums[1] = (4057706284U);
  AD_model_M->Sizes.checksums[2] = (227477489U);
  AD_model_M->Sizes.checksums[3] = (819159214U);

  {
    static const sysRanDType rtAlwaysEnabled = SUBSYS_RAN_BC_ENABLE;
    static RTWExtModeInfo rt_ExtModeInfo;
    static const sysRanDType *systemRan[1];
    AD_model_M->extModeInfo = (&rt_ExtModeInfo);
    rteiSetSubSystemActiveVectorAddresses(&rt_ExtModeInfo, systemRan);
    systemRan[0] = &rtAlwaysEnabled;
    rteiSetModelMappingInfoPtr(AD_model_M->extModeInfo,
      &AD_model_M->SpecialInfo.mappingInfo);
    rteiSetChecksumsPtr(AD_model_M->extModeInfo, AD_model_M->Sizes.checksums);
    rteiSetTPtr(AD_model_M->extModeInfo, rtmGetTPtr(AD_model_M));
  }

  AD_model_M->solverInfoPtr = (&AD_model_M->solverInfo);
  AD_model_M->Timing.stepSize = (0.02);
  rtsiSetFixedStepSize(&AD_model_M->solverInfo, 0.02);
  rtsiSetSolverMode(&AD_model_M->solverInfo, SOLVER_MODE_SINGLETASKING);

  /* block I/O */
  AD_model_M->ModelData.blockIO = ((void *) &AD_model_B);
  (void) memset(((void *) &AD_model_B), 0,
                sizeof(B_AD_model_T));

  /* parameters */
  AD_model_M->ModelData.defaultParam = ((real_T *)&AD_model_P);

  /* states (dwork) */
  AD_model_M->ModelData.dwork = ((void *) &AD_model_DW);
  (void) memset((void *)&AD_model_DW, 0,
                sizeof(DW_AD_model_T));

  /* data type transition information */
  {
    static DataTypeTransInfo dtInfo;
    (void) memset((char_T *) &dtInfo, 0,
                  sizeof(dtInfo));
    AD_model_M->SpecialInfo.mappingInfo = (&dtInfo);
    dtInfo.numDataTypes = 14;
    dtInfo.dataTypeSizes = &rtDataTypeSizes[0];
    dtInfo.dataTypeNames = &rtDataTypeNames[0];

    /* Block I/O transition table */
    dtInfo.B = &rtBTransTable;

    /* Parameters transition table */
    dtInfo.P = &rtPTransTable;
  }

  /* child S-Function registration */
  {
    RTWSfcnInfo *sfcnInfo = &AD_model_M->NonInlinedSFcns.sfcnInfo;
    AD_model_M->sfcnInfo = (sfcnInfo);
    rtssSetErrorStatusPtr(sfcnInfo, (&rtmGetErrorStatus(AD_model_M)));
    rtssSetNumRootSampTimesPtr(sfcnInfo, &AD_model_M->Sizes.numSampTimes);
    AD_model_M->NonInlinedSFcns.taskTimePtrs[0] = &(rtmGetTPtr(AD_model_M)[0]);
    rtssSetTPtrPtr(sfcnInfo,AD_model_M->NonInlinedSFcns.taskTimePtrs);
    rtssSetTStartPtr(sfcnInfo, &rtmGetTStart(AD_model_M));
    rtssSetTFinalPtr(sfcnInfo, &rtmGetTFinal(AD_model_M));
    rtssSetTimeOfLastOutputPtr(sfcnInfo, &rtmGetTimeOfLastOutput(AD_model_M));
    rtssSetStepSizePtr(sfcnInfo, &AD_model_M->Timing.stepSize);
    rtssSetStopRequestedPtr(sfcnInfo, &rtmGetStopRequested(AD_model_M));
    rtssSetDerivCacheNeedsResetPtr(sfcnInfo,
      &AD_model_M->ModelData.derivCacheNeedsReset);
    rtssSetZCCacheNeedsResetPtr(sfcnInfo,
      &AD_model_M->ModelData.zCCacheNeedsReset);
    rtssSetBlkStateChangePtr(sfcnInfo, &AD_model_M->ModelData.blkStateChange);
    rtssSetSampleHitsPtr(sfcnInfo, &AD_model_M->Timing.sampleHits);
    rtssSetPerTaskSampleHitsPtr(sfcnInfo, &AD_model_M->Timing.perTaskSampleHits);
    rtssSetSimModePtr(sfcnInfo, &AD_model_M->simMode);
    rtssSetSolverInfoPtr(sfcnInfo, &AD_model_M->solverInfoPtr);
  }

  AD_model_M->Sizes.numSFcns = (1);

  /* register each child */
  {
    (void) memset((void *)&AD_model_M->NonInlinedSFcns.childSFunctions[0], 0,
                  1*sizeof(SimStruct));
    AD_model_M->childSfunctions =
      (&AD_model_M->NonInlinedSFcns.childSFunctionPtrs[0]);
    AD_model_M->childSfunctions[0] =
      (&AD_model_M->NonInlinedSFcns.childSFunctions[0]);

    /* Level2 S-Function Block: AD_model/<Root>/Get_Parameter  (AD_v2) */
    {
      SimStruct *rts = AD_model_M->childSfunctions[0];

      /* timing info */
      time_T *sfcnPeriod = AD_model_M->NonInlinedSFcns.Sfcn0.sfcnPeriod;
      time_T *sfcnOffset = AD_model_M->NonInlinedSFcns.Sfcn0.sfcnOffset;
      int_T *sfcnTsMap = AD_model_M->NonInlinedSFcns.Sfcn0.sfcnTsMap;
      (void) memset((void*)sfcnPeriod, 0,
                    sizeof(time_T)*1);
      (void) memset((void*)sfcnOffset, 0,
                    sizeof(time_T)*1);
      ssSetSampleTimePtr(rts, &sfcnPeriod[0]);
      ssSetOffsetTimePtr(rts, &sfcnOffset[0]);
      ssSetSampleTimeTaskIDPtr(rts, sfcnTsMap);

      /* Set up the mdlInfo pointer */
      {
        ssSetBlkInfo2Ptr(rts, &AD_model_M->NonInlinedSFcns.blkInfo2[0]);
      }

      ssSetRTWSfcnInfo(rts, AD_model_M->sfcnInfo);

      /* Allocate memory of model methods 2 */
      {
        ssSetModelMethods2(rts, &AD_model_M->NonInlinedSFcns.methods2[0]);
      }

      /* Allocate memory of model methods 3 */
      {
        ssSetModelMethods3(rts, &AD_model_M->NonInlinedSFcns.methods3[0]);
      }

      /* Allocate memory for states auxilliary information */
      {
        ssSetStatesInfo2(rts, &AD_model_M->NonInlinedSFcns.statesInfo2[0]);
      }

      /* outputs */
      {
        ssSetPortInfoForOutputs(rts,
          &AD_model_M->NonInlinedSFcns.Sfcn0.outputPortInfo[0]);
        _ssSetNumOutputPorts(rts, 1);

        /* port 0 */
        {
          _ssSetOutputPortNumDimensions(rts, 0, 1);
          ssSetOutputPortWidth(rts, 0, 1);
          ssSetOutputPortSignal(rts, 0, ((real_T *) &AD_model_B.Get_Parameter));
        }
      }

      /* path info */
      ssSetModelName(rts, "Get_Parameter\n");
      ssSetPath(rts, "AD_model/Get_Parameter ");
      ssSetRTModel(rts,AD_model_M);
      ssSetParentSS(rts, (NULL));
      ssSetRootSS(rts, rts);
      ssSetVersion(rts, SIMSTRUCT_VERSION_LEVEL2);

      /* parameters */
      {
        mxArray **sfcnParams = (mxArray **)
          &AD_model_M->NonInlinedSFcns.Sfcn0.params;
        ssSetSFcnParamsCount(rts, 3);
        ssSetSFcnParamsPtr(rts, &sfcnParams[0]);
        ssSetSFcnParam(rts, 0, (mxArray*)AD_model_P.Get_Parameter_P1_Size);
        ssSetSFcnParam(rts, 1, (mxArray*)AD_model_P.Get_Parameter_P2_Size);
        ssSetSFcnParam(rts, 2, (mxArray*)AD_model_P.Get_Parameter_P3_Size);
      }

      /* work vectors */
      ssSetRWork(rts, (real_T *) &AD_model_DW.Get_Parameter_RWORK[0]);
      ssSetIWork(rts, (int_T *) &AD_model_DW.Get_Parameter_IWORK[0]);

      {
        struct _ssDWorkRecord *dWorkRecord = (struct _ssDWorkRecord *)
          &AD_model_M->NonInlinedSFcns.Sfcn0.dWork;
        struct _ssDWorkAuxRecord *dWorkAuxRecord = (struct _ssDWorkAuxRecord *)
          &AD_model_M->NonInlinedSFcns.Sfcn0.dWorkAux;
        ssSetSFcnDWork(rts, dWorkRecord);
        ssSetSFcnDWorkAux(rts, dWorkAuxRecord);
        _ssSetNumDWork(rts, 2);

        /* RWORK */
        ssSetDWorkWidth(rts, 0, 2);
        ssSetDWorkDataType(rts, 0,SS_DOUBLE);
        ssSetDWorkComplexSignal(rts, 0, 0);
        ssSetDWork(rts, 0, &AD_model_DW.Get_Parameter_RWORK[0]);

        /* IWORK */
        ssSetDWorkWidth(rts, 1, 2);
        ssSetDWorkDataType(rts, 1,SS_INTEGER);
        ssSetDWorkComplexSignal(rts, 1, 0);
        ssSetDWork(rts, 1, &AD_model_DW.Get_Parameter_IWORK[0]);
      }

      /* registration */
      AD_v2(rts);
      sfcnInitializeSizes(rts);
      sfcnInitializeSampleTimes(rts);

      /* adjust sample time */
      ssSetSampleTime(rts, 0, 0.02);
      ssSetOffsetTime(rts, 0, 0.0);
      sfcnTsMap[0] = 0;

      /* set compiled values of dynamic vector attributes */
      ssSetNumNonsampledZCs(rts, 0);

      /* Update connectivity flags for each port */
      _ssSetOutputPortConnected(rts, 0, 0);
      _ssSetOutputPortBeingMerged(rts, 0, 0);

      /* Update the BufferDstPort flags for each input port */
    }
  }

  /* Initialize Sizes */
  AD_model_M->Sizes.numContStates = (0);/* Number of continuous states */
  AD_model_M->Sizes.numY = (0);        /* Number of model outputs */
  AD_model_M->Sizes.numU = (0);        /* Number of model inputs */
  AD_model_M->Sizes.sysDirFeedThru = (0);/* The model is not direct feedthrough */
  AD_model_M->Sizes.numSampTimes = (1);/* Number of sample times */
  AD_model_M->Sizes.numBlocks = (1);   /* Number of blocks */
  AD_model_M->Sizes.numBlockIO = (1);  /* Number of block outputs */
  AD_model_M->Sizes.numBlockPrms = (9);/* Sum of parameter "widths" */
  return AD_model_M;
}