Exemple #1
0
/* Model initialize function */
void model1_initialize(void)
{
  /* Registration code */

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

  /* initialize real-time model */
  (void) memset((void *)model1_M, 0,
                sizeof(RT_MODEL_model1_T));
  rtmSetTFinal(model1_M, 2.0);
  model1_M->Timing.stepSize0 = 5.0E-5;

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

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

  /* states (dwork) */
  (void) memset((void *)&model1_DW, 0,
                sizeof(DW_model1_T));

  /* Matfile logging */
  rt_StartDataLoggingWithStartTime(model1_M->rtwLogInfo, 0.0, rtmGetTFinal
    (model1_M), model1_M->Timing.stepSize0, (&rtmGetErrorStatus(model1_M)));

  /* Enable for Sin: '<S11>/Sine Wave A' */
  model1_DW.systemEnable = 1;

  /* Enable for Sin: '<S11>/Sine Wave B' */
  model1_DW.systemEnable_i = 1;

  /* Enable for Sin: '<S11>/Sine Wave C' */
  model1_DW.systemEnable_g = 1;
}
Exemple #2
0
/* Model initialize function */
void udpRead_initialize(void)
{
  /* Registration code */

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

  /* initialize real-time model */
  (void) memset((void *)udpRead_M, 0,
                sizeof(RT_MODEL_udpRead_T));
  rtmSetTFinal(udpRead_M, -1);
  udpRead_M->Timing.stepSize0 = 0.001;

  /* External mode info */
  udpRead_M->Sizes.checksums[0] = (597430241U);
  udpRead_M->Sizes.checksums[1] = (1019470990U);
  udpRead_M->Sizes.checksums[2] = (4143940322U);
  udpRead_M->Sizes.checksums[3] = (93090447U);

  {
    static const sysRanDType rtAlwaysEnabled = SUBSYS_RAN_BC_ENABLE;
    static RTWExtModeInfo rt_ExtModeInfo;
    static const sysRanDType *systemRan[5];
    udpRead_M->extModeInfo = (&rt_ExtModeInfo);
    rteiSetSubSystemActiveVectorAddresses(&rt_ExtModeInfo, systemRan);
    systemRan[0] = &rtAlwaysEnabled;
    systemRan[1] = (sysRanDType *)&udpRead_DW.ForIteratorSubsystem_SubsysRanB;
    systemRan[2] = (sysRanDType *)&udpRead_DW.ForIteratorSubsystem1_SubsysRan;
    systemRan[3] = (sysRanDType *)&udpRead_DW.EnabledSubsystem_SubsysRanBC;
    systemRan[4] = &rtAlwaysEnabled;
    rteiSetModelMappingInfoPtr(udpRead_M->extModeInfo,
      &udpRead_M->SpecialInfo.mappingInfo);
    rteiSetChecksumsPtr(udpRead_M->extModeInfo, udpRead_M->Sizes.checksums);
    rteiSetTPtr(udpRead_M->extModeInfo, rtmGetTPtr(udpRead_M));
  }

  /* block I/O */
  (void) memset(((void *) &udpRead_B), 0,
                sizeof(B_udpRead_T));

  /* states (dwork) */
  (void) memset((void *)&udpRead_DW, 0,
                sizeof(DW_udpRead_T));

  /* data type transition information */
  {
    static DataTypeTransInfo dtInfo;
    (void) memset((char_T *) &dtInfo, 0,
                  sizeof(dtInfo));
    udpRead_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;
  }

  {
    char_T *sErr;

    /* Start for S-Function (sdspFromNetwork): '<Root>/UDP Receive' */
    sErr = GetErrorBuffer(&udpRead_DW.UDPReceive_NetworkLib[0U]);
    CreateUDPInterface(&udpRead_DW.UDPReceive_NetworkLib[0U]);
    if (*sErr == 0) {
      LibCreate_Network(&udpRead_DW.UDPReceive_NetworkLib[0U], 0, "0.0.0.0",
                        25000, "0.0.0.0", -1, 8192, 4, 0);
    }

    if (*sErr == 0) {
      LibStart(&udpRead_DW.UDPReceive_NetworkLib[0U]);
    }

    if (*sErr != 0) {
      DestroyUDPInterface(&udpRead_DW.UDPReceive_NetworkLib[0U]);
      if (*sErr != 0) {
        rtmSetErrorStatus(udpRead_M, sErr);
        rtmSetStopRequested(udpRead_M, 1);
      }
    }

    /* End of Start for S-Function (sdspFromNetwork): '<Root>/UDP Receive' */

    /* InitializeConditions for UnitDelay: '<S3>/FixPt Unit Delay2' */
    udpRead_DW.FixPtUnitDelay2_DSTATE =
      udpRead_P.FixPtUnitDelay2_InitialConditio;

    /* InitializeConditions for UnitDelay: '<S3>/FixPt Unit Delay1' */
    udpRead_DW.FixPtUnitDelay1_DSTATE = udpRead_P.UnitDelayResettable_vinit;
  }
}
Exemple #3
0
/* Model initialize function */
void HConstfolding_initialize(void)
{
  /* Registration code */

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

  /* initialize real-time model */
  (void) memset((void *)HConstfolding_M, 0,
                sizeof(RT_MODEL_HConstfolding));

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

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

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

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

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

  rtmSetTFinal(HConstfolding_M, 1.0E+8);
  HConstfolding_M->Timing.stepSize0 = 1.0;

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

  /* Setup for data logging */
  {
    rtliSetLogXSignalInfo(HConstfolding_M->rtwLogInfo, (NULL));
    rtliSetLogXSignalPtrs(HConstfolding_M->rtwLogInfo, (NULL));
    rtliSetLogT(HConstfolding_M->rtwLogInfo, "tout");
    rtliSetLogX(HConstfolding_M->rtwLogInfo, "");
    rtliSetLogXFinal(HConstfolding_M->rtwLogInfo, "");
    rtliSetSigLog(HConstfolding_M->rtwLogInfo, "");
    rtliSetLogVarNameModifier(HConstfolding_M->rtwLogInfo, "rt_");
    rtliSetLogFormat(HConstfolding_M->rtwLogInfo, 0);
    rtliSetLogMaxRows(HConstfolding_M->rtwLogInfo, 1000);
    rtliSetLogDecimation(HConstfolding_M->rtwLogInfo, 1);

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

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

    {
      static int_T rt_LoggedOutputWidths[] = {
        1
      };

      static int_T rt_LoggedOutputNumDimensions[] = {
        1
      };

      static int_T rt_LoggedOutputDimensions[] = {
        1
      };

      static boolean_T rt_LoggedOutputIsVarDims[] = {
        0
      };

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

      static int_T rt_LoggedCurrentSignalDimensionsSize[] = {
        4
      };

      static BuiltInDTypeId rt_LoggedOutputDataTypeIds[] = {
        SS_DOUBLE
      };

      static int_T rt_LoggedOutputComplexSignals[] = {
        0
      };

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

      static const char_T *rt_LoggedOutputBlockNames[] = {
        "HConstfolding/Out1" };

      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_LoggedCurrentSignalDimensionsSize,
          rt_LoggedOutputDataTypeIds,
          rt_LoggedOutputComplexSignals,
          (NULL),

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

          { rt_LoggedOutputBlockNames },

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

      rtliSetLogYSignalInfo(HConstfolding_M->rtwLogInfo,
                            rt_LoggedOutputSignalInfo);

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

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

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

  /* states (dwork) */
  (void) memset((void *)&HConstfolding_DWork, 0,
                sizeof(D_Work_HConstfolding));

  /* external outputs */
  HConstfolding_Y.Out1 = 0.0;

  /* Matfile logging */
  rt_StartDataLoggingWithStartTime(HConstfolding_M->rtwLogInfo, 0.0,
    rtmGetTFinal(HConstfolding_M), HConstfolding_M->Timing.stepSize0,
    (&rtmGetErrorStatus(HConstfolding_M)));

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

  /* InitializeConditions for UnitDelay: '<Root>/Unit Delay' */
  HConstfolding_DWork.UnitDelay_DSTATE = HConstfolding_P.UnitDelay_X0;

  /* InitializeConditions for UnitDelay: '<Root>/Unit Delay1' */
  HConstfolding_DWork.UnitDelay1_DSTATE = HConstfolding_P.UnitDelay1_X0;
}
Exemple #4
0
/* Model initialize function */
void motor_hr_initialize(void)
{
  /* Registration code */

  /* initialize real-time model */
  (void) memset((void *)motor_hr_M, 0,
                sizeof(RT_MODEL_motor_hr_T));
  rtmSetTFinal(motor_hr_M, 1000.0);
  motor_hr_M->Timing.stepSize0 = 20.0;

  /* External mode info */
  motor_hr_M->Sizes.checksums[0] = (822641153U);
  motor_hr_M->Sizes.checksums[1] = (2911569967U);
  motor_hr_M->Sizes.checksums[2] = (108929926U);
  motor_hr_M->Sizes.checksums[3] = (297514658U);

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

  /* states (dwork) */
  (void) memset((void *)&motor_hr_DW, 0,
                sizeof(DW_motor_hr_T));

  /* external inputs */
  (void) memset((void *)&motor_hr_U, 0,
                sizeof(ExtU_motor_hr_T));

  /* data type transition information */
  {
    static DataTypeTransInfo dtInfo;
    (void) memset((char_T *) &dtInfo, 0,
                  sizeof(dtInfo));
    motor_hr_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;
  }

  /* Start for S-Function (arduinodigitaloutput_sfcn): '<S1>/Digital Output' */
  MW_pinModeOutput(motor_hr_P.DigitalOutput_pinNumber);

  /* Start for S-Function (arduinoanalogoutput_sfcn): '<S2>/PWM' */
  MW_pinModeOutput(motor_hr_P.PWM_pinNumber);
}
/* Model initialize function */
void BP_MC1_initialize(boolean_T firstTime)
{
  (void)firstTime;

  /* Registration code */

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

  /* initialize real-time model */
  (void) memset((void *)BP_MC1_M,0,
                sizeof(RT_MODEL_BP_MC1));

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

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

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

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

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

  rtmSetTFinal(BP_MC1_M, -1);
  BP_MC1_M->Timing.stepSize0 = 0.05;

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

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

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

  /* block I/O */
  BP_MC1_M->ModelData.blockIO = ((void *) &BP_MC1_B);
  (void) memset(((void *) &BP_MC1_B),0,
                sizeof(BlockIO_BP_MC1));

  {
    BP_MC1_B.u1 = 0.0;
    BP_MC1_B.Sign = 0.0;
    BP_MC1_B.PortVPS_X = 0.0;
    BP_MC1_B.PortVPS_X_g = 0.0;
    BP_MC1_B.u1_p = 0.0;
    BP_MC1_B.PortVSP_Y = 0.0;
    BP_MC1_B.PortVSP_Y_i = 0.0;
    BP_MC1_B.u1_g = 0.0;
    BP_MC1_B.StarboardVSP_X = 0.0;
    BP_MC1_B.u1_pj = 0.0;
    BP_MC1_B.StarboardVSP_Y = 0.0;
    BP_MC1_B.Servo1 = 0.0;
    BP_MC1_B.Servo2 = 0.0;
    BP_MC1_B.Servo3 = 0.0;
    BP_MC1_B.Servo4 = 0.0;
    BP_MC1_B.VPS_Speed_Gain = 0.0;
    BP_MC1_B.Sum = 0.0;
    BP_MC1_B.BowThrusterdirection = 0.0;
    BP_MC1_B.BT_D_Gain1 = 0.0;
    BP_MC1_B.BT_D_Gain2 = 0.0;
    BP_MC1_B.Add = 0.0;
    BP_MC1_B.BT_L_Gain1 = 0.0;
    BP_MC1_B.BT_L_Gain2 = 0.0;
    BP_MC1_B.Sum1 = 0.0;
    BP_MC1_B.Sum2 = 0.0;
    BP_MC1_B.Switch = 0.0;
    BP_MC1_B.Switch2 = 0.0;
  }

  /* parameters */
  BP_MC1_M->ModelData.defaultParam = ((real_T *) &BP_MC1_P);

  /* states (dwork) */
  BP_MC1_M->Work.dwork = ((void *) &BP_MC1_DWork);
  (void) memset((void *)&BP_MC1_DWork, 0,
                sizeof(D_Work_BP_MC1));
}
Exemple #6
0
/* Model initialize function */
void CelpSimulink_initialize(boolean_T firstTime)
{
  (void)firstTime;

  /* Registration code */

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

  /* initialize real-time model */
  (void) memset((char_T *)CelpSimulink_M,0,
                sizeof(RT_MODEL_CelpSimulink));

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

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

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

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

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

  rtmSetTFinal(CelpSimulink_M, -1);
  CelpSimulink_M->Timing.stepSize0 = 0.01;

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

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

  /* block I/O */
  CelpSimulink_M->ModelData.blockIO = ((void *) &CelpSimulink_B);
  (void) memset(((void *) &CelpSimulink_B),0,
                sizeof(BlockIO_CelpSimulink));

  {
    int_T i;
    void *pVoidBlockIORegion;
    pVoidBlockIORegion = (void *)(&CelpSimulink_B.FromWaveFile[0]);
    for (i = 0; i < 411; i++) {
      ((real32_T*)pVoidBlockIORegion)[i] = 0.0F;
    }
  }

  /* parameters */
  CelpSimulink_M->ModelData.defaultParam = ((real_T *) &CelpSimulink_P);

  /* states (dwork) */
  CelpSimulink_M->Work.dwork = ((void *) &CelpSimulink_DWork);
  (void) memset((char_T *) &CelpSimulink_DWork,0,
                sizeof(D_Work_CelpSimulink));
  CelpSimulink_DWork.Maximum1_Valdata = 0.0;

  {
    int_T i;
    real32_T *dwork_ptr = (real32_T *)
      &CelpSimulink_DWork.PreEmphasis_FILT_STATES[0];
    for (i = 0; i < 1122; i++) {
      dwork_ptr[i] = 0.0F;
    }
  }
}
Exemple #7
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] = (943881189U);
  DI_model_M->Sizes.checksums[1] = (2376373844U);
  DI_model_M->Sizes.checksums[2] = (1356612486U);
  DI_model_M->Sizes.checksums[3] = (687118842U);

  {
    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);

  /* 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];
  }

  /* 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);

      /* 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;
}
Exemple #8
0
/* Model initialize function */
void arbeitspunkt_initialize(boolean_T firstTime)
{
  (void)firstTime;

  /* Registration code */

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

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

  rtsiSetSimTimeStep(&arbeitspunkt_M->solverInfo, MAJOR_TIME_STEP);
  rtsiSetSolverName(&arbeitspunkt_M->solverInfo,"FixedStepDiscrete");

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

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

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

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

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

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

  /* external mode info */
  arbeitspunkt_M->Sizes.checksums[0] = (51356583U);
  arbeitspunkt_M->Sizes.checksums[1] = (1228941243U);
  arbeitspunkt_M->Sizes.checksums[2] = (1622391598U);
  arbeitspunkt_M->Sizes.checksums[3] = (3849823737U);

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

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

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

  {
    int_T i;
    void *pVoidBlockIORegion;
    pVoidBlockIORegion = (void *)(&arbeitspunkt_B.V_Step);
    for (i = 0; i < 3; i++) {
      ((real_T*)pVoidBlockIORegion)[i] = 0.0;
    }
  }

  /* parameters */
  arbeitspunkt_M->ModelData.defaultParam = ((real_T *) &arbeitspunkt_P);

  /* states (dwork) */
  arbeitspunkt_M->Work.dwork = ((void *) &arbeitspunkt_DWork);
  (void) memset((char_T *) &arbeitspunkt_DWork,0,
                sizeof(D_Work_arbeitspunkt));

  /* data type transition information */
  {
    static DataTypeTransInfo dtInfo;
    (void) memset((char_T *) &dtInfo,0,
                  sizeof(dtInfo));
    arbeitspunkt_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;
  }
}
/* Registration function */
RT_MODEL_Force_ctrl_sixaxis_T *Force_ctrl_sixaxis(void)
{
  /* Registration code */

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

  /* initialize real-time model */
  (void) memset((void *)Force_ctrl_sixaxis_M, 0,
                sizeof(RT_MODEL_Force_ctrl_sixaxis_T));

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

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

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

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

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

  rtmSetTFinal(Force_ctrl_sixaxis_M, -1);
  Force_ctrl_sixaxis_M->Timing.stepSize0 = 0.01;

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

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

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

  /* block I/O */
  Force_ctrl_sixaxis_M->ModelData.blockIO = ((void *) &Force_ctrl_sixaxis_B);
  (void) memset(((void *) &Force_ctrl_sixaxis_B), 0,
                sizeof(B_Force_ctrl_sixaxis_T));

  /* parameters */
  Force_ctrl_sixaxis_M->ModelData.defaultParam = ((real_T *)
    &Force_ctrl_sixaxis_P);

  /* states (dwork) */
  Force_ctrl_sixaxis_M->ModelData.dwork = ((void *) &Force_ctrl_sixaxis_DW);
  (void) memset((void *)&Force_ctrl_sixaxis_DW, 0,
                sizeof(DW_Force_ctrl_sixaxis_T));

  /* Initialize Sizes */
  Force_ctrl_sixaxis_M->Sizes.numContStates = (0);/* Number of continuous states */
  Force_ctrl_sixaxis_M->Sizes.numY = (0);/* Number of model outputs */
  Force_ctrl_sixaxis_M->Sizes.numU = (0);/* Number of model inputs */
  Force_ctrl_sixaxis_M->Sizes.sysDirFeedThru = (0);/* The model is not direct feedthrough */
  Force_ctrl_sixaxis_M->Sizes.numSampTimes = (1);/* Number of sample times */
  Force_ctrl_sixaxis_M->Sizes.numBlocks = (22);/* Number of blocks */
  Force_ctrl_sixaxis_M->Sizes.numBlockIO = (12);/* Number of block outputs */
  Force_ctrl_sixaxis_M->Sizes.numBlockPrms = (96);/* Sum of parameter "widths" */
  return Force_ctrl_sixaxis_M;
}
Exemple #10
0
/* Model initialize function */
void m1006_initialize(boolean_T firstTime)
{

  if (firstTime) {
    /* registration code */
    /* initialize real-time model */
    (void)memset((char_T *)m1006_M, 0, sizeof(rtModel_m1006));

    {
      /* Setup solver object */

      rtsiSetSimTimeStepPtr(&m1006_M->solverInfo, &m1006_M->Timing.simTimeStep);
      rtsiSetTPtr(&m1006_M->solverInfo, &rtmGetTPtr(m1006_M));
      rtsiSetStepSizePtr(&m1006_M->solverInfo, &m1006_M->Timing.stepSize0);
      rtsiSetdXPtr(&m1006_M->solverInfo, &m1006_M->ModelData.derivs);
      rtsiSetContStatesPtr(&m1006_M->solverInfo, &m1006_M->ModelData.contStates);
      rtsiSetNumContStatesPtr(&m1006_M->solverInfo,
       &m1006_M->Sizes.numContStates);
      rtsiSetErrorStatusPtr(&m1006_M->solverInfo, &rtmGetErrorStatus(m1006_M));

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

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

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

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

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

    rtmSetTFinal(m1006_M, 10.0);
    m1006_M->Timing.stepSize0 = 0.1;
    m1006_M->Timing.stepSize1 = 0.1;

    /* Setup for data logging */
    {
      static RTWLogInfo rt_DataLoggingInfo;

      m1006_M->rtwLogInfo = &rt_DataLoggingInfo;

      rtliSetLogFormat(m1006_M->rtwLogInfo, 0);

      rtliSetLogMaxRows(m1006_M->rtwLogInfo, 1000);

      rtliSetLogDecimation(m1006_M->rtwLogInfo, 1);

      rtliSetLogVarNameModifier(m1006_M->rtwLogInfo, "rt_");

      rtliSetLogT(m1006_M->rtwLogInfo, "tout");

      rtliSetLogX(m1006_M->rtwLogInfo, "");

      rtliSetLogXFinal(m1006_M->rtwLogInfo, "");

      rtliSetSigLog(m1006_M->rtwLogInfo, "");

      rtliSetLogXSignalInfo(m1006_M->rtwLogInfo, NULL);

      rtliSetLogXSignalPtrs(m1006_M->rtwLogInfo, NULL);

      rtliSetLogY(m1006_M->rtwLogInfo, "yout");

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

        rtliSetLogYSignalPtrs(m1006_M->rtwLogInfo,
         ((LogSignalPtrsType)rt_LoggedOutputSignalPtrs));
      }
      {

        static int_T rt_LoggedOutputWidths[] = {
          1
        };

        static int_T rt_LoggedOutputNumDimensions[] = {
          1
        };

        static int_T rt_LoggedOutputDimensions[] = {
          1
        };

        static BuiltInDTypeId rt_LoggedOutputDataTypeIds[] = {
          SS_DOUBLE
        };

        static int_T rt_LoggedOutputComplexSignals[] = {
          0
        };

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

        static const char_T *rt_LoggedOutputBlockNames[] = {
          "m1006/Out1"};

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

        static RTWLogSignalInfo rt_LoggedOutputSignalInfo[] = {
          {
            1,
            rt_LoggedOutputWidths,
            rt_LoggedOutputNumDimensions,
            rt_LoggedOutputDimensions,
            rt_LoggedOutputDataTypeIds,
            rt_LoggedOutputComplexSignals,
            NULL,
            rt_LoggedOutputLabels,
            NULL,
            NULL,
            NULL,
            rt_LoggedOutputBlockNames,
            NULL,
            rt_RTWLogDataTypeConvert
          }
        };

        rtliSetLogYSignalInfo(m1006_M->rtwLogInfo, rt_LoggedOutputSignalInfo);
      }
    }

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

    {
      /* block I/O */
      void *b = (void *) &m1006_B;
      m1006_M->ModelData.blockIO = (b);

      {

        int_T i;
        b =&m1006_B.SineWave;
        for (i = 0; i < 2; i++) {
          ((real_T*)b)[i] = 0.0;
        }
      }
    }
    /* parameters */
    m1006_M->ModelData.defaultParam = ((real_T *) &m1006_P);
    /* states */
    {
      real_T *x = (real_T *) &m1006_X;
      m1006_M->ModelData.contStates = (x);
      (void)memset((char_T *)x, 0, sizeof(ContinuousStates_m1006));
    }

    /* external outputs */
    m1006_M->ModelData.outputs = (&m1006_Y);
    m1006_Y.Out1 = 0.0;

    /* initialize non-finites */
    rt_InitInfAndNaN(sizeof(real_T));
  }
}
/* Model initialize function */
void omni_interface_initialize(boolean_T firstTime)
{
  (void)firstTime;

  /* Registration code */

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

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

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

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

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

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

  rtmSetTFinal(omni_interface_M, -1);
  omni_interface_M->Timing.stepSize0 = 0.001;

  /* external mode info */
  omni_interface_M->Sizes.checksums[0] = (3515672156U);
  omni_interface_M->Sizes.checksums[1] = (4130000490U);
  omni_interface_M->Sizes.checksums[2] = (2703472843U);
  omni_interface_M->Sizes.checksums[3] = (3284165155U);

  {
    static const sysRanDType rtAlwaysEnabled = SUBSYS_RAN_BC_ENABLE;
    static RTWExtModeInfo rt_ExtModeInfo;
    static const sysRanDType *systemRan[13];
    omni_interface_M->extModeInfo = (&rt_ExtModeInfo);
    rteiSetSubSystemActiveVectorAddresses(&rt_ExtModeInfo, systemRan);
    systemRan[0] = &rtAlwaysEnabled;
    systemRan[1] = &rtAlwaysEnabled;
    systemRan[2] = &rtAlwaysEnabled;
    systemRan[3] = &rtAlwaysEnabled;
    systemRan[4] = &rtAlwaysEnabled;
    systemRan[5] = &rtAlwaysEnabled;
    systemRan[6] = &rtAlwaysEnabled;
    systemRan[7] = &rtAlwaysEnabled;
    systemRan[8] = &rtAlwaysEnabled;
    systemRan[9] = &rtAlwaysEnabled;
    systemRan[10] = &rtAlwaysEnabled;
    systemRan[11] = &rtAlwaysEnabled;
    systemRan[12] = &rtAlwaysEnabled;
    rteiSetModelMappingInfoPtr(&rt_ExtModeInfo,
      &omni_interface_M->SpecialInfo.mappingInfo);
    rteiSetChecksumsPtr(&rt_ExtModeInfo, omni_interface_M->Sizes.checksums);
    rteiSetTPtr(&rt_ExtModeInfo, rtmGetTPtr(omni_interface_M));
  }

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

  /* block I/O */
  omni_interface_M->ModelData.blockIO = ((void *) &omni_interface_B);
  (void) memset(((void *) &omni_interface_B),0,
                sizeof(BlockIO_omni_interface));

  {
    int_T i;
    void *pVoidBlockIORegion;
    pVoidBlockIORegion = (void *)(&omni_interface_B.Gain2[0]);
    for (i = 0; i < 12; i++) {
      ((real_T*)pVoidBlockIORegion)[i] = 0.0;
    }
  }

  /* parameters */
  omni_interface_M->ModelData.defaultParam = ((real_T *) &omni_interface_P);

  /* states (dwork) */
  omni_interface_M->Work.dwork = ((void *) &omni_interface_DWork);
  (void) memset((char_T *) &omni_interface_DWork,0,
                sizeof(D_Work_omni_interface));

  {
    int_T i;
    real_T *dwork_ptr = (real_T *) &omni_interface_DWork.FixPtUnitDelay1_DSTATE;
    for (i = 0; i < 19; i++) {
      dwork_ptr[i] = 0.0;
    }
  }

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

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

    /* Parameters transition table */
    dtInfo.P = &rtPTransTable;
  }
}
Exemple #12
0
/* Model initialize function */
void motor_control_initialize(void)
{
  /* Registration code */

  /* initialize real-time model */
  (void) memset((void *)motor_control_M, 0,
                sizeof(RT_MODEL_motor_control_T));
  rtmSetTFinal(motor_control_M, -1);
  motor_control_M->Timing.stepSize0 = 0.05;

  /* External mode info */
  motor_control_M->Sizes.checksums[0] = (2107225776U);
  motor_control_M->Sizes.checksums[1] = (1965539276U);
  motor_control_M->Sizes.checksums[2] = (1036431389U);
  motor_control_M->Sizes.checksums[3] = (618126809U);

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

  /* block I/O */
  (void) memset(((void *) &motor_control_B), 0,
                sizeof(B_motor_control_T));

  /* states (dwork) */
  (void) memset((void *)&motor_control_DW, 0,
                sizeof(DW_motor_control_T));

  /* data type transition information */
  {
    static DataTypeTransInfo dtInfo;
    (void) memset((char_T *) &dtInfo, 0,
                  sizeof(dtInfo));
    motor_control_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;
  }

  /* Start for DiscretePulseGenerator: '<Root>/Pulse Generator' */
  motor_control_DW.clockTickCounter = 0L;

  /* S-Function Block: <Root>/Encoder */
  {
    real_T initVector[1] = { 0 };

    {
      int_T i1;
      for (i1=0; i1 < 1; i1++) {
        motor_control_DW.Encoder_DSTATE = initVector[0];
      }
    }
  }

  /* InitializeConditions for DiscreteIntegrator: '<S1>/Integrator' */
  motor_control_DW.Integrator_DSTATE = motor_control_P.Integrator_IC;

  /* InitializeConditions for DiscreteIntegrator: '<S1>/Filter' */
  motor_control_DW.Filter_DSTATE = motor_control_P.Filter_IC;

  /* S-Function Block: <Root>/PWM */
  {
    real_T initVector[1] = { 0 };

    {
      int_T i1;
      for (i1=0; i1 < 1; i1++) {
        motor_control_DW.PWM_DSTATE = initVector[0];
      }
    }
  }
}
/* Model initialize function */
void motor_test_hierarchies_initialize(void)
{
  /* Registration code */

  /* initialize real-time model */
  (void) memset((void *)motor_test_hierarchies_M, 0,
                sizeof(RT_MODEL_motor_test_hierarchi_T));

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

  rtsiSetSimTimeStep(&motor_test_hierarchies_M->solverInfo, MAJOR_TIME_STEP);
  rtsiSetSolverName(&motor_test_hierarchies_M->solverInfo,"FixedStepDiscrete");
  rtmSetTPtr(motor_test_hierarchies_M, &motor_test_hierarchies_M->Timing.tArray
             [0]);
  rtmSetTFinal(motor_test_hierarchies_M, 200.0);
  motor_test_hierarchies_M->Timing.stepSize0 = 1.0;

  /* External mode info */
  motor_test_hierarchies_M->Sizes.checksums[0] = (1277721381U);
  motor_test_hierarchies_M->Sizes.checksums[1] = (3056422068U);
  motor_test_hierarchies_M->Sizes.checksums[2] = (826496824U);
  motor_test_hierarchies_M->Sizes.checksums[3] = (767811506U);

  {
    static const sysRanDType rtAlwaysEnabled = SUBSYS_RAN_BC_ENABLE;
    static RTWExtModeInfo rt_ExtModeInfo;
    static const sysRanDType *systemRan[9];
    motor_test_hierarchies_M->extModeInfo = (&rt_ExtModeInfo);
    rteiSetSubSystemActiveVectorAddresses(&rt_ExtModeInfo, systemRan);
    systemRan[0] = &rtAlwaysEnabled;
    systemRan[1] = &rtAlwaysEnabled;
    systemRan[2] = &rtAlwaysEnabled;
    systemRan[3] = &rtAlwaysEnabled;
    systemRan[4] = &rtAlwaysEnabled;
    systemRan[5] = &rtAlwaysEnabled;
    systemRan[6] = &rtAlwaysEnabled;
    systemRan[7] = &rtAlwaysEnabled;
    systemRan[8] = &rtAlwaysEnabled;
    rteiSetModelMappingInfoPtr(motor_test_hierarchies_M->extModeInfo,
      &motor_test_hierarchies_M->SpecialInfo.mappingInfo);
    rteiSetChecksumsPtr(motor_test_hierarchies_M->extModeInfo,
                        motor_test_hierarchies_M->Sizes.checksums);
    rteiSetTPtr(motor_test_hierarchies_M->extModeInfo, rtmGetTPtr
                (motor_test_hierarchies_M));
  }

  /* block I/O */
  (void) memset(((void *) &motor_test_hierarchies_B), 0,
                sizeof(B_motor_test_hierarchies_T));

  /* states (dwork) */
  (void) memset((void *)&motor_test_hierarchies_DW, 0,
                sizeof(DW_motor_test_hierarchies_T));

  /* data type transition information */
  {
    static DataTypeTransInfo dtInfo;
    (void) memset((char_T *) &dtInfo, 0,
                  sizeof(dtInfo));
    motor_test_hierarchies_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;
  }

  /* Start for FromWorkspace: '<S3>/FromWs' */
  {
    static real_T pTimeValues0[] = { 0.0, 1.0, 1.0, 2.0, 2.0, 4.0, 4.0, 6.0, 6.0,
      7.0 } ;

    static real_T pDataValues0[] = { 0.0, 128.0, 128.0, 128.0, 128.0, 255.0,
      255.0, 255.0, 255.0, 0.0 } ;

    motor_test_hierarchies_DW.FromWs_PWORK.TimePtr = (void *) pTimeValues0;
    motor_test_hierarchies_DW.FromWs_PWORK.DataPtr = (void *) pDataValues0;
    motor_test_hierarchies_DW.FromWs_IWORK.PrevIndex = 0;
  }

  /* Start for Atomic SubSystem: '<S1>/hl' */
  motor_test_hierarchies_hl_Start((P_hl_motor_test_hierarchies_T *)
    &motor_test_hierarchies_P.hl);

  /* End of Start for SubSystem: '<S1>/hl' */

  /* Start for Atomic SubSystem: '<S1>/hr' */
  /* Start for S-Function (arduinodigitaloutput_sfcn): '<S10>/Digital Output' */
  MW_pinModeOutput(motor_test_hierarchies_P.DigitalOutput_pinNumber);

  /* Start for S-Function (arduinoanalogoutput_sfcn): '<S11>/PWM' */
  MW_pinModeOutput(motor_test_hierarchies_P.PWM_pinNumber);

  /* Start for Atomic SubSystem: '<S1>/vl' */
  motor_test_hierarchies_hl_Start((P_hl_motor_test_hierarchies_T *)
    &motor_test_hierarchies_P.vl);

  /* End of Start for SubSystem: '<S1>/vl' */

  /* Start for Atomic SubSystem: '<S1>/vr' */
  /* Start for S-Function (arduinodigitaloutput_sfcn): '<S14>/Digital Output' */
  MW_pinModeOutput(motor_test_hierarchies_P.DigitalOutput_pinNumber_a);

  /* Start for S-Function (arduinoanalogoutput_sfcn): '<S15>/PWM' */
  MW_pinModeOutput(motor_test_hierarchies_P.PWM_pinNumber_n);
}
Exemple #14
0
void trajectory_test_initialize(boolean_T firstTime)
{
    if (firstTime) {

        /* Registration code */
        /* initialize real-time model */
        (void) memset((char_T *)trajectory_test_M,0,
                      sizeof(RT_MODEL_trajectory_test));

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

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

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

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

        rtmSetTFinal(trajectory_test_M, 20.0);
        trajectory_test_M->Timing.stepSize0 = 0.01;

        /* Setup for data logging */
        {
            static RTWLogInfo rt_DataLoggingInfo;

            trajectory_test_M->rtwLogInfo = &rt_DataLoggingInfo;

            rtliSetLogFormat(trajectory_test_M->rtwLogInfo, 0);

            rtliSetLogMaxRows(trajectory_test_M->rtwLogInfo, 1000);

            rtliSetLogDecimation(trajectory_test_M->rtwLogInfo, 1);

            rtliSetLogVarNameModifier(trajectory_test_M->rtwLogInfo, "rt_");

            rtliSetLogT(trajectory_test_M->rtwLogInfo, "tout");

            rtliSetLogX(trajectory_test_M->rtwLogInfo, "");

            rtliSetLogXFinal(trajectory_test_M->rtwLogInfo, "");

            rtliSetSigLog(trajectory_test_M->rtwLogInfo, "");

            rtliSetLogXSignalInfo(trajectory_test_M->rtwLogInfo, NULL);

            rtliSetLogXSignalPtrs(trajectory_test_M->rtwLogInfo, NULL);

            rtliSetLogY(trajectory_test_M->rtwLogInfo, "");

            rtliSetLogYSignalInfo(trajectory_test_M->rtwLogInfo, NULL);

            rtliSetLogYSignalPtrs(trajectory_test_M->rtwLogInfo, NULL);
        }

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

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

        {

            int_T i;
            void *pVoidBlockIORegion;

            pVoidBlockIORegion = (void *)(&trajectory_test_B.sf_Trajectorydesign2.a0);
            for (i = 0; i < 6; i++) {
                ((real_T*)pVoidBlockIORegion)[i] = 0.0;
            }

            pVoidBlockIORegion = (void *)(&trajectory_test_B.sf_Trajectorydesign1.a0);
            for (i = 0; i < 6; i++) {
                ((real_T*)pVoidBlockIORegion)[i] = 0.0;
            }

            ((real_T*)&trajectory_test_B.sf_Jointreferencesi_m.qa)[0] = 0.0;

            ((real_T*)&trajectory_test_B.sf_Jointreferencesing.qa)[0] = 0.0;
        }

        /* parameters */
        trajectory_test_M->ModelData.defaultParam = ((real_T *) &trajectory_test_P);

        /* states (dwork) */

        trajectory_test_M->Work.dwork = ((void *) &trajectory_test_DWork);

        (void) memset((char_T *) &trajectory_test_DWork,0,
                      sizeof(D_Work_trajectory_test));

        /* initialize non-finites */
        rt_InitInfAndNaN(sizeof(real_T));
    }
}
/* Model initialize function */
void trajectoryModel_initialize(void)
{
  /* Registration code */

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

  /* non-finite (run-time) assignments */
  trajectoryModel_P.stopRadius = rtInf;

  /* initialize real-time model */
  (void) memset((void *)trajectoryModel_M, 0,
                sizeof(RT_MODEL_trajectoryModel_T));

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

  rtsiSetSimTimeStep(&trajectoryModel_M->solverInfo, MAJOR_TIME_STEP);
  trajectoryModel_M->ModelData.intgData.y = trajectoryModel_M->ModelData.odeY;
  trajectoryModel_M->ModelData.intgData.f[0] = trajectoryModel_M->
    ModelData.odeF[0];
  trajectoryModel_M->ModelData.intgData.f[1] = trajectoryModel_M->
    ModelData.odeF[1];
  trajectoryModel_M->ModelData.intgData.f[2] = trajectoryModel_M->
    ModelData.odeF[2];
  trajectoryModel_M->ModelData.contStates = ((X_trajectoryModel_T *)
    &trajectoryModel_X);
  rtsiSetSolverData(&trajectoryModel_M->solverInfo, (void *)
                    &trajectoryModel_M->ModelData.intgData);
  rtsiSetSolverName(&trajectoryModel_M->solverInfo,"ode3");
  rtmSetTPtr(trajectoryModel_M, &trajectoryModel_M->Timing.tArray[0]);
  rtmSetTFinal(trajectoryModel_M, 12.0);
  trajectoryModel_M->Timing.stepSize0 = 0.01;

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

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

  /* block I/O */
  (void) memset(((void *) &trajectoryModel_B), 0,
                sizeof(B_trajectoryModel_T));

  /* states (continuous) */
  {
    (void) memset((void *)&trajectoryModel_X, 0,
                  sizeof(X_trajectoryModel_T));
  }

  /* states (dwork) */
  (void) memset((void *)&trajectoryModel_DW, 0,
                sizeof(DW_trajectoryModel_T));

  /* Matfile logging */
  rt_StartDataLoggingWithStartTime(trajectoryModel_M->rtwLogInfo, 0.0,
    rtmGetTFinal(trajectoryModel_M), trajectoryModel_M->Timing.stepSize0,
    (&rtmGetErrorStatus(trajectoryModel_M)));

  /* Start for If: '<Root>/If' */
  trajectoryModel_DW.If_ActiveSubsystem = -1;

  /* Start for IfAction SubSystem: '<Root>/If Action Subsystem' */
  traject_IfActionSubsystem_Start(&trajectoryModel_B.IfActionSubsystem,
    (P_IfActionSubsystem_trajector_T *)&trajectoryModel_P.IfActionSubsystem);

  /* End of Start for SubSystem: '<Root>/If Action Subsystem' */

  /* Start for IfAction SubSystem: '<Root>/If Action Subsystem1' */
  traject_IfActionSubsystem_Start(&trajectoryModel_B.IfActionSubsystem1,
    (P_IfActionSubsystem_trajector_T *)&trajectoryModel_P.IfActionSubsystem1);

  /* End of Start for SubSystem: '<Root>/If Action Subsystem1' */

  /* InitializeConditions for Integrator: '<Root>/x' */
  trajectoryModel_X.x_CSTATE = trajectoryModel_P.initialConditions[0];

  /* InitializeConditions for Integrator: '<Root>/y ' */
  trajectoryModel_X.y_CSTATE = trajectoryModel_P.initialConditions[2];

  /* InitializeConditions for Integrator: '<Root>/dx' */
  trajectoryModel_X.dx_CSTATE = trajectoryModel_P.initialConditions[1];

  /* InitializeConditions for Integrator: '<Root>/dy' */
  trajectoryModel_X.dy_CSTATE = trajectoryModel_P.initialConditions[3];
}
/* 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 */
    }
  }
}
Exemple #17
0
/* Registration function */
RT_MODEL_sfcndemo_sfunmem_T *sfcndemo_sfunmem(void)
{
  /* Registration code */

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

  /* initialize real-time model */
  (void) memset((void *)sfcndemo_sfunmem_M, 0,
                sizeof(RT_MODEL_sfcndemo_sfunmem_T));

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

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

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

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

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

  rtmSetTFinal(sfcndemo_sfunmem_M, 0.5);
  sfcndemo_sfunmem_M->Timing.stepSize0 = 0.01;

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

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

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

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

    {
      static int_T rt_LoggedOutputWidths[] = {
        1,
        2
      };

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

      static int_T rt_LoggedOutputDimensions[] = {
        1,
        2
      };

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

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

      static int_T rt_LoggedCurrentSignalDimensionsSize[] = {
        4,
        4
      };

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

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

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

      static const char_T *rt_LoggedOutputBlockNames[] = {
        "sfcndemo_sfunmem/Out1",
        "sfcndemo_sfunmem/Out2" };

      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_LoggedOutputSignalInfo[] = {
        {
          2,
          rt_LoggedOutputWidths,
          rt_LoggedOutputNumDimensions,
          rt_LoggedOutputDimensions,
          rt_LoggedOutputIsVarDims,
          rt_LoggedCurrentSignalDimensions,
          rt_LoggedCurrentSignalDimensionsSize,
          rt_LoggedOutputDataTypeIds,
          rt_LoggedOutputComplexSignals,
          (NULL),

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

          { rt_LoggedOutputBlockNames },

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

      rtliSetLogYSignalInfo(sfcndemo_sfunmem_M->rtwLogInfo,
                            rt_LoggedOutputSignalInfo);

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

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

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

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

  {
    sfcndemo_sfunmem_B.DiscretePulseGenerator = 0.0;
    sfcndemo_sfunmem_B.Sum = 0.0;
  }

  /* parameters */
  sfcndemo_sfunmem_M->ModelData.defaultParam = ((real_T *)&sfcndemo_sfunmem_P);

  /* states (dwork) */
  sfcndemo_sfunmem_M->ModelData.dwork = ((void *) &sfcndemo_sfunmem_DW);
  (void) memset((void *)&sfcndemo_sfunmem_DW, 0,
                sizeof(DW_sfcndemo_sfunmem_T));
  sfcndemo_sfunmem_DW.SFunction1_RWORK.InputAtLastUpdate = 0.0;
  sfcndemo_sfunmem_DW.SFunction2_RWORK.InputAtLastUpdate[0] = 0.0;
  sfcndemo_sfunmem_DW.SFunction2_RWORK.InputAtLastUpdate[1] = 0.0;

  /* external outputs */
  sfcndemo_sfunmem_M->ModelData.outputs = (&sfcndemo_sfunmem_Y);
  sfcndemo_sfunmem_Y.Out1 = 0.0;
  sfcndemo_sfunmem_Y.Out2[0] = 0.0;
  sfcndemo_sfunmem_Y.Out2[1] = 0.0;

  /* Initialize Sizes */
  sfcndemo_sfunmem_M->Sizes.numContStates = (0);/* Number of continuous states */
  sfcndemo_sfunmem_M->Sizes.numY = (3);/* Number of model outputs */
  sfcndemo_sfunmem_M->Sizes.numU = (0);/* Number of model inputs */
  sfcndemo_sfunmem_M->Sizes.sysDirFeedThru = (0);/* The model is not direct feedthrough */
  sfcndemo_sfunmem_M->Sizes.numSampTimes = (1);/* Number of sample times */
  sfcndemo_sfunmem_M->Sizes.numBlocks = (7);/* Number of blocks */
  sfcndemo_sfunmem_M->Sizes.numBlockIO = (4);/* Number of block outputs */
  sfcndemo_sfunmem_M->Sizes.numBlockPrms = (4);/* Sum of parameter "widths" */
  return sfcndemo_sfunmem_M;
}
/* 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);
    }
  }
}
Exemple #19
0
RT_MODEL_ALLOCATION *ALLOCATION(void)
{
  /* Registration code */

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

  /* initialize real-time model */
  (void) memset((void *)ALLOCATION_M, 0,
                sizeof(RT_MODEL_ALLOCATION));

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

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

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

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

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

  rtmSetTFinal(ALLOCATION_M, -1);
  ALLOCATION_M->Timing.stepSize0 = 0.01;
  ALLOCATION_M->solverInfoPtr = (&ALLOCATION_M->solverInfo);
  ALLOCATION_M->Timing.stepSize = (0.01);
  rtsiSetFixedStepSize(&ALLOCATION_M->solverInfo, 0.01);
  rtsiSetSolverMode(&ALLOCATION_M->solverInfo, SOLVER_MODE_SINGLETASKING);

  /* external inputs */
  ALLOCATION_M->ModelData.inputs = (((void*)&ALLOCATION_U));
  (void) memset((void *)&ALLOCATION_U, 0,
                sizeof(ExternalInputs_ALLOCATION));

  /* external outputs */
  ALLOCATION_M->ModelData.outputs = (&ALLOCATION_Y);
  (void) memset(&ALLOCATION_Y.w[0], 0,
                6U*sizeof(real32_T));

  /* Initialize Sizes */
  ALLOCATION_M->Sizes.numContStates = (0);/* Number of continuous states */
  ALLOCATION_M->Sizes.numY = (6);      /* Number of model outputs */
  ALLOCATION_M->Sizes.numU = (34);     /* Number of model inputs */
  ALLOCATION_M->Sizes.sysDirFeedThru = (1);/* The model is direct feedthrough */
  ALLOCATION_M->Sizes.numSampTimes = (1);/* Number of sample times */
  ALLOCATION_M->Sizes.numBlocks = (71);/* Number of blocks */
  ALLOCATION_M->Sizes.numBlockIO = (0);/* Number of block outputs */
  return ALLOCATION_M;
}
/* 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;
}
Exemple #21
0
/* Registration function */
RT_MODEL_motor_io_position_T *motor_io_position(void)
{
  /* Registration code */

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

  /* initialize real-time model */
  (void) memset((void *)motor_io_position_M, 0,
                sizeof(RT_MODEL_motor_io_position_T));

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

  rtsiSetSimTimeStep(&motor_io_position_M->solverInfo, MAJOR_TIME_STEP);
  motor_io_position_M->ModelData.intgData.f[0] =
    motor_io_position_M->ModelData.odeF[0];
  motor_io_position_M->ModelData.contStates = ((real_T *) &motor_io_position_X);
  rtsiSetSolverData(&motor_io_position_M->solverInfo, (void *)
                    &motor_io_position_M->ModelData.intgData);
  rtsiSetSolverName(&motor_io_position_M->solverInfo,"ode1");

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

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

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

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

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

  rtmSetTFinal(motor_io_position_M, -1);
  motor_io_position_M->Timing.stepSize0 = 0.03642463102798723;
  motor_io_position_M->Timing.stepSize1 = 0.03642463102798723;
  motor_io_position_M->solverInfoPtr = (&motor_io_position_M->solverInfo);
  motor_io_position_M->Timing.stepSize = (0.03642463102798723);
  rtsiSetFixedStepSize(&motor_io_position_M->solverInfo, 0.03642463102798723);
  rtsiSetSolverMode(&motor_io_position_M->solverInfo, SOLVER_MODE_SINGLETASKING);

  /* block I/O */
  motor_io_position_M->ModelData.blockIO = ((void *) &motor_io_position_B);
  (void) memset(((void *) &motor_io_position_B), 0,
                sizeof(B_motor_io_position_T));

  {
    motor_io_position_B.SFunction1 = 0.0;
    motor_io_position_B.fi1_scaling = 0.0;
    motor_io_position_B.Gfbreal = 0.0;
    motor_io_position_B.SinGenerator = 0.0;
    motor_io_position_B.SquareGenerator = 0.0;
    motor_io_position_B.ref = 0.0;
    motor_io_position_B.Gffreal = 0.0;
    motor_io_position_B.Sum = 0.0;
    motor_io_position_B.Gain = 0.0;
    motor_io_position_B.Volt = 0.0;
    motor_io_position_B.pwm_skalning = 0.0;
    motor_io_position_B.Sum_f = 0.0;
    motor_io_position_B.Gff = 0.0;
    motor_io_position_B.Integrator1 = 0.0;
    motor_io_position_B.Quantizer = 0.0;
    motor_io_position_B.ZeroOrderHold = 0.0;
    motor_io_position_B.Gfb = 0.0;
    motor_io_position_B.Sum1 = 0.0;
    motor_io_position_B.Saturation = 0.0;
    motor_io_position_B.Integrator = 0.0;
    motor_io_position_B.Gain1 = 0.0;
    motor_io_position_B.Add = 0.0;
    motor_io_position_B.kR = 0.0;
    motor_io_position_B.Stickslipregion = 0.0;
    motor_io_position_B.Abs = 0.0;
    motor_io_position_B.Vicousfriction = 0.0;
    motor_io_position_B.Sign = 0.0;
    motor_io_position_B.Product = 0.0;
    motor_io_position_B.Viscousregion = 0.0;
    motor_io_position_B.Friction = 0.0;
    motor_io_position_B.Add1 = 0.0;
    motor_io_position_B.Gain2 = 0.0;
    motor_io_position_B.Add2 = 0.0;
    motor_io_position_B.Inertias1J = 0.0;
    motor_io_position_B.Switch1 = 0.0;
    motor_io_position_B.SFunction2 = 0.0;
    motor_io_position_B.w1_scaling = 0.0;
  }

  /* parameters */
  motor_io_position_M->ModelData.defaultParam = ((real_T *)&motor_io_position_P);

  /* states (continuous) */
  {
    real_T *x = (real_T *) &motor_io_position_X;
    motor_io_position_M->ModelData.contStates = (x);
    (void) memset((void *)&motor_io_position_X, 0,
                  sizeof(X_motor_io_position_T));
  }

  /* states (dwork) */
  motor_io_position_M->ModelData.dwork = ((void *) &motor_io_position_DW);
  (void) memset((void *)&motor_io_position_DW, 0,
                sizeof(DW_motor_io_position_T));
  motor_io_position_DW.Gfbreal_states[0] = 0.0;
  motor_io_position_DW.Gfbreal_states[1] = 0.0;
  motor_io_position_DW.Gffreal_states[0] = 0.0;
  motor_io_position_DW.Gffreal_states[1] = 0.0;
  motor_io_position_DW.Gff_states[0] = 0.0;
  motor_io_position_DW.Gff_states[1] = 0.0;
  motor_io_position_DW.Gfb_states[0] = 0.0;
  motor_io_position_DW.Gfb_states[1] = 0.0;
  motor_io_position_DW.Gfbreal_tmp = 0.0;
  motor_io_position_DW.Gffreal_tmp = 0.0;
  motor_io_position_DW.Gff_tmp = 0.0;
  motor_io_position_DW.Gfb_tmp = 0.0;

  {
    /* user code (registration function declaration) */
    /*Call the macro that initializes the global TRC pointers
       inside the model initialization/registration function. */
    RTI_INIT_TRC_POINTERS();
  }

  /* Initialize Sizes */
  motor_io_position_M->Sizes.numContStates = (2);/* Number of continuous states */
  motor_io_position_M->Sizes.numY = (0);/* Number of model outputs */
  motor_io_position_M->Sizes.numU = (0);/* Number of model inputs */
  motor_io_position_M->Sizes.sysDirFeedThru = (0);/* The model is not direct feedthrough */
  motor_io_position_M->Sizes.numSampTimes = (2);/* Number of sample times */
  motor_io_position_M->Sizes.numBlocks = (58);/* Number of blocks */
  motor_io_position_M->Sizes.numBlockIO = (39);/* Number of block outputs */
  motor_io_position_M->Sizes.numBlockPrms = (58);/* Sum of parameter "widths" */
  return motor_io_position_M;
}
/* Model initialize function */
void GyroskopAuswertung_initialize(void)
{
  /* Registration code */

  /* initialize real-time model */
  (void) memset((void *)GyroskopAuswertung_M, 0,
                sizeof(RT_MODEL_GyroskopAuswertung_T));
  rtmSetTFinal(GyroskopAuswertung_M, 10.0);
  GyroskopAuswertung_M->Timing.stepSize0 = 0.01;

  /* External mode info */
  GyroskopAuswertung_M->Sizes.checksums[0] = (1941814335U);
  GyroskopAuswertung_M->Sizes.checksums[1] = (4017032776U);
  GyroskopAuswertung_M->Sizes.checksums[2] = (2489100557U);
  GyroskopAuswertung_M->Sizes.checksums[3] = (945044384U);

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

  /* block I/O */
  (void) memset(((void *) &GyroskopAuswertung_B), 0,
                sizeof(B_GyroskopAuswertung_T));

  /* states (dwork) */
  (void) memset((void *)&GyroskopAuswertung_DW, 0,
                sizeof(DW_GyroskopAuswertung_T));

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

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

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

  /* S-Function Block: <Root>/Sensor1 */
  {
    real_T initVector[1] = { 0 };

    {
      int_T i1;
      for (i1=0; i1 < 1; i1++) {
        GyroskopAuswertung_DW.Sensor1_DSTATE = initVector[0];
      }
    }
  }

  /* S-Function Block: <Root>/Sensor2 */
  {
    real_T initVector[1] = { 0 };

    {
      int_T i1;
      for (i1=0; i1 < 1; i1++) {
        GyroskopAuswertung_DW.Sensor2_DSTATE = initVector[0];
      }
    }
  }
}
/* Model initialize function */
void Crane_initialize(boolean_T firstTime)
{
  (void)firstTime;

  /* Registration code */

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

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

  rtsiSetSimTimeStep(&Crane_M->solverInfo, MAJOR_TIME_STEP);
  Crane_M->ModelData.intgData.f[0] = Crane_M->ModelData.odeF[0];
  Crane_M->ModelData.contStates = ((real_T *) &Crane_X);
  rtsiSetSolverData(&Crane_M->solverInfo, (void *)&Crane_M->ModelData.intgData);
  rtsiSetSolverName(&Crane_M->solverInfo,"ode1");

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

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

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

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

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

  rtmSetTFinal(Crane_M, -1);
  Crane_M->Timing.stepSize0 = 0.001;
  Crane_M->Timing.stepSize1 = 0.001;

  /* external mode info */
  Crane_M->Sizes.checksums[0] = (2478158774U);
  Crane_M->Sizes.checksums[1] = (3803381746U);
  Crane_M->Sizes.checksums[2] = (277883647U);
  Crane_M->Sizes.checksums[3] = (670793414U);

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

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

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

  {
    int_T i;
    void *pVoidBlockIORegion;
    pVoidBlockIORegion = (void *)(&Crane_B.Block1_o1[0]);
    for (i = 0; i < 49; i++) {
      ((real_T*)pVoidBlockIORegion)[i] = 0.0;
    }
  }

  /* parameters */
  Crane_M->ModelData.defaultParam = ((real_T *) &Crane_P);

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

  /* states (dwork) */
  Crane_M->Work.dwork = ((void *) &Crane_DWork);
  (void) memset((char_T *) &Crane_DWork,0,
                sizeof(D_Work_Crane));

  {
    int_T i;
    real_T *dwork_ptr = (real_T *) &Crane_DWork.Memory_PreviousInput[0];
    for (i = 0; i < 11; i++) {
      dwork_ptr[i] = 0.0;
    }
  }

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

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

    /* Parameters transition table */
    dtInfo.P = &rtPTransTable;
  }
}
int
  main(int argc, char * argv[])
{
  RT_MODEL * S;
  const char * status;
  int_T count;
  int exit_code = exit_success;
  boolean_T parseError = FALSE;
  real_T final_time = -2;              /* Let model select final time */
  int scheduling_priority;
  struct qsched_param scheduling;
  t_period timeout;
  t_timer_notify notify;
  t_error result;

  /*
   * Make controller threads higher priority than external mode threads:
   *   ext_priority = priority of lowest priority external mode thread
   *   min_priority = minimum allowable priority of lowest priority model task
   *   max_priority = maximum allowable priority of lowest priority model task
   */
  int ext_priority = qsched_get_priority_min(QSCHED_FIFO);
  int min_priority = ext_priority + 2;
  int max_priority = qsched_get_priority_max(QSCHED_FIFO) - 0;
  qsigset_t signal_set;
  qsigaction_t action;
  int_T stack_size = 0;                /* default stack size */
  (void) ssPrintf("Entered main(argc=%d, argv=%p)\n", argc, argv);
  for (count = 0; count < argc; count++) {
    (void) ssPrintf("  argv[%d] = %s\n", count, argv[count]);
  }

  scheduling_priority = 2;             /* default priority */
  if (scheduling_priority < min_priority)
    scheduling_priority = min_priority;
  else if (scheduling_priority > max_priority)
    scheduling_priority = max_priority;

  /*
   * Parse the standard RTW parameters.  Let all unrecognized parameters
   * pass through to external mode for parsing.  NULL out all args handled
   * so that the external mode parsing can ignore them.
   */
  for (count = 1; count < argc; ) {
    const char *option = argv[count++];
    char extraneous_characters[2];
    if ((strcmp(option, "-tf") == 0) && (count != argc)) {/* final time */
      const char * tf_argument = argv[count++];
      double time_value;               /* use a double for the sscanf since real_T may be a float or a double depending on the platform */
      if (strcmp(tf_argument, "inf") == 0) {
        time_value = RUN_FOREVER;
      } else {
        int items = sscanf(tf_argument, "%lf%1s", &time_value,
                           extraneous_characters);
        if ((items != 1) || (time_value < 0.0) ) {
          (void) fprintf(stderr,
                         "final_time must be a positive, real value or inf.\n");
          parseError = true;
          break;
        }
      }

      final_time = (real_T) time_value;
      argv[count-2] = NULL;
      argv[count-1] = NULL;
    } else if ((strcmp(option, "-pri") == 0) && (count != argc)) {/* base priority */
      const char * tf_argument = argv[count++];
      int priority;                    /* use an int for the sscanf since int_T may be the wrong size depending on the platform */
      int items = sscanf(tf_argument, "%d%1s", &priority, extraneous_characters);
      if ((items != 1) || (priority < min_priority) ) {
        (void) fprintf(stderr,
                       "priority must be a greater than or equal to %d.\n",
                       min_priority);
        parseError = true;
        break;
      }

      if (priority > max_priority) {
        (void) fprintf(stderr, "priority must be less than or equal to %d.\n",
                       max_priority);
        parseError = true;
        break;
      }

      scheduling_priority = priority;
      argv[count-2] = NULL;
      argv[count-1] = NULL;
    } else if ((strcmp(option, "-ss") == 0) && (count != argc)) {/* stack size */
      const char * stack_argument = argv[count++];
      int stack;                       /* use an int for the sscanf since int_T may be the wrong size depending on the platform */
      int items = sscanf(stack_argument, "%d%1s", &stack, extraneous_characters);
      if ((items != 1) || (stack < QTHREAD_STACK_MIN) ) {
        (void) fprintf(stderr,
                       "stack size must be a integral value greater than or equal to %d.\n",
                       QTHREAD_STACK_MIN);
        parseError = true;
        break;
      }

      stack_size = (int_T)stack;
      argv[count-2] = NULL;
      argv[count-1] = NULL;
    } else if ((strcmp(option, "-d") == 0) && (count != argc)) {/* current directory */
      const char * path_name = argv[count++];
      _chdir(path_name);
      argv[count-2] = NULL;
      argv[count-1] = NULL;
    }
  }

  rtExtModeQuarcParseArgs(argc, (const char **) argv, "shmem://Crane:1");

  /*
   * Check for unprocessed ("unhandled") args.
   */
  for (count = 1; count < argc; count++) {
    if (argv[count] != NULL) {
      (void) fprintf(stderr, "Unexpected command line argument: \"%s\".\n",
                     argv[count]);
      parseError = TRUE;
    }
  }

  if (parseError) {
    (void) fprintf(stderr,
                   "\nUsage: Crane -option1 val1 -option2 val2 -option3 ...\n\n");
    (void) fprintf(stderr,
                   "\t-tf  20               - sets final time to 20 seconds\n");
    (void) fprintf(stderr,
                   "\t-d   C:\\data          - sets current directory to C:\\data\n");
    (void) fprintf(stderr,
                   "\t-pri 5                - sets the minimum thread priority\n");
    (void) fprintf(stderr,
                   "\t-ss  65536            - sets the stack size for model threads\n");
    (void) fprintf(stderr,
                   "\t-w                    - wait for host to connect before starting\n");
    (void) fprintf(stderr,
                   "\t-uri shmem://mymodel  - set external mode URL to \"shmem://mymodel\"\n");
    (void) fprintf(stderr, "\n");
    return (exit_failure);
  }

  /****************************
   * Initialize global memory *
   ****************************/
  (void)memset(&GBLbuf, 0, sizeof(GBLbuf));

  /************************
   * Initialize the model *
   ************************/
  rt_InitInfAndNaN(sizeof(real_T));
  S = Crane();
  if (rtmGetErrorStatus(S) != NULL) {
    (void) fprintf(stderr, "Error during model registration: %s\n",
                   rtmGetErrorStatus(S));
    return (exit_failure);
  }

  if (final_time >= 0.0 || final_time == RUN_FOREVER) {
    rtmSetTFinal(S, final_time);
  } else {
    rtmSetTFinal(S, rtInf);
  }

  action.sa_handler = control_c_handler;
  action.sa_flags = 0;
  qsigemptyset(&action.sa_mask);
  qsigaction(SIGINT, &action, NULL);
  qsigaction(SIGBREAK, &action, NULL);
  qsigemptyset(&signal_set);
  qsigaddset(&signal_set, SIGINT);
  qsigaddset(&signal_set, SIGBREAK);
  qthread_sigmask(QSIG_UNBLOCK, &signal_set, NULL);
  initialize_sizes(S);
  initialize_sample_times(S);
  status = rt_SimInitTimingEngine(rtmGetNumSampleTimes(S),
    rtmGetStepSize(S),
    rtmGetSampleTimePtr(S),
    rtmGetOffsetTimePtr(S),
    rtmGetSampleHitPtr(S),
    rtmGetSampleTimeTaskIDPtr(S),
    rtmGetTStart(S),
    &rtmGetSimTimeStep(S),
    &rtmGetTimingData(S));
  if (status != NULL) {
    (void) fprintf(stderr, "Failed to initialize sample time engine: %s\n",
                   status);
    return (exit_failure);
  }

  rt_CreateIntegrationData(S);
  fflush(stdout);
  if (rtExtModeQuarcStartup(rtmGetRTWExtModeInfo(S),
       rtmGetNumSampleTimes(S),
       &rtmGetStopRequested(S),
       ext_priority,                   /* external mode thread priority */
       stack_size,
       SS_HAVESTDIO)) {
    (void) ssPrintf("\n** starting the model **\n");
    start(S);
    if (rtmGetErrorStatus(S) == NULL) {
      /*************************************************************************
       * Execute the model.
       *************************************************************************/
      if (rtmGetTFinal(S) == RUN_FOREVER) {
        (void) ssPrintf("\n**May run forever. Model stop time set to infinity.**\n");
      }

      timeout.seconds = (t_long) (rtmGetStepSize(S));
      timeout.nanoseconds = (t_int) ((rtmGetStepSize(S) - timeout.seconds) *
        1000000000L);
      result = qtimer_event_create(&notify.notify_value.event);
      if (result == 0) {
        t_timer timer;
        scheduling.sched_priority = scheduling_priority;
        qthread_setschedparam(qthread_self(), QSCHED_FIFO, &scheduling);
        notify.notify_type = TIMER_NOTIFY_EVENT;
        result = qtimer_create(&notify, &timer);
        if (result == 0) {
          result = qtimer_begin_resolution(timer, &timeout);
          if (result == 0) {
            t_period actual_timeout;
            (void) ssPrintf("Creating main thread with priority %d and period %g...\n",
                            scheduling_priority, rtmGetStepSize(S));
            result = qtimer_get_actual_period(timer, &timeout, &actual_timeout);
            if (result == 0 && (timeout.nanoseconds !=
                                actual_timeout.nanoseconds || timeout.seconds !=
                                actual_timeout.seconds))
              (void) ssPrintf("*** Actual period will be %g ***\n",
                              actual_timeout.seconds + 1e-9 *
                              actual_timeout.nanoseconds);
            fflush(stdout);
            result = qtimer_set_time(timer, &timeout, true);
            if (result == 0) {
              /* Enter the periodic loop */
              while (result == 0) {
                if (GBLbuf.stopExecutionFlag || rtmGetStopRequested(S)) {
                  break;
                }

                if (rtmGetTFinal(S) != RUN_FOREVER && rtmGetTFinal(S) - rtmGetT
                    (S) <= rtmGetT(S)*DBL_EPSILON) {
                  break;
                }

                if (qtimer_get_overrun(timer) > 0) {
                  (void) fprintf(stderr,
                                 "Sampling rate is too fast for base rate\n");
                  fflush(stderr);
                }

                rt_OneStep(S);
                result = qtimer_event_wait(notify.notify_value.event);
              }

              /* disarm the timer */
              qtimer_cancel(timer);
              if (rtmGetStopRequested(S) == false && rtmGetErrorStatus(S) ==
                  NULL) {
                /* Execute model last time step if final time expired */
                rt_OneStep(S);
              }

              (void) ssPrintf("Main thread exited\n");
            } else {
              msg_get_error_messageA(NULL, result, GBLbuf.submessage, sizeof
                (GBLbuf.submessage));
              string_format(GBLbuf.message, sizeof(GBLbuf.message),
                            "Unable to set base rate. %s", GBLbuf.submessage);
              rtmSetErrorStatus(S, GBLbuf.message);
            }

            qtimer_end_resolution(timer);
          } else {
            msg_get_error_messageA(NULL, result, GBLbuf.submessage, sizeof
              (GBLbuf.submessage));
            string_format(GBLbuf.message, sizeof(GBLbuf.message),
                          "Sampling period of %lg is too fast for the system clock. %s",
                          rtmGetStepSize(S), GBLbuf.submessage);
            rtmSetErrorStatus(S, GBLbuf.message);
          }

          qtimer_delete(timer);
        } else {
          msg_get_error_messageA(NULL, result, GBLbuf.submessage, sizeof
            (GBLbuf.submessage));
          string_format(GBLbuf.message, sizeof(GBLbuf.message),
                        "Unable to create timer for base rate. %s",
                        GBLbuf.submessage);
          rtmSetErrorStatus(S, GBLbuf.message);
        }
      } else {
        msg_get_error_messageA(NULL, result, GBLbuf.submessage, sizeof
          (GBLbuf.submessage));
        string_format(GBLbuf.message, sizeof(GBLbuf.message),
                      "Unable to create timer event for base rate. %s",
                      GBLbuf.submessage);
        rtmSetErrorStatus(S, GBLbuf.message);
      }

      GBLbuf.stopExecutionFlag = 1;
    }
  } else {
    rtmSetErrorStatus(S, "Unable to initialize external mode.");
  }

  rtExtSetReturnStatus(rtmGetErrorStatus(S));
  rtExtModeQuarcCleanup(rtmGetNumSampleTimes(S));

  /********************
   * Cleanup and exit *
   ********************/
  if (rtmGetErrorStatus(S) != NULL) {
    (void) fprintf(stderr, "%s\n", rtmGetErrorStatus(S));
    exit_code = exit_failure;
  }

  (void) ssPrintf("Invoking model termination function...\n");
  terminate(S);
  (void) ssPrintf("Exiting real-time code\n");
  return (exit_code);
}
Exemple #25
0
/* Model initialize function */
void motor_initialize(void)
{
  /* Registration code */

  /* initialize real-time model */
  (void) memset((void *)motor_M, 0,
                sizeof(RT_MODEL_motor_T));
  rtmSetTFinal(motor_M, -1);
  motor_M->Timing.stepSize0 = 0.2;

  /* External mode info */
  motor_M->Sizes.checksums[0] = (1008116136U);
  motor_M->Sizes.checksums[1] = (3564589615U);
  motor_M->Sizes.checksums[2] = (1322083197U);
  motor_M->Sizes.checksums[3] = (1603772587U);

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

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

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

  {
    uint8_T tmp;
    uint8_T tmp_0;
    uint8_T tmp_1;
    uint8_T tmp_2;
    uint8_T tmp_3;
    uint8_T tmp_4;

    /* Start for S-Function (linuxGpioWrite_sfcn): '<S1>/Left_high' */
    tmp_4 = motor_P.Left_high_p4;
    MW_gpioInit(motor_P.Left_high_p1, motor_P.Left_high_p2, motor_P.Left_high_p3,
                &tmp_4);

    /* Start for S-Function (linuxGpioWrite_sfcn): '<S1>/Left_low' */
    tmp_3 = motor_P.Left_low_p4;
    MW_gpioInit(motor_P.Left_low_p1, motor_P.Left_low_p2, motor_P.Left_low_p3,
                &tmp_3);

    /* Start for S-Function (linuxGpioWrite_sfcn): '<S1>/Right_high' */
    tmp_2 = motor_P.Right_high_p4;
    MW_gpioInit(motor_P.Right_high_p1, motor_P.Right_high_p2,
                motor_P.Right_high_p3, &tmp_2);

    /* Start for S-Function (linuxGpioWrite_sfcn): '<S1>/Right_low' */
    tmp_1 = motor_P.Right_low_p4;
    MW_gpioInit(motor_P.Right_low_p1, motor_P.Right_low_p2, motor_P.Right_low_p3,
                &tmp_1);

    /* Start for S-Function (linuxGpioWrite_sfcn): '<S1>/EN_Left' */
    tmp_0 = motor_P.EN_Left_p4;
    MW_gpioInit(motor_P.EN_Left_p1, motor_P.EN_Left_p2, motor_P.EN_Left_p3,
                &tmp_0);

    /* Start for S-Function (linuxGpioWrite_sfcn): '<S1>/EN_Right' */
    tmp = motor_P.EN_Right_p4;
    MW_gpioInit(motor_P.EN_Right_p1, motor_P.EN_Right_p2, motor_P.EN_Right_p3,
                &tmp);
  }
}
Exemple #26
0
/* Model initialize function */
void Motor_Test_All_initialize(void)
{
  /* Registration code */

  /* initialize real-time model */
  (void) memset((void *)Motor_Test_All_M, 0,
                sizeof(RT_MODEL_Motor_Test_All_T));
  rtmSetTFinal(Motor_Test_All_M, 100.0);
  Motor_Test_All_M->Timing.stepSize0 = 10.0;

  /* External mode info */
  Motor_Test_All_M->Sizes.checksums[0] = (391574619U);
  Motor_Test_All_M->Sizes.checksums[1] = (1808842219U);
  Motor_Test_All_M->Sizes.checksums[2] = (99353943U);
  Motor_Test_All_M->Sizes.checksums[3] = (1218331709U);

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

  /* states (dwork) */
  (void) memset((void *)&Motor_Test_All_DW, 0,
                sizeof(DW_Motor_Test_All_T));

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

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

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

  /* Model Initialize fcn for ModelReference Block: '<Root>/Model' */
  motor_hl_initialize(rtmGetErrorStatusPointer(Motor_Test_All_M),
                      &(Motor_Test_All_DW.Model_DWORK1.rtm));

  /* Model Initialize fcn for ModelReference Block: '<Root>/Model1' */
  motor_vr_initialize(rtmGetErrorStatusPointer(Motor_Test_All_M),
                      &(Motor_Test_All_DW.Model1_DWORK1.rtm));

  /* Model Initialize fcn for ModelReference Block: '<Root>/Model2' */
  motor_vl_initialize(rtmGetErrorStatusPointer(Motor_Test_All_M),
                      &(Motor_Test_All_DW.Model2_DWORK1.rtm));

  /* Model Initialize fcn for ModelReference Block: '<Root>/Model3' */
  motor_hr_initialize(rtmGetErrorStatusPointer(Motor_Test_All_M),
                      &(Motor_Test_All_DW.Model3_DWORK1.rtm));

  /* Start for ModelReference: '<Root>/Model' */
  motor_hl_Start();

  /* Start for ModelReference: '<Root>/Model1' */
  motor_vr_Start();

  /* Start for ModelReference: '<Root>/Model2' */
  motor_vl_Start();

  /* Start for ModelReference: '<Root>/Model3' */
  motor_hr_Start();

  /* InitializeConditions for UnitDelay: '<S2>/Output' */
  Motor_Test_All_DW.Output_DSTATE = Motor_Test_All_P.Output_InitialCondition;
}
/* Model initialize function */
void Koordinatentransfer3_initialize(void)
{
  /* Registration code */

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

  /* initialize real-time model */
  (void) memset((void *)Koordinatentransfer3_M, 0,
                sizeof(RT_MODEL_Koordinatentransfer3_T));
  rtmSetTFinal(Koordinatentransfer3_M, 0.1);
  Koordinatentransfer3_M->Timing.stepSize0 = 0.02;

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

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

    /*
     * Set pointers to the data and signal info for each output
     */
    {
      static void * rt_LoggedOutputSignalPtrs[] = {
        &Koordinatentransfer3_Y.a,
        &Koordinatentransfer3_Y.b,
        &Koordinatentransfer3_Y.c
      };

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

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

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

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

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

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

      static int_T rt_LoggedCurrentSignalDimensionsSize[] = {
        2,
        2,
        2
      };

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

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

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

      static const char_T *rt_LoggedOutputBlockNames[] = {
        "Koordinatentransfer3/a",
        "Koordinatentransfer3/b",
        "Koordinatentransfer3/c" };

      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 },

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

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

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

          { rt_LoggedOutputBlockNames },

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

      rtliSetLogYSignalInfo(Koordinatentransfer3_M->rtwLogInfo,
                            rt_LoggedOutputSignalInfo);

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

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

  /* external inputs */
  (void) memset((void *)&Koordinatentransfer3_U, 0,
                sizeof(ExtU_Koordinatentransfer3_T));

  /* external outputs */
  (void) memset((void *)&Koordinatentransfer3_Y, 0,
                sizeof(ExtY_Koordinatentransfer3_T));

  /* Matfile logging */
  rt_StartDataLoggingWithStartTime(Koordinatentransfer3_M->rtwLogInfo, 0.0,
    rtmGetTFinal(Koordinatentransfer3_M),
    Koordinatentransfer3_M->Timing.stepSize0, (&rtmGetErrorStatus
    (Koordinatentransfer3_M)));
}
Exemple #28
0
/* Model initialize function */
void fi_mdl_radix2fft_withscaling_initialize(boolean_T firstTime)
{

  if (firstTime) {
    /* registration code */
    /* initialize real-time model */
    (void)memset((char_T *)fi_mdl_radix2fft_withscaling_M, 0,
     sizeof(rtModel_fi_mdl_radix2fft_withscaling));

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

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

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

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

    rtmSetTFinal(fi_mdl_radix2fft_withscaling_M, 0.0);
    fi_mdl_radix2fft_withscaling_M->Timing.stepSize0 = 0.25;

    /* Setup for data logging */
    {
      static RTWLogInfo rt_DataLoggingInfo;

      fi_mdl_radix2fft_withscaling_M->rtwLogInfo = &rt_DataLoggingInfo;

      rtliSetLogFormat(fi_mdl_radix2fft_withscaling_M->rtwLogInfo, 0);

      rtliSetLogMaxRows(fi_mdl_radix2fft_withscaling_M->rtwLogInfo, 1000);

      rtliSetLogDecimation(fi_mdl_radix2fft_withscaling_M->rtwLogInfo, 1);

      rtliSetLogVarNameModifier(fi_mdl_radix2fft_withscaling_M->rtwLogInfo,
       "rt_");

      rtliSetLogT(fi_mdl_radix2fft_withscaling_M->rtwLogInfo, "tout");

      rtliSetLogX(fi_mdl_radix2fft_withscaling_M->rtwLogInfo, "");

      rtliSetLogXFinal(fi_mdl_radix2fft_withscaling_M->rtwLogInfo, "");

      rtliSetSigLog(fi_mdl_radix2fft_withscaling_M->rtwLogInfo, "");

      rtliSetLogXSignalInfo(fi_mdl_radix2fft_withscaling_M->rtwLogInfo, NULL);

      rtliSetLogXSignalPtrs(fi_mdl_radix2fft_withscaling_M->rtwLogInfo, NULL);

      rtliSetLogY(fi_mdl_radix2fft_withscaling_M->rtwLogInfo, "");

      rtliSetLogYSignalInfo(fi_mdl_radix2fft_withscaling_M->rtwLogInfo, NULL);

      rtliSetLogYSignalPtrs(fi_mdl_radix2fft_withscaling_M->rtwLogInfo, NULL);
    }

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

    /* parameters */
    fi_mdl_radix2fft_withscaling_M->ModelData.defaultParam = ((real_T *)
      &fi_mdl_radix2fft_withscaling_P);

    /* data type work */
    fi_mdl_radix2fft_withscaling_M->Work.dwork = ((void *)
      &fi_mdl_radix2fft_withscaling_DWork);
    (void)memset((char_T *) &fi_mdl_radix2fft_withscaling_DWork, 0,
     sizeof(D_Work_fi_mdl_radix2fft_withscaling));

    /* initialize non-finites */
    rt_InitInfAndNaN(sizeof(real_T));
  }
}
Exemple #29
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);
    }
  }
}
Exemple #30
0
/* Model initialize function */
void Hammerstein_initialize(void)
{
  /* Registration code */

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

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

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

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

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

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

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

  rtmSetTFinal(Hammerstein_M, 9.9599999999999991);
  Hammerstein_M->Timing.stepSize0 = 0.06;

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

  /* Setup for data logging */
  {
    rtliSetLogXSignalInfo(Hammerstein_M->rtwLogInfo, (NULL));
    rtliSetLogXSignalPtrs(Hammerstein_M->rtwLogInfo, (NULL));
    rtliSetLogT(Hammerstein_M->rtwLogInfo, "tout");
    rtliSetLogX(Hammerstein_M->rtwLogInfo, "");
    rtliSetLogXFinal(Hammerstein_M->rtwLogInfo, "");
    rtliSetSigLog(Hammerstein_M->rtwLogInfo, "");
    rtliSetLogVarNameModifier(Hammerstein_M->rtwLogInfo, "rt_");
    rtliSetLogFormat(Hammerstein_M->rtwLogInfo, 0);
    rtliSetLogMaxRows(Hammerstein_M->rtwLogInfo, 1000);
    rtliSetLogDecimation(Hammerstein_M->rtwLogInfo, 1);

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

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

    {
      static int_T rt_LoggedOutputWidths[] = {
        1
      };

      static int_T rt_LoggedOutputNumDimensions[] = {
        1
      };

      static int_T rt_LoggedOutputDimensions[] = {
        1
      };

      static boolean_T rt_LoggedOutputIsVarDims[] = {
        0
      };

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

      static int_T rt_LoggedCurrentSignalDimensionsSize[] = {
        4
      };

      static BuiltInDTypeId rt_LoggedOutputDataTypeIds[] = {
        SS_DOUBLE
      };

      static int_T rt_LoggedOutputComplexSignals[] = {
        0
      };

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

      static const char_T *rt_LoggedOutputBlockNames[] = {
        "Hammerstein/Out1" };

      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_LoggedCurrentSignalDimensionsSize,
          rt_LoggedOutputDataTypeIds,
          rt_LoggedOutputComplexSignals,
          (NULL),

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

          { rt_LoggedOutputBlockNames },

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

      rtliSetLogYSignalInfo(Hammerstein_M->rtwLogInfo, rt_LoggedOutputSignalInfo);

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

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

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

  /* block I/O */
  (void) memset(((void *) &Hammerstein_B), 0,
                sizeof(BlockIO_Hammerstein));

  /* states (dwork) */
  (void) memset((void *)&Hammerstein_DWork, 0,
                sizeof(D_Work_Hammerstein));

  /* external inputs */
  Hammerstein_U.In1 = 0.0;

  /* external outputs */
  Hammerstein_Y.Out1 = 0.0;

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

  Hammerstein_M->Sizes.numSFcns = (2);

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

    /* Level2 S-Function Block: Hammerstein/<S1>/Pwlinear1 (sfunpwlinear) */
    {
      SimStruct *rts = Hammerstein_M->childSfunctions[0];

      /* timing info */
      time_T *sfcnPeriod = Hammerstein_M->NonInlinedSFcns.Sfcn0.sfcnPeriod;
      time_T *sfcnOffset = Hammerstein_M->NonInlinedSFcns.Sfcn0.sfcnOffset;
      int_T *sfcnTsMap = Hammerstein_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, &Hammerstein_M->NonInlinedSFcns.blkInfo2[0]);
      }

      ssSetRTWSfcnInfo(rts, Hammerstein_M->sfcnInfo);

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

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

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

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

        /* port 0 */
        {
          ssSetInputPortRequiredContiguous(rts, 0, 1);
          ssSetInputPortSignal(rts, 0, &Hammerstein_B.LinearModel);
          _ssSetInputPortNumDimensions(rts, 0, 1);
          ssSetInputPortWidth(rts, 0, 1);
        }
      }

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

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

      /* path info */
      ssSetModelName(rts, "Pwlinear1");
      ssSetPath(rts, "Hammerstein/Hammerstein-Wiener Model1/Pwlinear1");
      ssSetRTModel(rts,Hammerstein_M);
      ssSetParentSS(rts, (NULL));
      ssSetRootSS(rts, rts);
      ssSetVersion(rts, SIMSTRUCT_VERSION_LEVEL2);

      /* parameters */
      {
        mxArray **sfcnParams = (mxArray **)
          &Hammerstein_M->NonInlinedSFcns.Sfcn0.params;
        ssSetSFcnParamsCount(rts, 7);
        ssSetSFcnParamsPtr(rts, &sfcnParams[0]);
        ssSetSFcnParam(rts, 0, (mxArray*)Hammerstein_P.Pwlinear1_P1_Size);
        ssSetSFcnParam(rts, 1, (mxArray*)Hammerstein_P.Pwlinear1_P2_Size);
        ssSetSFcnParam(rts, 2, (mxArray*)Hammerstein_P.Pwlinear1_P3_Size);
        ssSetSFcnParam(rts, 3, (mxArray*)Hammerstein_P.Pwlinear1_P4_Size);
        ssSetSFcnParam(rts, 4, (mxArray*)Hammerstein_P.Pwlinear1_P5_Size);
        ssSetSFcnParam(rts, 5, (mxArray*)Hammerstein_P.Pwlinear1_P6_Size);
        ssSetSFcnParam(rts, 6, (mxArray*)Hammerstein_P.Pwlinear1_P7_Size);
      }

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

      /* adjust sample time */
      ssSetSampleTime(rts, 0, 0.06);
      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: Hammerstein/<S1>/Pwlinear (sfunpwlinear) */
    {
      SimStruct *rts = Hammerstein_M->childSfunctions[1];

      /* timing info */
      time_T *sfcnPeriod = Hammerstein_M->NonInlinedSFcns.Sfcn1.sfcnPeriod;
      time_T *sfcnOffset = Hammerstein_M->NonInlinedSFcns.Sfcn1.sfcnOffset;
      int_T *sfcnTsMap = Hammerstein_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, &Hammerstein_M->NonInlinedSFcns.blkInfo2[1]);
      }

      ssSetRTWSfcnInfo(rts, Hammerstein_M->sfcnInfo);

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

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

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

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

        /* port 0 */
        {
          ssSetInputPortRequiredContiguous(rts, 0, 1);
          ssSetInputPortSignal(rts, 0, &Hammerstein_U.In1);
          _ssSetInputPortNumDimensions(rts, 0, 1);
          ssSetInputPortWidth(rts, 0, 1);
        }
      }

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

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

      /* path info */
      ssSetModelName(rts, "Pwlinear");
      ssSetPath(rts, "Hammerstein/Hammerstein-Wiener Model1/Pwlinear");
      ssSetRTModel(rts,Hammerstein_M);
      ssSetParentSS(rts, (NULL));
      ssSetRootSS(rts, rts);
      ssSetVersion(rts, SIMSTRUCT_VERSION_LEVEL2);

      /* parameters */
      {
        mxArray **sfcnParams = (mxArray **)
          &Hammerstein_M->NonInlinedSFcns.Sfcn1.params;
        ssSetSFcnParamsCount(rts, 7);
        ssSetSFcnParamsPtr(rts, &sfcnParams[0]);
        ssSetSFcnParam(rts, 0, (mxArray*)Hammerstein_P.Pwlinear_P1_Size);
        ssSetSFcnParam(rts, 1, (mxArray*)Hammerstein_P.Pwlinear_P2_Size);
        ssSetSFcnParam(rts, 2, (mxArray*)Hammerstein_P.Pwlinear_P3_Size);
        ssSetSFcnParam(rts, 3, (mxArray*)Hammerstein_P.Pwlinear_P4_Size);
        ssSetSFcnParam(rts, 4, (mxArray*)Hammerstein_P.Pwlinear_P5_Size);
        ssSetSFcnParam(rts, 5, (mxArray*)Hammerstein_P.Pwlinear_P6_Size);
        ssSetSFcnParam(rts, 6, (mxArray*)Hammerstein_P.Pwlinear_P7_Size);
      }

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

      /* adjust sample time */
      ssSetSampleTime(rts, 0, 0.06);
      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);
    }
  }

  /* Matfile logging */
  rt_StartDataLoggingWithStartTime(Hammerstein_M->rtwLogInfo, 0.0, rtmGetTFinal
    (Hammerstein_M), Hammerstein_M->Timing.stepSize0, (&rtmGetErrorStatus
    (Hammerstein_M)));

  /* Level2 S-Function Block: '<S1>/Pwlinear1' (sfunpwlinear) */
  {
    SimStruct *rts = Hammerstein_M->childSfunctions[0];
    sfcnStart(rts);
    if (ssGetErrorStatus(rts) != (NULL))
      return;
  }

  /* Level2 S-Function Block: '<S1>/Pwlinear' (sfunpwlinear) */
  {
    SimStruct *rts = Hammerstein_M->childSfunctions[1];
    sfcnStart(rts);
    if (ssGetErrorStatus(rts) != (NULL))
      return;
  }

  /* InitializeConditions for DiscreteStateSpace: '<S1>/LinearModel' */
  Hammerstein_DWork.LinearModel_DSTATE = Hammerstein_P.LinearModel_X0;

  /* Level2 S-Function Block: '<S1>/Pwlinear1' (sfunpwlinear) */
  {
    SimStruct *rts = Hammerstein_M->childSfunctions[0];
    sfcnInitializeConditions(rts);
    if (ssGetErrorStatus(rts) != (NULL))
      return;
  }

  /* Level2 S-Function Block: '<S1>/Pwlinear' (sfunpwlinear) */
  {
    SimStruct *rts = Hammerstein_M->childSfunctions[1];
    sfcnInitializeConditions(rts);
    if (ssGetErrorStatus(rts) != (NULL))
      return;
  }
}