add switch (on/off) in controlling data recording in log file

r3601 | jgn | 2012-06-14 11:28:03 +1000 (Thu, 14 Jun 2012) | 1 line
This commit is contained in:
Jing Chen
2012-06-14 11:28:03 +10:00
committed by Douglas Clowes
parent 9fa9bcf4f9
commit ca6ee7a191

View File

@@ -51,7 +51,7 @@ proc debug_log {args} {
namespace eval ::scobj::hv { namespace eval ::scobj::hv {
} }
proc ::scobj::hv:setting {field} { proc ::scobj::hv:setting {field basePath} {
set newPara [sct target] set newPara [sct target]
@@ -81,6 +81,15 @@ proc ::scobj::hv:setting {field} {
set comm "power down\r\n" set comm "power down\r\n"
} }
} }
"recording" {if {[string equal [string toupper [string trim $newPara " "]] "ON"]==1} {
hset $basePath/dataRecording "ON"
} elseif {[string equal [string toupper [string trim $newPara " "]] "OFF"]==1} {
hset $basePath/dataRecording "OFF"
} else {
error "ERROR: please enter 'on' or 'off' to set the switch"
}
return idle
}
default {error "ERROR: illegal input command, type help for more info" default {error "ERROR: illegal input command, type help for more info"
return idle return idle
} }
@@ -148,7 +157,10 @@ proc ::scobj::hv::rdHVStatusFunc {basePath mode} {
[lindex $replyText 5] [lindex $replyText 7] \ [lindex $replyText 5] [lindex $replyText 7] \
[lindex $replyText 28] [lindex $replyText 30] [lindex $replyText 32] [lindex $replyText 34] [lindex $replyText 36] [lindex $replyText 38] \ [lindex $replyText 28] [lindex $replyText 30] [lindex $replyText 32] [lindex $replyText 34] [lindex $replyText 36] [lindex $replyText 38] \
[lindex $replyText 4] [lindex $replyText 3]" [lindex $replyText 4] [lindex $replyText 3]"
debug_log $logdata
if {[string equal [hval $basePath/dataRecording] "ON"] == 1} {
debug_log $logdata
}
} elseif {$mode == "config"} { } elseif {$mode == "config"} {
hset $basePath/config/mode "[lindex $replyText 3] [lindex $replyText 4]" hset $basePath/config/mode "[lindex $replyText 3] [lindex $replyText 4]"
@@ -187,7 +199,10 @@ proc ::scobj::hv::mkHV {argList} {
sicslist setatt $pa(NAME) klass instrument sicslist setatt $pa(NAME) klass instrument
sicslist setatt $pa(NAME) long_name $pa(NAME) sicslist setatt $pa(NAME) long_name $pa(NAME)
hfactory /sics/$pa(NAME)/msg plain user text hfactory /sics/$pa(NAME)/msg plain user text
hfactory /sics/$pa(NAME)/dataRecording plain user text
hset /sics/$pa(NAME)/dataRecording "ON"
hfactory /sics/$pa(NAME)/status plain user none hfactory /sics/$pa(NAME)/status plain user none
hfactory /sics/$pa(NAME)/status/voltage plain user text hfactory /sics/$pa(NAME)/status/voltage plain user text
@@ -237,45 +252,49 @@ proc ::scobj::hv::mkHV {argList} {
hsetprop /sics/$pa(NAME) tuning $pa(TUNING) hsetprop /sics/$pa(NAME) tuning $pa(TUNING)
if {$pa(TUNING)} { if {$pa(TUNING)} {
hfactory /sics/$pa(NAME)/set_hv plain user int hfactory /sics/$pa(NAME)/set_hv plain user int
hfactory /sics/$pa(NAME)/set_pressure plain user int hfactory /sics/$pa(NAME)/set_pressure plain user int
hfactory /sics/$pa(NAME)/set_mode plain user text hfactory /sics/$pa(NAME)/set_mode plain user text
hfactory /sics/$pa(NAME)/set_date plain user text hfactory /sics/$pa(NAME)/set_date plain user text
hfactory /sics/$pa(NAME)/clear_error plain user text hfactory /sics/$pa(NAME)/clear_error plain user text
hfactory /sics/$pa(NAME)/set_PowerUp plain user text hfactory /sics/$pa(NAME)/set_PowerUp plain user text
hfactory /sics/$pa(NAME)/set_PowerDown plain user text hfactory /sics/$pa(NAME)/set_PowerDown plain user text
hfactory /sics/$pa(NAME)/set_dataRecording plain user text
::scobj::hinitprops $pa(NAME) set_hv set_pressure set_mode set_date ::scobj::hinitprops $pa(NAME) set_hv set_pressure set_mode set_date clear_error set_PowerUp set_PowerDown set_dataRecording
hsetprop /sics/$pa(NAME)/set_hv write ::scobj::hv:setting "voltage" hsetprop /sics/$pa(NAME)/set_hv write ::scobj::hv:setting "voltage" /sics/$pa(NAME)
hsetprop /sics/$pa(NAME)/set_hv checkReply ::scobj::hv::checkReplyFunc /sics/$pa(NAME) hsetprop /sics/$pa(NAME)/set_hv checkReply ::scobj::hv::checkReplyFunc /sics/$pa(NAME)
hsetprop /sics/$pa(NAME)/set_pressure write ::scobj::hv:setting "pressure" hsetprop /sics/$pa(NAME)/set_pressure write ::scobj::hv:setting "pressure" /sics/$pa(NAME)
hsetprop /sics/$pa(NAME)/set_pressure checkReply ::scobj::hv::checkReplyFunc /sics/$pa(NAME) hsetprop /sics/$pa(NAME)/set_pressure checkReply ::scobj::hv::checkReplyFunc /sics/$pa(NAME)
hsetprop /sics/$pa(NAME)/set_mode write ::scobj::hv:setting "mode" hsetprop /sics/$pa(NAME)/set_mode write ::scobj::hv:setting "mode" /sics/$pa(NAME)
hsetprop /sics/$pa(NAME)/set_mode checkReply ::scobj::hv::checkReplyFunc /sics/$pa(NAME) hsetprop /sics/$pa(NAME)/set_mode checkReply ::scobj::hv::checkReplyFunc /sics/$pa(NAME)
hsetprop /sics/$pa(NAME)/set_date write ::scobj::hv:setting "date" hsetprop /sics/$pa(NAME)/set_date write ::scobj::hv:setting "date" /sics/$pa(NAME)
hsetprop /sics/$pa(NAME)/set_date checkReply ::scobj::hv::checkReplyFunc /sics/$pa(NAME) hsetprop /sics/$pa(NAME)/set_date checkReply ::scobj::hv::checkReplyFunc /sics/$pa(NAME)
hsetprop /sics/$pa(NAME)/clear_error write ::scobj::hv:setting "clear" hsetprop /sics/$pa(NAME)/clear_error write ::scobj::hv:setting "clear" /sics/$pa(NAME)
hsetprop /sics/$pa(NAME)/clear_error checkReply ::scobj::hv::checkReplyFunc /sics/$pa(NAME) hsetprop /sics/$pa(NAME)/clear_error checkReply ::scobj::hv::checkReplyFunc /sics/$pa(NAME)
hsetprop /sics/$pa(NAME)/set_PowerUp write ::scobj::hv:setting "PowerUp" hsetprop /sics/$pa(NAME)/set_PowerUp write ::scobj::hv:setting "PowerUp" /sics/$pa(NAME)
hsetprop /sics/$pa(NAME)/set_PowerUp checkReply ::scobj::hv::checkReplyFunc /sics/$pa(NAME) hsetprop /sics/$pa(NAME)/set_PowerUp checkReply ::scobj::hv::checkReplyFunc /sics/$pa(NAME)
hsetprop /sics/$pa(NAME)/set_PowerDown write ::scobj::hv:setting "PowerDown" hsetprop /sics/$pa(NAME)/set_PowerDown write ::scobj::hv:setting "PowerDown" /sics/$pa(NAME)
hsetprop /sics/$pa(NAME)/set_PowerDown checkReply ::scobj::hv::checkReplyFunc /sics/$pa(NAME) hsetprop /sics/$pa(NAME)/set_PowerDown checkReply ::scobj::hv::checkReplyFunc /sics/$pa(NAME)
hsetprop /sics/$pa(NAME)/set_dataRecording write ::scobj::hv:setting "recording" /sics/$pa(NAME)
if {[SplitReply [environment_simulation]]=="false"} { if {[SplitReply [environment_simulation]]=="false"} {
sct_hv write /sics/$pa(NAME)/set_hv $pa(INTERVAL) sct_hv write /sics/$pa(NAME)/set_hv $pa(INTERVAL)
sct_hv write /sics/$pa(NAME)/set_pressure $pa(INTERVAL) sct_hv write /sics/$pa(NAME)/set_pressure $pa(INTERVAL)
sct_hv write /sics/$pa(NAME)/set_mode $pa(INTERVAL) sct_hv write /sics/$pa(NAME)/set_mode $pa(INTERVAL)
sct_hv write /sics/$pa(NAME)/set_date $pa(INTERVAL) sct_hv write /sics/$pa(NAME)/set_date $pa(INTERVAL)
sct_hv write /sics/$pa(NAME)/clear_error $pa(INTERVAL) sct_hv write /sics/$pa(NAME)/clear_error $pa(INTERVAL)
sct_hv write /sics/$pa(NAME)/set_PowerUp $pa(INTERVAL) sct_hv write /sics/$pa(NAME)/set_PowerUp $pa(INTERVAL)
sct_hv write /sics/$pa(NAME)/set_PowerDown $pa(INTERVAL) sct_hv write /sics/$pa(NAME)/set_PowerDown $pa(INTERVAL)
sct_hv write /sics/$pa(NAME)/set_dataRecording $pa(INTERVAL)
} }
} }
} }
@@ -330,6 +349,16 @@ proc hvHelp {} {
sct_hv send $cmd sct_hv send $cmd
} }
proc setDataRecord {args} {
switch $args {
"ON" {hset /sics/hv/dataRecording "ON"}
"on" {hset /sics/hv/dataRecording "ON"}
"OFF" {hset /sics/hv/dataRecording "OFF"}
"off" {hset /sics/hv/dataRecording "OFF"}
default {error "ERROR: please enter 'on' or 'off' to set the switch"}
}
}
publish hvGetStatus user publish hvGetStatus user
publish hvGetConfig user publish hvGetConfig user
publish hvClearError user publish hvClearError user
@@ -340,6 +369,7 @@ publish hvSetDate user
publish hvPowerUp user publish hvPowerUp user
publish hvPowerDown user publish hvPowerDown user
publish hvHelp user publish hvHelp user
publish setDataRecord user
# Main process call # Main process call
::scobj::hv::mkHV { ::scobj::hv::mkHV {