Пример #1
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);
    }
  }
}
Пример #2
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;
}
Пример #3
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;
  }
}
/* 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];
}
Пример #5
0
/* Model initialize function */
void Position_TiltModelClass::initialize()
{
  /* Registration code */

  /* initialize real-time model */
  (void) memset((void *)(&Position_Tilt_M), 0,
                sizeof(RT_MODEL_Position_Tilt_T));

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

  rtsiSetSimTimeStep(&(&Position_Tilt_M)->solverInfo, MAJOR_TIME_STEP);
  (&Position_Tilt_M)->ModelData.intgData.y = (&Position_Tilt_M)->ModelData.odeY;
  (&Position_Tilt_M)->ModelData.intgData.f[0] = (&Position_Tilt_M)
    ->ModelData.odeF[0];
  (&Position_Tilt_M)->ModelData.intgData.f[1] = (&Position_Tilt_M)
    ->ModelData.odeF[1];
  (&Position_Tilt_M)->ModelData.contStates = ((X_Position_Tilt_T *)
    &Position_Tilt_X);
  rtsiSetSolverData(&(&Position_Tilt_M)->solverInfo, (void *)&(&Position_Tilt_M
                    )->ModelData.intgData);
  rtsiSetSolverName(&(&Position_Tilt_M)->solverInfo,"ode2");
  rtmSetTPtr((&Position_Tilt_M), &(&Position_Tilt_M)->Timing.tArray[0]);
  (&Position_Tilt_M)->Timing.stepSize0 = 0.01;

  /* block I/O */
  (void) memset(((void *) &Position_Tilt_B), 0,
                sizeof(B_Position_Tilt_T));

  /* states (continuous) */
  {
    (void) memset((void *)&Position_Tilt_X, 0,
                  sizeof(X_Position_Tilt_T));
  }

  /* external inputs */
  (void) memset((void *)&Position_Tilt_U, 0,
                sizeof(ExtU_Position_Tilt_T));

  /* external outputs */
  (void) memset((void *)&Position_Tilt_Y, 0,
                sizeof(ExtY_Position_Tilt_T));

  /* InitializeConditions for Integrator: '<S2>/Filter' */
  Position_Tilt_X.Filter_CSTATE = Position_Tilt_P.Filter_IC;

  /* InitializeConditions for Integrator: '<S3>/Filter' */
  Position_Tilt_X.Filter_CSTATE_b = Position_Tilt_P.Filter_IC_d;
}
Пример #6
0
/* Model initialize function */
void Mechanics_initialize(boolean_T firstTime)
{
  (void)firstTime;

  /* Registration code */

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  Mechanics_M->Sizes.numSFcns = (1);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      /* Update the BufferDstPort flags for each input port */
    }
  }
}
Пример #7
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));
  }
}
Пример #8
0
/* Model initialize function */
void AttitudeModelClass::initialize()
{
  /* Registration code */

  /* initialize real-time model */
  (void) memset((void *)(&Attitude_M), 0,
                sizeof(RT_MODEL_Attitude_T));

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

  rtsiSetSimTimeStep(&(&Attitude_M)->solverInfo, MAJOR_TIME_STEP);
  (&Attitude_M)->ModelData.intgData.y = (&Attitude_M)->ModelData.odeY;
  (&Attitude_M)->ModelData.intgData.f[0] = (&Attitude_M)->ModelData.odeF[0];
  (&Attitude_M)->ModelData.intgData.f[1] = (&Attitude_M)->ModelData.odeF[1];
  (&Attitude_M)->ModelData.contStates = ((X_Attitude_T *) &Attitude_X);
  rtsiSetSolverData(&(&Attitude_M)->solverInfo, (void *)&(&Attitude_M)
                    ->ModelData.intgData);
  rtsiSetSolverName(&(&Attitude_M)->solverInfo,"ode2");
  rtmSetTPtr((&Attitude_M), &(&Attitude_M)->Timing.tArray[0]);
  (&Attitude_M)->Timing.stepSize0 = 0.01;

  /* block I/O */
  (void) memset(((void *) &Attitude_B), 0,
                sizeof(B_Attitude_T));

  /* states (continuous) */
  {
    (void) memset((void *)&Attitude_X, 0,
                  sizeof(X_Attitude_T));
  }

  /* external inputs */
  (void) memset((void *)&Attitude_U, 0,
                sizeof(ExtU_Attitude_T));

  /* external outputs */
  (void) memset(&Attitude_Y.Moments[0], 0,
                3U*sizeof(real_T));

  /* InitializeConditions for Integrator: '<S3>/Filter' */
  Attitude_X.Filter_CSTATE = Attitude_P.Filter_IC;

  /* InitializeConditions for Integrator: '<S2>/Filter' */
  Attitude_X.Filter_CSTATE_m = Attitude_P.Filter_IC_f;

  /* InitializeConditions for Integrator: '<S4>/Filter' */
  Attitude_X.Filter_CSTATE_mi = Attitude_P.Filter_IC_e;

  /* InitializeConditions for Integrator: '<S5>/Integrator' */
  Attitude_X.Integrator_CSTATE = Attitude_P.Integrator_IC;

  /* InitializeConditions for Integrator: '<S5>/Filter' */
  Attitude_X.Filter_CSTATE_k = Attitude_P.Filter_IC_c;

  /* InitializeConditions for Integrator: '<S6>/Integrator' */
  Attitude_X.Integrator_CSTATE_f = Attitude_P.Integrator_IC_l;

  /* InitializeConditions for Integrator: '<S6>/Filter' */
  Attitude_X.Filter_CSTATE_e = Attitude_P.Filter_IC_fv;

  /* InitializeConditions for Integrator: '<S7>/Integrator' */
  Attitude_X.Integrator_CSTATE_h = Attitude_P.Integrator_IC_k;

  /* InitializeConditions for Integrator: '<S7>/Filter' */
  Attitude_X.Filter_CSTATE_g = Attitude_P.Filter_IC_a;
}