~ubuntu-branches/ubuntu/hoary/scilab/hoary

« back to all changes in this revision

Viewing changes to macros/scicos_blocks/Electrical/SineVoltage.sci

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2005-01-09 22:58:21 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050109225821-473xr8vhgugxxx5j
Tags: 3.0-12
changed configure.in to build scilab's own malloc.o, closes: #255869

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
function [x,y,typ]= SineVoltage(job,arg1,arg2)
 
2
// Copyright INRIA
 
3
// exemple d'un bloc implicit, 
 
4
//   -  sans entree ni sortie de conditionnement
 
5
//   -  avec une entree et une sortie de type implicit et de dimension 1
 
6
//   - avec un dialogue de saisie de parametre
 
7
x=[];y=[];typ=[];
 
8
select job
 
9
case 'plot' then
 
10
  standard_draw(arg1,%f)
 
11
case 'getinputs' then
 
12
  [x,y,typ]=standard_inputs(arg1)
 
13
case 'getoutputs' then
 
14
  [x,y,typ]=standard_outputs(arg1)
 
15
case 'getorigin' then
 
16
  [x,y]=standard_origin(arg1)
 
17
case 'set' then
 
18
  x=arg1;
 
19
  graphics=arg1.graphics;exprs=graphics.exprs
 
20
  model=arg1.model;
 
21
  while %t do
 
22
    [ok,V,ph,frq,offset,start,exprs]=getvalue('Set voltage source parameter',..
 
23
                           ['Amplitude (Volt)','phase (rad)','Frequency (Hz)','Voltageoffset (V)','Timeoffset (s)'],..
 
24
                              list('vec',1,'vec',1,'vec',1,'vec',1,'vec',1),exprs)
 
25
    if ~ok then break,end
 
26
    model.rpar=[V;ph;frq;offset;start]
 
27
    model.equations.parameters(2)=list(V,ph,frq,offset,start)
 
28
    graphics.exprs=exprs
 
29
    x.graphics=graphics;x.model=model
 
30
    break
 
31
  end
 
32
case 'define' then
 
33
  model=scicos_model()
 
34
  model.in=[1];
 
35
  model.out=[1];
 
36
  V=1
 
37
  ph=0
 
38
  frq=1
 
39
  offset=0
 
40
  start=0
 
41
  model.rpar=[V;ph;frq;offset;start]
 
42
  model.sim='SineVoltage'
 
43
  model.blocktype='c'
 
44
  model.dep_ut=[%t %f]
 
45
  mo=modelica()
 
46
  mo.model='SineVoltage'
 
47
  mo.inputs='p';
 
48
  mo.outputs='n';
 
49
  mo.parameters=list(['V';'phase';'freqHz';'offset';'startTime'],list(V,ph,frq,offset,start))
 
50
  model.equations=mo
 
51
  
 
52
  exprs=[string(V);string(ph);string(frq);string(offset);string(start)]
 
53
  
 
54
  gr_i=['xarc(orig(1)+sz(1)*1/8,orig(2)+sz(2)*4.3/5,sz(1)*3/4,sz(2)*3/4,0,360*64);';
 
55
        'xsegs(orig(1)+sz(1)*[0 1/8],orig(2)+sz(2)*[1/2 1/2],0)';
 
56
        'xsegs(orig(1)+sz(1)*[7/8 1],orig(2)+sz(2)*[1/2 1/2],0)';
 
57
        'V=string(model.rpar(1));'
 
58
        'xstringb(orig(1),orig(2)+sz(2)*0.2,''~'',sz(1),sz(2)*0.3,''fill'')'
 
59
        'xstringb(orig(1),orig(2)+sz(2)*0.5,V,sz(1),sz(2)*0.3,''fill'')']
 
60
  
 
61
  
 
62
  x=standard_define([2 2],model,exprs,gr_i)
 
63
  x.graphics.in_implicit=['I']
 
64
  x.graphics.out_implicit=['I']
 
65
end
 
66
endfunction