Overview
Comment:TK viewer for simulation output (requires wish8.3).
- invoked with mtt sys gnuplot view.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 79f82d1a736f620353c0ee2b0d6779b6d48836a82ebfc4ab8525b1698cf01edb
User & Date: geraint@users.sourceforge.net on 2001-10-10 05:57:22
Other Links: branch diff | manifest | tags
Context
2001-10-11
00:22:52
Improved scrollbar, radio buttons; plot with lines. check-in: 93d647a0c7 user: geraint@users.sourceforge.net tags: origin/master, trunk
2001-10-10
05:57:22
TK viewer for simulation output (requires wish8.3).
- invoked with mtt sys gnuplot view.
check-in: 79f82d1a73 user: geraint@users.sourceforge.net tags: origin/master, trunk
2001-10-05
23:39:43
Made odes.dat2 .PRECIOUS to prevent deletion when simulation receives ^C. check-in: 1149469e42 user: geraint@users.sourceforge.net tags: origin/master, trunk
Changes

Added mttroot/mtt/bin/trans/struc2gnuplot_txt2wish version [ebd38b0a4a].

























































































































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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

sys=$1

out=${sys}_gnuplot.wish
tmp=${sys}_gnuplot.tmp

struc=${sys}_struc.txt
dat2=${sys}_odes.dat2

Nx=`mtt_getsize ${sys} x`
Ny=`mtt_getsize ${sys} y`


## write header
cat <<EOF > ${out}
#!/bin/sh
# Next line replaces shell with wish\\
exec wish "${out}" "$@"

## main window
wm title . "MTT Viewer: ${sys}"

button .print -text "Print" -command print
button .quit  -text "Quit"  -command exit

## states canvas
canvas		.cx
listbox		.cx.l
scrollbar	.cx.s
label		.cx.t	-text		"States"

## outputs canvas
canvas		.cy
listbox		.cy.l
scrollbar	.cy.s
label		.cy.t	-text		"Outputs"

## configure scrollbars
.cx.s configure -command ".cx.l yview"
.cy.s configure -command ".cy.l yview"
.cx configure -yscrollcommand ".cx.s set" -scrollregion "0 0 20 ${Nx}"
.cy configure -yscrollcommand ".cy.s set" -scrollregion "0 0 20 ${Ny}"

## bind lists
bind .cx.l <<ListboxSelect>> { plot [ .cx.l get anchor ] }
bind .cy.l <<ListboxSelect>> { plot [ .cy.l get anchor ] }

EOF

## create states and outputs lists
awk '
($1 == "state") {
    printf ".cx.l insert end state:%s\n", $4
}
($1 == "output") {
    printf ".cy.l insert end output:%s\n", $4
}' ${struc} >> ${out}

cat <<EOF >> ${out}

pack .cx.t -expand false -fill x -side top
pack .cy.t -expand false -fill x -side top

pack .cx.l -expand true -fill both -side left
pack .cy.l -expand true -fill both -side left

pack .cx.s -expand false -fill y -side right
pack .cy.s -expand false -fill y -side right

pack .cx -expand true -fill both
#pack .cy -expand true -fill both
radiobutton .states  -text "States"  -textvariable showx -command { .outputs deselect ; raise .cx }
radiobutton .outputs -text "Outputs" -textvariable showy -command { .states  deselect ; raise .cy }
place .cy -in .cx -relx 0 -rely 0 -relwidth 1 -relheight 1 -anchor nw -bordermode outside

pack .quit  -expand false -fill x -side right
pack .print -expand false -fill x -side right
pack .states .outputs -side right


## map names to column numbers
EOF

awk '
BEGIN {
    print "proc \"plot\" \"title\" {";
}
($1 == "state") {
    printf "if (\"%s\"==\"state:%s\") { plot_var \"%s\" %d }\n", Title, $4, $4, $2+2+Ny;
}
($1 == "output") {
    printf "if (\"%s\"==\"output:%s\") { plot_var \"%s\" %d }\n", Title, $4, $4, $2+1;
}    
END {
    print  "}"
}
' Title=\$title Ny=${Ny} ${struc} >> ${out}


cat <<EOF >> ${out}

## call gnuplot
proc "plot_var" "title column" {
    exec echo plot \"${dat2}\" using 1:\$column title \"\$title\" > ${tmp}
    exec echo pause -1 >> ${tmp}
    exec gnuplot -title "\$title" ${tmp} &
}

## print output
proc "print" "" {
    exec echo set term postscript > ${tmp}.print
    exec echo set output \\\"../${sys}_gnuplot.ps\\\" >> ${tmp}.print
    exec grep -v pause ${tmp} >> ${tmp}.print
    exec gnuplot ${tmp}.print
    puts "Graph printed to ${sys}_gnuplot.ps"
}

EOF
chmod +x ${out}

Modified mttroot/mtt/lib/rep/gnuplot_rep.make from [d9c045ea20] to [c53300960d].

1
2
3
4
5
6
7
8
9





10
11
12
13
14
15
16
1
2
3
4
5
6
7


8
9
10
11
12
13
14
15
16
17
18
19







-
-
+
+
+
+
+







# -*-makefile-*-
# create a gnuplot input file

MTTFLAGS	= $(OPTS)

all: $(SYS)_gnuplot.$(LANG)

$(SYS)_gnuplot.view: $(SYS)_gnuplot.txt $(SYS)_odes.dat2
	gnuplot $(SYS)_gnuplot.txt
$(SYS)_gnuplot.view: $(SYS)_gnuplot.wish $(SYS)_odes.dat2
	$(SYS)_gnuplot.wish

$(SYS)_gnuplot.wish: $(SYS)_struc.txt
	$(MTTPATH)/trans/struc2gnuplot_txt2wish $(SYS)

$(SYS)_gnuplot.txt: $(SYS)_struc.txt $(MTTPATH)/trans/struc2gnuplot_txt.exe
	$(MTTPATH)/trans/struc2gnuplot_txt.exe $(SYS) < $(SYS)_struc.txt > $(SYS)_gnuplot.txt

$(SYS)_struc.txt:
	mtt $(MTTFLAGS) $(SYS) struc txt


MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]