- Timestamp:
- Mar 15, 2013 9:49:06 AM (11 years ago)
- Location:
- trunk/gui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/apps/Makefile.in
r3501 r3507 34 34 $(srcdir)/flowvis-test \ 35 35 $(srcdir)/rpdiff \ 36 $(srcdir)/rptimes \ 36 37 rappture \ 37 38 rappture.env \ 38 39 rappture-csh.env \ 39 40 rappture.use \ 40 rpdiff \41 rptimes \42 41 rerun \ 43 42 simsim \ -
trunk/gui/apps/rptimes
r3501 r3507 45 45 46 46 # ---------------------------------------------------------------------- 47 # USAGE: normval <libObj> <rappturePath> ?-default? 48 # 49 # Returns information about the normalized value of a particular input 50 # in the Rappture run <libObj> at the specified <rappturePath> for the 51 # input. The optional -default switch causes the processing to apply 52 # to the default value instead of the current value. 53 # 54 # Returns info as a list of values in the form: 55 # 56 # <rappturePath> <type> <normValue> 57 # <rappturePath2> <type2> <normValue2> 58 # ... 59 # 60 # Most inputs return just 3 values: path/type/value. But some inputs 61 # split into multiple parts and return several triples. Images, for 62 # example, return a hash for the image itself, but also width/height 63 # parameters. The width/height may actually be the better predictors 64 # of CPU time required. 65 # ---------------------------------------------------------------------- 66 proc normval {libobj path {what "-current"}} { 67 set rlist "" 68 69 # get the default or the current raw value 70 set raw "" 71 switch -- $what { 72 -default { 73 set raw [$libobj get $path.default] 74 } 75 -current { 76 if {[$libobj element $path.current] ne ""} { 77 set raw [$libobj get $path.current] 78 } else { 79 set raw [$libobj get $path.default] 80 } 81 } 82 default { 83 error "bad option \"$what\": should be -current or -default" 84 } 85 } 86 87 # normalize the value depending on the type 88 switch -- [$libobj element -as type $path] { 89 integer { 90 lappend rlist $path "INTEGER" $raw 91 } 92 number { 93 set norm "" 94 if {$raw ne ""} { 95 # then normalize to default units 96 set units [$libobj get $path.units] 97 if {$units ne ""} { 98 set norm [Rappture::Units::convert $raw \ 99 -context $units -to $units -units off] 100 } 101 } 102 lappend rlist $path "REAL" $norm 103 } 104 boolean - choice - loader - periodicelement { 105 lappend rlist $path "TEXT" $raw 106 } 107 image { 108 # convert long string inputs into a unique (short) hash 109 set norm [base64::encode [md5::md5 $raw]] 110 if {[catch {package require Img; wm withdraw .} result]} { 111 error "can't analyze <image> types: $result" 112 } 113 if {[catch {image create photo -data $raw} result]} { 114 error "can't analyze <image> data: $result" 115 } 116 set width [image width $result] 117 set height [image height $result] 118 119 lappend rlist $path "TEXT" $norm 120 lappend rlist $path-WIDTH "INTEGER" $width 121 lappend rlist $path-HEIGHT "INTEGER" $height 122 } 123 string { 124 # convert long string inputs into a unique (short) hash 125 set norm [base64::encode [md5::md5 $raw]] 126 lappend rlist $path "TEXT" $norm 127 } 128 structure { 129 # oops! structure doesn't have a clear .current value 130 # use the XML dump of the data as its "value" 131 if {$what eq "-current"} { 132 if {[catch {$libobj xml $path.current} raw]} { 133 if {[catch {$libobj xml $path.default} raw]} { 134 set raw "" 135 } 136 } 137 } elseif {[catch {$libobj xml $path.default} raw]} { 138 set raw "" 139 } 140 set norm [base64::encode [md5::md5 $raw]] 141 lappend rlist $path "TEXT" $norm 142 } 143 default { 144 # for anything else, punt and use the raw value 145 lappend rlist $path "TEXT" $raw 146 } 147 } 148 return $rlist 149 } 47 150 48 151 # … … 104 207 set vals "" 105 208 foreach path [Rappture::entities $libobj input] { 106 set def [$libobj get $path.default] 107 foreach {raw norm} [Rappture::LibraryObj::value $libobj $path] break 108 109 switch -- [$libobj element -as type $path] { 110 integer { 111 set type "INTEGER" 112 } 113 number { 114 set type "REAL" 115 } 116 boolean - choice - loader - periodicelement { 117 set type "TEXT" 118 } 119 image - string { 120 # convert long string inputs into a unique (short) hash 121 set norm [base64::encode [md5::md5 $norm]] 122 set type "TEXT" 123 } 124 default { 125 set type "TEXT" 126 } 127 } 128 209 # get the nickname (column name) for this paraemter 129 210 set id [db eval "SELECT nickName from parameters where rappturePath='$path'"] 130 211 if {$id eq ""} { 131 212 # haven't seen this parameter before -- add it 213 foreach {rp type def} [normval $libobj $path -default] { 214 set num [db eval "SELECT COUNT(nickName) from parameters;"] 215 set id [format "x%03d" [incr num]] 216 217 db eval "INSERT INTO parameters values('$id','$rp','$def','$type')" 218 db eval "ALTER TABLE jobs ADD COLUMN $id $type;" 219 } 220 } 221 222 # add the current value onto the values we're building up for ALTER 223 foreach {raw norm} [Rappture::LibraryObj::value $libobj $path] break 224 225 foreach {rp type val} [normval $libobj $path] { 132 226 set num [db eval "SELECT COUNT(nickName) from parameters;"] 133 set id [format "x%03d" [incr num]] 134 db eval "INSERT INTO parameters values('$id','$path','$def','$type')" 135 db eval "ALTER TABLE jobs ADD COLUMN $id $type;" 136 } 137 138 lappend cols $id 139 if {$type eq "TEXT"} { 140 lappend vals '$norm' 141 } else { 142 lappend vals $norm 143 } 144 } 145 146 # add the info for this job 147 db eval "DELETE from jobs WHERE runToken='$runtoken';" 148 db eval "INSERT INTO jobs (runToken,date,cpuTime,wallTime,nCpus,venue,[join $cols ,]) values ('$runtoken','$date',$cput,$wallt,$ncpus,'$venue',[join $vals ,]);" 227 set id [db eval "SELECT nickName FROM parameters WHERE rappturePath='$rp'"] 228 if {$id eq ""} { 229 set err "INTERNAL ERROR: couldn't find nickName for existing parameter $rp" 230 break 231 } 232 lappend cols $id 233 if {$type eq "TEXT"} { 234 lappend vals '$val' 235 } else { 236 lappend vals $val 237 } 238 } 239 } 240 241 if {$err eq ""} { 242 # add the info for this job 243 db eval "DELETE from jobs WHERE runToken='$runtoken';" 244 db eval "INSERT INTO jobs (runToken,date,cpuTime,wallTime,nCpus,venue,[join $cols ,]) values ('$runtoken','$date',$cput,$wallt,$ncpus,'$venue',[join $vals ,]);" 245 } 149 246 } 150 247 … … 153 250 set status 1 154 251 } 252 catch {db close} 155 253 } 156 254 157 catch {db close}158 255 exit $status -
trunk/gui/scripts/tool.tcl
r3501 r3507 133 133 # ---------------------------------------------------------------------- 134 134 itcl::body Rappture::Tool::run {args} { 135 global e rrorInfo135 global env errorInfo 136 136 137 137 # … … 328 328 $result put output.walltime $times(walltime) 329 329 $result put output.cputime $times(cputime) 330 if {[info exists env(SESSION)]} { 331 $result put output.session $env(SESSION) 332 } 330 333 } else { 331 334 global errorInfo
Note: See TracChangeset
for help on using the changeset viewer.