Changeset 5029
- Timestamp:
- Feb 17, 2015 5:49:36 PM (9 years ago)
- Location:
- branches/uq
- Files:
-
- 6 added
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/uq/Makefile.in
r4544 r5029 40 40 endif 41 41 ifneq ($(ENABLE_GUI),) 42 TARGETS += gui builder tester examples 42 TARGETS += gui builder tester examples puq 43 43 endif 44 44 ifneq ($(HAVE_FFMPEG),) … … 57 57 $(MAKE) -C test all 58 58 59 install: 59 install: 60 60 for i in $(TARGETS) ; do \ 61 61 $(MAKE) -C $$i install || exit 1 ;\ 62 62 done 63 63 64 clean: 64 clean: 65 65 for i in $(TARGETS) ; do \ 66 66 $(MAKE) -C $$i clean || exit 1 ;\ … … 73 73 done 74 74 75 package: 75 package: 76 76 tar -C $(pkg_path) -czlf $(rappture_binary_tarfile) $(pkg_name) 77 77 78 distrib: 78 distrib: 79 79 $(RM) -r exported 80 80 $(MKDIR_P) -m 0755 exported -
branches/uq/configure
r4798 r5029 10213 10213 10214 10214 10215 ac_config_files="$ac_config_files Makefile packages/Makefile src/Makefile src/core/Makefile src/core2/Makefile src/objects/Makefile src/objects/RpHash.h gui/Makefile gui/apps/Makefile gui/apps/about gui/apps/copy_rappture_examples gui/apps/encodedata gui/apps/rappture gui/apps/rappture-csh.env gui/apps/rappture.env gui/apps/rappture.use gui/apps/rerun gui/apps/simsim gui/apps/xmldiff gui/pkgIndex.tcl gui/scripts/Makefile gui/src/Makefile builder/Makefile builder/pkgIndex.tcl builder/scripts/Makefile tester/Makefile tester/pkgIndex.tcl tester/scripts/Makefile lang/Makefile lang/java/Makefile lang/java/rappture/Makefile lang/perl/Makefile lang/perl/Makefile.PL lang/python/Makefile lang/python/setup.py lang/matlab/Makefile lang/octave/Makefile lang/octave/octave2/Makefile lang/octave/octave3/Makefile lang/R/Makefile lang/ruby/Makefile lang/ruby/build.rb lang/tcl/Makefile lang/tcl/pkgIndex.tcl lang/tcl/scripts/Makefile lang/tcl/src/Makefile lang/tcl/tests/Makefile lib/Makefile examples/3D/Makefile examples/Makefile examples/app-fermi/2.0/Makefile examples/app-fermi/Makefile examples/app-fermi/cee/Makefile examples/app-fermi/fortran/Makefile examples/app-fermi/java/Makefile examples/app-fermi/matlab/Makefile examples/app-fermi/matlab/compiled/Makefile examples/app-fermi/matlab/uncompiled/Makefile examples/app-fermi/octave/octave2/Makefile examples/app-fermi/octave/octave3/Makefile examples/app-fermi/octave/Makefile examples/app-fermi/perl/Makefile examples/app-fermi/python/Makefile examples/app-fermi/ruby/Makefile examples/app-fermi/tcl/Makefile examples/app-fermi/wrapper/Makefile examples/app-fermi/wrapper/cee/Makefile examples/app-fermi/wrapper/perl/Makefile examples/app-fermi/wrapper/python/Makefile examples/app-fermi/wrapper/tcl/Makefile examples/app-fermi/R/Makefile examples/c-example/Makefile examples/canvas/Makefile examples/demo.bash examples/flow/Makefile examples/flow/demo1/Makefile examples/flow/demo2/Makefile examples/flow/demo3/Makefile examples/graph/Makefile examples/objects/Makefile examples/objects/axis/Makefile examples/objects/curve/Makefile examples/objects/dxWriter/Makefile examples/objects/floatBuffer/Makefile examples/objects/histogram/Makefile examples/objects/library/Makefile examples/objects/number/Makefile examples/objects/path/Makefile examples/objects/plot/Makefile examples/objects/scatter/Makefile examples/objects/string/Makefile examples/objects/tree/Makefile examples/objects/xmlparser/Makefile examples/zoo/Makefile examples/zoo/binary/Makefile examples/zoo/boolean/Makefile examples/zoo/choice/Makefile examples/zoo/curve/Makefile examples/zoo/drawing/Makefile examples/zoo/enable/Makefile examples/zoo/field/Makefile examples/zoo/group/Makefile examples/zoo/histogram/Makefile examples/zoo/image/Makefile examples/zoo/image/docs/Makefile examples/zoo/image/examples/Makefile examples/zoo/integer/Makefile examples/zoo/integer2/Makefile examples/zoo/loader/Makefile examples/zoo/loader/examples/Makefile examples/zoo/log/Makefile examples/zoo/mesh/Makefile examples/zoo/note/Makefile examples/zoo/note/docs/Makefile examples/zoo/number/Makefile examples/zoo/number2/Makefile examples/zoo/parallelepiped/Makefile examples/zoo/periodicelement/Makefile examples/zoo/phase/Makefile examples/zoo/sequence/Makefile examples/zoo/sequence/examples/Makefile examples/zoo/string/Makefile examples/zoo/structure/Makefile examples/zoo/structure/examples/Makefile examples/zoo/table/Makefile video/Makefile video/pkgIndex.tcl oldtest/Makefile oldtest/src/Makefile "10215 ac_config_files="$ac_config_files Makefile packages/Makefile src/Makefile src/core/Makefile src/core2/Makefile src/objects/Makefile src/objects/RpHash.h gui/Makefile gui/apps/Makefile gui/apps/about gui/apps/copy_rappture_examples gui/apps/encodedata gui/apps/rappture gui/apps/rappture-csh.env gui/apps/rappture.env gui/apps/rappture.use gui/apps/rerun gui/apps/simsim gui/apps/xmldiff gui/pkgIndex.tcl gui/scripts/Makefile gui/src/Makefile builder/Makefile builder/pkgIndex.tcl builder/scripts/Makefile tester/Makefile tester/pkgIndex.tcl tester/scripts/Makefile lang/Makefile lang/java/Makefile lang/java/rappture/Makefile lang/perl/Makefile lang/perl/Makefile.PL lang/python/Makefile lang/python/setup.py lang/matlab/Makefile lang/octave/Makefile lang/octave/octave2/Makefile lang/octave/octave3/Makefile lang/R/Makefile lang/ruby/Makefile lang/ruby/build.rb lang/tcl/Makefile lang/tcl/pkgIndex.tcl lang/tcl/scripts/Makefile lang/tcl/src/Makefile lang/tcl/tests/Makefile lib/Makefile examples/3D/Makefile examples/Makefile examples/app-fermi/2.0/Makefile examples/app-fermi/Makefile examples/app-fermi/cee/Makefile examples/app-fermi/fortran/Makefile examples/app-fermi/java/Makefile examples/app-fermi/matlab/Makefile examples/app-fermi/matlab/compiled/Makefile examples/app-fermi/matlab/uncompiled/Makefile examples/app-fermi/octave/octave2/Makefile examples/app-fermi/octave/octave3/Makefile examples/app-fermi/octave/Makefile examples/app-fermi/perl/Makefile examples/app-fermi/python/Makefile examples/app-fermi/ruby/Makefile examples/app-fermi/tcl/Makefile examples/app-fermi/wrapper/Makefile examples/app-fermi/wrapper/cee/Makefile examples/app-fermi/wrapper/perl/Makefile examples/app-fermi/wrapper/python/Makefile examples/app-fermi/wrapper/tcl/Makefile examples/app-fermi/R/Makefile examples/c-example/Makefile examples/canvas/Makefile examples/demo.bash examples/flow/Makefile examples/flow/demo1/Makefile examples/flow/demo2/Makefile examples/flow/demo3/Makefile examples/graph/Makefile examples/objects/Makefile examples/objects/axis/Makefile examples/objects/curve/Makefile examples/objects/dxWriter/Makefile examples/objects/floatBuffer/Makefile examples/objects/histogram/Makefile examples/objects/library/Makefile examples/objects/number/Makefile examples/objects/path/Makefile examples/objects/plot/Makefile examples/objects/scatter/Makefile examples/objects/string/Makefile examples/objects/tree/Makefile examples/objects/xmlparser/Makefile examples/zoo/Makefile examples/zoo/binary/Makefile examples/zoo/boolean/Makefile examples/zoo/choice/Makefile examples/zoo/curve/Makefile examples/zoo/drawing/Makefile examples/zoo/enable/Makefile examples/zoo/field/Makefile examples/zoo/group/Makefile examples/zoo/histogram/Makefile examples/zoo/image/Makefile examples/zoo/image/docs/Makefile examples/zoo/image/examples/Makefile examples/zoo/integer/Makefile examples/zoo/integer2/Makefile examples/zoo/loader/Makefile examples/zoo/loader/examples/Makefile examples/zoo/log/Makefile examples/zoo/mesh/Makefile examples/zoo/note/Makefile examples/zoo/note/docs/Makefile examples/zoo/number/Makefile examples/zoo/number2/Makefile examples/zoo/parallelepiped/Makefile examples/zoo/periodicelement/Makefile examples/zoo/phase/Makefile examples/zoo/sequence/Makefile examples/zoo/sequence/examples/Makefile examples/zoo/string/Makefile examples/zoo/structure/Makefile examples/zoo/structure/examples/Makefile examples/zoo/table/Makefile video/Makefile video/pkgIndex.tcl oldtest/Makefile oldtest/src/Makefile puq/Makefile" 10216 10216 10217 10217 cat >confcache <<\_ACEOF … … 11037 11037 "oldtest/Makefile") CONFIG_FILES="$CONFIG_FILES oldtest/Makefile" ;; 11038 11038 "oldtest/src/Makefile") CONFIG_FILES="$CONFIG_FILES oldtest/src/Makefile" ;; 11039 "puq/Makefile") CONFIG_FILES="$CONFIG_FILES puq/Makefile" ;; 11039 11040 11040 11041 *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; -
branches/uq/configure.in
r4798 r5029 43 43 AC_PROG_MAKE_SET 44 44 45 # Check for C, C++, and FORTRAN 45 # Check for C, C++, and FORTRAN 46 46 AC_PROG_CC 47 47 AC_PROG_CXX 48 # Avoid g95 48 # Avoid g95 49 49 AC_PROG_F77([g77 gfortran f77 fort77 f90 xlf xlf90 fl32]) 50 50 … … 146 146 for dir in \ 147 147 ${exec_prefix} \ 148 ${exec_prefix}/lib ; do 148 ${exec_prefix}/lib ; do 149 149 tclconfig="${dir}/tclConfig.sh" 150 150 if test -f "$tclconfig" ; then … … 171 171 if test "${with_tclsh}" != "no" ; then 172 172 tclsh="tclsh${TCL_VERSION}" 173 if test "${with_tclsh}" = "yes" ; then 173 if test "${with_tclsh}" = "yes" ; then 174 174 AC_PATH_PROG(TCLSH, ${tclsh}, [], [${exec_prefix}/bin:${PATH}]) 175 else 175 else 176 176 AC_PATH_PROG(TCLSH, ${tclsh}, [], [${with_tclsh}/bin:${with_tclsh}]) 177 177 fi … … 188 188 [AS_HELP_STRING([--with-vtk[=version]], 189 189 [VTK library version @<:@default=6.0@:>@])], 190 [], 190 [], 191 191 [with_vtk=yes]) 192 192 … … 230 230 [AS_HELP_STRING([--enable-vtkdicom], 231 231 [Use vtkDICOM package @<:@default=no@:>@])], 232 [], 232 [], 233 233 [enable_vtkdicom=no]) 234 234 … … 296 296 #-------------------------------------------------------------------- 297 297 if test "${with_ffmpeg}" != "no" ; then 298 if test "${with_ffmpeg}" = "yes" ; then 298 if test "${with_ffmpeg}" = "yes" ; then 299 299 AC_PATH_PROG(FFMPEG, ffmpeg, [], $PATH) 300 else 300 else 301 301 AC_PATH_PROG(FFMPEG, ffmpeg, [], [${with_ffmpeg}/bin:${with_ffmpeg}]) 302 fi 302 fi 303 303 if test "${FFMPEG}x" != "x" ; then 304 304 AC_DEFINE(HAVE_FFMPEG, 1, [Render servers can use ffmpeg]) … … 342 342 AC_CHECK_FUNCS(av_close_input_file) 343 343 AC_CHECK_FUNCS(avformat_close_input) 344 344 345 345 AC_CHECK_FUNC(avcodec_find_decoder,, 346 346 AC_MSG_ERROR(oops! no av_codec_find_decoder ?!?)) … … 598 598 oldtest/Makefile 599 599 oldtest/src/Makefile 600 puq/Makefile 600 601 ]) 601 602 AC_OUTPUT 602 603 -
branches/uq/gui/apps/launcher.tcl
r4513 r5029 107 107 # Note: We're sourcing the driver file "main.tcl" rather than exec-ing 108 108 # wish because we want to see stderr and stdout messages when they 109 # are written, rather than when the program completes. It also 110 # eliminates one process waiting for the other to complete. If 111 # "exec" is needed, then the following could be replaced with 109 # are written, rather than when the program completes. It also 110 # eliminates one process waiting for the other to complete. If 111 # "exec" is needed, then the following could be replaced with 112 112 # blt::bgexec. It doesn't try to redirect stderr into a file. 113 113 set argv $alist … … 116 116 } 117 117 source $mainscript 118 puts "Done with launcher" -
branches/uq/gui/scripts/Makefile.in
r4512 r5029 95 95 $(srcdir)/periodictable.tcl \ 96 96 $(srcdir)/postern.tcl \ 97 $(srcdir)/probdisteditor.tcl \ 97 98 $(srcdir)/progress.tcl \ 98 99 $(srcdir)/pushbutton.tcl \ … … 158 159 --outfile tclIndex 159 160 160 install: all install_scripts install_images 161 install: all install_scripts install_images 161 162 162 install_scripts: 163 install_scripts: 163 164 $(MKDIR_P) -m 0755 $(destdir) 164 165 @for i in $(FILES); do \ 165 166 echo "Installing $$i" ; \ 166 167 $(INSTALL) -m 0444 $$i $(destdir) ; \ 167 done 168 done 168 169 $(INSTALL) -m 0444 tclIndex $(destdir) 169 170 … … 173 174 echo "Installing $$i" ; \ 174 175 $(INSTALL) -m 0444 $$i $(destdir)/images ; \ 175 done 176 done 176 177 177 178 clean: -
branches/uq/gui/scripts/analyzer.tcl
r4512 r5029 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 2 # ---------------------------------------------------------------------- 3 3 # COMPONENT: analyzer - output area for Rappture … … 50 50 itk_option define -notebookpage notebookPage NotebookPage "" 51 51 52 constructor {tool args} { 53 # defined below 54 } 55 destructor { 56 # defined below 52 constructor {tool args} { 53 # defined below 54 } 55 destructor { 56 # defined below 57 57 } 58 58 … … 103 103 itcl::body Rappture::Analyzer::constructor {tool args} { 104 104 set _tool $tool 105 105 puts "Analyzer init" 106 106 # use this to store all simulation results 107 107 set _resultset [Rappture::ResultSet ::\#auto] … … 391 391 # ---------------------------------------------------------------------- 392 392 itcl::body Rappture::Analyzer::simulate {args} { 393 puts "simulate $args" 393 394 if {$args == "-ifneeded"} { 394 395 # check to see if simulation is really needed … … 401 402 } 402 403 set args "" 403 } 404 404 } 405 puts "simulation needed" 405 406 # simulation is needed -- go to simulation page 406 407 $itk_component(notebook) current simulate … … 423 424 424 425 # execute the job 426 puts "$_tool run $args" 427 425 428 foreach {status result} [eval $_tool run $args] break 426 429 … … 443 446 if {$status != 0} { 444 447 $itk_component(runinfo) configure -state normal 445 # Don't erase program error messages. 448 # Don't erase program error messages. 446 449 # $itk_component(runinfo) delete 1.0 end 447 450 $itk_component(runinfo) insert end "\n\nProblem launching job:\n\n" text … … 585 588 $popup activate $widget below 586 589 } else { 587 download now $widget 590 download now $widget 588 591 } 589 592 } else { … … 1282 1285 set frame ${sequence}.element($frameNum) 1283 1286 $xmlobj put ${frame}.index $frameNum 1284 1287 1285 1288 set molecule ${frame}.structure.components.molecule 1286 1289 $xmlobj put ${molecule}.pdb $contents … … 1325 1328 set frame ${sequence}.element($frameNum) 1326 1329 $xmlobj put ${frame}.index $frameNum 1327 1330 1328 1331 set molecule ${frame}.structure.components.molecule 1329 1332 $xmlobj put ${molecule}.lammps $frameContents 1330 1333 $xmlobj put ${molecule}.lammpstypemap $typemap 1331 1334 1332 1335 incr frameNum 1333 1336 set frameContents "" … … 1345 1348 set frame ${sequence}.element($frameNum) 1346 1349 $xmlobj put ${frame}.index $frameNum 1347 1350 1348 1351 set molecule ${frame}.structure.components.molecule 1349 1352 $xmlobj put ${molecule}.lammps $frameContents … … 1355 1358 # USAGE: _trajToSequence <xmlobj> ?<path>? 1356 1359 # 1357 # Check for PDB and LAMMPS trajectories in molecule data and rewrite 1358 # the individual models as a sequence of molecules. Used internally 1360 # Check for PDB and LAMMPS trajectories in molecule data and rewrite 1361 # the individual models as a sequence of molecules. Used internally 1359 1362 # to detect any molecule output elements that contain trajectory data. 1360 1363 # Trajectories will be converted into sequences of individual molecules. 1361 1364 # All other elements will be unaffected. Scans the entire xml tree if a 1362 # starting path is not specified. 1365 # starting path is not specified. 1363 1366 # 1364 1367 # ---------------------------------------------------------------------- -
branches/uq/gui/scripts/controlOwner.tcl
r3636 r5029 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 2 # ---------------------------------------------------------------------- 3 3 # COMPONENT: owner - manages Rappture controls -
branches/uq/gui/scripts/gauge.tcl
r3739 r5029 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 2 # ---------------------------------------------------------------------- 3 3 # COMPONENT: gauge - compact readout for real values … … 42 42 itk_option define -sampleheight sampleHeight SampleHeight 0 43 43 itk_option define -log log Log "" 44 itk_option define -varname varname Varname "" 45 itk_option define -label label Label "" 44 46 45 47 constructor {args} { # defined below } … … 56 58 protected method _layout {} 57 59 protected method _log {event args} 60 protected method _change_param_type {choice} 61 protected method _pop_uq {win} 62 protected method _pop_uq_deactivate {} 58 63 59 64 private variable _value 0 ;# value for this widget 65 private variable _mode exact ;# current mode 66 private variable _pde "" ;# ProbDistEditor 67 private variable _val "" ;# value choice combobox 60 68 61 69 blt::bitmap define GaugeArrow { … … 66 74 } 67 75 } 68 76 69 77 itk::usual Gauge { 70 78 keep -cursor -font -foreground -background … … 76 84 # ---------------------------------------------------------------------- 77 85 itcl::body Rappture::Gauge::constructor {args} { 86 78 87 itk_option remove hull.borderwidth hull.relief 79 88 component hull configure -borderwidth 0 … … 89 98 bind $itk_component(icon) <Configure> [itcl::code $this _redraw] 90 99 100 itk_component add uq { 101 button $itk_interior.uq -image [Rappture::icon UQ] \ 102 -command [itcl::code $this _pop_uq $itk_interior] 103 } 104 105 pack $itk_component(uq) -side right -padx 10 106 91 107 itk_component add -protected vframe { 92 108 frame $itk_interior.vframe … … 96 112 97 113 itk_component add value { 98 label $itk_component(vframe).value -width 7\114 label $itk_component(vframe).value -width 20 \ 99 115 -borderwidth 1 -relief flat -textvariable [itcl::scope _value] 100 116 } { … … 197 213 # ---------------------------------------------------------------------- 198 214 itcl::body Rappture::Gauge::value {args} { 199 set onlycheck 0 215 # puts "Gauge value: $args" 216 217 # Query. Just return the current value. 218 if {[llength $args] == 0} { 219 return $_value 220 } 221 200 222 set i [lsearch -exact $args -check] 201 223 if {$i >= 0} { 202 224 set onlycheck 1 203 225 set args [lreplace $args $i $i] 204 } 205 206 if {[llength $args] == 1} { 207 # 208 # If this gauge has -units, try to convert the incoming 209 # value to that system of units. Also, make sure that 210 # the value is bound by any min/max value constraints. 211 # 212 # Keep track of the inputted units so we can give a 213 # response about min and max values in familiar units. 214 # 215 set newval [set nv [string trim [lindex $args 0]]] 216 set units $itk_option(-units) 217 if {"" != $units} { 218 set newval [Rappture::Units::convert $newval -context $units] 219 set nvUnits [Rappture::Units::Search::for $newval] 220 if { "" == $nvUnits} { 221 set msg [Rappture::Units::description $units] 222 error "unrecognized units in value \"$newval\": should be value with units of $msg" 223 } 224 set nv [Rappture::Units::convert $nv \ 225 -context $units -to $units -units off] 226 227 # Normalize the units name 228 set newval [Rappture::Units::convert $newval -units off]$nvUnits 229 } 230 231 switch -- $itk_option(-type) { 232 integer { 233 if { [scan $nv "%g" value] != 1 || int($nv) != $value } { 234 error "bad value \"$nv\": should be an integer value" 235 } 236 } 237 real { 238 # "scan" will reject the number if the string is "NaN" or 239 # "Inf" or the empty string. It also is accepts large numbers 240 # (e.g. 111111111111111111111) that "string is double" 241 # rejects. The problem with "scan" is that it doesn't care if 242 # there are extra characters trailing the number (eg. "123a"). 243 # The extra %s substitution is used to detect this case. 244 if { [scan $nv "%g%s" dummy1 dummy2] != 1 } { 245 error "bad value \"$nv\": should be a real number" 246 } 247 } 248 } 249 250 if {"" != $itk_option(-minvalue)} { 251 set convMinVal [set minv $itk_option(-minvalue)] 252 if {"" != $units} { 253 set minv [Rappture::Units::convert $minv \ 254 -context $units -to $units -units off] 255 set convMinVal [Rappture::Units::convert \ 256 $itk_option(-minvalue) -context $units -to $nvUnits] 257 } else { 258 set newval [format "%g" $newval] 259 } 260 261 # fix for the case when the user tries to 262 # compare values like minv=-500 nv=-0600 263 set nv [format "%g" $nv] 264 set minv [format "%g" $minv] 265 266 if {$nv < $minv} { 267 error "minimum value allowed here is $convMinVal" 268 } 269 } 270 271 if {"" != $itk_option(-maxvalue)} { 272 set convMaxVal [set maxv $itk_option(-maxvalue)] 273 if {"" != $units} { 274 set maxv [Rappture::Units::convert $maxv \ 275 -context $units -to $units -units off] 276 set convMaxVal [Rappture::Units::convert \ 277 $itk_option(-maxvalue) -context $units -to $nvUnits] 278 } else { 279 set newval [format "%g" $newval] 280 } 281 282 # fix for the case when the user tries to 283 # compare values like maxv=500 nv=0600 284 set nv [format "%g" $nv] 285 set maxv [format "%g" $maxv] 286 287 if {$nv > $maxv} { 288 error "maximum value allowed here is $convMaxVal" 289 } 290 } 291 292 if {$onlycheck} { 293 return 294 } 295 296 set _value $newval 297 298 _redraw 299 event generate $itk_component(hull) <<Value>> 300 301 } elseif {[llength $args] != 0} { 226 } else { 227 set onlycheck 0 228 } 229 230 if {[llength $args] != 1} { 302 231 error "wrong # args: should be \"value ?-check? ?newval?\"" 232 } 233 234 set newval [Rappture::Units::mcheck_range [lindex $args 0] \ 235 $itk_option(-minvalue) $itk_option(-maxvalue) $itk_option(-units)] 236 237 set newmode [lindex $newval 0] 238 switch -- $newmode { 239 uniform - 240 gaussian { 241 set _mode $newmode 242 } 243 exact - 244 default { 245 set _mode exact 246 } 247 } 248 249 if {$itk_option(-type) == "integer"} { 250 if { [scan $newval "%g" value] != 1 || int($newval) != $value } { 251 error "bad value \"$newval\": should be an integer value" 252 } 253 } 254 255 if {$onlycheck} { 256 return 257 } 258 259 set _value $newval 260 $itk_component(value) configure -width [string length $_value] 261 _redraw 262 event generate $itk_component(hull) <<Value>> 263 264 if {"" != $_pde} { 265 set val [$_val translate [$_val value]] 266 $_val value $_mode 267 $_pde value $_value 268 303 269 } 304 270 return $_value … … 483 449 # ---------------------------------------------------------------------- 484 450 itcl::body Rappture::Gauge::_editor {option args} { 451 # puts "Gauge::editor option=$option args=$args" 485 452 if {$itk_option(-state) == "disabled"} { 486 453 return ;# disabled? then bail out here! … … 504 471 } 505 472 set val [lindex $args 0] 506 507 473 if {[catch {value -check $val} result]} { 508 474 if {[regexp {allowed here is (.+)} $result match newval]} { … … 586 552 } 587 553 554 if {$itk_option(-type) != "integer"} { 555 pack $itk_component(uq) -side right -padx 10 556 } 557 588 558 array set side2anchor { 589 559 left e … … 733 703 } 734 704 } 705 706 itcl::body Rappture::Gauge::_pop_uq {win} { 707 # puts "min=$itk_option(-minvalue) max=$itk_option(-maxvalue) units=$itk_option(-units)" 708 set varname $itk_option(-varname) 709 set popup .pop_uq_$varname 710 if { ![winfo exists $popup] } { 711 Rappture::Balloon $popup -title $itk_option(-label) 712 set inner [$popup component inner] 713 frame $inner.type 714 pack $inner.type -side top -fill x 715 label $inner.type.l -text "Parameter Value:" 716 pack $inner.type.l -side left 717 718 set _val [Rappture::Combobox $inner.type.val -width 20 -editable no] 719 pack $_val -side left -expand yes -fill x 720 $_val choices insert end exact "Exact Value" 721 $_val choices insert end uniform "Uniform Distribution" 722 $_val choices insert end gaussian "Gaussian Distribution" 723 bind $_val <<Value>> [itcl::code $this _change_param_type $inner] 724 725 set _pde [Rappture::ProbDistEditor $inner.entry \ 726 $itk_option(-minvalue) $itk_option(-maxvalue)] 727 $_val value $_mode 728 $_pde value $_value 729 pack $inner.entry -expand yes -fill both -pady {10 0} 730 731 $popup configure \ 732 -deactivatecommand [itcl::code $this _pop_uq_deactivate] 733 } 734 update 735 $popup activate $win right 736 } 737 738 itcl::body Rappture::Gauge::_pop_uq_deactivate {} { 739 # puts "deactivate [$_pde value]" 740 value [$_pde value] 741 } 742 743 itcl::body Rappture::Gauge::_change_param_type {inner} { 744 set val [$_val translate [$_val value]] 745 $_pde mode $val 746 } -
branches/uq/gui/scripts/main.tcl
r3700 r5029 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 2 #!/bin/sh 3 3 # ---------------------------------------------------------------------- … … 96 96 } 97 97 98 # mmh 99 puts "main.tcl $argv" 100 parray params 101 98 102 proc ReadToolParameters { numTries } { 99 incr numTries -1 103 incr numTries -1 100 104 if { $numTries < 0 } { 101 105 return … … 107 111 return 108 112 } 109 catch { 113 catch { 110 114 set f [open $paramsFile "r"] 111 115 set contents [read $f] 112 116 close $f 113 set pattern {^file\((.*)\):(.*)$} 117 set pattern {^file\((.*)\):(.*)$} 114 118 foreach line [split $contents "\n"] { 115 119 if { [regexp $pattern $line match path rest] } { … … 178 182 set installdir [file normalize [file dirname $params(-tool)]] 179 183 $xmlobj put tool.version.application.directory(tool) $installdir 180 181 184 set tool [Rappture::Tool ::#auto $xmlobj $installdir] 182 185 … … 358 361 set arrangement [$win.pager cget -arrangement] 359 362 if { $type == "" } { 360 if { $arrangement != "side-by-side" } { 363 if { $arrangement != "side-by-side" } { 361 364 set type auto 362 365 } 363 366 } 364 if { $arrangement != "side-by-side" && 367 if { $arrangement != "side-by-side" && 365 368 ($type == "manual" || $type == "manual-resim" || 366 369 $type == "auto" || $style == "wizard") } { … … 389 392 $win.pager current analyzer 390 393 } 391 394 puts "DONE main.tcl" 392 395 wm deiconify .main -
branches/uq/gui/scripts/numberentry.tcl
r3647 r5029 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 2 # ---------------------------------------------------------------------- 3 3 # COMPONENT: NumberEntry - widget for entering numeric values … … 25 25 public method label {} 26 26 public method tooltip {} 27 28 27 protected method _newValue {} 29 28 … … 43 42 # ---------------------------------------------------------------------- 44 43 itcl::body Rappture::NumberEntry::constructor {owner path args} { 44 puts "NumberEntry '$path' '$args'" 45 set varname [lindex [split $path ()] 1] 46 45 47 if {[catch {$owner isa Rappture::ControlOwner} valid] != 0 || !$valid} { 46 48 error "bad object \"$owner\": should be Rappture::ControlOwner" … … 48 50 set _owner $owner 49 51 set _path $path 50 52 53 puts "LABEL=[label]" 51 54 # 52 55 # Figure out what sort of control to create … … 58 61 lappend presets $value $label 59 62 } 60 63 61 64 set class Rappture::Gauge 62 65 set units [string trim [$_owner xml get $path.units]] 66 puts "units=$units" 63 67 if {$units != ""} { 64 68 set desc [Rappture::Units::description $units] … … 67 71 } 68 72 } 69 73 70 74 # 71 75 # Create the widget and configure it properly based on other … … 73 77 # 74 78 itk_component add gauge { 75 $class $itk_interior.gauge -units $units -presets $presets -log $path 79 $class $itk_interior.gauge -units $units -presets $presets -log $path -varname $varname -label [label] 76 80 } 77 81 pack $itk_component(gauge) -expand yes -fill both 78 82 bind $itk_component(gauge) <<Value>> [itcl::code $this _newValue] 79 83 80 84 set min [string trim [$_owner xml get $path.min]] 81 if {$min ne ""} { 82 $itk_component(gauge) configure -minvalue $min 83 } 84 85 if {$min ne ""} { 86 $itk_component(gauge) configure -minvalue $min 87 } 88 85 89 set max [string trim [$_owner xml get $path.max]] 86 if {$max ne ""} { 87 $itk_component(gauge) configure -maxvalue $max 90 if {$max ne ""} { 91 $itk_component(gauge) configure -maxvalue $max 88 92 } 89 93 … … 119 123 # 120 124 set str [string trim [$_owner xml get $path.default]] 121 if {$str ne ""} { 122 $itk_component(gauge) value $str 125 puts "Default=$str" 126 if {$str ne ""} { 127 $itk_component(gauge) value $str 123 128 } 124 129 } -
branches/uq/gui/scripts/spectrum.tcl
r3330 r5029 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 2 # ---------------------------------------------------------------------- 3 3 # COMPONENT: spectrum - maps a range of real values onto a color … … 41 41 private variable _specw0 0 ;# wavelength for minimum 42 42 } 43 43 44 44 # ---------------------------------------------------------------------- 45 45 # CONSTRUCTOR … … 80 80 set val1 [lindex $args 2] 81 81 set color1 [string trimright [lindex $args 3] "nm"] 82 82 83 83 if {"" != $units} { 84 84 set val0 [Rappture::Units::convert $val0 \ … … 176 176 # ---------------------------------------------------------------------- 177 177 itcl::body Rappture::Spectrum::get {args} { 178 puts "Spectrum::get $args" 178 179 if {[llength $args] == 0} { 179 180 set rlist "" … … 199 200 200 201 set value [lindex $args 0] 201 if {$units != ""} { 202 set value [Rappture::Units::convert $value \ 203 -context $units -to $units -units off] 204 } 205 202 203 puts "SPECTRUN GET value=$value units=$units" 204 205 switch -- [lindex $value 0] { 206 gaussian { 207 set value [lindex $value 1] 208 if {$units != ""} { 209 set value [Rappture::Units::convert $value \ 210 -context $units -to $units -units off] 211 } 212 } 213 uniform { 214 set min [lindex $value 1] 215 set max [lindex $value 2] 216 if {$units != ""} { 217 set min [Rappture::Units::convert $min \ 218 -context $units -to $units -units off] 219 set max [Rappture::Units::convert $max \ 220 -context $units -to $units -units off] 221 } 222 set value [expr {0.5 * ($min + $max)}] 223 } 224 default { 225 if {$units != ""} { 226 set value [Rappture::Units::convert $value \ 227 -context $units -to $units -units off] 228 } 229 } 230 } 231 puts "SPECTRUN GET NEW value=$value what=$what" 206 232 switch -- $what { 207 233 -color { -
branches/uq/gui/scripts/tempgauge.tcl
r3642 r5029 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 2 # ---------------------------------------------------------------------- 3 3 # COMPONENT: tempgauge - gauge for temperature values … … 73 73 74 74 if {"" != $itk_option(-spectrum)} { 75 puts "TemperatureGauge" 75 76 set color [$itk_option(-spectrum) get [value]] 77 puts "TemperatureGauge: color=$color" 76 78 set frac [$itk_option(-spectrum) get -fraction [value]] 77 79 } else { -
branches/uq/gui/scripts/tool.tcl
r4531 r5029 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 2 # ---------------------------------------------------------------------- 3 3 # COMPONENT: tool - represents an entire tool … … 31 31 public method run {args} { 32 32 sync ;# sync all widget values to XML 33 puts "Tool $_task run $args" 33 34 eval $_task run $args 34 35 } … … 52 53 # ---------------------------------------------------------------------- 53 54 itcl::body Rappture::Tool::constructor {xmlobj installdir} { 55 puts "Tool Init" 56 54 57 if {![Rappture::library isvalid $xmlobj]} { 55 58 error "bad value \"$xmlobj\": should be Rappture::Library" -
branches/uq/gui/scripts/units.tcl
r3330 r5029 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 2 # ---------------------------------------------------------------------- 3 3 # COMPONENT: units - mechanism for converting numbers with units … … 61 61 } 62 62 63 64 # ---------------------------------------------------------------------- 65 # USAGE: mcheck_range value {min ""} {max ""} 66 # 67 # Checks a value or PDF to determine if is is in a required range. 68 # Automatically does unit conversion if necessary. 69 # Returns value if OK. Error if out-of-range 70 # Examples: 71 # [mcheck_range "gaussian 0C 1C" 200K 500K] returns 1 72 # [mcheck_range "uniform 100 200" 150 250] returns 0 73 # [mcheck_range 100 0 200] returns 1 74 # ---------------------------------------------------------------------- 75 76 proc Rappture::Units::_check_range {value min max units} { 77 # make sure the value has units 78 if {$units != ""} { 79 set value [Rappture::Units::convert $value -context $units] 80 # for comparisons, remove units 81 set nv [Rappture::Units::convert $value -units off] 82 # get the units for the value 83 set newunits [Rappture::Units::Search::for $value] 84 } else { 85 set nv $value 86 } 87 88 if {"" != $min} { 89 if {"" != $units} { 90 # compute the minimum in the new units 91 set minv [Rappture::Units::convert $min -to $newunits -units off] 92 # same, but include units for printing 93 set convMinVal [Rappture::Units::convert $min -to $newunits] 94 } else { 95 set minv $min 96 set convMinVal $min 97 } 98 if {$nv < $minv} { 99 error "Minimum value allowed here is $convMinVal" 100 } 101 } 102 if {"" != $max} { 103 if {"" != $units} { 104 # compute the maximum in the new units 105 set maxv [Rappture::Units::convert $max -to $newunits -units off] 106 # same, but include units for printing 107 set convMaxVal [Rappture::Units::convert $max -to $newunits] 108 } else { 109 set maxv $max 110 set convMaxVal $max 111 } 112 if {$nv > $maxv} { 113 error "Maximum value allowed here is $convMaxVal" 114 } 115 } 116 return $value 117 } 118 119 proc Rappture::Units::mcheck_range {value {min ""} {max ""} {units ""}} { 120 puts "mcheck_range $value min=$min max=$max units=$units" 121 122 switch -- [lindex $value 0] { 123 normal - 124 gaussian { 125 # get the mean 126 set mean [_check_range [lindex $value 1] $min $max $units] 127 if {$units == ""} { 128 set dev [lindex $value 2] 129 set ndev $dev 130 } else { 131 set dev [Rappture::Units::convert [lindex $value 2] -context $units] 132 set ndev [Rappture::Units::convert $dev -units off] 133 } 134 if {$ndev <= 0} { 135 error "Deviation must be positive." 136 } 137 return [list gaussian $mean $dev] 138 } 139 uniform { 140 set min [_check_range [lindex $value 1] $min $max $units] 141 set max [_check_range [lindex $value 2] $min $max $units] 142 return [list uniform $min $max] 143 } 144 exact { 145 return [_check_range [lindex $value 1] $min $max $units] 146 } 147 default { 148 return [_check_range [lindex $value 0] $min $max $units] 149 } 150 } 151 } 152 153 # ---------------------------------------------------------------------- 154 # USAGE: mconvert value ?-context units? ?-to units? ?-units on/off? 155 # 156 # This version of convert() converts multiple values. Used when the 157 # value could be a range or probability density function (PDF). 158 # Examples: 159 # gaussian 100k 1k 160 # uniform 0eV 10eV 161 # 42 162 # exact 42 163 # ---------------------------------------------------------------------- 164 165 proc Rappture::Units::mconvert {value args} { 166 puts "mconvert $value : $args" 167 array set opts { 168 -context "" 169 -to "" 170 -units "on" 171 } 172 173 set value [split $value] 174 175 switch [lindex $value 0] { 176 normal - 177 gaussian { 178 set valtype gaussian 179 set vals [lrange $value 1 2] 180 set convtype {0 1} 181 } 182 uniform { 183 set valtype uniform 184 set vals [lrange $value 1 2] 185 set convtype {0 0} 186 } 187 exact { 188 set valtype "" 189 set vals [lindex $value 1] 190 set convtype {0} 191 } 192 default { 193 set valtype "" 194 set vals $value 195 set convtype {0} 196 } 197 } 198 199 foreach {key val} $args { 200 if {![info exists opts($key)]} { 201 error "bad option \"$key\": should be [join [lsort [array names opts]] {, }]" 202 } 203 set opts($key) $val 204 } 205 206 set newval $valtype 207 foreach val $vals ctype $convtype { 208 if {$ctype == 1} { 209 # This code handles unit conversion for deltas (changes). 210 # For example, if we want a standard deviation of 10C converted 211 # to Kelvin, that is 10K, NOT a standard deviation of 283.15K. 212 set units [Rappture::Units::Search::for $val] 213 set base [eval Rappture::Units::convert 0$units $args -units off] 214 set new [eval Rappture::Units::convert $val $args -units off] 215 set delta [expr $new - $base] 216 set val $delta$opts(-to) 217 } 218 # tcl 8.5 allows us to do this: 219 # lappend newval [Rappture::Units::convert $val {*}$args] 220 # but we are using tcl8.4 so we use eval :^( 221 lappend newval [eval Rappture::Units::convert $val $args] 222 } 223 return $newval 224 } 225 63 226 # ---------------------------------------------------------------------- 64 227 # USAGE: convert value ?-context units? ?-to units? ?-units on/off? … … 70 233 # current system. 71 234 # ---------------------------------------------------------------------- 72 proc Rappture::Units::convert {value args} { 73 array set opts { 74 -context "" 75 -to "" 76 -units "on" 77 } 78 foreach {key val} $args { 79 if {![info exists opts($key)]} { 80 error "bad option \"$key\": should be [join [lsort [array names opts]] {, }]" 81 } 82 set opts($key) $val 83 } 84 85 # 86 # Parse the value into the number part and the units part. 87 # 88 set value [string trim $value] 89 if {![regexp {^([-+]?[0-9]+\.?([0-9]+)?([eEdD][-+]?[0-9]+)?) *(/?[a-zA-Z]+[0-9]*)?$} $value match number dummy1 dummy2 units]} { 90 set mesg "bad value \"$value\": should be real number with units" 91 if {$opts(-context) != ""} { 92 append mesg " of [Rappture::Units::description $opts(-context)]" 93 } 94 error $mesg 95 } 96 if {$units == ""} { 97 set units $opts(-context) 98 } 99 100 # 101 # Try to find the object representing the current system of units. 102 # 103 set units [Rappture::Units::System::regularize $units] 104 set oldsys [Rappture::Units::System::for $units] 105 if {$oldsys == ""} { 106 set mesg "value \"$value\" has unrecognized units" 107 if {$opts(-context) != ""} { 108 append mesg ".\nShould be units of [Rappture::Units::description $opts(-context)]" 109 } 110 error $mesg 111 } 112 113 # 114 # Convert the number to the new system of units. 115 # 116 if {$opts(-to) == ""} { 117 # no units -- return the number as is 118 return "$number$units" 119 } 120 return [$oldsys convert "$number$units" $opts(-to) $opts(-units)] 121 } 235 # proc Rappture::Units::convert {value args} {} 236 # Actual implementation is in rappture/lang/tcl/src/RpUnitsTclInterface.cc. 237 122 238 123 239 # ---------------------------------------------------------------------- … … 128 244 # along with a list of all compatible systems. 129 245 # ---------------------------------------------------------------------- 130 proc Rappture::Units::description {units} { 131 set sys [Rappture::Units::System::for $units] 132 if {$sys == ""} { 133 return "" 134 } 135 set mesg [$sys cget -type] 136 set ulist [Rappture::Units::System::all $units] 137 if {"" != $ulist} { 138 append mesg " ([join $ulist {, }])" 139 } 140 return $mesg 141 } 246 # proc Rappture::Units::description {units} {} 247 # Actual implementation is in rappture/lang/tcl/src/RpUnitsTclInterface.cc. 248 142 249 143 250 # ---------------------------------------------------------------------- … … 154 261 private variable _system "" ;# this system of units 155 262 156 public proc for {units} 157 public proc all {units} 263 # These are in rappture/lang/tcl/src/RpUnitsTclInterface.cc. 264 # public proc for {units} 265 # public proc all {units} 266 158 267 public proc regularize {units} 159 268 … … 361 470 # if there is no system that matches the units string. 362 471 # ---------------------------------------------------------------------- 363 itcl::body Rappture::Units::System::for {units} { 364 # 365 # See if the units are a recognized system. If not, then try to 366 # extract any metric prefix and see if what's left is a recognized 367 # system. If all else fails, see if we can find a system without 368 # the exact capitalization. The user might say "25c" instead of 369 # "25C". Try to allow that. 370 # 371 if {[info exists _base($units)]} { 372 return $_base($units) 373 } else { 374 set orig $units 375 if {[regexp {^(/?)[cCmMuUnNpPfFaAkKgGtT](.+)$} $units match slash tail]} { 376 set base "$slash$tail" 377 if {[info exists _base($base)]} { 378 set sys $_base($base) 379 if {[$sys cget -metric]} { 380 return $sys 381 } 382 } 383 384 # check the base part for improper capitalization below... 385 set units $base 386 } 387 388 set matching "" 389 foreach u [array names _base] { 390 if {[string equal -nocase $u $units]} { 391 lappend matching $_base($u) 392 } 393 } 394 if {[llength $matching] == 1} { 395 set sys [lindex $matching 0] 396 # 397 # If we got rid of a metric prefix above, make sure 398 # that the system is metric. If not, then we don't 399 # have a match. 400 # 401 if {[string equal $units $orig] || [$sys cget -metric]} { 402 return $sys 403 } 404 } 405 } 406 return "" 407 } 472 # itcl::body Rappture::Units::System::for {units} {} 473 # Actual implementation is in rappture/lang/tcl/src/RpUnitsTclInterface.cc. 474 408 475 409 476 # ---------------------------------------------------------------------- … … 414 481 # relationships that lead to the same base system. 415 482 # ---------------------------------------------------------------------- 416 itcl::body Rappture::Units::System::all {units} { 417 set sys [Rappture::Units::System::for $units] 418 if {$sys == ""} { 419 return "" 420 } 421 422 if {"" != [$sys cget -basis]} { 423 set basis [lindex [$sys cget -basis] 0] 424 } else { 425 set basis $units 426 } 427 428 set ulist $basis 429 foreach u [array names _base] { 430 set obj $_base($u) 431 set b [lindex [$obj cget -basis] 0] 432 if {$b == $basis} { 433 lappend ulist $u 434 } 435 } 436 return $ulist 437 } 483 # itcl::body Rappture::Units::System::all {units} {} 484 # Actual implementation is in rappture/lang/tcl/src/RpUnitsTclInterface.cc. 485 438 486 439 487 # ---------------------------------------------------------------------- -
branches/uq/lang/tcl/scripts/library.tcl
r4180 r5029 215 215 public method remove {{path ""}} 216 216 public method xml {{path ""}} 217 public method uq_make_template {} 217 218 218 219 public method diff {libobj} … … 228 229 private variable _root 0 ;# non-zero => this obj owns document 229 230 private variable _document "" ;# XML DOM tree 230 private variable _node "" ;# node within 231 private variable _node "" ;# node within 231 232 } 232 233 … … 1038 1039 return $rlist 1039 1040 } 1041 1042 1043 # FIXME: get units convert. change varlist to have no units 1044 itcl::body Rappture::LibraryObj::uq_make_template {} { 1045 set varlist "" 1046 set n [$_node selectNodes /run/input//number] 1047 foreach _n $n { 1048 set x [$_n selectNodes current/text()] 1049 set val [$x nodeValue] 1050 if {[string equal -length 8 $val "uniform "] || 1051 [string equal -length 9 $val "gaussian "]} { 1052 set unode [$_n selectNodes units/text()] 1053 if {"" != $unode} { 1054 set units [$unode nodeValue] 1055 set val [Rappture::Units::mconvert $val \ 1056 -context $units -to $units -units off] 1057 } 1058 $x nodeValue @@[$_n getAttribute id] 1059 lappend varlist [list [$_n getAttribute id] $val] 1060 } 1061 } 1062 return $varlist 1063 } -
branches/uq/lang/tcl/scripts/task.tcl
r4514 r5029 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 2 # ---------------------------------------------------------------------- 3 3 # COMPONENT: task - represents the executable part of a tool … … 57 57 # default method for -jobstats control 58 58 public proc MiddlewareTime {args} 59 60 public method get_params {varlist csvname uq_type args} 59 61 } 60 62 … … 75 77 # ---------------------------------------------------------------------- 76 78 itcl::body Rappture::Task::constructor {xmlobj installdir args} { 79 puts "Task Init" 77 80 if {![Rappture::library isvalid $xmlobj]} { 78 81 error "bad value \"$xmlobj\": should be Rappture::Library" … … 138 141 itcl::body Rappture::Task::run {args} { 139 142 global env errorInfo 140 143 puts "task run $args" 141 144 # 142 145 # Make sure that we save the proper application name. … … 164 167 foreach item {control output error} { set job($item) "" } 165 168 166 # write out the driver.xml file for the tool167 set file "driver[pid].xml"168 set status [catch {169 set fid [open $file w]170 puts $fid "<?xml version=\"1.0\"?>"171 puts $fid [$_xmlobj xml]172 close $fid173 } result]174 175 169 # Set limits for cpu time 176 170 set limit [$_xmlobj get tool.limits.cputime] … … 185 179 set limit 10; # lower bound is 10 seconds. 186 180 } 187 } 188 Rappture::rlimit set cputime $limit 181 } 182 Rappture::rlimit set cputime $limit 183 184 # write out the driver.xml file for the tool 185 set file "driver[pid].xml" 186 set status [catch { 187 set fid [open $file w] 188 puts $fid "<?xml version=\"1.0\"?>" 189 puts $fid [$_xmlobj xml] 190 close $fid 191 } result] 192 193 # This will turn the driver xml into a template 194 # and return a list of the UQ variables and their PDFs. 195 set uq_varlist [$_xmlobj uq_make_template] 196 197 if {$uq_varlist != ""} { 198 # write out the template file for submit 199 set tfile "template[pid].xml" 200 set status [catch { 201 set fid [open $tfile w] 202 puts $fid "<?xml version=\"1.0\"?>" 203 puts $fid [$_xmlobj xml] 204 close $fid 205 } result] 206 } 207 208 189 209 # execute the tool using the path from the tool description 190 210 if {$status == 0} { 191 211 set cmd [$_xmlobj get tool.command] 212 puts "1. cmd=$cmd" 192 213 regsub -all @tool $cmd $_installdir cmd 193 regsub -all @driver $cmd $file cmd 194 regsub -all {\\} $cmd {\\\\} cmd 214 215 if {$uq_varlist == ""} { 216 regsub -all @driver $cmd $file cmd 217 } else { 218 regsub -all @driver $cmd $tfile cmd 219 } 195 220 set cmd [string trimleft $cmd " "] 196 if { $cmd == "" } { 197 puts stderr "cmd is empty" 198 return [list 1 "Command is empty.\n\nThere is no command specified by\n\n <command>\n </command>\n\nin the tool.xml file."] 199 } 200 201 switch -glob -- [resources -jobprotocol] { 202 "submit*" { 203 # if job_protocol is "submit", then use use submit command 204 set cmd "submit --local $cmd" 205 } 206 "mx" { 207 # metachory submission 208 set cmd "mx $cmd" 209 } 210 "exec" { 211 # default -- nothing special 212 } 213 } 221 puts "2. cmd=$cmd" 222 if { $cmd == "" } { 223 puts stderr "cmd is empty" 224 return [list 1 "Command is empty.\n\nThere is no command specified by\n\n <command>\n </command>\n\nin the tool.xml file."] 225 } 226 227 if {$uq_varlist == ""} { 228 switch -glob -- [resources -jobprotocol] { 229 "submit*" { 230 # if job_protocol is "submit", then use use submit command 231 set cmd "submit --local $cmd" 232 } 233 "mx" { 234 # metachory submission 235 set cmd "mx $cmd" 236 } 237 "exec" { 238 # default -- nothing special 239 } 240 } 241 } else { 242 puts "uq_varlist=$uq_varlist" 243 # FIXME. Default to Smolyak level 2, but allow more later. 244 file delete -force puq 245 set params_file [get_params $file $uq_varlist "smolyak" 2] 246 set cmd "submit --runName=puq -l -d $params_file python uq.py $cmd @:$tfile" 247 } 248 214 249 $_xmlobj put tool.execute $cmd 215 250 216 # starting job... 217 _log run started 218 Rappture::rusage mark 219 220 if {0 == [string compare -nocase -length 5 $cmd "ECHO "] } { 221 set status 0; 222 set job(output) [string range $cmd 5 end] 223 } else { 224 set status [catch { 225 set ::Rappture::Task::job(control) "" 226 eval blt::bgexec \ 227 ::Rappture::Task::job(control) \ 228 -keepnewline yes \ 229 -killsignal SIGTERM \ 230 -onoutput [list [itcl::code $this _output]] \ 251 puts "cmd=$cmd" 252 # starting job... 253 _log run started 254 Rappture::rusage mark 255 256 if {0 == [string compare -nocase -length 5 $cmd "ECHO "] } { 257 set status 0; 258 set job(output) [string range $cmd 5 end] 259 } else { 260 set status [catch { 261 set ::Rappture::Task::job(control) "" 262 eval blt::bgexec \ 263 ::Rappture::Task::job(control) \ 264 -keepnewline yes \ 265 -killsignal SIGTERM \ 266 -onoutput [list [itcl::code $this _output]] \ 231 267 -output ::Rappture::Task::job(output) \ 232 268 -error ::Rappture::Task::job(error) \ 233 269 $cmd 234 235 236 237 # We're here because the exec-ed program failed 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 270 } result] 271 272 if { $status != 0 } { 273 # We're here because the exec-ed program failed 274 set logmesg $result 275 if { $::Rappture::Task::job(control) ne "" } { 276 foreach { token pid code mesg } \ 277 $::Rappture::Task::job(control) break 278 if { $token == "EXITED" } { 279 # This means that the program exited normally but 280 # returned a non-zero exitcode. Consider this an 281 # invalid result from the program. Append the stderr 282 # from the program to the message. 283 set logmesg "Program finished: exit code is $code" 284 set result "$logmesg\n\n$::Rappture::Task::job(error)" 285 } elseif { $token == "abort" } { 286 # The user pressed the abort button. 287 set logmesg "Program terminated by user." 288 set result "$logmesg\n\n$::Rappture::Task::job(output)" 289 } else { 290 # Abnormal termination 291 set logmesg "Abnormal program termination: $mesg" 292 set result "$logmesg\n\n$::Rappture::Task::job(output)" 293 } 294 } 295 _log run failed [list $logmesg] 296 return [list $status $result] 297 } 298 } 299 # ...job is finished 300 array set times [Rappture::rusage measure] 301 302 if {[resources -jobprotocol] ne "submit"} { 303 set id [$_xmlobj get tool.id] 304 set vers [$_xmlobj get tool.version.application.revision] 305 set simulation simulation 306 if { $id ne "" && $vers ne "" } { 307 set pid [pid] 308 set simulation ${pid}_${id}_r${vers} 309 } 310 311 # need to save job info? then invoke the callback 312 if {[string length $jobstats] > 0} { 313 uplevel #0 $jobstats [list job [incr jobnum] \ 314 event $simulation start $times(start) \ 315 walltime $times(walltime) cputime $times(cputime) \ 316 status $status] 317 } 318 319 # 320 # Scan through stderr channel and look for statements that 321 # represent grid jobs that were executed. The statements 322 # look like this: 323 # 324 # MiddlewareTime: job=1 event=simulation start=3.001094 ... 325 # 326 set subjobs 0 327 while {[regexp -indices {(^|\n)MiddlewareTime:( +[a-z]+=[^ \n]+)+(\n|$)} $job(error) match]} { 328 foreach {p0 p1} $match break 329 if {[string index $job(error) $p0] == "\n"} { incr p0 } 330 331 catch {unset data} 332 array set data { 333 job 1 334 event simulation 335 start 0 336 walltime 0 337 cputime 0 338 status 0 339 } 304 340 foreach arg [lrange [string range $job(error) $p0 $p1] 1 end] { 305 341 foreach {key val} [split $arg =] break … … 337 373 } 338 374 if {$status == 0} { 339 file delete -force -- $file375 # file delete -force -- $file 340 376 } 341 377 … … 350 386 # a reference to the run.xml file containing results. 351 387 # 388 352 389 if {$status == 0} { 353 390 set result [string trim $job(output)] 391 puts "result=$result" 392 if {$uq_varlist != ""} { 393 file delete -force -- new.xml 394 exec puq_analyze.py puq_[pid].hdf5 395 append result "\n" "=RAPPTURE-RUN=>new.xml" 396 } 354 397 if {[regexp {=RAPPTURE-RUN=>([^\n]+)} $result match file]} { 355 398 set status [catch {Rappture::library $file} result] 399 puts "STATUS=$status" 356 400 if {$status == 0} { 357 401 # add cputime info to run.xml file … … 381 425 if {$status == 0 && $rdir ne ""} { 382 426 catch { 383 file delete -force -- $file427 # file delete -force -- $file 384 428 if {![file exists $rdir]} { 385 429 _mkdir $rdir … … 393 437 } else { 394 438 # don't keep the file 395 file delete -force -- $file439 # file delete -force -- $file 396 440 } 397 441 } else { … … 518 562 puts stderr $line 519 563 } 564 565 566 # 567 # Send the list of parameters to a python program so it can call PUQ 568 # and get a CSV file containing the parameter values to use for the runs. 569 itcl::body Rappture::Task::get_params {dfile varlist uq_type args} { 570 571 # convert tcl list of variables to json so python can read it 572 proc varlist2py {inlist} { 573 set ovar "\[" 574 set first 1 575 foreach a $inlist { 576 foreach {var val} $a break 577 if {$first == 1} { 578 append ovar \[\"$var\", 579 set first 0 580 } else { 581 append ovar \],\[\"$var\", 582 } 583 switch [lindex $val 0] { 584 gaussian { 585 append ovar "\[\"gaussian\",[lindex $val 1],[lindex $val 2]\]" 586 } 587 uniform { 588 append ovar "\[\"uniform\",[lindex $val 1],[lindex $val 2]\]" 589 } 590 default { 591 append ovar $val 592 } 593 } 594 } 595 append ovar "\]\]" 596 return $ovar 597 } 598 599 puts "varlist=$varlist" 600 set varlist [varlist2py $varlist] 601 set pid [pid] 602 exec get_params.py $dfile $pid $varlist $uq_type $args 603 return params[pid].csv 604 } -
branches/uq/lang/tcl/scripts/units.tcl
r3362 r5029 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 1 2 # ---------------------------------------------------------------------- 2 3 # COMPONENT: units - mechanism for converting numbers with units … … 60 61 } 61 62 63 64 # ---------------------------------------------------------------------- 65 # USAGE: mcheck_range value {min ""} {max ""} 66 # 67 # Checks a value or PDF to determine if is is in a required range. 68 # Automatically does unit conversion if necessary. 69 # Returns value if OK. Error if out-of-range 70 # Examples: 71 # [mcheck_range "gaussian 0C 1C" 200K 500K] returns 1 72 # [mcheck_range "uniform 100 200" 150 250] returns 0 73 # [mcheck_range 100 0 200] returns 1 74 # ---------------------------------------------------------------------- 75 76 proc Rappture::Units::_check_range {value min max units} { 77 # make sure the value has units 78 if {$units != ""} { 79 set value [Rappture::Units::convert $value -context $units] 80 # for comparisons, remove units 81 set nv [Rappture::Units::convert $value -units off] 82 # get the units for the value 83 set newunits [Rappture::Units::Search::for $value] 84 } else { 85 set nv $value 86 } 87 88 if {"" != $min} { 89 if {"" != $units} { 90 # compute the minimum in the new units 91 set minv [Rappture::Units::convert $min -to $newunits -units off] 92 # same, but include units for printing 93 set convMinVal [Rappture::Units::convert $min -to $newunits] 94 } else { 95 set minv $min 96 set convMinVal $min 97 } 98 if {$nv < $minv} { 99 error "Minimum value allowed here is $convMinVal" 100 } 101 } 102 if {"" != $max} { 103 if {"" != $units} { 104 # compute the maximum in the new units 105 set maxv [Rappture::Units::convert $max -to $newunits -units off] 106 # same, but include units for printing 107 set convMaxVal [Rappture::Units::convert $max -to $newunits] 108 } else { 109 set maxv $max 110 set convMaxVal $max 111 } 112 if {$nv > $maxv} { 113 error "Maximum value allowed here is $convMaxVal" 114 } 115 } 116 return $value 117 } 118 119 proc Rappture::Units::mcheck_range {value {min ""} {max ""} {units ""}} { 120 puts "mcheck_range $value min=$min max=$max units=$units" 121 122 switch -- [lindex $value 0] { 123 normal - 124 gaussian { 125 # get the mean 126 set mean [_check_range [lindex $value 1] $min $max $units] 127 if {$units == ""} { 128 set dev [lindex $value 2] 129 set ndev $dev 130 } else { 131 set dev [Rappture::Units::convert [lindex $value 2] -context $units] 132 set ndev [Rappture::Units::convert $dev -units off] 133 } 134 if {$ndev <= 0} { 135 error "Deviation must be positive." 136 } 137 return [list gaussian $mean $dev] 138 } 139 uniform { 140 set min [_check_range [lindex $value 1] $min $max $units] 141 set max [_check_range [lindex $value 2] $min $max $units] 142 return [list uniform $min $max] 143 } 144 exact { 145 return [_check_range [lindex $value 1] $min $max $units] 146 } 147 default { 148 return [_check_range [lindex $value 0] $min $max $units] 149 } 150 } 151 } 152 153 # ---------------------------------------------------------------------- 154 # USAGE: mconvert value ?-context units? ?-to units? ?-units on/off? 155 # 156 # This version of convert() converts multiple values. Used when the 157 # value could be a range or probability density function (PDF). 158 # Examples: 159 # gaussian 100k 1k 160 # uniform 0eV 10eV 161 # 42 162 # exact 42 163 # ---------------------------------------------------------------------- 164 165 proc Rappture::Units::mconvert {value args} { 166 puts "mconvert $value : $args" 167 array set opts { 168 -context "" 169 -to "" 170 -units "on" 171 } 172 173 set value [split $value] 174 175 switch [lindex $value 0] { 176 normal - 177 gaussian { 178 set valtype gaussian 179 set vals [lrange $value 1 2] 180 set convtype {0 1} 181 } 182 uniform { 183 set valtype uniform 184 set vals [lrange $value 1 2] 185 set convtype {0 0} 186 } 187 exact { 188 set valtype "" 189 set vals [lindex $value 1] 190 set convtype {0} 191 } 192 default { 193 set valtype "" 194 set vals $value 195 set convtype {0} 196 } 197 } 198 199 foreach {key val} $args { 200 if {![info exists opts($key)]} { 201 error "bad option \"$key\": should be [join [lsort [array names opts]] {, }]" 202 } 203 set opts($key) $val 204 } 205 206 set newval $valtype 207 foreach val $vals ctype $convtype { 208 if {$ctype == 1} { 209 # This code handles unit conversion for deltas (changes). 210 # For example, if we want a standard deviation of 10C converted 211 # to Kelvin, that is 10K, NOT a standard deviation of 283.15K. 212 set units [Rappture::Units::Search::for $val] 213 set base [eval Rappture::Units::convert 0$units $args -units off] 214 set new [eval Rappture::Units::convert $val $args -units off] 215 set delta [expr $new - $base] 216 set val $delta$opts(-to) 217 } 218 # tcl 8.5 allows us to do this: 219 # lappend newval [Rappture::Units::convert $val {*}$args] 220 # but we are using tcl8.4 so we use eval :^( 221 lappend newval [eval Rappture::Units::convert $val $args] 222 } 223 return $newval 224 } 225 62 226 # ---------------------------------------------------------------------- 63 227 # USAGE: convert value ?-context units? ?-to units? ?-units on/off? … … 69 233 # current system. 70 234 # ---------------------------------------------------------------------- 71 proc Rappture::Units::convert {value args} { 72 array set opts { 73 -context "" 74 -to "" 75 -units "on" 76 } 77 foreach {key val} $args { 78 if {![info exists opts($key)]} { 79 error "bad option \"$key\": should be [join [lsort [array names opts]] {, }]" 80 } 81 set opts($key) $val 82 } 83 84 # 85 # Parse the value into the number part and the units part. 86 # 87 set value [string trim $value] 88 if {![regexp {^([-+]?[0-9]+\.?([0-9]+)?([eEdD][-+]?[0-9]+)?) *(/?[a-zA-Z]+[0-9]*)?$} $value match number dummy1 dummy2 units]} { 89 set mesg "bad value \"$value\": should be real number with units" 90 if {$opts(-context) != ""} { 91 append mesg " of [Rappture::Units::description $opts(-context)]" 92 } 93 error $mesg 94 } 95 if {$units == ""} { 96 set units $opts(-context) 97 } 98 99 # 100 # Try to find the object representing the current system of units. 101 # 102 set units [Rappture::Units::System::regularize $units] 103 set oldsys [Rappture::Units::System::for $units] 104 if {$oldsys == ""} { 105 set mesg "value \"$value\" has unrecognized units" 106 if {$opts(-context) != ""} { 107 append mesg ".\nShould be units of [Rappture::Units::description $opts(-context)]" 108 } 109 error $mesg 110 } 111 112 # 113 # Convert the number to the new system of units. 114 # 115 if {$opts(-to) == ""} { 116 # no units -- return the number as is 117 return "$number$units" 118 } 119 return [$oldsys convert "$number$units" $opts(-to) $opts(-units)] 120 } 235 # proc Rappture::Units::convert {value args} {} 236 # Actual implementation is in rappture/lang/tcl/src/RpUnitsTclInterface.cc. 237 121 238 122 239 # ---------------------------------------------------------------------- … … 127 244 # along with a list of all compatible systems. 128 245 # ---------------------------------------------------------------------- 129 proc Rappture::Units::description {units} { 130 set sys [Rappture::Units::System::for $units] 131 if {$sys == ""} { 132 return "" 133 } 134 set mesg [$sys cget -type] 135 set ulist [Rappture::Units::System::all $units] 136 if {"" != $ulist} { 137 append mesg " ([join $ulist {, }])" 138 } 139 return $mesg 140 } 246 # proc Rappture::Units::description {units} {} 247 # Actual implementation is in rappture/lang/tcl/src/RpUnitsTclInterface.cc. 248 141 249 142 250 # ---------------------------------------------------------------------- … … 153 261 private variable _system "" ;# this system of units 154 262 155 public proc for {units} 156 public proc all {units} 263 # These are in rappture/lang/tcl/src/RpUnitsTclInterface.cc. 264 # public proc for {units} 265 # public proc all {units} 266 157 267 public proc regularize {units} 158 268 … … 360 470 # if there is no system that matches the units string. 361 471 # ---------------------------------------------------------------------- 362 itcl::body Rappture::Units::System::for {units} { 363 # 364 # See if the units are a recognized system. If not, then try to 365 # extract any metric prefix and see if what's left is a recognized 366 # system. If all else fails, see if we can find a system without 367 # the exact capitalization. The user might say "25c" instead of 368 # "25C". Try to allow that. 369 # 370 if {[info exists _base($units)]} { 371 return $_base($units) 372 } else { 373 set orig $units 374 if {[regexp {^(/?)[cCmMuUnNpPfFaAkKgGtT](.+)$} $units match slash tail]} { 375 set base "$slash$tail" 376 if {[info exists _base($base)]} { 377 set sys $_base($base) 378 if {[$sys cget -metric]} { 379 return $sys 380 } 381 } 382 383 # check the base part for improper capitalization below... 384 set units $base 385 } 386 387 set matching "" 388 foreach u [array names _base] { 389 if {[string equal -nocase $u $units]} { 390 lappend matching $_base($u) 391 } 392 } 393 if {[llength $matching] == 1} { 394 set sys [lindex $matching 0] 395 # 396 # If we got rid of a metric prefix above, make sure 397 # that the system is metric. If not, then we don't 398 # have a match. 399 # 400 if {[string equal $units $orig] || [$sys cget -metric]} { 401 return $sys 402 } 403 } 404 } 405 return "" 406 } 472 # itcl::body Rappture::Units::System::for {units} {} 473 # Actual implementation is in rappture/lang/tcl/src/RpUnitsTclInterface.cc. 474 407 475 408 476 # ---------------------------------------------------------------------- … … 413 481 # relationships that lead to the same base system. 414 482 # ---------------------------------------------------------------------- 415 itcl::body Rappture::Units::System::all {units} { 416 set sys [Rappture::Units::System::for $units] 417 if {$sys == ""} { 418 return "" 419 } 420 421 if {"" != [$sys cget -basis]} { 422 set basis [lindex [$sys cget -basis] 0] 423 } else { 424 set basis $units 425 } 426 427 set ulist $basis 428 foreach u [array names _base] { 429 set obj $_base($u) 430 set b [lindex [$obj cget -basis] 0] 431 if {$b == $basis} { 432 lappend ulist $u 433 } 434 } 435 return $ulist 436 } 483 # itcl::body Rappture::Units::System::all {units} {} 484 # Actual implementation is in rappture/lang/tcl/src/RpUnitsTclInterface.cc. 485 437 486 438 487 # ---------------------------------------------------------------------- -
branches/uq/src/core/RpUnits.cc
r4224 r5029 70 70 exponent = 1; 71 71 72 // check to see if there is an exponent at the end 72 // check to see if there is an exponent at the end 73 73 // of the search string 74 74 idx = RpUnits::grabExponent(searchStr, &exponent); … … 353 353 } 354 354 355 // check to see if they are the same basis, 355 // check to see if they are the same basis, 356 356 // no need to list all of the metric conversions. 357 357 if (basis) { … … 493 493 494 494 // this is kinda the wrong way to get the job done... 495 // how do we only create 1 conversion object and share it between 496 // atleast two RpUnits objs so that when the RpUnits objs are 495 // how do we only create 1 conversion object and share it between 496 // atleast two RpUnits objs so that when the RpUnits objs are 497 497 // deleted, we are not trying to delete already deleted memory. 498 498 // so for the sake of safety we get the following few lines of code. … … 528 528 // this is kinda the wrong way to get the job done... 529 529 // how do we only create 1 conversion object and share it between at 530 // least two RpUnits objs so that when the RpUnits objs are deleted, 530 // least two RpUnits objs so that when the RpUnits objs are deleted, 531 531 // we are not trying to delete already deleted memory. 532 532 // so for the sake of safety we get the following few lines of code. … … 640 640 /// Retrieve the RpUnits object representing the basis of this object. 641 641 /** 642 * Returns a pointer to a RpUnits object which, on success, points to the 642 * Returns a pointer to a RpUnits object which, on success, points to the 643 643 * RpUnits object that is the basis of the calling object. 644 644 */ … … 808 808 * across a unit that is unrecognized or can not be interpreted, then it 809 809 * returns error (a non-zero value). 810 * 810 * 811 811 * if &compatList == NULL, no compatible list of units will be generated. 812 * this function does not do a good job of placing the available units 812 * this function does not do a good job of placing the available units 813 813 * back into the original formula. i still need to work on this. 814 814 */ … … 920 920 921 921 if ((RPUNITS_ORIG_EXP & flags) == RPUNITS_STRICT_NAME) { 922 // if the user asks for strict naming, 922 // if the user asks for strict naming, 923 923 // always place the exponent on the name 924 924 name << myExp; … … 1114 1114 1115 1115 /* 1116 // if the exponent != 1,-1 then do a second search 1116 // if the exponent != 1,-1 then do a second search 1117 1117 // for the unit+exponent string that might be defined. 1118 1118 // this is to cover the case were we have defined conversions … … 1397 1397 // these are conditions where no conversion is needed 1398 1398 if ( (fromUnitsName.empty()) || (toUnitsName == fromUnitsName) ) { 1399 // there were no units in the input 1399 // there were no units in the input 1400 1400 // string or no conversion needed 1401 1401 // assume fromUnitsName = toUnitsName … … 1508 1508 toIter = toUnitsList.begin(); 1509 1509 1510 // raise error that there was an 1510 // raise error that there was an 1511 1511 // unrecognized conversion request 1512 1512 … … 1651 1651 } 1652 1652 1653 return (std::string(unitText.str())); 1653 return (std::string(unitText.str())); 1654 1654 1655 1655 } … … 1701 1701 // trying to avoid the recursive way of converting to the basis. 1702 1702 // need to rethink this. 1703 // 1703 // 1704 1704 if ( (basis) && (basis->getUnitsName() != toUnit->getUnitsName()) ) { 1705 1705 value = convert(basis,value,&my_result); … … 1711 1711 // find the toUnit in our dictionary. 1712 1712 // if the toUnits has a basis, we need to search for the basis 1713 // and convert between basis' and then convert again back to the 1713 // and convert between basis' and then convert again back to the 1714 1714 // original unit. 1715 1715 if ( (toBasis) && (toBasis->getUnitsName() != fromUnit->getUnitsName()) ) { … … 1755 1755 // conversion for a two arg conv function pointer 1756 1756 // need to make this simpler, more logical maybe only allow 2 arg 1757 if ( (p->conv->convForwFxnPtr) 1757 if ( (p->conv->convForwFxnPtr) 1758 1758 && (! p->conv->convForwFxnPtrDD) ) { 1759 1759 1760 1760 value = p->conv->convForwFxnPtr(value); 1761 1761 } 1762 else if ( (p->conv->convForwFxnPtrDD) 1762 else if ( (p->conv->convForwFxnPtrDD) 1763 1763 && (! p->conv->convForwFxnPtr) ) { 1764 1764 1765 value = 1765 value = 1766 1766 p->conv->convForwFxnPtrDD(value, fromUnit->getExponent()); 1767 1767 } … … 1770 1770 // or to the requested unit's basis. 1771 1771 // if we converted to the requested unit's basis. we need to 1772 // do one last conversion from the requested unit's basis back 1772 // do one last conversion from the requested unit's basis back 1773 1773 // to the requested unit. 1774 1774 if ( (toBasis) && (toBasis->getUnitsName() != fromUnit->getUnitsName()) ) { … … 1783 1783 1784 1784 // change the result code to zero, a conversion was performed 1785 // (we think)... its ture that it is possible to get to this 1786 // point and have skipped the conversion because the 1785 // (we think)... its ture that it is possible to get to this 1786 // point and have skipped the conversion because the 1787 1787 // conversion object was not properly created... 1788 1788 // ie. both fxn ptrs were null or neither fxn ptr was null … … 1803 1803 // conversion for a two arg conv function pointer 1804 1804 // need to make this simpler, more logical maybe only allow 2 arg 1805 if ( (p->conv->convBackFxnPtr) 1805 if ( (p->conv->convBackFxnPtr) 1806 1806 && (! p->conv->convBackFxnPtrDD) ) { 1807 1807 1808 1808 value = p->conv->convBackFxnPtr(value); 1809 1809 } 1810 else if ( (p->conv->convBackFxnPtrDD) 1810 else if ( (p->conv->convBackFxnPtrDD) 1811 1811 && (! p->conv->convBackFxnPtr) ) { 1812 1812 1813 value = 1813 value = 1814 1814 p->conv->convBackFxnPtrDD(value, fromUnit->getExponent()); 1815 1815 } … … 1818 1818 // or to the requested unit's basis. 1819 1819 // if we converted to the requested unit's basis. we need to 1820 // do one last conversion from the requested unit's basis back 1820 // do one last conversion from the requested unit's basis back 1821 1821 // to the requested unit. 1822 1822 if ( (toBasis) && (toBasis->getUnitsName() != fromUnit->getUnitsName()) ) { … … 1831 1831 1832 1832 // change the result code to zero, a conversion was performed 1833 // (we think)... its ture that it is possible to get to this 1834 // point and have skipped the conversion because the 1833 // (we think)... its ture that it is possible to get to this 1834 // point and have skipped the conversion because the 1835 1835 // conversion object was not properly created... 1836 1836 // ie. both fxn ptrs were null or neither fxn ptr was null … … 1911 1911 // find the toUnit in our dictionary. 1912 1912 // if the toUnits has a basis, we need to search for the basis 1913 // and convert between basis' and then convert again back to the 1913 // and convert between basis' and then convert again back to the 1914 1914 // original unit. 1915 1915 if ( (toBasis) && (toBasis->getUnitsName() != fromUnit->getUnitsName()) ) { … … 1955 1955 // or to the requested unit's basis. 1956 1956 // if we converted to the requested unit's basis. we need to 1957 // do one last conversion from the requested unit's basis back 1957 // do one last conversion from the requested unit's basis back 1958 1958 // to the requested unit. 1959 1959 if ( (toBasis) && (toBasis->getUnitsName() != fromUnit->getUnitsName()) ) { … … 1968 1968 1969 1969 // change the result code to zero, a conversion was performed 1970 // (we think)... its ture that it is possible to get to this 1971 // point and have skipped the conversion because the 1970 // (we think)... its ture that it is possible to get to this 1971 // point and have skipped the conversion because the 1972 1972 // conversion object was not properly created... 1973 1973 // ie. both fxn ptrs were null or neither fxn ptr was null … … 1988 1988 // or to the requested unit's basis. 1989 1989 // if we converted to the requested unit's basis. we need to 1990 // do one last conversion from the requested unit's basis back 1990 // do one last conversion from the requested unit's basis back 1991 1991 // to the requested unit. 1992 1992 if ( (toBasis) && (toBasis->getUnitsName() != fromUnit->getUnitsName()) ) { … … 2001 2001 2002 2002 // change the result code to zero, a conversion was performed 2003 // (we think)... its ture that it is possible to get to this 2004 // point and have skipped the conversion because the 2003 // (we think)... its ture that it is possible to get to this 2004 // point and have skipped the conversion because the 2005 2005 // conversion object was not properly created... 2006 2006 // ie. both fxn ptrs were null or neither fxn ptr was null … … 2084 2084 // find the toUnit in our dictionary. 2085 2085 // if the toUnits has a basis, we need to search for the basis 2086 // and convert between basis' and then convert again back to the 2086 // and convert between basis' and then convert again back to the 2087 2087 // original unit. 2088 2088 if ( (toBasis) && (toBasis->getUnitsName() != fromUnit->getUnitsName()) ) { … … 2148 2148 // or to the requested unit's basis. 2149 2149 // if we converted to the requested unit's basis. we need to 2150 // do one last conversion from the requested unit's basis back 2150 // do one last conversion from the requested unit's basis back 2151 2151 // to the requested unit. 2152 2152 if ( (toBasis) && (toBasis->getUnitsName() != fromUnit->getUnitsName()) ) { … … 2166 2166 // conversion for a two arg conv function pointer 2167 2167 // need to make this simpler, more logical maybe only allow 2 arg 2168 if ( (p->conv->convBackFxnPtr) 2168 if ( (p->conv->convBackFxnPtr) 2169 2169 && (! p->conv->convBackFxnPtrDD) ) { 2170 2170 … … 2184 2184 // or to the requested unit's basis. 2185 2185 // if we converted to the requested unit's basis. we need to 2186 // do one last conversion from the requested unit's basis back 2186 // do one last conversion from the requested unit's basis back 2187 2187 // to the requested unit. 2188 2188 if ( (toBasis) && (toBasis->getUnitsName() != fromUnit->getUnitsName()) ) { … … 2280 2280 /// Place an RpUnits Object into the Rappture Units Dictionary. 2281 2281 /** 2282 * Return whether the inserted key was new with a non-zero 2282 * Return whether the inserted key was new with a non-zero 2283 2283 * value, or if the key already existed with a value of zero. 2284 2284 */ … … 2442 2442 /**********************************************************************/ 2443 2443 // METHOD: addPresetPrefix() 2444 /// 2444 /// 2445 2445 /** 2446 2446 * Defines the following unit prefixes: … … 2543 2543 * days (d) 2544 2544 * 2545 * month and year are not included because simple 2545 * month and year are not included because simple 2546 2546 * day->month conversions may be misleading 2547 2547 * month->year conversions may be included in the future 2548 * 2548 * 2549 2549 * Return codes: 0 success, anything else is error 2550 2550 */ … … 3229 3229 /// Convert a std::list<std::string> into a comma delimited std::string 3230 3230 /** 3231 * Iterates through a std::list<std::string> and returns a comma 3231 * Iterates through a std::list<std::string> and returns a comma 3232 3232 * delimited std::string containing the elements of the inputted std::list. 3233 3233 *
Note: See TracChangeset
for help on using the changeset viewer.