File: GPCA_SW_Functional.c

    1   /*
    2    * GPCA_SW_Functional.c
    3    *
    4    * Code generation for model "GPCA_SW_Functional".
    5    *
    6    * Model version              : 1.1238
    7    * Simulink Coder version : 8.4 (R2013a) 13-Feb-2013
    8    * C source code generated on : Tue Aug 20 14:29:47 2013
    9    *
   10    * Target selection: grt.tlc
   11    * Note: GRT includes extra infrastructure and instrumentation for prototyping
   12    * Embedded hardware selection: 32-bit Generic
   13    * Code generation objectives: Unspecified
   14    * Validation result: Not run
   15    */
   16   #include "GPCA_SW_Functional.h"
   17   #include "GPCA_SW_Functional_private.h"
   18   
   19   const GPCA_SW_Outputs GPCA_SW_Functional_rtZGPCA_SW_Outputs = {
   20     FALSE,                               /* Request_Confirm_Stop */
   21     0U,                                  /* Log */
   22     0U,                                  /* Current_System_Mode */
   23     0U,                                  /* Actual_Infusion_Duration */
   24     0U,                                  /* Commanded_Flow_Rate */
   25     0U,                                  /* Volume_Infused */
   26     0U,                                  /* Reservoir_Volume */
   27     0U,                                  /* Is_Audio_Disabled */
   28     0U,                                  /* Notification_Message */
   29     0U,                                  /* Audio_Notification_Command */
   30     0U,                                  /* Patient_ID */
   31     0U,                                  /* Drug_Name */
   32     0U,                                  /* Drug_Concentration */
   33     0U,                                  /* Infusion_Total_Duration */
   34     0U,                                  /* VTBI_Total */
   35     0U,                                  /* Flow_Rate_Basal */
   36     0U,                                  /* Flow_Rate_Intermittent_Bolus */
   37     0U,                                  /* Duration_Intermittent_Bolus */
   38     0U,                                  /* Interval_Intermittent_Bolus */
   39     0U,                                  /* Flow_Rate_Patient_Bolus */
   40     0U,                                  /* Duration_Patient_Bolus */
   41     0U,                                  /* Lockout_Period_Patient_Bolus */
   42     0U,                                  /* Max_Number_of_Patient_Bolus */
   43     0U,                                  /* Flow_Rate_KVO */
   44     0U,                                  /* Entered_Reservoir_Volume */
   45     0U,                                  /* Configured */
   46     0U,                                  /* Error_Message_ID */
   47     FALSE,                               /* Request_Config_Type */
   48     FALSE,                               /* Request_Confirm_Infusion_Initiate */
   49     FALSE,                               /* Request_Patient_Drug_Info */
   50     FALSE                                /* Request_Infusion_Info */
   51   } ;                                    /* GPCA_SW_Outputs ground */
   52   
   53   /* Block signals (auto storage) */
   54   B_GPCA_SW_Functional_T GPCA_SW_Functional_B;
   55   
   56   /* Block states (auto storage) */
   57   DW_GPCA_SW_Functional_T GPCA_SW_Functional_DW;
   58   
   59   /* External inputs (root inport signals with auto storage) */
   60   ExtU_GPCA_SW_Functional_T GPCA_SW_Functional_U;
   61   
   62   /* External outputs (root outports fed by signals with auto storage) */
   63   ExtY_GPCA_SW_Functional_T GPCA_SW_Functional_Y;
   64   
   65   /* Real-time model */
   66   RT_MODEL_GPCA_SW_Functional_T GPCA_SW_Functional_M_;
   67   RT_MODEL_GPCA_SW_Functional_T *const GPCA_SW_Functional_M =
   68     &GPCA_SW_Functional_M_;
   69   
   70   /* Model step function */
   71   void GPCA_SW_Functional_step(void)
   72   {
   73     /* local block i/o variables */
   74     Device_Sensor_Inputs rtb_BusConversion_InsertedFor_GPCASOFTWARE_at_inpo;
   75     Device_Configuration_Inputs rtb_BusConversion_InsertedFor_GPCASOFTWARE_at_in_b;
   76     Operator_Commands rtb_BusConversion_InsertedFor_GPCASOFTWARE_at_in_i;
   77     Drug_Database_Inputs rtb_BusConversion_InsertedFor_GPCASOFTWARE_at_in_m;
   78     Prescription_Inputs rtb_BusConversion_InsertedFor_GPCASOFTWARE_at_in_c;
   79     Patient_Inputs rtb_BusConversion_InsertedFor_GPCASOFTWARE_at_i_bo;
   80   
   81     /* BusCreator: '<Root>/BusConversion_InsertedFor_GPCA SOFTWARE_at_inport_0' incorporates:
   82      *  Inport: '<Root>/SENSOR_IN'
   83      */
   84     rtb_BusConversion_InsertedFor_GPCASOFTWARE_at_inpo =
   85       GPCA_SW_Functional_U.SENSOR_IN;
   86   
   87     /* BusCreator: '<Root>/BusConversion_InsertedFor_GPCA SOFTWARE_at_inport_1' incorporates:
   88      *  Inport: '<Root>/CONST_IN'
   89      */
   90     rtb_BusConversion_InsertedFor_GPCASOFTWARE_at_in_b =
   91       GPCA_SW_Functional_U.CONST_IN;
   92   
   93     /* BusCreator: '<Root>/BusConversion_InsertedFor_GPCA SOFTWARE_at_inport_2' incorporates:
   94      *  Inport: '<Root>/OP_CMD_IN'
   95      */
   96     rtb_BusConversion_InsertedFor_GPCASOFTWARE_at_in_i =
   97       GPCA_SW_Functional_U.OP_CMD_IN;
   98   
   99     /* BusCreator: '<Root>/BusConversion_InsertedFor_GPCA SOFTWARE_at_inport_3' incorporates:
  100      *  Inport: '<Root>/DB_IN'
  101      */
  102     rtb_BusConversion_InsertedFor_GPCASOFTWARE_at_in_m =
  103       GPCA_SW_Functional_U.DB_IN;
  104   
  105     /* BusCreator: '<Root>/BusConversion_InsertedFor_GPCA SOFTWARE_at_inport_4' incorporates:
  106      *  Inport: '<Root>/PRES_IN'
  107      */
  108     rtb_BusConversion_InsertedFor_GPCASOFTWARE_at_in_c =
  109       GPCA_SW_Functional_U.PRES_IN;
  110   
  111     /* BusCreator: '<Root>/BusConversion_InsertedFor_GPCA SOFTWARE_at_inport_5' incorporates:
  112      *  Inport: '<Root>/PATIENT_IN'
  113      */
  114     rtb_BusConversion_InsertedFor_GPCASOFTWARE_at_i_bo =
  115       GPCA_SW_Functional_U.PATIENT_IN;
  116   
  117     /* ModelReference: '<Root>/GPCA SOFTWARE' */
  118     GPCA_SW_Logical_Architecture
  119       (&rtb_BusConversion_InsertedFor_GPCASOFTWARE_at_inpo,
  120        &rtb_BusConversion_InsertedFor_GPCASOFTWARE_at_in_b,
  121        &rtb_BusConversion_InsertedFor_GPCASOFTWARE_at_in_i,
  122        &rtb_BusConversion_InsertedFor_GPCASOFTWARE_at_in_m,
  123        &rtb_BusConversion_InsertedFor_GPCASOFTWARE_at_in_c,
  124        &rtb_BusConversion_InsertedFor_GPCASOFTWARE_at_i_bo,
  125        &GPCA_SW_Functional_B.GPCASOFTWARE,
  126        &(GPCA_SW_Functional_DW.GPCASOFTWARE_DWORK1.rtb),
  127        &(GPCA_SW_Functional_DW.GPCASOFTWARE_DWORK1.rtdw));
  128   
  129     /* Outport: '<Root>/GPCA_SW_OUT' incorporates:
  130      *  BusCreator: '<Root>/BusConversion_InsertedFor_GPCA_SW_OUT_at_inport_0'
  131      */
  132     GPCA_SW_Functional_Y.GPCA_SW_OUT = GPCA_SW_Functional_B.GPCASOFTWARE;
  133   
  134     /* Update for ModelReference: '<Root>/GPCA SOFTWARE' */
  135     GPCA_SW_Logical_Architecture_Update
  136       (&(GPCA_SW_Functional_DW.GPCASOFTWARE_DWORK1.rtb),
  137        &(GPCA_SW_Functional_DW.GPCASOFTWARE_DWORK1.rtdw));
  138   
  139     /* Matfile logging */
  140     rt_UpdateTXYLogVars(GPCA_SW_Functional_M->rtwLogInfo,
  141                         (&GPCA_SW_Functional_M->Timing.taskTime0));
  142   
  143     /* signal main to stop simulation */
  144     {                                    /* Sample time: [1.0s, 0.0s] */
  145       if ((rtmGetTFinal(GPCA_SW_Functional_M)!=-1) &&
  146           !((rtmGetTFinal(GPCA_SW_Functional_M)-
  147              GPCA_SW_Functional_M->Timing.taskTime0) >
  148             GPCA_SW_Functional_M->Timing.taskTime0 * (DBL_EPSILON))) {
  149         rtmSetErrorStatus(GPCA_SW_Functional_M, "Simulation finished");
  150       }
  151     }
  152   
  153     /* Update absolute time for base rate */
  154     /* The "clockTick0" counts the number of times the code of this task has
  155      * been executed. The absolute time is the multiplication of "clockTick0"
  156      * and "Timing.stepSize0". Size of "clockTick0" ensures timer will not
  157      * overflow during the application lifespan selected.
  158      * Timer of this task consists of two 32 bit unsigned integers.
  159      * The two integers represent the low bits Timing.clockTick0 and the high bits
  160      * Timing.clockTickH0. When the low bit overflows to 0, the high bits increment.
  161      */
  162     if (!(++GPCA_SW_Functional_M->Timing.clockTick0)) {
  163       ++GPCA_SW_Functional_M->Timing.clockTickH0;
  164     }
  165   
  166     GPCA_SW_Functional_M->Timing.taskTime0 =
  167       GPCA_SW_Functional_M->Timing.clockTick0 *
  168       GPCA_SW_Functional_M->Timing.stepSize0 +
  169       GPCA_SW_Functional_M->Timing.clockTickH0 *
  170       GPCA_SW_Functional_M->Timing.stepSize0 * 4294967296.0;
  171   }
  172   
  173   /* Model initialize function */
  174   void GPCA_SW_Functional_initialize(void)
  175   {
  176     /* Registration code */
  177   
  178     /* initialize non-finites */
  179     rt_InitInfAndNaN(sizeof(real_T));
  180   
  181     /* initialize real-time model */
  182     (void) memset((void *)GPCA_SW_Functional_M, 0,
  183                   sizeof(RT_MODEL_GPCA_SW_Functional_T));
  184     rtmSetTFinal(GPCA_SW_Functional_M, 500.0);
  185     GPCA_SW_Functional_M->Timing.stepSize0 = 1.0;
  186   
  187     /* Setup for data logging */
  188     {
  189       static RTWLogInfo rt_DataLoggingInfo;
  190       GPCA_SW_Functional_M->rtwLogInfo = &rt_DataLoggingInfo;
  191     }
  192   
  193     /* Setup for data logging */
  194     {
  195       rtliSetLogXSignalInfo(GPCA_SW_Functional_M->rtwLogInfo, (NULL));
  196       rtliSetLogXSignalPtrs(GPCA_SW_Functional_M->rtwLogInfo, (NULL));
  197       rtliSetLogT(GPCA_SW_Functional_M->rtwLogInfo, "tout");
  198       rtliSetLogX(GPCA_SW_Functional_M->rtwLogInfo, "");
  199       rtliSetLogXFinal(GPCA_SW_Functional_M->rtwLogInfo, "");
  200       rtliSetSigLog(GPCA_SW_Functional_M->rtwLogInfo, "");
  201       rtliSetLogVarNameModifier(GPCA_SW_Functional_M->rtwLogInfo, "rt_");
  202       rtliSetLogFormat(GPCA_SW_Functional_M->rtwLogInfo, 2);
  203       rtliSetLogMaxRows(GPCA_SW_Functional_M->rtwLogInfo, 1000);
  204       rtliSetLogDecimation(GPCA_SW_Functional_M->rtwLogInfo, 1);
  205       rtliSetLogY(GPCA_SW_Functional_M->rtwLogInfo, "");
  206       rtliSetLogYSignalInfo(GPCA_SW_Functional_M->rtwLogInfo, (NULL));
  207       rtliSetLogYSignalPtrs(GPCA_SW_Functional_M->rtwLogInfo, (NULL));
  208     }
  209   
  210     /* block I/O */
  211     (void) memset(((void *) &GPCA_SW_Functional_B), 0,
  212                   sizeof(B_GPCA_SW_Functional_T));
  213   
  214     /* states (dwork) */
  215     (void) memset((void *)&GPCA_SW_Functional_DW, 0,
  216                   sizeof(DW_GPCA_SW_Functional_T));
  217   
  218     /* external inputs */
  219     (void) memset((void *)&GPCA_SW_Functional_U, 0,
  220                   sizeof(ExtU_GPCA_SW_Functional_T));
  221   
  222     /* external outputs */
  223     GPCA_SW_Functional_Y.GPCA_SW_OUT = GPCA_SW_Functional_rtZGPCA_SW_Outputs;
  224   
  225     /* Model Initialize fcn for ModelReference Block: '<Root>/GPCA SOFTWARE' */
  226     GPCA_SW_Logical_Architecture_initialize(rtmGetErrorStatusPointer
  227       (GPCA_SW_Functional_M), &(GPCA_SW_Functional_DW.GPCASOFTWARE_DWORK1.rtm),
  228       &(GPCA_SW_Functional_DW.GPCASOFTWARE_DWORK1.rtb),
  229       &(GPCA_SW_Functional_DW.GPCASOFTWARE_DWORK1.rtdw));
  230   
  231     /* Matfile logging */
  232     rt_StartDataLoggingWithStartTime(GPCA_SW_Functional_M->rtwLogInfo, 0.0,
  233       rtmGetTFinal(GPCA_SW_Functional_M), GPCA_SW_Functional_M->Timing.stepSize0,
  234                                      (&rtmGetErrorStatus(GPCA_SW_Functional_M)));
  235   
  236     /* InitializeConditions for ModelReference: '<Root>/GPCA SOFTWARE' */
  237     GPCA_SW_Logical_Architecture_Init
  238       (&(GPCA_SW_Functional_DW.GPCASOFTWARE_DWORK1.rtdw));
  239   }
  240   
  241   /* Model terminate function */
  242   void GPCA_SW_Functional_terminate(void)
  243   {
  244     /* (no terminate code required) */
  245   }
  246