added --(a)ddress and --(p)ort arguments to core-gui command-line
added save/close buttons to plugins dialog updated man page/documentation with new arguments (Boeing r1816)
This commit is contained in:
parent
f2d1b6a553
commit
ca332bd83a
6 changed files with 74 additions and 94 deletions
|
@ -4,7 +4,7 @@
|
|||
core-gui \- Common Open Research Emulator (CORE) graphical user interface
|
||||
.SH SYNOPSIS
|
||||
.B core-gui
|
||||
[\fI-h|-v\fR] [\fI-b|-c <sessionid>\fR] [\fI-s\fR] [\fI<configfile.imn>\fR]
|
||||
[\fI-h|-v\fR] [\fI-b|-c <sessionid>\fR] [\fI-s\fR] [\fI-a address\fR] [\fI-p port\fR] [\fI<configfile.imn>\fR]
|
||||
.SH DESCRIPTION
|
||||
Launches the CORE Tcl/Tk X11 GUI or starts an imn\-based emulation.
|
||||
.TP
|
||||
|
@ -23,6 +23,12 @@ stop and clean up a batch mode session <sessionid>
|
|||
\-(\fB\-s\fR)tart
|
||||
start in execute mode, not edit mode
|
||||
.TP
|
||||
\-(\fB\-a\fR)ddress
|
||||
connect to the specified IP address (default 127.0.0.1)
|
||||
.TP
|
||||
\-(\fB\-p\fR)ort
|
||||
connect to the specified TCP port (default 4038)
|
||||
.TP
|
||||
<configfile.imn>
|
||||
(optional) load the specified imn scenario file
|
||||
.PP
|
||||
|
|
|
@ -88,6 +88,13 @@ The session number is printed in the terminal when batch mode is started. This s
|
|||
The GUI can be run as a normal user on Linux. For FreeBSD, the GUI should be run
|
||||
as root in order to start an emulation.
|
||||
|
||||
.. index:: port number
|
||||
|
||||
The GUI can be connected to a different address or TCP port using
|
||||
the ``--address`` and/or ``--port`` options. The defaults are shown below.
|
||||
::
|
||||
core-gui --address 127.0.0.1 --port 4038
|
||||
|
||||
.. _Toolbar:
|
||||
|
||||
Toolbar
|
||||
|
|
|
@ -34,7 +34,8 @@
|
|||
case $1 in
|
||||
-h | --help)
|
||||
echo ""
|
||||
echo "Usage: `basename $0` [-h|-v] [-b|-c <sessionid>] [-s] [<configfile.imn>]"
|
||||
echo "Usage: `basename $0` [-h|-v] [-b|-c <sessionid>] [-s] [-a address] [-p port]"
|
||||
echo " [<configfile.imn>]"
|
||||
echo ""
|
||||
echo "Launches the CORE Tcl/Tk X11 GUI or starts an imn-based emulation."
|
||||
echo ""
|
||||
|
@ -44,6 +45,8 @@ case $1 in
|
|||
echo -n " -(-c)losebatch <sessionid> stop and clean up a batch mode "
|
||||
echo "session <sessionid>"
|
||||
echo " -(-s)tart start in execute mode, not edit mode"
|
||||
echo " -(-a)ddress connect to the specified IP address (default 127.0.0.1)"
|
||||
echo " -(-p)port connect to the specified TCP port (default 4038)"
|
||||
echo " <configfile.imn> (optional) load the specified imn scenario file"
|
||||
echo ""
|
||||
echo "With no parameters, starts the GUI in edit mode with a blank canvas."
|
||||
|
@ -154,10 +157,19 @@ case $1 in
|
|||
exec ${TCLBIN} $core "$@"
|
||||
;;
|
||||
-s)
|
||||
exec ${WISH} $core "--start $@"
|
||||
shift
|
||||
exec ${WISH} $core -- "--start" "$@"
|
||||
;;
|
||||
-a)
|
||||
shift
|
||||
exec ${WISH} $core -- "--address" "$@"
|
||||
;;
|
||||
-p)
|
||||
shift
|
||||
exec ${WISH} $core -- "--port" "$@"
|
||||
;;
|
||||
*)
|
||||
exec ${WISH} $core $@
|
||||
exec ${WISH} $core -- $@
|
||||
;;
|
||||
esac
|
||||
|
||||
|
|
86
gui/core.tcl
86
gui/core.tcl
|
@ -31,49 +31,19 @@
|
|||
# and Technology through the research contract #IP-2003-143.
|
||||
#
|
||||
|
||||
#****h* imunes/imunes.tcl
|
||||
# NAME
|
||||
# imunes.tcl
|
||||
# FUNCTION
|
||||
# Starts imunes in batch or interactive mode. Include procedures from
|
||||
# external files and initializes global variables.
|
||||
#
|
||||
# imunes [-b|--batch] [filename]
|
||||
#
|
||||
# When starting the program in batch mode the option -b or --batch must
|
||||
# be specified.
|
||||
#
|
||||
# When starting the program with defined filename, configuration for
|
||||
# file "filename" is loaded to imunes.
|
||||
#****
|
||||
|
||||
if {[lindex $argv 0] == "-b" || [lindex $argv 0] == "--batch"} {
|
||||
set argv [lrange $argv 1 end]
|
||||
set execMode batch
|
||||
} elseif {[lindex $argv 0] == "-c" || [lindex $argv 0] == "--closebatch"} {
|
||||
set argv [lrange $argv 1 end]
|
||||
set execMode closebatch
|
||||
} elseif {[lindex $argv 0] == "-a" || [lindex $argv 0] == "--addons"} {
|
||||
} elseif {[lindex $argv 0] == "--addons"} {
|
||||
set argv [lrange $argv 1 end]
|
||||
set execMode addons
|
||||
} else {
|
||||
set execMode interactive
|
||||
}
|
||||
|
||||
#
|
||||
# Include procedure definitions from external files. There must be
|
||||
# some better way to accomplish the same goal, but that's how we do it
|
||||
# for the moment.
|
||||
#
|
||||
|
||||
#****v* imunes.tcl/LIBDIR
|
||||
# NAME
|
||||
# LIBDIR
|
||||
# FUNCTION
|
||||
# The location of imunes library files. The LIBDIR variable
|
||||
# will be automatically set to the proper value by the installation script.
|
||||
#*****
|
||||
|
||||
set LIBDIR ""
|
||||
set SBINDIR "/usr/local/sbin"
|
||||
set CONFDIR "."
|
||||
|
@ -136,61 +106,12 @@ source "$LIBDIR/exceptions.tcl"
|
|||
#
|
||||
# Global variables are initialized here
|
||||
#
|
||||
|
||||
#****v* imunes.tcl/node_list
|
||||
# NAME
|
||||
# node_list
|
||||
# FUNCTION
|
||||
# Represents the list of all the nodes in the simulation. When starting
|
||||
# the program this list is empty.
|
||||
#*****
|
||||
|
||||
#****v* imunes.tcl/link_list
|
||||
# NAME
|
||||
# link_list
|
||||
# FUNCTION
|
||||
# Represents the list of all the links in the simulation. When starting
|
||||
# the program this list is empty.
|
||||
#*****
|
||||
|
||||
#****v* imunes.tcl/canvas_list
|
||||
# NAME
|
||||
# canvas_list
|
||||
# FUNCTION
|
||||
# Contains the list of all the canvases in the simulation. When starting
|
||||
# the program this list is empty.
|
||||
#*****
|
||||
|
||||
#****v* imunes.tcl/prefs
|
||||
# NAME
|
||||
# prefs
|
||||
# FUNCTION
|
||||
# Contains the list of preferences. When starting a program
|
||||
# this list is empty.
|
||||
#*****
|
||||
|
||||
#****v* imunes.tcl/eid
|
||||
# NAME
|
||||
# eid -- experiment id.
|
||||
# FUNCTION
|
||||
# The id of the current experiment. When starting a program this variable
|
||||
# is set to e0.
|
||||
#*****
|
||||
|
||||
set node_list {}
|
||||
set link_list {}
|
||||
set annotation_list {}
|
||||
set canvas_list {}
|
||||
set eid e0
|
||||
set plot_list {}
|
||||
|
||||
#****v* core.tcl/exec_servers
|
||||
# NAME
|
||||
# exec_servers -- array of CORE remote execution servers
|
||||
# FUNCTION
|
||||
#*****
|
||||
|
||||
# IP port monitor_port active ssh username
|
||||
array set exec_servers {}
|
||||
loadServersConf ;# populate exec_servers
|
||||
|
||||
|
@ -202,6 +123,7 @@ set g_mrulist {}
|
|||
initDefaultPrefs
|
||||
loadDotFile
|
||||
loadPluginsConf
|
||||
checkCommandLineAddressPort
|
||||
autoConnectPlugins
|
||||
|
||||
|
||||
|
@ -225,12 +147,10 @@ if {$execMode == "interactive"} {
|
|||
puts " $e"
|
||||
}
|
||||
}
|
||||
# end Boeing
|
||||
setOperMode edit
|
||||
fileOpenStartUp
|
||||
# Boeing --start option
|
||||
foreach arg $argv {
|
||||
if { $arg == "--start -s" || $arg == "--start" } {
|
||||
if { $arg == "--start" } {
|
||||
global currentFile
|
||||
if { [file extension $currentFile] == ".xml" } {
|
||||
after 100; update; # yield to other events so XML file
|
||||
|
|
|
@ -261,8 +261,7 @@ proc fileOpenStartUp {} {
|
|||
|
||||
# Boeing
|
||||
foreach arg $argv {
|
||||
if { $arg != "" && $arg != "--start -s" && $arg != "--start" && \
|
||||
$arg != "--batch -b" && $arg != "--batch" } {
|
||||
if { $arg != "" && $arg != "--start" && $arg != "--batch" } {
|
||||
set currentFile [argAbsPathname $arg]
|
||||
openFile
|
||||
break
|
||||
|
|
|
@ -120,8 +120,9 @@ proc popupPluginsConfig {} {
|
|||
|
||||
# close button
|
||||
frame $wi.b -borderwidth 0
|
||||
button $wi.b.cancel -text "Close" -command "writePluginsConf; destroy $wi"
|
||||
pack $wi.b.cancel -side right
|
||||
button $wi.b.save -text "Save" -command "writePluginsConf; destroy $wi"
|
||||
button $wi.b.cancel -text "Cancel" -command "destroy $wi"
|
||||
pack $wi.b.cancel $wi.b.save -side right
|
||||
pack $wi.b -side bottom
|
||||
|
||||
# uncomment to make modal
|
||||
|
@ -1230,6 +1231,7 @@ proc pluginConnect { name cmd retry } {
|
|||
# connect, disconnect, or do nothing
|
||||
if { $cmd == "connect" && $snum != 1} {
|
||||
puts -nonewline "Connecting to $name ($ip:$port)..."
|
||||
flush stdout
|
||||
set sock [openAPIChannel $ip $port $retry]
|
||||
if { "$sock" <= -1 } { return -1 };# user pressed cancel
|
||||
set snum 1 ;# status connected
|
||||
|
@ -1561,3 +1563,37 @@ proc listToKeyValues { keyvalues } {
|
|||
return $r
|
||||
}
|
||||
|
||||
# parse command-line parameters for address/port to connect with
|
||||
proc checkCommandLineAddressPort {} {
|
||||
global argv g_plugins
|
||||
set addr ""; set port ""
|
||||
set addri [lsearch -regexp $argv "(^\[-\]\[-\]address$|^\[-\]a$)"]
|
||||
#set addri [lsearch -exact $argv "--address"]
|
||||
if { $addri > -1 } {
|
||||
set argv [lreplace $argv $addri $addri]
|
||||
set addr [lindex $argv $addri]
|
||||
if { ![checkIPv4Addr $addr] } {
|
||||
puts "error: invalid address '$addr'"; exit;
|
||||
}
|
||||
set argv [lreplace $argv $addri $addri]
|
||||
}
|
||||
|
||||
#set porti [lsearch -exact $argv "--port"]
|
||||
set porti [lsearch -regexp $argv "(^\[-\]\[-\]port$|^\[-\]p$)"]
|
||||
if { $porti > -1 } {
|
||||
set argv [lreplace $argv $porti $porti]
|
||||
set port [lindex $argv $porti]
|
||||
if { $port == "" || ![string is integer $port] || $port > 65535 } {
|
||||
puts "error: invalid port '$port'"; exit;
|
||||
}
|
||||
set argv [lreplace $argv $porti $porti]
|
||||
}
|
||||
# update the auto-connect plugin (core-daemon entry)
|
||||
if { $addri > -1 || $porti > -1 } {
|
||||
set key [lindex [getEmulPlugin "*"] 0]
|
||||
set plugin_data $g_plugins($key)
|
||||
if { $addri > -1 } { set plugin_data [lreplace $plugin_data 0 0 $addr] }
|
||||
if { $porti > -1 } { set plugin_data [lreplace $plugin_data 1 1 $port] }
|
||||
array set g_plugins [list $key $plugin_data]
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue