Updated from ics2-pelican.

This commit is contained in:
Ferdi Franceschini
2013-11-23 11:49:28 +11:00
committed by Ferdi Franceschini
parent 7b814089ff
commit 472ca4f9d9
3 changed files with 103 additions and 106 deletions

View File

@@ -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
}