File: Logging_Functional.c

    1   /*
    2    * Code generation for system model 'Logging_Functional'
    3    *
    4    * Model                      : Logging_Functional
    5    * Model version              : 1.1169
    6    * Simulink Coder version : 8.4 (R2013a) 13-Feb-2013
    7    * C source code generated on : Thu Sep 12 09:50:07 2013
    8    *
    9    * Note that the functions contained in this file are part of a Simulink
   10    * model, and are not self-contained algorithms.
   11    */
   12   
   13   #include "Logging_Functional.h"
   14   #include "Logging_Functional_private.h"
   15   
   16   /* Named constants for Chart: '<Root>/Log Sub-System' */
   17   #define Logging_Functional_IN_NOT_ON   ((uint8_T)1U)
   18   #define Logging_Functional_IN_NO_ACTIVE_CHILD ((uint8_T)0U)
   19   #define Logging_Functional_IN_TOP_Level_Mode ((uint8_T)2U)
   20   
   21   /* Forward declaration for local functions */
   22   static void Logging_Functional_writeLog(B_Logging_Functional_c_T *localB);
   23   
   24   /* Function for Chart: '<Root>/Log Sub-System' */
   25   static void Logging_Functional_writeLog(B_Logging_Functional_c_T *localB)
   26   {
   27     /* Graphical Function 'writeLog': '<S1>:4055' */
   28     /* Transition: '<S1>:4059' */
   29     localB->LOGGING_OUT_Log = 0U;
   30     if ((localB->Log_Message_ID_n > 0) || (localB->Log_Message_ID_eue > 0) ||
   31         (localB->Log_Message_ID > 0) || (localB->Log_Message_ID_e > 0) ||
   32         (localB->Log_Message_ID_eu > 0)) {
   33       /* Transition: '<S1>:4057' */
   34       localB->LOGGING_OUT_Log = 1U;
   35     }
   36   }
   37   
   38   /* Initial conditions for referenced model: 'Logging_Functional' */
   39   void Logging_Functional_Init(B_Logging_Functional_c_T *localB,
   40     DW_Logging_Functional_f_T *localDW)
   41   {
   42     /* InitializeConditions for Chart: '<Root>/Log Sub-System' */
   43     localDW->is_active_c2_Logging_Functional = 0U;
   44     localDW->is_c2_Logging_Functional = Logging_Functional_IN_NO_ACTIVE_CHILD;
   45     localB->LOGGING_OUT_Log = 0U;
   46     localB->LOGGING_OUT_Logging_Failed = FALSE;
   47   }
   48   
   49   /* Output and update for referenced model: 'Logging_Functional' */
   50   void Logging_Functional(const Top_Level_Mode_Outputs *rtu_TLM_MODE_IN, const
   51     Config_Outputs *rtu_CONFIG_IN, const Alarm_Outputs *rtu_ALARM_IN, const
   52     System_Status_Outputs *rtu_SYS_STAT_IN, const Infusion_Manager_Outputs
   53     *rtu_IM_IN, Log_Output *rty_LOG_OUT, B_Logging_Functional_c_T *localB,
   54     DW_Logging_Functional_f_T *localDW)
   55   {
   56     /* BusSelector: '<Root>/BusConversion_InsertedFor_ALARM_IN_at_outport_0' */
   57     localB->Log_Message_ID = rtu_ALARM_IN->Log_Message_ID;
   58   
   59     /* BusSelector: '<Root>/BusConversion_InsertedFor_CONFIG_IN_at_outport_0' */
   60     localB->Log_Message_ID_e = rtu_CONFIG_IN->Log_Message_ID;
   61   
   62     /* BusSelector: '<Root>/BusConversion_InsertedFor_IM_IN_at_outport_0' */
   63     localB->Log_Message_ID_eu = rtu_IM_IN->Log_Message_ID;
   64   
   65     /* BusSelector: '<Root>/BusConversion_InsertedFor_TLM_MODE_IN_at_outport_0' */
   66     localB->Log_Message_ID_n = rtu_TLM_MODE_IN->Log_Message_ID;
   67   
   68     /* BusSelector: '<Root>/BusConversion_InsertedFor_SYS_STAT_IN_at_outport_0' */
   69     localB->Log_Message_ID_eue = rtu_SYS_STAT_IN->Log_Message_ID;
   70   
   71     /* Chart: '<Root>/Log Sub-System' incorporates:
   72      *  BusSelector: '<Root>/BusConversion_InsertedFor_TLM_MODE_IN_at_outport_0'
   73      */
   74     /* Gateway: Log Sub-System */
   75     /* During: Log Sub-System */
   76     if (localDW->is_active_c2_Logging_Functional == 0U) {
   77       /* Entry: Log Sub-System */
   78       localDW->is_active_c2_Logging_Functional = 1U;
   79   
   80       /* Entry Internal: Log Sub-System */
   81       if (rtu_TLM_MODE_IN->System_On) {
   82         /* Transition: '<S1>:4040' */
   83         localDW->is_c2_Logging_Functional = Logging_Functional_IN_TOP_Level_Mode;
   84   
   85         /* Entry 'TOP_Level_Mode': '<S1>:4024' */
   86         localB->LOGGING_OUT_Logging_Failed = FALSE;
   87         Logging_Functional_writeLog(localB);
   88       } else {
   89         /* Transition: '<S1>:4038' */
   90         localDW->is_c2_Logging_Functional = Logging_Functional_IN_NOT_ON;
   91   
   92         /* Entry 'NOT_ON': '<S1>:4034' */
   93         localB->LOGGING_OUT_Log = 0U;
   94       }
   95     } else if (localDW->is_c2_Logging_Functional == Logging_Functional_IN_NOT_ON)
   96     {
   97       /* During 'NOT_ON': '<S1>:4034' */
   98       if (rtu_TLM_MODE_IN->System_On) {
   99         /* Transition: '<S1>:4042' */
  100         /* Exit 'NOT_ON': '<S1>:4034' */
  101         localB->LOGGING_OUT_Log = 0U;
  102         localDW->is_c2_Logging_Functional = Logging_Functional_IN_TOP_Level_Mode;
  103   
  104         /* Entry 'TOP_Level_Mode': '<S1>:4024' */
  105         localB->LOGGING_OUT_Logging_Failed = FALSE;
  106         Logging_Functional_writeLog(localB);
  107       } else {
  108         localB->LOGGING_OUT_Log = 0U;
  109       }
  110     } else {
  111       /* During 'TOP_Level_Mode': '<S1>:4024' */
  112       if (!rtu_TLM_MODE_IN->System_On) {
  113         /* Transition: '<S1>:4039' */
  114         /* Exit 'TOP_Level_Mode': '<S1>:4024' */
  115         localB->LOGGING_OUT_Logging_Failed = FALSE;
  116         Logging_Functional_writeLog(localB);
  117         localDW->is_c2_Logging_Functional = Logging_Functional_IN_NOT_ON;
  118   
  119         /* Entry 'NOT_ON': '<S1>:4034' */
  120         localB->LOGGING_OUT_Log = 0U;
  121       } else {
  122         localB->LOGGING_OUT_Logging_Failed = FALSE;
  123         Logging_Functional_writeLog(localB);
  124       }
  125     }
  126   
  127     /* End of Chart: '<Root>/Log Sub-System' */
  128   
  129     /* BusCreator: '<Root>/BusConversion_InsertedFor_LOG_OUT_at_inport_0' */
  130     rty_LOG_OUT->Log = localB->LOGGING_OUT_Log;
  131     rty_LOG_OUT->Logging_Failed = localB->LOGGING_OUT_Logging_Failed;
  132   }
  133   
  134   /* Model initialize function */
  135   void Logging_Functional_initialize(const char_T **rt_errorStatus,
  136     RT_MODEL_Logging_Functional_T *const Logging_Functional_M,
  137     B_Logging_Functional_c_T *localB, DW_Logging_Functional_f_T *localDW)
  138   {
  139     /* Registration code */
  140   
  141     /* initialize error status */
  142     rtmSetErrorStatusPointer(Logging_Functional_M, rt_errorStatus);
  143   
  144     /* block I/O */
  145     (void) memset(((void *) localB), 0,
  146                   sizeof(B_Logging_Functional_c_T));
  147   
  148     /* states (dwork) */
  149     (void) memset((void *)localDW, 0,
  150                   sizeof(DW_Logging_Functional_f_T));
  151   }
  152