/*
 * File: Controller.h
 *
 * Real-Time Workshop code generated for Simulink model Controller.
 *
 * Model version                        : 1.375
 * Real-Time Workshop file version      : 7.3  (R2009a)  15-Jan-2009
 * Real-Time Workshop file generated on : Mon Jan 11 12:01:09 2010
 * TLC version                          : 7.3 (Jan 18 2009)
 * C/C++ source code generated on       : Mon Jan 11 12:01:10 2010
 *
 * Target selection: motohawk_ert_rtw.tlc
 * Embedded hardware selection: Specified
 * Code generation objectives: Unspecified
 * Validation result: Not run
 */

#ifndef RTW_HEADER_Controller_h_
#define RTW_HEADER_Controller_h_
#ifndef Controller_COMMON_INCLUDES_
# define Controller_COMMON_INCLUDES_
#include <math.h>
#include <string.h>
#include "rtwtypes.h"
#include "rt_zcfcn.h"
#include "Application.h"
#include "rt_MAXd_snf.h"
#include "rt_MINd_snf.h"
#include "rt_SATURATE.h"
#include "rt_nonfinite.h"
#endif                                 /* Controller_COMMON_INCLUDES_ */

#include "Controller_types.h"

/* Child system includes */
#include "Controller_Foreground.h"

/* Macros for accessing real-time model data structure */
#ifndef rtmGetErrorStatus
# define rtmGetErrorStatus(rtm)        ((rtm)->errorStatus)
#endif

#ifndef rtmSetErrorStatus
# define rtmSetErrorStatus(rtm, val)   ((rtm)->errorStatus = (val))
#endif

#ifndef rtmGetStopRequested
# define rtmGetStopRequested(rtm)      ((void*) 0)
#endif

/* Block signals (auto storage) */
typedef struct {
  real_T s1_ReadCANMessage_o1;         /* '<S1>/Read CAN Message' */
  real_T s1_ReadCANMessage_o2;         /* '<S1>/Read CAN Message' */
  real_T s1_ReadCANMessage_o3;         /* '<S1>/Read CAN Message' */
  real_T s1_ReadCANMessage3_o1;        /* '<S1>/Read CAN Message3' */
  real_T s1_ReadCANMessage3_o2;        /* '<S1>/Read CAN Message3' */
  real_T s1_ReadCANMessage3_o3;        /* '<S1>/Read CAN Message3' */
  real_T s1_secondsperhour;            /* '<S1>/seconds per hour' */
  real_T s1_ReadCANMessage4;           /* '<S1>/Read CAN Message4' */
  real_T s1_ReadCANMessage5;           /* '<S1>/Read CAN Message5' */
  real_T s1_ReadCANMessage6;           /* '<S1>/Read CAN Message6' */
  real_T s1_ReadCANMessage2_o1;        /* '<S1>/Read CAN Message2' */
  real_T s1_ReadCANMessage2_o2;        /* '<S1>/Read CAN Message2' */
  real_T s1_ReadCANMessage2_o3;        /* '<S1>/Read CAN Message2' */
  real_T s1_ReadCANMessage1_o1;        /* '<S1>/Read CAN Message1' */
  real_T s1_ReadCANMessage1_o2;        /* '<S1>/Read CAN Message1' */
  real_T s1_ReadCANMessage1_o3;        /* '<S1>/Read CAN Message1' */
  real_T s1_Sum;                       /* '<S1>/Sum' */
  real_T s1_Sum1;                      /* '<S1>/Sum1' */
  real_T s1_DataTypeConversion8;       /* '<S1>/Data Type Conversion8' */
  real_T s1_DataTypeConversion9;       /* '<S1>/Data Type Conversion9' */
  real_T s1_DataTypeConversion10;      /* '<S1>/Data Type Conversion10' */
  real_T s3_Product;                   /* '<S3>/Product' */
  real_T s13_DiscreteTransferFcn;      /* '<S13>/Discrete Transfer Fcn' */
  real_T s18_Yk;                       /* '<S18>/Difference Inputs2' */
  real_T s11_Product4;                 /* '<S11>/Product4' */
  real_T s11_Foundation_Brake_Request; /* '<S11>/Sum' */
  real_T s19_Vehicle_Ready;            /* '<S3>/Startup_and_Shifting' */
  real_T s19_State;                    /* '<S3>/Startup_and_Shifting' */
  real_T s19_Battery_Connect_Command;  /* '<S3>/Startup_and_Shifting' */
  real_T s19_Error;                    /* '<S3>/Startup_and_Shifting' */
  real_T s19_Motor_Enable;             /* '<S3>/Startup_and_Shifting' */
  real_T s19_Gen_Enable;               /* '<S3>/Startup_and_Shifting' */
  real_T s19_Forward_LED;              /* '<S3>/Startup_and_Shifting' */
  real_T s19_Reverse_LED;              /* '<S3>/Startup_and_Shifting' */
  real_T s19_Park_LED;                 /* '<S3>/Startup_and_Shifting' */
  real_T s19_Gear;                     /* '<S3>/Startup_and_Shifting' */
  real_T s12_charge_current;           /* '<S3>/Charge_Controller' */
  real_T s12_Desired_Engine_rpm;       /* '<S3>/Charge_Controller' */
  real_T s12_Enable_Generator;         /* '<S3>/Charge_Controller' */
  real_T s12_Current_Feedback_Enable;  /* '<S3>/Charge_Controller' */
  real_T s12_Engine_On;                /* '<S3>/Charge_Controller' */
  real_T s12_Throttle_Offset;          /* '<S3>/Charge_Controller' */
  real_T s12_Current_Track;            /* '<S3>/Charge_Controller' */
  real_T s12_Charge_State;             /* '<S3>/Charge_Controller' */
} BlockIO_Controller;

/* Block states (auto storage) for system '<Root>' */
typedef struct {
  real_T s16_DelayInput2_DSTATE;       /* '<S16>/Delay Input2' */
  real_T s14_UnitDelay_DSTATE;         /* '<S14>/Unit Delay' */
  real_T s13_DiscreteTransferFcn_DSTATE;/* '<S13>/Discrete Transfer Fcn' */
  real_T s17_DelayInput2_DSTATE;       /* '<S17>/Delay Input2' */
  real_T s15_UnitDelay_DSTATE;         /* '<S15>/Unit Delay' */
  real_T s18_DelayInput2_DSTATE;       /* '<S18>/Delay Input2' */
  real_T s22_DelayInput2_DSTATE;       /* '<S22>/Delay Input2' */
  real_T s21_DelayInput2_DSTATE;       /* '<S21>/Delay Input2' */
  uint32_T root_Foreground_ELAPS_T;    /* '<Root>/Foreground' */
  uint32_T root_Foreground_PREV_T;     /* '<Root>/Foreground' */
  uint32_T s14_motohawk_delta_time_DWORK1;/* '<S14>/motohawk_delta_time' */
  uint32_T s15_motohawk_delta_time_DWORK1;/* '<S15>/motohawk_delta_time' */
  uint16_T s39_UnitDelay_DSTATE;       /* '<S39>/Unit Delay' */
  uint16_T s39_UnitDelay1_DSTATE;      /* '<S39>/Unit Delay1' */
  uint16_T s19_temporalCounter_i1;     /* '<S3>/Startup_and_Shifting' */
  boolean_T s40_UnitDelay_DSTATE;      /* '<S40>/Unit Delay' */
  boolean_T s50_UnitDelay_DSTATE;      /* '<S50>/Unit Delay' */
  boolean_T s38_UnitDelay5_DSTATE;     /* '<S38>/Unit Delay5' */
  boolean_T s38_UnitDelay2_DSTATE;     /* '<S38>/Unit Delay2' */
  boolean_T s38_UnitDelay_DSTATE;      /* '<S38>/Unit Delay' */
  boolean_T s38_UnitDelay1_DSTATE;     /* '<S38>/Unit Delay1' */
  boolean_T s38_UnitDelay3_DSTATE;     /* '<S38>/Unit Delay3' */
  boolean_T s38_UnitDelay4_DSTATE;     /* '<S38>/Unit Delay4' */
  uint8_T s19_is_active_c2_Controller; /* '<S3>/Startup_and_Shifting' */
  uint8_T s19_is_c2_Controller;        /* '<S3>/Startup_and_Shifting' */
  uint8_T s12_is_active_c1_Controller; /* '<S3>/Charge_Controller' */
  uint8_T s12_is_c1_Controller;        /* '<S3>/Charge_Controller' */
} D_Work_Controller;

/* Zero-crossing (trigger) state */
typedef struct {
  ZCSigState Startup_and_Shifting_Trig_ZCE;/* '<S3>/Startup_and_Shifting' */
  ZCSigState Charge_Controller_Trig_ZCE;/* '<S3>/Charge_Controller' */
  ZCSigState ShutdownpoweronECU565128_Trig_ZCE;/* '<S38>/Shutdown power on ECU565-128' */
  ZCSigState SaveNVVarsonetickbeforeMPRDoff_Trig_ZCE;/* '<S38>/Save NV Vars one tick before MPRD off' */
  ZCSigState ProcessorReboot_Trig_ZCE; /* '<S38>/Processor Reboot' */
  ZCSigState PostShutdowntwoticksbeforeMPRDoff_Trig_ZCE;/* '<S38>/Post Shutdown two ticks before MPRD off' */
  ZCSigState Clear_Trig_ZCE;           /* '<S42>/Clear' */
  ZCSigState Clear_Trig_ZCE_e;         /* '<S41>/Clear' */
} PrevZCSigStates_Controller;

/* Constant parameters (auto storage) */
typedef struct {
  /* Expression: [0 3 8 10]
   * Referenced by blocks:
   * '<S11>/Disable Regen2'
   * '<S11>/Disable Regen3'
   */
  real_T pooled17[4];

  /* Expression: [0 0 1 1]
   * Referenced by blocks:
   * '<S11>/Disable Regen2'
   * '<S11>/Disable Regen3'
   */
  real_T pooled18[4];

  /* Expression: [0 .75 .85 1]
   * Referenced by blocks:
   * '<S11>/Disable Regen'
   * '<S11>/Disable Regen1'
   */
  real_T pooled19[4];

  /* Expression: [1 1 0 0]
   * Referenced by blocks:
   * '<S11>/Disable Regen'
   * '<S11>/Disable Regen1'
   */
  real_T pooled20[4];

  /* Expression: [0 1 1]
   * Referenced by blocks:
   * '<S11>/Regen Braking'
   * '<S11>/Regen Braking1'
   */
  real_T pooled22[3];

  /* Expression: [0 0.25  1]
   * '<S11>/Foundation Braking'
   */
  real_T FoundationBraking_XData[3];

  /* Expression: [0 0 1]
   * '<S11>/Foundation Braking'
   */
  real_T FoundationBraking_YData[3];
} ConstParam_Controller;

/* Real-time Model Data Structure */
struct RT_MODEL_Controller {
  const char_T *errorStatus;

  /*
   * Timing:
   * The following substructure contains information regarding
   * the timing information for the model.
   */
  struct {
    uint32_T clockTick0;
    uint32_T clockTickH0;
  } Timing;
};

/* Block signals (auto storage) */
extern BlockIO_Controller Controller_B;

/* Block states (auto storage) */
extern D_Work_Controller Controller_DWork;

/* Constant parameters (auto storage) */
extern const ConstParam_Controller Controller_ConstP;

/* External data declarations for dependent source files */

/* Zero-crossing (trigger) state */
extern PrevZCSigStates_Controller Controller_PrevZCSigState;

/* Model entry point functions */
extern void Controller_initialize(boolean_T firstTime);
extern void Controller_step(void);
extern void Controller_terminate(void);

/* Real-time Model object */
extern RT_MODEL_Controller *Controller_M;

/*-
 * The generated code includes comments that allow you to trace directly
 * back to the appropriate location in the model.  The basic format
 * is <system>/block_name, where system is the system number (uniquely
 * assigned by Simulink) and block_name is the name of the block.
 *
 * Use the MATLAB hilite_system command to trace the generated code back
 * to the model.  For example,
 *
 * hilite_system('<S3>')    - opens system 3
 * hilite_system('<S3>/Kp') - opens and selects block Kp which resides in S3
 *
 * Here is the system hierarchy for this model
 *
 * '<Root>' : Controller
 * '<S1>'   : Controller/Foreground
 * '<S2>'   : Controller/Main Power Relay1
 * '<S3>'   : Controller/Foreground/Control
 * '<S4>'   : Controller/Foreground/Probes
 * '<S5>'   : Controller/Foreground/Probes1
 * '<S6>'   : Controller/Foreground/motohawk_override_abs
 * '<S7>'   : Controller/Foreground/motohawk_override_abs1
 * '<S8>'   : Controller/Foreground/motohawk_override_abs2
 * '<S9>'   : Controller/Foreground/motohawk_override_abs3
 * '<S10>'  : Controller/Foreground/motohawk_override_abs4
 * '<S11>'  : Controller/Foreground/Control/Acceleration_and_Braking
 * '<S12>'  : Controller/Foreground/Control/Charge_Controller
 * '<S13>'  : Controller/Foreground/Control/Charge_Current_Calculator
 * '<S14>'  : Controller/Foreground/Control/RHIT Integrator
 * '<S15>'  : Controller/Foreground/Control/RHIT Integrator1
 * '<S16>'  : Controller/Foreground/Control/RHIT Rate Limiter
 * '<S17>'  : Controller/Foreground/Control/RHIT Rate Limiter1
 * '<S18>'  : Controller/Foreground/Control/RHIT Rate Limiter2
 * '<S19>'  : Controller/Foreground/Control/Startup_and_Shifting
 * '<S20>'  : Controller/Foreground/Control/Acceleration_and_Braking/Pedal_Conditioning
 * '<S21>'  : Controller/Foreground/Control/Acceleration_and_Braking/Pedal_Conditioning/RHIT Rate Limiter
 * '<S22>'  : Controller/Foreground/Control/Acceleration_and_Braking/Pedal_Conditioning/RHIT Rate Limiter1
 * '<S23>'  : Controller/Foreground/Control/Acceleration_and_Braking/Pedal_Conditioning/RHIT Rate Limiter/Saturation Dynamic
 * '<S24>'  : Controller/Foreground/Control/Acceleration_and_Braking/Pedal_Conditioning/RHIT Rate Limiter1/Saturation Dynamic
 * '<S25>'  : Controller/Foreground/Control/RHIT Rate Limiter/Saturation Dynamic
 * '<S26>'  : Controller/Foreground/Control/RHIT Rate Limiter1/Saturation Dynamic
 * '<S27>'  : Controller/Foreground/Control/RHIT Rate Limiter2/Saturation Dynamic
 * '<S28>'  : Controller/Foreground/motohawk_override_abs/NewValue
 * '<S29>'  : Controller/Foreground/motohawk_override_abs/OldValue
 * '<S30>'  : Controller/Foreground/motohawk_override_abs1/NewValue
 * '<S31>'  : Controller/Foreground/motohawk_override_abs1/OldValue
 * '<S32>'  : Controller/Foreground/motohawk_override_abs2/NewValue
 * '<S33>'  : Controller/Foreground/motohawk_override_abs2/OldValue
 * '<S34>'  : Controller/Foreground/motohawk_override_abs3/NewValue
 * '<S35>'  : Controller/Foreground/motohawk_override_abs3/OldValue
 * '<S36>'  : Controller/Foreground/motohawk_override_abs4/NewValue
 * '<S37>'  : Controller/Foreground/motohawk_override_abs4/OldValue
 * '<S38>'  : Controller/Main Power Relay1/Background
 * '<S39>'  : Controller/Main Power Relay1/Background/Delay
 * '<S40>'  : Controller/Main Power Relay1/Background/Display Variable Event Boolean
 * '<S41>'  : Controller/Main Power Relay1/Background/Display Variable Event Function-Call
 * '<S42>'  : Controller/Main Power Relay1/Background/Display Variable Event Function-Call1
 * '<S43>'  : Controller/Main Power Relay1/Background/Post Shutdown two ticks before MPRD off
 * '<S44>'  : Controller/Main Power Relay1/Background/Processor Reboot
 * '<S45>'  : Controller/Main Power Relay1/Background/Save NV Vars one tick before MPRD off
 * '<S46>'  : Controller/Main Power Relay1/Background/Shutdown power on ECU565-128
 * '<S47>'  : Controller/Main Power Relay1/Background/motohawk_override_abs
 * '<S48>'  : Controller/Main Power Relay1/Background/motohawk_restore_nvmem
 * '<S49>'  : Controller/Main Power Relay1/Background/motohawk_store_nvmem
 * '<S50>'  : Controller/Main Power Relay1/Background/Delay/MotoHawk S-R Flip-Flop
 * '<S51>'  : Controller/Main Power Relay1/Background/Display Variable Event Function-Call/Clear
 * '<S52>'  : Controller/Main Power Relay1/Background/Display Variable Event Function-Call1/Clear
 * '<S53>'  : Controller/Main Power Relay1/Background/Post Shutdown two ticks before MPRD off/Post Shutdown two ticks before MPRD off
 * '<S54>'  : Controller/Main Power Relay1/Background/Save NV Vars one tick before MPRD off/Save NV Vars one tick before MPRD off
 * '<S55>'  : Controller/Main Power Relay1/Background/Shutdown power on ECU565-128/Shutdown power on ECU565-128
 * '<S56>'  : Controller/Main Power Relay1/Background/motohawk_override_abs/NewValue
 * '<S57>'  : Controller/Main Power Relay1/Background/motohawk_override_abs/OldValue
 */
#endif                                 /* RTW_HEADER_Controller_h_ */

/* File trailer for Real-Time Workshop generated code.
 *
 * [EOF]
 */
