summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern B. Brandenburg <bbb@cs.unc.edu>2008-11-08 21:42:31 -0500
committerBjoern B. Brandenburg <bbb@cs.unc.edu>2008-11-08 21:42:31 -0500
commitf198d1acb2c9c897263ab46150dbe19af2550ce5 (patch)
treeeeb06f1cb9acd3c6ce2b9d3103141db8fc626be0
parent349b3d4954e480d08323d242ae13ad9242611b72 (diff)
add wrapper script for drawing schedules
-rwxr-xr-xst_draw156
1 files changed, 156 insertions, 0 deletions
diff --git a/st_draw b/st_draw
new file mode 100755
index 0000000..55a97f2
--- /dev/null
+++ b/st_draw
@@ -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
20ST_SHOW=showst
21ST2PL=st2pl
22ASY=asy
23SHOW_PDF=evince
24
25function die {
26 echo "(EE) $*"
27 exit 1
28}
29
30function info {
31 echo "(II) $*"
32}
33
34KEEP=
35NO_SHOW=
36NAME=
37FROM=
38TO=
39LENGTH=1000
40while true
41do
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
73LITMUS^RT Schedule Drawing Utility
74(c) 2008 B. Brandenburg <bbb@cs.unc.edu>
75
76Usage: st_draw [OPTIONS] <sched trace file>+
77
78Options:
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.
100EOF
101 exit 0
102 ;;
103 *)
104 break
105 ;;
106 esac
107done
108
109TRACES=$*
110info "Trace files: $TRACES"
111
112if [ -z "$FROM" ]
113then
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
122fi
123
124if [ -z "$TO" ]
125then
126 TO=$(($FROM + $LENGTH))
127fi
128
129info "Drawing schedule from $FROM to $TO."
130
131if [ ! -z "$NAME" ]
132then
133 SCHED="${NAME}.asy"
134 PDF="${NAME}.pdf"
135else
136 SCHED=`mktemp`
137 PDF=`mktemp`
138fi
139
140info "Drawing schedule..."
141$ST2PL -lasy -f $FROM -t $TO -s 0.4 $TRACES > $SCHED || die "$ST2PL failed."
142info "Generating PDF..."
143$ASY -f pdf -o $PDF $SCHED || die "$ASY failed."
144
145if [ -z "$NO_SHOW" ]
146then
147 $SHOW_PDF $PDF || die "$SHOW_PDF failed."
148fi
149
150if [ -z "$KEEP" ]
151then
152 rm -f $SCHED $PDF
153else
154 info "ASY: $SCHED"
155 info "PDF: $PDF"
156fi