From ed750d42dc5f433a88a756e781b2bcf74a21771a Mon Sep 17 00:00:00 2001 From: Ron Fox Date: Wed, 9 Oct 2024 06:58:38 -0400 Subject: [PATCH 1/7] Issue #15 - Provide defaults for ring parameters for attach online Add support for default ring host and name to the GUI and preferences 'database'. --- main/Gui/prefs.tcl | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/main/Gui/prefs.tcl b/main/Gui/prefs.tcl index ec1a0583c..80fbfa705 100644 --- a/main/Gui/prefs.tcl +++ b/main/Gui/prefs.tcl @@ -33,6 +33,7 @@ package require guihelp # | NSCL DAQ: | # | NSCL DAQ root: [ ] [browse...] | # | Default Buffer Size [ ] | +# | Default ring host [ ] Default Ring [ ]| # +---------------------------------------------+ # | [Ok] [Cancel] [Help] | # +---------------------------------------------+ @@ -42,11 +43,15 @@ package require guihelp # -ydefault - Value in the Y axis entry. # -daqroot - Value of location of nscldaq root. # -buffersize - Default buffers size in bytes on attach dialogs. +# Added to resolve issue #15 +# -defaultringhost - Default host for attach online +# -defaultringname - Default ring name for attach online. +# # # -okscript - Script to execute on click of ok. # -cancelscript - Script to execute on click of cancel. # -helpscript - Script to execute on click of help. - +# # # snit::widget prefsEditor { @@ -55,6 +60,8 @@ snit::widget prefsEditor { option -ydefault option -daqroot option -buffersize + option -defaultringhost + option -defaultringname option -okscript option -cancelscript @@ -85,6 +92,11 @@ snit::widget prefsEditor { entry $win.daqparams.bufsize -textvariable ${selfns}::options(-buffersize) \ -width 15 + label $win.daqparams.hostlabel -text {Online Host} + entry $win.daqparams.host -textvariable [myvar options(-defaultringhost)] + label $win.daqparams.ringlabel -text {Ring Name} + entry $win.daqparams.ring -textvariable [myvar options(-defaultringname)] + frame $win.action -relief groove -borderwidth 3 button $win.action.ok -text Ok -command [mymethod dispatch -okscript] @@ -100,6 +112,8 @@ snit::widget prefsEditor { grid $win.daqparams.title - - grid $win.daqparams.rootlbl $win.daqparams.root $win.daqparams.browse grid $win.daqparams.bufsizelbl $win.daqparams.bufsize x + grid $win.daqparams.hostlabel $win.daqparams.host \ + $win.daqparams.ringlabel $win.daqparams.ring grid $win.daqparams -columnspan 3 -sticky ew @@ -170,6 +184,8 @@ proc preferences::ok {} { set ::GuiPrefs::preferences(defaultYChannels) [.prefs cget -ydefault] set ::GuiPrefs::preferences(defaultDaqRoot) [.prefs cget -daqroot] set ::GuiPrefs::preferences(defaultBuffersize) [.prefs cget -buffersize] + set ::GuiPrefs::preferences(defaultRingHost) [.prefs cget -defaultringhost] + set ::GuiPrefs::preferences(defaultRingName) [.prefs cget -defaultringname] destroy .prefs } proc preferences::cancel {} { @@ -184,6 +200,8 @@ proc preferences::editPrefs {} { -ydefault $::GuiPrefs::preferences(defaultYChannels) \ -daqroot $::GuiPrefs::preferences(defaultDaqRoot) \ -buffersize $::GuiPrefs::preferences(defaultBuffersize) \ + -defaultringhost $::GuiPrefs::preferences(defaultRingHost) \ + -defaultringname $::GuiPrefs::preferences(defaultRingName) \ -okscript preferences::ok \ -cancelscript preferences::cancel \ -helpscript preferences::help From 7bbb32177765d4d12b8e6a19a3aced54cc238a6a Mon Sep 17 00:00:00 2001 From: Ron Fox Date: Wed, 9 Oct 2024 06:59:11 -0400 Subject: [PATCH 2/7] Issue #15 - Provide defaults for ring parameters for attach online Pre-stock the values of the default rig name and host in case it's not in the preferences file when that's read the first time - it will be stored when written --- main/Gui/folderGui.tcl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/main/Gui/folderGui.tcl b/main/Gui/folderGui.tcl index fb0bcd385..f32dd969b 100755 --- a/main/Gui/folderGui.tcl +++ b/main/Gui/folderGui.tcl @@ -1173,5 +1173,17 @@ proc ::FolderGui::startFolderGui {{top {}} {parent {}}} { updateStatus 1000 set ::SpecTclIODwellMax 100 + # We can stock some preferences if there's not (yet) a preferences file: + + setDefaultPrefs preferences::readPrefs } + +# +# setDefaultPrefs +# Set default values for preferences prior to reading the preferences from file: +# +proc setDefaultPrefs() { + set ::GuiPrefs::preferences(defaultRingName) $::tcl_platform(user) + set ::GuiPrefs::preferences(defaultRingHost) localhost +} \ No newline at end of file From 96c62a34016ec7edab4d44892bf892a48c32885f Mon Sep 17 00:00:00 2001 From: Ron Fox Date: Wed, 9 Oct 2024 07:06:35 -0400 Subject: [PATCH 3/7] Issue #15 - Provide defaults for ring parameters for attach online Use the default stuff when prompting attach-online. --- main/Gui/datasource.tcl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/main/Gui/datasource.tcl b/main/Gui/datasource.tcl index 9746b8584..b3da6d5f7 100755 --- a/main/Gui/datasource.tcl +++ b/main/Gui/datasource.tcl @@ -27,8 +27,9 @@ package require segmentedrun # Namespace to hold some of the configuration entries. # namespace eval datasource { - variable daqroot [list $::daqdefs::daqroot /usr/opt/daq/current /usr/opt/daq/8.1 /usr/opt/daq/8.0 /usr/opt/daq]; # Where the DAQ software is installed. - variable lasthost localhost; # Most recent online host. + variable daqroot [list $::daqdefs::daqroot \ + ::GuiPrefs::preferences(defaultDaqRoot) /usr/opt/daq/current \ + /usr/opt/daq/8.1 /usr/opt/daq/8.0 /usr/opt/daq]; # Where the DAQ software is installed. variable lastformat ring11 variable lasteventfile {} variable lastpipecommand {} @@ -38,7 +39,6 @@ namespace eval datasource { variable warnedFilters 0 variable lastFilterFile {} variable actualSpecTclDaq {} - variable lastring $::tcl_platform(user) variable clustersize 8192 variable defaultFileBuffer [expr 128*1024]; # Better performance for files. @@ -200,10 +200,10 @@ proc attachDataSource {format size sourcetype sourcespec} { # We need to pop up a dialog to request the node from which we take data. # proc attachOnline {} { - hostprompt .hostprompt -host $::datasource::lasthost \ + hostprompt .hostprompt -host $::GuiPrefs::preferences \ -format [defaultFormat] \ -buffersize $::GuiPrefs::preferences(defaultBuffersize) \ - -ringname $::datasource::lastring + -ringname $::GuiPrefs::preferences(defaultRingName) \ #after 1 .hostprompt configure -format [defaultFormat] .hostprompt modal if {[winfo exists .hostprompt]} { @@ -215,11 +215,11 @@ proc attachOnline {} { if {[string match ring* $format]} { set additionalInfo [.hostprompt cget -ringname] - set ::datasource::lastring $additionalInfo + set $::GuiPrefs::preferences(defaultRingName) $additionalInfo } set size [.hostprompt cget -buffersize] - set ::datasource::lasthost $host + set $::GuiPrefs::preferences(defaultRingHost) $host set ::datasource::lastformat $format set ::GuiPrefs::preferences(defaultBuffersize) $size From 5a2af6e3064bab1795562479e49939ee3761b257 Mon Sep 17 00:00:00 2001 From: Ron Fox Date: Wed, 9 Oct 2024 07:07:59 -0400 Subject: [PATCH 4/7] Begin work on 7.0-001 --- main/configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/configure.ac b/main/configure.ac index b8bf69c23..aa417a05a 100755 --- a/main/configure.ac +++ b/main/configure.ac @@ -1,6 +1,6 @@ # Process this file with autoconf to produce a configure script. -AC_INIT(SpecTcl,7.0-000, daqhelp@frib.msu.edu) +AC_INIT(SpecTcl,7.0-001, daqhelp@frib.msu.edu) AC_CONFIG_AUX_DIR(config) AM_INIT_AUTOMAKE([tar-ustar foreign]) From 28e3c6a1590024b51343c4d416b2463c8b93b0e1 Mon Sep 17 00:00:00 2001 From: Ron Fox Date: Wed, 9 Oct 2024 08:22:45 -0400 Subject: [PATCH 5/7] Issue #15 - Provide defaults for ring parameters for attach online Work around the fact that tclhttpd overwrite the HOME env variable which affects what ~ is...and pop up a dialog if saving the preferences file fails. --- main/Gui/folderGui.tcl | 12 +++++++++--- main/Gui/prefs.tcl | 5 +++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/main/Gui/folderGui.tcl b/main/Gui/folderGui.tcl index f32dd969b..d9068b558 100755 --- a/main/Gui/folderGui.tcl +++ b/main/Gui/folderGui.tcl @@ -223,7 +223,13 @@ proc incrementalSource filename { # We also save the new preferences for the user. proc editPrefs {} { preferences::editPrefs - preferences::savePrefs + if {[catch {preferences::savePrefs} msg] != 0} { + tk_messageBox \ + -icon warning \ + -message "Could not save preferences file $msg" \ + -parent . -title "Preferences failed" -type ok + } + } @@ -1182,8 +1188,8 @@ proc ::FolderGui::startFolderGui {{top {}} {parent {}}} { # # setDefaultPrefs # Set default values for preferences prior to reading the preferences from file: -# -proc setDefaultPrefs() { +# These are new values as of 7.0-001 - to resolve issue #15 which may not be in the file: +proc setDefaultPrefs {} { set ::GuiPrefs::preferences(defaultRingName) $::tcl_platform(user) set ::GuiPrefs::preferences(defaultRingHost) localhost } \ No newline at end of file diff --git a/main/Gui/prefs.tcl b/main/Gui/prefs.tcl index 80fbfa705..cd4c6b7a9 100644 --- a/main/Gui/prefs.tcl +++ b/main/Gui/prefs.tcl @@ -220,10 +220,11 @@ proc preferences::readPrefs {} { } } proc preferences::savePrefs {} { - set fd [open [file join ~ $::preferences::SpecTclDefaults] w] + set home ~$::tcl_platform(user) + set fd [open [file join $home $::preferences::SpecTclDefaults] w] puts $fd "# SpecTcl gui preferences written [clock format [clock seconds]]" foreach pref [array names GuiPrefs::preferences] { - puts $fd "set preferences($pref) $GuiPrefs::preferences($pref)" + puts $fd "set preferences($pref) $GuiPrefs::preferences($pref)" } close $fd } \ No newline at end of file From e8180fe277acf5bced262df7ba747c18203fc687 Mon Sep 17 00:00:00 2001 From: Ron Fox Date: Wed, 9 Oct 2024 08:39:30 -0400 Subject: [PATCH 6/7] Issue #15 - Provide defaults for ring parameters for attach online Fix errors in updateing the preferences from the attach online dialog. --- main/Gui/datasource.tcl | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/main/Gui/datasource.tcl b/main/Gui/datasource.tcl index b3da6d5f7..61906722a 100755 --- a/main/Gui/datasource.tcl +++ b/main/Gui/datasource.tcl @@ -200,35 +200,36 @@ proc attachDataSource {format size sourcetype sourcespec} { # We need to pop up a dialog to request the node from which we take data. # proc attachOnline {} { - hostprompt .hostprompt -host $::GuiPrefs::preferences \ + + hostprompt .hostprompt -host $::GuiPrefs::preferences(defaultRingHost) \ -format [defaultFormat] \ -buffersize $::GuiPrefs::preferences(defaultBuffersize) \ - -ringname $::GuiPrefs::preferences(defaultRingName) \ - #after 1 .hostprompt configure -format [defaultFormat] + -ringname $::GuiPrefs::preferences(defaultRingName) + .hostprompt configure -format [defaultFormat] .hostprompt modal if {[winfo exists .hostprompt]} { set host [.hostprompt cget -host] if {$host != ""} { - set format [.hostprompt cget -format] - set additionalInfo {} + set format [.hostprompt cget -format] + set additionalInfo {} - if {[string match ring* $format]} { - set additionalInfo [.hostprompt cget -ringname] - set $::GuiPrefs::preferences(defaultRingName) $additionalInfo + if {[string match ring* $format]} { + set additionalInfo [.hostprompt cget -ringname] + set ::GuiPrefs::preferences(defaultRingName) $additionalInfo } set size [.hostprompt cget -buffersize] - - set $::GuiPrefs::preferences(defaultRingHost) $host - set ::datasource::lastformat $format - set ::GuiPrefs::preferences(defaultBuffersize) $size - - set helper [.hostprompt onlinehelper $host $additionalInfo] + set ::GuiPrefs::preferences(defaultRingHost) $host + set ::datasource::lastformat $format + set ::GuiPrefs::preferences(defaultBuffersize) $size + + set helper [.hostprompt onlinehelper $host $additionalInfo] attachDataSource $format $size -pipe $helper } destroy .hostprompt } + } # attachFile # Prompts for an event file to attach to and does the deed. From 880c9418a533b8d6ec5dcfe94ec2090b833348b5 Mon Sep 17 00:00:00 2001 From: Ron Fox Date: Wed, 9 Oct 2024 08:45:52 -0400 Subject: [PATCH 7/7] also canonicalize to ~user in reading. --- main/Gui/prefs.tcl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main/Gui/prefs.tcl b/main/Gui/prefs.tcl index cd4c6b7a9..910aa21a5 100644 --- a/main/Gui/prefs.tcl +++ b/main/Gui/prefs.tcl @@ -213,9 +213,11 @@ proc preferences::editPrefs {} { } proc preferences::readPrefs {} { - if {[file readable [file join ~ $::preferences::SpecTclDefaults]]} { + set home ~$::tcl_platform(user) + set prefFile [file join $home $::preferences::SpecTclDefaults] + if {[file readable $prefFile]} { namespace eval ::GuiPrefs { - source [file join ~ $::preferences::SpecTclDefaults] + source [file $prefFile] } } }