added -stop flag

This commit is contained in:
laznovsky
2013-04-15 12:10:40 +00:00
parent 73e937537c
commit 218a93caa2

13
ca
View File

@@ -2,12 +2,12 @@
# ca* by Dirk Zimoch
# $Source: /cvs/G/EPICS/App/scripts/ca,v $
# $Date: 2011/12/20 16:18:26 $
# $Date: 2013/04/15 12:10:40 $
regsub -all {\$} {ca* by Dirk Zimoch
$Source: /cvs/G/EPICS/App/scripts/ca,v $
$Revision: 1.19 $
$Date: 2011/12/20 16:18:26 $} {} version
$Revision: 1.20 $
$Date: 2013/04/15 12:10:40 $} {} version
proc printHelp {} {
puts {usage: caget [flags] <channel> [<channel> ...]}
@@ -40,6 +40,7 @@ proc printHelp {} {
puts {-prec <digits> override the PREC field}
puts {-plain don't do any formatting}
puts {-timeout <sec> timeout cawait after <sec> seconds}
puts {-stop <num> exit after <num> updates (for camon)}
puts {-version print version and exit}
puts {-help print this help text and exit}
}
@@ -54,6 +55,7 @@ if {![regexp {gets|get|putq|put|info|mon|do|wait} [file tail $argv0] command]} {
}
set flags {}
set stop 0
while {[string match "-*" [set flag [lindex $argv 0]]]} {
switch -regexp -- $flag {
{^-(\?)|(h(elp)?)$} { printHelp; exit}
@@ -62,6 +64,8 @@ while {[string match "-*" [set flag [lindex $argv 0]]]} {
set argv [lrange $argv 2 end] }
{^-prec} { set prec [lindex $argv 1]
set argv [lrange $argv 2 end] }
{^-stop} { set stop [lindex $argv 1]
set argv [lrange $argv 2 end] }
default { lappend flags $flag
set argv [lrange $argv 1 end] }
}
@@ -206,7 +210,7 @@ proc parsecond {cond} {
}
proc monitor {channel condition io value stat sevr time} {
global info oldval
global info flags oldval stop
if {$io != "OK"} {
unset info($channel)
unset oldval($channel)
@@ -221,6 +225,7 @@ proc monitor {channel condition io value stat sevr time} {
if {[info exists oldval($channel)] && $oldval($channel) == $newval} return
set oldval($channel) $newval
puts $newval
if {$stop > 0 && [incr stop -1] < 1} { exit }
return
}
if [expr $condition] {