/*
 * rampa_g.c
 *
 * Code generation for model "rampa_g".
 *
 * Model version              : 1.102
 * Simulink Coder version : 8.3 (R2012b) 20-Jul-2012
 * C source code generated on : Fri May 22 15:51:42 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 "rampa_g.h"
#include "rampa_g_private.h"
#include "rampa_g_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_rampa_g rampa_g_B;

/* Continuous states */
ContinuousStates_rampa_g rampa_g_X;

/* Block states (auto storage) */
D_Work_rampa_g rampa_g_DWork;

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

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

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

  /* RTWBLOCK_START_COMMENT */

  /* TransferFcn: '<Root>/Transfer Fcn1' */
  rampa_g_B.TransferFcn1 = rampa_g_P.TransferFcn1_C*
    rampa_g_X.TransferFcn1_CSTATE;
  if (rtmIsMajorTimeStep(rampa_g_M)) {
    /* ManualSwitch: '<S3>/Manual Switch' incorporates:
     *  Constant: '<S3>/Constant1'
     *  Constant: '<S3>/Constant2'
     */
    if (rampa_g_P.ManualSwitch_CurrentSetting == 1) {
      rtb_Step = rampa_g_P.Constant1_Value;
    } else {
      rtb_Step = rampa_g_P.Constant2_Value;
    }

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

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

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

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

    /* Gain: '<S3>/Gain' */
    rampa_g_B.Gain = rampa_g_P.Gain_Gain * rtb_Step;

    /* Step: '<Root>/Step' */
    currentTime = rampa_g_M->Timing.t[1];
    if (currentTime < rampa_g_P.Step_Time) {
      rtb_Step = rampa_g_P.Step_Y0;
    } else {
      rtb_Step = rampa_g_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 = (!rampa_g_DWork.CounterInput_IWORK.LastResetInput && reset) ?
        IOREADWITHRESET : IOREAD;
      parm.edge = (COUNTEREDGE) rampa_g_P.CounterInput_CtrEdge;
      parm.gate = (COUNTERGATE) rampa_g_P.CounterInput_CtrGate;
      RTBIO_DriverIO(0, COUNTERINPUT, action, 1,
                     &rampa_g_P.CounterInput_Channels, inval, &parm);
      rampa_g_B.CounterInput = (uint32_T) *invalp++;
      rampa_g_DWork.CounterInput_IWORK.LastResetInput = reset;
    }

    /* Gain: '<Root>/Gain2' */
    rampa_g_B.Gain2 = rampa_g_P.Gain2_Gain * rampa_g_B.Gain;
  }

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

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

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

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

  /* TransferFcn: '<Root>/Transfer Fcn2' */
  rampa_g_B.TransferFcn2 = rampa_g_P.TransferFcn2_C*
    rampa_g_X.TransferFcn2_CSTATE;
  if (rtmIsMajorTimeStep(rampa_g_M)) {
    /* Gain: '<Root>/Gain3' */
    rampa_g_B.Gain3 = rampa_g_P.Gain3_Gain * rampa_g_B.Gain;
  }

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

      deltaT = t - lastTime;
      rampa_g_B.Derivative = (rampa_g_B.Gain3 - *lastU++) / deltaT;
    }
  }

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

/* Model update function */
void rampa_g_update(void)
{
  if (rtmIsMajorTimeStep(rampa_g_M)) {
    /* Update for UnitDelay: '<S1>/Delay Input1' */
    rampa_g_DWork.DelayInput1_DSTATE = rampa_g_B.Step1;
  }

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

    *lastTime = rampa_g_M->Timing.t[0];
    *lastU++ = rampa_g_B.Gain3;
  }

  if (rtmIsMajorTimeStep(rampa_g_M)) {
    rt_ertODEUpdateContinuousStates(&rampa_g_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 (!(++rampa_g_M->Timing.clockTick0)) {
    ++rampa_g_M->Timing.clockTickH0;
  }

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

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

/* Derivatives for root system: '<Root>' */
void rampa_g_derivatives(void)
{
  /* Derivatives for TransferFcn: '<Root>/Transfer Fcn1' */
  {
    ((StateDerivatives_rampa_g *) rampa_g_M->ModelData.derivs)
      ->TransferFcn1_CSTATE = rampa_g_P.Constant1_Value_g;
    ((StateDerivatives_rampa_g *) rampa_g_M->ModelData.derivs)
      ->TransferFcn1_CSTATE += (rampa_g_P.TransferFcn1_A)*
      rampa_g_X.TransferFcn1_CSTATE;
  }

  /* Derivatives for TransferFcn: '<Root>/Transfer Fcn2' */
  {
    ((StateDerivatives_rampa_g *) rampa_g_M->ModelData.derivs)
      ->TransferFcn2_CSTATE = rampa_g_B.Derivative;
    ((StateDerivatives_rampa_g *) rampa_g_M->ModelData.derivs)
      ->TransferFcn2_CSTATE += (rampa_g_P.TransferFcn2_A)*
      rampa_g_X.TransferFcn2_CSTATE;
  }
}

/* Model initialize function */
void rampa_g_initialize(void)
{
  /* S-Function Block: <S3>/Frequency Output */
  {
    {
      RTBIO_DriverIO(0, FREQUENCYOUTPUT, IOWRITE, 1,
                     &rampa_g_P.FrequencyOutput_Channels,
                     &rampa_g_P.FrequencyOutput_Frequency,
                     &rampa_g_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 = rampa_g_P.DataStoreMemory_InitialValue;

  /* InitializeConditions for TransferFcn: '<Root>/Transfer Fcn1' */
  rampa_g_X.TransferFcn1_CSTATE = 0.0;

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

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

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

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

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

/* Model terminate function */
void rampa_g_terminate(void)
{
  /* S-Function Block: <S3>/Frequency Output */
  {
    {
      RTBIO_DriverIO(0, FREQUENCYOUTPUT, IOWRITE, 1,
                     &rampa_g_P.FrequencyOutput_Channels,
                     &rampa_g_P.FrequencyOutput_FrequencyFinalValue,
                     &rampa_g_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, &rampa_g_P.Enable_Channels,
                   &rampa_g_P.Enable_FinalValue, &rampa_g_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)
{
  rampa_g_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)
{
  rampa_g_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)
{
  rampa_g_initialize();
}

void MdlTerminate(void)
{
  rampa_g_terminate();
}

RT_MODEL_rampa_g *rampa_g(void)
{
  /* Registration code */

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

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

  /* initialize real-time model */
  (void) memset((void *)rampa_g_M, 0,
                sizeof(RT_MODEL_rampa_g));

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

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

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

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

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

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

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

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

  /* External mode info */
  rampa_g_M->Sizes.checksums[0] = (1972648346U);
  rampa_g_M->Sizes.checksums[1] = (1191984729U);
  rampa_g_M->Sizes.checksums[2] = (3529801435U);
  rampa_g_M->Sizes.checksums[3] = (103692598U);

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

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

  /* block I/O */
  rampa_g_M->ModelData.blockIO = ((void *) &rampa_g_B);
  (void) memset(((void *) &rampa_g_B), 0,
                sizeof(BlockIO_rampa_g));

  /* parameters */
  rampa_g_M->ModelData.defaultParam = ((real_T *)&rampa_g_P);

  /* states (continuous) */
  {
    real_T *x = (real_T *) &rampa_g_X;
    rampa_g_M->ModelData.contStates = (x);
    (void) memset((void *)&rampa_g_X, 0,
                  sizeof(ContinuousStates_rampa_g));
  }

  /* states (dwork) */
  rampa_g_M->Work.dwork = ((void *) &rampa_g_DWork);
  (void) memset((void *)&rampa_g_DWork, 0,
                sizeof(D_Work_rampa_g));

  /* exported global states */
  rozdil = 0.0;

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

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