⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 weather.c

📁 智能信息处理应用的实例
💻 C
📖 第 1 页 / 共 3 页
字号:
          rtmin = rtb_Weighting_h;
          rtmin = rt_MIN(u1[i1], rtmin);
          y0[i1] = rtmin;
        }
      }
    }

    /* MinMax: '<S14>/impMethod' incorporates:
     *   Constant: '<S19>/rainy'
     *   Constant: '<S18>/low'
     */
    {
      real_T rtmin;

      {
        int_T i1;

        const real_T *u1 = &rtP.rainy_Value[0];
        real_T *y0 = &rtb_impMethod_i[0];

        for (i1=0; i1 < 101; i1++) {
          rtmin = rtb_Weighting_i;
          rtmin = rt_MIN(u1[i1], rtmin);
          y0[i1] = rtmin;
        }

        u1 = &rtP.low_Value[0];
        y0 = &rtb_impMethod_i[101];

        for (i1=0; i1 < 101; i1++) {
          rtmin = rtb_Weighting_i;
          rtmin = rt_MIN(u1[i1], rtmin);
          y0[i1] = rtmin;
        }
      }
    }

    /* MinMax: '<S6>/impMethod' incorporates:
     *   Constant: '<S19>/snowy'
     *   Constant: '<S18>/low'
     */
    {
      real_T rtmin;

      {
        int_T i1;

        const real_T *u1 = &rtP.snowy_Value[0];
        real_T *y0 = &rtb_impMethod_j[0];

        for (i1=0; i1 < 101; i1++) {
          rtmin = rtb_Weighting_j;
          rtmin = rt_MIN(u1[i1], rtmin);
          y0[i1] = rtmin;
        }

        u1 = &rtP.low_Value[0];
        y0 = &rtb_impMethod_j[101];

        for (i1=0; i1 < 101; i1++) {
          rtmin = rtb_Weighting_j;
          rtmin = rt_MIN(u1[i1], rtmin);
          y0[i1] = rtmin;
        }
      }
    }

    /* MinMax: '<S2>/AggMethod1' */
    {
      real_T rtmax;

      {
        int_T i1;

        const real_T *u0 = &rtb_impMethod_a[0];
        const real_T *u1 = &rtb_impMethod_b[0];
        const real_T *u2 = &rtb_impMethod_c[0];
        const real_T *u3 = &rtb_impMethod_d[0];
        const real_T *u4 = &rtb_impMethod_e[0];
        const real_T *u5 = &rtb_impMethod_f[0];
        const real_T *u6 = &rtb_impMethod_g[0];
        const real_T *u7 = &rtb_impMethod_h[0];
        const real_T *u8 = &rtb_impMethod_i[0];
        const real_T *u9 = &rtb_impMethod_j[0];
        real_T *y0 = &rtb_AggMethod1[0];

        for (i1=0; i1 < 101; i1++) {
          rtmax = u0[i1];
          rtmax = rt_MAX(u1[i1], rtmax);
          rtmax = rt_MAX(u2[i1], rtmax);
          rtmax = rt_MAX(u3[i1], rtmax);
          rtmax = rt_MAX(u4[i1], rtmax);
          rtmax = rt_MAX(u5[i1], rtmax);
          rtmax = rt_MAX(u6[i1], rtmax);
          rtmax = rt_MAX(u7[i1], rtmax);
          rtmax = rt_MAX(u8[i1], rtmax);
          rtmax = rt_MAX(u9[i1], rtmax);
          y0[i1] = rtmax;
        }
      }
    }

    /* Sum: '<S3>/Sum' incorporates:
     *   Product: '<S3>/Product (COA)'
     *   Constant: '<S3>/x data'
     */
    rtb_temp51 = (rtP.x_data_a_Value[0] * rtb_AggMethod1[0]);
    {
      int_T i1;

      for (i1=0; i1 < 100; i1++) {
        rtb_temp51 += (rtP.x_data_a_Value[i1+1] * rtb_AggMethod1[i1+1]);
      }
    }

    /* Sum: '<S3>/Sum1' */
    rtb_Sum1_a = rtb_AggMethod1[0];
    {
      int_T i1;

      const real_T *u0 = &rtb_AggMethod1[1];

      for (i1=0; i1 < 100; i1++) {
        rtb_Sum1_a += u0[i1];
      }
    }

    /* RelationalOperator: '<S3>/Zero Strength (COA)' incorporates:
     *   Constant: '<S3>/Prevent Div//1'
     */
    rtb_Zero_Strength_COA_a = (rtb_Sum1_a <= rtP.Prevent_Div_1_a_Value);

    /* Product: '<S3>/Averaging (COA)' incorporates:
     *   MinMax: '<S3>/Max (COA)'
     */
    rtb_Averaging_COA_a = rtb_temp51 / rt_MAX(rtb_Sum1_a,
      rtb_Zero_Strength_COA_a);

    /* MinMax: '<S2>/AggMethod2' */
    {
      real_T rtmax;

      {
        int_T i1;

        const real_T *u0 = &rtb_impMethod_a[101];
        const real_T *u1 = &rtb_impMethod_b[101];
        const real_T *u2 = &rtb_impMethod_c[101];
        const real_T *u3 = &rtb_impMethod_d[101];
        const real_T *u4 = &rtb_impMethod_e[101];
        const real_T *u5 = &rtb_impMethod_f[101];
        const real_T *u6 = &rtb_impMethod_g[101];
        const real_T *u7 = &rtb_impMethod_h[101];
        const real_T *u8 = &rtb_impMethod_i[101];
        const real_T *u9 = &rtb_impMethod_j[101];
        real_T *y0 = &rtb_AggMethod2[0];

        for (i1=0; i1 < 101; i1++) {
          rtmax = u0[i1];
          rtmax = rt_MAX(u1[i1], rtmax);
          rtmax = rt_MAX(u2[i1], rtmax);
          rtmax = rt_MAX(u3[i1], rtmax);
          rtmax = rt_MAX(u4[i1], rtmax);
          rtmax = rt_MAX(u5[i1], rtmax);
          rtmax = rt_MAX(u6[i1], rtmax);
          rtmax = rt_MAX(u7[i1], rtmax);
          rtmax = rt_MAX(u8[i1], rtmax);
          rtmax = rt_MAX(u9[i1], rtmax);
          y0[i1] = rtmax;
        }
      }
    }

    /* Sum: '<S4>/Sum' incorporates:
     *   Product: '<S4>/Product (COA)'
     *   Constant: '<S4>/x data'
     */
    rtb_temp51 = (rtP.x_data_b_Value[0] * rtb_AggMethod2[0]);
    {
      int_T i1;

      for (i1=0; i1 < 100; i1++) {
        rtb_temp51 += (rtP.x_data_b_Value[i1+1] * rtb_AggMethod2[i1+1]);
      }
    }

    /* Sum: '<S4>/Sum1' */
    rtb_Sum1_b = rtb_AggMethod2[0];
    {
      int_T i1;

      const real_T *u0 = &rtb_AggMethod2[1];

      for (i1=0; i1 < 100; i1++) {
        rtb_Sum1_b += u0[i1];
      }
    }

    /* RelationalOperator: '<S4>/Zero Strength (COA)' incorporates:
     *   Constant: '<S4>/Prevent Div//1'
     */
    rtb_Zero_Strength_COA_b = (rtb_Sum1_b <= rtP.Prevent_Div_1_b_Value);

    /* Product: '<S4>/Averaging (COA)' incorporates:
     *   MinMax: '<S4>/Max (COA)'
     */
    rtb_Averaging_COA_b = rtb_temp51 / rt_MAX(rtb_Sum1_b,
      rtb_Zero_Strength_COA_b);

    rtB.Switch[0] = rtb_Averaging_COA_a;
    rtB.Switch[1] = rtb_Averaging_COA_b;
  } else {
    rtB.Switch[0] = rtP.MidRange_Value[0];
    rtB.Switch[1] = rtP.MidRange_Value[1];
  }
}

/* Update for root system: '<Root>' */
void MdlUpdate(int_T tid)
{

  /* tid is required for a uniform function interface. This system
   * is single rate, and in this case, tid is not accessed. */
  UNUSED_PARAMETER(tid);
}

/* Terminate for root system: '<Root>' */
void MdlTerminate(void)
{
  if(rtM_weather != NULL) {
  }
}

/* Function to initialize sizes */
void MdlInitializeSizes(void)
{
  rtM_weather->Sizes.numContStates = (0); /* Number of continuous states */
  rtM_weather->Sizes.numY = (0);        /* Number of model outputs */
  rtM_weather->Sizes.numU = (0);        /* Number of model inputs */
  rtM_weather->Sizes.sysDirFeedThru = (0); /* The model is not direct feedthrough */
  rtM_weather->Sizes.numSampTimes = (2); /* Number of sample times */
  rtM_weather->Sizes.numBlocks = (140); /* Number of blocks */
  rtM_weather->Sizes.numBlockIO = (28); /* Number of block outputs */
  rtM_weather->Sizes.numBlockPrms = (979); /* Sum of parameter "widths" */
}

/* Function to initialize sample times */
void MdlInitializeSampleTimes(void)
{
  /* task periods */
  rtM_weather->Timing.sampleTimes[0] = (0.0);
  rtM_weather->Timing.sampleTimes[1] = (0.2);

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

/* Function to register the model */
rtModel_weather *weather(void)
{
  (void)memset((char *)rtM_weather, 0, sizeof(rtModel_weather));

  {
    /* Setup solver object */
    static RTWSolverInfo rt_SolverInfo;
    rtM_weather->solverInfo = (&rt_SolverInfo);

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

    rtsiSetRTModelPtr(rtM_weather->solverInfo, rtM_weather);
  }

  /* timing info */
  {
    static time_T mdlPeriod[NSAMPLE_TIMES];
    static time_T mdlOffset[NSAMPLE_TIMES];
    static time_T mdlTaskTimes[NSAMPLE_TIMES];
    static int_T mdlTsMap[NSAMPLE_TIMES];
    static int_T mdlSampleHits[NSAMPLE_TIMES];

    {
      int_T i;

      for(i = 0; i < NSAMPLE_TIMES; i++) {
        mdlPeriod[i] = 0.0;
        mdlOffset[i] = 0.0;
        mdlTaskTimes[i] = 0.0;
      }
    }
    (void)memset((char_T *)&mdlTsMap[0], 0, 2 * sizeof(int_T));
    (void)memset((char_T *)&mdlSampleHits[0], 0, 2 * sizeof(int_T));

    rtM_weather->Timing.sampleTimes = (&mdlPeriod[0]);
    rtM_weather->Timing.offsetTimes = (&mdlOffset[0]);
    rtM_weather->Timing.sampleTimeTaskIDPtr = (&mdlTsMap[0]);
    rtmSetTPtr(rtM_weather, &mdlTaskTimes[0]);
    rtM_weather->Timing.sampleHits = (&mdlSampleHits[0]);
  }
  rtsiSetSolverMode(rtM_weather->solverInfo, SOLVER_MODE_SINGLETASKING);

  /*
   * initialize model vectors and cache them in SimStruct
   */

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

    {
      int_T i;

      b = &rtB.Merge_a;
      for (i = 0; i < 11; i++) {
        ((real_T*)b)[i] = 0.0;
      }
      ((real_T*)&rtB.If_Action_p.c_b)[0] = 0.0;
      ((real_T*)&rtB.If_Action_o.b_a)[0] = 0.0;
      ((real_T*)&rtB.If_Action_t.c_b)[0] = 0.0;
      ((real_T*)&rtB.If_Action_s.b_a)[0] = 0.0;
      ((real_T*)&rtB.If_Action_h.c_b)[0] = 0.0;
      ((real_T*)&rtB.If_Action_g.b_a)[0] = 0.0;
      ((real_T*)&rtB.If_Action_ab.c_b)[0] = 0.0;
      ((real_T*)&rtB.If_Action_aa.b_a)[0] = 0.0;
      ((real_T*)&rtB.If_Action_l.c_b)[0] = 0.0;
      ((real_T*)&rtB.If_Action_k.b_a)[0] = 0.0;
      ((real_T*)&rtB.If_Action_aj.c_b)[0] = 0.0;
      ((real_T*)&rtB.If_Action_ai.b_a)[0] = 0.0;
      ((real_T*)&rtB.If_Action_d.c_b)[0] = 0.0;
      ((real_T*)&rtB.If_Action_c.b_a)[0] = 0.0;
      ((real_T*)&rtB.If_Action_af.c_b)[0] = 0.0;
      ((real_T*)&rtB.If_Action_ae.b_a)[0] = 0.0;
      ((real_T*)&rtB.If_Action_x.c_b)[0] = 0.0;
      b =&rtB.If_Action_w.b_a;
      for (i = 0; i < 1; i++) {
        ((real_T*)b)[i] = 0.0;
      }
    }
  }

  /* parameters */
  rtM_weather->ModelData.defaultParam = ((real_T *) &rtP);

  /* data type work */
  {
    void *dwork = (void *) &rtDWork;
    rtM_weather->Work.dwork = (dwork);
    (void)memset((char_T *) dwork, 0, sizeof(D_Work));
  }

  /* Model specific registration */

  rtM_weather->modelName = ("weather");
  rtM_weather->path = ("weather");

  rtmSetTStart(rtM_weather, 0.0);
  rtM_weather->Timing.tFinal = (10.0);
  rtM_weather->Timing.stepSize = (0.2);
  rtsiSetFixedStepSize(rtM_weather->solverInfo, 0.2);
  /* Setup for data logging */
  {
    static RTWLogInfo rt_DataLoggingInfo;

    rtM_weather->rtwLogInfo = (&rt_DataLoggingInfo);

    rtliSetLogFormat(rtM_weather->rtwLogInfo, 0);

    rtliSetLogMaxRows(rtM_weather->rtwLogInfo, 1000);

    rtliSetLogDecimation(rtM_weather->rtwLogInfo, 1);

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

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

    rtliSetLogX(rtM_weather->rtwLogInfo, "");

    rtliSetLogXFinal(rtM_weather->rtwLogInfo, "");

    rtliSetLogXSignalInfo(rtM_weather->rtwLogInfo, NULL);

    rtliSetLogXSignalPtrs(rtM_weather->rtwLogInfo, NULL);

    rtliSetLogY(rtM_weather->rtwLogInfo, "");

    rtliSetLogYSignalInfo(rtM_weather->rtwLogInfo, NULL);

    rtliSetLogYSignalPtrs(rtM_weather->rtwLogInfo, NULL);
  }

  rtM_weather->Sizes.checksums[0] = (3245761298U);
  rtM_weather->Sizes.checksums[1] = (422176952U);
  rtM_weather->Sizes.checksums[2] = (276252803U);
  rtM_weather->Sizes.checksums[3] = (1553048759U);

  return rtM_weather;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -