diff options
author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2008-11-08 21:42:31 -0500 |
---|---|---|
committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2008-11-08 21:42:31 -0500 |
commit | f198d1acb2c9c897263ab46150dbe19af2550ce5 (patch) | |
tree | eeb06f1cb9acd3c6ce2b9d3103141db8fc626be0 | |
parent | 349b3d4954e480d08323d242ae13ad9242611b72 (diff) |
add wrapper script for drawing schedules
-rwxr-xr-x | st_draw | 156 |
1 files changed, 156 insertions, 0 deletions
@@ -0,0 +1,156 @@ | |||
1 | #!/bin/bash | ||
2 | # st_draw --- Draw binary sched_trace traces as nicely formatted PDFs. | ||
3 | # Copyright (C) 2008 B. Brandenburg, <bbb@cs.unc.edu> | ||
4 | # | ||
5 | # This program is free software; you can redistribute it and/or modify | ||
6 | # it under the terms of the GNU General Public License as published by | ||
7 | # the Free Software Foundation; either version 2 of the License, or | ||
8 | # (at your option) any later version. | ||
9 | # | ||
10 | # This program is distributed in the hope that it will be useful, | ||
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | # GNU General Public License for more details. | ||
14 | # | ||
15 | # You should have received a copy of the GNU General Public License along | ||
16 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
17 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | |||
19 | |||
20 | ST_SHOW=showst | ||
21 | ST2PL=st2pl | ||
22 | ASY=asy | ||
23 | SHOW_PDF=evince | ||
24 | |||
25 | function die { | ||
26 | echo "(EE) $*" | ||
27 | exit 1 | ||
28 | } | ||
29 | |||
30 | function info { | ||
31 | echo "(II) $*" | ||
32 | } | ||
33 | |||
34 | KEEP= | ||
35 | NO_SHOW= | ||
36 | NAME= | ||
37 | FROM= | ||
38 | TO= | ||
39 | LENGTH=1000 | ||
40 | while true | ||
41 | do | ||
42 | case "$1" in | ||
43 | -f | --from) | ||
44 | shift | ||
45 | FROM=$1 | ||
46 | shift | ||
47 | ;; | ||
48 | -t | --to) | ||
49 | shift | ||
50 | TO=$1 | ||
51 | shift | ||
52 | ;; | ||
53 | -l | --length) | ||
54 | shift | ||
55 | LENGTH=$1 | ||
56 | shift | ||
57 | ;; | ||
58 | -k | --keep) | ||
59 | KEEP=yes | ||
60 | shift | ||
61 | ;; | ||
62 | --no-show) | ||
63 | NO_SHOW=yes | ||
64 | shift | ||
65 | ;; | ||
66 | -n | --name) | ||
67 | shift | ||
68 | NAME=$1 | ||
69 | shift | ||
70 | ;; | ||
71 | -h | --help) | ||
72 | cat <<EOF | ||
73 | LITMUS^RT Schedule Drawing Utility | ||
74 | (c) 2008 B. Brandenburg <bbb@cs.unc.edu> | ||
75 | |||
76 | Usage: st_draw [OPTIONS] <sched trace file>+ | ||
77 | |||
78 | Options: | ||
79 | -f FROM | ||
80 | --from FROM Start at time FROM. | ||
81 | Time of system release if not specified. | ||
82 | |||
83 | -l LENGTH | ||
84 | --length LENGTH Draw schedule of length LENGTH. (Default: 1000) | ||
85 | |||
86 | -t TO | ||
87 | --to TO Draw schedule up to time TO. (Default: FROM + LENGTH) | ||
88 | If given, then LENGTH is ignored. | ||
89 | |||
90 | -n NAME | ||
91 | --name NAME Filename to use. | ||
92 | |||
93 | -k | ||
94 | --keep Keep the generated .asy/.pdf files. | ||
95 | |||
96 | --no-show Don't start a PDF document viewer. | ||
97 | |||
98 | -h | ||
99 | --help Show this message and exit. | ||
100 | EOF | ||
101 | exit 0 | ||
102 | ;; | ||
103 | *) | ||
104 | break | ||
105 | ;; | ||
106 | esac | ||
107 | done | ||
108 | |||
109 | TRACES=$* | ||
110 | info "Trace files: $TRACES" | ||
111 | |||
112 | if [ -z "$FROM" ] | ||
113 | then | ||
114 | info "Searching for task system release..." | ||
115 | FROM=`$ST_SHOW $TRACES | grep SYS_RELEASE | head -1 | awk '{print $8}' | sed 's/\.[0-9]*ms//'` | ||
116 | if [ -z "$FROM" ] | ||
117 | then | ||
118 | error "No task system release found in trace." | ||
119 | else | ||
120 | info "Task system released at $FROM." | ||
121 | fi | ||
122 | fi | ||
123 | |||
124 | if [ -z "$TO" ] | ||
125 | then | ||
126 | TO=$(($FROM + $LENGTH)) | ||
127 | fi | ||
128 | |||
129 | info "Drawing schedule from $FROM to $TO." | ||
130 | |||
131 | if [ ! -z "$NAME" ] | ||
132 | then | ||
133 | SCHED="${NAME}.asy" | ||
134 | PDF="${NAME}.pdf" | ||
135 | else | ||
136 | SCHED=`mktemp` | ||
137 | PDF=`mktemp` | ||
138 | fi | ||
139 | |||
140 | info "Drawing schedule..." | ||
141 | $ST2PL -lasy -f $FROM -t $TO -s 0.4 $TRACES > $SCHED || die "$ST2PL failed." | ||
142 | info "Generating PDF..." | ||
143 | $ASY -f pdf -o $PDF $SCHED || die "$ASY failed." | ||
144 | |||
145 | if [ -z "$NO_SHOW" ] | ||
146 | then | ||
147 | $SHOW_PDF $PDF || die "$SHOW_PDF failed." | ||
148 | fi | ||
149 | |||
150 | if [ -z "$KEEP" ] | ||
151 | then | ||
152 | rm -f $SCHED $PDF | ||
153 | else | ||
154 | info "ASY: $SCHED" | ||
155 | info "PDF: $PDF" | ||
156 | fi | ||