added exitstatus and some flags

This commit is contained in:
zimoch
2003-04-07 09:19:57 +00:00
parent 98dfa0523a
commit eedf29f835

43
ca
View File

@@ -1,7 +1,10 @@
#!/usr/bin/tclsh
# $Id: ca,v 1.6 2002/12/17 17:34:49 zimoch Exp $
# $Id: ca,v 1.7 2003/04/07 09:19:57 zimoch Exp $
# $Source: /cvs/G/EPICS/App/scripts/ca,v $
# $Log: ca,v $
# Revision 1.7 2003/04/07 09:19:57 zimoch
# added exitstatus and some flags
#
# Revision 1.6 2002/12/17 17:34:49 zimoch
# debugged
#
@@ -34,8 +37,8 @@ while {[string match "-*" [lindex $argv 0]]} {
if {[lsearch -regexp $flags {-(v(er(sion)?)?)}] != -1} {
puts "ca* by Dirk Zimoch"
puts [string trim {$Source: /cvs/G/EPICS/App/scripts/ca,v $} $]
puts [string trim {$Revision: 1.6 $} $]
puts [string trim {$Date: 2002/12/17 17:34:49 $} $]
puts [string trim {$Revision: 1.7 $} $]
puts [string trim {$Date: 2003/04/07 09:19:57 $} $]
exit
}
@@ -59,6 +62,12 @@ if {[lsearch -regexp $flags {-(\?)|(h(elp)?)}] != -1 || [llength $argv] == 0} {
puts {-localdate add host date}
puts {-time add record execution time}
puts {-localtime add host time}
puts {-noname don't add channel name}
puts {-nounit don't add units}
puts {-stat always add severity/status}
puts {-nostat never add severity/status}
puts {-version print version and exit}
puts {-help print this help text and exit}
exit
}
@@ -99,7 +108,7 @@ proc formatval {channel {value {}} {sevr {}} {stat {}} {time {}}} {
set value [list $value]
}
if {$sevr != "NO_ALARM"} {
if {[lsearch $flags -stat] != -1 || $sevr != "NO_ALARM"} {
set status " (SEVR:$sevr STAT:$stat)"
} else {
set status ""
@@ -115,13 +124,16 @@ proc formatval {channel {value {}} {sevr {}} {stat {}} {time {}}} {
set time ""
foreach flag $flags {
switch -- $flag {
"-date" {append time [format "%02d.%02d.%02d " $d $m $y]}
"-localdate" {append time [clock format $clock -format "%d.%m.%y "]}
"-time" {append time [format "%02d:%02d:%05.2f " $H $M $S]}
"-localtime" {append time [clock format $clock -format "%H:%M:%S "]}
"-date" {lappend time [format "%02d.%02d.%02d" $d $m $y]}
"-localdate" {lappend time [clock format $clock -format "%d.%m.%y"]}
"-time" {lappend time [format "%02d:%02d:%05.2f" $H $M $S]}
"-localtime" {lappend time [clock format $clock -format "%H:%M:%S"]}
"-noname" {set channel ""}
"-nounit" {set EGU ""}
"-nostat" {set status ""}
}
}
return "$time$channel $value $EGU$status"
return [concat $time $channel $value $EGU $status]
}
proc monitor {channel io value stat sevr time} {
@@ -141,10 +153,14 @@ proc monitor {channel io value stat sevr time} {
puts $newval
}
set exitstatus 0
if {$command == "gets"} {
foreach channel $argv {
regexp {^[^\.]*} $channel base
pvput $base.PROC 1
if [catch {pvput $base.PROC 1} msg] {
puts stderr "pvput: $msg"
incr exitstatus
}
}
}
@@ -155,12 +171,14 @@ if {$command == "put"} {
pvput $channel $setvalue
} msg] {
puts stderr "pvput: $msg"
incr exitstatus
}
if [catch {
pvget $channel
lappend channels $channel
} msg] {
puts stderr "pvget: $msg"
incr exitstatus
}
}
} else {
@@ -171,14 +189,16 @@ if {$command == "do"} {
foreach channel $channels {
if [catch {pvputq $channel 1} msg] {
puts stderr "pvputq: $msg"
incr exitstatus
}
}
exit
exit $exitstatus
}
foreach channel $channels {
if [catch {set info($channel) [pvinfo $channel]} msg] {
puts stderr "pvinfo: $msg"
incr exitstatus
}
switch $command {
"mon" {
@@ -202,4 +222,5 @@ foreach channel $channels {
}
if {$command == "mon"} {vwait forever}
exit $exitstatus