    1/*

    2 * File: ert_main.c

    3 *

    4 * Code generated for Simulink model 'automats'.

    5 *

    6 * Model version                  : 1.33

    7 * Simulink Coder version         : 9.4 (R2020b) 29-Jul-2020

    8 * C/C++ source code generated on : Thu May 13 21:48:38 2021

    9 *

    10 * Target selection: ert.tlc

    11 * Embedded hardware selection: AMD->x86-64 (Windows64)

    12 * Code generation objectives:

    13 *    1. Execution efficiency

    14 *    2. RAM efficiency

    15 * Validation result: Not run

    16 */

    17

    18#include <stddef.h>

    19#include <stdio.h>              /* This ert_main.c example uses printf/fflush */

    20#include "automats.h"                  /* Model's header file */

    21#include "rtwtypes.h"

    22

    23/*

    24 * Associating rt_OneStep with a real-time clock or interrupt service routine

    25 * is what makes the generated code "real-time".  The function rt_OneStep is

    26 * always associated with the base rate of the model.  Subrates are managed

    27 * by the base rate from inside the generated code.  Enabling/disabling

    28 * interrupts and floating point context switches are target specific.  This

    29 * example code indicates where these should take place relative to executing

    30 * the generated code step function.  Overrun behavior should be tailored to

    31 * your application needs.  This example simply sets an error status in the

    32 * real-time model and returns from rt_OneStep.

    33 */

    34void rt_OneStep(void);

    35void rt_OneStep(void)

    36{

    37  static boolean_T OverrunFlag = false;

    38

    39  /* Disable interrupts here */

    40

    41  /* Check for overrun */

    42  if (OverrunFlag) {

    43    rtmSetErrorStatus(rtM, "Overrun");

    44    return;

    45  }

    46

    47  OverrunFlag = true;

    48

    49  /* Save FPU context here (if necessary) */

    50  /* Re-enable timer or interrupt here */

    51  /* Set model inputs here */

    52

    53  /* Step the model */

    54  automats_step();

    55

    56  /* Get model outputs here */

    57

    58  /* Indicate task complete */

    59  OverrunFlag = false;

    60

    61  /* Disable interrupts here */

    62  /* Restore FPU context here (if necessary) */

    63  /* Enable interrupts here */

    64}

    65

    66/*

    67 * The example "main" function illustrates what is required by your

    68 * application code to initialize, execute, and terminate the generated code.

    69 * Attaching rt_OneStep to a real-time clock is target specific.  This example

    70 * illustrates how you do this relative to initializing the model.

    71 */

    72int_T main(int_T argc, const char *argv[])

    73{

    74  /* Unused arguments */

    75  (void)(argc);

    76  (void)(argv);

    77

    78  /* Initialize model */

    79  automats_initialize();

    80

    81  /* Attach rt_OneStep to a timer or interrupt service routine with

    82   * period 0.0001 seconds (the model's base sample time) here.  The

    83   * call syntax for rt_OneStep is

    84   *

    85   *  rt_OneStep();

    86   */

    87  printf("Warning: The simulation will run forever. "

    88         "Generated ERT main won't simulate model step behavior. "

    89         "To change this behavior select the 'MAT-file logging' option.\n");

    90  fflush((NULL));

    91  while (rtmGetErrorStatus(rtM) == (NULL)) {

    92    /*  Perform other application tasks here */

    93  }

    94

    95  /* Disable rt_OneStep() here */

    96  return 0;

    97}

    98

    99/*

    100 * File trailer for generated code.

    101 *

    102 * [EOF]

    103 */

    104