File: tut6

package info (click to toggle)
scilab 4.0-12
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 100,640 kB
  • ctags: 57,333
  • sloc: ansic: 377,889; fortran: 242,862; xml: 179,819; tcl: 42,062; sh: 10,593; ml: 9,441; makefile: 4,377; cpp: 1,354; java: 621; csh: 260; yacc: 247; perl: 130; lex: 126; asm: 72; lisp: 30
file content (129 lines) | stat: -rw-r--r-- 3,649 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
-2,0,-2,-1,"execstr(Misc_1000(15))"// Misc/Comment
//x_dialog:Enter comments
  Scicos tutorial: Defining a new block using CBlock2.
  This requires the presence of a C compiler on the
  system.
  We start with the diagram from the previous tutorial.
  o //OK
-2,0,-2,-1,"execstr(Diagram_1000(8))"// Diagram/Load
//xgetfile: 
diagram5.cos
-2,0,-2,-1,"execstr(Edit_1000(1))"// Edit/Palettes
//x_choose:  Choose a Palette
  7//Others
0,368,20.8,1001,"void"// Palette: Others, Block: 6 CBLOCK
257.9,277.2,-1//xgemouse
243,272.7,-1//xgemouse
242.3,273.4,-1//xgemouse
241.5,274.2,-1//xgemouse
240.8,274.9,-1//xgemouse
240.8,275.7,-1//xgemouse
240.8,276.4,-1//xgemouse
240.8,277.2,-1//xgemouse
240.1,277.2,-1//xgemouse
240.1,278.6,-1//xgemouse
243,284.6,-1//xgemouse
243,283.9,-1//xgemouse
244.5,283.9,-1//xgemouse
245.3,283.1,-1//xgemouse
246,282.4,-1//xgemouse
249,279.4,-1//xgemouse
250.5,278.6,-1//xgemouse
252,278.6,-1//xgemouse
256.4,277.2,-1//xgemouse
257.9,277.2,-1//xgemouse
258.7,276.4,-1//xgemouse
259.4,276.4,-1//xgemouse
260.2,276.4,-1//xgemouse
259.4,276.4,-1//xgemouse
259.4,277.2,-1//xgemouse
259.4,276.4,-1//xgemouse
260.2,276.4,-1//xgemouse
260.2,275.7,-1//xgemouse
260.2,274.9,-1//xgemouse
260.2,274.2,-1//xgemouse
260.2,273.4,-1//xgemouse
260.2,272.7,-1//xgemouse
260.2,271.9,-1//xgemouse
260.2,271.2,-1//xgemouse
260.2,271.9,-1//xgemouse
260.9,271.9,-1//xgemouse
260.9,271.9,0//xgemouse
-2,0,-2,-1,"execstr(Misc_1000(15))"// Misc/Comment
//x_dialog:Enter comments
  We grab the Cblock2 block from the Others palette.
  This block is used to define block behavior on line
  in C language.
  o //OK
0,281,292.8,1000,"void"// Block: 17 CBLOCK
//x_mdialog: Set C-Block2 block parameters
  toto
  n
  1
  1
  1
  []
  []
  0
  [0;0;0]
  []
  []
  []
  n
  n
  o //OK
//x_dialog:Function definition in C
  #include <math.h>
  #include <stdlib.h>
  #include <scicos/scicos_block.h>
  void toto(scicos_block *block,int flag)
  {
    if (flag == 4) { /* initialization */
     toto_bloc_init(block,flag);
   
    } else if(flag == 1) { /* output computation*/
     set_block_error(toto_bloc_outputs(block,flag));
    } else if(flag == 2) { /* computation of next discrte state*/ 
       set_block_error(toto_bloc_states(block,flag));
    } else  if (flag == 5) { /* ending */
       set_block_error(toto_bloc_ending(block,flag));
    }
  }
  int toto_bloc_init(scicos_block *block,int flag)
  {
  return 0;}
  int toto_bloc_outputs(scicos_block *block,int flag)
  {
  block->outptr[0][0]=block->z[2];
  return 0;}
  int toto_bloc_states(scicos_block *block,int flag)
  {
  block->z[2]=block->z[2]+(get_scicos_time()-block->z[0])*block->z[1];
  block->z[0]=get_scicos_time();
  block->z[1]=block->inptr[0][0];
  return 0;}
  int toto_bloc_ending(scicos_block *block,int flag)
  {
  return 0;}
  o //OK
-2,0,-2,-1,"execstr(Misc_1000(15))"// Misc/Comment
//x_dialog:Enter comments
  we now replace the Scifunc with the new Cblock2 block
  which is supposed to do the same thing a lot more efficiently.
  o //OK
-2,0,-2,-1,"execstr(Edit_1000(7))"// Edit/Replace
0,278.8,289.8,1000,"void"// Block: 17 CBLOCK
0,222.9,224.2,1000,"void"// Block: 2 scifunc_block
-2,0,-2,-1,"execstr(Edit_1000(10))"// Edit/Delete
0,288.4,294.3,1000,"void"// Block: 17 CBLOCK
-2,0,-2,-1,"execstr(Diagram_1000(5))"// Diagram/Rename
//x_dialog:Enter the new diagram name
  diagram6
  o //OK
-2,0,-2,-1,"execstr(Diagram_1000(6))"// Diagram/Save
-2,0,-2,-1,"execstr(Simulate_1000(5))"// Simulate/Run
-2,0,-2,-1,"execstr(Misc_1000(15))"// Misc/Comment
//x_dialog:Enter comments
  This is confirmed by simulation.
  o //OK
-2,0,-2,-1,"execstr(Diagram_1000(16))"// Diagram/Quit