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

📄 ipa_control_acc.c

📁 其中提到遺傳學的程式碼與應用提供給次淚相向的研究者參考下載
💻 C
📖 第 1 页 / 共 5 页
字号:
#if 0

This file is not available for use in any application other than as a
Matlab(R) MEX file for use with the Simulink(R) Accelerator product.

If you do not have the Real-Time Workshop licensed, this file contains
encrypted block names, etc. If you purchase the Real-Time Workshop,
this file will contain full block descriptions and improved variable
names.

#endif

/*
 * IPa_control_acc.c
 *
 * Real-Time Workshop code generation for Simulink model "IPa_control_acc.mdl".
 *
 * Model Version                        : 1.38
 * Real-Time Workshop file version      : 4.0 $Date: 2000/09/19 19:45:27 $
 * Real-Time Workshop file generated on : Fri Aug 03 15:51:13 2001
 * TLC version                          : 4.0 (Aug 21 2000)
 * C source code generated on           : Fri Aug 03 15:51:13 2001
 *
 * Relevant TLC Options:
 *   InlineParameters      = 0
 *   RollThreshold         = 5
 *   CodeFormat            = S-Function
 *
 * Simulink model settings:
 *   Solver     : FixedStep
 *   StartTime  : 0.0 s
 *   StopTime   : 6.0 s
 *   FixedStep  : 0.01 s
 */

#include <math.h>
#include <string.h>
#include "IPa_control_acc.h"
#include "IPa_control_acc_prm.h"

real_T rtInf;

/* Start of Functions in model "IPa_control_acc" */

/* Compute block outputs */
static void mdlOutputs(SimStruct *S, int_T tid)
{
  /* simstruct variables */
  IPa_control_BlockIO *IPa_control_B = (IPa_control_BlockIO *) _ssGetBlockIO(S);
  IPa_control_ContinuousStates *IPa_control_X = (IPa_control_ContinuousStates*) ssGetContStates(S);
  IPa_control_D_Work *IPa_control_DWork = (IPa_control_D_Work *) ssGetRootDWork(S);
  IPa_control_Parameters *IPa_control_P = (IPa_control_Parameters *) ssGetDefaultParam(S);

  /* local block i/o variables */
  real_T rtb_s17_impMethod[101];
  real_T rtb_s24_impMethod[101];
  real_T rtb_s25_impMethod[101];
  real_T rtb_s26_impMethod[101];
  real_T rtb_s27_impMethod[101];
  real_T rtb_s28_impMethod[101];
  real_T rtb_s29_impMethod[101];
  real_T rtb_s30_impMethod[101];
  real_T rtb_s7_impMethod[101];
  real_T rtb_s8_impMethod[101];
  real_T rtb_s9_impMethod[101];
  real_T rtb_s10_impMethod[101];
  real_T rtb_s11_impMethod[101];
  real_T rtb_s12_impMethod[101];
  real_T rtb_s13_impMethod[101];
  real_T rtb_s14_impMethod[101];
  real_T rtb_s15_impMethod[101];
  real_T rtb_s16_impMethod[101];
  real_T rtb_s18_impMethod[101];
  real_T rtb_s19_impMethod[101];
  real_T rtb_s20_impMethod[101];
  real_T rtb_s21_impMethod[101];
  real_T rtb_s22_impMethod[101];
  real_T rtb_temp118;
  real_T rtb_temp119[101];
  real_T rtb_temp120;
  real_T rtb_temp121;
  real_T rtb_temp122;
  real_T rtb_temp123;
  real_T rtb_temp124;
  real_T rtb_temp125;
  real_T rtb_temp126;
  real_T rtb_temp127;
  real_T rtb_temp128;
  real_T rtb_temp129[101];
  real_T rtb_temp130;
  real_T rtb_temp131;
  real_T rtb_temp132;
  real_T rtb_temp133;
  real_T rtb_temp134;
  real_T rtb_temp135;
  real_T rtb_temp136;
  real_T rtb_temp137;
  real_T rtb_temp138;
  real_T rtb_temp139;
  real_T rtb_temp140;
  real_T rtb_temp141;
  real_T rtb_temp142;
  real_T rtb_temp143;
  real_T rtb_temp144;
  real_T rtb_temp145;
  real_T rtb_temp146;
  real_T rtb_temp147;
  real_T rtb_temp148;
  real_T rtb_temp149;

  if (ssIsContinuousTask(S, tid)) {     /* Sample time: [0.0, 0.0] */
    /* Step Block: <Root>/Step */
    if (ssGetTaskTime(S,tid) < (IPa_control_P->root_Step_Time)) {
      IPa_control_B->root_Step = (IPa_control_P->root_Step_Y0);
    } else {
      IPa_control_B->root_Step = (IPa_control_P->root_Step_YFinal);
    }
  }

  if (ssIsSampleHit(S, 1, tid)) {       /* Sample time: [0.01, 0.0] */
    /* Constant Block: <Root>/Constant */
    rtb_temp149 = (IPa_control_P->root_Constant_Value);

    /* Gain Block: <Root>/Gain2 */
    IPa_control_B->root_Gain2 = rtb_temp149 * (IPa_control_P->root_Gain2_Gain);
  }

  if (ssIsContinuousTask(S, tid)) {     /* Sample time: [0.0, 0.0] */
    /* Integrator Block: <S2>/Integrator1 */
    if (IPa_control_DWork->s2_Integrator1_IWORK.IcNeedsLoading) {
      IPa_control_X->s2_Integrator1 = IPa_control_B->root_Gain2;
      IPa_control_DWork->s2_Integrator1_IWORK.IcNeedsLoading = 0;
    }
    rtb_temp118 = IPa_control_X->s2_Integrator1;

    /* Saturate Block: <S2>/Saturation */
    if (rtb_temp118 >= (IPa_control_P->s2_Saturation_UpperSat)) {
      rtb_temp118 = (IPa_control_P->s2_Saturation_UpperSat);
    } else if (rtb_temp118 <= (IPa_control_P->s2_Saturation_LowerSat)) {
      rtb_temp118 = (IPa_control_P->s2_Saturation_LowerSat);
      /* Buffer Reuse Active; Following statement(s) unnecessary */
      /* } else { */
      /*   rtb_temp118 = rtb_temp118; */
    }
  }

  if (ssIsSampleHit(S, 1, tid)) {       /* Sample time: [0.01, 0.0] */
    /* RandomNumber Block: <Root>/Random Number */
    rtb_temp149 = IPa_control_DWork->root_Random_Number_RWORK.NextOutput;

    /* Gain Block: <Root>/Gain4 */
    IPa_control_B->root_Gain4 = rtb_temp149 * (IPa_control_P->root_Gain4_Gain);
  }

  if (ssIsContinuousTask(S, tid)) {     /* Sample time: [0.0, 0.0] */
    /* Sum Block: <Root>/Sum1 */
    rtb_temp148 = rtb_temp118 - IPa_control_B->root_Gain4;

    /* Sum Block: <Root>/Sum */
    IPa_control_B->root_Sum = IPa_control_B->root_Step - rtb_temp148;

    /* Outport Block: <Root>/Out1 */
    /* Call into Simulink for root Outports */
    ssCallAccelRunBlock(S, 0, 9, SS_CALL_MDL_OUTPUTS);

    /* Outport Block: <Root>/Out2 */
    /* Call into Simulink for root Outports */
    ssCallAccelRunBlock(S, 0, 10, SS_CALL_MDL_OUTPUTS);

    /* Gain Block: <Root>/Gain */
    IPa_control_B->root_Gain = rtb_temp148 * (IPa_control_P->root_Gain_Gain);

    /* Outport Block: <Root>/Out3 */
    /* Call into Simulink for root Outports */
    ssCallAccelRunBlock(S, 0, 12, SS_CALL_MDL_OUTPUTS);
  }

  if (ssIsSampleHit(S, 1, tid)) {       /* Sample time: [0.01, 0.0] */
    /* Constant Block: <Root>/Constant1 */
    rtb_temp149 = (IPa_control_P->root_Constant1_Value);

    /* Gain Block: <Root>/Gain3 */
    IPa_control_B->root_Gain3 = rtb_temp149 * (IPa_control_P->root_Gain3_Gain);
  }

  if (ssIsContinuousTask(S, tid)) {     /* Sample time: [0.0, 0.0] */
    /* Integrator Block: <S2>/Integrator */
    if (IPa_control_DWork->s2_Integrator_IWORK.IcNeedsLoading) {
      IPa_control_X->s2_Integrator = IPa_control_B->root_Gain3;
      IPa_control_DWork->s2_Integrator_IWORK.IcNeedsLoading = 0;
    }
    IPa_control_B->s2_Integrator = IPa_control_X->s2_Integrator;

    /* Gain Block: <Root>/Gain1 */
    IPa_control_B->root_Gain1 = IPa_control_B->s2_Integrator * (IPa_control_P->root_Gain1_Gain);

    /* Outport Block: <Root>/Out4 */
    /* Call into Simulink for root Outports */
    ssCallAccelRunBlock(S, 0, 17, SS_CALL_MDL_OUTPUTS);
  }

  if (ssIsSampleHit(S, 1, tid)) {       /* Sample time: [0.01, 0.0] */
    /* Scope Block: <Root>/Scope */
    /* Call into Simulink for Scope */
    ssCallAccelRunBlock(S, 0, 18, SS_CALL_MDL_OUTPUTS);

    /* Scope Block: <Root>/Scope1 */
    /* Call into Simulink for Scope */
    ssCallAccelRunBlock(S, 0, 19, SS_CALL_MDL_OUTPUTS);

    /* ToWorkspace Block: <Root>/To Workspace */
    /* Call into Simulink for To Workspace */
    ssCallAccelRunBlock(S, 0, 20, SS_CALL_MDL_OUTPUTS);

    /* ToWorkspace Block: <Root>/To Workspace1 */
    /* Call into Simulink for To Workspace */
    ssCallAccelRunBlock(S, 0, 21, SS_CALL_MDL_OUTPUTS);
  }

  if (ssIsContinuousTask(S, tid)) {     /* Sample time: [0.0, 0.0] */
    /* Derivative Block: <Root>/Derivative */
    {
      real_T t = ssGetTaskTime(S,tid);
      real_T timeStampA = IPa_control_DWork->root_Derivative_RWORK.TimeStampA;
      real_T timeStampB = IPa_control_DWork->root_Derivative_RWORK.TimeStampB;

      if (timeStampA >= t && timeStampB >= t) {
        rtb_temp148 = 0.0;
      } else {
        real_T deltaT;
        real_T *lastBank = &IPa_control_DWork->root_Derivative_RWORK.TimeStampA;
        if (timeStampA < timeStampB) {
          if (timeStampB < t) {
            lastBank += 2;
          }
        } else if (timeStampA >= t) {
          lastBank += 2;
        }
        deltaT = t - *lastBank++;
        rtb_temp148 = (IPa_control_B->root_Sum - *lastBank++) / deltaT;
      }
    }
  }

  if (ssIsSampleHit(S, 1, tid)) {       /* Sample time: [0.01, 0.0] */
    /* Constant Block: <S5>/x data */
    {
      int_T i1;
      real_T *y0 = &IPa_control_B->s5_x_data[0];
      const real_T *p_s5_x_data_Value = &IPa_control_P->s5_x_data_Value[0];

      for (i1=0; i1 < 101; i1++) {
        y0[i1] = (p_s5_x_data_Value[i1]);
      }
    }

    /* Constant Block: <S6>/Weight */
    IPa_control_B->s6_Weight = (IPa_control_P->s6_Weight_Value);
  }

  if (ssIsContinuousTask(S, tid)) {     /* Sample time: [0.0, 0.0] */
    /* Gain Block: <S1>/Gain2 */
    rtb_temp137 = IPa_control_B->root_Sum * (IPa_control_P->s1_Gain2_Gain);

    /* Saturate Block: <S1>/Saturation */
    if (rtb_temp137 >= (IPa_control_P->s1_Saturation_UpperSat)) {
      rtb_temp137 = (IPa_control_P->s1_Saturation_UpperSat);
    } else if (rtb_temp137 <= (IPa_control_P->s1_Saturation_LowerSat)) {
      rtb_temp137 = (IPa_control_P->s1_Saturation_LowerSat);
      /* Buffer Reuse Active; Following statement(s) unnecessary */
      /* } else { */
      /*   rtb_temp137 = rtb_temp137; */
    }
  }

  if (ssIsSampleHit(S, 1, tid)) {       /* Sample time: [0.01, 0.0] */
    /* Constant Block: <S39>/a */
    IPa_control_B->s39_a = (IPa_control_P->s39_a_Value);
  }

  if (ssIsContinuousTask(S, tid)) {     /* Sample time: [0.0, 0.0] */
    /* Sum Block: <S39>/Sum */
    rtb_temp138 = rtb_temp137 - IPa_control_B->s39_a;
  }

  if (ssIsSampleHit(S, 1, tid)) {       /* Sample time: [0.01, 0.0] */
    /* Constant Block: <S39>/b */
    rtb_temp149 = (IPa_control_P->s39_b_Value);

    /* Sum Block: <S39>/Sum1 */
    IPa_control_B->s39_b_a = - IPa_control_B->s39_a + rtb_temp149;
  }

  if (ssIsContinuousTask(S, tid)) {     /* Sample time: [0.0, 0.0] */
    /* Product Block: <S39>/Product ab (trimf) */
    rtb_temp138 = rtb_temp138 /
      IPa_control_B->s39_b_a;
  }

  if (ssIsSampleHit(S, 1, tid)) {       /* Sample time: [0.01, 0.0] */
    /* Constant Block: <S39>/c */
    IPa_control_B->s39_c = (IPa_control_P->s39_c_Value);

    /* Sum Block: <S39>/Sum2 */
    IPa_control_B->s39_c_b = - rtb_temp149 + IPa_control_B->s39_c;
  }

  if (ssIsContinuousTask(S, tid)) {     /* Sample time: [0.0, 0.0] */
    /* Sum Block: <S39>/Sum3 */
    rtb_temp147 = IPa_control_B->s39_c - rtb_temp137;

    /* Product Block: <S39>/Product cd (trimf) */
    rtb_temp147 = 1.0 / IPa_control_B->s39_c_b *
      rtb_temp147;

    /* MinMax Block: <S39>/Min (trimf) */
    rtb_temp138 = (rtb_temp138 < rtb_temp147) ? rtb_temp138 : rtb_temp147;
  }

  if (ssIsSampleHit(S, 1, tid)) {       /* Sample time: [0.01, 0.0] */
    /* Constant Block: <S39>/0 */
    IPa_control_B->s39_0 = (IPa_control_P->s39_0_Value);
  }

  if (ssIsContinuousTask(S, tid)) {     /* Sample time: [0.0, 0.0] */
    /* MinMax Block: <S39>/Max (trimf) */
    rtb_temp138 = (rtb_temp138 > IPa_control_B->s39_0) ? rtb_temp138 : IPa_control_B->s39_0;

    /* Gain Block: <S1>/Gain1 */
    rtb_temp148 *= (IPa_control_P->s1_Gain1_Gain);

    /* Saturate Block: <S1>/Saturation1 */
    if (rtb_temp148 >= (IPa_control_P->s1_Saturation1_UpperSat)) {
      rtb_temp148 = (IPa_control_P->s1_Saturation1_UpperSat);
    } else if (rtb_temp148 <= (IPa_control_P->s1_Saturation1_LowerSat)) {
      rtb_temp148 = (IPa_control_P->s1_Saturation1_LowerSat);
      /* Buffer Reuse Active; Following statement(s) unnecessary */
      /* } else { */
      /*   rtb_temp148 = rtb_temp148; */
    }
  }

  if (ssIsSampleHit(S, 1, tid)) {       /* Sample time: [0.01, 0.0] */
    /* Constant Block: <S34>/a */
    IPa_control_B->s34_a = (IPa_control_P->s34_a_Value);
  }

  if (ssIsContinuousTask(S, tid)) {     /* Sample time: [0.0, 0.0] */
    /* Sum Block: <S34>/Sum */
    rtb_temp147 = rtb_temp148 - IPa_control_B->s34_a;
  }

  if (ssIsSampleHit(S, 1, tid)) {       /* Sample time: [0.01, 0.0] */
    /* Constant Block: <S34>/b */
    rtb_temp149 = (IPa_control_P->s34_b_Value);

    /* Sum Block: <S34>/Sum1 */
    IPa_control_B->s34_b_a = - IPa_control_B->s34_a + rtb_temp149;
  }

  if (ssIsContinuousTask(S, tid)) {     /* Sample time: [0.0, 0.0] */
    /* Product Block: <S34>/Product ab (trimf) */
    rtb_temp147 = rtb_temp147 /
      IPa_control_B->s34_b_a;
  }

  if (ssIsSampleHit(S, 1, tid)) {       /* Sample time: [0.01, 0.0] */
    /* Constant Block: <S34>/c */
    IPa_control_B->s34_c = (IPa_control_P->s34_c_Value);

    /* Sum Block: <S34>/Sum2 */
    IPa_control_B->s34_c_b = - rtb_temp149 + IPa_control_B->s34_c;
  }

  if (ssIsContinuousTask(S, tid)) {     /* Sample time: [0.0, 0.0] */
    /* Sum Block: <S34>/Sum3 */
    rtb_temp139 = IPa_control_B->s34_c - rtb_temp148;

    /* Product Block: <S34>/Product cd (trimf) */
    rtb_temp139 = 1.0 / IPa_control_B->s34_c_b *
      rtb_temp139;

    /* MinMax Block: <S34>/Min (trimf) */
    rtb_temp147 = (rtb_temp147 < rtb_temp139) ? rtb_temp147 : rtb_temp139;
  }

  if (ssIsSampleHit(S, 1, tid)) {       /* Sample time: [0.01, 0.0] */
    /* Constant Block: <S34>/0 */
    IPa_control_B->s34_0 = (IPa_control_P->s34_0_Value);
  }

  if (ssIsContinuousTask(S, tid)) {     /* Sample time: [0.0, 0.0] */
    /* MinMax Block: <S34>/Max (trimf) */
    rtb_temp147 = (rtb_temp147 > IPa_control_B->s34_0) ? rtb_temp147 : IPa_control_B->s34_0;

    /* MinMax Block: <S6>/andorMethod */
    {
      real_T min = rtb_temp138;

      if (rtb_temp147 < min) {
        min = rtb_temp147;
      }
      rtb_temp139 = min;
    }

    /* Product Block: <S6>/Weighting */
    rtb_temp139 = IPa_control_B->s6_Weight *
      rtb_temp139;
  }

  if (ssIsSampleHit(S, 1, tid)) {       /* Sample time: [0.01, 0.0] */
    /* Constant Block: <S33>/PL */
    {
      int_T i1;
      real_T *y0 = &IPa_control_B->s33_PL[0];
      const real_T *p_s33_PL_Value = &IPa_control_P->s33_PL_Value[0];

      for (i1=0; i1 < 101; i1++) {
        y0[i1] = (p_s33_PL_Value[i1]);
      }
    }
  }

  if (ssIsContinuousTask(S, tid)) {     /* Sample time: [0.0, 0.0] */
    /* MinMax Block: <S6>/impMethod */
    {
      real_T min;

      {
        int_T i1;
        const real_T *u1 = &IPa_control_B->s33_PL[0];

⌨️ 快捷键说明

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