- Added Sycamore protocol and command context to SICS
- Added sinfo to SICS - Added driver for TCP/IP Astrium velocity selector - Added driver for TCP/IP Astrium chopper controller SKIPPED: psi/amor2t.c psi/amorstat.c psi/dornier2.c psi/ecb.c psi/el734hp.c psi/fowrite.c psi/libpsi.a psi/make_gen psi/nextrics.c psi/pardef.c psi/pimotor.c psi/pipiezo.c psi/polterwrite.c psi/psi.c psi/scontroller.c psi/serial.c psi/tasinit.c psi/tasscan.c psi/tcpdocho.c psi/tcpdornier.c psi/tricssupport.c psi/velodornier.c
This commit is contained in:
91
sycFormat.tcl
Normal file
91
sycFormat.tcl
Normal file
@@ -0,0 +1,91 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# 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 cache
|
||||
|
||||
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\]"
|
||||
}
|
||||
|
||||
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 {
|
||||
"start" {
|
||||
set output "[_prefix start] $msgString"
|
||||
|
||||
}
|
||||
"event" {
|
||||
switch $eventType {
|
||||
"POSITION" {
|
||||
regexp {(\w+)\.position *= *(\d+(?:\.\d+)?)} $msgString match device position
|
||||
set output "[_prefix event] $tag={type=$eventType,$devID.position=$position}"
|
||||
}
|
||||
default {
|
||||
# Error
|
||||
}
|
||||
}
|
||||
}
|
||||
"out" {
|
||||
# Concatenate multiple messages into a comma separated list
|
||||
if [info exists cache($transID)] {
|
||||
append msg ", " $msgString
|
||||
eval "lappend cache($transID) $msg"
|
||||
} else {
|
||||
eval "lappend cache($transID) $msgString"
|
||||
}
|
||||
set output ""
|
||||
}
|
||||
"finish" {
|
||||
if [info exists cache($transID)] {
|
||||
set output "[_prefix out] $tag=\{$cache($transID)\}"
|
||||
append output "\n[_prefix finish]"
|
||||
unset cache($transID)
|
||||
} else {
|
||||
set output "[_prefix finish]"
|
||||
}
|
||||
}
|
||||
default {
|
||||
set output "[_prefix $msgFlag] $msgString"
|
||||
}
|
||||
}
|
||||
return $output
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user