/* Include files */

#include "Master_sfun.h"
#include "c1_Master.h"
#include "c2_Master.h"
#include "c3_Master.h"
#include "c4_Master.h"
#include "c5_Master.h"
#include "c6_Master.h"

/* Type Definitions */

/* Named Constants */

/* Variable Declarations */

/* Variable Definitions */
uint8_T _sfEvent_;
uint32_T _MasterMachineNumber_;
real_T _sfTime_;

/* Function Declarations */

/* Function Definitions */
void Master_initializer(void)
{
  _sfEvent_ = CALL_EVENT;
}

void Master_terminator(void)
{
}

/* SFunction Glue Code */
unsigned int sf_Master_method_dispatcher(SimStruct *simstructPtr, unsigned int
  chartFileNumber, int_T method, void *data)
{
  if (chartFileNumber==1) {
    c1_Master_method_dispatcher(simstructPtr, method, data);
    return 1;
  }

  if (chartFileNumber==2) {
    c2_Master_method_dispatcher(simstructPtr, method, data);
    return 1;
  }

  if (chartFileNumber==3) {
    c3_Master_method_dispatcher(simstructPtr, method, data);
    return 1;
  }

  if (chartFileNumber==4) {
    c4_Master_method_dispatcher(simstructPtr, method, data);
    return 1;
  }

  if (chartFileNumber==5) {
    c5_Master_method_dispatcher(simstructPtr, method, data);
    return 1;
  }

  if (chartFileNumber==6) {
    c6_Master_method_dispatcher(simstructPtr, method, data);
    return 1;
  }

  return 0;
}

unsigned int sf_Master_process_check_sum_call( int nlhs, mxArray * plhs[], int
  nrhs, const mxArray * prhs[] )
{

#ifdef MATLAB_MEX_FILE

  char commandName[20];
  if (nrhs<1 || !mxIsChar(prhs[0]) )
    return 0;

  /* Possible call to get the checksum */
  mxGetString(prhs[0], commandName,sizeof(commandName)/sizeof(char));
  commandName[(sizeof(commandName)/sizeof(char)-1)] = '\0';
  if (strcmp(commandName,"sf_get_check_sum"))
    return 0;
  plhs[0] = mxCreateDoubleMatrix( 1,4,mxREAL);
  if (nrhs>1 && mxIsChar(prhs[1])) {
    mxGetString(prhs[1], commandName,sizeof(commandName)/sizeof(char));
    commandName[(sizeof(commandName)/sizeof(char)-1)] = '\0';
    if (!strcmp(commandName,"machine")) {
      ((real_T *)mxGetPr((plhs[0])))[0] = (real_T)(3715102292U);
      ((real_T *)mxGetPr((plhs[0])))[1] = (real_T)(2346991771U);
      ((real_T *)mxGetPr((plhs[0])))[2] = (real_T)(956330205U);
      ((real_T *)mxGetPr((plhs[0])))[3] = (real_T)(335243644U);
    } else if (!strcmp(commandName,"exportedFcn")) {
      ((real_T *)mxGetPr((plhs[0])))[0] = (real_T)(0U);
      ((real_T *)mxGetPr((plhs[0])))[1] = (real_T)(0U);
      ((real_T *)mxGetPr((plhs[0])))[2] = (real_T)(0U);
      ((real_T *)mxGetPr((plhs[0])))[3] = (real_T)(0U);
    } else if (!strcmp(commandName,"makefile")) {
      ((real_T *)mxGetPr((plhs[0])))[0] = (real_T)(3464746237U);
      ((real_T *)mxGetPr((plhs[0])))[1] = (real_T)(4273214104U);
      ((real_T *)mxGetPr((plhs[0])))[2] = (real_T)(1180840797U);
      ((real_T *)mxGetPr((plhs[0])))[3] = (real_T)(2019476679U);
    } else if (nrhs==3 && !strcmp(commandName,"chart")) {
      unsigned int chartFileNumber;
      chartFileNumber = (unsigned int)mxGetScalar(prhs[2]);
      switch (chartFileNumber) {
       case 1:
        {
          extern void sf_c1_Master_get_check_sum(mxArray *plhs[]);
          sf_c1_Master_get_check_sum(plhs);
          break;
        }

       case 2:
        {
          extern void sf_c2_Master_get_check_sum(mxArray *plhs[]);
          sf_c2_Master_get_check_sum(plhs);
          break;
        }

       case 3:
        {
          extern void sf_c3_Master_get_check_sum(mxArray *plhs[]);
          sf_c3_Master_get_check_sum(plhs);
          break;
        }

       case 4:
        {
          extern void sf_c4_Master_get_check_sum(mxArray *plhs[]);
          sf_c4_Master_get_check_sum(plhs);
          break;
        }

       case 5:
        {
          extern void sf_c5_Master_get_check_sum(mxArray *plhs[]);
          sf_c5_Master_get_check_sum(plhs);
          break;
        }

       case 6:
        {
          extern void sf_c6_Master_get_check_sum(mxArray *plhs[]);
          sf_c6_Master_get_check_sum(plhs);
          break;
        }

       default:
        ((real_T *)mxGetPr((plhs[0])))[0] = (real_T)(0.0);
        ((real_T *)mxGetPr((plhs[0])))[1] = (real_T)(0.0);
        ((real_T *)mxGetPr((plhs[0])))[2] = (real_T)(0.0);
        ((real_T *)mxGetPr((plhs[0])))[3] = (real_T)(0.0);
      }
    } else if (!strcmp(commandName,"target")) {
      ((real_T *)mxGetPr((plhs[0])))[0] = (real_T)(687034110U);
      ((real_T *)mxGetPr((plhs[0])))[1] = (real_T)(345661051U);
      ((real_T *)mxGetPr((plhs[0])))[2] = (real_T)(3115312863U);
      ((real_T *)mxGetPr((plhs[0])))[3] = (real_T)(2219695150U);
    } else {
      return 0;
    }
  } else {
    ((real_T *)mxGetPr((plhs[0])))[0] = (real_T)(1455742655U);
    ((real_T *)mxGetPr((plhs[0])))[1] = (real_T)(673726904U);
    ((real_T *)mxGetPr((plhs[0])))[2] = (real_T)(604691842U);
    ((real_T *)mxGetPr((plhs[0])))[3] = (real_T)(53467205U);
  }

  return 1;

#else

  return 0;

#endif

}

unsigned int sf_Master_autoinheritance_info( int nlhs, mxArray * plhs[], int
  nrhs, const mxArray * prhs[] )
{

#ifdef MATLAB_MEX_FILE

  char commandName[32];
  if (nrhs<2 || !mxIsChar(prhs[0]) )
    return 0;

  /* Possible call to get the autoinheritance_info */
  mxGetString(prhs[0], commandName,sizeof(commandName)/sizeof(char));
  commandName[(sizeof(commandName)/sizeof(char)-1)] = '\0';
  if (strcmp(commandName,"get_autoinheritance_info"))
    return 0;

  {
    unsigned int chartFileNumber;
    chartFileNumber = (unsigned int)mxGetScalar(prhs[1]);
    switch (chartFileNumber) {
     case 1:
      {
        extern mxArray *sf_c1_Master_get_autoinheritance_info(void);
        plhs[0] = sf_c1_Master_get_autoinheritance_info();
        break;
      }

     case 2:
      {
        extern mxArray *sf_c2_Master_get_autoinheritance_info(void);
        plhs[0] = sf_c2_Master_get_autoinheritance_info();
        break;
      }

     case 3:
      {
        extern mxArray *sf_c3_Master_get_autoinheritance_info(void);
        plhs[0] = sf_c3_Master_get_autoinheritance_info();
        break;
      }

     case 4:
      {
        extern mxArray *sf_c4_Master_get_autoinheritance_info(void);
        plhs[0] = sf_c4_Master_get_autoinheritance_info();
        break;
      }

     case 5:
      {
        extern mxArray *sf_c5_Master_get_autoinheritance_info(void);
        plhs[0] = sf_c5_Master_get_autoinheritance_info();
        break;
      }

     case 6:
      {
        extern mxArray *sf_c6_Master_get_autoinheritance_info(void);
        plhs[0] = sf_c6_Master_get_autoinheritance_info();
        break;
      }

     default:
      plhs[0] = mxCreateDoubleMatrix(0,0,mxREAL);
    }
  }

  return 1;

#else

  return 0;

#endif

}

unsigned int sf_Master_get_eml_resolved_functions_info( int nlhs, mxArray *
  plhs[], int nrhs, const mxArray * prhs[] )
{

#ifdef MATLAB_MEX_FILE

  char commandName[64];
  if (nrhs<2 || !mxIsChar(prhs[0]))
    return 0;

  /* Possible call to get the get_eml_resolved_functions_info */
  mxGetString(prhs[0], commandName,sizeof(commandName)/sizeof(char));
  commandName[(sizeof(commandName)/sizeof(char)-1)] = '\0';
  if (strcmp(commandName,"get_eml_resolved_functions_info"))
    return 0;

  {
    unsigned int chartFileNumber;
    chartFileNumber = (unsigned int)mxGetScalar(prhs[1]);
    switch (chartFileNumber) {
     case 1:
      {
        extern const mxArray *sf_c1_Master_get_eml_resolved_functions_info(void);
        mxArray *persistentMxArray = (mxArray *)
          sf_c1_Master_get_eml_resolved_functions_info();
        plhs[0] = mxDuplicateArray(persistentMxArray);
        mxDestroyArray(persistentMxArray);
        break;
      }

     case 2:
      {
        extern const mxArray *sf_c2_Master_get_eml_resolved_functions_info(void);
        mxArray *persistentMxArray = (mxArray *)
          sf_c2_Master_get_eml_resolved_functions_info();
        plhs[0] = mxDuplicateArray(persistentMxArray);
        mxDestroyArray(persistentMxArray);
        break;
      }

     case 3:
      {
        extern const mxArray *sf_c3_Master_get_eml_resolved_functions_info(void);
        mxArray *persistentMxArray = (mxArray *)
          sf_c3_Master_get_eml_resolved_functions_info();
        plhs[0] = mxDuplicateArray(persistentMxArray);
        mxDestroyArray(persistentMxArray);
        break;
      }

     case 4:
      {
        extern const mxArray *sf_c4_Master_get_eml_resolved_functions_info(void);
        mxArray *persistentMxArray = (mxArray *)
          sf_c4_Master_get_eml_resolved_functions_info();
        plhs[0] = mxDuplicateArray(persistentMxArray);
        mxDestroyArray(persistentMxArray);
        break;
      }

     case 5:
      {
        extern const mxArray *sf_c5_Master_get_eml_resolved_functions_info(void);
        mxArray *persistentMxArray = (mxArray *)
          sf_c5_Master_get_eml_resolved_functions_info();
        plhs[0] = mxDuplicateArray(persistentMxArray);
        mxDestroyArray(persistentMxArray);
        break;
      }

     case 6:
      {
        extern const mxArray *sf_c6_Master_get_eml_resolved_functions_info(void);
        mxArray *persistentMxArray = (mxArray *)
          sf_c6_Master_get_eml_resolved_functions_info();
        plhs[0] = mxDuplicateArray(persistentMxArray);
        mxDestroyArray(persistentMxArray);
        break;
      }

     default:
      plhs[0] = mxCreateDoubleMatrix(0,0,mxREAL);
    }
  }

  return 1;

#else

  return 0;

#endif

}

void Master_debug_initialize(void)
{
  _MasterMachineNumber_ = sf_debug_initialize_machine("Master","sfun",0,6,0,0,0);
  sf_debug_set_machine_event_thresholds(_MasterMachineNumber_,0,0);
  sf_debug_set_machine_data_thresholds(_MasterMachineNumber_,0);
}

void Master_register_exported_symbols(SimStruct* S)
{
}
