How to used Input/Output functions in new module (external module)

hehiha dungnguyenbk at gmail.com
Mon Jun 11 04:29:00 CEST 2012


Sorry I don't description detail.
I try to add new module name write_total. 
I understand that I must implement 2 file.
[1] total.sci in macro folder.

function [x,y,typ]=TOTAL(job,arg1,arg2)
x=[];y=[];typ=[];
select job
case 'plot' then
  sgn=arg1.model.rpar
  standard_draw(arg1)
case 'getinputs' then
  [x,y,typ]=standard_inputs(arg1)
case 'getoutputs' then
  [x,y,typ]=standard_outputs(arg1)
case 'getorigin' then
  [x,y]=standard_origin(arg1)
case 'set' then
  x=arg1;
  graphics=arg1.graphics
  model=arg1.model
  exprs=graphics.exprs
  while %t do
    [ok,sgn,exprs]=scicos_getvalue('Set sum block parameters',..
    			   'Inputs ports signs/gain',list('vec',-1),exprs)
    if ~ok then
      break
    end
    
    in = -ones(size(sgn,'*'),1)
    
    //** Patch: check added 
    [model,graphics,ok] = check_io(model,graphics,in,-1,[],[]);
    if ok then
      model.rpar = sgn(:)    ;
      graphics.exprs = exprs ;
      
      x.graphics = graphics;
      x.model = model ;
      break
    end
       
  end
case 'define' then
  sgn=[1;1]
  model=scicos_model()
  model.sim=list('TOTAL',2)
  model.in=[-1;-1]
  model.out=-1
  model.rpar=sgn
  model.blocktype='c'
  model.dep_ut=[%t %f]

  
  exprs=sci2exp(sgn)
  gr_i=['[x,y,typ]=standard_inputs(o) ';
	'dd=sz(1)/8,de=0,'
	'if ~arg1.graphics.flip then dd=6*sz(1)/8,de=-sz(1)/8,end'
	'for k=1:size(x,''*'')';
	'  if sgn(k)>0 then';
	'    xstring(orig(1)+dd,y(k)-4,''+'')';
	'  else';
	'    xstring(orig(1)+dd,y(k)-4,''-'')';
	'  end';
	'end';
	'xx=sz(1)*[.8 .4 0.75 .4 .8]+orig(1)+de';
	'yy=sz(2)*[.8 .8 .5 .2 .2]+orig(2)';
	'xpoly(xx,yy,''lines'')']
  x=standard_define([2 3],model, exprs,gr_i)
end
endfunction
[2] total.c in /src/c folder

#include "assert.h"
#include "stdio.h"
#include "stdlib.h"

/**
* Check the size of the output and inputs
*/
#ifndef NDEBUG
static void check_size(int insz[], int nin, int outsz[]);
#endif

//SCICOS_BLOCKS_IMPEXP void TOTAL(int *flag, int *nevprt, double *t, double
xd[],
void TOTAL(int *flag, int *nevprt, double *t, double xd[],
                              double x[], int *nx, double z[], int *nz,
                              double tvec[], int *ntvec, double rpar[],
                              int *nrpar, int ipar[], int *nipar,
                              double *inptr[], int insz[], int *nin,
                              double *outptr[], int outsz[], int *nout)
{
    int i = 0;
    int n = 0;
    double *y;
	int fd = 0;
	char* filen = "test.bin";
mopen(filen,'wb');
// Write total input to file 
mclose();
 
}

I understand that file is c language, and I can use c standard function (ex:
stdio, math, stdlib ...). That's right ?
So, what's file I can used function "Files : Input/Output functions" of
scilab?




--
View this message in context: http://mailinglists.scilab.org/How-to-used-Input-Output-functions-in-new-module-external-module-tp4024319p4024332.html
Sent from the Scilab developers - Mailing Lists Archives mailing list archive at Nabble.com.



More information about the dev mailing list