From 3b4247c8d28026852575f1d5c67923bd23d6ef14 Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Sun, 12 Feb 2012 18:55:07 +1100 Subject: [PATCH] Moved the pre_count and post_count procs to quokka's environment.tcl because their definition is specific to quokka. They have also been modified to include the lakeshore readings. r3364 | ffr | 2012-02-12 18:55:07 +1100 (Sun, 12 Feb 2012) | 4 lines --- .../magneticField/sct_oxford_labview.tcl | 87 +++++++++++-------- 1 file changed, 50 insertions(+), 37 deletions(-) diff --git a/site_ansto/instrument/config/environment/magneticField/sct_oxford_labview.tcl b/site_ansto/instrument/config/environment/magneticField/sct_oxford_labview.tcl index 7a058ee2..c73d7d26 100644 --- a/site_ansto/instrument/config/environment/magneticField/sct_oxford_labview.tcl +++ b/site_ansto/instrument/config/environment/magneticField/sct_oxford_labview.tcl @@ -23,8 +23,9 @@ # @param basePath, The object path, this is where we keep our state variables. proc debug_log {args} { - set fd [open "../log/magnetic.log" a] - puts $fd "[clock format [clock seconds] -format "%T"] $args" + set d1 [clock format [clock seconds] -format %d%h%Y] + set fd [open "../log/magnetic$d1.log" a] + puts $fd "[clock format [clock seconds] -format "%D %T"] $args" close $fd } @@ -43,7 +44,7 @@ proc ::scobj::magnetic::checkReplyFunc {basePath} { # set replyStr [sct result] #analysis the reply from the Oxford Device # if {[string first "Error" $replyStr] != -1} { -# broadcast "ERROR: Oxford Device cannot set the new target value, check again!!" +# broadcast "Error: Oxford Device cannot set the new target value, check again!!" # } return idle } @@ -61,18 +62,21 @@ proc ::scobj::magnetic::rqFieldFunc {} { # @brief Read and record the Magnetific Field value from the Oxford Device proc ::scobj::magnetic::rdFieldStateFunc {basePath} { set replyStr [sct result] - debug_log $replyStr - #broadcast "getF reply:$replyStr" + #broadcast "getF reply: $replyStr" if {[string first "Error" $replyStr] != -1} { - broadcast "ERROR: cannot get the Magnetific Field value from the Oxford Device, check again!" + broadcast "Error: cannot get the Magnetific Field value from the Oxford Labview server, check again!" + } elseif {[string first "failed" $replyStr] != -1} { + broadcast "Error: Connection to Oxford Labview server failed, check connection!" + } elseif {[string first "read timeout" $replyStr] != -1} { + broadcast "Error: read timeout on the connectiion to the Oxford Labview server" } else { + debug_log [expr $replyStr/10.0] hset $basePath/magneticField $replyStr } return idle } - # @brief Request a state report from the Oxford Device by sending a Magnetic Temperature request command proc ::scobj::magnetic::rqTempFunc {} { set comm "getT\r\n" @@ -87,7 +91,11 @@ proc ::scobj::magnetic::rdTempStateFunc {basePath} { debug_log $replyStr #broadcast "getT reply:$replyStr\n" if {[string first "Error" $replyStr] != -1} { - broadcast "ERROR: cannot get the Magnetific Temperature value from the Oxford Device, check again!" + broadcast "Error: cannot get the Magnetific Temperature value from the Oxford Labview server, check again!" + } elseif {[string first "failed" $replyStr] != -1} { + broadcast "Error: Connection to Oxford Labview server failed, check connection!" + } elseif {[string first "read timeout" $replyStr] != -1} { + broadcast "Error: read timeout on the connectiion to the Oxford Labview server" } else { set s1 [string trimright $replyStr "\n"] set s2 [split $s1 "=;"] @@ -100,7 +108,6 @@ proc ::scobj::magnetic::rdTempStateFunc {basePath} { return idle } - ## # @brief Make a Magnetic Controller # @@ -108,7 +115,7 @@ proc ::scobj::magnetic::rdTempStateFunc {basePath} { # # name: name of magnetic controller object # IP: IP address of RF generator moxa box -# PORT: Port number assigned to the generator on the moxa-box +# POT: Port number assigned to the generator on the moxa-box # tuning: boolean, set tuning=1 to allow instrument scientists to set the axe positions # interval: polling and ramping interval in seconds. @@ -120,7 +127,7 @@ proc ::scobj::magnetic::mkMagnetic {argList} { } MakeSICSObj $pa(NAME) SCT_OBJECT - sicslist setatt $pa(NAME) klass instrument + #sicslist setatt $pa(NAME) klass environment sicslist setatt $pa(NAME) long_name $pa(NAME) hfactory /sics/$pa(NAME)/field plain user float @@ -145,6 +152,30 @@ proc ::scobj::magnetic::mkMagnetic {argList} { hfactory /sics/$pa(NAME)/setRate plain user float hfactory /sics/$pa(NAME)/setTemp plain user float + # Initialise properties required for generating the API for GumTree and to save data + ::scobj::hinitprops $pa(NAME) start_magnetic end_magnetic magneticField + ::scobj::hinitprops $pa(NAME) start_temperature_s1 end_temperature_s1 Temp_s1 + ::scobj::hinitprops $pa(NAME) start_temperature_s2 end_temperature_s2 Temp_s2 + ::scobj::hinitprops $pa(NAME) start_temperature_s3 end_temperature_s3 Temp_s3 + + sicslist setatt $pa(NAME) klass environment + +# proc ::histogram_memory::pre_count "{fPath $pa(NAME)}" { +# hset /sics/$fPath/start_magnetic [hval /sics/$fPath/magneticField] + +# hset /sics/$fPath/start_temperature_s1 [hval /sics/$fPath/Temp_s1] +# hset /sics/$fPath/start_temperature_s2 [hval /sics/$fPath/Temp_s2] +# hset /sics/$fPath/start_temperature_s3 [hval /sics/$fPath/Temp_s3] +# } + +# proc ::histogram_memory::post_count "{fPath $pa(NAME)}" { +# hset /sics/$fPath/end_magnetic [hval /sics/$fPath/magneticField] + +# hset /sics/$fPath/end_temperature_s1 [hval /sics/$fPath/Temp_s1] +# hset /sics/$fPath/end_temperature_s2 [hval /sics/$fPath/Temp_s2] +# hset /sics/$fPath/end_temperature_s3 [hval /sics/$fPath/Temp_s3] +# } + #makesctcontroller sct_magnetic rfamp $pa(IP):$pa(PORT) makesctcontroller sct_magnetic std $pa(IP):$pa(PORT) @@ -154,40 +185,22 @@ proc ::scobj::magnetic::mkMagnetic {argList} { hsetprop /sics/$pa(NAME)/Temp read ::scobj::magnetic::rqTempFunc hsetprop /sics/$pa(NAME)/Temp rdTempState ::scobj::magnetic::rdTempStateFunc /sics/$pa(NAME) + if {[SplitReply [environment_simulation]]=="false"} { + sct_magnetic poll /sics/$pa(NAME)/field $pa(INTERVAL) + sct_magnetic poll /sics/$pa(NAME)/Temp $pa(INTERVAL) + } + hsetprop /sics/$pa(NAME) tuning $pa(TUNING) - # Initialise properties required for generating the API for GumTree and to save data - ::scobj::hinitprops $pa(NAME) start_magnetic end_magnetic magneticField - ::scobj::hinitprops $pa(NAME) start_temperature_s1 end_temperature_s1 Temp_s1 - ::scobj::hinitprops $pa(NAME) start_temperature_s2 end_temperature_s2 Temp_s2 - ::scobj::hinitprops $pa(NAME) start_temperature_s3 end_temperature_s3 Temp_s3 - - sct_magnetic poll /sics/$pa(NAME)/field $pa(INTERVAL) - sct_magnetic poll /sics/$pa(NAME)/Temp $pa(INTERVAL) - if {$pa(TUNING)} { hfactory /sics/$pa(NAME)/set_magneticField plain user float hsetprop /sics/$pa(NAME)/set_magneticField write ::scobj::magnetic::setting hsetprop /sics/$pa(NAME)/set_magneticField checkReply ::scobj::magnetic::checkReplyFunc /sics/$pa(NAME) - sct_magnetic write /sics/$pa(NAME)/set_magneticField $pa(INTERVAL) - } - - proc ::histogram_memory::pre_count {} { - hset /sics/$pa(NAME)/start_magnetic [hval /sics/$pa(NAME)/magneticField] - - hset /sics/$pa(NAME)/start_temperature_s1 [hval /sics/$pa(NAME)/Temp_s1] - hset /sics/$pa(NAME)/start_temperature_s2 [hval /sics/$pa(NAME)/Temp_s2] - hset /sics/$pa(NAME)/start_temperature_s3 [hval /sics/$pa(NAME)/Temp_s3] - } - - proc ::histogram_memory::post_count {} { - hset /sics/$pa(NAME)/end_magnetic [hval /sics/$pa(NAME)/magneticField] - - hset /sics/$pa(NAME)/end_temperature_s1 [hval /sics/$pa(NAME)/Temp_s1] - hset /sics/$pa(NAME)/end_temperature_s2 [hval /sics/$pa(NAME)/Temp_s2] - hset /sics/$pa(NAME)/end_temperature_s3 [hval /sics/$pa(NAME)/Temp_s3] + if {[SplitReply [environment_simulation]]=="false"} { + sct_magnetic write /sics/$pa(NAME)/set_magneticField + } } }