~ubuntu-branches/debian/jessie/rtai/jessie

« back to all changes in this revision

Viewing changes to rtai-lab/scilab/macros/RTAI/rtai_mbx_ovrwr_send.sci

  • Committer: Bazaar Package Importer
  • Author(s): Roland Stigge
  • Date: 2009-07-04 11:47:08 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090704114708-0ivbkccfaawz2pby
Tags: 3.7.1-1
* New upstream release
* debian/control: Standards-Version: 3.8.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
function [x,y,typ]=rtai_mbx_ovrwr_send(job,arg1,arg2)
2
 
//
3
 
// Copyright roberto.bucher@supsi.ch
4
 
x=[];y=[];typ=[];
5
 
select job
6
 
case 'plot' then
7
 
  graphics=arg1.graphics; exprs=graphics.exprs;
8
 
  name=exprs(1)(2);
9
 
  standard_draw(arg1)
10
 
case 'getinputs' then
11
 
  [x,y,typ]=standard_inputs(arg1)
12
 
case 'getoutputs' then
13
 
  [x,y,typ]=standard_outputs(arg1)
14
 
case 'getorigin' then
15
 
  [x,y]=standard_origin(arg1)
16
 
case 'set' then
17
 
  x=arg1
18
 
  model=arg1.model;graphics=arg1.graphics;
19
 
  label=graphics.exprs;
20
 
  while %t do
21
 
    [ok,ip,name,ipaddr,lab]=..
22
 
        getvalue('Set RTAI-mbx_ovrwr_send block parameters',..
23
 
        ['input ports';
24
 
        'MBX Name';
25
 
        'IP Addr'],..
26
 
         list('vec',-1,'str',1,'str',1),label(1))
27
 
 
28
 
    if ~ok then break,end
29
 
    label(1)=lab
30
 
    funam='o_mbx_ovrwr_send_' + name;
31
 
    xx=[];ng=[];z=0;
32
 
    nx=0;nz=0;
33
 
    o=[];
34
 
    i=[];
35
 
    for nn = 1 : ip
36
 
      i=[i,1];
37
 
    end
38
 
    i=int(i(:));nin=size(i,1);
39
 
    ci=1;nevin=1;
40
 
    co=[];nevout=0;
41
 
    funtyp=2004;
42
 
    depu=%t;
43
 
    dept=%f;
44
 
    dep_ut=[depu dept];
45
 
 
46
 
    [ok,tt]=getCode_mbx_ovrwr_send(funam)
47
 
    if ~ok then break,end
48
 
    [model,graphics,ok]=check_io(model,graphics,i,o,ci,co)
49
 
    if ok then
50
 
      model.sim=list(funam,funtyp)
51
 
      model.in=i
52
 
      model.out=[]
53
 
      model.evtin=ci
54
 
      model.evtout=[]
55
 
      model.state=[]
56
 
      model.dstate=[]
57
 
      model.rpar=[]
58
 
      model.ipar=[]
59
 
      model.firing=[]
60
 
      model.dep_ut=dep_ut
61
 
      model.nzcross=0
62
 
      label(2)=tt
63
 
      x.model=model
64
 
      graphics.exprs=label
65
 
      x.graphics=graphics
66
 
      break
67
 
    end
68
 
  end
69
 
case 'define' then
70
 
  in=1
71
 
  insz = 1
72
 
  name = 'MBX'
73
 
  ipaddr = '127.0.0.1'
74
 
 
75
 
  model=scicos_model()
76
 
  model.sim=list(' ',2004)
77
 
  model.in=insz
78
 
  model.out=[]
79
 
  model.evtin=1
80
 
  model.evtout=[]
81
 
  model.state=[]
82
 
  model.dstate=[]
83
 
  model.rpar=[]
84
 
  model.ipar=[]
85
 
  model.blocktype='d'
86
 
  model.firing=[]
87
 
  model.dep_ut=[%t %f]
88
 
  model.nzcross=0
89
 
 
90
 
  label=list([sci2exp(in),name,ipaddr],[])
91
 
 
92
 
  gr_i=['xstringb(orig(1),orig(2),[''Mbx Send Ovw'';name],sz(1),sz(2),''fill'');']
93
 
  x=standard_define([3 2],model,label,gr_i)
94
 
 
95
 
end
96
 
endfunction
97
 
 
98
 
function [ok,tt]=getCode_mbx_ovrwr_send(funam)
99
 
   textmp=[
100
 
          '#ifndef MODEL'
101
 
          '#include <math.h>';
102
 
          '#include <stdlib.h>';
103
 
          '#include <scicos/scicos_block.h>';
104
 
          '#endif'
105
 
          '';
106
 
          'void '+funam+'(scicos_block *block,int flag)';
107
 
         ];
108
 
  textmp($+1)='{'
109
 
  textmp($+1)='#ifdef MODEL'
110
 
  textmp($+1)='static void * blk;'
111
 
  textmp($+1)='int i;'
112
 
  textmp($+1)='double u[' + string(nin) + '];'
113
 
  textmp($+1)='double t = get_scicos_time();' 
114
 
  textmp($+1)='  switch(flag) {'
115
 
  textmp($+1)='  case 4:'
116
 
  textmp($+1)='    blk=out_mbx_ovrwr_send_init('+ string(nin)+','+ '""' + name + '"",""'+ipaddr+'"");'
117
 
  textmp($+1)='    break;'; 
118
 
  textmp($+1)='  case 2:'
119
 
  textmp($+1)='    for (i=0;i<' + string(nin) + ';i++) u[i]=block->inptr[i][0];'
120
 
  textmp($+1)='    out_mbx_ovrwr_send_output(blk,u,t);'
121
 
  textmp($+1)='    break;'
122
 
  textmp($+1)='  case 5:'
123
 
  textmp($+1)='    out_mbx_ovrwr_send_end(blk);'
124
 
  textmp($+1)='    break;'
125
 
  textmp($+1)='  }'
126
 
  textmp($+1)='#endif'
127
 
  textmp($+1)='}'
128
 
  tt=textmp;
129
 
 
130
 
  ok = %t;
131
 
 
132
 
endfunction