Generate the green magnet wrapper TCL code
This commit is contained in:
@@ -0,0 +1,135 @@
|
||||
# Generated driver for green_magnet_labview
|
||||
# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent
|
||||
#
|
||||
|
||||
namespace eval ::scobj::green_magnet_labview {
|
||||
set debug_threshold 5
|
||||
}
|
||||
|
||||
proc ::scobj::green_magnet_labview::debug_log {tc_root debug_level debug_string} {
|
||||
set catch_status [ catch {
|
||||
set debug_threshold [hgetpropval ${tc_root} debug_threshold]
|
||||
if {${debug_level} >= ${debug_threshold}} {
|
||||
set fd [open "../log/green_magnet_labview_[basename ${tc_root}].log" "a"]
|
||||
set line "[clock format [clock seconds] -format "%T"] ${debug_string}"
|
||||
puts ${fd} "${line}"
|
||||
close ${fd}
|
||||
}
|
||||
} catch_message ]
|
||||
}
|
||||
|
||||
proc ::scobj::green_magnet_labview::sics_log {debug_level debug_string} {
|
||||
set catch_status [ catch {
|
||||
set debug_threshold ${::scobj::green_magnet_labview::debug_threshold}
|
||||
if {${debug_level} >= ${debug_threshold}} {
|
||||
sicslog "::scobj::green_magnet_labview::${debug_string}"
|
||||
}
|
||||
} catch_message ]
|
||||
}
|
||||
|
||||
proc ::scobj::green_magnet_labview::mkDriver { sct_controller name } {
|
||||
::scobj::green_magnet_labview::sics_log 9 "::scobj::green_magnet_labview::mkDriver for ${name}"
|
||||
set ns "[namespace current]"
|
||||
set catch_status [ catch {
|
||||
|
||||
# mkWrapper hook code starts
|
||||
# TCL code
|
||||
::scobj::green::mkGreen {
|
||||
name "green_magnet"
|
||||
IP 137.157.201.88
|
||||
PORT 5001
|
||||
tuning 1
|
||||
interval 3
|
||||
}
|
||||
# mkWrapper hook code ends
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
namespace eval ::scobj::green_magnet_labview {
|
||||
namespace export debug_threshold
|
||||
namespace export debug_log
|
||||
namespace export sics_log
|
||||
namespace export mkDriver
|
||||
}
|
||||
|
||||
proc add_green_magnet_labview {name IP port} {
|
||||
set catch_status [ catch {
|
||||
::scobj::green_magnet_labview::sics_log 9 "add_green_magnet_labview ${name} ${IP} ${port}"
|
||||
::scobj::green_magnet_labview::sics_log 9 "No sctcontroller for green_magnet_labview"
|
||||
::scobj::green_magnet_labview::sics_log 1 "::scobj::green_magnet_labview::mkDriver sct_${name} ${name}"
|
||||
::scobj::green_magnet_labview::mkDriver sct_${name} ${name}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
clientput "file evaluation of sct_green_magnet_labview.tcl"
|
||||
::scobj::green_magnet_labview::sics_log 9 "file evaluation of sct_green_magnet_labview.tcl"
|
||||
|
||||
proc ::scobj::green_magnet_labview::read_config {} {
|
||||
set catch_status [ catch {
|
||||
set ns "::scobj::green_magnet_labview"
|
||||
dict for {k u} $::config_dict {
|
||||
if { [dict exists $u "implementation"] } {
|
||||
if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } {
|
||||
continue
|
||||
}
|
||||
set enabled [string tolower [dict get $u "enabled"]]
|
||||
if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } {
|
||||
continue
|
||||
}
|
||||
set name [dict get $u name]
|
||||
set implementation [dict get $u "implementation"]
|
||||
if { !([dict exists $::config_dict $implementation]) } {
|
||||
continue
|
||||
}
|
||||
set v [dict get $::config_dict $implementation]
|
||||
if { !([dict exists $v "driver"]) } {
|
||||
continue
|
||||
}
|
||||
if { [string equal -nocase [dict get $v "driver"] "green_magnet_labview"] } {
|
||||
if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } {
|
||||
set asyncqueue "null"
|
||||
${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue"
|
||||
} elseif { [dict exists $v "asyncqueue"] } {
|
||||
set asyncqueue [dict get $v "asyncqueue"]
|
||||
if { [string equal -nocase ${asyncqueue} "sct"] } {
|
||||
set IP [dict get $v ip]
|
||||
set PORT [dict get $v port]
|
||||
}
|
||||
} else {
|
||||
if { [dict exists $v "asyncprotocol"] } {
|
||||
set asyncprotocol [dict get $v "asyncprotocol"]
|
||||
} else {
|
||||
set asyncprotocol ${name}_protocol
|
||||
MakeAsyncProtocol ${asyncprotocol}
|
||||
if { [dict exists $v "terminator"] } {
|
||||
${asyncprotocol} sendterminator "[dict get $v "terminator"]"
|
||||
${asyncprotocol} replyterminator "[dict get $v "terminator"]"
|
||||
}
|
||||
}
|
||||
set asyncqueue ${name}_queue
|
||||
set IP [dict get $v ip]
|
||||
set PORT [dict get $v port]
|
||||
MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${IP} ${PORT}
|
||||
if { [dict exists $v "timeout"] } {
|
||||
${asyncqueue} timeout "[dict get $v "timeout"]"
|
||||
}
|
||||
}
|
||||
if { [string equal -nocase ${asyncqueue} "sct"] } {
|
||||
add_green_magnet_labview ${name} ${IP} ${PORT}
|
||||
} else {
|
||||
add_green_magnet_labview ${name} "aqadapter" ${asyncqueue}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
if { [info exists ::config_dict] } {
|
||||
::scobj::green_magnet_labview::read_config
|
||||
} else {
|
||||
::scobj::green_magnet_labview::sics_log 5 "No config dict"
|
||||
}
|
||||
Reference in New Issue
Block a user