/*
 * wt_sablona.c
 *
 * Code generation for model "wt_sablona".
 *
 * Model version              : 1.90
 * Simulink Coder version : 8.3 (R2012b) 20-Jul-2012
 * C source code generated on : Thu May 21 15:42:27 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.h"
#include "wt_sablona_private.h"
#include "wt_sablona_dt.h"

/* options for Real-Time Windows Target board 0 */
static double RTWinBoardOptions0[] = {
  9.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 },
};

/* Exported block states */
real_T rozdil;                         /* '<Root>/Data Store Memory' */

/* Block signals (auto storage) */
BlockIO_wt_sablona wt_sablona_B;

/* Continuous states */
ContinuousStates_wt_sablona wt_sablona_X;

/* Block states (auto storage) */
D_Work_wt_sablona wt_sablona_DWork;

/* Real-time model */
RT_MODEL_wt_sablona wt_sablona_M_;
RT_MODEL_wt_sablona *const wt_sablona_M = &wt_sablona_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 = 1;
  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_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_output();
  wt_sablona_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_output();
  wt_sablona_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_output(void)
{
  /* local block i/o variables */
  real_T rtb_Step;
  real_T currentTime;
  if (rtmIsMajorTimeStep(wt_sablona_M)) {
    /* set solver stop time */
    if (!(wt_sablona_M->Timing.clockTick0+1)) {
      rtsiSetSolverStopTime(&wt_sablona_M->solverInfo,
                            ((wt_sablona_M->Timing.clockTickH0 + 1) *
        wt_sablona_M->Timing.stepSize0 * 4294967296.0));
    } else {
      rtsiSetSolverStopTime(&wt_sablona_M->solverInfo,
                            ((wt_sablona_M->Timing.clockTick0 + 1) *
        wt_sablona_M->Timing.stepSize0 + wt_sablona_M->Timing.clockTickH0 *
        wt_sablona_M->Timing.stepSize0 * 4294967296.0));
    }
  }                                    /* end MajorTimeStep */

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

  /* Reset subsysRan breadcrumbs */
  srClearBC(wt_sablona_DWork.EnabledSubsystem_SubsysRanBC);

  /* RTWBLOCK_START_COMMENT */
  if (rtmIsMajorTimeStep(wt_sablona_M)) {
    /* ManualSwitch: '<S3>/Manual Switch' incorporates:
     *  Constant: '<S3>/Constant1'
     *  Constant: '<S3>/Constant2'
     */
    if (wt_sablona_P.ManualSwitch_CurrentSetting == 1) {
      rtb_Step = wt_sablona_P.Constant1_Value;
    } else {
      rtb_Step = wt_sablona_P.Constant2_Value;
    }

    /* End of ManualSwitch: '<S3>/Manual Switch' */
    /* S-Function Block: <S3>/Frequency Output */
    {
      {
        RTBIO_DriverIO(0, FREQUENCYOUTPUT, IOWRITE, 1,
                       &wt_sablona_P.FrequencyOutput_Channels,
                       &wt_sablona_P.Constant3_Value, &wt_sablona_P.Strida_Value);
      }
    }

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

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

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

    /* Gain: '<S3>/Gain' */
    wt_sablona_B.Gain = wt_sablona_P.Gain_Gain * rtb_Step;

    /* Step: '<Root>/Step' */
    currentTime = wt_sablona_M->Timing.t[1];
    if (currentTime < wt_sablona_P.Step_Time) {
      rtb_Step = wt_sablona_P.Step_Y0;
    } else {
      rtb_Step = wt_sablona_P.Step_YFinal;
    }

    /* End of Step: '<Root>/Step' */
    /* S-Function Block: <Root>/Counter Input */
    {
      double inval[1];
      double* invalp = inval;
      COUNTERINPARM parm;
      DRVIOACTION action;
      int reset = rtb_Step != 0;
      action = (!wt_sablona_DWork.CounterInput_IWORK.LastResetInput && reset) ?
        IOREADWITHRESET : IOREAD;
      parm.edge = (COUNTEREDGE) wt_sablona_P.CounterInput_CtrEdge;
      parm.gate = (COUNTERGATE) wt_sablona_P.CounterInput_CtrGate;
      RTBIO_DriverIO(0, COUNTERINPUT, action, 1,
                     &wt_sablona_P.CounterInput_Channels, inval, &parm);
      wt_sablona_B.CounterInput = (uint32_T) *invalp++;
      wt_sablona_DWork.CounterInput_IWORK.LastResetInput = reset;
    }

    /* Gain: '<Root>/Gain2' */
    wt_sablona_B.Gain2 = wt_sablona_P.Gain2_Gain * wt_sablona_B.Gain;
  }

  /* Step: '<Root>/Step1' */
  currentTime = wt_sablona_M->Timing.t[0];
  if (currentTime < wt_sablona_P.Step1_Time) {
    wt_sablona_B.Step1 = wt_sablona_P.Step1_Y0;
  } else {
    wt_sablona_B.Step1 = wt_sablona_P.Step1_YFinal;
  }

  /* End of Step: '<Root>/Step1' */
  if (rtmIsMajorTimeStep(wt_sablona_M)) {
    /* UnitDelay: '<S1>/Delay Input1' */
    wt_sablona_B.Uk1 = wt_sablona_DWork.DelayInput1_DSTATE;
  }

  /* RelationalOperator: '<S1>/FixPt Relational Operator' */
  wt_sablona_B.FixPtRelationalOperator = (wt_sablona_B.Step1 > wt_sablona_B.Uk1);
  if (rtmIsMajorTimeStep(wt_sablona_M)) {
    /* Outputs for Enabled SubSystem: '<Root>/Enabled Subsystem' incorporates:
     *  EnablePort: '<S2>/Enable'
     */
    if (wt_sablona_B.FixPtRelationalOperator) {
      /* DataStoreWrite: '<S2>/Data Store Write' incorporates:
       *  Sum: '<S2>/Add'
       */
      rozdil = (real_T)wt_sablona_B.CounterInput - wt_sablona_B.Gain2;
      if (rtmIsMajorTimeStep(wt_sablona_M)) {
        srUpdateBC(wt_sablona_DWork.EnabledSubsystem_SubsysRanBC);
      }
    }

    /* End of Outputs for SubSystem: '<Root>/Enabled Subsystem' */
  }

  /* TransferFcn: '<Root>/Transfer Fcn2' */
  wt_sablona_B.TransferFcn2 = wt_sablona_P.TransferFcn2_C*
    wt_sablona_X.TransferFcn2_CSTATE;
  if (rtmIsMajorTimeStep(wt_sablona_M)) {
    /* Gain: '<Root>/Gain1' */
    wt_sablona_B.Gain1 = wt_sablona_P.Gain1_Gain * wt_sablona_B.Gain;
  }

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

      deltaT = t - lastTime;
      wt_sablona_B.Derivative = (wt_sablona_B.Gain1 - *lastU++) / deltaT;
    }
  }

  if (rtmIsMajorTimeStep(wt_sablona_M)) {
    /* DataStoreRead: '<Root>/Data Store Read' */
    wt_sablona_B.DataStoreRead = rozdil;
  }
}

/* Model update function */
void wt_sablona_update(void)
{
  if (rtmIsMajorTimeStep(wt_sablona_M)) {
    /* Update for UnitDelay: '<S1>/Delay Input1' */
    wt_sablona_DWork.DelayInput1_DSTATE = wt_sablona_B.Step1;
  }

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

    *lastTime = wt_sablona_M->Timing.t[0];
    *lastU++ = wt_sablona_B.Gain1;
  }

  if (rtmIsMajorTimeStep(wt_sablona_M)) {
    rt_ertODEUpdateContinuousStates(&wt_sablona_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_M->Timing.clockTick0)) {
    ++wt_sablona_M->Timing.clockTickH0;
  }

  wt_sablona_M->Timing.t[0] = rtsiGetSolverStopTime(&wt_sablona_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_M->Timing.clockTick1)) {
      ++wt_sablona_M->Timing.clockTickH1;
    }

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

/* Derivatives for root system: '<Root>' */
void wt_sablona_derivatives(void)
{
  /* Derivatives for TransferFcn: '<Root>/Transfer Fcn2' */
  {
    ((StateDerivatives_wt_sablona *) wt_sablona_M->ModelData.derivs)
      ->TransferFcn2_CSTATE = wt_sablona_B.Derivative;
    ((StateDerivatives_wt_sablona *) wt_sablona_M->ModelData.derivs)
      ->TransferFcn2_CSTATE += (wt_sablona_P.TransferFcn2_A)*
      wt_sablona_X.TransferFcn2_CSTATE;
  }
}

/* Model initialize function */
void wt_sablona_initialize(void)
{
  /* S-Function Block: <S3>/Frequency Output */
  {
    {
      RTBIO_DriverIO(0, FREQUENCYOUTPUT, IOWRITE, 1,
                     &wt_sablona_P.FrequencyOutput_Channels,
                     &wt_sablona_P.FrequencyOutput_Frequency,
                     &wt_sablona_P.FrequencyOutput_Duty);
    }
  }

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

  /* no initial value should be set */

  /* S-Function Block: <S3>/Enable */

  /* no initial value should be set */

  /* Start for DataStoreMemory: '<Root>/Data Store Memory' */
  rozdil = wt_sablona_P.DataStoreMemory_InitialValue;

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

  /* S-Function Block: <Root>/Counter Input */
  {
    COUNTERINPARM parm;
    parm.edge = (COUNTEREDGE) wt_sablona_P.CounterInput_CtrEdge;
    parm.gate = (COUNTERGATE) wt_sablona_P.CounterInput_CtrGate;
    RTBIO_DriverIO(0, COUNTERINPUT, IORESET, 1,
                   &wt_sablona_P.CounterInput_Channels, NULL, &parm);
  }

  /* InitializeConditions for UnitDelay: '<S1>/Delay Input1' */
  wt_sablona_DWork.DelayInput1_DSTATE =
    wt_sablona_P.DelayInput1_InitialCondition;

  /* InitializeConditions for TransferFcn: '<Root>/Transfer Fcn2' */
  wt_sablona_X.TransferFcn2_CSTATE = 0.0;

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

/* Model terminate function */
void wt_sablona_terminate(void)
{
  /* S-Function Block: <S3>/Frequency Output */
  {
    {
      RTBIO_DriverIO(0, FREQUENCYOUTPUT, IOWRITE, 1,
                     &wt_sablona_P.FrequencyOutput_Channels,
                     &wt_sablona_P.FrequencyOutput_FrequencyFinalValue,
                     &wt_sablona_P.FrequencyOutput_DutyFinalValue);
    }
  }

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

  /* no final value should be set */

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

/*========================================================================*
 * 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_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_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_initialize();
}

void MdlTerminate(void)
{
  wt_sablona_terminate();
}

RT_MODEL_wt_sablona *wt_sablona(void)
{
  /* Registration code */

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

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

  /* initialize real-time model */
  (void) memset((void *)wt_sablona_M, 0,
                sizeof(RT_MODEL_wt_sablona));

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

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

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

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

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

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

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

  rtmSetTFinal(wt_sablona_M, 3.0);
  wt_sablona_M->Timing.stepSize0 = 0.0001;
  wt_sablona_M->Timing.stepSize1 = 0.0001;

  /* External mode info */
  wt_sablona_M->Sizes.checksums[0] = (4056588543U);
  wt_sablona_M->Sizes.checksums[1] = (3292554598U);
  wt_sablona_M->Sizes.checksums[2] = (2178486650U);
  wt_sablona_M->Sizes.checksums[3] = (3314561573U);

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

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

  /* block I/O */
  wt_sablona_M->ModelData.blockIO = ((void *) &wt_sablona_B);
  (void) memset(((void *) &wt_sablona_B), 0,
                sizeof(BlockIO_wt_sablona));

  /* parameters */
  wt_sablona_M->ModelData.defaultParam = ((real_T *)&wt_sablona_P);

  /* states (continuous) */
  {
    real_T *x = (real_T *) &wt_sablona_X;
    wt_sablona_M->ModelData.contStates = (x);
    (void) memset((void *)&wt_sablona_X, 0,
                  sizeof(ContinuousStates_wt_sablona));
  }

  /* states (dwork) */
  wt_sablona_M->Work.dwork = ((void *) &wt_sablona_DWork);
  (void) memset((void *)&wt_sablona_DWork, 0,
                sizeof(D_Work_wt_sablona));

  /* exported global states */
  rozdil = 0.0;

  /* data type transition information */
  {
    static DataTypeTransInfo dtInfo;
    (void) memset((char_T *) &dtInfo, 0,
                  sizeof(dtInfo));
    wt_sablona_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_M->Sizes.numContStates = (1);/* Number of continuous states */
  wt_sablona_M->Sizes.numY = (0);      /* Number of model outputs */
  wt_sablona_M->Sizes.numU = (0);      /* Number of model inputs */
  wt_sablona_M->Sizes.sysDirFeedThru = (0);/* The model is not direct feedthrough */
  wt_sablona_M->Sizes.numSampTimes = (2);/* Number of sample times */
  wt_sablona_M->Sizes.numBlocks = (34);/* Number of blocks */
  wt_sablona_M->Sizes.numBlockIO = (10);/* Number of block outputs */
  wt_sablona_M->Sizes.numBlockPrms = (44);/* Sum of parameter "widths" */
  return wt_sablona_M;
}

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