/*
 * WheelSpd1.c
 *
 * Academic License - for use in teaching, academic research, and meeting
 * course requirements at degree granting institutions only.  Not for
 * government, commercial, or other organizational use.
 *
 * Code generation for model "WheelSpd1".
 *
 * Model version              : 1.397
 * Simulink Coder version : 8.14 (R2018a) 06-Feb-2018
 * C source code generated on : Tue Jul 11 16:56:29 2023
 *
 * Target selection: slrt.tlc
 * Note: GRT includes extra infrastructure and instrumentation for prototyping
 * Embedded hardware selection: Generic->32-bit x86 compatible
 * Code generation objectives: Unspecified
 * Validation result: Not run
 */

#include "rt_logging_mmi.h"
#include "WheelSpd1_capi.h"
#include "WheelSpd1.h"
#include "WheelSpd1_private.h"

/* Block signals (default storage) */
B_WheelSpd1_T WheelSpd1_B;

/* Block states (default storage) */
DW_WheelSpd1_T WheelSpd1_DW;

/* Real-time model */
RT_MODEL_WheelSpd1_T WheelSpd1_M_;
RT_MODEL_WheelSpd1_T *const WheelSpd1_M = &WheelSpd1_M_;
real_T rt_powd_snf(real_T u0, real_T u1)
{
  real_T y;
  real_T tmp;
  real_T tmp_0;
  if (rtIsNaN(u0) || rtIsNaN(u1)) {
    y = (rtNaN);
  } else {
    tmp = fabs(u0);
    tmp_0 = fabs(u1);
    if (rtIsInf(u1)) {
      if (tmp == 1.0) {
        y = 1.0;
      } else if (tmp > 1.0) {
        if (u1 > 0.0) {
          y = (rtInf);
        } else {
          y = 0.0;
        }
      } else if (u1 > 0.0) {
        y = 0.0;
      } else {
        y = (rtInf);
      }
    } else if (tmp_0 == 0.0) {
      y = 1.0;
    } else if (tmp_0 == 1.0) {
      if (u1 > 0.0) {
        y = u0;
      } else {
        y = 1.0 / u0;
      }
    } else if (u1 == 2.0) {
      y = u0 * u0;
    } else if ((u1 == 0.5) && (u0 >= 0.0)) {
      y = sqrt(u0);
    } else if ((u0 < 0.0) && (u1 > floor(u1))) {
      y = (rtNaN);
    } else {
      y = pow(u0, u1);
    }
  }

  return y;
}

/* Model output function */
static void WheelSpd1_output(void)
{
  int32_T s1_iter;
  real_T u0;
  real_T u1;
  real_T u2;

  /* Gain: '<S4>/ContM' incorporates:
   *  Constant: '<S4>/ContMode'
   */
  WheelSpd1_B.ContMode = WheelSpd1_P.ContM_Gain * WheelSpd1_P.ContMode_Value;

  /* Constant: '<S5>/Constant' */
  WheelSpd1_B.Ready = WheelSpd1_P.Constant_Value;

  /* Constant: '<S5>/Constant1' */
  WheelSpd1_B.Gear = WheelSpd1_P.Constant1_Value;

  /* Constant: '<S5>/Constant2' */
  WheelSpd1_B.BMS = WheelSpd1_P.Constant2_Value;

  /* Constant: '<S5>/Constant3' */
  WheelSpd1_B.PosTQLim = WheelSpd1_P.Constant3_Value;

  /* Constant: '<S5>/Constant4' */
  WheelSpd1_B.NegTQLim = WheelSpd1_P.Constant4_Value;

  /* Clock: '<S6>/Clock1' */
  WheelSpd1_B.Clock1 = WheelSpd1_M->Timing.t[0];

  /* Product: '<S6>/Product' incorporates:
   *  Constant: '<S6>/deltaFreq'
   *  Constant: '<S6>/targetTime'
   */
  u0 = (WheelSpd1_P.ChirpSignal_f2 - WheelSpd1_P.ChirpSignal_f1) *
    6.2831853071795862;
  WheelSpd1_B.Product = u0 / WheelSpd1_P.ChirpSignal_T;

  /* Gain: '<S6>/Gain' */
  WheelSpd1_B.Gain = WheelSpd1_P.Gain_Gain_a * WheelSpd1_B.Product;

  /* FromWorkspace: '<S10>/FromWs' */
  {
    real_T *pDataValues = (real_T *) WheelSpd1_DW.FromWs_PWORK.DataPtr;
    real_T *pTimeValues = (real_T *) WheelSpd1_DW.FromWs_PWORK.TimePtr;
    int_T currTimeIndex = WheelSpd1_DW.FromWs_IWORK.PrevIndex;
    real_T t = WheelSpd1_M->Timing.t[0];

    /* Get index */
    if (t <= pTimeValues[0]) {
      currTimeIndex = 0;
    } else if (t >= pTimeValues[17]) {
      currTimeIndex = 16;
    } else {
      if (t < pTimeValues[currTimeIndex]) {
        while (t < pTimeValues[currTimeIndex]) {
          currTimeIndex--;
        }
      } else {
        while (t >= pTimeValues[currTimeIndex + 1]) {
          currTimeIndex++;
        }
      }
    }

    WheelSpd1_DW.FromWs_IWORK.PrevIndex = currTimeIndex;

    /* Post output */
    {
      real_T t1 = pTimeValues[currTimeIndex];
      real_T t2 = pTimeValues[currTimeIndex + 1];
      if (t1 == t2) {
        if (t < t1) {
          WheelSpd1_B.FromWs = pDataValues[currTimeIndex];
        } else {
          WheelSpd1_B.FromWs = pDataValues[currTimeIndex + 1];
        }
      } else {
        real_T f1 = (t2 - t) / (t2 - t1);
        real_T f2 = 1.0 - f1;
        real_T d1;
        real_T d2;
        int_T TimeIndex= currTimeIndex;
        d1 = pDataValues[TimeIndex];
        d2 = pDataValues[TimeIndex + 1];
        WheelSpd1_B.FromWs = (real_T) rtInterpolate(d1, d2, f1, f2);
        pDataValues += 18;
      }
    }
  }

  /* Sin: '<S4>/InputSine' */
  WheelSpd1_B.InputSine = sin(WheelSpd1_P.InputSine_Freq * WheelSpd1_M->
    Timing.t[0] + WheelSpd1_P.InputSine_Phase) * WheelSpd1_P.InputSine_Amp +
    WheelSpd1_P.InputSine_Bias;

  /* MultiPortSwitch: '<S4>/Multiport Switch' incorporates:
   *  Constant: '<S4>/InputSelector'
   */
  switch ((int32_T)WheelSpd1_P.InputSelector_Value) {
   case 1:
    /* Product: '<S6>/Product1' */
    WheelSpd1_B.Product1_lf = WheelSpd1_B.Clock1 * WheelSpd1_B.Gain;

    /* Sum: '<S6>/Sum' incorporates:
     *  Constant: '<S6>/initialFreq'
     */
    u0 = 6.2831853071795862 * WheelSpd1_P.ChirpSignal_f1;
    WheelSpd1_B.Sum = WheelSpd1_B.Product1_lf + u0;

    /* Product: '<S6>/Product2' */
    WheelSpd1_B.Product2_g = WheelSpd1_B.Clock1 * WheelSpd1_B.Sum;

    /* Trigonometry: '<S6>/Output' */
    WheelSpd1_B.Output = sin(WheelSpd1_B.Product2_g);

    /* Gain: '<S4>/Gain1' */
    WheelSpd1_B.Gain1 = WheelSpd1_P.Gain1_Gain * WheelSpd1_B.Output;
    WheelSpd1_B.TargetSpd = WheelSpd1_B.Gain1;
    break;

   case 2:
    /* Gain: '<S4>/Gain' */
    WheelSpd1_B.Gain_d = WheelSpd1_P.Gain_Gain * WheelSpd1_B.FromWs;
    WheelSpd1_B.TargetSpd = WheelSpd1_B.Gain_d;
    break;

   default:
    WheelSpd1_B.TargetSpd = WheelSpd1_B.InputSine;
    break;
  }

  /* End of MultiPortSwitch: '<S4>/Multiport Switch' */

  /* UnitDelay: '<S9>/d1' */
  WheelSpd1_B.d1 = WheelSpd1_DW.d1_DSTATE;

  /* Sum: '<S9>/Sum3' */
  WheelSpd1_B.Sum3 = WheelSpd1_B.TargetSpd + WheelSpd1_B.d1;

  /* Gain: '<S9>/gain' */
  WheelSpd1_B.gain = WheelSpd1_P.Ts * WheelSpd1_B.Sum3;

  /* Gain: '<S9>/gain2' incorporates:
   *  Constant: '<S4>/Constant1'
   */
  WheelSpd1_B.gain2 = WheelSpd1_P.gain2_Gain * WheelSpd1_P.Constant1_Value_a;

  /* Product: '<S9>/Product2' incorporates:
   *  Constant: '<S9>/Constant1'
   */
  WheelSpd1_B.Product2 = WheelSpd1_P.Constant1_Value_n / WheelSpd1_B.gain2;

  /* Gain: '<S9>/gain1' */
  WheelSpd1_B.gain1 = WheelSpd1_P.gain1_Gain * WheelSpd1_B.Product2;

  /* Sum: '<S9>/Sum1' incorporates:
   *  Constant: '<S9>/Constant'
   */
  WheelSpd1_B.Sum1 = WheelSpd1_B.gain1 - WheelSpd1_P.Ts;

  /* UnitDelay: '<S9>/d' */
  WheelSpd1_B.d = WheelSpd1_DW.d_DSTATE;

  /* Product: '<S9>/Product11' */
  WheelSpd1_B.Product11 = WheelSpd1_B.Sum1 * WheelSpd1_B.d;

  /* Sum: '<S9>/Sum2' */
  WheelSpd1_B.Sum2 = WheelSpd1_B.gain + WheelSpd1_B.Product11;

  /* Sum: '<S9>/Sum4' incorporates:
   *  Constant: '<S9>/Constant'
   */
  WheelSpd1_B.Sum4 = WheelSpd1_B.gain1 + WheelSpd1_P.Ts;

  /* Product: '<S9>/Product1' */
  WheelSpd1_B.Product1 = WheelSpd1_B.Sum2 / WheelSpd1_B.Sum4;

  /* Product: '<S17>/Product2' incorporates:
   *  Constant: '<S17>/Constant5'
   */
  u0 = WheelSpd1_P.P * 196.0;
  WheelSpd1_B.Product2_c = u0 * WheelSpd1_B.Product1;

  /* UnitDelay: '<S22>/d' */
  WheelSpd1_B.d_a = WheelSpd1_DW.d_DSTATE_a;

  /* Sum: '<S22>/Sum2' */
  WheelSpd1_B.Sum2_h = WheelSpd1_B.Product1 - WheelSpd1_B.d_a;

  /* Gain: '<S22>/gain' */
  u0 = WheelSpd1_P.Ts;
  u0 = 2.0 / u0;
  WheelSpd1_B.gain_m = u0 * WheelSpd1_B.Sum2_h;

  /* UnitDelay: '<S22>/d1' */
  WheelSpd1_B.d1_d = WheelSpd1_DW.d1_DSTATE_l;

  /* Sum: '<S22>/Sum1' */
  WheelSpd1_B.Sum1_n = WheelSpd1_B.gain_m - WheelSpd1_B.d1_d;

  /* Product: '<S17>/Product1' incorporates:
   *  Constant: '<S17>/Constant4'
   */
  u0 = 2.0 * WheelSpd1_P.jeta * WheelSpd1_P.Wn * WheelSpd1_P.P + 196.0;
  WheelSpd1_B.Product1_f = u0 * WheelSpd1_B.Sum1_n;

  /* UnitDelay: '<S23>/d' */
  WheelSpd1_B.d_b = WheelSpd1_DW.d_DSTATE_i;

  /* Sum: '<S23>/Sum2' */
  WheelSpd1_B.Sum2_g = WheelSpd1_B.Sum1_n - WheelSpd1_B.d_b;

  /* Gain: '<S23>/gain' */
  u0 = WheelSpd1_P.Ts;
  u0 = 2.0 / u0;
  WheelSpd1_B.gain_o = u0 * WheelSpd1_B.Sum2_g;

  /* UnitDelay: '<S23>/d1' */
  WheelSpd1_B.d1_c = WheelSpd1_DW.d1_DSTATE_a;

  /* Sum: '<S23>/Sum1' */
  WheelSpd1_B.Sum1_p = WheelSpd1_B.gain_o - WheelSpd1_B.d1_c;

  /* Product: '<S17>/Product' incorporates:
   *  Constant: '<S17>/Constant3'
   */
  u0 = 2.0 * WheelSpd1_P.jeta * WheelSpd1_P.Wn + WheelSpd1_P.P;
  WheelSpd1_B.Product_n = u0 * WheelSpd1_B.Sum1_p;

  /* UnitDelay: '<S24>/d' */
  WheelSpd1_B.d_bp = WheelSpd1_DW.d_DSTATE_ak;

  /* Sum: '<S24>/Sum2' */
  WheelSpd1_B.Sum2_k = WheelSpd1_B.Sum1_p - WheelSpd1_B.d_bp;

  /* Gain: '<S24>/gain' */
  u0 = WheelSpd1_P.Ts;
  u0 = 2.0 / u0;
  WheelSpd1_B.gain_d = u0 * WheelSpd1_B.Sum2_k;

  /* UnitDelay: '<S24>/d1' */
  WheelSpd1_B.d1_f = WheelSpd1_DW.d1_DSTATE_f;

  /* Sum: '<S24>/Sum1' */
  WheelSpd1_B.Sum1_k = WheelSpd1_B.gain_d - WheelSpd1_B.d1_f;

  /* Sum: '<S17>/Add5' */
  WheelSpd1_B.Add5 = ((WheelSpd1_B.Product2_c + WheelSpd1_B.Product1_f) +
                      WheelSpd1_B.Product_n) + WheelSpd1_B.Sum1_k;

  /* Gain: '<S17>/Gain' */
  u0 = 196.0 * WheelSpd1_P.K;
  u0 = 1.0 / u0;
  WheelSpd1_B.Gain_l = u0 * WheelSpd1_B.Add5;

  /* Delay: '<S26>/Delay1' */
  WheelSpd1_B.Delay1 = WheelSpd1_DW.Delay1_DSTATE;

  /* Gain: '<S26>/gain1' */
  WheelSpd1_B.gain1_g = WheelSpd1_P.gain1_Gain_b * WheelSpd1_B.Delay1;

  /* Delay: '<S26>/Delay' */
  WheelSpd1_B.Delay = WheelSpd1_DW.Delay_DSTATE[0];

  /* Sum: '<S26>/Sum3' */
  WheelSpd1_B.Sum3_d = (WheelSpd1_B.Gain_l + WheelSpd1_B.gain1_g) +
    WheelSpd1_B.Delay;

  /* Gain: '<S26>/gain2' incorporates:
   *  Constant: '<S8>/FF_CutoffFreq'
   */
  WheelSpd1_B.gain2_h = WheelSpd1_P.gain2_Gain_p *
    WheelSpd1_P.FF_CutoffFreq_Value;

  /* Product: '<S26>/Product2' incorporates:
   *  Constant: '<S26>/Constant'
   */
  WheelSpd1_B.Product2_e = WheelSpd1_B.gain2_h * WheelSpd1_B.gain2_h *
    WheelSpd1_P.Ts * WheelSpd1_P.Ts;

  /* Product: '<S26>/x(n), x(n-1), x(n-2)' */
  WheelSpd1_B.xnxn1xn2 = WheelSpd1_B.Sum3_d * WheelSpd1_B.Product2_e;

  /* Gain: '<S26>/gain3' */
  WheelSpd1_B.gain3 = WheelSpd1_P.gain3_Gain * WheelSpd1_B.Product2_e;

  /* Sum: '<S26>/Sum4' incorporates:
   *  Constant: '<S26>/Constant1'
   */
  WheelSpd1_B.Sum4_c = WheelSpd1_B.gain3 - WheelSpd1_P.Constant1_Value_p;

  /* Delay: '<S26>/Delay2' */
  WheelSpd1_B.Delay2 = WheelSpd1_DW.Delay2_DSTATE;

  /* Product: '<S26>/y(n-1)' */
  WheelSpd1_B.yn1 = WheelSpd1_B.Sum4_c * WheelSpd1_B.Delay2;

  /* Sum: '<S26>/Sum1' */
  WheelSpd1_B.Sum1_a = WheelSpd1_B.xnxn1xn2 - WheelSpd1_B.yn1;

  /* Product: '<S26>/Product3' incorporates:
   *  Constant: '<S26>/Constant'
   */
  WheelSpd1_B.Product3 = WheelSpd1_B.gain2_h * WheelSpd1_P.Ts;

  /* Gain: '<S26>/gain4' */
  WheelSpd1_B.gain4 = WheelSpd1_P.gain4_Gain * WheelSpd1_B.Product3;

  /* Product: '<S26>/Product4' incorporates:
   *  Constant: '<S17>/zeta'
   */
  WheelSpd1_B.Product4 = WheelSpd1_B.gain4 * WheelSpd1_P.zeta_Value;

  /* Sum: '<S26>/Sum5' incorporates:
   *  Constant: '<S26>/Constant2'
   */
  WheelSpd1_B.Sum5 = (WheelSpd1_B.Product2_e - WheelSpd1_B.Product4) +
    WheelSpd1_P.Constant2_Value_f;

  /* Delay: '<S26>/Delay3' */
  WheelSpd1_B.Delay3 = WheelSpd1_DW.Delay3_DSTATE[0];

  /* Product: '<S26>/y(n-2)' */
  WheelSpd1_B.yn2 = WheelSpd1_B.Sum5 * WheelSpd1_B.Delay3;

  /* Sum: '<S26>/Sum2' */
  WheelSpd1_B.Sum2_c = WheelSpd1_B.Sum1_a - WheelSpd1_B.yn2;

  /* Sum: '<S26>/Sum6' incorporates:
   *  Constant: '<S26>/Constant2'
   */
  WheelSpd1_B.Sum6 = (WheelSpd1_B.Product2_e + WheelSpd1_B.Product4) +
    WheelSpd1_P.Constant2_Value_f;

  /* Product: '<S26>/Product1' */
  WheelSpd1_B.Product1_n = WheelSpd1_B.Sum2_c / WheelSpd1_B.Sum6;

  /* UnitDelay: '<S25>/d1' */
  WheelSpd1_B.d1_b = WheelSpd1_DW.d1_DSTATE_b;

  /* Sum: '<S25>/Sum3' */
  WheelSpd1_B.Sum3_c = WheelSpd1_B.Product1_n + WheelSpd1_B.d1_b;

  /* Gain: '<S25>/gain' */
  WheelSpd1_B.gain_e = WheelSpd1_P.Ts * WheelSpd1_B.Sum3_c;

  /* Gain: '<S25>/gain2' incorporates:
   *  Constant: '<S17>/Constant1'
   */
  WheelSpd1_B.gain2_k = WheelSpd1_P.gain2_Gain_po *
    WheelSpd1_P.Constant1_Value_i;

  /* Product: '<S25>/Product2' incorporates:
   *  Constant: '<S25>/Constant1'
   */
  WheelSpd1_B.Product2_p = WheelSpd1_P.Constant1_Value_h / WheelSpd1_B.gain2_k;

  /* Gain: '<S25>/gain1' */
  WheelSpd1_B.gain1_gt = WheelSpd1_P.gain1_Gain_f * WheelSpd1_B.Product2_p;

  /* Sum: '<S25>/Sum1' incorporates:
   *  Constant: '<S25>/Constant'
   */
  WheelSpd1_B.Sum1_px = WheelSpd1_B.gain1_gt - WheelSpd1_P.Ts;

  /* UnitDelay: '<S25>/d' */
  WheelSpd1_B.d_i = WheelSpd1_DW.d_DSTATE_o;

  /* Product: '<S25>/Product11' */
  WheelSpd1_B.Product11_e = WheelSpd1_B.Sum1_px * WheelSpd1_B.d_i;

  /* Sum: '<S25>/Sum2' */
  WheelSpd1_B.Sum2_kk = WheelSpd1_B.gain_e + WheelSpd1_B.Product11_e;

  /* Sum: '<S25>/Sum4' incorporates:
   *  Constant: '<S25>/Constant'
   */
  WheelSpd1_B.Sum4_l = WheelSpd1_B.gain1_gt + WheelSpd1_P.Ts;

  /* Product: '<S25>/Product1' */
  WheelSpd1_B.Product1_i = WheelSpd1_B.Sum2_kk / WheelSpd1_B.Sum4_l;

  /* Gain: '<S17>/FFGain' */
  WheelSpd1_B.FFGain = WheelSpd1_P.FFGain_Gain * WheelSpd1_B.Product1_i;

  /* Outputs for Iterator SubSystem: '<Root>/DAQ_In' incorporates:
   *  WhileIterator: '<S1>/While Iterator'
   */
  s1_iter = 1;
  do {
    /* Level2 S-Function Block: '<S1>/CAN Setup' (sg_IO613_setup_s) */
    {
      SimStruct *rts = WheelSpd1_M->childSfunctions[0];
      sfcnOutputs(rts,1);
    }

    /* Level2 S-Function Block: '<S1>/CAN Read1' (sg_IO61X_read_s) */
    {
      SimStruct *rts = WheelSpd1_M->childSfunctions[1];
      sfcnOutputs(rts,1);
    }

    {
      /* S-Function (scanunpack): '<S1>/CAN Unpack2' */
      if ((8 == WheelSpd1_B.CANRead1_o2.Length) && (WheelSpd1_B.CANRead1_o2.ID
           != INVALID_CAN_ID) ) {
        if ((768U == WheelSpd1_B.CANRead1_o2.ID) && (0U ==
             WheelSpd1_B.CANRead1_o2.Extended) ) {
          {
            /* --------------- START Unpacking signal 0 ------------------
             *  startBit                = 32
             *  length                  = 16
             *  desiredSignalByteLayout = LITTLEENDIAN
             *  dataType                = UNSIGNED
             *  factor                  = 1.0
             *  offset                  = -32768.0
             * -----------------------------------------------------------------------*/
            {
              {
                real64_T outValue = 0;

                {
                  {
                    uint16_T unpackedValue = 0;

                    {
                      uint16_T tempValue = (uint16_T) (0);

                      {
                        tempValue = tempValue | (uint16_T)((uint16_T)((uint16_T)
                          ((WheelSpd1_B.CANRead1_o2.Data[4]) & (uint16_T)
                           ( (uint16_T) (1)<< 0)) >> 0)<<0);
                      }

                      {
                        tempValue = tempValue | (uint16_T)((uint16_T)((uint16_T)
                          ((WheelSpd1_B.CANRead1_o2.Data[4]) & (uint16_T)
                           ( (uint16_T) (1)<< 1)) >> 1)<<1);
                      }

                      {
                        tempValue = tempValue | (uint16_T)((uint16_T)((uint16_T)
                          ((WheelSpd1_B.CANRead1_o2.Data[4]) & (uint16_T)
                           ( (uint16_T) (1)<< 2)) >> 2)<<2);
                      }

                      {
                        tempValue = tempValue | (uint16_T)((uint16_T)((uint16_T)
                          ((WheelSpd1_B.CANRead1_o2.Data[4]) & (uint16_T)
                           ( (uint16_T) (1)<< 3)) >> 3)<<3);
                      }

                      {
                        tempValue = tempValue | (uint16_T)((uint16_T)((uint16_T)
                          ((WheelSpd1_B.CANRead1_o2.Data[4]) & (uint16_T)
                           ( (uint16_T) (1)<< 4)) >> 4)<<4);
                      }

                      {
                        tempValue = tempValue | (uint16_T)((uint16_T)((uint16_T)
                          ((WheelSpd1_B.CANRead1_o2.Data[4]) & (uint16_T)
                           ( (uint16_T) (1)<< 5)) >> 5)<<5);
                      }

                      {
                        tempValue = tempValue | (uint16_T)((uint16_T)((uint16_T)
                          ((WheelSpd1_B.CANRead1_o2.Data[4]) & (uint16_T)
                           ( (uint16_T) (1)<< 6)) >> 6)<<6);
                      }

                      {
                        tempValue = tempValue | (uint16_T)((uint16_T)((uint16_T)
                          ((WheelSpd1_B.CANRead1_o2.Data[4]) & (uint16_T)
                           ( (uint16_T) (1)<< 7)) >> 7)<<7);
                      }

                      {
                        tempValue = tempValue | (uint16_T)((uint16_T)((uint16_T)
                          ((WheelSpd1_B.CANRead1_o2.Data[5]) & (uint16_T)
                           ( (uint16_T) (1)<< 0)) >> 0)<<8);
                      }

                      {
                        tempValue = tempValue | (uint16_T)((uint16_T)((uint16_T)
                          ((WheelSpd1_B.CANRead1_o2.Data[5]) & (uint16_T)
                           ( (uint16_T) (1)<< 1)) >> 1)<<9);
                      }

                      {
                        tempValue = tempValue | (uint16_T)((uint16_T)((uint16_T)
                          ((WheelSpd1_B.CANRead1_o2.Data[5]) & (uint16_T)
                           ( (uint16_T) (1)<< 2)) >> 2)<<10);
                      }

                      {
                        tempValue = tempValue | (uint16_T)((uint16_T)((uint16_T)
                          ((WheelSpd1_B.CANRead1_o2.Data[5]) & (uint16_T)
                           ( (uint16_T) (1)<< 3)) >> 3)<<11);
                      }

                      {
                        tempValue = tempValue | (uint16_T)((uint16_T)((uint16_T)
                          ((WheelSpd1_B.CANRead1_o2.Data[5]) & (uint16_T)
                           ( (uint16_T) (1)<< 4)) >> 4)<<12);
                      }

                      {
                        tempValue = tempValue | (uint16_T)((uint16_T)((uint16_T)
                          ((WheelSpd1_B.CANRead1_o2.Data[5]) & (uint16_T)
                           ( (uint16_T) (1)<< 5)) >> 5)<<13);
                      }

                      {
                        tempValue = tempValue | (uint16_T)((uint16_T)((uint16_T)
                          ((WheelSpd1_B.CANRead1_o2.Data[5]) & (uint16_T)
                           ( (uint16_T) (1)<< 6)) >> 6)<<14);
                      }

                      {
                        tempValue = tempValue | (uint16_T)((uint16_T)((uint16_T)
                          ((WheelSpd1_B.CANRead1_o2.Data[5]) & (uint16_T)
                           ( (uint16_T) (1)<< 7)) >> 7)<<15);
                      }

                      unpackedValue = tempValue;
                    }

                    outValue = (real64_T) (unpackedValue);
                  }
                }

                {
                  real64_T result = (real64_T) outValue;
                  result = result + -32768.0;
                  WheelSpd1_B.RPM = result;
                }
              }
            }

            /* --------------- START Unpacking signal 1 ------------------
             *  startBit                = 48
             *  length                  = 16
             *  desiredSignalByteLayout = LITTLEENDIAN
             *  dataType                = UNSIGNED
             *  factor                  = 0.1
             *  offset                  = -200.0
             * -----------------------------------------------------------------------*/
            {
              {
                real64_T outValue = 0;

                {
                  {
                    uint16_T unpackedValue = 0;

                    {
                      uint16_T tempValue = (uint16_T) (0);

                      {
                        tempValue = tempValue | (uint16_T)((uint16_T)((uint16_T)
                          ((WheelSpd1_B.CANRead1_o2.Data[6]) & (uint16_T)
                           ( (uint16_T) (1)<< 0)) >> 0)<<0);
                      }

                      {
                        tempValue = tempValue | (uint16_T)((uint16_T)((uint16_T)
                          ((WheelSpd1_B.CANRead1_o2.Data[6]) & (uint16_T)
                           ( (uint16_T) (1)<< 1)) >> 1)<<1);
                      }

                      {
                        tempValue = tempValue | (uint16_T)((uint16_T)((uint16_T)
                          ((WheelSpd1_B.CANRead1_o2.Data[6]) & (uint16_T)
                           ( (uint16_T) (1)<< 2)) >> 2)<<2);
                      }

                      {
                        tempValue = tempValue | (uint16_T)((uint16_T)((uint16_T)
                          ((WheelSpd1_B.CANRead1_o2.Data[6]) & (uint16_T)
                           ( (uint16_T) (1)<< 3)) >> 3)<<3);
                      }

                      {
                        tempValue = tempValue | (uint16_T)((uint16_T)((uint16_T)
                          ((WheelSpd1_B.CANRead1_o2.Data[6]) & (uint16_T)
                           ( (uint16_T) (1)<< 4)) >> 4)<<4);
                      }

                      {
                        tempValue = tempValue | (uint16_T)((uint16_T)((uint16_T)
                          ((WheelSpd1_B.CANRead1_o2.Data[6]) & (uint16_T)
                           ( (uint16_T) (1)<< 5)) >> 5)<<5);
                      }

                      {
                        tempValue = tempValue | (uint16_T)((uint16_T)((uint16_T)
                          ((WheelSpd1_B.CANRead1_o2.Data[6]) & (uint16_T)
                           ( (uint16_T) (1)<< 6)) >> 6)<<6);
                      }

                      {
                        tempValue = tempValue | (uint16_T)((uint16_T)((uint16_T)
                          ((WheelSpd1_B.CANRead1_o2.Data[6]) & (uint16_T)
                           ( (uint16_T) (1)<< 7)) >> 7)<<7);
                      }

                      {
                        tempValue = tempValue | (uint16_T)((uint16_T)((uint16_T)
                          ((WheelSpd1_B.CANRead1_o2.Data[7]) & (uint16_T)
                           ( (uint16_T) (1)<< 0)) >> 0)<<8);
                      }

                      {
                        tempValue = tempValue | (uint16_T)((uint16_T)((uint16_T)
                          ((WheelSpd1_B.CANRead1_o2.Data[7]) & (uint16_T)
                           ( (uint16_T) (1)<< 1)) >> 1)<<9);
                      }

                      {
                        tempValue = tempValue | (uint16_T)((uint16_T)((uint16_T)
                          ((WheelSpd1_B.CANRead1_o2.Data[7]) & (uint16_T)
                           ( (uint16_T) (1)<< 2)) >> 2)<<10);
                      }

                      {
                        tempValue = tempValue | (uint16_T)((uint16_T)((uint16_T)
                          ((WheelSpd1_B.CANRead1_o2.Data[7]) & (uint16_T)
                           ( (uint16_T) (1)<< 3)) >> 3)<<11);
                      }

                      {
                        tempValue = tempValue | (uint16_T)((uint16_T)((uint16_T)
                          ((WheelSpd1_B.CANRead1_o2.Data[7]) & (uint16_T)
                           ( (uint16_T) (1)<< 4)) >> 4)<<12);
                      }

                      {
                        tempValue = tempValue | (uint16_T)((uint16_T)((uint16_T)
                          ((WheelSpd1_B.CANRead1_o2.Data[7]) & (uint16_T)
                           ( (uint16_T) (1)<< 5)) >> 5)<<13);
                      }

                      {
                        tempValue = tempValue | (uint16_T)((uint16_T)((uint16_T)
                          ((WheelSpd1_B.CANRead1_o2.Data[7]) & (uint16_T)
                           ( (uint16_T) (1)<< 6)) >> 6)<<14);
                      }

                      {
                        tempValue = tempValue | (uint16_T)((uint16_T)((uint16_T)
                          ((WheelSpd1_B.CANRead1_o2.Data[7]) & (uint16_T)
                           ( (uint16_T) (1)<< 7)) >> 7)<<15);
                      }

                      unpackedValue = tempValue;
                    }

                    outValue = (real64_T) (unpackedValue);
                  }
                }

                {
                  real64_T result = (real64_T) outValue;
                  result = (result * 0.1) + -200.0;
                  WheelSpd1_B.TQ = result;
                }
              }
            }
          }
        }
      }
    }

    s1_iter++;
  } while (WheelSpd1_B.CANRead1_o1 && (s1_iter <= 501));

  /* End of Outputs for SubSystem: '<Root>/DAQ_In' */

  /* Sum: '<S4>/Subtract' */
  WheelSpd1_B.Error = WheelSpd1_B.Product1 - WheelSpd1_B.RPM;

  /* Gain: '<S18>/Gain' incorporates:
   *  Constant: '<S8>/BW_P'
   */
  WheelSpd1_B.Gain_a = WheelSpd1_P.Gain_Gain_n * WheelSpd1_P.BW_P_Value;

  /* Fcn: '<S18>/Kp' */
  u0 = WheelSpd1_B.Gain_a;
  u0 = rt_powd_snf(u0, 3.0);
  WheelSpd1_B.Kp = (u0 - 156.8) / 105840.0;

  /* Gain: '<S19>/gain ' incorporates:
   *  Constant: '<S8>/BW_PI'
   */
  WheelSpd1_B.gain_mk = WheelSpd1_P.gain_Gain * WheelSpd1_P.BW_PI_Value;

  /* Fcn: '<S19>/Kp' */
  u0 = WheelSpd1_B.gain_mk;
  u0 = rt_powd_snf(u0, 3.0);
  WheelSpd1_B.Kp_b = (4.0 * u0 - 156.8) / 105840.0;

  /* Fcn: '<S19>/Ki' */
  u0 = WheelSpd1_B.gain_mk;
  u0 = rt_powd_snf(u0, 4.0);
  WheelSpd1_B.Ki = 105840.0 / u0;

  /* Gain: '<S20>/gain2' incorporates:
   *  Constant: '<S19>/Constant'
   */
  WheelSpd1_B.gain2_n = WheelSpd1_P.gain2_Gain_c * WheelSpd1_P.Constant_Value_d;

  /* Product: '<S20>/Product2' incorporates:
   *  Constant: '<S20>/Constant1'
   */
  WheelSpd1_B.tau = WheelSpd1_P.Constant1_Value_l / WheelSpd1_B.gain2_n;

  /* Gain: '<S20>/gain3' */
  WheelSpd1_B.utau = WheelSpd1_P.gain3_Gain_o * WheelSpd1_B.tau;

  /* UnitDelay: '<S21>/d1' */
  WheelSpd1_B.d1_cf = WheelSpd1_DW.d1_DSTATE_g;

  /* Sum: '<S21>/Sum1' */
  WheelSpd1_B.Sum1_d = WheelSpd1_B.Error + WheelSpd1_B.d1_cf;

  /* Gain: '<S21>/gain' */
  u0 = WheelSpd1_P.Ts;
  u0 /= 2.0;
  WheelSpd1_B.gain_ds = u0 * WheelSpd1_B.Sum1_d;

  /* UnitDelay: '<S21>/d' */
  WheelSpd1_B.d_c = WheelSpd1_DW.d_DSTATE_ir;

  /* Sum: '<S21>/Sum2' */
  WheelSpd1_B.Sum2_l = WheelSpd1_B.gain_ds + WheelSpd1_B.d_c;

  /* UnitDelay: '<S20>/d1' */
  WheelSpd1_B.d1_p = WheelSpd1_DW.d1_DSTATE_lw;

  /* Sum: '<S20>/Sum3' */
  WheelSpd1_B.Sum3_g = WheelSpd1_B.Sum2_l - WheelSpd1_B.d1_p;

  /* Product: '<S20>/Product3' */
  WheelSpd1_B.Product3_e = WheelSpd1_B.utau * WheelSpd1_B.Sum3_g;

  /* Sum: '<S20>/Sum1' incorporates:
   *  Constant: '<S20>/Constant'
   */
  WheelSpd1_B.Sum1_i = WheelSpd1_B.utau - WheelSpd1_P.Ts;

  /* UnitDelay: '<S20>/d' */
  WheelSpd1_B.d_j = WheelSpd1_DW.d_DSTATE_b;

  /* Product: '<S20>/Product11' */
  WheelSpd1_B.Product11_n = WheelSpd1_B.Sum1_i * WheelSpd1_B.d_j;

  /* Sum: '<S20>/Sum2' */
  WheelSpd1_B.Sum2_j = WheelSpd1_B.Product3_e + WheelSpd1_B.Product11_n;

  /* Sum: '<S20>/Sum4' incorporates:
   *  Constant: '<S20>/Constant2'
   */
  WheelSpd1_B.Sum4_a = WheelSpd1_B.utau + WheelSpd1_P.Ts;

  /* Product: '<S20>/Product1' */
  WheelSpd1_B.Product1_a = WheelSpd1_B.Sum2_j / WheelSpd1_B.Sum4_a;

  /* MultiPortSwitch: '<S16>/Multiport Switch1' incorporates:
   *  Constant: '<S8>/Selector'
   */
  if ((int32_T)WheelSpd1_P.Selector_Value == 1) {
    /* Product: '<S18>/Product' */
    WheelSpd1_B.Product_k = WheelSpd1_B.Error * WheelSpd1_B.Kp;
    WheelSpd1_B.MultiportSwitch1 = WheelSpd1_B.Product_k;
  } else {
    /* Product: '<S19>/Divide2' */
    WheelSpd1_B.Divide2 = WheelSpd1_B.Ki * WheelSpd1_B.Product1_a;

    /* Product: '<S19>/Divide1' */
    WheelSpd1_B.Divide1 = WheelSpd1_B.Error * WheelSpd1_B.Kp_b;

    /* Sum: '<S19>/Add' */
    WheelSpd1_B.Add_k = WheelSpd1_B.Divide1 + WheelSpd1_B.Divide2;
    WheelSpd1_B.MultiportSwitch1 = WheelSpd1_B.Add_k;
  }

  /* End of MultiPortSwitch: '<S16>/Multiport Switch1' */

  /* Gain: '<S8>/FBGain' */
  WheelSpd1_B.FBOut = WheelSpd1_P.FBGain_Gain * WheelSpd1_B.MultiportSwitch1;

  /* Sum: '<S8>/Add' */
  WheelSpd1_B.Add = WheelSpd1_B.FFGain + WheelSpd1_B.FBOut;

  /* Memory: '<S4>/Memory' */
  WheelSpd1_B.Memory = WheelSpd1_DW.Memory_PreviousInput;

  /* Product: '<S7>/Product4' incorporates:
   *  Constant: '<S7>/Constant5'
   */
  u0 = WheelSpd1_P.P * 196.0;
  WheelSpd1_B.Product4_o = u0 * WheelSpd1_B.Product1;

  /* UnitDelay: '<S11>/d' */
  WheelSpd1_B.d_in = WheelSpd1_DW.d_DSTATE_bw;

  /* Sum: '<S11>/Sum2' */
  WheelSpd1_B.Sum2_hn = WheelSpd1_B.Product1 - WheelSpd1_B.d_in;

  /* Gain: '<S11>/gain' */
  u0 = WheelSpd1_P.Ts;
  u0 = 2.0 / u0;
  WheelSpd1_B.gain_j = u0 * WheelSpd1_B.Sum2_hn;

  /* UnitDelay: '<S11>/d1' */
  WheelSpd1_B.d1_e = WheelSpd1_DW.d1_DSTATE_gc;

  /* Sum: '<S11>/Sum1' */
  WheelSpd1_B.Sum1_m = WheelSpd1_B.gain_j - WheelSpd1_B.d1_e;

  /* Product: '<S7>/Product3' incorporates:
   *  Constant: '<S7>/Constant4'
   */
  u0 = 2.0 * WheelSpd1_P.jeta * WheelSpd1_P.Wn * WheelSpd1_P.P + 196.0;
  WheelSpd1_B.Product3_f = u0 * WheelSpd1_B.Sum1_m;

  /* UnitDelay: '<S12>/d' */
  WheelSpd1_B.d_n = WheelSpd1_DW.d_DSTATE_d;

  /* Sum: '<S12>/Sum2' */
  WheelSpd1_B.Sum2_kl = WheelSpd1_B.Sum1_m - WheelSpd1_B.d_n;

  /* Gain: '<S12>/gain' */
  u0 = WheelSpd1_P.Ts;
  u0 = 2.0 / u0;
  WheelSpd1_B.gain_g = u0 * WheelSpd1_B.Sum2_kl;

  /* UnitDelay: '<S12>/d1' */
  WheelSpd1_B.d1_bp = WheelSpd1_DW.d1_DSTATE_l3;

  /* Sum: '<S12>/Sum1' */
  WheelSpd1_B.Sum1_f = WheelSpd1_B.gain_g - WheelSpd1_B.d1_bp;

  /* Product: '<S7>/Product2' incorporates:
   *  Constant: '<S7>/Constant3'
   */
  u0 = 2.0 * WheelSpd1_P.jeta * WheelSpd1_P.Wn + WheelSpd1_P.P;
  WheelSpd1_B.Product2_l = u0 * WheelSpd1_B.Sum1_f;

  /* UnitDelay: '<S13>/d' */
  WheelSpd1_B.d_cu = WheelSpd1_DW.d_DSTATE_g;

  /* Sum: '<S13>/Sum2' */
  WheelSpd1_B.Sum2_a = WheelSpd1_B.Sum1_f - WheelSpd1_B.d_cu;

  /* Gain: '<S13>/gain' */
  u0 = WheelSpd1_P.Ts;
  u0 = 2.0 / u0;
  WheelSpd1_B.gain_gz = u0 * WheelSpd1_B.Sum2_a;

  /* UnitDelay: '<S13>/d1' */
  WheelSpd1_B.d1_di = WheelSpd1_DW.d1_DSTATE_c;

  /* Sum: '<S13>/Sum1' */
  WheelSpd1_B.Sum1_g = WheelSpd1_B.gain_gz - WheelSpd1_B.d1_di;

  /* Sum: '<S7>/Add2' */
  WheelSpd1_B.Add2 = ((WheelSpd1_B.Product4_o + WheelSpd1_B.Product3_f) +
                      WheelSpd1_B.Product2_l) + WheelSpd1_B.Sum1_g;

  /* Gain: '<S7>/Gain' */
  u0 = 196.0 * WheelSpd1_P.K;
  u0 = 1.0 / u0;
  WheelSpd1_B.Gain_c = u0 * WheelSpd1_B.Add2;

  /* Sum: '<S7>/Add3' */
  WheelSpd1_B.Add3 = WheelSpd1_B.Gain_c - WheelSpd1_B.Memory;

  /* UnitDelay: '<S14>/d1' */
  WheelSpd1_B.d1_n = WheelSpd1_DW.d1_DSTATE_m;

  /* Sum: '<S14>/Sum3' */
  WheelSpd1_B.Sum3_f = WheelSpd1_B.Add3 + WheelSpd1_B.d1_n;

  /* Gain: '<S14>/gain' */
  WheelSpd1_B.gain_o3 = WheelSpd1_P.Ts * WheelSpd1_B.Sum3_f;

  /* Gain: '<S14>/gain2' incorporates:
   *  Constant: '<S4>/Pole'
   */
  WheelSpd1_B.gain2_m = WheelSpd1_P.gain2_Gain_a * WheelSpd1_P.Pole_Value;

  /* Product: '<S14>/Product2' incorporates:
   *  Constant: '<S14>/Constant1'
   */
  WheelSpd1_B.Product2_h = WheelSpd1_P.Constant1_Value_id / WheelSpd1_B.gain2_m;

  /* Gain: '<S14>/gain1' */
  WheelSpd1_B.gain1_k = WheelSpd1_P.gain1_Gain_f2 * WheelSpd1_B.Product2_h;

  /* Sum: '<S14>/Sum1' incorporates:
   *  Constant: '<S14>/Constant'
   */
  WheelSpd1_B.Sum1_e = WheelSpd1_B.gain1_k - WheelSpd1_P.Ts;

  /* UnitDelay: '<S14>/d' */
  WheelSpd1_B.d_p = WheelSpd1_DW.d_DSTATE_h;

  /* Product: '<S14>/Product11' */
  WheelSpd1_B.Product11_i = WheelSpd1_B.Sum1_e * WheelSpd1_B.d_p;

  /* Sum: '<S14>/Sum2' */
  WheelSpd1_B.Sum2_b = WheelSpd1_B.gain_o3 + WheelSpd1_B.Product11_i;

  /* Sum: '<S14>/Sum4' incorporates:
   *  Constant: '<S14>/Constant'
   */
  WheelSpd1_B.Sum4_k = WheelSpd1_B.gain1_k + WheelSpd1_P.Ts;

  /* Product: '<S14>/Product1' */
  WheelSpd1_B.Product1_l = WheelSpd1_B.Sum2_b / WheelSpd1_B.Sum4_k;

  /* Delay: '<S15>/Delay1' */
  WheelSpd1_B.Delay1_n = WheelSpd1_DW.Delay1_DSTATE_i;

  /* Gain: '<S15>/gain1' */
  WheelSpd1_B.gain1_f = WheelSpd1_P.gain1_Gain_n * WheelSpd1_B.Delay1_n;

  /* Delay: '<S15>/Delay' */
  WheelSpd1_B.Delay_a = WheelSpd1_DW.Delay_DSTATE_g[0];

  /* Sum: '<S15>/Sum3' */
  WheelSpd1_B.Sum3_a = (WheelSpd1_B.Product1_l + WheelSpd1_B.gain1_f) +
    WheelSpd1_B.Delay_a;

  /* Gain: '<S15>/gain2' incorporates:
   *  Constant: '<S4>/Qfilter2'
   */
  WheelSpd1_B.gain2_d = WheelSpd1_P.gain2_Gain_f * WheelSpd1_P.Qfilter2_Value;

  /* Product: '<S15>/Product2' incorporates:
   *  Constant: '<S15>/Constant'
   */
  WheelSpd1_B.Product2_m = WheelSpd1_B.gain2_d * WheelSpd1_B.gain2_d *
    WheelSpd1_P.Ts * WheelSpd1_P.Ts;

  /* Product: '<S15>/x(n), x(n-1), x(n-2)' */
  WheelSpd1_B.xnxn1xn2_a = WheelSpd1_B.Sum3_a * WheelSpd1_B.Product2_m;

  /* Gain: '<S15>/gain3' */
  WheelSpd1_B.gain3_b = WheelSpd1_P.gain3_Gain_d * WheelSpd1_B.Product2_m;

  /* Sum: '<S15>/Sum4' incorporates:
   *  Constant: '<S15>/Constant1'
   */
  WheelSpd1_B.Sum4_kn = WheelSpd1_B.gain3_b - WheelSpd1_P.Constant1_Value_e;

  /* Delay: '<S15>/Delay2' */
  WheelSpd1_B.Delay2_n = WheelSpd1_DW.Delay2_DSTATE_c;

  /* Product: '<S15>/y(n-1)' */
  WheelSpd1_B.yn1_m = WheelSpd1_B.Sum4_kn * WheelSpd1_B.Delay2_n;

  /* Sum: '<S15>/Sum1' */
  WheelSpd1_B.Sum1_ek = WheelSpd1_B.xnxn1xn2_a - WheelSpd1_B.yn1_m;

  /* Product: '<S15>/Product3' incorporates:
   *  Constant: '<S15>/Constant'
   */
  WheelSpd1_B.Product3_i = WheelSpd1_B.gain2_d * WheelSpd1_P.Ts;

  /* Gain: '<S15>/gain4' */
  WheelSpd1_B.gain4_g = WheelSpd1_P.gain4_Gain_i * WheelSpd1_B.Product3_i;

  /* Product: '<S15>/Product4' incorporates:
   *  Constant: '<S7>/zeta1'
   */
  WheelSpd1_B.Product4_i = WheelSpd1_B.gain4_g * WheelSpd1_P.zeta1_Value;

  /* Sum: '<S15>/Sum5' incorporates:
   *  Constant: '<S15>/Constant2'
   */
  WheelSpd1_B.Sum5_f = (WheelSpd1_B.Product2_m - WheelSpd1_B.Product4_i) +
    WheelSpd1_P.Constant2_Value_h;

  /* Delay: '<S15>/Delay3' */
  WheelSpd1_B.Delay3_i = WheelSpd1_DW.Delay3_DSTATE_o[0];

  /* Product: '<S15>/y(n-2)' */
  WheelSpd1_B.yn2_g = WheelSpd1_B.Sum5_f * WheelSpd1_B.Delay3_i;

  /* Sum: '<S15>/Sum2' */
  WheelSpd1_B.Sum2_m = WheelSpd1_B.Sum1_ek - WheelSpd1_B.yn2_g;

  /* Sum: '<S15>/Sum6' incorporates:
   *  Constant: '<S15>/Constant2'
   */
  WheelSpd1_B.Sum6_g = (WheelSpd1_B.Product2_m + WheelSpd1_B.Product4_i) +
    WheelSpd1_P.Constant2_Value_h;

  /* Product: '<S15>/Product1' */
  WheelSpd1_B.Product1_fm = WheelSpd1_B.Sum2_m / WheelSpd1_B.Sum6_g;

  /* Product: '<S4>/Product' incorporates:
   *  Constant: '<S4>/DOBFlag'
   */
  WheelSpd1_B.Product_d = WheelSpd1_B.Product1_fm * WheelSpd1_P.DOBFlag_Value;

  /* Sum: '<S4>/Subtract2' */
  WheelSpd1_B.Subtract2 = WheelSpd1_B.Add - WheelSpd1_B.Product_d;

  /* Gain: '<S4>/ControlFlag' */
  WheelSpd1_B.ControlFlag = WheelSpd1_P.ControlFlag_Gain * WheelSpd1_B.Subtract2;

  /* Saturate: '<S4>/Saturation' */
  u0 = WheelSpd1_B.ControlFlag;
  u1 = WheelSpd1_P.Saturation_LowerSat;
  u2 = WheelSpd1_P.Saturation_UpperSat;
  if (u0 > u2) {
    WheelSpd1_B.ControlOutput = u2;
  } else if (u0 < u1) {
    WheelSpd1_B.ControlOutput = u1;
  } else {
    WheelSpd1_B.ControlOutput = u0;
  }

  /* End of Saturate: '<S4>/Saturation' */

  /* S-Function (scanpack): '<S5>/CAN Pack' */
  /* S-Function (scanpack): '<S5>/CAN Pack' */
  WheelSpd1_B.CANPack.ID = 592U;
  WheelSpd1_B.CANPack.Length = 8U;
  WheelSpd1_B.CANPack.Extended = 0U;
  WheelSpd1_B.CANPack.Remote = 0;
  WheelSpd1_B.CANPack.Data[0] = 0;
  WheelSpd1_B.CANPack.Data[1] = 0;
  WheelSpd1_B.CANPack.Data[2] = 0;
  WheelSpd1_B.CANPack.Data[3] = 0;
  WheelSpd1_B.CANPack.Data[4] = 0;
  WheelSpd1_B.CANPack.Data[5] = 0;
  WheelSpd1_B.CANPack.Data[6] = 0;
  WheelSpd1_B.CANPack.Data[7] = 0;

  {
    /* --------------- START Packing signal 0 ------------------
     *  startBit                = 0
     *  length                  = 1
     *  desiredSignalByteLayout = LITTLEENDIAN
     *  dataType                = UNSIGNED
     *  factor                  = 1.0
     *  offset                  = 0.0
     *  minimum                 = 0.0
     *  maximum                 = 0.0
     * -----------------------------------------------------------------------*/
    {
      {
        real64_T outValue = 0;

        {
          real64_T result = WheelSpd1_B.ContMode;

          /* no scaling required */
          outValue = result;
        }

        {
          {
            uint8_T packedValue;
            if (outValue > (real64_T)(1)) {
              packedValue = (uint8_T) 1;
            } else if (outValue < (real64_T)(0)) {
              packedValue = (uint8_T) 0;
            } else {
              packedValue = (uint8_T) (outValue);
            }

            {
              {
                WheelSpd1_B.CANPack.Data[0] = WheelSpd1_B.CANPack.Data[0] |
                  (uint8_T)((uint8_T)((uint8_T)(packedValue & (uint8_T)
                  (((uint8_T)(1)) << 0)) >> 0)<<0);
              }
            }
          }
        }
      }
    }

    /* --------------- START Packing signal 1 ------------------
     *  startBit                = 1
     *  length                  = 1
     *  desiredSignalByteLayout = LITTLEENDIAN
     *  dataType                = UNSIGNED
     *  factor                  = 1.0
     *  offset                  = 0.0
     *  minimum                 = 0.0
     *  maximum                 = 0.0
     * -----------------------------------------------------------------------*/
    {
      {
        real64_T outValue = 0;

        {
          real64_T result = WheelSpd1_B.Ready;

          /* no scaling required */
          outValue = result;
        }

        {
          {
            uint8_T packedValue;
            if (outValue > (real64_T)(1)) {
              packedValue = (uint8_T) 1;
            } else if (outValue < (real64_T)(0)) {
              packedValue = (uint8_T) 0;
            } else {
              packedValue = (uint8_T) (outValue);
            }

            {
              {
                WheelSpd1_B.CANPack.Data[0] = WheelSpd1_B.CANPack.Data[0] |
                  (uint8_T)((uint8_T)((uint8_T)(packedValue & (uint8_T)
                  (((uint8_T)(1)) << 0)) >> 0)<<1);
              }
            }
          }
        }
      }
    }

    /* --------------- START Packing signal 2 ------------------
     *  startBit                = 2
     *  length                  = 1
     *  desiredSignalByteLayout = LITTLEENDIAN
     *  dataType                = UNSIGNED
     *  factor                  = 1.0
     *  offset                  = 0.0
     *  minimum                 = 0.0
     *  maximum                 = 0.0
     * -----------------------------------------------------------------------*/
    {
      {
        real64_T outValue = 0;

        {
          real64_T result = WheelSpd1_B.Ready;

          /* no scaling required */
          outValue = result;
        }

        {
          {
            uint8_T packedValue;
            if (outValue > (real64_T)(1)) {
              packedValue = (uint8_T) 1;
            } else if (outValue < (real64_T)(0)) {
              packedValue = (uint8_T) 0;
            } else {
              packedValue = (uint8_T) (outValue);
            }

            {
              {
                WheelSpd1_B.CANPack.Data[0] = WheelSpd1_B.CANPack.Data[0] |
                  (uint8_T)((uint8_T)((uint8_T)(packedValue & (uint8_T)
                  (((uint8_T)(1)) << 0)) >> 0)<<2);
              }
            }
          }
        }
      }
    }

    /* --------------- START Packing signal 3 ------------------
     *  startBit                = 3
     *  length                  = 1
     *  desiredSignalByteLayout = LITTLEENDIAN
     *  dataType                = UNSIGNED
     *  factor                  = 1.0
     *  offset                  = 0.0
     *  minimum                 = 0.0
     *  maximum                 = 0.0
     * -----------------------------------------------------------------------*/
    {
      {
        real64_T outValue = 0;

        {
          real64_T result = WheelSpd1_B.Ready;

          /* no scaling required */
          outValue = result;
        }

        {
          {
            uint8_T packedValue;
            if (outValue > (real64_T)(1)) {
              packedValue = (uint8_T) 1;
            } else if (outValue < (real64_T)(0)) {
              packedValue = (uint8_T) 0;
            } else {
              packedValue = (uint8_T) (outValue);
            }

            {
              {
                WheelSpd1_B.CANPack.Data[0] = WheelSpd1_B.CANPack.Data[0] |
                  (uint8_T)((uint8_T)((uint8_T)(packedValue & (uint8_T)
                  (((uint8_T)(1)) << 0)) >> 0)<<3);
              }
            }
          }
        }
      }
    }

    /* --------------- START Packing signal 4 ------------------
     *  startBit                = 4
     *  length                  = 4
     *  desiredSignalByteLayout = LITTLEENDIAN
     *  dataType                = UNSIGNED
     *  factor                  = 1.0
     *  offset                  = 0.0
     *  minimum                 = 0.0
     *  maximum                 = 0.0
     * -----------------------------------------------------------------------*/
    {
      {
        real64_T outValue = 0;

        {
          real64_T result = WheelSpd1_B.Gear;

          /* no scaling required */
          outValue = result;
        }

        {
          {
            uint8_T packedValue;
            if (outValue > (real64_T)(15)) {
              packedValue = (uint8_T) 15;
            } else if (outValue < (real64_T)(0)) {
              packedValue = (uint8_T) 0;
            } else {
              packedValue = (uint8_T) (outValue);
            }

            {
              {
                WheelSpd1_B.CANPack.Data[0] = WheelSpd1_B.CANPack.Data[0] |
                  (uint8_T)((uint8_T)((uint8_T)(packedValue & (uint8_T)
                  (((uint8_T)(1)) << 0)) >> 0)<<4);
              }

              {
                WheelSpd1_B.CANPack.Data[0] = WheelSpd1_B.CANPack.Data[0] |
                  (uint8_T)((uint8_T)((uint8_T)(packedValue & (uint8_T)
                  (((uint8_T)(1)) << 1)) >> 1)<<5);
              }

              {
                WheelSpd1_B.CANPack.Data[0] = WheelSpd1_B.CANPack.Data[0] |
                  (uint8_T)((uint8_T)((uint8_T)(packedValue & (uint8_T)
                  (((uint8_T)(1)) << 2)) >> 2)<<6);
              }

              {
                WheelSpd1_B.CANPack.Data[0] = WheelSpd1_B.CANPack.Data[0] |
                  (uint8_T)((uint8_T)((uint8_T)(packedValue & (uint8_T)
                  (((uint8_T)(1)) << 3)) >> 3)<<7);
              }
            }
          }
        }
      }
    }

    /* --------------- START Packing signal 5 ------------------
     *  startBit                = 8
     *  length                  = 2
     *  desiredSignalByteLayout = LITTLEENDIAN
     *  dataType                = UNSIGNED
     *  factor                  = 1.0
     *  offset                  = 0.0
     *  minimum                 = 0.0
     *  maximum                 = 0.0
     * -----------------------------------------------------------------------*/
    {
      {
        real64_T outValue = 0;

        {
          real64_T result = WheelSpd1_B.Ready;

          /* no scaling required */
          outValue = result;
        }

        {
          {
            uint8_T packedValue;
            if (outValue > (real64_T)(3)) {
              packedValue = (uint8_T) 3;
            } else if (outValue < (real64_T)(0)) {
              packedValue = (uint8_T) 0;
            } else {
              packedValue = (uint8_T) (outValue);
            }

            {
              {
                WheelSpd1_B.CANPack.Data[1] = WheelSpd1_B.CANPack.Data[1] |
                  (uint8_T)((uint8_T)((uint8_T)(packedValue & (uint8_T)
                  (((uint8_T)(1)) << 0)) >> 0)<<0);
              }

              {
                WheelSpd1_B.CANPack.Data[1] = WheelSpd1_B.CANPack.Data[1] |
                  (uint8_T)((uint8_T)((uint8_T)(packedValue & (uint8_T)
                  (((uint8_T)(1)) << 1)) >> 1)<<1);
              }
            }
          }
        }
      }
    }

    /* --------------- START Packing signal 6 ------------------
     *  startBit                = 10
     *  length                  = 3
     *  desiredSignalByteLayout = LITTLEENDIAN
     *  dataType                = UNSIGNED
     *  factor                  = 1.0
     *  offset                  = 0.0
     *  minimum                 = 0.0
     *  maximum                 = 0.0
     * -----------------------------------------------------------------------*/
    {
      {
        real64_T outValue = 0;

        {
          real64_T result = WheelSpd1_B.BMS;

          /* no scaling required */
          outValue = result;
        }

        {
          {
            uint8_T packedValue;
            if (outValue > (real64_T)(7)) {
              packedValue = (uint8_T) 7;
            } else if (outValue < (real64_T)(0)) {
              packedValue = (uint8_T) 0;
            } else {
              packedValue = (uint8_T) (outValue);
            }

            {
              {
                WheelSpd1_B.CANPack.Data[1] = WheelSpd1_B.CANPack.Data[1] |
                  (uint8_T)((uint8_T)((uint8_T)(packedValue & (uint8_T)
                  (((uint8_T)(1)) << 0)) >> 0)<<2);
              }

              {
                WheelSpd1_B.CANPack.Data[1] = WheelSpd1_B.CANPack.Data[1] |
                  (uint8_T)((uint8_T)((uint8_T)(packedValue & (uint8_T)
                  (((uint8_T)(1)) << 1)) >> 1)<<3);
              }

              {
                WheelSpd1_B.CANPack.Data[1] = WheelSpd1_B.CANPack.Data[1] |
                  (uint8_T)((uint8_T)((uint8_T)(packedValue & (uint8_T)
                  (((uint8_T)(1)) << 2)) >> 2)<<4);
              }
            }
          }
        }
      }
    }

    /* --------------- START Packing signal 7 ------------------
     *  startBit                = 13
     *  length                  = 2
     *  desiredSignalByteLayout = LITTLEENDIAN
     *  dataType                = UNSIGNED
     *  factor                  = 1.0
     *  offset                  = 0.0
     *  minimum                 = 0.0
     *  maximum                 = 0.0
     * -----------------------------------------------------------------------*/
    {
      {
        real64_T outValue = 0;

        {
          real64_T result = WheelSpd1_B.Ready;

          /* no scaling required */
          outValue = result;
        }

        {
          {
            uint8_T packedValue;
            if (outValue > (real64_T)(3)) {
              packedValue = (uint8_T) 3;
            } else if (outValue < (real64_T)(0)) {
              packedValue = (uint8_T) 0;
            } else {
              packedValue = (uint8_T) (outValue);
            }

            {
              {
                WheelSpd1_B.CANPack.Data[1] = WheelSpd1_B.CANPack.Data[1] |
                  (uint8_T)((uint8_T)((uint8_T)(packedValue & (uint8_T)
                  (((uint8_T)(1)) << 0)) >> 0)<<5);
              }

              {
                WheelSpd1_B.CANPack.Data[1] = WheelSpd1_B.CANPack.Data[1] |
                  (uint8_T)((uint8_T)((uint8_T)(packedValue & (uint8_T)
                  (((uint8_T)(1)) << 1)) >> 1)<<6);
              }
            }
          }
        }
      }
    }

    /* --------------- START Packing signal 8 ------------------
     *  startBit                = 16
     *  length                  = 16
     *  desiredSignalByteLayout = LITTLEENDIAN
     *  dataType                = UNSIGNED
     *  factor                  = 0.1
     *  offset                  = -200.0
     *  minimum                 = 0.0
     *  maximum                 = 0.0
     * -----------------------------------------------------------------------*/
    {
      {
        real64_T outValue = 0;

        {
          real64_T result = WheelSpd1_B.PosTQLim;

          /* full scaling operation */
          result = (result - -200.0) * (1 / 0.1);
          outValue = result;
        }

        {
          {
            uint16_T packedValue;
            if (outValue > (real64_T)(65535)) {
              packedValue = (uint16_T) 65535;
            } else if (outValue < (real64_T)(0)) {
              packedValue = (uint16_T) 0;
            } else {
              packedValue = (uint16_T) (outValue);
            }

            {
              {
                WheelSpd1_B.CANPack.Data[2] = WheelSpd1_B.CANPack.Data[2] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 0)) >> 0)<<0);
              }

              {
                WheelSpd1_B.CANPack.Data[2] = WheelSpd1_B.CANPack.Data[2] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 1)) >> 1)<<1);
              }

              {
                WheelSpd1_B.CANPack.Data[2] = WheelSpd1_B.CANPack.Data[2] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 2)) >> 2)<<2);
              }

              {
                WheelSpd1_B.CANPack.Data[2] = WheelSpd1_B.CANPack.Data[2] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 3)) >> 3)<<3);
              }

              {
                WheelSpd1_B.CANPack.Data[2] = WheelSpd1_B.CANPack.Data[2] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 4)) >> 4)<<4);
              }

              {
                WheelSpd1_B.CANPack.Data[2] = WheelSpd1_B.CANPack.Data[2] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 5)) >> 5)<<5);
              }

              {
                WheelSpd1_B.CANPack.Data[2] = WheelSpd1_B.CANPack.Data[2] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 6)) >> 6)<<6);
              }

              {
                WheelSpd1_B.CANPack.Data[2] = WheelSpd1_B.CANPack.Data[2] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 7)) >> 7)<<7);
              }

              {
                WheelSpd1_B.CANPack.Data[3] = WheelSpd1_B.CANPack.Data[3] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 8)) >> 8)<<0);
              }

              {
                WheelSpd1_B.CANPack.Data[3] = WheelSpd1_B.CANPack.Data[3] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 9)) >> 9)<<1);
              }

              {
                WheelSpd1_B.CANPack.Data[3] = WheelSpd1_B.CANPack.Data[3] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 10)) >> 10)<<2);
              }

              {
                WheelSpd1_B.CANPack.Data[3] = WheelSpd1_B.CANPack.Data[3] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 11)) >> 11)<<3);
              }

              {
                WheelSpd1_B.CANPack.Data[3] = WheelSpd1_B.CANPack.Data[3] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 12)) >> 12)<<4);
              }

              {
                WheelSpd1_B.CANPack.Data[3] = WheelSpd1_B.CANPack.Data[3] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 13)) >> 13)<<5);
              }

              {
                WheelSpd1_B.CANPack.Data[3] = WheelSpd1_B.CANPack.Data[3] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 14)) >> 14)<<6);
              }

              {
                WheelSpd1_B.CANPack.Data[3] = WheelSpd1_B.CANPack.Data[3] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 15)) >> 15)<<7);
              }
            }
          }
        }
      }
    }

    /* --------------- START Packing signal 9 ------------------
     *  startBit                = 32
     *  length                  = 16
     *  desiredSignalByteLayout = LITTLEENDIAN
     *  dataType                = UNSIGNED
     *  factor                  = 0.1
     *  offset                  = -200.0
     *  minimum                 = 0.0
     *  maximum                 = 0.0
     * -----------------------------------------------------------------------*/
    {
      {
        real64_T outValue = 0;

        {
          real64_T result = WheelSpd1_B.NegTQLim;

          /* full scaling operation */
          result = (result - -200.0) * (1 / 0.1);
          outValue = result;
        }

        {
          {
            uint16_T packedValue;
            if (outValue > (real64_T)(65535)) {
              packedValue = (uint16_T) 65535;
            } else if (outValue < (real64_T)(0)) {
              packedValue = (uint16_T) 0;
            } else {
              packedValue = (uint16_T) (outValue);
            }

            {
              {
                WheelSpd1_B.CANPack.Data[4] = WheelSpd1_B.CANPack.Data[4] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 0)) >> 0)<<0);
              }

              {
                WheelSpd1_B.CANPack.Data[4] = WheelSpd1_B.CANPack.Data[4] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 1)) >> 1)<<1);
              }

              {
                WheelSpd1_B.CANPack.Data[4] = WheelSpd1_B.CANPack.Data[4] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 2)) >> 2)<<2);
              }

              {
                WheelSpd1_B.CANPack.Data[4] = WheelSpd1_B.CANPack.Data[4] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 3)) >> 3)<<3);
              }

              {
                WheelSpd1_B.CANPack.Data[4] = WheelSpd1_B.CANPack.Data[4] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 4)) >> 4)<<4);
              }

              {
                WheelSpd1_B.CANPack.Data[4] = WheelSpd1_B.CANPack.Data[4] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 5)) >> 5)<<5);
              }

              {
                WheelSpd1_B.CANPack.Data[4] = WheelSpd1_B.CANPack.Data[4] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 6)) >> 6)<<6);
              }

              {
                WheelSpd1_B.CANPack.Data[4] = WheelSpd1_B.CANPack.Data[4] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 7)) >> 7)<<7);
              }

              {
                WheelSpd1_B.CANPack.Data[5] = WheelSpd1_B.CANPack.Data[5] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 8)) >> 8)<<0);
              }

              {
                WheelSpd1_B.CANPack.Data[5] = WheelSpd1_B.CANPack.Data[5] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 9)) >> 9)<<1);
              }

              {
                WheelSpd1_B.CANPack.Data[5] = WheelSpd1_B.CANPack.Data[5] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 10)) >> 10)<<2);
              }

              {
                WheelSpd1_B.CANPack.Data[5] = WheelSpd1_B.CANPack.Data[5] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 11)) >> 11)<<3);
              }

              {
                WheelSpd1_B.CANPack.Data[5] = WheelSpd1_B.CANPack.Data[5] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 12)) >> 12)<<4);
              }

              {
                WheelSpd1_B.CANPack.Data[5] = WheelSpd1_B.CANPack.Data[5] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 13)) >> 13)<<5);
              }

              {
                WheelSpd1_B.CANPack.Data[5] = WheelSpd1_B.CANPack.Data[5] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 14)) >> 14)<<6);
              }

              {
                WheelSpd1_B.CANPack.Data[5] = WheelSpd1_B.CANPack.Data[5] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 15)) >> 15)<<7);
              }
            }
          }
        }
      }
    }

    /* --------------- START Packing signal 10 ------------------
     *  startBit                = 48
     *  length                  = 16
     *  desiredSignalByteLayout = LITTLEENDIAN
     *  dataType                = UNSIGNED
     *  factor                  = 0.1
     *  offset                  = -200.0
     *  minimum                 = 0.0
     *  maximum                 = 0.0
     * -----------------------------------------------------------------------*/
    {
      {
        real64_T outValue = 0;

        {
          real64_T result = WheelSpd1_B.ControlOutput;

          /* full scaling operation */
          result = (result - -200.0) * (1 / 0.1);
          outValue = result;
        }

        {
          {
            uint16_T packedValue;
            if (outValue > (real64_T)(65535)) {
              packedValue = (uint16_T) 65535;
            } else if (outValue < (real64_T)(0)) {
              packedValue = (uint16_T) 0;
            } else {
              packedValue = (uint16_T) (outValue);
            }

            {
              {
                WheelSpd1_B.CANPack.Data[6] = WheelSpd1_B.CANPack.Data[6] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 0)) >> 0)<<0);
              }

              {
                WheelSpd1_B.CANPack.Data[6] = WheelSpd1_B.CANPack.Data[6] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 1)) >> 1)<<1);
              }

              {
                WheelSpd1_B.CANPack.Data[6] = WheelSpd1_B.CANPack.Data[6] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 2)) >> 2)<<2);
              }

              {
                WheelSpd1_B.CANPack.Data[6] = WheelSpd1_B.CANPack.Data[6] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 3)) >> 3)<<3);
              }

              {
                WheelSpd1_B.CANPack.Data[6] = WheelSpd1_B.CANPack.Data[6] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 4)) >> 4)<<4);
              }

              {
                WheelSpd1_B.CANPack.Data[6] = WheelSpd1_B.CANPack.Data[6] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 5)) >> 5)<<5);
              }

              {
                WheelSpd1_B.CANPack.Data[6] = WheelSpd1_B.CANPack.Data[6] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 6)) >> 6)<<6);
              }

              {
                WheelSpd1_B.CANPack.Data[6] = WheelSpd1_B.CANPack.Data[6] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 7)) >> 7)<<7);
              }

              {
                WheelSpd1_B.CANPack.Data[7] = WheelSpd1_B.CANPack.Data[7] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 8)) >> 8)<<0);
              }

              {
                WheelSpd1_B.CANPack.Data[7] = WheelSpd1_B.CANPack.Data[7] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 9)) >> 9)<<1);
              }

              {
                WheelSpd1_B.CANPack.Data[7] = WheelSpd1_B.CANPack.Data[7] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 10)) >> 10)<<2);
              }

              {
                WheelSpd1_B.CANPack.Data[7] = WheelSpd1_B.CANPack.Data[7] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 11)) >> 11)<<3);
              }

              {
                WheelSpd1_B.CANPack.Data[7] = WheelSpd1_B.CANPack.Data[7] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 12)) >> 12)<<4);
              }

              {
                WheelSpd1_B.CANPack.Data[7] = WheelSpd1_B.CANPack.Data[7] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 13)) >> 13)<<5);
              }

              {
                WheelSpd1_B.CANPack.Data[7] = WheelSpd1_B.CANPack.Data[7] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 14)) >> 14)<<6);
              }

              {
                WheelSpd1_B.CANPack.Data[7] = WheelSpd1_B.CANPack.Data[7] |
                  (uint8_T)((uint8_T)((uint16_T)(packedValue & (uint16_T)
                  (((uint16_T)(1)) << 15)) >> 15)<<7);
              }
            }
          }
        }
      }
    }
  }

  /* S-Function (sg_IO61X_write_s): '<S5>/CAN Write1' */

  /* Level2 S-Function Block: '<S5>/CAN Write1' (sg_IO61X_write_s) */
  {
    SimStruct *rts = WheelSpd1_M->childSfunctions[2];
    sfcnOutputs(rts,1);
  }

  /* Constant: '<S8>/Constant1' */
  WheelSpd1_B.Constant1 = WheelSpd1_P.Wn;

  /* Constant: '<S8>/Constant16' */
  WheelSpd1_B.Constant16 = WheelSpd1_P.P;

  /* Constant: '<S8>/Constant17' */
  WheelSpd1_B.Constant17 = WheelSpd1_P.jeta;

  /* Constant: '<S8>/Constant2' */
  WheelSpd1_B.Constant2 = WheelSpd1_P.K;
}

/* Model update function */
static void WheelSpd1_update(void)
{
  /* Update for UnitDelay: '<S9>/d1' */
  WheelSpd1_DW.d1_DSTATE = WheelSpd1_B.TargetSpd;

  /* Update for UnitDelay: '<S9>/d' */
  WheelSpd1_DW.d_DSTATE = WheelSpd1_B.Product1;

  /* Update for UnitDelay: '<S22>/d' */
  WheelSpd1_DW.d_DSTATE_a = WheelSpd1_B.Product1;

  /* Update for UnitDelay: '<S22>/d1' */
  WheelSpd1_DW.d1_DSTATE_l = WheelSpd1_B.Sum1_n;

  /* Update for UnitDelay: '<S23>/d' */
  WheelSpd1_DW.d_DSTATE_i = WheelSpd1_B.Sum1_n;

  /* Update for UnitDelay: '<S23>/d1' */
  WheelSpd1_DW.d1_DSTATE_a = WheelSpd1_B.Sum1_p;

  /* Update for UnitDelay: '<S24>/d' */
  WheelSpd1_DW.d_DSTATE_ak = WheelSpd1_B.Sum1_p;

  /* Update for UnitDelay: '<S24>/d1' */
  WheelSpd1_DW.d1_DSTATE_f = WheelSpd1_B.Sum1_k;

  /* Update for Delay: '<S26>/Delay1' */
  WheelSpd1_DW.Delay1_DSTATE = WheelSpd1_B.Gain_l;

  /* Update for Delay: '<S26>/Delay' */
  WheelSpd1_DW.Delay_DSTATE[0] = WheelSpd1_DW.Delay_DSTATE[1];
  WheelSpd1_DW.Delay_DSTATE[1] = WheelSpd1_B.Gain_l;

  /* Update for Delay: '<S26>/Delay2' */
  WheelSpd1_DW.Delay2_DSTATE = WheelSpd1_B.Product1_n;

  /* Update for Delay: '<S26>/Delay3' */
  WheelSpd1_DW.Delay3_DSTATE[0] = WheelSpd1_DW.Delay3_DSTATE[1];
  WheelSpd1_DW.Delay3_DSTATE[1] = WheelSpd1_B.Product1_n;

  /* Update for UnitDelay: '<S25>/d1' */
  WheelSpd1_DW.d1_DSTATE_b = WheelSpd1_B.Product1_n;

  /* Update for UnitDelay: '<S25>/d' */
  WheelSpd1_DW.d_DSTATE_o = WheelSpd1_B.Product1_i;

  /* Update for UnitDelay: '<S21>/d1' */
  WheelSpd1_DW.d1_DSTATE_g = WheelSpd1_B.Error;

  /* Update for UnitDelay: '<S21>/d' */
  WheelSpd1_DW.d_DSTATE_ir = WheelSpd1_B.Sum2_l;

  /* Update for UnitDelay: '<S20>/d1' */
  WheelSpd1_DW.d1_DSTATE_lw = WheelSpd1_B.Sum2_l;

  /* Update for UnitDelay: '<S20>/d' */
  WheelSpd1_DW.d_DSTATE_b = WheelSpd1_B.Product1_a;

  /* Update for Memory: '<S4>/Memory' */
  WheelSpd1_DW.Memory_PreviousInput = WheelSpd1_B.ControlOutput;

  /* Update for UnitDelay: '<S11>/d' */
  WheelSpd1_DW.d_DSTATE_bw = WheelSpd1_B.Product1;

  /* Update for UnitDelay: '<S11>/d1' */
  WheelSpd1_DW.d1_DSTATE_gc = WheelSpd1_B.Sum1_m;

  /* Update for UnitDelay: '<S12>/d' */
  WheelSpd1_DW.d_DSTATE_d = WheelSpd1_B.Sum1_m;

  /* Update for UnitDelay: '<S12>/d1' */
  WheelSpd1_DW.d1_DSTATE_l3 = WheelSpd1_B.Sum1_f;

  /* Update for UnitDelay: '<S13>/d' */
  WheelSpd1_DW.d_DSTATE_g = WheelSpd1_B.Sum1_f;

  /* Update for UnitDelay: '<S13>/d1' */
  WheelSpd1_DW.d1_DSTATE_c = WheelSpd1_B.Sum1_g;

  /* Update for UnitDelay: '<S14>/d1' */
  WheelSpd1_DW.d1_DSTATE_m = WheelSpd1_B.Add3;

  /* Update for UnitDelay: '<S14>/d' */
  WheelSpd1_DW.d_DSTATE_h = WheelSpd1_B.Product1_l;

  /* Update for Delay: '<S15>/Delay1' */
  WheelSpd1_DW.Delay1_DSTATE_i = WheelSpd1_B.Product1_l;

  /* Update for Delay: '<S15>/Delay' */
  WheelSpd1_DW.Delay_DSTATE_g[0] = WheelSpd1_DW.Delay_DSTATE_g[1];
  WheelSpd1_DW.Delay_DSTATE_g[1] = WheelSpd1_B.Product1_l;

  /* Update for Delay: '<S15>/Delay2' */
  WheelSpd1_DW.Delay2_DSTATE_c = WheelSpd1_B.Product1_fm;

  /* Update for Delay: '<S15>/Delay3' */
  WheelSpd1_DW.Delay3_DSTATE_o[0] = WheelSpd1_DW.Delay3_DSTATE_o[1];
  WheelSpd1_DW.Delay3_DSTATE_o[1] = WheelSpd1_B.Product1_fm;

  /* Update absolute time for base rate */
  /* The "clockTick0" counts the number of times the code of this task has
   * been executed. The absolute time is the multiplication of "clockTick0"
   * and "Timing.stepSize0". Size of "clockTick0" ensures timer will not
   * overflow during the application lifespan selected.
   * Timer of this task consists of two 32 bit unsigned integers.
   * The two integers represent the low bits Timing.clockTick0 and the high bits
   * Timing.clockTickH0. When the low bit overflows to 0, the high bits increment.
   */
  if (!(++WheelSpd1_M->Timing.clockTick0)) {
    ++WheelSpd1_M->Timing.clockTickH0;
  }

  WheelSpd1_M->Timing.t[0] = WheelSpd1_M->Timing.clockTick0 *
    WheelSpd1_M->Timing.stepSize0 + WheelSpd1_M->Timing.clockTickH0 *
    WheelSpd1_M->Timing.stepSize0 * 4294967296.0;

  {
    /* Update absolute timer for sample time: [0.002s, 0.0s] */
    /* The "clockTick1" counts the number of times the code of this task has
     * been executed. The absolute time is the multiplication of "clockTick1"
     * and "Timing.stepSize1". Size of "clockTick1" ensures timer will not
     * overflow during the application lifespan selected.
     * Timer of this task consists of two 32 bit unsigned integers.
     * The two integers represent the low bits Timing.clockTick1 and the high bits
     * Timing.clockTickH1. When the low bit overflows to 0, the high bits increment.
     */
    if (!(++WheelSpd1_M->Timing.clockTick1)) {
      ++WheelSpd1_M->Timing.clockTickH1;
    }

    WheelSpd1_M->Timing.t[1] = WheelSpd1_M->Timing.clockTick1 *
      WheelSpd1_M->Timing.stepSize1 + WheelSpd1_M->Timing.clockTickH1 *
      WheelSpd1_M->Timing.stepSize1 * 4294967296.0;
  }
}

/* Model initialize function */
static void WheelSpd1_initialize(void)
{
  /* Start for Constant: '<S5>/Constant' */
  WheelSpd1_B.Ready = WheelSpd1_P.Constant_Value;

  /* Start for Constant: '<S5>/Constant1' */
  WheelSpd1_B.Gear = WheelSpd1_P.Constant1_Value;

  /* Start for Constant: '<S5>/Constant2' */
  WheelSpd1_B.BMS = WheelSpd1_P.Constant2_Value;

  /* Start for Constant: '<S5>/Constant3' */
  WheelSpd1_B.PosTQLim = WheelSpd1_P.Constant3_Value;

  /* Start for Constant: '<S5>/Constant4' */
  WheelSpd1_B.NegTQLim = WheelSpd1_P.Constant4_Value;

  /* Start for FromWorkspace: '<S10>/FromWs' */
  {
    static real_T pTimeValues0[] = { 0.0, 1.9, 1.9, 2.0, 2.0, 4.0, 4.0, 4.1, 4.1,
      5.9, 5.9, 6.0, 6.0, 8.0, 8.0, 8.1, 8.1, 10.0 } ;

    static real_T pDataValues0[] = { 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0,
      0.0, 0.0, -1.0, -1.0, -1.0, -1.0, 0.0, 0.0, 0.0 } ;

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

  /* Start for Iterator SubSystem: '<Root>/DAQ_In' */

  /* Start for S-Function (sg_IO613_setup_s): '<S1>/CAN Setup' */
  /* Level2 S-Function Block: '<S1>/CAN Setup' (sg_IO613_setup_s) */
  {
    SimStruct *rts = WheelSpd1_M->childSfunctions[0];
    sfcnStart(rts);
    if (ssGetErrorStatus(rts) != (NULL))
      return;
  }

  /* Start for S-Function (sg_IO61X_read_s): '<S1>/CAN Read1' */
  /* Level2 S-Function Block: '<S1>/CAN Read1' (sg_IO61X_read_s) */
  {
    SimStruct *rts = WheelSpd1_M->childSfunctions[1];
    sfcnStart(rts);
    if (ssGetErrorStatus(rts) != (NULL))
      return;
  }

  /* Start for S-Function (scanunpack): '<S1>/CAN Unpack2' */

  /*-----------S-Function Block: <S1>/CAN Unpack2 -----------------*/

  /* End of Start for SubSystem: '<Root>/DAQ_In' */

  /* Start for S-Function (sg_IO61X_write_s): '<S5>/CAN Write1' */
  /* Level2 S-Function Block: '<S5>/CAN Write1' (sg_IO61X_write_s) */
  {
    SimStruct *rts = WheelSpd1_M->childSfunctions[2];
    sfcnStart(rts);
    if (ssGetErrorStatus(rts) != (NULL))
      return;
  }

  /* InitializeConditions for UnitDelay: '<S9>/d1' */
  WheelSpd1_DW.d1_DSTATE = WheelSpd1_P.d1_InitialCondition;

  /* InitializeConditions for UnitDelay: '<S9>/d' */
  WheelSpd1_DW.d_DSTATE = WheelSpd1_P.d_InitialCondition;

  /* InitializeConditions for UnitDelay: '<S22>/d' */
  WheelSpd1_DW.d_DSTATE_a = WheelSpd1_P.d_InitialCondition_j;

  /* InitializeConditions for UnitDelay: '<S22>/d1' */
  WheelSpd1_DW.d1_DSTATE_l = WheelSpd1_P.d1_InitialCondition_p;

  /* InitializeConditions for UnitDelay: '<S23>/d' */
  WheelSpd1_DW.d_DSTATE_i = WheelSpd1_P.d_InitialCondition_b;

  /* InitializeConditions for UnitDelay: '<S23>/d1' */
  WheelSpd1_DW.d1_DSTATE_a = WheelSpd1_P.d1_InitialCondition_j;

  /* InitializeConditions for UnitDelay: '<S24>/d' */
  WheelSpd1_DW.d_DSTATE_ak = WheelSpd1_P.d_InitialCondition_f;

  /* InitializeConditions for UnitDelay: '<S24>/d1' */
  WheelSpd1_DW.d1_DSTATE_f = WheelSpd1_P.d1_InitialCondition_l;

  /* InitializeConditions for Delay: '<S26>/Delay1' */
  WheelSpd1_DW.Delay1_DSTATE = WheelSpd1_P.Delay1_InitialCondition;

  /* InitializeConditions for Delay: '<S26>/Delay2' */
  WheelSpd1_DW.Delay2_DSTATE = WheelSpd1_P.Delay2_InitialCondition;

  /* InitializeConditions for UnitDelay: '<S25>/d1' */
  WheelSpd1_DW.d1_DSTATE_b = WheelSpd1_P.d1_InitialCondition_e;

  /* InitializeConditions for UnitDelay: '<S25>/d' */
  WheelSpd1_DW.d_DSTATE_o = WheelSpd1_P.d_InitialCondition_o;

  /* InitializeConditions for UnitDelay: '<S21>/d1' */
  WheelSpd1_DW.d1_DSTATE_g = WheelSpd1_P.d1_InitialCondition_a;

  /* InitializeConditions for UnitDelay: '<S21>/d' */
  WheelSpd1_DW.d_DSTATE_ir = WheelSpd1_P.d_InitialCondition_g;

  /* InitializeConditions for UnitDelay: '<S20>/d1' */
  WheelSpd1_DW.d1_DSTATE_lw = WheelSpd1_P.d1_InitialCondition_g;

  /* InitializeConditions for UnitDelay: '<S20>/d' */
  WheelSpd1_DW.d_DSTATE_b = WheelSpd1_P.d_InitialCondition_l;

  /* InitializeConditions for Memory: '<S4>/Memory' */
  WheelSpd1_DW.Memory_PreviousInput = WheelSpd1_P.Memory_InitialCondition;

  /* InitializeConditions for UnitDelay: '<S11>/d' */
  WheelSpd1_DW.d_DSTATE_bw = WheelSpd1_P.d_InitialCondition_k;

  /* InitializeConditions for UnitDelay: '<S11>/d1' */
  WheelSpd1_DW.d1_DSTATE_gc = WheelSpd1_P.d1_InitialCondition_e1;

  /* InitializeConditions for UnitDelay: '<S12>/d' */
  WheelSpd1_DW.d_DSTATE_d = WheelSpd1_P.d_InitialCondition_be;

  /* InitializeConditions for UnitDelay: '<S12>/d1' */
  WheelSpd1_DW.d1_DSTATE_l3 = WheelSpd1_P.d1_InitialCondition_h;

  /* InitializeConditions for UnitDelay: '<S13>/d' */
  WheelSpd1_DW.d_DSTATE_g = WheelSpd1_P.d_InitialCondition_k0;

  /* InitializeConditions for UnitDelay: '<S13>/d1' */
  WheelSpd1_DW.d1_DSTATE_c = WheelSpd1_P.d1_InitialCondition_d;

  /* InitializeConditions for UnitDelay: '<S14>/d1' */
  WheelSpd1_DW.d1_DSTATE_m = WheelSpd1_P.d1_InitialCondition_c;

  /* InitializeConditions for UnitDelay: '<S14>/d' */
  WheelSpd1_DW.d_DSTATE_h = WheelSpd1_P.d_InitialCondition_kh;

  /* InitializeConditions for Delay: '<S15>/Delay1' */
  WheelSpd1_DW.Delay1_DSTATE_i = WheelSpd1_P.Delay1_InitialCondition_c;

  /* InitializeConditions for Delay: '<S15>/Delay2' */
  WheelSpd1_DW.Delay2_DSTATE_c = WheelSpd1_P.Delay2_InitialCondition_c;

  /* InitializeConditions for Delay: '<S26>/Delay' */
  WheelSpd1_DW.Delay_DSTATE[0] = WheelSpd1_P.Delay_InitialCondition;

  /* InitializeConditions for Delay: '<S26>/Delay3' */
  WheelSpd1_DW.Delay3_DSTATE[0] = WheelSpd1_P.Delay3_InitialCondition;

  /* InitializeConditions for Delay: '<S15>/Delay' */
  WheelSpd1_DW.Delay_DSTATE_g[0] = WheelSpd1_P.Delay_InitialCondition_c;

  /* InitializeConditions for Delay: '<S15>/Delay3' */
  WheelSpd1_DW.Delay3_DSTATE_o[0] = WheelSpd1_P.Delay3_InitialCondition_f;

  /* InitializeConditions for Delay: '<S26>/Delay' */
  WheelSpd1_DW.Delay_DSTATE[1] = WheelSpd1_P.Delay_InitialCondition;

  /* InitializeConditions for Delay: '<S26>/Delay3' */
  WheelSpd1_DW.Delay3_DSTATE[1] = WheelSpd1_P.Delay3_InitialCondition;

  /* InitializeConditions for Delay: '<S15>/Delay' */
  WheelSpd1_DW.Delay_DSTATE_g[1] = WheelSpd1_P.Delay_InitialCondition_c;

  /* InitializeConditions for Delay: '<S15>/Delay3' */
  WheelSpd1_DW.Delay3_DSTATE_o[1] = WheelSpd1_P.Delay3_InitialCondition_f;
}

/* Model terminate function */
static void WheelSpd1_terminate(void)
{
  /* Terminate for Iterator SubSystem: '<Root>/DAQ_In' */

  /* Terminate for S-Function (sg_IO613_setup_s): '<S1>/CAN Setup' */
  /* Level2 S-Function Block: '<S1>/CAN Setup' (sg_IO613_setup_s) */
  {
    SimStruct *rts = WheelSpd1_M->childSfunctions[0];
    sfcnTerminate(rts);
  }

  /* Terminate for S-Function (sg_IO61X_read_s): '<S1>/CAN Read1' */
  /* Level2 S-Function Block: '<S1>/CAN Read1' (sg_IO61X_read_s) */
  {
    SimStruct *rts = WheelSpd1_M->childSfunctions[1];
    sfcnTerminate(rts);
  }

  /* End of Terminate for SubSystem: '<Root>/DAQ_In' */

  /* Terminate for S-Function (sg_IO61X_write_s): '<S5>/CAN Write1' */
  /* Level2 S-Function Block: '<S5>/CAN Write1' (sg_IO61X_write_s) */
  {
    SimStruct *rts = WheelSpd1_M->childSfunctions[2];
    sfcnTerminate(rts);
  }
}

/*========================================================================*
 * Start of Classic call interface                                        *
 *========================================================================*/
void MdlOutputs(int_T tid)
{
  WheelSpd1_output();
  UNUSED_PARAMETER(tid);
}

void MdlUpdate(int_T tid)
{
  WheelSpd1_update();
  UNUSED_PARAMETER(tid);
}

void MdlInitializeSizes(void)
{
}

void MdlInitializeSampleTimes(void)
{
}

void MdlInitialize(void)
{
}

void MdlStart(void)
{
  WheelSpd1_initialize();
}

void MdlTerminate(void)
{
  WheelSpd1_terminate();
}

/* Registration function */
RT_MODEL_WheelSpd1_T *WheelSpd1(void)
{
  /* Registration code */

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

  /* initialize real-time model */
  (void) memset((void *)WheelSpd1_M, 0,
                sizeof(RT_MODEL_WheelSpd1_T));

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

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

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

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

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

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

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

  rtmSetTFinal(WheelSpd1_M, -1);
  WheelSpd1_M->Timing.stepSize0 = 0.002;
  WheelSpd1_M->Timing.stepSize1 = 0.002;

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

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

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

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

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

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

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

      static RTWPreprocessingFcnPtr rt_LoggingStatePreprocessingFcnPtrs[] = {
        (NULL),
        (NULL),
        (NULL),
        (NULL),
        (NULL),
        (NULL),
        (NULL),
        (NULL),
        (NULL),
        (NULL),
        (NULL),
        (NULL),
        (NULL),
        (NULL),
        (NULL),
        (NULL),
        (NULL),
        (NULL),
        (NULL),
        (NULL),
        (NULL),
        (NULL),
        (NULL),
        (NULL),
        (NULL),
        (NULL),
        (NULL),
        (NULL),
        (NULL),
        (NULL)
      };

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

      static const char_T *rt_LoggedStateBlockNames[] = {
        "WheelSpd1/Mon_Cont/LPFM/d1",
        "WheelSpd1/Mon_Cont/LPFM/d",
        "WheelSpd1/Mon_Cont/FF+PID Controller/FF/Dot/d",
        "WheelSpd1/Mon_Cont/FF+PID Controller/FF/Dot/d1",
        "WheelSpd1/Mon_Cont/FF+PID Controller/FF/Dot2/d",
        "WheelSpd1/Mon_Cont/FF+PID Controller/FF/Dot2/d1",
        "WheelSpd1/Mon_Cont/FF+PID Controller/FF/Dot3/d",
        "WheelSpd1/Mon_Cont/FF+PID Controller/FF/Dot3/d1",
        "WheelSpd1/Mon_Cont/FF+PID Controller/FF/Second order\nLPF/Delay1",
        "WheelSpd1/Mon_Cont/FF+PID Controller/FF/Second order\nLPF/Delay",
        "WheelSpd1/Mon_Cont/FF+PID Controller/FF/Second order\nLPF/Delay2",
        "WheelSpd1/Mon_Cont/FF+PID Controller/FF/Second order\nLPF/Delay3",
        "WheelSpd1/Mon_Cont/FF+PID Controller/FF/LPFM/d1",
        "WheelSpd1/Mon_Cont/FF+PID Controller/FF/LPFM/d",
        "WheelSpd1/Mon_Cont/FF+PID Controller/FB/PI/Integrator1/d1",
        "WheelSpd1/Mon_Cont/FF+PID Controller/FB/PI/Integrator1/d",
        "WheelSpd1/Mon_Cont/FF+PID Controller/FB/PI/HPF/d1",
        "WheelSpd1/Mon_Cont/FF+PID Controller/FB/PI/HPF/d",
        "WheelSpd1/Mon_Cont/DOB/Dot3/d",
        "WheelSpd1/Mon_Cont/DOB/Dot3/d1",
        "WheelSpd1/Mon_Cont/DOB/Dot4/d",
        "WheelSpd1/Mon_Cont/DOB/Dot4/d1",
        "WheelSpd1/Mon_Cont/DOB/Dot5/d",
        "WheelSpd1/Mon_Cont/DOB/Dot5/d1",
        "WheelSpd1/Mon_Cont/DOB/LPFM/d1",
        "WheelSpd1/Mon_Cont/DOB/LPFM/d",
        "WheelSpd1/Mon_Cont/DOB/Second order\nLPF/Delay1",
        "WheelSpd1/Mon_Cont/DOB/Second order\nLPF/Delay",
        "WheelSpd1/Mon_Cont/DOB/Second order\nLPF/Delay2",
        "WheelSpd1/Mon_Cont/DOB/Second order\nLPF/Delay3"
      };

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

      static boolean_T rt_LoggedStateCrossMdlRef[] = {
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        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 },

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

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

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

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

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

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

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

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

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

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

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

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

        { rt_LoggedStateBlockNames },

        { rt_LoggedStateNames },
        rt_LoggedStateCrossMdlRef,
        rt_RTWLogDataTypeConvert
      };

      static void * rt_LoggedStateSignalPtrs[30];
      rtliSetLogXSignalPtrs(WheelSpd1_M->rtwLogInfo, (LogSignalPtrsType)
                            rt_LoggedStateSignalPtrs);
      rtliSetLogXSignalInfo(WheelSpd1_M->rtwLogInfo, &rt_LoggedStateSignalInfo);
      rt_LoggedStateSignalPtrs[0] = (void*)&WheelSpd1_DW.d1_DSTATE;
      rt_LoggedStateSignalPtrs[1] = (void*)&WheelSpd1_DW.d_DSTATE;
      rt_LoggedStateSignalPtrs[2] = (void*)&WheelSpd1_DW.d_DSTATE_a;
      rt_LoggedStateSignalPtrs[3] = (void*)&WheelSpd1_DW.d1_DSTATE_l;
      rt_LoggedStateSignalPtrs[4] = (void*)&WheelSpd1_DW.d_DSTATE_i;
      rt_LoggedStateSignalPtrs[5] = (void*)&WheelSpd1_DW.d1_DSTATE_a;
      rt_LoggedStateSignalPtrs[6] = (void*)&WheelSpd1_DW.d_DSTATE_ak;
      rt_LoggedStateSignalPtrs[7] = (void*)&WheelSpd1_DW.d1_DSTATE_f;
      rt_LoggedStateSignalPtrs[8] = (void*)&WheelSpd1_DW.Delay1_DSTATE;
      rt_LoggedStateSignalPtrs[9] = (void*)WheelSpd1_DW.Delay_DSTATE;
      rt_LoggedStateSignalPtrs[10] = (void*)&WheelSpd1_DW.Delay2_DSTATE;
      rt_LoggedStateSignalPtrs[11] = (void*)WheelSpd1_DW.Delay3_DSTATE;
      rt_LoggedStateSignalPtrs[12] = (void*)&WheelSpd1_DW.d1_DSTATE_b;
      rt_LoggedStateSignalPtrs[13] = (void*)&WheelSpd1_DW.d_DSTATE_o;
      rt_LoggedStateSignalPtrs[14] = (void*)&WheelSpd1_DW.d1_DSTATE_g;
      rt_LoggedStateSignalPtrs[15] = (void*)&WheelSpd1_DW.d_DSTATE_ir;
      rt_LoggedStateSignalPtrs[16] = (void*)&WheelSpd1_DW.d1_DSTATE_lw;
      rt_LoggedStateSignalPtrs[17] = (void*)&WheelSpd1_DW.d_DSTATE_b;
      rt_LoggedStateSignalPtrs[18] = (void*)&WheelSpd1_DW.d_DSTATE_bw;
      rt_LoggedStateSignalPtrs[19] = (void*)&WheelSpd1_DW.d1_DSTATE_gc;
      rt_LoggedStateSignalPtrs[20] = (void*)&WheelSpd1_DW.d_DSTATE_d;
      rt_LoggedStateSignalPtrs[21] = (void*)&WheelSpd1_DW.d1_DSTATE_l3;
      rt_LoggedStateSignalPtrs[22] = (void*)&WheelSpd1_DW.d_DSTATE_g;
      rt_LoggedStateSignalPtrs[23] = (void*)&WheelSpd1_DW.d1_DSTATE_c;
      rt_LoggedStateSignalPtrs[24] = (void*)&WheelSpd1_DW.d1_DSTATE_m;
      rt_LoggedStateSignalPtrs[25] = (void*)&WheelSpd1_DW.d_DSTATE_h;
      rt_LoggedStateSignalPtrs[26] = (void*)&WheelSpd1_DW.Delay1_DSTATE_i;
      rt_LoggedStateSignalPtrs[27] = (void*)WheelSpd1_DW.Delay_DSTATE_g;
      rt_LoggedStateSignalPtrs[28] = (void*)&WheelSpd1_DW.Delay2_DSTATE_c;
      rt_LoggedStateSignalPtrs[29] = (void*)WheelSpd1_DW.Delay3_DSTATE_o;
    }

    rtliSetLogT(WheelSpd1_M->rtwLogInfo, "tout");
    rtliSetLogX(WheelSpd1_M->rtwLogInfo, "xout");
    rtliSetLogXFinal(WheelSpd1_M->rtwLogInfo, "");
    rtliSetLogVarNameModifier(WheelSpd1_M->rtwLogInfo, "rt_");
    rtliSetLogFormat(WheelSpd1_M->rtwLogInfo, 2);
    rtliSetLogMaxRows(WheelSpd1_M->rtwLogInfo, 0);
    rtliSetLogDecimation(WheelSpd1_M->rtwLogInfo, 1);
    rtliSetLogY(WheelSpd1_M->rtwLogInfo, "");
    rtliSetLogYSignalInfo(WheelSpd1_M->rtwLogInfo, (NULL));
    rtliSetLogYSignalPtrs(WheelSpd1_M->rtwLogInfo, (NULL));
  }

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

  /* block I/O */
  WheelSpd1_M->blockIO = ((void *) &WheelSpd1_B);
  (void) memset(((void *) &WheelSpd1_B), 0,
                sizeof(B_WheelSpd1_T));

  {
    WheelSpd1_B.CANPack = CAN_DATATYPE_GROUND;
    WheelSpd1_B.CANRead1_o2 = CAN_DATATYPE_GROUND;
    WheelSpd1_B.ContMode = 0.0;
    WheelSpd1_B.Ready = 0.0;
    WheelSpd1_B.Gear = 0.0;
    WheelSpd1_B.BMS = 0.0;
    WheelSpd1_B.PosTQLim = 0.0;
    WheelSpd1_B.NegTQLim = 0.0;
    WheelSpd1_B.Clock1 = 0.0;
    WheelSpd1_B.Product = 0.0;
    WheelSpd1_B.Gain = 0.0;
    WheelSpd1_B.FromWs = 0.0;
    WheelSpd1_B.InputSine = 0.0;
    WheelSpd1_B.TargetSpd = 0.0;
    WheelSpd1_B.d1 = 0.0;
    WheelSpd1_B.Sum3 = 0.0;
    WheelSpd1_B.gain = 0.0;
    WheelSpd1_B.gain2 = 0.0;
    WheelSpd1_B.Product2 = 0.0;
    WheelSpd1_B.gain1 = 0.0;
    WheelSpd1_B.Sum1 = 0.0;
    WheelSpd1_B.d = 0.0;
    WheelSpd1_B.Product11 = 0.0;
    WheelSpd1_B.Sum2 = 0.0;
    WheelSpd1_B.Sum4 = 0.0;
    WheelSpd1_B.Product1 = 0.0;
    WheelSpd1_B.Product2_c = 0.0;
    WheelSpd1_B.d_a = 0.0;
    WheelSpd1_B.Sum2_h = 0.0;
    WheelSpd1_B.gain_m = 0.0;
    WheelSpd1_B.d1_d = 0.0;
    WheelSpd1_B.Sum1_n = 0.0;
    WheelSpd1_B.Product1_f = 0.0;
    WheelSpd1_B.d_b = 0.0;
    WheelSpd1_B.Sum2_g = 0.0;
    WheelSpd1_B.gain_o = 0.0;
    WheelSpd1_B.d1_c = 0.0;
    WheelSpd1_B.Sum1_p = 0.0;
    WheelSpd1_B.Product_n = 0.0;
    WheelSpd1_B.d_bp = 0.0;
    WheelSpd1_B.Sum2_k = 0.0;
    WheelSpd1_B.gain_d = 0.0;
    WheelSpd1_B.d1_f = 0.0;
    WheelSpd1_B.Sum1_k = 0.0;
    WheelSpd1_B.Add5 = 0.0;
    WheelSpd1_B.Gain_l = 0.0;
    WheelSpd1_B.Delay1 = 0.0;
    WheelSpd1_B.gain1_g = 0.0;
    WheelSpd1_B.Delay = 0.0;
    WheelSpd1_B.Sum3_d = 0.0;
    WheelSpd1_B.gain2_h = 0.0;
    WheelSpd1_B.Product2_e = 0.0;
    WheelSpd1_B.xnxn1xn2 = 0.0;
    WheelSpd1_B.gain3 = 0.0;
    WheelSpd1_B.Sum4_c = 0.0;
    WheelSpd1_B.Delay2 = 0.0;
    WheelSpd1_B.yn1 = 0.0;
    WheelSpd1_B.Sum1_a = 0.0;
    WheelSpd1_B.Product3 = 0.0;
    WheelSpd1_B.gain4 = 0.0;
    WheelSpd1_B.Product4 = 0.0;
    WheelSpd1_B.Sum5 = 0.0;
    WheelSpd1_B.Delay3 = 0.0;
    WheelSpd1_B.yn2 = 0.0;
    WheelSpd1_B.Sum2_c = 0.0;
    WheelSpd1_B.Sum6 = 0.0;
    WheelSpd1_B.Product1_n = 0.0;
    WheelSpd1_B.d1_b = 0.0;
    WheelSpd1_B.Sum3_c = 0.0;
    WheelSpd1_B.gain_e = 0.0;
    WheelSpd1_B.gain2_k = 0.0;
    WheelSpd1_B.Product2_p = 0.0;
    WheelSpd1_B.gain1_gt = 0.0;
    WheelSpd1_B.Sum1_px = 0.0;
    WheelSpd1_B.d_i = 0.0;
    WheelSpd1_B.Product11_e = 0.0;
    WheelSpd1_B.Sum2_kk = 0.0;
    WheelSpd1_B.Sum4_l = 0.0;
    WheelSpd1_B.Product1_i = 0.0;
    WheelSpd1_B.FFGain = 0.0;
    WheelSpd1_B.Error = 0.0;
    WheelSpd1_B.Gain_a = 0.0;
    WheelSpd1_B.Kp = 0.0;
    WheelSpd1_B.gain_mk = 0.0;
    WheelSpd1_B.Kp_b = 0.0;
    WheelSpd1_B.Ki = 0.0;
    WheelSpd1_B.gain2_n = 0.0;
    WheelSpd1_B.tau = 0.0;
    WheelSpd1_B.utau = 0.0;
    WheelSpd1_B.d1_cf = 0.0;
    WheelSpd1_B.Sum1_d = 0.0;
    WheelSpd1_B.gain_ds = 0.0;
    WheelSpd1_B.d_c = 0.0;
    WheelSpd1_B.Sum2_l = 0.0;
    WheelSpd1_B.d1_p = 0.0;
    WheelSpd1_B.Sum3_g = 0.0;
    WheelSpd1_B.Product3_e = 0.0;
    WheelSpd1_B.Sum1_i = 0.0;
    WheelSpd1_B.d_j = 0.0;
    WheelSpd1_B.Product11_n = 0.0;
    WheelSpd1_B.Sum2_j = 0.0;
    WheelSpd1_B.Sum4_a = 0.0;
    WheelSpd1_B.Product1_a = 0.0;
    WheelSpd1_B.MultiportSwitch1 = 0.0;
    WheelSpd1_B.FBOut = 0.0;
    WheelSpd1_B.Add = 0.0;
    WheelSpd1_B.Memory = 0.0;
    WheelSpd1_B.Product4_o = 0.0;
    WheelSpd1_B.d_in = 0.0;
    WheelSpd1_B.Sum2_hn = 0.0;
    WheelSpd1_B.gain_j = 0.0;
    WheelSpd1_B.d1_e = 0.0;
    WheelSpd1_B.Sum1_m = 0.0;
    WheelSpd1_B.Product3_f = 0.0;
    WheelSpd1_B.d_n = 0.0;
    WheelSpd1_B.Sum2_kl = 0.0;
    WheelSpd1_B.gain_g = 0.0;
    WheelSpd1_B.d1_bp = 0.0;
    WheelSpd1_B.Sum1_f = 0.0;
    WheelSpd1_B.Product2_l = 0.0;
    WheelSpd1_B.d_cu = 0.0;
    WheelSpd1_B.Sum2_a = 0.0;
    WheelSpd1_B.gain_gz = 0.0;
    WheelSpd1_B.d1_di = 0.0;
    WheelSpd1_B.Sum1_g = 0.0;
    WheelSpd1_B.Add2 = 0.0;
    WheelSpd1_B.Gain_c = 0.0;
    WheelSpd1_B.Add3 = 0.0;
    WheelSpd1_B.d1_n = 0.0;
    WheelSpd1_B.Sum3_f = 0.0;
    WheelSpd1_B.gain_o3 = 0.0;
    WheelSpd1_B.gain2_m = 0.0;
    WheelSpd1_B.Product2_h = 0.0;
    WheelSpd1_B.gain1_k = 0.0;
    WheelSpd1_B.Sum1_e = 0.0;
    WheelSpd1_B.d_p = 0.0;
    WheelSpd1_B.Product11_i = 0.0;
    WheelSpd1_B.Sum2_b = 0.0;
    WheelSpd1_B.Sum4_k = 0.0;
    WheelSpd1_B.Product1_l = 0.0;
    WheelSpd1_B.Delay1_n = 0.0;
    WheelSpd1_B.gain1_f = 0.0;
    WheelSpd1_B.Delay_a = 0.0;
    WheelSpd1_B.Sum3_a = 0.0;
    WheelSpd1_B.gain2_d = 0.0;
    WheelSpd1_B.Product2_m = 0.0;
    WheelSpd1_B.xnxn1xn2_a = 0.0;
    WheelSpd1_B.gain3_b = 0.0;
    WheelSpd1_B.Sum4_kn = 0.0;
    WheelSpd1_B.Delay2_n = 0.0;
    WheelSpd1_B.yn1_m = 0.0;
    WheelSpd1_B.Sum1_ek = 0.0;
    WheelSpd1_B.Product3_i = 0.0;
    WheelSpd1_B.gain4_g = 0.0;
    WheelSpd1_B.Product4_i = 0.0;
    WheelSpd1_B.Sum5_f = 0.0;
    WheelSpd1_B.Delay3_i = 0.0;
    WheelSpd1_B.yn2_g = 0.0;
    WheelSpd1_B.Sum2_m = 0.0;
    WheelSpd1_B.Sum6_g = 0.0;
    WheelSpd1_B.Product1_fm = 0.0;
    WheelSpd1_B.Product_d = 0.0;
    WheelSpd1_B.Subtract2 = 0.0;
    WheelSpd1_B.ControlFlag = 0.0;
    WheelSpd1_B.ControlOutput = 0.0;
    WheelSpd1_B.Constant1 = 0.0;
    WheelSpd1_B.Constant16 = 0.0;
    WheelSpd1_B.Constant17 = 0.0;
    WheelSpd1_B.Constant2 = 0.0;
    WheelSpd1_B.Product_k = 0.0;
    WheelSpd1_B.Divide2 = 0.0;
    WheelSpd1_B.Divide1 = 0.0;
    WheelSpd1_B.Add_k = 0.0;
    WheelSpd1_B.Product1_lf = 0.0;
    WheelSpd1_B.Sum = 0.0;
    WheelSpd1_B.Product2_g = 0.0;
    WheelSpd1_B.Output = 0.0;
    WheelSpd1_B.Gain1 = 0.0;
    WheelSpd1_B.Gain_d = 0.0;
    WheelSpd1_B.RPM = 0.0;
    WheelSpd1_B.TQ = 0.0;
  }

  /* parameters */
  WheelSpd1_M->defaultParam = ((real_T *)&WheelSpd1_P);

  /* states (dwork) */
  WheelSpd1_M->dwork = ((void *) &WheelSpd1_DW);
  (void) memset((void *)&WheelSpd1_DW, 0,
                sizeof(DW_WheelSpd1_T));
  WheelSpd1_DW.d1_DSTATE = 0.0;
  WheelSpd1_DW.d_DSTATE = 0.0;
  WheelSpd1_DW.d_DSTATE_a = 0.0;
  WheelSpd1_DW.d1_DSTATE_l = 0.0;
  WheelSpd1_DW.d_DSTATE_i = 0.0;
  WheelSpd1_DW.d1_DSTATE_a = 0.0;
  WheelSpd1_DW.d_DSTATE_ak = 0.0;
  WheelSpd1_DW.d1_DSTATE_f = 0.0;
  WheelSpd1_DW.Delay1_DSTATE = 0.0;
  WheelSpd1_DW.Delay_DSTATE[0] = 0.0;
  WheelSpd1_DW.Delay_DSTATE[1] = 0.0;
  WheelSpd1_DW.Delay2_DSTATE = 0.0;
  WheelSpd1_DW.Delay3_DSTATE[0] = 0.0;
  WheelSpd1_DW.Delay3_DSTATE[1] = 0.0;
  WheelSpd1_DW.d1_DSTATE_b = 0.0;
  WheelSpd1_DW.d_DSTATE_o = 0.0;
  WheelSpd1_DW.d1_DSTATE_g = 0.0;
  WheelSpd1_DW.d_DSTATE_ir = 0.0;
  WheelSpd1_DW.d1_DSTATE_lw = 0.0;
  WheelSpd1_DW.d_DSTATE_b = 0.0;
  WheelSpd1_DW.d_DSTATE_bw = 0.0;
  WheelSpd1_DW.d1_DSTATE_gc = 0.0;
  WheelSpd1_DW.d_DSTATE_d = 0.0;
  WheelSpd1_DW.d1_DSTATE_l3 = 0.0;
  WheelSpd1_DW.d_DSTATE_g = 0.0;
  WheelSpd1_DW.d1_DSTATE_c = 0.0;
  WheelSpd1_DW.d1_DSTATE_m = 0.0;
  WheelSpd1_DW.d_DSTATE_h = 0.0;
  WheelSpd1_DW.Delay1_DSTATE_i = 0.0;
  WheelSpd1_DW.Delay_DSTATE_g[0] = 0.0;
  WheelSpd1_DW.Delay_DSTATE_g[1] = 0.0;
  WheelSpd1_DW.Delay2_DSTATE_c = 0.0;
  WheelSpd1_DW.Delay3_DSTATE_o[0] = 0.0;
  WheelSpd1_DW.Delay3_DSTATE_o[1] = 0.0;
  WheelSpd1_DW.Memory_PreviousInput = 0.0;

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

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

  WheelSpd1_M->Sizes.numSFcns = (3);

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

    /* Level2 S-Function Block: WheelSpd1/<S1>/CAN Setup (sg_IO613_setup_s) */
    {
      SimStruct *rts = WheelSpd1_M->childSfunctions[0];

      /* timing info */
      time_T *sfcnPeriod = WheelSpd1_M->NonInlinedSFcns.Sfcn0.sfcnPeriod;
      time_T *sfcnOffset = WheelSpd1_M->NonInlinedSFcns.Sfcn0.sfcnOffset;
      int_T *sfcnTsMap = WheelSpd1_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);

      {
        ssSetBlkInfo2Ptr(rts, &WheelSpd1_M->NonInlinedSFcns.blkInfo2[0]);
      }

      _ssSetBlkInfo2PortInfo2Ptr(rts,
        &WheelSpd1_M->NonInlinedSFcns.inputOutputPortInfo2[0]);

      /* Set up the mdlInfo pointer */
      ssSetRTWSfcnInfo(rts, WheelSpd1_M->sfcnInfo);

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

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

      /* Allocate memory of model methods 4 */
      {
        ssSetModelMethods4(rts, &WheelSpd1_M->NonInlinedSFcns.methods4[0]);
      }

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

      /* path info */
      ssSetModelName(rts, "CAN Setup");
      ssSetPath(rts, "WheelSpd1/DAQ_In/CAN Setup");
      ssSetRTModel(rts,WheelSpd1_M);
      ssSetParentSS(rts, (NULL));
      ssSetRootSS(rts, rts);
      ssSetVersion(rts, SIMSTRUCT_VERSION_LEVEL2);

      /* parameters */
      {
        mxArray **sfcnParams = (mxArray **)
          &WheelSpd1_M->NonInlinedSFcns.Sfcn0.params;
        ssSetSFcnParamsCount(rts, 24);
        ssSetSFcnParamsPtr(rts, &sfcnParams[0]);
        ssSetSFcnParam(rts, 0, (mxArray*)WheelSpd1_P.CANSetup_P1_Size);
        ssSetSFcnParam(rts, 1, (mxArray*)WheelSpd1_P.CANSetup_P2_Size);
        ssSetSFcnParam(rts, 2, (mxArray*)WheelSpd1_P.CANSetup_P3_Size);
        ssSetSFcnParam(rts, 3, (mxArray*)WheelSpd1_P.CANSetup_P4_Size);
        ssSetSFcnParam(rts, 4, (mxArray*)WheelSpd1_P.CANSetup_P5_Size);
        ssSetSFcnParam(rts, 5, (mxArray*)WheelSpd1_P.CANSetup_P6_Size);
        ssSetSFcnParam(rts, 6, (mxArray*)WheelSpd1_P.CANSetup_P7_Size);
        ssSetSFcnParam(rts, 7, (mxArray*)WheelSpd1_P.CANSetup_P8_Size);
        ssSetSFcnParam(rts, 8, (mxArray*)WheelSpd1_P.CANSetup_P9_Size);
        ssSetSFcnParam(rts, 9, (mxArray*)WheelSpd1_P.CANSetup_P10_Size);
        ssSetSFcnParam(rts, 10, (mxArray*)WheelSpd1_P.CANSetup_P11_Size);
        ssSetSFcnParam(rts, 11, (mxArray*)WheelSpd1_P.CANSetup_P12_Size);
        ssSetSFcnParam(rts, 12, (mxArray*)WheelSpd1_P.CANSetup_P13_Size);
        ssSetSFcnParam(rts, 13, (mxArray*)WheelSpd1_P.CANSetup_P14_Size);
        ssSetSFcnParam(rts, 14, (mxArray*)WheelSpd1_P.CANSetup_P15_Size);
        ssSetSFcnParam(rts, 15, (mxArray*)WheelSpd1_P.CANSetup_P16_Size);
        ssSetSFcnParam(rts, 16, (mxArray*)WheelSpd1_P.CANSetup_P17_Size);
        ssSetSFcnParam(rts, 17, (mxArray*)WheelSpd1_P.CANSetup_P18_Size);
        ssSetSFcnParam(rts, 18, (mxArray*)WheelSpd1_P.CANSetup_P19_Size);
        ssSetSFcnParam(rts, 19, (mxArray*)WheelSpd1_P.CANSetup_P20_Size);
        ssSetSFcnParam(rts, 20, (mxArray*)WheelSpd1_P.CANSetup_P21_Size);
        ssSetSFcnParam(rts, 21, (mxArray*)WheelSpd1_P.CANSetup_P22_Size);
        ssSetSFcnParam(rts, 22, (mxArray*)WheelSpd1_P.CANSetup_P23_Size);
        ssSetSFcnParam(rts, 23, (mxArray*)WheelSpd1_P.CANSetup_P24_Size);
      }

      /* work vectors */
      ssSetIWork(rts, (int_T *) &WheelSpd1_DW.CANSetup_IWORK);

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

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

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

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

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

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

    /* Level2 S-Function Block: WheelSpd1/<S1>/CAN Read1 (sg_IO61X_read_s) */
    {
      SimStruct *rts = WheelSpd1_M->childSfunctions[1];

      /* timing info */
      time_T *sfcnPeriod = WheelSpd1_M->NonInlinedSFcns.Sfcn1.sfcnPeriod;
      time_T *sfcnOffset = WheelSpd1_M->NonInlinedSFcns.Sfcn1.sfcnOffset;
      int_T *sfcnTsMap = WheelSpd1_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);

      {
        ssSetBlkInfo2Ptr(rts, &WheelSpd1_M->NonInlinedSFcns.blkInfo2[1]);
      }

      _ssSetBlkInfo2PortInfo2Ptr(rts,
        &WheelSpd1_M->NonInlinedSFcns.inputOutputPortInfo2[1]);

      /* Set up the mdlInfo pointer */
      ssSetRTWSfcnInfo(rts, WheelSpd1_M->sfcnInfo);

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

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

      /* Allocate memory of model methods 4 */
      {
        ssSetModelMethods4(rts, &WheelSpd1_M->NonInlinedSFcns.methods4[1]);
      }

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

      /* outputs */
      {
        ssSetPortInfoForOutputs(rts,
          &WheelSpd1_M->NonInlinedSFcns.Sfcn1.outputPortInfo[0]);
        _ssSetNumOutputPorts(rts, 2);
        _ssSetPortInfo2ForOutputUnits(rts,
          &WheelSpd1_M->NonInlinedSFcns.Sfcn1.outputPortUnits[0]);
        ssSetOutputPortUnit(rts, 0, 0);
        ssSetOutputPortUnit(rts, 1, 0);
        _ssSetPortInfo2ForOutputCoSimAttribute(rts,
          &WheelSpd1_M->NonInlinedSFcns.Sfcn1.outputPortCoSimAttribute[0]);
        ssSetOutputPortIsContinuousQuantity(rts, 0, 0);
        ssSetOutputPortIsContinuousQuantity(rts, 1, 0);

        /* port 0 */
        {
          _ssSetOutputPortNumDimensions(rts, 0, 1);
          ssSetOutputPortWidth(rts, 0, 1);
          ssSetOutputPortSignal(rts, 0, ((boolean_T *) &WheelSpd1_B.CANRead1_o1));
        }

        /* port 1 */
        {
          _ssSetOutputPortNumDimensions(rts, 1, 1);
          ssSetOutputPortWidth(rts, 1, 1);
          ssSetOutputPortSignal(rts, 1, ((CAN_DATATYPE *)
            &WheelSpd1_B.CANRead1_o2));
        }
      }

      /* path info */
      ssSetModelName(rts, "CAN Read1");
      ssSetPath(rts, "WheelSpd1/DAQ_In/CAN Read1");
      ssSetRTModel(rts,WheelSpd1_M);
      ssSetParentSS(rts, (NULL));
      ssSetRootSS(rts, rts);
      ssSetVersion(rts, SIMSTRUCT_VERSION_LEVEL2);

      /* parameters */
      {
        mxArray **sfcnParams = (mxArray **)
          &WheelSpd1_M->NonInlinedSFcns.Sfcn1.params;
        ssSetSFcnParamsCount(rts, 6);
        ssSetSFcnParamsPtr(rts, &sfcnParams[0]);
        ssSetSFcnParam(rts, 0, (mxArray*)WheelSpd1_P.CANRead1_P1_Size);
        ssSetSFcnParam(rts, 1, (mxArray*)WheelSpd1_P.CANRead1_P2_Size);
        ssSetSFcnParam(rts, 2, (mxArray*)WheelSpd1_P.CANRead1_P3_Size);
        ssSetSFcnParam(rts, 3, (mxArray*)WheelSpd1_P.CANRead1_P4_Size);
        ssSetSFcnParam(rts, 4, (mxArray*)WheelSpd1_P.CANRead1_P5_Size);
        ssSetSFcnParam(rts, 5, (mxArray*)WheelSpd1_P.CANRead1_P6_Size);
      }

      /* work vectors */
      ssSetIWork(rts, (int_T *) &WheelSpd1_DW.CANRead1_IWORK);

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

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

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

      /* adjust sample time */
      ssSetSampleTime(rts, 0, 0.002);
      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);
      _ssSetOutputPortConnected(rts, 1, 1);
      _ssSetOutputPortBeingMerged(rts, 0, 0);
      _ssSetOutputPortBeingMerged(rts, 1, 0);

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

    /* Level2 S-Function Block: WheelSpd1/<S5>/CAN Write1 (sg_IO61X_write_s) */
    {
      SimStruct *rts = WheelSpd1_M->childSfunctions[2];

      /* timing info */
      time_T *sfcnPeriod = WheelSpd1_M->NonInlinedSFcns.Sfcn2.sfcnPeriod;
      time_T *sfcnOffset = WheelSpd1_M->NonInlinedSFcns.Sfcn2.sfcnOffset;
      int_T *sfcnTsMap = WheelSpd1_M->NonInlinedSFcns.Sfcn2.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);

      {
        ssSetBlkInfo2Ptr(rts, &WheelSpd1_M->NonInlinedSFcns.blkInfo2[2]);
      }

      _ssSetBlkInfo2PortInfo2Ptr(rts,
        &WheelSpd1_M->NonInlinedSFcns.inputOutputPortInfo2[2]);

      /* Set up the mdlInfo pointer */
      ssSetRTWSfcnInfo(rts, WheelSpd1_M->sfcnInfo);

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

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

      /* Allocate memory of model methods 4 */
      {
        ssSetModelMethods4(rts, &WheelSpd1_M->NonInlinedSFcns.methods4[2]);
      }

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

      /* inputs */
      {
        _ssSetNumInputPorts(rts, 1);
        ssSetPortInfoForInputs(rts,
          &WheelSpd1_M->NonInlinedSFcns.Sfcn2.inputPortInfo[0]);
        _ssSetPortInfo2ForInputUnits(rts,
          &WheelSpd1_M->NonInlinedSFcns.Sfcn2.inputPortUnits[0]);
        ssSetInputPortUnit(rts, 0, 0);
        _ssSetPortInfo2ForInputCoSimAttribute(rts,
          &WheelSpd1_M->NonInlinedSFcns.Sfcn2.inputPortCoSimAttribute[0]);
        ssSetInputPortIsContinuousQuantity(rts, 0, 0);

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

      /* path info */
      ssSetModelName(rts, "CAN Write1");
      ssSetPath(rts, "WheelSpd1/DAQ_Out/CANBoard/CAN Write1");
      ssSetRTModel(rts,WheelSpd1_M);
      ssSetParentSS(rts, (NULL));
      ssSetRootSS(rts, rts);
      ssSetVersion(rts, SIMSTRUCT_VERSION_LEVEL2);

      /* parameters */
      {
        mxArray **sfcnParams = (mxArray **)
          &WheelSpd1_M->NonInlinedSFcns.Sfcn2.params;
        ssSetSFcnParamsCount(rts, 7);
        ssSetSFcnParamsPtr(rts, &sfcnParams[0]);
        ssSetSFcnParam(rts, 0, (mxArray*)WheelSpd1_P.CANWrite1_P1_Size);
        ssSetSFcnParam(rts, 1, (mxArray*)WheelSpd1_P.CANWrite1_P2_Size);
        ssSetSFcnParam(rts, 2, (mxArray*)WheelSpd1_P.CANWrite1_P3_Size);
        ssSetSFcnParam(rts, 3, (mxArray*)WheelSpd1_P.CANWrite1_P4_Size);
        ssSetSFcnParam(rts, 4, (mxArray*)WheelSpd1_P.CANWrite1_P5_Size);
        ssSetSFcnParam(rts, 5, (mxArray*)WheelSpd1_P.CANWrite1_P6_Size);
        ssSetSFcnParam(rts, 6, (mxArray*)WheelSpd1_P.CANWrite1_P7_Size);
      }

      /* work vectors */
      ssSetIWork(rts, (int_T *) &WheelSpd1_DW.CANWrite1_IWORK);
      ssSetPWork(rts, (void **) &WheelSpd1_DW.CANWrite1_PWORK);

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

        /* IWORK */
        ssSetDWorkWidth(rts, 0, 1);
        ssSetDWorkDataType(rts, 0,SS_INTEGER);
        ssSetDWorkComplexSignal(rts, 0, 0);
        ssSetDWork(rts, 0, &WheelSpd1_DW.CANWrite1_IWORK);

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

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

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

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

/*========================================================================*
 * End of Classic call interface                                          *
 *========================================================================*/
