⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 codegeneration_.sci

📁 rtai-3.1-test3的源代码(Real-Time Application Interface )
💻 SCI
📖 第 1 页 / 共 5 页
字号:
	cformatline('void '+rdnom+'_end(double *z, double *t, '+..		    'double * rpar, int *nrpar, int *ipar, int *nipar) ;',70);	' ';	'int '+rdnom+'()  ;';	' ';	cformatline('int '+rdnom+'ddoit1(double *z, int * zptr, double *t, double"+...		    " *tevts, int *evtspt, int * nevts, int *pointi, int * outptr,"+...		    " int *clkptr, int *ordptr, int *ordclk, int *nordcl, double *"+...		    " rpar, int *ipar, int *funptr, int *funtyp, double *outtb, int"+...		    " *iwa)  ;',70);	' ';	cformatline('int '+rdnom+'ddoit2(double *z, int * zptr, double *t, double"+...		    " *tevts, int *evtspt, int * nevts, int *pointi, int * outptr,"+...		    " int *clkptr, int *ordptr, int *ordclk, int *nordcl, double *"+...		    " rpar, int *ipar, int *funptr, int *funtyp, double *outtb, int"+...		    " *iwa)  ;',70);	' ';	cformatline('int '+rdnom+'edoit1(double *z, int * zptr, double *t, double"+...		    " *tevts, int *evtspt, int * nevts, int *pointi, int * outptr,"+...		    " int *clkptr, int *ordptr, int *ordclk, int *nordcl, double *"+...		    " rpar, int *ipar, int *funptr, int *funtyp, double"+...		    " *outtb, int * urg, int *iwa, int *kiwa)  ;',70);		' ';	cformatline('int '+rdnom+'_initi(double *z, int * zptr, double *t, double"+...		    " *tevts, int *evtspt, int * nevts, int *pointi, int * outptr,"+...		    " int *clkptr, int *ordptr, int *ordclk, int *nordcl, double *"+...		    " rpar, int *ipar, int *funptr, int *funtyp, double *outtb, int"+...		    " *iwa)  ;',70);	' ';	cformatline('int '+rdnom+'_endi(double *z, int * zptr, double *t, double"+...		    " *tevts, int *evtspt, int * nevts, int *pointi, int * outptr,"+...		    " int *clkptr, int *ordptr, int *ordclk, int *nordcl, double *"+...		    " rpar, int *ipar, int *funptr, int *funtyp, double *outtb, int"+...		    " *iwa)  ;',70);	' ';	cformatline('int '+rdnom+'_outtb(double *z, int * zptr, double *t, double"+...		    " *tevts, int *evtspt, int * nevts, int *pointi, int * outptr,"+...		    " int *clkptr, int *ordptr, int *ordclk, int *nordcl, double *"+...		    " rpar, int *ipar, int *funptr, int *funtyp, double *outtb, int"+...		    " *iwa)  ;',70);	' ';	cformatline('int C2F(putevs)(double *tevts, int *evtspt, int * nevts, int"+...		    " *pointi, double *told, int *i2, int *ierr);',70);	'/* ---- block simulation functions -------*/'	' '];endfunctionfunction Code=make_decl_standalone()//generates  procedure declarations//Copyright INRIA//Author : Rachid Djenidi  Code=['/* Code prototype for standalone use  */';	'/*     Generated by Code_Generation toolbox of Scicos with '+ ..	getversion()+' */';	'/*     date : '+date(getdate())+' */';	''	'#include <stdio.h>';	'#include <string.h>';	'';	cformatline('void '+rdnom+'main1(double *z, double *t, '+..		    'double * rpar, integer *nrpar,integer *ipar,integer *nipar);',70);	'';	cformatline('void '+rdnom+'main2(double *z, double *t, '+..		    'double * rpar, integer *nrpar,integer *ipar,integer *nipar) ;',70);	'';	cformatline('void '+rdnom+'_init(double *z, double *t, '+..		    'double * rpar, integer *nrpar,integer *ipar,integer *nipar) ;',70);	'';	cformatline('void '+rdnom+'_end(double *z, double *t, '+..		    'double * rpar, integer *nrpar,integer *ipar,integer *"+...		    " nipar) ;',70);	''	cformatline('void '+rdnom+'_sim(double tf)"+...		    " ;',70);	''	cformatline('void '+rdnom+'_events(int *nevprt, "+...		    "double *t);',70)	''	'void set_nevprt(int nevprt);']endfunctionfunction Code=make_end()//Copyright INRIA//Author : Rachid Djenidi  nordcl=size(ordclk,1);  Code=['/*'+part('-',ones(1,40))+' end */ ';	'void '	cformatline(rdnom+'_end(double *z, double *t, double * rpar, '+..		    'integer *nrpar,integer *ipar,integer *nipar)',70);	'{'];    if size(pointi,1) <> 0 then    Code($+1)='  integer pointi[ ]={'+strcat(string(pointi),",")+'};';   else    Code($+1)='  integer pointi[1];';  end  Code=[Code	'integer nordcl = '+string(nordcl)+';';	''	cformatline('  '+rdnom+'_endi(z, zptr, t, tevts, evtspt, nevts, pointi, '+..		    'outptr, clkptr, ordptr, ordclk, &nordcl, rpar, ipar, '+..		    'rdfunptr, funtyp, &(z['+string(size(z,1))+']), '+..		    '(int *)(z+'+string(size(z,1)+size(outtb,1))+'));',70);		'} '];  endfunctionfunction Code=make_init()//Copyright INRIA//Author : Rachid Djenidi  nordcl=size(ordclk,1);  Code=['/*'+part('-',ones(1,40))+' init */ ';	'void '	cformatline(rdnom+'_init(double *z, double *t, double * rpar, '+..		    'integer *nrpar,integer *ipar,integer *nipar)',70);	'{'];  if size(pointi,1) <> 0 then    Code($+1)='  integer pointi[ ]={'+strcat(string(pointi),",")+'};';   else    Code($+1)='  integer pointi[1];';  end  Code=[Code;	'integer nordcl = '+string(nordcl)+';';	'  /*Block initializations*/'	cformatline('  '+rdnom+'_initi(z, zptr, t, tevts, evtspt, nevts, '+..		    'pointi, outptr, clkptr, ordptr, ordclk, &nordcl, rpar, ipar, '+..		    'rdfunptr,funtyp, &(z['+string(size(z,1))+']), '+..		    '(int *)(z+'+string(size(z,1)+size(outtb,1))+'));',70);	'  /*Constants propagation*/'	cformatline('  '+rdnom+'_outtb(z, zptr, t, tevts, evtspt, nevts, '+..		    'pointi, outptr, clkptr, ordptr, ordclk, &nordcl, rpar, ipar, '+..		    'rdfunptr,funtyp, &(z['+string(size(z,1))+']), '+..		    '(int *)(z+'+string(size(z,1)+size(outtb,1))+'));',70);       '} '];  endfunctionfunction Code=make_main1()//generate code for flag=1 case  //Copyright INRIA//Author : Rachid Djenidi  nordcl=size(ordclk,1);  Code=['/*'+part('-',ones(1,40))+' main1 */ ';	'void '	cformatline(rdnom+'main1(double *z, double *t, double * rpar, '+..		    'integer *nrpar,integer *ipar,integer *nipar)',70);	'{'];    if size(pointi,1) <> 0 then    Code($+1)='  integer pointi[ ]={'+strcat(string(pointi),",")+'};';   else    Code($+1)='  integer pointi[1];';  end    Code=[Code;	'integer nordcl = '+string(nordcl)+';';	''	cformatline('  '+rdnom+'ddoit1(z, zptr, t, tevts, evtspt, nevts, '+..		    'pointi, outptr, clkptr, ordptr, ordclk, &nordcl, rpar, ipar, '+..		    'rdfunptr, funtyp, &(z['+string(size(z,1))+']), '+..		    '(int *)(z+'+string(size(z,1)+size(outtb,1))+'));',70);	'} '];endfunctionfunction Code=make_main2()//generate code for flag=2 case//Copyright INRIA//Author : Rachid Djenidi  nordcl=size(ordclk,1);  Code=['/*'+part('-',ones(1,40))+' main2 */ ';	'void '	cformatline(rdnom+'main2(double *z, double *t, double * rpar, '+..		    'integer *nrpar,integer *ipar,integer *nipar)',70);	'{'];    if size(pointi,1) <> 0 then    Code($+1)='  integer pointi[ ]={'+strcat(string(pointi),",")+'};';   else    Code($+1)='  integer pointi[1];';  end  Code=[Code;	'integer nordcl = '+string(nordcl)+';';	''	cformatline('  '+rdnom+'ddoit2(z, zptr, t, tevts, evtspt, nevts, '+..		    'pointi, outptr, clkptr, ordptr, ordclk, &nordcl, rpar, '+..		    'ipar, rdfunptr, funtyp, &(z['+string(size(z,1))+']), '+..		    '(int *)(z+'+string(size(z,1)+size(outtb,1))+'));',70);		'} ']; endfunctionfunction Code=make_outevents()//generates skeleton of external world events handling function  z='0'  if szclkIN==[] then    newszclkIN=0;  else    newszclkIN=szclkIN;  end   Code=[ '/*'+part('-',ones(1,40))+'  External events handling function */ ';	 'void '	 rdnom+'_events(int *nevprt,double *t)';	 '{'	 '/*  set next event time and associated events ports  '	 ' *  nevprt has binary expression b1..b'+string(newszclkIN)+' where bi is a bit '	 ' *  bi is set to 1 if an activation is received by port i. Note that'	 ' *  more than one activation can be received simultaneously '	 ' *  Caution: at least one bi should be equal to one */'	 ''	 '    int i,p,b[]={'+strcat(z(ones(1,newszclkIN)),',')+'};'	 ''	 '/* this is an example for the activation of events ports */'	 '    b[0]=1;']  if newszclkIN>1 then    for bb=2:newszclkIN      Code($+1)='    b['+string(bb-1)+']=1;'    end  end  Code=[Code;' '	'/* definition of the step time  */'	'    *t = *t + 0.1;'	' '	'/* External events handling process */'	'    *nevprt=0;p=1;'	'    for (i=0;i<'+string(newszclkIN)+';i++) {'	'      *nevprt=*nevprt+b[i]*p;'	'      p=p*2;}'	'}']endfunctionfunction Code=make_sensor(standalone)// Generating the routine for sensors interfacing//Copyright INRIA//Author : Rachid Djenidi  Call=['/*'+part('-',ones(1,40))+' Sensor */ ';      'void ';      rdnom+'_sensor(flag,nport,nevprt,t,y,ny)']comments=['     /*'          '      * To be customized for standalone execution';	  '      * flag  : specifies the action to be done'	  '      * nport : specifies the  index of the Super Bloc '	  '      *         regular input (The input ports are numbered '	  '      *         from the top to the bottom ) '	  '      * nevprt: indicates if an activation had been received'	  '      *         0 = no activation'	  '      *         1 = activation '	  '      * t     : the current time value'	  '      * y     : the vector outputs value'	  '      * ny    : the output  vector size'	  '      */']dcl=['     integer *flag,*nevprt,*nport;'     '     integer *ny;'     ''     '     double  *t, y[];'     '{'     '  int k;'];if standalone then  a_sensor=['  switch (*flag) {'	    '  case 1 : /* set the output value */'	    '    printf(""Require outputs of sensor number %d\n"", *nport);'	    '    printf(""time is: %f\n"", *t);'	    '    printf(""size of the sensor output is: %d\n"", *ny);'	    '    puts(""Please set the sensor output values""); '	    '    for (k=0;k<*ny;k++) scanf(""%lf"", &(y[k]));'	    '    break;'	    '  case 4 : /* sensor initialisation */'	    '    /* do whatever you want to initialize the sensor */'	    '    break;'	    '  case 5 : /* sensor ending */'	    '    /* do whatever you want to end the sensor */'	    '    break;'	    '  }']else  a_sensor=[]endnc=size(cap,'*')Code=[]if nc==1|~standalone then  Code=[Code;	Call	comments	dcl	a_sensor	'}'];elseif nc>1 then  S='  switch (*nport) {'  for k=1:nc    S=[S;       '  case '+string(k)+' : /* Port number '+string(k)+' ----------*/'       '  '+a_sensor       '  break;']  end    S=[S;'  }']      Code=[Code	  Call	  comments	  dcl	  S	  '}']endendfunctionfunction Code=make_standalone()//generates code of the standalone simulation procedure//Copyright INRIA//Author : Rachid Djenidi//Generates simulation routine for standalone simulation  iwa=zeros(clkptr($),1),Z=[z;outtb;iwa]';  Code=[ '/*Main program */'	 'int main()'	 '{'	 '   double tf=10.0;';	 '   '+rdnom+'_sim(tf);';	 '   return 0;'	 '}'	 ''	 '/*'+part('-',ones(1,40))+'  External simulation function */ ';	 'void '	 rdnom+'_sim(tf)';	 ' '	 '     double tf; ';	 '{'	 '  double t;'	 '  int nevprt=1;'	 ''	 '  /*Initial values */';	 cformatline('  double z[]={'+strcat(string(Z),',')+'};',70);	 '/* Note that z[]=[z_initial_condition;outtb;iwa]';	 cformatline('z_initial_condition= {'+strcat(string(z),",")+'};',70);	 cformatline('outtb= {'+strcat(string(outtb),"," )+'};',70);	 cformatline('iwa= {'+strcat(string(iwa),"," )+'};',70);	 '*/ ']  if size(z,1) <> 0 then    for i=1:(length(zptr)-1)             if zptr(i+1)-zptr(i)>0 then	if size(corinv(i),'*')==1 then	  OO=scs_m.objs(corinv(i));	else	  path=list('objs');	  for l=cpr.corinv(i)(1:$-1),path($+1)=l;path($+1)='model';path($+1)='rpar'; path($+1)='objs';end	 path($+1)=cpr.corinv(i)($);	  OO=scs_m(path);	end	aaa=OO.gui;bbb=emptystr(3,1);	if and(aaa+bbb~= ['INPUTPORTEVTS';'OUTPUTPORTEVTS';'EVTGEN_f']) then	  Code($+1)=' ';		  Code($+1)='/* Routine name of block: '+strcat(string(cpr.sim.funs(i)));	  Code($+1)=' Gui name of block: '+strcat(string(OO.gui));	  //Code($+1)='/* Name block: '+strcat(string(cpr.sim.funs(i)));	//Code($+1)='Object number in diagram: '+strcat(string(cpr.corinv(i)));	Code($+1)='Compiled structure index: '+strcat(string(i));	if stripblanks(OO.model.label)~=emptystr() then	    	  Code=[Code;cformatline('Label: '+strcat(string(OO.model.label)),70)];	end	if stripblanks(OO.graphics.exprs)~=emptystr() then	  Code=[Code;cformatline('Exprs: '+strcat(OO.graphics.exprs,","),70)];	end	if stripblanks(OO.graphics.id)~=emptystr() then	  Code=[Code;		cformatline('Identification: '+..			    strcat(string(OO.graphics.id)),70)];	  	end	Code=[Code;cformatline('z= {'+strcat(string(z(zptr(i):zptr(i+1)-1)),",")+'};',70)];	Code($+1)='*/';	end      end    end  end  Code=[Code;'  t=0.0;'	'  '+rdnom+'_init(z,&t,RPAR1,&NRPAR1,IPAR1,&NIPAR1);'	'  while (t<=tf) {   ';	'    '+rdnom+'_events(&nevprt,&t);'	'    set_nevprt(nevprt);'	'    '+rdnom+'main1(z,&t,RPAR1,&NRPAR1,IPAR1,&NIPAR1);'	'    '+rdnom+'main2(z,&t,RPAR1,&NRPAR1,IPAR1,&NIPAR1);'	'  }'	'  '+rdnom+'_end(z,&t,RPAR1,&NRPAR1,IPAR1,&NIPAR1);'	'  return ;'	'}'  	'/*'+part('-',ones(1,40))+'  Lapack messag function */ ';	'void'	'C2F(xerbla)(SRNAME,INFO,L)'	'char *SRNAME;'	'int *INFO;'	'long int L;'	'{'	'printf(""** On entry to %s, parameter number %d  had an illegal value\n"",SRNAME,*INFO);'	'}']endfunctionfunction Code=make_static()//generates  static table definitions//Copyright INRIA//Author : Rachid Djenidi    z=cpr.state.z;  tevts=cpr.state.tevts;evtspt=cpr.state.evtspt;  nevts=size(evtspt,1);  zptr=cpr.sim.zptr;  outptr=cpr.sim.outptr;  funtyp=cpr.sim.funtyp;  clkptr=cpr.sim.clkptr;ordptr=cpr.sim.ordptr;  ordclk=cpr.sim.ordclk;nordcl=size(ordclk,1);  funs=cpr.sim.funs;    Code= ['/* Table of constant values */ ';	 ' ';	 'static integer totalnevprt; '];    if size(evtspt,1) <> 0 then    Code=[Code;cformatline('static integer evtspt[ ]={'+..			   strcat(string(evtspt),",")+'};',70)]   else    Code($+1)='static integer evtspt[1];';  end    if size(nevts,1) <> 0 then    Code=[Code;cformatline('static integer nevts[ ]={'+..			   strcat(string(nevts),",")+'};',70)]   else    Code($+1)='static integer nevts[1];';  end  Code($+1)='static double x[1];';      if size(zptr,1) <> 0 then    Code=[Code;cformatline('static integer zptr[ ]={'+..			   strcat(string(zptr),",")+'};',70)]   else    Code($+1)='static integer zptr[1];';  end    if size(clkptr,1) <> 0 then    Code=[Code;cformatline('static integer clkptr[ ]={'+..			   strcat(string(clkptr),",")+'};',70)]   else    Code($+1)='static integer clkptr[1];';  end  if size(ordptr,1) <> 0 then    Code=[Code;cformatline('static integer ordptr[ ]={'+..			   strcat(string(ordptr),",")+'};',70)]   else    Code($+1)='static integer ordptr[1];';  end    if size(ordclk,1) <> 0 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -