source: branches/gui/sample/miscellaneous/sample_timer.mso @ 925

Last change on this file since 925 was 925, checked in by Rafael de Pelegrini Soares, 12 years ago

Added a simple open/close timer sample

File size: 609 bytes
Line 
1
2using "types";
3
4FlowSheet sample_timer
5    PARAMETERS
6    Timer as Switcher(Valid = ["closed", "opened"], Default = "closed");
7       
8        TimeOpened as time_sec;
9        TimeClosed as time_sec;
10
11        VARIABLES
12        Clock as time_h;
13        flow as flow_vol;
14       
15        SET
16        TimeOpened = 2*'s';
17        TimeClosed = 4*'s';
18       
19    EQUATIONS
20
21    switch Timer
22        case "closed":
23                flow = 0 * 'm^3/h';
24               
25                diff(Clock) = 1*'s'/TimeClosed;
26                when Clock/'s' > 1 switchto "opened";
27
28        case "opened":
29                flow = 1 * 'm^3/h';
30               
31                diff(Clock) = -1*'s'/TimeOpened;
32                when Clock/'s' < 0 switchto "closed";
33        end
34       
35        INITIAL
36        Clock = 0*'s';
37       
38        OPTIONS
39        TimeStep = 0.1;
40end
41
Note: See TracBrowser for help on using the repository browser.