示例#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)
  {
    real_T         *xD  = ssGetDiscStates(S);
    const real_T   *micros  = (const real_T*) ssGetInputPortSignal(S,0);
    const int_T   p_width0  = mxGetNumberOfElements(PARAM_DEF0(S));
    const int_T   p_width1  = mxGetNumberOfElements(PARAM_DEF1(S));
    const real_T  *S_T  = (const real_T *)mxGetData(PARAM_DEF0(S));
    const real_T  *PIN  = (const real_T *)mxGetData(PARAM_DEF1(S));

    hitec_Update_wrapper(micros,  xD, S_T, p_width0, PIN, p_width1);
}
/* 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)
  {
    real_T         *xD  = ssGetDiscStates(S);
    real_T        *Temp  = (real_T *)ssGetOutputPortRealSignal(S,0);
    const int_T   p_width0  = mxGetNumberOfElements(PARAM_DEF0(S));
    const int_T   p_width1  = mxGetNumberOfElements(PARAM_DEF1(S));
    const int8_T  *i2cAddress  = (const int8_T *)mxGetData(PARAM_DEF0(S));
    const real_T  *sampleTime  = (const real_T *)mxGetData(PARAM_DEF1(S));

    Tmp102_Update_wrapper(Temp,  xD, i2cAddress, p_width0, sampleTime, p_width1);
}
/* Function: mdlOutputs =======================================================
 *
*/
static void mdlOutputs(SimStruct *S, int_T tid)
{
    const real_T   *u0  = (const real_T*) ssGetInputPortSignal(S,0);
    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 int32_T  *baud  = (const int32_T *)mxGetData(PARAM_DEF0(S));
    const int32_T  *uart  = (const int32_T *)mxGetData(PARAM_DEF1(S));
    const real_T  *SampleTime  = (const real_T *)mxGetData(PARAM_DEF2(S));

}
/* Function: mdlOutputs =======================================================
 *
*/
static void mdlOutputs(SimStruct *S, int_T tid)
{
    uint8_T        *y0  = (uint8_T *)ssGetOutputPortRealSignal(S,0);
    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  *baud  = (const real_T *)mxGetData(PARAM_DEF0(S));
    const real_T  *uart  = (const real_T *)mxGetData(PARAM_DEF1(S));
    const real_T  *SampleTime  = (const real_T *)mxGetData(PARAM_DEF2(S));

    y0[0] = 0;
}
/* Function: mdlOutputs =======================================================
 *
*/
static void mdlOutputs(SimStruct *S, int_T tid)
{
    const int16_T   *uint16_01  = (const int16_T*) ssGetInputPortSignal(S,0);
    const real_T   *xD = ssGetDiscStates(S);
    const int_T   p_width0  = mxGetNumberOfElements(PARAM_DEF0(S));
    const int8_T  *Address  = (const int8_T *)mxGetData(PARAM_DEF0(S));


    MinSegBus01Int_Outputs_wrapper(uint16_01, xD, Address, p_width0);


}
示例#6
0
/* Function: mdlOutputs =======================================================
 *
*/
static void mdlOutputs(SimStruct *S, int_T tid)
{
    const uint8_T   *in  = (const uint8_T*) ssGetInputPortSignal(S,0);
    const real_T   *xD = ssGetDiscStates(S);
    const int_T   p_width0  = mxGetNumberOfElements(PARAM_DEF0(S));
    const uint8_T  *pin  = (const uint8_T *)mxGetData(PARAM_DEF0(S));


    sfcn_PWM_Out_Outputs_wrapper(in, xD, pin, p_width0);


}
示例#7
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;
}
/* Function: mdlOutputs =======================================================
 *
*/
static void mdlOutputs(SimStruct *S, int_T tid)
{
    const real_T   *pCyl  = (const real_T*) ssGetInputPortSignal(S,0);
    const real_T   *tempCyl  = (const real_T*) ssGetInputPortSignal(S,1);
    const real_T   *vCyl  = (const real_T*) ssGetInputPortSignal(S,2);
    const real_T   *omega  = (const real_T*) ssGetInputPortSignal(S,3);
    const real_T   *tempWall = (const real_T*) ssGetInputPortSignal(S,4);
    real_T        *dQ  = (real_T *)ssGetOutputPortRealSignal(S,0);
    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 int_T   p_width3  = mxGetNumberOfElements(PARAM_DEF3(S));
    const real_T  *stroke  = (const real_T *)mxGetData(PARAM_DEF0(S));
    const real_T  *B  = (const real_T *)mxGetData(PARAM_DEF1(S));
    const real_T  *cAlpha  = (const real_T *)mxGetData(PARAM_DEF2(S));
    const real_T  *nCyl  = (const real_T *)mxGetData(PARAM_DEF3(S));

    EngCylHeatTransfer_Outputs_wrapper(pCyl, tempCyl, vCyl, omega, tempWall, dQ, stroke, p_width0, B, p_width1, cAlpha, p_width2, nCyl, p_width3);
}
示例#9
0
/* Function: mdlOutputs =======================================================
 *
*/
static void mdlOutputs(SimStruct *S, int_T tid)
{
    const real_T   *m  = (const real_T*) ssGetInputPortSignal(S,0);
    const real_T   *E  = (const real_T*) ssGetInputPortSignal(S,1);
    const real_T   *mb  = (const real_T*) ssGetInputPortSignal(S,2);
    const real_T   *V  = (const real_T*) ssGetInputPortSignal(S,3);
    real_T        *p  = (real_T *)ssGetOutputPortRealSignal(S,0);
    real_T        *T  = (real_T *)ssGetOutputPortRealSignal(S,1);
    real_T        *F  = (real_T *)ssGetOutputPortRealSignal(S,2);
    const int_T   p_width0  = mxGetNumberOfElements(PARAM_DEF0(S));
    const real_T  *fs  = (const real_T *)mxGetData(PARAM_DEF0(S));
    const real_T *T_prev = (const real_T*) ssGetDWork(S,0);
	const real_T *R_prev = (const real_T*) ssGetDWork(S,1);
    const real_T *u_prev = (const real_T*) ssGetDWork(S,2);
    const real_T *Cv_prev = (const real_T*) ssGetDWork(S,3);

    ThdynCV_Outputs_wrapper(m, E, mb, V, p, T, F, T_prev, R_prev, u_prev, Cv_prev, fs, p_width0);

}
示例#10
0
/* Function: mdlOutputs =======================================================
 *
*/
static void mdlOutputs(SimStruct *S, int_T tid)
{
    const uint32_T   *in0  = (const uint32_T*) ssGetInputPortSignal(S,0);
    const uint32_T   *in1  = (const uint32_T*) ssGetInputPortSignal(S,1);
    const uint32_T   *in2  = (const uint32_T*) ssGetInputPortSignal(S,2);
    const uint32_T   *in3  = (const uint32_T*) ssGetInputPortSignal(S,3);
    uint32_T        *adder_out  = (uint32_T *)ssGetOutputPortRealSignal(S,0);
    uint32_T        *DBG_in01  = (uint32_T *)ssGetOutputPortRealSignal(S,1);
    uint32_T        *DBG_in012  = (uint32_T *)ssGetOutputPortRealSignal(S,2);
    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 int_T   p_width3  = mxGetNumberOfElements(PARAM_DEF3(S));
    const uint32_T  *in_bitwidth  = (const uint32_T *)mxGetData(PARAM_DEF0(S));
    const uint32_T  *in_fp_position  = (const uint32_T *)mxGetData(PARAM_DEF1(S));
    const uint32_T  *out_bitwidth  = (const uint32_T *)mxGetData(PARAM_DEF2(S));
    const uint32_T  *out_fp_position  = (const uint32_T *)mxGetData(PARAM_DEF3(S));

    SDFPAdder4_Outputs_wrapper(in0, in1, in2, in3, adder_out, DBG_in01, DBG_in012, in_bitwidth, p_width0, in_fp_position, p_width1, out_bitwidth, p_width2, out_fp_position, p_width3);
}
示例#11
0
static void mdlStart(SimStruct *S)
{
    const real_T  *pp1  = mxGetData(PARAM_DEF0(S));
    const real_T  *pp2  = mxGetData(PARAM_DEF1(S));
    int P2=*pp2;
    if(P2!=0)
        ssSetOutputPortWidth(S, 0,P2);
    int connected=0,accCon,portno;
    struct sockaddr_in serv_addr; 
    char* P1=(char*)mxGetPr(ssGetSFcnParam(S,0));
    char* last;
    int num=mxGetNumberOfElements(ssGetSFcnParam(S,0));

    int count;
    char  *port;
    char  porttemp[20];
/*Determine Port Number*/  

    
    portno =*pp1;
    const int_T        y_width = ssGetOutputPortWidth(S,0);
    int yes=1;int i; 
	accCon = socket(AF_INET, SOCK_STREAM, 0);
	if (accCon < 0) 
	error("ERROR opening socket");
	bzero((char *) &serv_addr, sizeof(serv_addr));
	setsockopt(accCon,SOL_SOCKET,SO_REUSEADDR,&yes,sizeof(yes));

	serv_addr.sin_family = AF_INET;
	serv_addr.sin_addr.s_addr = INADDR_ANY;
	serv_addr.sin_port = htons(portno);

	if (bind(accCon, (struct sockaddr *) &serv_addr,
	sizeof(serv_addr)) < 0) 
	error("ERROR on binding");

	
	fcntl(accCon, F_SETFL, O_NONBLOCK); 
    last =  malloc( y_width);
    for(i=0;i<y_width;i++)
         last[i]=128;
    ssSetIWorkValue(S, 0, connected);
    ssSetIWorkValue(S, 1, accCon);
    /*ssSetPWorkValue(S, 2, (void*) &cli_addr);*/
    ssSetPWorkValue(S, 1, (void*) last);

}
示例#12
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 *xC   = ssGetContStates(S);
   
    const real_T  *fs  = (const real_T *)mxGetData(PARAM_DEF0(S));
    const real_T  *m0  = (const real_T *)mxGetData(PARAM_DEF5(S));
    const real_T  *E0  = (const real_T *)mxGetData(PARAM_DEF6(S));
    const real_T  *mb0  = (const real_T *)mxGetData(PARAM_DEF7(S));
    const real_T  *V0  = (const real_T *)mxGetData(PARAM_DEF8(S));
    const real_T  *alpha = (const real_T *)mxGetData(PARAM_DEF3(S));
    
    real_T *p_prev = (real_T*) ssGetDWork(S,0);      
    real_T *Tu_prev = (real_T*) ssGetDWork(S,1);
    real_T *Fu_prev = (real_T*) ssGetDWork(S,2);
    real_T *Ru_prev = (real_T*) ssGetDWork(S,3);
    real_T *uu_prev = (real_T*) ssGetDWork(S,4);    
	real_T *Cvu_prev = (real_T*) ssGetDWork(S,5);    
    real_T *Tb_prev = (real_T*) ssGetDWork(S,6);
    real_T *Fb_prev = (real_T*) ssGetDWork(S,7);
    real_T *Rb_prev = (real_T*) ssGetDWork(S,8);
    real_T *ub_prev = (real_T*) ssGetDWork(S,9);    
	real_T *Cvb_prev = (real_T*) ssGetDWork(S,10);  
    real_T *mCyl_prev = (real_T*) ssGetDWork(S,11);
    real_T *mbCyl_prev = (real_T*) ssGetDWork(S,12);
    real_T *VCyl_prev = (real_T*) ssGetDWork(S,13);
    real_T *mu_prev = (real_T*) ssGetDWork(S,14);
    real_T *mub_prev = (real_T*) ssGetDWork(S,15);
    real_T *Vu_prev = (real_T*) ssGetDWork(S,16);
    real_T *QCyl_prev = (real_T*) ssGetDWork(S,17);
    real_T *HCyl_prev = (real_T*) ssGetDWork(S,18);        
    real_T *WCyl_prev = (real_T*) ssGetDWork(S,19);        
    real_T *mfb_prev = (real_T*) ssGetDWork(S,20);
    real_T *mMix_prev = (real_T*) ssGetDWork(S,21);
    real_T *mbb0 = (real_T*) ssGetDWork(S,22);
    real_T *ResetMix = (real_T*) ssGetDWork(S,23);
                                 
    xC[0] = m0[0]; 
    xC[1] = mb0[0];
    xC[2] = V0[0];
    xC[3] = 0;
	xC[4] = 0;
	xC[5] = E0[0];
	xC[6] = 0;
   
    GetPTFV1(m0[0],mb0[0],E0[0],V0[0],300,287,2.1386e5,718.7,fs[0], 
            p_prev,Tu_prev,Fu_prev);
    Ru_prev[0] = 287;
    uu_prev[0] = E0[0]/m0[0];
    Cvu_prev[0] = 718.7221;
    Tb_prev[0] = Tu_prev[0];
    Fb_prev[0] = Fu_prev[0];
    Rb_prev[0] = 287;
	ub_prev[0] = E0[0] / m0[0];
    Cvb_prev[0] = 718.7221;
    mCyl_prev[0] = m0[0];
    mbCyl_prev[0] = mb0[0];
    VCyl_prev[0] = V0[0];
    mu_prev[0] = m0[0]*(1-alpha[0]);
    mub_prev[0] = mb0[0]*(1-alpha[0]);
    Vu_prev[0] = V0[0]*(1-alpha[0]);
    QCyl_prev[0] = 0;
    HCyl_prev[0] = E0[0];
    WCyl_prev[0] = 0;
    mfb_prev[0] = 0;
    mMix_prev[0] = 0;
    mbb0[0] = 0;
    ResetMix[0] = 1;
}
示例#13
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 *FComb = (const real_T*) ssGetInputPortSignal(S,7);
    const real_T *phi = (const real_T*) ssGetInputPortSignal(S,8);
    const real_T *combState = (const real_T*) ssGetInputPortSignal(S,9);
    real_T        *p = (real_T *)ssGetOutputPortRealSignal(S,0);
    real_T        *Tu = (real_T *)ssGetOutputPortRealSignal(S,1);
    real_T        *Fu = (real_T *)ssGetOutputPortRealSignal(S,2);
    real_T        *Vu = (real_T *)ssGetOutputPortRealSignal(S,3);
    real_T        *Tb = (real_T *)ssGetOutputPortRealSignal(S,4);
    real_T        *Fb = (real_T *)ssGetOutputPortRealSignal(S,5);
    real_T        *Vb = (real_T *)ssGetOutputPortRealSignal(S,6);
    const real_T *xC = ssGetContStates(S);
    real_T *p_prev = (real_T*) ssGetDWork(S,0);      
    real_T *Tu_prev = (real_T*) ssGetDWork(S,1);
    real_T *Fu_prev = (real_T*) ssGetDWork(S,2);
    real_T *Ru_prev = (real_T*) ssGetDWork(S,3);
    real_T *uu_prev = (real_T*) ssGetDWork(S,4);    
	real_T *Cvu_prev = (real_T*) ssGetDWork(S,5);    
    real_T *Tb_prev = (real_T*) ssGetDWork(S,6);
    real_T *Fb_prev = (real_T*) ssGetDWork(S,7);
    real_T *Rb_prev = (real_T*) ssGetDWork(S,8);
    real_T *ub_prev = (real_T*) ssGetDWork(S,9);    
	real_T *Cvb_prev = (real_T*) ssGetDWork(S,10);  
    real_T *mCyl_prev = (real_T*) ssGetDWork(S,11);
    real_T *mbCyl_prev = (real_T*) ssGetDWork(S,12);
    real_T *VCyl_prev = (real_T*) ssGetDWork(S,13);
    real_T *mu_prev = (real_T*) ssGetDWork(S,14);
    real_T *mub_prev = (real_T*) ssGetDWork(S,15);
    real_T *Vu_prev = (real_T*) ssGetDWork(S,16);
    real_T *QCyl_prev = (real_T*) ssGetDWork(S,17);
    real_T *HCyl_prev = (real_T*) ssGetDWork(S,18);        
    real_T *WCyl_prev = (real_T*) ssGetDWork(S,19);        
    real_T *mfb_prev = (real_T*) ssGetDWork(S,20);
    real_T *mMix_prev = (real_T*) ssGetDWork(S,21);
    real_T *mb0 = (real_T*) ssGetDWork(S,22);
    real_T *ResetMix = (real_T*) ssGetDWork(S,23);
    
    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 int_T   p_width3  = mxGetNumberOfElements(PARAM_DEF3(S));
	const int_T   p_width4 = mxGetNumberOfElements(PARAM_DEF4(S));
    const int_T   p_width9  = mxGetNumberOfElements(PARAM_DEF9(S));

    const real_T  *fs  = (const real_T *)mxGetData(PARAM_DEF0(S));
    const real_T  *DPhiMix  = (const real_T *)mxGetData(PARAM_DEF1(S));
    const real_T  *phiMix0  = (const real_T *)mxGetData(PARAM_DEF2(S));
    const real_T  *alpha  = (const real_T *)mxGetData(PARAM_DEF3(S));
	const real_T  *hn = (const real_T *)mxGetData(PARAM_DEF4(S));
    const real_T  *nStroke  = (const real_T *)mxGetData(PARAM_DEF9(S));

    ThdynCVNV2Zone_Update_wrapper(phi,FComb,combState,p,Tu,Fu,Vu,Tb,Fb,Vb,
            xC,p_prev,Tu_prev,Fu_prev,Ru_prev,uu_prev,Cvu_prev,
            Tb_prev,Fb_prev,Rb_prev,ub_prev,Cvb_prev,
            mCyl_prev,mbCyl_prev,VCyl_prev,QCyl_prev,HCyl_prev,WCyl_prev,
            mu_prev,mub_prev,Vu_prev,mfb_prev,
            mMix_prev,mb0,ResetMix,
            fs,p_width0,DPhiMix,p_width1,phiMix0,p_width2,
            alpha,p_width3,hn,p_width4,nStroke,p_width9);
}