Ejemplo n.º 1
0
/* Function: mdlUpdate ======================================================
   * Abstract:
   *    This function is called once for every major integration time step.
   *    Discrete states are typically updated here, but this function is useful
   *    for performing any tasks that should only take place once per
   *    integration step.
   */
static void mdlUpdate(SimStruct *S, int_T tid)
{
    const real_T *p  = (const real_T *)ssGetOutputPortRealSignal(S,0);
    const real_T *T  = (const real_T *)ssGetOutputPortRealSignal(S,1);
    const real_T *F  = (const real_T *)ssGetOutputPortRealSignal(S,2);
    const real_T  *fs  = (const real_T *)mxGetData(PARAM_DEF0(S));
    
    real_T *T_prev = (real_T*) ssGetDWork(S,0);
    
	real_T *R_prev = (real_T*) ssGetDWork(S,1);

    real_T *u_prev = (real_T*) ssGetDWork(S,2);
    
    real_T *Cv_prev = (real_T*) ssGetDWork(S,3);
    
    
    real_T R,h,s,u,uP,uT,uF,RP,RT,RF,sP,sT,sF,Cp,Cv,K;
    
    GetThdynCombGasZachV1(*p,*T,*F,fs[0],&R,&h,&s,&u,&RF,&RP,&RT,&uF,&uP,
            &uT,&sF,&sP,&sT,&Cp,&Cv,&K);
    
    
    *T_prev = *T;
	*R_prev = R;
    *u_prev = u;
    *Cv_prev = Cv;
}
Ejemplo n.º 2
0
/* Function: mdlOutputs =======================================================
 *
*/
static void mdlOutputs(SimStruct *S, int_T tid)
{
    const real_T   *phi  = (const real_T*) ssGetInputPortSignal(S,0);
    const real_T   *phiInj  = (const real_T*) ssGetInputPortSignal(S,1);
    const real_T   *uGov  = (const real_T*) ssGetInputPortSignal(S,2);
    const real_T   *omega  = (const real_T*) ssGetInputPortSignal(S,3);
    const real_T   *p  = (const real_T*) ssGetInputPortSignal(S,4);
    const real_T   *temp  = (const real_T*) ssGetInputPortSignal(S,5);
    real_T        *combStateO  = (real_T *)ssGetOutputPortRealSignal(S,0);
    real_T        *phiComb  = (real_T *)ssGetOutputPortRealSignal(S,1);
    real_T        *phiIgO  = (real_T *)ssGetOutputPortRealSignal(S,2);
    real_T        *mqfO  = (real_T *)ssGetOutputPortRealSignal(S,3);
    const int_T   p_width0  = mxGetNumberOfElements(PARAM_DEF0(S));
    const int_T   p_width1  = mxGetNumberOfElements(PARAM_DEF1(S));
    const int_T   p_width2  = mxGetNumberOfElements(PARAM_DEF2(S));
    const real_T  *mqfCycMax  = (const real_T *)mxGetData(PARAM_DEF0(S));
    const real_T  *wiebePara  = (const real_T *)mxGetData(PARAM_DEF1(S));
    const real_T  *nStroke  = (const real_T *)mxGetData(PARAM_DEF2(S));
    const real_T *combState = (const real_T*) ssGetDWork(S,0);
    const real_T *phiIg = (const real_T*) ssGetDWork(S,1);
    const real_T *mqf = (const real_T*) ssGetDWork(S,2);
    
    combState_Outputs_wrapper(phi, phiInj, uGov, omega, temp, p, combState, 
            phiIg, mqf, combStateO, phiComb, phiIgO, mqfO, mqfCycMax, 
            p_width0, wiebePara, p_width1, nStroke, p_width2);
}
Ejemplo n.º 3
0
  /* Function: mdlStart =======================================================
   * Abstract:
   *    This function is called once at start of model execution. If you
   *    have states that should be initialized once, this is the place
   *    to do it.
   */
  static void mdlStart(SimStruct *S)
  {
      struct comStruc_IN **dataIN = (struct comStruc_IN**) ssGetDWork(S,DVECSHMIN);
      struct comStruc_OUT **dataOUT = (struct comStruc_OUT**) ssGetDWork(S,DVECSHMOUT);
#ifdef _WIN32
#else
      dataIN[0] = rtai_malloc(nam2num(SHMNAM_IN), sizeof(struct comStruc_IN));
      dataOUT[0] = rtai_malloc(nam2num(SHMNAM_OUT), sizeof(struct comStruc_OUT));
      printf("OUT: %d, IN: %d\n", sizeof(struct comStruc_OUT), sizeof(struct comStruc_IN));
#endif
  }
Ejemplo n.º 4
0
/* Function: mdlTerminate =====================================================
 * Abstract:
 *    In this function, you should perform any actions that are necessary
 *    at the termination of a simulation.  For example, if memory was
 *    allocated in mdlStart, this is the place to free it.
 */
static void mdlTerminate(SimStruct *S)
{
      struct comStruc_IN **dataIN = (struct comStruc_IN**) ssGetDWork(S,DVECSHMIN);
      struct comStruc_OUT **dataOUT = (struct comStruc_IN**) ssGetDWork(S,DVECSHMOUT);
#ifdef _WIN32
#else
      rtai_free(nam2num(SHMNAM_IN), dataIN[0]);
      rtai_free(nam2num(SHMNAM_OUT), dataOUT[0]);
      printf("%s\n", "terminate");
#endif

}
static void mdlStart(SimStruct *S)
{
    char *bufSimEng;  // SIMULATION_ENGINE
    int bufSimEngLen;

    // Build the list of parameters that configure the tres::Network
    std::vector<std::string> ns_params = readMaskAndBuildConfVector(S);

    // Get the type of the adapter, i.e., the concrete implementation of tres::Network
    bufSimEngLen = mxGetN( ssGetSFcnParam(S,SIMULATION_ENGINE) )+1;
    bufSimEng = new char[bufSimEngLen];
    mxGetString(ssGetSFcnParam(S,SIMULATION_ENGINE), bufSimEng, bufSimEngLen);
    std::string engine(bufSimEng);
    delete bufSimEng;

    // Instantiate the concrete representation of tres::Network
    std::unique_ptr<tres::Network> ns = Factory<tres::Network>::instance()
                                                    .create(engine, ns_params);

    // Save the C++ object to the pointers vector
    tres::Network *_ns = ns.release();
    ssGetPWork(S)[0] = _ns;

    // Set the `New pending activations available' flag to false
    boolean_T *pendingActivsAvail = (boolean_T*) ssGetDWork(S,0);
    pendingActivsAvail[0] = false;

    // Get the time resolution (actually, its floating point representation)
    std::vector<std::string>::iterator it = ns_params.end()-1;
    double time_resolution = atof((*it).c_str());

    // Save the time resolution to the real vector workspace
    ssGetRWork(S)[0] = time_resolution;
}
static const mxArray *get_sim_state_c20_adcs_v15_integral_Power_nom(void)
{
  const mxArray *c20_st = NULL;
  const mxArray *c20_y = NULL;
  int32_T c20_i0;
  real_T c20_u[3];
  const mxArray *c20_b_y = NULL;
  uint8_T c20_b_u;
  const mxArray *c20_c_y = NULL;
  uint8_T *c20_is_active_c20_adcs_v15_integral_Power_nom;
  real_T (*c20_v_B)[3];
  c20_is_active_c20_adcs_v15_integral_Power_nom = (uint8_T *)ssGetDWork
    (chartInstance.S, 2);
  c20_v_B = (real_T (*)[3])ssGetOutputPortSignal(chartInstance.S, 1);
  c20_st = NULL;
  c20_y = NULL;
  sf_mex_assign(&c20_y, sf_mex_createcellarray(2));
  for (c20_i0 = 0; c20_i0 < 3; c20_i0 = c20_i0 + 1) {
    c20_u[c20_i0] = (*c20_v_B)[c20_i0];
  }

  c20_b_y = NULL;
  sf_mex_assign(&c20_b_y, sf_mex_create("y", &c20_u, 0, 0U, 1U, 0U, 1, 3));
  sf_mex_setcell(c20_y, 0, c20_b_y);
  c20_b_u = *c20_is_active_c20_adcs_v15_integral_Power_nom;
  c20_c_y = NULL;
  sf_mex_assign(&c20_c_y, sf_mex_create("y", &c20_b_u, 3, 0U, 0U, 0U, 0));
  sf_mex_setcell(c20_y, 1, c20_c_y);
  sf_mex_assign(&c20_st, c20_y);
  return c20_st;
}
static const mxArray *get_sim_state_c31_adcs_v15_integral_Power_nom(void)
{
  const mxArray *c31_st = NULL;
  const mxArray *c31_y = NULL;
  real_T c31_u;
  const mxArray *c31_b_y = NULL;
  uint8_T c31_b_u;
  const mxArray *c31_c_y = NULL;
  real_T *c31_pow_drawn;
  uint8_T *c31_is_active_c31_adcs_v15_integral_Power_nom;
  c31_is_active_c31_adcs_v15_integral_Power_nom = (uint8_T *)ssGetDWork
    (chartInstance.S, 2);
  c31_pow_drawn = (real_T *)ssGetOutputPortSignal(chartInstance.S, 1);
  c31_st = NULL;
  c31_y = NULL;
  sf_mex_assign(&c31_y, sf_mex_createcellarray(2));
  c31_u = *c31_pow_drawn;
  c31_b_y = NULL;
  sf_mex_assign(&c31_b_y, sf_mex_create("y", &c31_u, 0, 0U, 0U, 0U, 0));
  sf_mex_setcell(c31_y, 0, c31_b_y);
  c31_b_u = *c31_is_active_c31_adcs_v15_integral_Power_nom;
  c31_c_y = NULL;
  sf_mex_assign(&c31_c_y, sf_mex_create("y", &c31_b_u, 3, 0U, 0U, 0U, 0));
  sf_mex_setcell(c31_y, 1, c31_c_y);
  sf_mex_assign(&c31_st, c31_y);
  return c31_st;
}
/* Function Definitions */
static void initialize_c4_Gravity_Well(void)
{
  uint8_T *c4_is_active_c4_Gravity_Well;
  c4_is_active_c4_Gravity_Well = (uint8_T *)ssGetDWork(chartInstance.S, 1);
  _sfTime_ = (real_T)ssGetT(chartInstance.S);
  *c4_is_active_c4_Gravity_Well = 0U;
}
Ejemplo n.º 9
0
 /* Function: mdlInitializeConditions ========================================
  * Abstract:
  *    Initialize the states
  */
 static void mdlInitializeConditions(SimStruct *S)
 {
   #define MDL_INITIALIZE_CONDITIONS
/* Function: mdlInitializeConditions ============================
* Abstract:
* Initialize both continuous states to zero
*/
    real_T *x1 = (real_T*) ssGetDWork(S,0);
    real_T *x2 = (real_T*) ssGetDWork(S,1);
    real_T *x3 = (real_T*) ssGetDWork(S,2);

    /* Initialize the dwork to 0 */
    x1[0] = 0;  // combustion state
    x2[0] = 0;  // ignition delay
    x3[0] = 0;  // mass of fuel injected
}
Ejemplo n.º 10
0
static void mdlUpdate(SimStruct *S, int_T tid)
{
  UNUSED(tid);
  struct timeval tv;
  gettimeofday(&tv, NULL);

  double *wall_t0 = (double*) ssGetDWork(S,0);
  if (*wall_t0 == TIME_NOT_YET_SET) {
    // t0 not set yet, set it now.  (note: used to set this in mdlStart, but there can be a big pause between mdlStart and the full simulation start)
    *wall_t0 = timevalToDouble(tv);
    return;
  }

  double wall_t = timevalToDouble(tv),
  			simtime = ssGetT(S),
  			realtime_factor = mxGetScalar(ssGetSFcnParam(S, 1));

  double t_diff = (wall_t - *wall_t0)*realtime_factor - simtime;
// mexPrintf("wall time: %f, sim time: %f, (scaled) diff: %f\n", wall_t-*wall_t0, simtime, t_diff);

  if (t_diff<0.0) {  // then simtime > scaled wall_time
    timespec tosleep;
    tv = doubleToTimeval(-t_diff);
    tosleep.tv_sec = tv.tv_sec;
    tosleep.tv_nsec = tv.tv_usec * 1000;
//    mexPrintf("sleeping...  %d sec, %d nsec\n", tosleep.tv_sec, tosleep.tv_nsec);
    nanosleep(&tosleep, NULL);
  } else if (t_diff>1.0) {  // then I'm behind by more than 1 second
    mexPrintf("at time %f, I'm behind by %f sec\n", simtime, t_diff);
    ssSetErrorStatus(S, "Simulink is not keeping up with real time.  Consider reducing demands on your ODE solver, or optimizing your code.");
  }
}
Ejemplo n.º 11
0
 /* Function: mdlUpdate ======================================================
  * Abstract:
  *    Update dwork for:
  *               +--------+
  *      input -->|  sfcn  |--------> input from last time step (delay)
  *               |        |--------> number of times we've seen nonzero inputs
  *               +--------+
  */
 static void mdlUpdate(SimStruct *S, int_T tid)
 {
     const real_T *u       = (const real_T*) ssGetInputPortSignal(S,0);
     CounterStateStruct *p = (CounterStateStruct*)ssGetDWork(S,0);
     p->state   = u[0];
     p->counter += (u[0] != 0.0);
 }
/* Function Definitions */
static void initialize_c4_Force_Rendering(void)
{
  uint8_T *c4_is_active_c4_Force_Rendering;
  c4_is_active_c4_Force_Rendering = (uint8_T *)ssGetDWork(chartInstance.S, 1);
  _sfTime_ = (real_T)ssGetT(chartInstance.S);
  *c4_is_active_c4_Force_Rendering = 0U;
}
Ejemplo n.º 13
0
static void mdlStart(SimStruct *S)
{
  rtMdlrefDWork_mr_vdmultRM *dw = (rtMdlrefDWork_mr_vdmultRM *) ssGetDWork(S, 0);
  void *sysRanPtr = NULL;
  int sysTid = 0;
  ssGetContextSysRanBCPtr(S, &sysRanPtr);
  ssGetContextSysTid(S, &sysTid);

  {
    static const char* toFileNames[] = { "" };

    static const char* fromFileNames[] = { "" };

    if (!ssSetModelRefFromFiles(S, 0,fromFileNames))
      return;
    if (!ssSetModelRefToFiles(S, 0,toFileNames))
      return;
  }

  mr_vdmultRM_initialize(S, ssGetSampleTimeTaskID(S, 0), &(dw->rtm), sysRanPtr,
    sysTid, NULL, NULL, 0, -1);
  ssSetModelMappingInfoPtr(S, &(dw->rtm.DataMapInfo.mmi));
  if (S->mdlInfo->genericFcn != NULL) {
    _GenericFcn fcn = S->mdlInfo->genericFcn;
    boolean_T hasDiscTs = 0;
    real_T startTime = 0.0;
    real_T fixedStep = 0.4;
    if (!(fcn)(S, GEN_FCN_CHK_MODELREF_START_TIME, -1, &startTime))
      return;
    if (!(fcn)(S, GEN_FCN_CHK_MODELREF_FIXED_STEP, (int_T)hasDiscTs, &fixedStep))
      return;
  }
}
Ejemplo n.º 14
0
  /* Function: mdlStart ========================================================
   * Abstract:
   *    Initialize the counter state structure at model startup. If desired,
   *    we could also have an mdlInitializeConditions() method to reset the
   *    state and/or counter to zero for enabled subsystem restarts. For the
   *    sake of simplicity, we have not added this method.
   */
  static void mdlStart(SimStruct *S)
  {
      CounterStateStruct *p = (CounterStateStruct*)ssGetDWork(S,0);

      p->counter = 0;
      p->state   = 0.0;
  }
Ejemplo n.º 15
0
/* Function: mdlOutputs =======================================================
 * Abstract:
 *    Produce outputs for:
 *               +--------+
 *      input -->|  sfcn  |--------> input from last time step (delay)
 *               |        |--------> number of times we've seen nonzero inputs
 *               +--------+
 *    
 */
static void mdlOutputs(SimStruct *S, int_T tid)
{
    CounterStateStruct *p = (CounterStateStruct*)ssGetDWork(S,0);
    real_T             *y = ssGetOutputPortSignal(S,0);
    y[0] = p->state;
    y[1] = p->counter;
}
static const mxArray
  *get_sim_state_c6_adcs_v15_integral_Power_no_charge_in_detumb(void)
{
  const mxArray *c6_st = NULL;
  const mxArray *c6_y = NULL;
  real_T c6_u;
  const mxArray *c6_b_y = NULL;
  uint8_T c6_b_u;
  const mxArray *c6_c_y = NULL;
  real_T *c6_d_y;
  uint8_T *c6_is_active_c6_adcs_v15_integral_Power_no_charge_in_detumb;
  c6_d_y = (real_T *)ssGetOutputPortSignal(chartInstance.S, 1);
  c6_is_active_c6_adcs_v15_integral_Power_no_charge_in_detumb = (uint8_T *)
    ssGetDWork(chartInstance.S, 2);
  c6_st = NULL;
  c6_y = NULL;
  sf_mex_assign(&c6_y, sf_mex_createcellarray(2));
  c6_u = *c6_d_y;
  c6_b_y = NULL;
  sf_mex_assign(&c6_b_y, sf_mex_create("y", &c6_u, 0, 0U, 0U, 0U, 0));
  sf_mex_setcell(c6_y, 0, c6_b_y);
  c6_b_u = *c6_is_active_c6_adcs_v15_integral_Power_no_charge_in_detumb;
  c6_c_y = NULL;
  sf_mex_assign(&c6_c_y, sf_mex_create("y", &c6_b_u, 3, 0U, 0U, 0U, 0));
  sf_mex_setcell(c6_y, 1, c6_c_y);
  sf_mex_assign(&c6_st, c6_y);
  return c6_st;
}
Ejemplo n.º 17
0
static const mxArray *get_sim_state_c7_adcs_v15_integral_Power(void)
{
  const mxArray *c7_st = NULL;
  const mxArray *c7_y = NULL;
  int32_T c7_i0;
  real_T c7_u[7];
  const mxArray *c7_b_y = NULL;
  uint8_T c7_b_u;
  const mxArray *c7_c_y = NULL;
  uint8_T *c7_is_active_c7_adcs_v15_integral_Power;
  real_T (*c7_xN)[7];
  c7_xN = (real_T (*)[7])ssGetOutputPortSignal(chartInstance.S, 1);
  c7_is_active_c7_adcs_v15_integral_Power = (uint8_T *)ssGetDWork
    (chartInstance.S, 2);
  c7_st = NULL;
  c7_y = NULL;
  sf_mex_assign(&c7_y, sf_mex_createcellarray(2));
  for (c7_i0 = 0; c7_i0 < 7; c7_i0 = c7_i0 + 1) {
    c7_u[c7_i0] = (*c7_xN)[c7_i0];
  }

  c7_b_y = NULL;
  sf_mex_assign(&c7_b_y, sf_mex_create("y", &c7_u, 0, 0U, 1U, 0U, 1, 7));
  sf_mex_setcell(c7_y, 0, c7_b_y);
  c7_b_u = *c7_is_active_c7_adcs_v15_integral_Power;
  c7_c_y = NULL;
  sf_mex_assign(&c7_c_y, sf_mex_create("y", &c7_b_u, 3, 0U, 0U, 0U, 0));
  sf_mex_setcell(c7_y, 1, c7_c_y);
  sf_mex_assign(&c7_st, c7_y);
  return c7_st;
}
Ejemplo n.º 18
0
static void mdlUpdate(SimStruct *S, int_T tid)
{
    BlockIO_Hammerstein *_rtB;
    _rtB = ((BlockIO_Hammerstein *) ssGetLocalBlockIO(S));

    /* Update for DiscreteStateSpace: '<S1>/LinearModel' */
    {
        ((real_T*) ssGetDWork(S, 0))[0] = ((BlockIO_Hammerstein *) ssGetLocalBlockIO
                                           (S))->Pwlinear + 0.95520909191040437*
                                          ((real_T*) ssGetDWork(S, 0))[0];
    }

    /* tid is required for a uniform function interface.
     * Argument tid is not used in the function. */
    UNUSED_PARAMETER(tid);
}
Ejemplo n.º 19
0
/* Outputs for root system: '<Root>' */
static void mdlOutputs(SimStruct *S, int_T tid)
{
    BlockIO_Hammerstein *_rtB;
    _rtB = ((BlockIO_Hammerstein *) ssGetLocalBlockIO(S));

    /* DiscreteStateSpace: '<S1>/LinearModel' */
    {
        ((BlockIO_Hammerstein *) ssGetLocalBlockIO(S))->LinearModel = 1.0*((real_T*)
                ssGetDWork(S, 0))[0];
    }

    /* Level2 S-Function Block: '<S1>/Pwlinear1' (sfunpwlinear) */
    {
        SimStruct *rts = ssGetSFunction(S, 0);
        sfcnOutputs(rts, 0);
        if (ssGetErrorStatus(rts) != (NULL))
            return;
    }

    /* Outport: '<Root>/Out1' */
    ((real_T *)ssGetOutputPortSignal(S, 0))[0] = _rtB->Pwlinear1;

    /* Level2 S-Function Block: '<S1>/Pwlinear' (sfunpwlinear) */
    {
        SimStruct *rts = ssGetSFunction(S, 1);
        sfcnOutputs(rts, 0);
        if (ssGetErrorStatus(rts) != (NULL))
            return;
    }

    /* tid is required for a uniform function interface.
     * Argument tid is not used in the function. */
    UNUSED_PARAMETER(tid);
}
Ejemplo n.º 20
0
/* Function: mdlUpdate ======================================================
 * Abstract:
 *    This function is called once for every major integration time step.
 *    Discrete states are typically updated here, but this function is useful
 *    for performing any tasks that should only take place once per
 *    integration step.
 */
static void mdlUpdate(SimStruct *S, int_T tid)
{

#ifndef VARIABLE_STEP

    /* 
     *    For Fixed Step Code Only
     *    ------------------------
     * If your Fortran code runs at a fixed time step that advances
     * each time you call it, it is best to call it here instead of
     * in mdlOutputs().  The states in the Fortran code need not be
     * continuous if you call your code from here.
     */
    InputRealPtrsType uPtrs = ssGetInputPortRealSignalPtrs(S,0);
    float  *sampleArgs   = (float *) ssGetDWork(S,1);
    double *y            = ssGetOutputPortRealSignal(S,0);
    float  *sampleOutput = (float *) ssGetDWork(S,0);
    int k;
    
    /* 
     * If the datatype in the Fortran code is REAL
     * then you have to downcast the I/O and states from
     * double to float as copies before sending them 
     * to your code (or change the Fortran code).
     */

    for (k=0; k < ssGetDWorkWidth(S,1); k++) {
        sampleArgs[k] = (float) (*uPtrs[k]);
    }


    /* ==== Call the Fortran routine (args are pass-by-reference) */
    
    /* nameofsub_(sampleArgs, sampleOutput ); */

   
    /* 
     * If needed, convert the float outputs to the 
     * double (y) output array 
     */
    for (k=0; k < ssGetOutputPortWidth(S,0); k++) {
        y[k] = (double) sampleOutput[k];
    }

#endif

}
Ejemplo n.º 21
0
/* Function: mdlUpdate ======================================================
   * Abstract:
   *    This function is called once for every major integration time step.
   *    Discrete states are typically updated here, but this function is useful
   *    for performing any tasks that should only take place once per
   *    integration step.
   */
  static void mdlUpdate(SimStruct *S, int_T tid)
  {
    const real_T  *combStateO  = (const real_T *)ssGetOutputPortRealSignal(S,0);
    const real_T  *phiIgO  = (const real_T *)ssGetOutputPortRealSignal(S,2);
    const real_T  *mqfO  = (const real_T *)ssGetOutputPortRealSignal(S,3);
    real_T *combState = (real_T*) ssGetDWork(S,0);
    real_T *phiIg = (real_T*) ssGetDWork(S,1);
    real_T *mqf = (real_T*) ssGetDWork(S,2);
    /*
    combState_Update_wrapper(phi, phiInj, uGov, omega, temp, p, combState, 
            phiIg, mqf, combStateO, phiComb, phiIgO, mqfO, mqfCycMax, 
            p_width0, wiebePara, p_width1);
     */
    *combState = *combStateO;
    *mqf = *mqfO;
    *phiIg = *phiIgO;
}
Ejemplo n.º 22
0
/* Function Definitions */
static void initialize_c7_adcs_v15_integral_Power(void)
{
  uint8_T *c7_is_active_c7_adcs_v15_integral_Power;
  c7_is_active_c7_adcs_v15_integral_Power = (uint8_T *)ssGetDWork
    (chartInstance.S, 2);
  _sfTime_ = (real_T)ssGetT(chartInstance.S);
  *c7_is_active_c7_adcs_v15_integral_Power = 0U;
}
/* Function Definitions */
static void initialize_c19_adcs_v15_integral_Power_nom(void)
{
  uint8_T *c19_is_active_c19_adcs_v15_integral_Power_nom;
  c19_is_active_c19_adcs_v15_integral_Power_nom = (uint8_T *)ssGetDWork
    (chartInstance.S, 2);
  _sfTime_ = (real_T)ssGetT(chartInstance.S);
  *c19_is_active_c19_adcs_v15_integral_Power_nom = 0U;
}
/* Function Definitions */
static void initialize_c31_adcs_v15_integral_Power_dist(void)
{
  uint8_T *c31_is_active_c31_adcs_v15_integral_Power_dist;
  c31_is_active_c31_adcs_v15_integral_Power_dist = (uint8_T *)ssGetDWork
    (chartInstance.S, 2);
  _sfTime_ = (real_T)ssGetT(chartInstance.S);
  *c31_is_active_c31_adcs_v15_integral_Power_dist = 0U;
}
/* Function Definitions */
static void initialize_c6_adcs_v15_integral_Power_no_charge_in_detumb(void)
{
  uint8_T *c6_is_active_c6_adcs_v15_integral_Power_no_charge_in_detumb;
  c6_is_active_c6_adcs_v15_integral_Power_no_charge_in_detumb = (uint8_T *)
    ssGetDWork(chartInstance.S, 2);
  _sfTime_ = (real_T)ssGetT(chartInstance.S);
  *c6_is_active_c6_adcs_v15_integral_Power_no_charge_in_detumb = 0U;
}
/* Function Definitions */
static void initialize_c3_Puncture_Through_Wall(void)
{
  uint8_T *c3_is_active_c3_Puncture_Through_Wall;
  c3_is_active_c3_Puncture_Through_Wall = (uint8_T *)ssGetDWork(chartInstance.S,
   1);
  _sfTime_ = (real_T)ssGetT(chartInstance.S);
  *c3_is_active_c3_Puncture_Through_Wall = 0U;
}
static void set_sim_state_c7_adcs_v15_integral_Power_no_charge_in_detumb(const
  mxArray *c7_st)
{
  const mxArray *c7_u;
  const mxArray *c7_xN;
  real_T c7_dv0[7];
  int32_T c7_i1;
  real_T c7_y[7];
  int32_T c7_i2;
  const mxArray *c7_is_active_c7_adcs_v15_integral_Power_no_charge_in_detumb;
  uint8_T c7_u0;
  uint8_T c7_b_y;
  boolean_T *c7_doneDoubleBufferReInit;
  uint8_T *c7_b_is_active_c7_adcs_v15_integral_Power_no_charge_in_detumb;
  real_T (*c7_b_xN)[7];
  c7_doneDoubleBufferReInit = (boolean_T *)ssGetDWork(chartInstance.S, 1);
  c7_b_is_active_c7_adcs_v15_integral_Power_no_charge_in_detumb = (uint8_T *)
    ssGetDWork(chartInstance.S, 2);
  c7_b_xN = (real_T (*)[7])ssGetOutputPortSignal(chartInstance.S, 1);
  *c7_doneDoubleBufferReInit = true;
  c7_u = sf_mex_dup(c7_st);
  c7_xN = sf_mex_dup(sf_mex_getcell(c7_u, 0));
  sf_mex_import("xN", sf_mex_dup(c7_xN), &c7_dv0, 1, 0, 0U, 1, 0U, 1, 7);
  for (c7_i1 = 0; c7_i1 < 7; c7_i1 = c7_i1 + 1) {
    c7_y[c7_i1] = c7_dv0[c7_i1];
  }

  sf_mex_destroy(&c7_xN);
  for (c7_i2 = 0; c7_i2 < 7; c7_i2 = c7_i2 + 1) {
    (*c7_b_xN)[c7_i2] = c7_y[c7_i2];
  }

  c7_is_active_c7_adcs_v15_integral_Power_no_charge_in_detumb = sf_mex_dup
    (sf_mex_getcell(c7_u, 1));
  sf_mex_import("is_active_c7_adcs_v15_integral_Power_no_charge_in_detumb",
                sf_mex_dup(
    c7_is_active_c7_adcs_v15_integral_Power_no_charge_in_detumb), &c7_u0, 1, 3,
                0U, 0, 0U, 0);
  c7_b_y = c7_u0;
  sf_mex_destroy(&c7_is_active_c7_adcs_v15_integral_Power_no_charge_in_detumb);
  *c7_b_is_active_c7_adcs_v15_integral_Power_no_charge_in_detumb = c7_b_y;
  sf_mex_destroy(&c7_u);
  c7_update_debugger_state_c7_adcs_v15_integral_Power_no_charge_i();
  sf_mex_destroy(&c7_st);
}
Ejemplo n.º 28
0
 /* Function: mdlInitializeConditions ========================================
  * Abstract:
  *    Initialize the states
  */
 static void mdlInitializeConditions(SimStruct *S)
 {
   #define MDL_INITIALIZE_CONDITIONS
/* Function: mdlInitializeConditions ============================
* Abstract:
* Initialize both continuous states to zero
*/
    real_T *T_prev = (real_T*) ssGetDWork(S,0);
    real_T *R_prev = (real_T*) ssGetDWork(S,1);
    real_T *u_prev = (real_T*) ssGetDWork(S,2);    
	real_T *Cv_prev = (real_T*) ssGetDWork(S,3);    

    /* Initialize the previous temperature, internal energy and Cv */
    T_prev[0] = 300;  
	R_prev[0] = 287;
    u_prev[0] = 2.1386e+05;
    Cv_prev[0] = 718.7221;
}
Ejemplo n.º 29
0
static void set_sim_state_c30_adcs_v15_integral_Power(const mxArray *c30_st)
{
  const mxArray *c30_u;
  const mxArray *c30_r_ECEF;
  real_T c30_dv0[3];
  int32_T c30_i1;
  real_T c30_y[3];
  int32_T c30_i2;
  const mxArray *c30_is_active_c30_adcs_v15_integral_Power;
  uint8_T c30_u0;
  uint8_T c30_b_y;
  boolean_T *c30_doneDoubleBufferReInit;
  uint8_T *c30_b_is_active_c30_adcs_v15_integral_Power;
  real_T (*c30_b_r_ECEF)[3];
  c30_b_r_ECEF = (real_T (*)[3])ssGetOutputPortSignal(chartInstance.S, 1);
  c30_doneDoubleBufferReInit = (boolean_T *)ssGetDWork(chartInstance.S, 1);
  c30_b_is_active_c30_adcs_v15_integral_Power = (uint8_T *)ssGetDWork
    (chartInstance.S, 2);
  *c30_doneDoubleBufferReInit = true;
  c30_u = sf_mex_dup(c30_st);
  c30_r_ECEF = sf_mex_dup(sf_mex_getcell(c30_u, 0));
  sf_mex_import("r_ECEF", sf_mex_dup(c30_r_ECEF), &c30_dv0, 1, 0, 0U, 1, 0U, 1,
                3);
  for (c30_i1 = 0; c30_i1 < 3; c30_i1 = c30_i1 + 1) {
    c30_y[c30_i1] = c30_dv0[c30_i1];
  }

  sf_mex_destroy(&c30_r_ECEF);
  for (c30_i2 = 0; c30_i2 < 3; c30_i2 = c30_i2 + 1) {
    (*c30_b_r_ECEF)[c30_i2] = c30_y[c30_i2];
  }

  c30_is_active_c30_adcs_v15_integral_Power = sf_mex_dup(sf_mex_getcell(c30_u, 1));
  sf_mex_import("is_active_c30_adcs_v15_integral_Power", sf_mex_dup
                (c30_is_active_c30_adcs_v15_integral_Power), &c30_u0, 1, 3, 0U,
                0,
                0U, 0);
  c30_b_y = c30_u0;
  sf_mex_destroy(&c30_is_active_c30_adcs_v15_integral_Power);
  *c30_b_is_active_c30_adcs_v15_integral_Power = c30_b_y;
  sf_mex_destroy(&c30_u);
  c30_update_debugger_state_c30_adcs_v15_integral_Power();
  sf_mex_destroy(&c30_st);
}
Ejemplo n.º 30
0
static void mdlOutputs(SimStruct *S, int_T tid)
{
  const real_T *InPort_0 = (real_T *) ssGetInputPortSignal(S, 0);
  const real_T *InPort_1 = (real_T *) ssGetInputPortSignal(S, 1);
  real_T *OutPort_0 = (real_T *) ssGetOutputPortSignal(S, 0);
  rtMdlrefDWork_mr_vdmultRM *dw = (rtMdlrefDWork_mr_vdmultRM *) ssGetDWork(S, 0);
  if (tid != CONSTANT_TID) {
    mr_vdmultRM(InPort_0, InPort_1, OutPort_0);
  }
}