Replaced by protocol.c:sycformat(...)

This commit is contained in:
hauser_n
2006-04-05 01:13:11 +00:00
parent 08dc6c764b
commit e25fb68080

View File

@ -1,75 +0,0 @@
#----------------------------------------------------------------------------
# Implements sycFormat which is needed by the sycamore protocol.
# Deobjectified version of the ANSTO original
#
# Original Implementor: Paul Hathaway, Ferdi Francescini
#
# More bugs introduced by: Mark Koennecke
#-------------------------------------------------------------------------
if { [info exists sycinit] == 0 } {
set sycinit 1
Publish sycformat Spy
}
array set statusMap [ list OKOK "ok" \
HWIdle "idle" \
HWBusy "running" \
HWFault "fault" \
HWPosFault "posfault" \
HWCrash "crash" \
NOMEMORY "nomemory" \
HWNoBeam "nobeam" \
HWPause "pause" \
HWWarn "warn" \
HWRedo "redo" ]
# 'tag' and 'msgString' parameters must be passed within braces
# eg sycFormat con0004 t000005 s1 event {s1} {type.position status.HWBusy}
proc sycformat {connID transID devID msgFlag tag msgString} {
global statusMap
set fullmatch ""; set msg ""; set eventType ""; set status ""
set position ""
proc _prefix {flag} {
upvar connID cID transID tID devID dID
return "\[$cID:$tID:$dID:$flag\]"
}
set msgString [string trim $msgString]
regexp {<(.*)>} $msgString match msg
regexp {type\.(\w*)} $msgString match eventType
regexp {status\.(\w*)} $msgString match status
# Skip useless messages
if {[string first "Parameter Listing for motor" $msgString] > -1} {
return ""
}
switch $msgFlag {
"event" {
switch $eventType {
"POSITION" {
regexp {(\w+)\.position *= *(\d+(?:\.\d+)?)} $msgString match device position
set output "[_prefix event] $tag={type=$eventType,$devID.position=$position}"
}
"STATUS" {
set output "[_prefix event] $tag={type=$eventType,$devID.status=$statusMap($status)}"
}
default {
# Error
}
}
}
"finish" {
set output "[_prefix finish]"
}
default {
set output "[_prefix $msgFlag] $tag=\{$msgString\}"
}
}
return $output
}