Skip to content

Commit

Permalink
Merge pull request #173 from FRIBDAQ/rfoxkendo/issue15
Browse files Browse the repository at this point in the history
Rfoxkendo/issue15
  • Loading branch information
rfoxkendo authored Oct 9, 2024
2 parents e540f78 + 880c941 commit 6803ce5
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 24 deletions.
35 changes: 18 additions & 17 deletions main/Gui/datasource.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand All @@ -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.

Expand Down Expand Up @@ -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 $::datasource::lasthost \

hostprompt .hostprompt -host $::GuiPrefs::preferences(defaultRingHost) \
-format [defaultFormat] \
-buffersize $::GuiPrefs::preferences(defaultBuffersize) \
-ringname $::datasource::lastring
#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 ::datasource::lastring $additionalInfo
if {[string match ring* $format]} {
set additionalInfo [.hostprompt cget -ringname]
set ::GuiPrefs::preferences(defaultRingName) $additionalInfo
}
set size [.hostprompt cget -buffersize]

set ::datasource::lasthost $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.
Expand Down
20 changes: 19 additions & 1 deletion main/Gui/folderGui.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

}


Expand Down Expand Up @@ -1173,5 +1179,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:
# 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
}
31 changes: 26 additions & 5 deletions main/Gui/prefs.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ package require guihelp
# | NSCL DAQ: |
# | NSCL DAQ root: [ ] [browse...] |
# | Default Buffer Size [ ] |
# | Default ring host [ ] Default Ring [ ]|
# +---------------------------------------------+
# | [Ok] [Cancel] [Help] |
# +---------------------------------------------+
Expand All @@ -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 {
Expand All @@ -55,6 +60,8 @@ snit::widget prefsEditor {
option -ydefault
option -daqroot
option -buffersize
option -defaultringhost
option -defaultringname

option -okscript
option -cancelscript
Expand Down Expand Up @@ -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]
Expand All @@ -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


Expand Down Expand Up @@ -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 {} {
Expand All @@ -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
Expand All @@ -195,17 +213,20 @@ 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]
}
}
}
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
}
2 changes: 1 addition & 1 deletion main/configure.ac
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Process this file with autoconf to produce a configure script.

AC_INIT(SpecTcl,7.0-000, [email protected])
AC_INIT(SpecTcl,7.0-001, [email protected])

AC_CONFIG_AUX_DIR(config)
AM_INIT_AUTOMAKE([tar-ustar foreign])
Expand Down

0 comments on commit 6803ce5

Please sign in to comment.