/*
 * wt_sablona_proud.c
 *
 * Code generation for model "wt_sablona_proud".
 *
 * Model version              : 1.38
 * Simulink Coder version : 8.3 (R2012b) 20-Jul-2012
 * C source code generated on : Tue Apr 28 18:00:57 2015
 *
 * Target selection: rtwin.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 "wt_sablona_proud.h"
#include "wt_sablona_proud_private.h"
#include "wt_sablona_proud_dt.h"

/* options for Real-Time Windows Target board 0 */
static double RTWinBoardOptions0[] = {
  1.0,
};

/* list of Real-Time Windows Target timers */
const int RTWinTimerCount = 1;
const double RTWinTimers[2] = {
  0.0001, 0.0,
};

/* list of Real-Time Windows Target boards */
const int RTWinBoardCount = 1;
RTWINBOARD RTWinBoards[1] = {
  { "Humusoft/MF624", 4294967295U, 1, RTWinBoardOptions0 },
};

/* Block signals (auto storage) */
BlockIO_wt_sablona_proud wt_sablona_proud_B;

/* Continuous states */
ContinuousStates_wt_sablona_proud wt_sablona_proud_X;

/* Block states (auto storage) */
D_Work_wt_sablona_proud wt_sablona_proud_DWork;

/* Real-time model */
RT_MODEL_wt_sablona_proud wt_sablona_proud_M_;
RT_MODEL_wt_sablona_proud *const wt_sablona_proud_M = &wt_sablona_proud_M_;

/*
 * This function updates continuous states using the ODE3 fixed-step
 * solver algorithm
 */
static void rt_ertODEUpdateContinuousStates(RTWSolverInfo *si )
{
  /* Solver Matrices */
  static const real_T rt_ODE3_A[3] = {
    1.0/2.0, 3.0/4.0, 1.0
  };

  static const real_T rt_ODE3_B[3][3] = {
    { 1.0/2.0, 0.0, 0.0 },

    { 0.0, 3.0/4.0, 0.0 },

    { 2.0/9.0, 1.0/3.0, 4.0/9.0 }
  };

  time_T t = rtsiGetT(si);
  time_T tnew = rtsiGetSolverStopTime(si);
  time_T h = rtsiGetStepSize(si);
  real_T *x = rtsiGetContStates(si);
  ODE3_IntgData *id = (ODE3_IntgData *)rtsiGetSolverData(si);
  real_T *y = id->y;
  real_T *f0 = id->f[0];
  real_T *f1 = id->f[1];
  real_T *f2 = id->f[2];
  real_T hB[3];
  int_T i;
  int_T nXc = 2;
  rtsiSetSimTimeStep(si,MINOR_TIME_STEP);

  /* Save the state values at time t in y, we'll use x as ynew. */
  (void) memcpy(y, x,
                (uint_T)nXc*sizeof(real_T));

  /* Assumes that rtsiSetT and ModelOutputs are up-to-date */
  /* f0 = f(t,y) */
  rtsiSetdX(si, f0);
  wt_sablona_proud_derivatives();

  /* f(:,2) = feval(odefile, t + hA(1), y + f*hB(:,1), args(:)(*)); */
  hB[0] = h * rt_ODE3_B[0][0];
  for (i = 0; i < nXc; i++) {
    x[i] = y[i] + (f0[i]*hB[0]);
  }

  rtsiSetT(si, t + h*rt_ODE3_A[0]);
  rtsiSetdX(si, f1);
  wt_sablona_proud_output();
  wt_sablona_proud_derivatives();

  /* f(:,3) = feval(odefile, t + hA(2), y + f*hB(:,2), args(:)(*)); */
  for (i = 0; i <= 1; i++) {
    hB[i] = h * rt_ODE3_B[1][i];
  }

  for (i = 0; i < nXc; i++) {
    x[i] = y[i] + (f0[i]*hB[0] + f1[i]*hB[1]);
  }

  rtsiSetT(si, t + h*rt_ODE3_A[1]);
  rtsiSetdX(si, f2);
  wt_sablona_proud_output();
  wt_sablona_proud_derivatives();

  /* tnew = t + hA(3);
     ynew = y + f*hB(:,3); */
  for (i = 0; i <= 2; i++) {
    hB[i] = h * rt_ODE3_B[2][i];
  }

  for (i = 0; i < nXc; i++) {
    x[i] = y[i] + (f0[i]*hB[0] + f1[i]*hB[1] + f2[i]*hB[2]);
  }

  rtsiSetT(si, tnew);
  rtsiSetSimTimeStep(si,MAJOR_TIME_STEP);
}

/* Model output function */
void wt_sablona_proud_output(void)
{
  /* local block i/o variables */
  real_T rtb_ManualSwitch;
  real_T rtb_TransferFcn3;
  if (rtmIsMajorTimeStep(wt_sablona_proud_M)) {
    /* set solver stop time */
    if (!(wt_sablona_proud_M->Timing.clockTick0+1)) {
      rtsiSetSolverStopTime(&wt_sablona_proud_M->solverInfo,
                            ((wt_sablona_proud_M->Timing.clockTickH0 + 1) *
        wt_sablona_proud_M->Timing.stepSize0 * 4294967296.0));
    } else {
      rtsiSetSolverStopTime(&wt_sablona_proud_M->solverInfo,
                            ((wt_sablona_proud_M->Timing.clockTick0 + 1) *
        wt_sablona_proud_M->Timing.stepSize0 +
        wt_sablona_proud_M->Timing.clockTickH0 *
        wt_sablona_proud_M->Timing.stepSize0 * 4294967296.0));
    }
  }                                    /* end MajorTimeStep */

  /* Update absolute time of base rate at minor time step */
  if (rtmIsMinorTimeStep(wt_sablona_proud_M)) {
    wt_sablona_proud_M->Timing.t[0] = rtsiGetT(&wt_sablona_proud_M->solverInfo);
  }

  if (rtmIsMajorTimeStep(wt_sablona_proud_M)) {
    /* ManualSwitch: '<Root>/Manual Switch' incorporates:
     *  Constant: '<Root>/Constant1'
     *  Constant: '<Root>/Constant2'
     */
    if (wt_sablona_proud_P.ManualSwitch_CurrentSetting == 1) {
      rtb_ManualSwitch = wt_sablona_proud_P.Constant1_Value;
    } else {
      rtb_ManualSwitch = wt_sablona_proud_P.Constant2_Value;
    }

    /* End of ManualSwitch: '<Root>/Manual Switch' */

    /* Gain: '<S1>/Slider Gain' incorporates:
     *  Constant: '<Root>/Constant3'
     */
    wt_sablona_proud_B.SliderGain = wt_sablona_proud_P.SliderGain_Gain *
      wt_sablona_proud_P.Constant3_Value;

    /* S-Function Block: <Root>/Enable */
    {
      RTBIO_DriverIO(0, DIGITALOUTPUT, IOWRITE, 1,
                     &wt_sablona_proud_P.Enable_Channels,
                     &wt_sablona_proud_P.Constant_Value,
                     &wt_sablona_proud_P.Enable_BitMode);
    }

    /* S-Function Block: <Root>/DIR */
    {
      RTBIO_DriverIO(0, DIGITALOUTPUT, IOWRITE, 1,
                     &wt_sablona_proud_P.DIR_Channels, &rtb_ManualSwitch,
                     &wt_sablona_proud_P.DIR_BitMode);
    }

    /* S-Function Block: <Root>/Frequency Output */
    {
      {
        RTBIO_DriverIO(0, FREQUENCYOUTPUT, IOWRITE, 1,
                       &wt_sablona_proud_P.FrequencyOutput_Channels,
                       &wt_sablona_proud_B.SliderGain,
                       &wt_sablona_proud_P.Constant4_Value);
      }
    }

    /* S-Function Block: <Root>/Encoder Input */
    {
      ENCODERINPARM parm;
      parm.quad = (QUADMODE) 0;
      parm.index = (INDEXPULSE) 2;
      parm.infilter = wt_sablona_proud_P.EncoderInput_InputFilter;
      RTBIO_DriverIO(0, ENCODERINPUT, IOREAD, 1,
                     &wt_sablona_proud_P.EncoderInput_Channels,
                     &wt_sablona_proud_B.EncoderInput, &parm);
    }

    /* S-Function Block: <Root>/Proud ridici */
    {
      ANALOGIOPARM parm;
      parm.mode = (RANGEMODE) wt_sablona_proud_P.Proudridici_RangeMode;
      parm.rangeidx = wt_sablona_proud_P.Proudridici_VoltRange;
      RTBIO_DriverIO(0, ANALOGINPUT, IOREAD, 1,
                     &wt_sablona_proud_P.Proudridici_Channels,
                     &wt_sablona_proud_B.Proudridici, &parm);
    }

    /* Gain: '<Root>/Gain' */
    wt_sablona_proud_B.Gain = wt_sablona_proud_P.Gain_Gain *
      wt_sablona_proud_B.EncoderInput;
  }

  /* TransferFcn: '<Root>/Transfer Fcn' */
  wt_sablona_proud_B.TransferFcn = wt_sablona_proud_P.TransferFcn_C*
    wt_sablona_proud_X.TransferFcn_CSTATE;

  /* Derivative: '<Root>/Derivative' */
  {
    real_T t = wt_sablona_proud_M->Timing.t[0];
    real_T timeStampA = wt_sablona_proud_DWork.Derivative_RWORK.TimeStampA;
    real_T timeStampB = wt_sablona_proud_DWork.Derivative_RWORK.TimeStampB;
    real_T *lastU = &wt_sablona_proud_DWork.Derivative_RWORK.LastUAtTimeA;
    if (timeStampA >= t && timeStampB >= t) {
      wt_sablona_proud_B.Derivative = 0.0;
    } else {
      real_T deltaT;
      real_T lastTime = timeStampA;
      if (timeStampA < timeStampB) {
        if (timeStampB < t) {
          lastTime = timeStampB;
          lastU = &wt_sablona_proud_DWork.Derivative_RWORK.LastUAtTimeB;
        }
      } else if (timeStampA >= t) {
        lastTime = timeStampB;
        lastU = &wt_sablona_proud_DWork.Derivative_RWORK.LastUAtTimeB;
      }

      deltaT = t - lastTime;
      wt_sablona_proud_B.Derivative = (wt_sablona_proud_B.TransferFcn - *lastU++)
        / deltaT;
    }
  }

  if (rtmIsMajorTimeStep(wt_sablona_proud_M)) {
    /* Gain: '<Root>/Gain1' */
    wt_sablona_proud_B.Gain1 = wt_sablona_proud_P.Gain1_Gain *
      wt_sablona_proud_B.Gain;
  }

  /* TransferFcn: '<Root>/Transfer Fcn3' */
  rtb_TransferFcn3 = wt_sablona_proud_P.TransferFcn3_C*
    wt_sablona_proud_X.TransferFcn3_CSTATE;

  /* Gain: '<Root>/Gain2' */
  wt_sablona_proud_B.Gain2 = wt_sablona_proud_P.Gain2_Gain * rtb_TransferFcn3;
  if (rtmIsMajorTimeStep(wt_sablona_proud_M)) {
  }
}

/* Model update function */
void wt_sablona_proud_update(void)
{
  /* Update for Derivative: '<Root>/Derivative' */
  {
    real_T timeStampA = wt_sablona_proud_DWork.Derivative_RWORK.TimeStampA;
    real_T timeStampB = wt_sablona_proud_DWork.Derivative_RWORK.TimeStampB;
    real_T* lastTime = &wt_sablona_proud_DWork.Derivative_RWORK.TimeStampA;
    real_T* lastU = &wt_sablona_proud_DWork.Derivative_RWORK.LastUAtTimeA;
    if (timeStampA != rtInf) {
      if (timeStampB == rtInf) {
        lastTime = &wt_sablona_proud_DWork.Derivative_RWORK.TimeStampB;
        lastU = &wt_sablona_proud_DWork.Derivative_RWORK.LastUAtTimeB;
      } else if (timeStampA >= timeStampB) {
        lastTime = &wt_sablona_proud_DWork.Derivative_RWORK.TimeStampB;
        lastU = &wt_sablona_proud_DWork.Derivative_RWORK.LastUAtTimeB;
      }
    }

    *lastTime = wt_sablona_proud_M->Timing.t[0];
    *lastU++ = wt_sablona_proud_B.TransferFcn;
  }

  if (rtmIsMajorTimeStep(wt_sablona_proud_M)) {
    rt_ertODEUpdateContinuousStates(&wt_sablona_proud_M->solverInfo);
  }

  /* 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 (!(++wt_sablona_proud_M->Timing.clockTick0)) {
    ++wt_sablona_proud_M->Timing.clockTickH0;
  }

  wt_sablona_proud_M->Timing.t[0] = rtsiGetSolverStopTime
    (&wt_sablona_proud_M->solverInfo);

  {
    /* Update absolute timer for sample time: [0.0001s, 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 (!(++wt_sablona_proud_M->Timing.clockTick1)) {
      ++wt_sablona_proud_M->Timing.clockTickH1;
    }

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

/* Derivatives for root system: '<Root>' */
void wt_sablona_proud_derivatives(void)
{
  /* Derivatives for TransferFcn: '<Root>/Transfer Fcn' */
  {
    ((StateDerivatives_wt_sablona_proud *) wt_sablona_proud_M->ModelData.derivs
      )->TransferFcn_CSTATE = wt_sablona_proud_B.Gain1;
    ((StateDerivatives_wt_sablona_proud *) wt_sablona_proud_M->ModelData.derivs
      )->TransferFcn_CSTATE += (wt_sablona_proud_P.TransferFcn_A)*
      wt_sablona_proud_X.TransferFcn_CSTATE;
  }

  /* Derivatives for TransferFcn: '<Root>/Transfer Fcn3' */
  {
    ((StateDerivatives_wt_sablona_proud *) wt_sablona_proud_M->ModelData.derivs
      )->TransferFcn3_CSTATE = wt_sablona_proud_B.Proudridici;
    ((StateDerivatives_wt_sablona_proud *) wt_sablona_proud_M->ModelData.derivs
      )->TransferFcn3_CSTATE += (wt_sablona_proud_P.TransferFcn3_A)*
      wt_sablona_proud_X.TransferFcn3_CSTATE;
  }
}

/* Model initialize function */
void wt_sablona_proud_initialize(void)
{
  /* S-Function Block: <Root>/Enable */

  /* no initial value should be set */

  /* S-Function Block: <Root>/DIR */

  /* no initial value should be set */

  /* S-Function Block: <Root>/Frequency Output */
  {
    {
      RTBIO_DriverIO(0, FREQUENCYOUTPUT, IOWRITE, 1,
                     &wt_sablona_proud_P.FrequencyOutput_Channels,
                     &wt_sablona_proud_P.FrequencyOutput_Frequency,
                     &wt_sablona_proud_P.FrequencyOutput_Duty);
    }
  }

  /* S-Function Block: <Root>/Encoder Input */
  {
    ENCODERINPARM parm;
    parm.quad = (QUADMODE) 0;
    parm.index = (INDEXPULSE) 2;
    parm.infilter = wt_sablona_proud_P.EncoderInput_InputFilter;
    RTBIO_DriverIO(0, ENCODERINPUT, IORESET, 1,
                   &wt_sablona_proud_P.EncoderInput_Channels, NULL, &parm);
  }

  /* InitializeConditions for TransferFcn: '<Root>/Transfer Fcn' */
  wt_sablona_proud_X.TransferFcn_CSTATE = 0.0;

  /* InitializeConditions for Derivative: '<Root>/Derivative' */
  wt_sablona_proud_DWork.Derivative_RWORK.TimeStampA = rtInf;
  wt_sablona_proud_DWork.Derivative_RWORK.TimeStampB = rtInf;

  /* InitializeConditions for TransferFcn: '<Root>/Transfer Fcn3' */
  wt_sablona_proud_X.TransferFcn3_CSTATE = 0.0;
}

/* Model terminate function */
void wt_sablona_proud_terminate(void)
{
  /* S-Function Block: <Root>/Enable */
  {
    RTBIO_DriverIO(0, DIGITALOUTPUT, IOWRITE, 1,
                   &wt_sablona_proud_P.Enable_Channels,
                   &wt_sablona_proud_P.Enable_FinalValue,
                   &wt_sablona_proud_P.Enable_BitMode);
  }

  /* S-Function Block: <Root>/DIR */

  /* no final value should be set */

  /* S-Function Block: <Root>/Frequency Output */
  {
    {
      RTBIO_DriverIO(0, FREQUENCYOUTPUT, IOWRITE, 1,
                     &wt_sablona_proud_P.FrequencyOutput_Channels,
                     &wt_sablona_proud_P.FrequencyOutput_FrequencyFinalValue,
                     &wt_sablona_proud_P.FrequencyOutput_DutyFinalValue);
    }
  }
}

/*========================================================================*
 * Start of Classic call interface                                        *
 *========================================================================*/

/* Solver interface called by GRT_Main */
#ifndef USE_GENERATED_SOLVER

void rt_ODECreateIntegrationData(RTWSolverInfo *si)
{
  UNUSED_PARAMETER(si);
  return;
}                                      /* do nothing */

void rt_ODEDestroyIntegrationData(RTWSolverInfo *si)
{
  UNUSED_PARAMETER(si);
  return;
}                                      /* do nothing */

void rt_ODEUpdateContinuousStates(RTWSolverInfo *si)
{
  UNUSED_PARAMETER(si);
  return;
}                                      /* do nothing */

#endif

void MdlOutputs(int_T tid)
{
  wt_sablona_proud_output();

  /* tid is required for a uniform function interface.
   * Argument tid is not used in the function. */
  UNUSED_PARAMETER(tid);
}

void MdlUpdate(int_T tid)
{
  wt_sablona_proud_update();

  /* tid is required for a uniform function interface.
   * Argument tid is not used in the function. */
  UNUSED_PARAMETER(tid);
}

void MdlInitializeSizes(void)
{
}

void MdlInitializeSampleTimes(void)
{
}

void MdlInitialize(void)
{
}

void MdlStart(void)
{
  wt_sablona_proud_initialize();
}

void MdlTerminate(void)
{
  wt_sablona_proud_terminate();
}

RT_MODEL_wt_sablona_proud *wt_sablona_proud(void)
{
  /* Registration code */

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

  /* non-finite (run-time) assignments */
  wt_sablona_proud_P.EncoderInput_InputFilter = rtInf;

  /* initialize real-time model */
  (void) memset((void *)wt_sablona_proud_M, 0,
                sizeof(RT_MODEL_wt_sablona_proud));

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

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

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

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

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

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

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

  rtmSetTFinal(wt_sablona_proud_M, 5.0);
  wt_sablona_proud_M->Timing.stepSize0 = 0.0001;
  wt_sablona_proud_M->Timing.stepSize1 = 0.0001;

  /* External mode info */
  wt_sablona_proud_M->Sizes.checksums[0] = (2252089081U);
  wt_sablona_proud_M->Sizes.checksums[1] = (3478679980U);
  wt_sablona_proud_M->Sizes.checksums[2] = (1488413386U);
  wt_sablona_proud_M->Sizes.checksums[3] = (2353805011U);

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

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

  /* block I/O */
  wt_sablona_proud_M->ModelData.blockIO = ((void *) &wt_sablona_proud_B);
  (void) memset(((void *) &wt_sablona_proud_B), 0,
                sizeof(BlockIO_wt_sablona_proud));

  /* parameters */
  wt_sablona_proud_M->ModelData.defaultParam = ((real_T *)&wt_sablona_proud_P);

  /* states (continuous) */
  {
    real_T *x = (real_T *) &wt_sablona_proud_X;
    wt_sablona_proud_M->ModelData.contStates = (x);
    (void) memset((void *)&wt_sablona_proud_X, 0,
                  sizeof(ContinuousStates_wt_sablona_proud));
  }

  /* states (dwork) */
  wt_sablona_proud_M->Work.dwork = ((void *) &wt_sablona_proud_DWork);
  (void) memset((void *)&wt_sablona_proud_DWork, 0,
                sizeof(D_Work_wt_sablona_proud));

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

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

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

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

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