add Dlition Sample temperautre contorl
r3686 | jgn | 2012-08-01 09:50:08 +1000 (Wed, 01 Aug 2012) | 1 line
This commit is contained in:
committed by
Douglas Clowes
parent
cad63a8578
commit
a311f331cd
@@ -51,6 +51,32 @@ proc ::scobj::magnetic::checkReplyFunc {basePath} {
|
||||
|
||||
##
|
||||
|
||||
# @brief Request a state report from the Oxford Device by sending a current Temp Set Popint request command
|
||||
proc ::scobj::magnetic::rqTempSetPointFunc {} {
|
||||
set comm "getST\r\n"
|
||||
sct send $comm
|
||||
return rdTempSetPointState
|
||||
}
|
||||
|
||||
##
|
||||
# @brief Read and record the current temp Set Point from the Oxford Device
|
||||
proc ::scobj::magnetic::rdTempSetPointStateFunc {basePath} {
|
||||
set replyStr [sct result]
|
||||
#broadcast "Current temperature being set to : $replyStr"
|
||||
if {[string first "Error" $replyStr] != -1} {
|
||||
broadcast "Error: cannot get the temperature setpoint 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 {
|
||||
#broadcast "Current temperature being set to : $replyStr"
|
||||
hset $basePath/TempSetPoint $replyStr
|
||||
}
|
||||
|
||||
return idle
|
||||
}
|
||||
|
||||
# @brief Request a state report from the Oxford Device by sending a Magnetic Field request command
|
||||
proc ::scobj::magnetic::rqFieldFunc {} {
|
||||
set comm "getF\r\n"
|
||||
@@ -71,7 +97,6 @@ proc ::scobj::magnetic::rdFieldStateFunc {basePath} {
|
||||
broadcast "Error: read timeout on the connectiion to the Oxford Labview server"
|
||||
} else {
|
||||
debug_log "Magnetic Current: $replyStr"
|
||||
debug_log [expr $replyStr/10.0]
|
||||
hset $basePath/magneticField $replyStr
|
||||
}
|
||||
|
||||
@@ -109,16 +134,6 @@ proc ::scobj::magnetic::rdTempStateFunc {basePath} {
|
||||
return idle
|
||||
}
|
||||
|
||||
proc OxfordSetTemp {temp} {
|
||||
set NAME "magnetic"
|
||||
hset /sics/$NAME/TempSetTarget $temp
|
||||
|
||||
set comm "setT $temp\r\n"
|
||||
sct_magnetic send $comm
|
||||
}
|
||||
|
||||
publish OxfordSetTemp user
|
||||
|
||||
##
|
||||
# @brief Make a Magnetic Controller
|
||||
#
|
||||
@@ -151,6 +166,8 @@ proc ::scobj::magnetic::mkMagnetic {argList} {
|
||||
hfactory /sics/$pa(NAME)/Temp_s1 plain user float
|
||||
hfactory /sics/$pa(NAME)/Temp_s2 plain user float
|
||||
hfactory /sics/$pa(NAME)/Temp_s3 plain user float
|
||||
#hfactory /sics/$pa(NAME)/Set_Sensor_Temp user float
|
||||
#hfactory /sics/$pa(NAME)/Set_Sensor_Channel user int
|
||||
|
||||
hfactory /sics/$pa(NAME)/start_temperature_s1 plain user float
|
||||
hfactory /sics/$pa(NAME)/end_temperature_s1 plain user float
|
||||
@@ -163,33 +180,15 @@ proc ::scobj::magnetic::mkMagnetic {argList} {
|
||||
hfactory /sics/$pa(NAME)/setPoint plain user float
|
||||
hfactory /sics/$pa(NAME)/setRate plain user float
|
||||
|
||||
# Setting Temperature
|
||||
# Setting Temperature & initiate
|
||||
hfactory /sics/$pa(NAME)/TempSetTarget plain user float
|
||||
hfactory /sics/$pa(NAME)/TempSetPoint 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
|
||||
hset /sics/$pa(NAME)/magneticField 0
|
||||
hset /sics/$pa(NAME)/setPoint 0
|
||||
|
||||
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]
|
||||
# }
|
||||
hset /sics/$pa(NAME)/TempSetTarget 0
|
||||
hset /sics/$pa(NAME)/TempSetPoint 0
|
||||
|
||||
# Initialise properties required for generating the API for GumTree and to save data
|
||||
::scobj::hinitprops $pa(NAME) start_magnetic end_magnetic magneticField
|
||||
@@ -215,9 +214,11 @@ proc ::scobj::magnetic::mkMagnetic {argList} {
|
||||
# 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)
|
||||
|
||||
hsetprop /sics/$pa(NAME) read ::scobj::magnetic::rqTempSetPointFunc
|
||||
hsetprop /sics/$pa(NAME) rdTempSetPointState ::scobj::magnetic::rdTempSetPointStateFunc /sics/$pa(NAME)
|
||||
|
||||
hsetprop /sics/$pa(NAME)/field read ::scobj::magnetic::rqFieldFunc
|
||||
hsetprop /sics/$pa(NAME)/field rdFieldState ::scobj::magnetic::rdFieldStateFunc /sics/$pa(NAME)
|
||||
|
||||
@@ -225,6 +226,9 @@ proc ::scobj::magnetic::mkMagnetic {argList} {
|
||||
hsetprop /sics/$pa(NAME)/Temp rdTempState ::scobj::magnetic::rdTempStateFunc /sics/$pa(NAME)
|
||||
|
||||
if {[SplitReply [environment_simulation]]=="false"} {
|
||||
sct_magnetic poll /sics/$pa(NAME) 1
|
||||
#need to set interval to 1 if need to monitor magnetic value in Labview
|
||||
#sct_magnetic poll /sics/$pa(NAME)/field 1
|
||||
sct_magnetic poll /sics/$pa(NAME)/field $pa(INTERVAL)
|
||||
sct_magnetic poll /sics/$pa(NAME)/Temp $pa(INTERVAL)
|
||||
}
|
||||
@@ -244,6 +248,9 @@ proc ::scobj::magnetic::mkMagnetic {argList} {
|
||||
|
||||
}
|
||||
|
||||
# Set the magnetic field
|
||||
# command is : OxfordSetField fieldValue P ; where "P" is an optinal parameter and if set will change
|
||||
# to posistent mode after changig the magnetic field
|
||||
proc OxfordSetField {setPoint {mode ""} args} {
|
||||
set NAME "magnetic"
|
||||
hset /sics/$NAME/setPoint $setPoint
|
||||
@@ -256,9 +263,20 @@ proc OxfordSetField {setPoint {mode ""} args} {
|
||||
sct_magnetic send $comm
|
||||
} else {
|
||||
broadcast "Wrong parameters being provided, check!"
|
||||
return
|
||||
}
|
||||
|
||||
#set num 0
|
||||
#while { $num <= 40 && [expr abs([hval /sics/$NAME/setPoint] - [hval /sics/$NAME/magneticField]) ] >= 0.001 } {
|
||||
# broadcast "Magnetic field being set to [hval /sics/$NAME/magneticField] now ......"
|
||||
# after 500
|
||||
# set num [expr $num + 1]
|
||||
#}
|
||||
#broadcast "Done, Magnetic field set to [hval /sics/$NAME/magneticField]"
|
||||
}
|
||||
|
||||
# Assign the rate of the changing magnetic field;
|
||||
# This needs only to be set once unless required
|
||||
proc OxfordSetRate {setRate} {
|
||||
set NAME "magnetic"
|
||||
hset /sics/$NAME/setRate $setRate
|
||||
@@ -267,6 +285,40 @@ proc OxfordSetRate {setRate} {
|
||||
sct_magnetic send $comm
|
||||
}
|
||||
|
||||
# Change the Heliox temperature
|
||||
proc OxfordSetHTemp {temp} {
|
||||
set NAME "magnetic"
|
||||
hset /sics/$NAME/TempSetTarget $temp
|
||||
|
||||
set comm "setT $temp\r\n"
|
||||
sct_magnetic send $comm
|
||||
|
||||
#set num 0
|
||||
#while { $num <= 40 && [expr abs([hval /sics/$NAME/TempSetTarget] - [hval /sics/$NAME/TempSetPoint]) ] >= 0.001 } {
|
||||
# broadcast "Temperature being set to [hval /sics/$NAME/TempSetPoint] now ......"
|
||||
# after 500
|
||||
# set num [expr $num + 1]
|
||||
#}
|
||||
#broadcast "Done, Temperaure set to [hval /sics/$NAME/TempSetPoint]"
|
||||
}
|
||||
|
||||
# Set the Heater Switch to ON or OFF
|
||||
# Command: OxfordSetHS ON (turn on, goto non-persistent mode)
|
||||
# OxfordSetHS OFF (turn off, goto persistent mode)
|
||||
proc OxfordSetHS {mode} {
|
||||
if {[string equal $mode "ON"]!=1 && [string equal $mode "OFF"]!=1} {
|
||||
error "Error commmand, the corrent command should be : OxfordSetHS ON/OFF"
|
||||
return
|
||||
}
|
||||
|
||||
set comm "setHS $mode\r\n"
|
||||
sct_magnetic send $comm
|
||||
broadcast "Wait 60 seconds for the operation to complete before reset the mode"
|
||||
}
|
||||
|
||||
publish OxfordSetHTemp user
|
||||
publish OxfordSetField user
|
||||
publish OxfordSetRate user
|
||||
publish OxfordSetHS user
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user