From 472ca4f9d9e4f980f527ad3086fca35961c51749 Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Sat, 23 Nov 2013 11:49:28 +1100 Subject: [PATCH] Updated from ics2-pelican. --- .../temperature/sct_lakeshore_218.tcl | 38 ++--- .../pelican/config/beamline/sct_power.tcl | 130 ++++++++---------- .../instrument/pelican/config/hmm/sct_hv.tcl | 41 +++--- 3 files changed, 103 insertions(+), 106 deletions(-) diff --git a/site_ansto/instrument/config/environment/temperature/sct_lakeshore_218.tcl b/site_ansto/instrument/config/environment/temperature/sct_lakeshore_218.tcl index 7565d2bb..181864ce 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_lakeshore_218.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_lakeshore_218.tcl @@ -78,11 +78,9 @@ proc ::scobj::ls218::rdValue {nodeName varName idx} { set replyData [string trimright [sct result] " \r\n"] if {[string first "ASCERR" $replyData] != -1} { - #broadcast "Error in LS218 Response: ASCERR:" sct geterror $replyData return -code error "Error in LS218 Response: $replyData" } elseif {[string length $replyData] < 1} { - #broadcast "Error in LS218 Response: no message returned from device" return -code error "Error in LS218: no message returned from device" } else { set fields [split $replyData ,] @@ -119,7 +117,6 @@ proc ::scobj::ls218::rdValue {nodeName varName idx} { } } "Celsius" { hset $nodeName [lindex $fields 0] - #append $logString " Celsius - $fields;" set curValue [lindex $fields 0] } "CurveHd" { hset $nodeName/curve [lindex $fields 0] @@ -193,33 +190,34 @@ proc ::scobj::ls218::rdValue {nodeName varName idx} { } } "mnmxValue" { hset $nodeName "[lindex $fields 0] , [lindex $fields 1]"} - "status" { hset $nodeName "" + "status" { # RDGST? chID Reads input status returns an integer with the following meaning # Bit Weighting StatusIndicator # 4 16 temp underrange # 5 32 temp overrange # 6 64 units under range # 7 128 untis over range - set curValue $fields set field [string trimleft $fields 0] if {[string length $field] == 0} { set field 0 - } - set stateString "" - set i [format %x $field] + } + + set str "" + set i [format %x $field] set i [expr 0x$i >> 4] set bitValue [expr 0x$i & 0x01] - if {$bitValue == 1} { append $stateString "temp underrange; " } + if {$bitValue == 1} { append str "temp underrange, " } set i [expr 0x$i >> 1] set bitValue [expr 0x$i & 0x01] - if {$bitValue == 1} { append $stateString "temp overrange; " } + if {$bitValue == 1} { append str "temp overrange, " } set i [expr 0x$i >> 1] set bitValue [expr 0x$i & 0x01] - if {$bitValue == 1} { append $stateString "units under range; " } + if {$bitValue == 1} { append str "units under range, " } set i [expr 0x$i >> 1] set bitValue [expr 0x$i & 0x01] - if {$bitValue == 1} { append $stateString "untis over range; " } - hset $nodeName $stateString + if {$bitValue == 1} { append str "untis over range" } + + hset $nodeName $str } "SensorUnitValue" { hset $nodeName $fields #append $logString " SensorUnitValue - $fields;" @@ -350,7 +348,7 @@ proc createNode {scobj_hpath idx sct_controller cmdGroup varName readable pollEn if {$pollEnabled == 1} { if {[SplitReply [environment_simulation]]=="false"} { # puts "enabling polling for $nodeName" - $sct_controller poll $nodeName + $sct_controller poll $nodeName 3 } } } message ]} { @@ -622,14 +620,16 @@ proc ::scobj::ls218::mkLS218 {argList} { # @internal time internal in polling the nodes # @return nothing (well, the sct object) +MakeAsyncProtocol std +MakeAsyncQueue ls218 std 137.157.202.214 4002 ::scobj::ls218::mkLS218 { name ls218 - IP 137.157.202.214 - PORT 4002 + IP aqadapter + PORT ls218 tuning 1 interval 5 - inputChan {1 2} - outputChan {} - relayChan {} + inputChan {1 2 3 4 5 6 7 8} + outputChan {1 2} + relayChan {1 2 3 4 5 6 7 8} } diff --git a/site_ansto/instrument/pelican/config/beamline/sct_power.tcl b/site_ansto/instrument/pelican/config/beamline/sct_power.tcl index e65e3dd0..02472022 100644 --- a/site_ansto/instrument/pelican/config/beamline/sct_power.tcl +++ b/site_ansto/instrument/pelican/config/beamline/sct_power.tcl @@ -62,7 +62,10 @@ proc ::scobj::ag1010::getValue {tc_root nextState rdPara} { set CTRL [lindex $rdPara 1] set DATA 0 set CRC 0 - + + if {[hpropexists [sct] geterror]} { + hdelprop [sct] geterror + } if {$LEN < 2} { return -code error "Error in LF AG1010 Setting: wrong data length provided." } elseif {$LEN > 2} { @@ -109,8 +112,9 @@ proc ::scobj::ag1010::setValue {tc_root nextState rdPara wrPara} { return idle } else { # scale W to dW - set FPL [expr int([hval $ns/limits/ForwardPower] * 10)] - set data [format %04x%04x%04x%04x $newPara $FPL 0 0] + set FPL [expr $newPara * 10] + set RPL [expr int([hval $ns/limits/ReversePower] * 10)] + set data [format %04x%04x%04x%04x $FPL $RPL 0 0] } } "RPL" { if {$newPara > $RefPowerLimit || $newPara < 0} { @@ -118,12 +122,17 @@ proc ::scobj::ag1010::setValue {tc_root nextState rdPara wrPara} { return idle } else { # scale W to dW - set RPL [expr int([hval $ns/limits/ReversePower] * 10)] - set data [format %04x%04x%04x%04x $RPL $newPara 0 0] + set FPL [expr int([hval $ns/limits/ForwardPower] * 10)] + set RPL [expr $newPara * 10] + set data [format %04x%04x%04x%04x $FPL $RPL 0 0] } } - "PAGC" { set data [expr [format %04x int($newPara * 10)]] } - "PMGC" { set data [expr [format %04x int($newPara * 10)]] } + "PAGC" { set newPara [expr $newPara * 10] + set data [format %04x $newPara] + } + "PMGC" { set newPara [expr $newPara * 10] + set data [format %04x $newPara] + } "FREQ" { if {$newPara<$FreqDownLimit || $newPara>$FreqUpLimit} { broadcast "Error: Freqence shall be set between $FreqDownLimit Hz and $FreqUpLimit Hz" return idle @@ -377,14 +386,11 @@ proc ::scobj::ag1010::rdValue {} { hset $ns/responseMsg "$data" #broadcast "rdValue : $data" - if {[string first "failed" $data] != -1} { - broadcast "Error in LF AG1010 Response: $data" - return -code error "$data" - } elseif {[string first "read timeout" $data] != -1} { - broadcast "Error in LF AG1010 Response: $data" + if {[string first "ASCERR" $data] != -1} { + sct geterror $replyData return -code error "$data" } elseif {[string length $data] < 1} { - broadcast "Error in LF AG1010 Response: no message returned from device" + #broadcast "Error in LF AG1010 Response: no message returned from device" return -code error "Error in LF AG1010 Response: no message returned from device" } @@ -405,7 +411,7 @@ proc ::scobj::ag1010::rdValue {} { 3 { set AGCPoH [string range $data 6 7] set AGCPoL [string range $data 8 9] # scale dW to W - hset $ns/AGC/PAGC [expr [[format %d [expr 0x$AGCPoH$AGCPoL]]/10.0] + hset $ns/AGC/PAGC [expr [format %d [expr 0x$AGCPoH$AGCPoL]]/10.0] } 4 { set MGCPoH [string range $data 6 7] set MGCPoL [string range $data 8 9] @@ -726,7 +732,7 @@ proc ::scobj::ag1010::mkAG {argList} { P AGC 1 0 1 1 none {} user {2 19} {rdValue} {} {} AGC PAGC 0 0 0 1 float {W} user {} {} {} {} P MGC 1 0 1 1 none {} user {2 20} {rdValue} {} {} - MGC PMGC 0 0 0 1 float {} user {} {} {} {} + MGC PMGC 0 0 0 1 float {%} user {} {} {} {} P FRE 1 0 1 1 none {} user {2 21} {rdValue} {} {} FRE FREQ 0 0 0 1 int {Hz} user {} {} {} {} P SKEY 1 0 1 1 none {} spy {3 23} {rdValue} {} {} @@ -774,7 +780,7 @@ proc ::scobj::ag1010::mkAG {argList} { P SetLimitsFPL 0 1 1 1 float {W} user {10 2} {rdValue} {FPL} {} P SetLimitsRPL 0 1 1 1 float {W} user {10 2} {rdValue} {RPL} {} P SetPAGC 0 1 1 1 float {W} user {4 3} {rdValue} {PAGC} {} - P SetPMGC 0 1 1 1 float {} user {4 4} {rdValue} {PMGC} {} + P SetPMGC 0 1 1 1 float {%} user {4 4} {rdValue} {PMGC} {} P SetFREQ 0 1 1 1 int {Hz} user {6 5} {rdValue} {FREQ} {} P SetSoftOn 0 1 1 1 int {} user {3 7} {rdValue} {SoftOn} {1,0} P SetKey1 0 1 1 1 int {} user {3 7} {rdValue} {Key1} {1,0} @@ -841,22 +847,22 @@ namespace import ::scobj::ag1010::par proc lf_pagc {{para ""} args} { if {$para == ""} { - broadcast "[hget /instrument/ag1010/AGC/PAGC] W" + broadcast "[hget /sample/ag1010/AGC/PAGC] W" } else { set HEAD 0x96 set LEN 4 set CTRL 3 set CRC 0 - set ns /instrument/ag1010 + set ns /sample/ag1010 set newPara [string trim $para " "] # scale W to dW - set newPara [expr int($newPara * 10)] + set newPara [expr $newPara * 10] set data [format %04x $newPara] set cmd [format %02x%02x%02x%s%02x $HEAD $LEN $CTRL $data $CRC] - broadcast "Set Power Level for AGC mode to $newPara W" + broadcast "Set Power Level for AGC mode to $newPara dW" sct_ag1010 send "$cmd" } } @@ -864,18 +870,18 @@ proc lf_pagc {{para ""} args} { proc lf_pmgc {{para ""} args} { if {$para == ""} { - broadcast "[hget /instrument/ag1010/MGC/PMGC]%" + broadcast "[hget /sample/ag1010/MGC/PMGC] %" } else { set HEAD 0x96 set LEN 4 set CTRL 4 set CRC 0 - set ns /instrument/ag1010 + set ns /sample/ag1010 set newPara [string trim $para " "] # scale by 10 - set newPara [expr int($newPara * 10)] + set newPara [expr $newPara * 10] set data [format %04x $newPara] set cmd [format %02x%02x%02x%s%02x $HEAD $LEN $CTRL $data $CRC] @@ -887,26 +893,15 @@ proc lf_pmgc {{para ""} args} { proc lf_freq {{para ""} args} { if {$para == ""} { - broadcast "[hget /instrument/ag1010/FRE/FREQ] Hz" + broadcast "[hget /sample/ag1010/FRE/FREQ] Hz" } else { - set HEAD 0x96 - set LEN 6 - set CTRL 5 - set CRC 0 - - set ns /instrument/ag1010 + set ns /sample/ag1010 set newPara [string trim $para " "] if {$para < 0.02 || $para > 2000000} { broadcast "Error: Freqence shall be set between 0.02 Hz and 2 MHz" } else { - set Freq [expr $newPara / 1000] - set FreqHz [expr $newPara % 1000] - set data [format %04x%04x $Freq $FreqHz] - set cmd [format %02x%02x%02x%s%02x $HEAD $LEN $CTRL $data $CRC] - - broadcast "Set Frequency to $newPara Hz" - sct_ag1010 send "$cmd" + hset $ns/SetFREQ $newPara } } } @@ -939,63 +934,60 @@ proc lf_sweep_run {startF stepF np {mode 2} args} { proc lf_limits {args} { if {$args == ""} { - broadcast "[hget /instrument/ag1010/limits/ForwardPower] W" - broadcast "[hget /instrument/ag1010/limits/ReversePower] W" + broadcast "[hget /sample/ag1010/limits/ForwardPower] W" + broadcast "[hget /sample/ag1010/limits/ReversePower] W" } else { set HEAD 0x96 set LEN 10 set CTRL 2 set CRC 0 - set ns /instrument/ag1010 + set ns /sample/ag1010 foreach {arg val} $args { switch $arg { "FPL" { if {$val > 10040 || $val < 0} { broadcast "Error: The Limit for the Forward Power is 0~10040 W" + set FPL [expr [hval $ns/limits/ForwardPower]*10] } else { - set FPL [hval $ns/limits/ForwardPower] # scale W to dW - set FPL [expr int($FPL * 10)] - set data [format %04x%04x%04x%04x $val $FPL 0 0] - set cmd [format %02x%02x%02x%s%02x $HEAD $LEN $CTRL $data $CRC] - - broadcast "Set Forward Power Limits to $val W" - sct_ag1010 send "$cmd" + set FPL [expr $val * 10] } } "RPL" { if {$val > 1630 || $val < 0} { broadcast "Error: The Limit for the Reflected Power is 0~1630 dW" + set RPL [expr [hval $ns/limits/ReversePower]*10] } else { - set RPL [hval $ns/limits/ReversePower] # scale W to dW - set RPL [expr int($RPL * 10)] - set data [format %04x%04x%04x%04x $RPL $val 0 0] - set cmd [format %02x%02x%02x%s%02x $HEAD $LEN $CTRL $data $CRC] - - broadcast "Set Reverse Power Limits to $val dW" - sct_ag1010 send "$cmd" + set RPL [expr $val * 10] } } - default { error "ERROR: $arg should be 'FPL' or 'RPL'" } + default { error "ERROR: $arg should be 'FPL' or 'RPL'" + return idle + } } } + broadcast "Set Forward Power Limits to $FPL dW" + broadcast "Set Reverse Power Limits to $RPL dW" + set data [format %04x%04x%04x%04x $FPL $RPL 0 0] + set cmd [format %02x%02x%02x%s%02x $HEAD $LEN $CTRL $data $CRC] + sct_ag1010 send "$cmd" } } proc lf_burst {args} { if {$args == ""} { - broadcast "[hget /instrument/ag1010/BurstPar/BurstMode]" - broadcast "[hget /instrument/ag1010/BurstPar/BRepTime] ms" - broadcast "[hget /instrument/ag1010/BurstPar/TimeOfPower] us" + broadcast "[hget /sample/ag1010/BurstPar/BurstMode]" + broadcast "[hget /sample/ag1010/BurstPar/BRepTime] ms" + broadcast "[hget /sample/ag1010/BurstPar/TimeOfPower] us" } else { set HEAD 0x96 set LEN 7 set CTRL 8 set CRC 0 - set ns /instrument/ag1010 + set ns /sample/ag1010 set BurstMode 2 set BRepTime [hval $ns/BurstPar/BRepTime] @@ -1039,17 +1031,17 @@ proc lf_burst {args} { proc lf_sweep {args} { if {$args == ""} { - broadcast "[hget /instrument/ag1010/SweepPar/SweepMode]" - broadcast "[hget /instrument/ag1010/SweepPar/StartFreq] Hz" - broadcast "[hget /instrument/ag1010/SweepPar/StepFreq] Hz" - broadcast "[hget /instrument/ag1010/SweepPar/SCyc]" + broadcast "[hget /sample/ag1010/SweepPar/SweepMode]" + broadcast "[hget /sample/ag1010/SweepPar/StartFreq] Hz" + broadcast "[hget /sample/ag1010/SweepPar/StepFreq] Hz" + broadcast "[hget /sample/ag1010/SweepPar/SCyc]" } else { set HEAD 0x96 set LEN 13 set CTRL 9 set CRC 0 - set ns /instrument/ag1010 + set ns /sample/ag1010 set SweepMode 2 set SStr [expr [hval $ns/SweepPar/StartFreq] / 1000] @@ -1102,9 +1094,9 @@ proc lf_sweep {args} { proc lf_meas {} { - broadcast "[hget /instrument/ag1010/MEAS/ForwardPower] W" - broadcast "[hget /instrument/ag1010/MEAS/ReversePower] W" - broadcast "[hget /instrument/ag1010/MEAS/Temperature] Degree" + broadcast "[hget /sample/ag1010/MEAS/ForwardPower] W" + broadcast "[hget /sample/ag1010/MEAS/ReversePower] W" + broadcast "[hget /sample/ag1010/MEAS/Temperature] Degree" } publish lf_limits user @@ -1126,8 +1118,8 @@ publish lf_sweep user # IP 137.157.202.219 ::scobj::ag1010::mkAG { name "ag1010" - IP 137.157.202.219 - PORT 4001 + IP 137.157.202.214 + PORT 4003 tuning 1 interval 5 } diff --git a/site_ansto/instrument/pelican/config/hmm/sct_hv.tcl b/site_ansto/instrument/pelican/config/hmm/sct_hv.tcl index 2c94b895..d312bad7 100644 --- a/site_ansto/instrument/pelican/config/hmm/sct_hv.tcl +++ b/site_ansto/instrument/pelican/config/hmm/sct_hv.tcl @@ -179,7 +179,9 @@ proc ::scobj::hv::rdHVStatusFunc {basePath mode} { } elseif {$mode == "config"} { hset $basePath/config/mode "[lindex $replyText 3] [lindex $replyText 4]" - hset $basePath/config/hv [lindex $replyText 5] + if {[lindex $replyText 5] != ""} { + hset $basePath/config/hv [lindex $replyText 5] + } hset $basePath/config/pressure_threshold [lindex $replyText 6] hsetprop $basePath/config/pressure_threshold units [lindex $replyText 7] @@ -329,17 +331,17 @@ proc ::scobj::hv::mkHV {argList} { proc hv_status {} { set cmd "get status\r\n" - sct_hv send $cmd + sct_hv transact $cmd } proc hv_config {} { set cmd "get config\r\n" - sct_hv send $cmd + sct_hv transact $cmd } proc hv_clear_error {} { set cmd "clear error\r\n" - sct_hv send $cmd + sct_hv transact $cmd } proc hv_vol {{vol ""} args} { @@ -347,7 +349,7 @@ proc hv_vol {{vol ""} args} { hget /instrument/hv/config/hv } else { set cmd "set hv=$vol\r\n" - sct_hv send $cmd + sct_hv transact $cmd } } @@ -356,7 +358,7 @@ proc hv_pressure {{pressure ""} args} { hget /instrument/hv/config/pressure_threshold } else { set cmd "set pressure=$pressure\r\n" - sct_hv send $cmd + sct_hv transact $cmd } } @@ -365,7 +367,7 @@ proc hv_mode {{mode ""} args} { hget /instrument/hv/config/mode } else { set cmd "set mode=$mode\r\n" - sct_hv send $cmd + sct_hv transact $cmd } } @@ -373,23 +375,23 @@ proc hv_date {{date ""} args} { if {$date == ""} { } else { set cmd "set date=$date\r\n" - sct_hv send $cmd + sct_hv transact $cmd } } proc hv_powerup {} { set cmd "power up\r\n" - sct_hv send $cmd + sct_hv transact $cmd } proc hv_powerdown {} { set cmd "power down\r\n" - sct_hv send $cmd + sct_hv transact $cmd } proc hv_help {} { set cmd "help\r\n" - sct_hv send $cmd + sct_hv transact $cmd } proc set_data_record {args} { @@ -414,14 +416,17 @@ publish hv_powerdown user publish hv_help user publish set_data_record user + +MakeAsyncProtocol std +MakeAsyncQueue hvport std 10.157.205.10 4001 # Main process call to create the driver -#::scobj::hv::mkHV { -# name "hv" -# IP 137.157.202.215 -# PORT 55011 -# tuning 1 -# interval 5 -#} +::scobj::hv::mkHV { + name "hv" + IP aqadapter + PORT hvport + tuning 1 + interval 5 +}