~ubuntu-branches/ubuntu/karmic/scilab/karmic

« back to all changes in this revision

Viewing changes to macros/scicos_blocks/DELAY_f.sci

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2002-03-21 16:57:43 UTC
  • Revision ID: james.westby@ubuntu.com-20020321165743-e9mv12c1tb1plztg
Tags: upstream-2.6
ImportĀ upstreamĀ versionĀ 2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
function [x,y,typ]=DELAY_f(job,arg1,arg2)
 
2
// Copyright INRIA
 
3
x=[];y=[],typ=[]
 
4
select job
 
5
case 'plot' then
 
6
  standard_draw(arg1)
 
7
case 'getinputs' then
 
8
  [x,y,typ]=standard_inputs(arg1)
 
9
case 'getoutputs' then
 
10
  [x,y,typ]=standard_outputs(arg1)
 
11
case 'getorigin' then
 
12
  [x,y]=standard_origin(arg1)
 
13
case 'set' then
 
14
  // paths to updatable parameters or states
 
15
  x=arg1
 
16
  ppath = list(4,5)
 
17
  newpar=list();
 
18
  register_label=x(3)(8)(4)(2)(4)
 
19
  evtdly_label=x(3)(8)(5)(2)(4)
 
20
  label=[evtdly_label(1);register_label]
 
21
  while %t do
 
22
    [ok,dt,z0,label]=getvalue(['This block implements as a discretised delay';
 
23
        'it is consist of a shift register and a clock';
 
24
        'value of the delay is given by;'
 
25
        'the discretisation time step multiplied by the';
 
26
        'number-1 of state of the register'],..
 
27
            ['Discretisation time step';
 
28
            'Register initial state'],list('vec',1,'vec',-1),label)
 
29
    if ~ok then break,end
 
30
    mess=[]
 
31
    if prod(size(z0))<2 then
 
32
      mess=[mess;'Register length must be at least 2';' ']
 
33
      ok=%f
 
34
    end    
 
35
    if dt<=0 then
 
36
      mess=[mess;'Discretisation time step must be positive';' ']
 
37
      ok=%f
 
38
    end
 
39
    if ~ok then message(mess);end
 
40
    if ok then
 
41
      //Change the clock
 
42
      x(3)(8)(5)(2)(4)(1)=label(1);
 
43
      x(3)(8)(5)(3)(11)=0; //initial delay firing date
 
44
      if x(3)(8)(5)(3)(8)<>dt then //Discretisation time step
 
45
        x(3)(8)(5)(3)(8)=dt
 
46
        newpar($+1)=5 // notify clock changes
 
47
      end
 
48
      //Change the register
 
49
      x(3)(8)(4)(2)(4)=label(2)
 
50
      if or(x(3)(8)(4)(3)(7)<>z0(:)) then //Register initial state
 
51
        x(3)(8)(4)(3)(7)=z0(:)
 
52
        newpar($+1)=4 // notify register changes
 
53
      end
 
54
      break
 
55
    end
 
56
  end
 
57
 
 
58
  needcompile=0
 
59
  y=needcompile
 
60
  typ=newpar
 
61
case 'define' then
 
62
  model = list('csuper',1,1,[],[],[],[],..
 
63
  list(list([600,400],'DELAY_f',[],[]),..
 
64
  list('Block',list([92,210],[20,20],%t,['1';'1'],[],7,[],[],[]),..
 
65
  list('input',[],1,[],[],[],[],[],1,'c',[],[%f,%f],' ',list()),' ','IN_f'),..
 
66
  list('Block',list([440,210],[20,20],%t,['1';'1'],6,[],[],[],[]),..
 
67
  list('output',1,[],[],[],[],[],[],1,'c',[],[%f,%f],' ',list()),' ','OUT_f'),..
 
68
  list('Block',list([238,195],[50,50],%t,'0;0;0;0;0;0;0;0;0;0',7,6,10,[],..
 
69
  ['dly=model(8);';'txt=[''Shift'';''Register'';string(dly)];';
 
70
  'xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'')']),..
 
71
  list('delay',1,1,1,[],[],zeros(10,1),[],[],'d',[],[%f,%f],' ',list()),' ','REGISTER_f'),..
 
72
  list('Block',list([243,296],[40,40],%t,['0.1';'1'],[],[],11,8,..
 
73
  ['dt=model(8);';'txt=[''Delay'';string(dt)];';
 
74
  'xstringb(orig(1),orig(2),txt,sz(1),sz(2),''fill'');']),..
 
75
  list('evtdly',[],[],1,1,[],[],0.1,[],'d',1,[%f,%f],' ',list()),' ','EVTDLY_f'),..
 
76
  list('Link',[296.6;440],[220;220],'drawlink',' ',[0,0],[1,1],[4,1],[3,1]),..
 
77
  list('Link',[112;229.4],[220;220],'drawlink',' ',[0,0],[1,1],[2,1],[4,1]),..
 
78
  list('Link',[263;263],[290.3;271.2],'drawlink',' ',[0,0],[5,-1],[5,1],[9,1]),..
 
79
  list('Block',list([263;271.2],[1,1],%t,' ',[],[],8,[10;11]),..
 
80
  list('lsplit',[],[],1,[1;1],[],[],[],[],'d',[-1,-1],[%t,%f],' ',list()),' ','CLKSPLIT_f'),..
 
81
  list('Link',[263;263],[271.2;250.7],'drawlink',' ',[0,0],[5,-1],[9,1],[4,1]),..
 
82
  list('Link',[263;308.6;308.6;263;263],[271.2;271.2;367;367;341.7],'drawlink',..
 
83
  ' ',[0,0],[5,-1],[9,2],[5,1])),[],'h',%f,[%f,%f])
 
84
  gr_i='xstringb(orig(1),orig(2),''Delay'',sz(1),sz(2),''fill'')'
 
85
  x=standard_define([2 2],model,'DELAY_f',gr_i)
 
86
end