Merge branch 'RELEASE-3_1'

Conflicts:
	sics/site_ansto/instrument/bilby/config/chopper/sct_astrium_chopper.tcl
	sics/site_ansto/instrument/config/beamline/sct_he3_polanal.tcl
	sics/site_ansto/instrument/config/environment/isotech_ps.sct
	sics/site_ansto/instrument/config/environment/isotech_ps_sct.tcl
	sics/site_ansto/instrument/config/environment/temperature/julabo_lh45.sct
	sics/site_ansto/instrument/config/environment/temperature/julabo_lh45_gen_sct.tcl
	sics/site_ansto/instrument/config/environment/temperature/ls340_sct.tcl
	sics/site_ansto/instrument/util/gen_sct.py
This commit is contained in:
Douglas Clowes
2014-11-13 13:52:46 +11:00
18 changed files with 678 additions and 307 deletions

View File

@@ -10,9 +10,12 @@ proc ::scobj::bruker::debug_log {tc_root debug_level debug_string} {
set catch_status [ catch {
set debug_threshold [hgetpropval ${tc_root} debug_threshold]
if {${debug_level} >= ${debug_threshold}} {
set fd [open "../log/bruker_[basename ${tc_root}].log" "a"]
set line "[clock format [clock seconds] -format "%T"] ${debug_string}"
puts ${fd} "${line}"
set now [clock seconds]
set ts [clock format ${now} -format "%Y%m%d"]
set log_file_name "../log/bruker_[basename ${tc_root}]_${ts}.log"
set fd [open "${log_file_name}" "a"]
set ts [clock format ${now} -format "%T"]
puts ${fd} "${ts} ${debug_string}"
close ${fd}
}
} catch_message ]
@@ -51,7 +54,9 @@ proc ::scobj::bruker::add_driver {name device_class simulation_flag ip_address t
makesctcontroller sct_${name} astvelsel ${ip_address}:${tcp_port}
}
} else {
::scobj::bruker::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for bruker"
::scobj::bruker::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for bruker"
::scobj::bruker::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL"
makesctcontroller sct_${name} aqadapter NULL
}
::scobj::bruker::sics_log 1 "::scobj::bruker::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${tol}"
::scobj::bruker::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${tol}
@@ -69,7 +74,7 @@ namespace eval ::scobj::bruker {
proc add_bruker {name ip_address tcp_port id datype {tol 0.1}} {
set simulation_flag "[string tolower [SplitReply [environment_simulation]]]"
::scobj::bruker::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${id}" "${datype}" "${{tol}" "${0.1}}"
::scobj::bruker::add_driver ${name} "environment" ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${tol}
}
clientput "file evaluation of sct_bruker.tcl"
@@ -108,20 +113,31 @@ proc ::scobj::bruker::read_config {} {
if { ![string equal -nocase "${simulation_flag}" "false"] } {
set asyncqueue "null"
${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue"
${ns}::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL"
makesctcontroller sct_${name} aqadapter NULL
} elseif { [dict exists $v "asyncqueue"] } {
set asyncqueue [dict get $v "asyncqueue"]
if { [string equal -nocase ${asyncqueue} "sct"] } {
set ip_address [dict get $v ip]
set tcp_port [dict get $v port]
}
makesctcontroller sct_${name} astvelsel ${ip_address}:${tcp_port}
} else {
makesctcontroller sct_${name} aqadapter ${asyncqueue}
}
} else {
if { [dict exists $v "asyncprotocol"] } {
set asyncprotocol [dict get $v "asyncprotocol"]
} else {
set asyncprotocol ${name}_protocol
MakeAsyncProtocol ${asyncprotocol}
if { [dict exists $v "terminator"] } {
if { [dict exists $v "sendterminator"] } {
${asyncprotocol} sendterminator "[dict get $v "sendterminator"]"
} elseif { [dict exists $v "terminator"] } {
${asyncprotocol} sendterminator "[dict get $v "terminator"]"
}
if { [dict exists $v "replyterminator"] } {
${asyncprotocol} replyterminator "[dict get $v "replyterminator"]"
} elseif { [dict exists $v "terminator"] } {
${asyncprotocol} replyterminator "[dict get $v "terminator"]"
}
}
@@ -132,6 +148,7 @@ proc ::scobj::bruker::read_config {} {
if { [dict exists $v "timeout"] } {
${asyncqueue} timeout "[dict get $v "timeout"]"
}
makesctcontroller sct_${name} aqadapter ${asyncqueue}
}
set arg_list [list]
set missing_list [list]
@@ -148,11 +165,7 @@ proc ::scobj::bruker::read_config {} {
if { [llength $missing_list] > 0 } {
error "$name is missing configuration values $missing_list"
}
if { [string equal -nocase ${asyncqueue} "sct"] } {
${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list
} else {
${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list
}
${ns}::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list
}
}
}

View File

@@ -10,9 +10,12 @@ proc ::scobj::knauer_pump::debug_log {tc_root debug_level debug_string} {
set catch_status [ catch {
set debug_threshold [hgetpropval ${tc_root} debug_threshold]
if {${debug_level} >= ${debug_threshold}} {
set fd [open "../log/knauer_pump_[basename ${tc_root}].log" "a"]
set line "[clock format [clock seconds] -format "%T"] ${debug_string}"
puts ${fd} "${line}"
set now [clock seconds]
set ts [clock format ${now} -format "%Y%m%d"]
set log_file_name "../log/knauer_pump_[basename ${tc_root}]_${ts}.log"
set fd [open "${log_file_name}" "a"]
set ts [clock format ${now} -format "%T"]
puts ${fd} "${ts} ${debug_string}"
close ${fd}
}
} catch_message ]
@@ -583,7 +586,12 @@ proc ::scobj::knauer_pump::volume_checkstatus {tc_root} {
# volume_checkstatus hook code goes here
if {[sct driving]} {
set sp "[sct target]"
set pv "[hval ${tc_root}/[sct driveable]]"
if {[hpropexists [sct] simulated] && [sct simulated] == "true"} {
set pv "${sp}"
hupdateif ${tc_root}/[sct driveable] ${sp}
} else {
set pv "[hval ${tc_root}/[sct driveable]]"
}
if { abs(${pv} - ${sp}) <= [sct tolerance] } {
if { [hpropexists [sct] settle_time] } {
if { [hpropexists [sct] settle_time_start] } {
@@ -881,9 +889,6 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio
set scobj_hpath /sics/${name}
hfactory ${scobj_hpath}/dummy plain spy none
hsetprop ${scobj_hpath}/dummy data "false"
hsetprop ${scobj_hpath}/dummy klass "@none"
hsetprop ${scobj_hpath}/dummy type "part"
hfactory ${scobj_hpath}/dummy/glp plain user text
hsetprop ${scobj_hpath}/dummy/glp read ${ns}::getValue ${scobj_hpath} read_glp {GLP?}
@@ -898,6 +903,14 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio
hsetprop ${scobj_hpath}/dummy/glp type "part"
hsetprop ${scobj_hpath}/dummy/glp nxalias "${name}_dummy_glp"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/dummy/glp 1
hsetprop ${scobj_hpath}/dummy/glp simulated false
} else {
::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for knauer_pump"
hsetprop ${scobj_hpath}/dummy/glp simulated true
}
hfactory ${scobj_hpath}/dummy/status plain user text
hsetprop ${scobj_hpath}/dummy/status read ${ns}::getValue ${scobj_hpath} read_status {STATUS?}
hsetprop ${scobj_hpath}/dummy/status read_status ${ns}::read_status ${scobj_hpath}
@@ -912,16 +925,17 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio
hsetprop ${scobj_hpath}/dummy/status nxalias "${name}_dummy_status"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/dummy/glp 1
${sct_controller} poll ${scobj_hpath}/dummy/status 1
hsetprop ${scobj_hpath}/dummy/status simulated false
} else {
::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for knauer_pump"
hsetprop ${scobj_hpath}/dummy/status simulated true
}
hsetprop ${scobj_hpath}/dummy data "false"
hsetprop ${scobj_hpath}/dummy klass "@none"
hsetprop ${scobj_hpath}/dummy type "part"
hfactory ${scobj_hpath}/pump plain spy none
hsetprop ${scobj_hpath}/pump data "true"
hsetprop ${scobj_hpath}/pump klass "@none"
hsetprop ${scobj_hpath}/pump type "part"
hfactory ${scobj_hpath}/pump/remote plain user int
hsetprop ${scobj_hpath}/pump/remote read ${ns}::getValue ${scobj_hpath} remote_read {REMOTE?}
@@ -940,6 +954,15 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio
hsetprop ${scobj_hpath}/pump/remote type "part"
hsetprop ${scobj_hpath}/pump/remote nxalias "${name}_pump_remote"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/pump/remote 1
${sct_controller} write ${scobj_hpath}/pump/remote
hsetprop ${scobj_hpath}/pump/remote simulated false
} else {
::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for knauer_pump"
hsetprop ${scobj_hpath}/pump/remote simulated true
}
hfactory ${scobj_hpath}/pump/state plain user text
hsetprop ${scobj_hpath}/pump/state read ${ns}::state_fetch ${scobj_hpath} rdValue { }
hsetprop ${scobj_hpath}/pump/state rdValue ${ns}::rdValue ${scobj_hpath}
@@ -953,6 +976,14 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio
hsetprop ${scobj_hpath}/pump/state type "part"
hsetprop ${scobj_hpath}/pump/state nxalias "${name}_pump_state"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/pump/state 1
hsetprop ${scobj_hpath}/pump/state simulated false
} else {
::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for knauer_pump"
hsetprop ${scobj_hpath}/pump/state simulated true
}
hfactory ${scobj_hpath}/pump/status plain user text
hsetprop ${scobj_hpath}/pump/status read ${ns}::status_fetch ${scobj_hpath} rdValue { }
hsetprop ${scobj_hpath}/pump/status rdValue ${ns}::rdValue ${scobj_hpath}
@@ -967,18 +998,17 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio
hsetprop ${scobj_hpath}/pump/status nxalias "${name}_pump_status"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/pump/remote 1
${sct_controller} poll ${scobj_hpath}/pump/state 1
${sct_controller} poll ${scobj_hpath}/pump/status 1
${sct_controller} write ${scobj_hpath}/pump/remote
hsetprop ${scobj_hpath}/pump/status simulated false
} else {
::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for knauer_pump"
hsetprop ${scobj_hpath}/pump/status simulated true
}
hsetprop ${scobj_hpath}/pump data "true"
hsetprop ${scobj_hpath}/pump klass "@none"
hsetprop ${scobj_hpath}/pump type "part"
hfactory ${scobj_hpath}/pump/flow plain spy none
hsetprop ${scobj_hpath}/pump/flow data "true"
hsetprop ${scobj_hpath}/pump/flow klass "@none"
hsetprop ${scobj_hpath}/pump/flow type "part"
hfactory ${scobj_hpath}/pump/flow/pval plain user float
hsetprop ${scobj_hpath}/pump/flow/pval read ${ns}::flow_fetch ${scobj_hpath} rdValue { }
@@ -994,6 +1024,14 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio
hsetprop ${scobj_hpath}/pump/flow/pval units "mL/min"
hsetprop ${scobj_hpath}/pump/flow/pval nxalias "${name}_pump_flow_pval"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/pump/flow/pval 1
hsetprop ${scobj_hpath}/pump/flow/pval simulated false
} else {
::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for knauer_pump"
hsetprop ${scobj_hpath}/pump/flow/pval simulated true
}
hfactory ${scobj_hpath}/pump/flow/setp plain user float
hsetprop ${scobj_hpath}/pump/flow/setp write ${ns}::flow_write ${scobj_hpath} noResponse { }
hsetprop ${scobj_hpath}/pump/flow/setp noResponse ${ns}::noResponse ${scobj_hpath}
@@ -1013,16 +1051,17 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio
hsetprop ${scobj_hpath}/pump/flow/setp nxalias "${name}_pump_flow_setp"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/pump/flow/pval 1
${sct_controller} write ${scobj_hpath}/pump/flow/setp
hsetprop ${scobj_hpath}/pump/flow/setp simulated false
} else {
::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for knauer_pump"
hsetprop ${scobj_hpath}/pump/flow/setp simulated true
}
hsetprop ${scobj_hpath}/pump/flow data "true"
hsetprop ${scobj_hpath}/pump/flow klass "@none"
hsetprop ${scobj_hpath}/pump/flow type "part"
hfactory ${scobj_hpath}/pump/ratio plain spy none
hsetprop ${scobj_hpath}/pump/ratio data "true"
hsetprop ${scobj_hpath}/pump/ratio klass "@none"
hsetprop ${scobj_hpath}/pump/ratio type "part"
hfactory ${scobj_hpath}/pump/ratio/pval plain user text
hsetprop ${scobj_hpath}/pump/ratio/pval read ${ns}::ratio_fetch ${scobj_hpath} rdValue { }
@@ -1038,6 +1077,14 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio
hsetprop ${scobj_hpath}/pump/ratio/pval units "percent"
hsetprop ${scobj_hpath}/pump/ratio/pval nxalias "${name}_pump_ratio_pval"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/pump/ratio/pval 1
hsetprop ${scobj_hpath}/pump/ratio/pval simulated false
} else {
::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for knauer_pump"
hsetprop ${scobj_hpath}/pump/ratio/pval simulated true
}
hfactory ${scobj_hpath}/pump/ratio/setp plain user text
hsetprop ${scobj_hpath}/pump/ratio/setp write ${ns}::ratio_write ${scobj_hpath} noResponse { }
hsetprop ${scobj_hpath}/pump/ratio/setp noResponse ${ns}::noResponse ${scobj_hpath}
@@ -1055,16 +1102,17 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio
hsetprop ${scobj_hpath}/pump/ratio/setp nxalias "${name}_pump_ratio_setp"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/pump/ratio/pval 1
${sct_controller} write ${scobj_hpath}/pump/ratio/setp
hsetprop ${scobj_hpath}/pump/ratio/setp simulated false
} else {
::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for knauer_pump"
hsetprop ${scobj_hpath}/pump/ratio/setp simulated true
}
hsetprop ${scobj_hpath}/pump/ratio data "true"
hsetprop ${scobj_hpath}/pump/ratio klass "@none"
hsetprop ${scobj_hpath}/pump/ratio type "part"
hfactory ${scobj_hpath}/pump/volume plain spy none
hsetprop ${scobj_hpath}/pump/volume data "true"
hsetprop ${scobj_hpath}/pump/volume klass "@none"
hsetprop ${scobj_hpath}/pump/volume type "part"
hfactory ${scobj_hpath}/pump/volume/pval plain user float
hsetprop ${scobj_hpath}/pump/volume/pval read ${ns}::volume_fetch ${scobj_hpath} volume_read { }
@@ -1080,6 +1128,14 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio
hsetprop ${scobj_hpath}/pump/volume/pval units "mL"
hsetprop ${scobj_hpath}/pump/volume/pval nxalias "${name}_pump_volume_pval"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/pump/volume/pval 1
hsetprop ${scobj_hpath}/pump/volume/pval simulated false
} else {
::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for knauer_pump"
hsetprop ${scobj_hpath}/pump/volume/pval simulated true
}
hfactory ${scobj_hpath}/pump/volume/setp plain user float
hsetprop ${scobj_hpath}/pump/volume/setp read ${ns}::volume_fsm ${scobj_hpath} volume_store { }
hsetprop ${scobj_hpath}/pump/volume/setp volume_store ${ns}::volume_store ${scobj_hpath}
@@ -1107,18 +1163,20 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio
hsetprop ${scobj_hpath}/pump/volume/setp nxalias "${name}_pump_volume_setp"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/pump/volume/pval 1
${sct_controller} poll ${scobj_hpath}/pump/volume/setp 1
${sct_controller} write ${scobj_hpath}/pump/volume/setp
hsetprop ${scobj_hpath}/pump/volume/setp simulated false
} else {
::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for knauer_pump"
hsetprop ${scobj_hpath}/pump/volume/setp simulated true
}
hsetprop ${scobj_hpath}/pump/volume data "true"
hsetprop ${scobj_hpath}/pump/volume klass "@none"
hsetprop ${scobj_hpath}/pump/volume type "part"
ansto_makesctdrive ${name}_pump_volume_setp ${scobj_hpath}/pump/volume/setp ${scobj_hpath}/pump/volume/pval ${sct_controller}
hsetprop ${scobj_hpath} klass ${device_class}
hsetprop ${scobj_hpath} data true
hsetprop ${scobj_hpath} debug_threshold 0
if {[string equal -nocase "${simulation_flag}" "false"]} {
ansto_makesctdrive ${name}_pump_volume_setp ${scobj_hpath}/pump/volume/setp ${scobj_hpath}/pump/volume/pval ${sct_controller}
}
# mkDriver hook code starts
#hset ${scobj_hpath}/pump/remote 1
# mkDriver hook code ends
@@ -1138,7 +1196,9 @@ proc ::scobj::knauer_pump::add_driver {name device_class simulation_flag ip_addr
makesctcontroller sct_${name} knauer_ap ${ip_address}:${tcp_port}
}
} else {
::scobj::knauer_pump::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for knauer_pump"
::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for knauer_pump"
::scobj::knauer_pump::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL"
makesctcontroller sct_${name} aqadapter NULL
}
::scobj::knauer_pump::sics_log 1 "::scobj::knauer_pump::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}"
::scobj::knauer_pump::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}
@@ -1156,7 +1216,7 @@ namespace eval ::scobj::knauer_pump {
proc add_knauer_pump {name ip_address tcp_port} {
set simulation_flag "[string tolower [SplitReply [environment_simulation]]]"
::scobj::knauer_pump::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port}
::scobj::knauer_pump::add_driver ${name} "environment" ${simulation_flag} ${ip_address} ${tcp_port}
}
clientput "file evaluation of sct_knauer_pump.tcl"
@@ -1195,20 +1255,31 @@ proc ::scobj::knauer_pump::read_config {} {
if { ![string equal -nocase "${simulation_flag}" "false"] } {
set asyncqueue "null"
${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue"
${ns}::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL"
makesctcontroller sct_${name} aqadapter NULL
} elseif { [dict exists $v "asyncqueue"] } {
set asyncqueue [dict get $v "asyncqueue"]
if { [string equal -nocase ${asyncqueue} "sct"] } {
set ip_address [dict get $v ip]
set tcp_port [dict get $v port]
}
makesctcontroller sct_${name} knauer_ap ${ip_address}:${tcp_port}
} else {
makesctcontroller sct_${name} aqadapter ${asyncqueue}
}
} else {
if { [dict exists $v "asyncprotocol"] } {
set asyncprotocol [dict get $v "asyncprotocol"]
} else {
set asyncprotocol ${name}_protocol
MakeAsyncProtocol ${asyncprotocol}
if { [dict exists $v "terminator"] } {
if { [dict exists $v "sendterminator"] } {
${asyncprotocol} sendterminator "[dict get $v "sendterminator"]"
} elseif { [dict exists $v "terminator"] } {
${asyncprotocol} sendterminator "[dict get $v "terminator"]"
}
if { [dict exists $v "replyterminator"] } {
${asyncprotocol} replyterminator "[dict get $v "replyterminator"]"
} elseif { [dict exists $v "terminator"] } {
${asyncprotocol} replyterminator "[dict get $v "terminator"]"
}
}
@@ -1219,12 +1290,9 @@ proc ::scobj::knauer_pump::read_config {} {
if { [dict exists $v "timeout"] } {
${asyncqueue} timeout "[dict get $v "timeout"]"
}
makesctcontroller sct_${name} aqadapter ${asyncqueue}
}
if { [string equal -nocase ${asyncqueue} "sct"] } {
${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}
} else {
${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue}
}
${ns}::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}
}
}
}

View File

@@ -10,9 +10,12 @@ proc ::scobj::mvp_valve::debug_log {tc_root debug_level debug_string} {
set catch_status [ catch {
set debug_threshold [hgetpropval ${tc_root} debug_threshold]
if {${debug_level} >= ${debug_threshold}} {
set fd [open "../log/mvp_valve_[basename ${tc_root}].log" "a"]
set line "[clock format [clock seconds] -format "%T"] ${debug_string}"
puts ${fd} "${line}"
set now [clock seconds]
set ts [clock format ${now} -format "%Y%m%d"]
set log_file_name "../log/mvp_valve_[basename ${tc_root}]_${ts}.log"
set fd [open "${log_file_name}" "a"]
set ts [clock format ${now} -format "%T"]
puts ${fd} "${ts} ${debug_string}"
close ${fd}
}
} catch_message ]
@@ -59,7 +62,7 @@ namespace eval ::scobj::mvp_valve {
proc add_mvp_valve {name ip_address tcp_port id datype} {
set simulation_flag "[string tolower [SplitReply [environment_simulation]]]"
::scobj::mvp_valve::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${id}" "${datype}"
::scobj::mvp_valve::add_driver ${name} "environment" ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype}
}
clientput "file evaluation of sct_mvp_valve.tcl"
@@ -95,34 +98,7 @@ proc ::scobj::mvp_valve::read_config {} {
continue
}
if { [string equal -nocase [dict get $v "driver"] "mvp_valve"] } {
if { ![string equal -nocase "${simulation_flag}" "false"] } {
set asyncqueue "null"
${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue"
} elseif { [dict exists $v "asyncqueue"] } {
set asyncqueue [dict get $v "asyncqueue"]
if { [string equal -nocase ${asyncqueue} "sct"] } {
set ip_address [dict get $v ip]
set tcp_port [dict get $v port]
}
} else {
if { [dict exists $v "asyncprotocol"] } {
set asyncprotocol [dict get $v "asyncprotocol"]
} else {
set asyncprotocol ${name}_protocol
MakeAsyncProtocol ${asyncprotocol}
if { [dict exists $v "terminator"] } {
${asyncprotocol} sendterminator "[dict get $v "terminator"]"
${asyncprotocol} replyterminator "[dict get $v "terminator"]"
}
}
set asyncqueue ${name}_queue
set ip_address [dict get $v ip]
set tcp_port [dict get $v port]
MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${ip_address} ${tcp_port}
if { [dict exists $v "timeout"] } {
${asyncqueue} timeout "[dict get $v "timeout"]"
}
}
::scobj::mvp_valve::sics_log 9 "No sctcontroller for mvp_valve"
set arg_list [list]
set missing_list [list]
foreach arg {id datype} {
@@ -138,11 +114,7 @@ proc ::scobj::mvp_valve::read_config {} {
if { [llength $missing_list] > 0 } {
error "$name is missing configuration values $missing_list"
}
if { [string equal -nocase ${asyncqueue} "sct"] } {
${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list
} else {
${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list
}
${ns}::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list
}
}
}

View File

@@ -10,9 +10,12 @@ proc ::scobj::syringe_pump::debug_log {tc_root debug_level debug_string} {
set catch_status [ catch {
set debug_threshold [hgetpropval ${tc_root} debug_threshold]
if {${debug_level} >= ${debug_threshold}} {
set fd [open "../log/syringe_pump_[basename ${tc_root}].log" "a"]
set line "[clock format [clock seconds] -format "%T"] ${debug_string}"
puts ${fd} "${line}"
set now [clock seconds]
set ts [clock format ${now} -format "%Y%m%d"]
set log_file_name "../log/syringe_pump_[basename ${tc_root}]_${ts}.log"
set fd [open "${log_file_name}" "a"]
set ts [clock format ${now} -format "%T"]
puts ${fd} "${ts} ${debug_string}"
close ${fd}
}
} catch_message ]
@@ -51,7 +54,9 @@ proc ::scobj::syringe_pump::add_driver {name device_class simulation_flag ip_add
makesctcontroller sct_${name} syringe ${ip_address}:${tcp_port}
}
} else {
::scobj::syringe_pump::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for syringe_pump"
::scobj::syringe_pump::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for syringe_pump"
::scobj::syringe_pump::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL"
makesctcontroller sct_${name} aqadapter NULL
}
::scobj::syringe_pump::sics_log 1 "::scobj::syringe_pump::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype}"
::scobj::syringe_pump::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype}
@@ -69,7 +74,7 @@ namespace eval ::scobj::syringe_pump {
proc add_syringe_pump {name ip_address tcp_port id datype} {
set simulation_flag "[string tolower [SplitReply [environment_simulation]]]"
::scobj::syringe_pump::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${id}" "${datype}"
::scobj::syringe_pump::add_driver ${name} "environment" ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype}
}
clientput "file evaluation of sct_syringe_pump.tcl"
@@ -108,20 +113,31 @@ proc ::scobj::syringe_pump::read_config {} {
if { ![string equal -nocase "${simulation_flag}" "false"] } {
set asyncqueue "null"
${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue"
${ns}::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL"
makesctcontroller sct_${name} aqadapter NULL
} elseif { [dict exists $v "asyncqueue"] } {
set asyncqueue [dict get $v "asyncqueue"]
if { [string equal -nocase ${asyncqueue} "sct"] } {
set ip_address [dict get $v ip]
set tcp_port [dict get $v port]
}
makesctcontroller sct_${name} syringe ${ip_address}:${tcp_port}
} else {
makesctcontroller sct_${name} aqadapter ${asyncqueue}
}
} else {
if { [dict exists $v "asyncprotocol"] } {
set asyncprotocol [dict get $v "asyncprotocol"]
} else {
set asyncprotocol ${name}_protocol
MakeAsyncProtocol ${asyncprotocol}
if { [dict exists $v "terminator"] } {
if { [dict exists $v "sendterminator"] } {
${asyncprotocol} sendterminator "[dict get $v "sendterminator"]"
} elseif { [dict exists $v "terminator"] } {
${asyncprotocol} sendterminator "[dict get $v "terminator"]"
}
if { [dict exists $v "replyterminator"] } {
${asyncprotocol} replyterminator "[dict get $v "replyterminator"]"
} elseif { [dict exists $v "terminator"] } {
${asyncprotocol} replyterminator "[dict get $v "terminator"]"
}
}
@@ -132,6 +148,7 @@ proc ::scobj::syringe_pump::read_config {} {
if { [dict exists $v "timeout"] } {
${asyncqueue} timeout "[dict get $v "timeout"]"
}
makesctcontroller sct_${name} aqadapter ${asyncqueue}
}
set arg_list [list]
set missing_list [list]
@@ -148,11 +165,7 @@ proc ::scobj::syringe_pump::read_config {} {
if { [llength $missing_list] > 0 } {
error "$name is missing configuration values $missing_list"
}
if { [string equal -nocase ${asyncqueue} "sct"] } {
${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list
} else {
${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list
}
${ns}::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list
}
}
}

View File

@@ -3,8 +3,8 @@ driver eurotherm_3200 = {
protocol = modbus_ap;
class = environment;
simulation_group = environment_simulation;
add_args = 'id datype dev_id tol';
make_args = 'id datype dev_id tol';
add_args = 'id datype dev_id {tol 5 } {lowerlimit 0} {upperlimit 500}';
make_args = 'id datype dev_id {tol 5} {lowerlimit 0} {upperlimit 500}';
group util = {
data = false; control = false; nxsave = false; mutable = false;
@@ -17,7 +17,7 @@ driver eurotherm_3200 = {
var sensor = { read_command = '1'; permlink = 'T.S01'; };
writeable = 1;
var setpoint = { read_command = '2'; write_command = '2'; permlink = 'T.SP01';
driveable = loop1/sensor; lowerlimit = 0; upperlimit =40; tolerance = '${tol}';
driveable = loop1/sensor; lowerlimit = '${lowerlimit}'; upperlimit = '${upperlimit}'; tolerance = '${tol}';
};
}
group loop1_extra = {

View File

@@ -10,9 +10,12 @@ proc ::scobj::eurotherm_3200::debug_log {tc_root debug_level debug_string} {
set catch_status [ catch {
set debug_threshold [hgetpropval ${tc_root} debug_threshold]
if {${debug_level} >= ${debug_threshold}} {
set fd [open "../log/eurotherm_3200_[basename ${tc_root}].log" "a"]
set line "[clock format [clock seconds] -format "%T"] ${debug_string}"
puts ${fd} "${line}"
set now [clock seconds]
set ts [clock format ${now} -format "%Y%m%d"]
set log_file_name "../log/eurotherm_3200_[basename ${tc_root}]_${ts}.log"
set fd [open "${log_file_name}" "a"]
set ts [clock format ${now} -format "%T"]
puts ${fd} "${ts} ${debug_string}"
close ${fd}
}
} catch_message ]
@@ -86,7 +89,12 @@ proc ::scobj::eurotherm_3200::checkstatus {tc_root} {
# checkstatus hook code goes here
if {[sct driving]} {
set sp "[sct target]"
set pv "[hval ${tc_root}/[sct driveable]]"
if {[hpropexists [sct] simulated] && [sct simulated] == "true"} {
set pv "${sp}"
hupdateif ${tc_root}/[sct driveable] ${sp}
} else {
set pv "[hval ${tc_root}/[sct driveable]]"
}
if { abs(${pv} - ${sp}) <= [sct tolerance] } {
if { [hpropexists [sct] settle_time] } {
if { [hpropexists [sct] settle_time_start] } {
@@ -224,8 +232,8 @@ proc ::scobj::eurotherm_3200::setValue {tc_root nextState cmd_str} {
handle_exception ${catch_status} ${catch_message}
}
proc ::scobj::eurotherm_3200::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id datype dev_id tol } {
::scobj::eurotherm_3200::sics_log 9 "::scobj::eurotherm_3200::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}"
proc ::scobj::eurotherm_3200::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id datype dev_id {tol 5} {lowerlimit 0} {upperlimit 500} } {
::scobj::eurotherm_3200::sics_log 9 "::scobj::eurotherm_3200::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol} ${lowerlimit} ${upperlimit}"
set ns "[namespace current]"
set catch_status [ catch {
@@ -237,9 +245,6 @@ proc ::scobj::eurotherm_3200::mkDriver { sct_controller name device_class simula
set scobj_hpath /sics/${name}
hfactory ${scobj_hpath}/loop1 plain spy none
hsetprop ${scobj_hpath}/loop1 data "true"
hsetprop ${scobj_hpath}/loop1 klass "@none"
hsetprop ${scobj_hpath}/loop1 type "part"
hfactory ${scobj_hpath}/loop1/sensor plain user float
hsetprop ${scobj_hpath}/loop1/sensor read ${ns}::getValue ${scobj_hpath} rdValue {1}
@@ -256,6 +261,14 @@ proc ::scobj::eurotherm_3200::mkDriver { sct_controller name device_class simula
hsetprop ${scobj_hpath}/loop1/sensor type "part"
hsetprop ${scobj_hpath}/loop1/sensor nxalias "${name}_loop1_sensor"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/loop1/sensor 1
hsetprop ${scobj_hpath}/loop1/sensor simulated false
} else {
::scobj::eurotherm_3200::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for eurotherm_3200"
hsetprop ${scobj_hpath}/loop1/sensor simulated true
}
hfactory ${scobj_hpath}/loop1/setpoint plain user float
hsetprop ${scobj_hpath}/loop1/setpoint read ${ns}::getValue ${scobj_hpath} rdValue {2}
hsetprop ${scobj_hpath}/loop1/setpoint rdValue ${ns}::rdValue ${scobj_hpath}
@@ -271,8 +284,8 @@ proc ::scobj::eurotherm_3200::mkDriver { sct_controller name device_class simula
hsetprop ${scobj_hpath}/loop1/setpoint data true
hsetprop ${scobj_hpath}/loop1/setpoint mutable true
hsetprop ${scobj_hpath}/loop1/setpoint nxsave true
hsetprop ${scobj_hpath}/loop1/setpoint lowerlimit 0
hsetprop ${scobj_hpath}/loop1/setpoint upperlimit 40
hsetprop ${scobj_hpath}/loop1/setpoint lowerlimit ${lowerlimit}
hsetprop ${scobj_hpath}/loop1/setpoint upperlimit ${upperlimit}
hsetprop ${scobj_hpath}/loop1/setpoint tolerance ${tol}
hsetprop ${scobj_hpath}/loop1/setpoint permlink data_set "T[format "%02d" ${id}]SP01"
hsetprop ${scobj_hpath}/loop1/setpoint @description "T[format "%02d" ${id}]SP01"
@@ -283,17 +296,19 @@ proc ::scobj::eurotherm_3200::mkDriver { sct_controller name device_class simula
hsetprop ${scobj_hpath}/loop1/setpoint nxalias "${name}_loop1_setpoint"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/loop1/sensor 1
${sct_controller} poll ${scobj_hpath}/loop1/setpoint 1
${sct_controller} write ${scobj_hpath}/loop1/setpoint
hsetprop ${scobj_hpath}/loop1/setpoint simulated false
} else {
::scobj::eurotherm_3200::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for eurotherm_3200"
hsetprop ${scobj_hpath}/loop1/setpoint simulated true
}
hsetprop ${scobj_hpath}/loop1 data "true"
hsetprop ${scobj_hpath}/loop1 klass "@none"
hsetprop ${scobj_hpath}/loop1 type "part"
ansto_makesctdrive ${name}_loop1_setpoint ${scobj_hpath}/loop1/setpoint ${scobj_hpath}/loop1/sensor ${sct_controller}
hfactory ${scobj_hpath}/loop1_extra plain spy none
hsetprop ${scobj_hpath}/loop1_extra data "false"
hsetprop ${scobj_hpath}/loop1_extra klass "@none"
hsetprop ${scobj_hpath}/loop1_extra type "part"
hfactory ${scobj_hpath}/loop1_extra/active_setpoint plain user float
hsetprop ${scobj_hpath}/loop1_extra/active_setpoint read ${ns}::getValue ${scobj_hpath} rdValue {15}
@@ -307,6 +322,14 @@ proc ::scobj::eurotherm_3200::mkDriver { sct_controller name device_class simula
hsetprop ${scobj_hpath}/loop1_extra/active_setpoint type "part"
hsetprop ${scobj_hpath}/loop1_extra/active_setpoint nxalias "${name}_loop1_extra_active_setpoint"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/loop1_extra/active_setpoint 1
hsetprop ${scobj_hpath}/loop1_extra/active_setpoint simulated false
} else {
::scobj::eurotherm_3200::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for eurotherm_3200"
hsetprop ${scobj_hpath}/loop1_extra/active_setpoint simulated true
}
hfactory ${scobj_hpath}/loop1_extra/alarm1_thresh plain user float
hsetprop ${scobj_hpath}/loop1_extra/alarm1_thresh read ${ns}::getValue ${scobj_hpath} rdValue {13}
hsetprop ${scobj_hpath}/loop1_extra/alarm1_thresh rdValue ${ns}::rdValue ${scobj_hpath}
@@ -322,6 +345,15 @@ proc ::scobj::eurotherm_3200::mkDriver { sct_controller name device_class simula
hsetprop ${scobj_hpath}/loop1_extra/alarm1_thresh type "part"
hsetprop ${scobj_hpath}/loop1_extra/alarm1_thresh nxalias "${name}_loop1_extra_alarm1_thresh"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/loop1_extra/alarm1_thresh 1
${sct_controller} write ${scobj_hpath}/loop1_extra/alarm1_thresh
hsetprop ${scobj_hpath}/loop1_extra/alarm1_thresh simulated false
} else {
::scobj::eurotherm_3200::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for eurotherm_3200"
hsetprop ${scobj_hpath}/loop1_extra/alarm1_thresh simulated true
}
hfactory ${scobj_hpath}/loop1_extra/alarm2_thresh plain user float
hsetprop ${scobj_hpath}/loop1_extra/alarm2_thresh read ${ns}::getValue ${scobj_hpath} rdValue {14}
hsetprop ${scobj_hpath}/loop1_extra/alarm2_thresh rdValue ${ns}::rdValue ${scobj_hpath}
@@ -337,6 +369,15 @@ proc ::scobj::eurotherm_3200::mkDriver { sct_controller name device_class simula
hsetprop ${scobj_hpath}/loop1_extra/alarm2_thresh type "part"
hsetprop ${scobj_hpath}/loop1_extra/alarm2_thresh nxalias "${name}_loop1_extra_alarm2_thresh"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/loop1_extra/alarm2_thresh 1
${sct_controller} write ${scobj_hpath}/loop1_extra/alarm2_thresh
hsetprop ${scobj_hpath}/loop1_extra/alarm2_thresh simulated false
} else {
::scobj::eurotherm_3200::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for eurotherm_3200"
hsetprop ${scobj_hpath}/loop1_extra/alarm2_thresh simulated true
}
hfactory ${scobj_hpath}/loop1_extra/manual_output plain user float
hsetprop ${scobj_hpath}/loop1_extra/manual_output read ${ns}::getValue ${scobj_hpath} rdValue {3}
hsetprop ${scobj_hpath}/loop1_extra/manual_output rdValue ${ns}::rdValue ${scobj_hpath}
@@ -349,6 +390,14 @@ proc ::scobj::eurotherm_3200::mkDriver { sct_controller name device_class simula
hsetprop ${scobj_hpath}/loop1_extra/manual_output type "part"
hsetprop ${scobj_hpath}/loop1_extra/manual_output nxalias "${name}_loop1_extra_manual_output"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/loop1_extra/manual_output 1
hsetprop ${scobj_hpath}/loop1_extra/manual_output simulated false
} else {
::scobj::eurotherm_3200::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for eurotherm_3200"
hsetprop ${scobj_hpath}/loop1_extra/manual_output simulated true
}
hfactory ${scobj_hpath}/loop1_extra/power_limit_high plain user float
hsetprop ${scobj_hpath}/loop1_extra/power_limit_high read ${ns}::getValue ${scobj_hpath} rdValue {30}
hsetprop ${scobj_hpath}/loop1_extra/power_limit_high rdValue ${ns}::rdValue ${scobj_hpath}
@@ -364,6 +413,15 @@ proc ::scobj::eurotherm_3200::mkDriver { sct_controller name device_class simula
hsetprop ${scobj_hpath}/loop1_extra/power_limit_high type "part"
hsetprop ${scobj_hpath}/loop1_extra/power_limit_high nxalias "${name}_loop1_extra_power_limit_high"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/loop1_extra/power_limit_high 1
${sct_controller} write ${scobj_hpath}/loop1_extra/power_limit_high
hsetprop ${scobj_hpath}/loop1_extra/power_limit_high simulated false
} else {
::scobj::eurotherm_3200::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for eurotherm_3200"
hsetprop ${scobj_hpath}/loop1_extra/power_limit_high simulated true
}
hfactory ${scobj_hpath}/loop1_extra/power_limit_low plain user float
hsetprop ${scobj_hpath}/loop1_extra/power_limit_low read ${ns}::getValue ${scobj_hpath} rdValue {31}
hsetprop ${scobj_hpath}/loop1_extra/power_limit_low rdValue ${ns}::rdValue ${scobj_hpath}
@@ -379,6 +437,15 @@ proc ::scobj::eurotherm_3200::mkDriver { sct_controller name device_class simula
hsetprop ${scobj_hpath}/loop1_extra/power_limit_low type "part"
hsetprop ${scobj_hpath}/loop1_extra/power_limit_low nxalias "${name}_loop1_extra_power_limit_low"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/loop1_extra/power_limit_low 1
${sct_controller} write ${scobj_hpath}/loop1_extra/power_limit_low
hsetprop ${scobj_hpath}/loop1_extra/power_limit_low simulated false
} else {
::scobj::eurotherm_3200::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for eurotherm_3200"
hsetprop ${scobj_hpath}/loop1_extra/power_limit_low simulated true
}
hfactory ${scobj_hpath}/loop1_extra/power_slew_rate plain user float
hsetprop ${scobj_hpath}/loop1_extra/power_slew_rate read ${ns}::getValue ${scobj_hpath} rdValue {37}
hsetprop ${scobj_hpath}/loop1_extra/power_slew_rate rdValue ${ns}::rdValue ${scobj_hpath}
@@ -394,6 +461,15 @@ proc ::scobj::eurotherm_3200::mkDriver { sct_controller name device_class simula
hsetprop ${scobj_hpath}/loop1_extra/power_slew_rate type "part"
hsetprop ${scobj_hpath}/loop1_extra/power_slew_rate nxalias "${name}_loop1_extra_power_slew_rate"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/loop1_extra/power_slew_rate 1
${sct_controller} write ${scobj_hpath}/loop1_extra/power_slew_rate
hsetprop ${scobj_hpath}/loop1_extra/power_slew_rate simulated false
} else {
::scobj::eurotherm_3200::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for eurotherm_3200"
hsetprop ${scobj_hpath}/loop1_extra/power_slew_rate simulated true
}
hfactory ${scobj_hpath}/loop1_extra/setpoint_slew_rate plain user float
hsetprop ${scobj_hpath}/loop1_extra/setpoint_slew_rate read ${ns}::getValue ${scobj_hpath} rdValue {35}
hsetprop ${scobj_hpath}/loop1_extra/setpoint_slew_rate rdValue ${ns}::rdValue ${scobj_hpath}
@@ -409,6 +485,15 @@ proc ::scobj::eurotherm_3200::mkDriver { sct_controller name device_class simula
hsetprop ${scobj_hpath}/loop1_extra/setpoint_slew_rate type "part"
hsetprop ${scobj_hpath}/loop1_extra/setpoint_slew_rate nxalias "${name}_loop1_extra_setpoint_slew_rate"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/loop1_extra/setpoint_slew_rate 1
${sct_controller} write ${scobj_hpath}/loop1_extra/setpoint_slew_rate
hsetprop ${scobj_hpath}/loop1_extra/setpoint_slew_rate simulated false
} else {
::scobj::eurotherm_3200::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for eurotherm_3200"
hsetprop ${scobj_hpath}/loop1_extra/setpoint_slew_rate simulated true
}
hfactory ${scobj_hpath}/loop1_extra/working_output plain user float
hsetprop ${scobj_hpath}/loop1_extra/working_output read ${ns}::getValue ${scobj_hpath} rdValue {4}
hsetprop ${scobj_hpath}/loop1_extra/working_output rdValue ${ns}::rdValue ${scobj_hpath}
@@ -421,6 +506,14 @@ proc ::scobj::eurotherm_3200::mkDriver { sct_controller name device_class simula
hsetprop ${scobj_hpath}/loop1_extra/working_output type "part"
hsetprop ${scobj_hpath}/loop1_extra/working_output nxalias "${name}_loop1_extra_working_output"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/loop1_extra/working_output 1
hsetprop ${scobj_hpath}/loop1_extra/working_output simulated false
} else {
::scobj::eurotherm_3200::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for eurotherm_3200"
hsetprop ${scobj_hpath}/loop1_extra/working_output simulated true
}
hfactory ${scobj_hpath}/loop1_extra/working_setpoint plain user float
hsetprop ${scobj_hpath}/loop1_extra/working_setpoint read ${ns}::getValue ${scobj_hpath} rdValue {5}
hsetprop ${scobj_hpath}/loop1_extra/working_setpoint rdValue ${ns}::rdValue ${scobj_hpath}
@@ -434,30 +527,17 @@ proc ::scobj::eurotherm_3200::mkDriver { sct_controller name device_class simula
hsetprop ${scobj_hpath}/loop1_extra/working_setpoint nxalias "${name}_loop1_extra_working_setpoint"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/loop1_extra/active_setpoint 1
${sct_controller} poll ${scobj_hpath}/loop1_extra/alarm1_thresh 1
${sct_controller} poll ${scobj_hpath}/loop1_extra/alarm2_thresh 1
${sct_controller} poll ${scobj_hpath}/loop1_extra/manual_output 1
${sct_controller} poll ${scobj_hpath}/loop1_extra/power_limit_high 1
${sct_controller} poll ${scobj_hpath}/loop1_extra/power_limit_low 1
${sct_controller} poll ${scobj_hpath}/loop1_extra/power_slew_rate 1
${sct_controller} poll ${scobj_hpath}/loop1_extra/setpoint_slew_rate 1
${sct_controller} poll ${scobj_hpath}/loop1_extra/working_output 1
${sct_controller} poll ${scobj_hpath}/loop1_extra/working_setpoint 1
${sct_controller} write ${scobj_hpath}/loop1_extra/alarm1_thresh
${sct_controller} write ${scobj_hpath}/loop1_extra/alarm2_thresh
${sct_controller} write ${scobj_hpath}/loop1_extra/power_limit_high
${sct_controller} write ${scobj_hpath}/loop1_extra/power_limit_low
${sct_controller} write ${scobj_hpath}/loop1_extra/power_slew_rate
${sct_controller} write ${scobj_hpath}/loop1_extra/setpoint_slew_rate
hsetprop ${scobj_hpath}/loop1_extra/working_setpoint simulated false
} else {
::scobj::eurotherm_3200::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for eurotherm_3200"
hsetprop ${scobj_hpath}/loop1_extra/working_setpoint simulated true
}
hsetprop ${scobj_hpath}/loop1_extra data "false"
hsetprop ${scobj_hpath}/loop1_extra klass "@none"
hsetprop ${scobj_hpath}/loop1_extra type "part"
hfactory ${scobj_hpath}/util plain spy none
hsetprop ${scobj_hpath}/util data "false"
hsetprop ${scobj_hpath}/util klass "@none"
hsetprop ${scobj_hpath}/util type "part"
hfactory ${scobj_hpath}/util/mode plain user text
hsetprop ${scobj_hpath}/util/mode control false
@@ -481,20 +561,20 @@ proc ::scobj::eurotherm_3200::mkDriver { sct_controller name device_class simula
hsetprop ${scobj_hpath}/util/unit sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/util/unit type "part"
hsetprop ${scobj_hpath}/util/unit nxalias "${name}_util_unit"
hsetprop ${scobj_hpath}/util data "false"
hsetprop ${scobj_hpath}/util klass "@none"
hsetprop ${scobj_hpath}/util type "part"
hsetprop ${scobj_hpath} klass ${device_class}
hsetprop ${scobj_hpath} data true
hsetprop ${scobj_hpath} debug_threshold 5
if {[string equal -nocase "${simulation_flag}" "false"]} {
ansto_makesctdrive ${name}_loop1_setpoint ${scobj_hpath}/loop1/setpoint ${scobj_hpath}/loop1/sensor ${sct_controller}
}
# mkDriver hook code goes here
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
proc ::scobj::eurotherm_3200::add_driver {name device_class simulation_flag ip_address tcp_port id datype dev_id tol} {
proc ::scobj::eurotherm_3200::add_driver {name device_class simulation_flag ip_address tcp_port id datype dev_id {tol 5 } {lowerlimit 0} {upperlimit 500}} {
set catch_status [ catch {
::scobj::eurotherm_3200::sics_log 9 "::scobj::eurotherm_3200::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}"
::scobj::eurotherm_3200::sics_log 9 "::scobj::eurotherm_3200::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol} ${lowerlimit} ${upperlimit}"
if {[string equal -nocase "${simulation_flag}" "false"]} {
if {[string equal -nocase "aqadapter" "${ip_address}"]} {
::scobj::eurotherm_3200::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}"
@@ -504,10 +584,12 @@ proc ::scobj::eurotherm_3200::add_driver {name device_class simulation_flag ip_a
makesctcontroller sct_${name} modbus_ap ${ip_address}:${tcp_port}
}
} else {
::scobj::eurotherm_3200::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for eurotherm_3200"
::scobj::eurotherm_3200::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for eurotherm_3200"
::scobj::eurotherm_3200::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL"
makesctcontroller sct_${name} aqadapter NULL
}
::scobj::eurotherm_3200::sics_log 1 "::scobj::eurotherm_3200::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}"
::scobj::eurotherm_3200::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}
::scobj::eurotherm_3200::sics_log 1 "::scobj::eurotherm_3200::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol} ${lowerlimit} ${upperlimit}"
::scobj::eurotherm_3200::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol} ${lowerlimit} ${upperlimit}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
@@ -520,9 +602,9 @@ namespace eval ::scobj::eurotherm_3200 {
namespace export add_driver
}
proc add_eurotherm_3200 {name ip_address tcp_port id datype dev_id tol} {
proc add_eurotherm_3200 {name ip_address tcp_port id datype dev_id {tol 5 } {lowerlimit 0} {upperlimit 500}} {
set simulation_flag "[string tolower [SplitReply [environment_simulation]]]"
::scobj::eurotherm_3200::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${id}" "${datype}" "${dev_id}" "${tol}"
::scobj::eurotherm_3200::add_driver ${name} "environment" ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol} ${lowerlimit} ${upperlimit}
}
clientput "file evaluation of sct_eurotherm_3200.tcl"
@@ -561,20 +643,31 @@ proc ::scobj::eurotherm_3200::read_config {} {
if { ![string equal -nocase "${simulation_flag}" "false"] } {
set asyncqueue "null"
${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue"
${ns}::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL"
makesctcontroller sct_${name} aqadapter NULL
} elseif { [dict exists $v "asyncqueue"] } {
set asyncqueue [dict get $v "asyncqueue"]
if { [string equal -nocase ${asyncqueue} "sct"] } {
set ip_address [dict get $v ip]
set tcp_port [dict get $v port]
}
makesctcontroller sct_${name} modbus_ap ${ip_address}:${tcp_port}
} else {
makesctcontroller sct_${name} aqadapter ${asyncqueue}
}
} else {
if { [dict exists $v "asyncprotocol"] } {
set asyncprotocol [dict get $v "asyncprotocol"]
} else {
set asyncprotocol ${name}_protocol
MakeAsyncProtocol ${asyncprotocol}
if { [dict exists $v "terminator"] } {
if { [dict exists $v "sendterminator"] } {
${asyncprotocol} sendterminator "[dict get $v "sendterminator"]"
} elseif { [dict exists $v "terminator"] } {
${asyncprotocol} sendterminator "[dict get $v "terminator"]"
}
if { [dict exists $v "replyterminator"] } {
${asyncprotocol} replyterminator "[dict get $v "replyterminator"]"
} elseif { [dict exists $v "terminator"] } {
${asyncprotocol} replyterminator "[dict get $v "terminator"]"
}
}
@@ -585,14 +678,19 @@ proc ::scobj::eurotherm_3200::read_config {} {
if { [dict exists $v "timeout"] } {
${asyncqueue} timeout "[dict get $v "timeout"]"
}
makesctcontroller sct_${name} aqadapter ${asyncqueue}
}
set arg_list [list]
set missing_list [list]
foreach arg {id datype dev_id tol} {
array unset default_map
array set default_map [list tol 5 lowerlimit 0 upperlimit 500]
foreach arg {id datype dev_id tol lowerlimit upperlimit} {
if {[dict exists $u $arg]} {
lappend arg_list "[dict get $u $arg]"
} elseif {[dict exists $v $arg]} {
lappend arg_list "[dict get $v $arg]"
} elseif {[info exists default_map($arg)]} {
lappend arg_list $default_map($arg)
} else {
${ns}::sics_log 9 "Missing configuration value $arg"
lappend missing_list $arg
@@ -601,11 +699,7 @@ proc ::scobj::eurotherm_3200::read_config {} {
if { [llength $missing_list] > 0 } {
error "$name is missing configuration values $missing_list"
}
if { [string equal -nocase ${asyncqueue} "sct"] } {
${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list
} else {
${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list
}
${ns}::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list
}
}
}

View File

@@ -10,9 +10,12 @@ proc ::scobj::srs_sr630::debug_log {tc_root debug_level debug_string} {
set catch_status [ catch {
set debug_threshold [hgetpropval ${tc_root} debug_threshold]
if {${debug_level} >= ${debug_threshold}} {
set fd [open "../log/srs_sr630_[basename ${tc_root}].log" "a"]
set line "[clock format [clock seconds] -format "%T"] ${debug_string}"
puts ${fd} "${line}"
set now [clock seconds]
set ts [clock format ${now} -format "%Y%m%d"]
set log_file_name "../log/srs_sr630_[basename ${tc_root}]_${ts}.log"
set fd [open "${log_file_name}" "a"]
set ts [clock format ${now} -format "%T"]
puts ${fd} "${ts} ${debug_string}"
close ${fd}
}
} catch_message ]
@@ -217,6 +220,14 @@ proc ::scobj::srs_sr630::mkDriver { sct_controller name device_class simulation_
hsetprop ${scobj_hpath}/id type "part"
hsetprop ${scobj_hpath}/id nxalias "${name}_id"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/id 600
hsetprop ${scobj_hpath}/id simulated false
} else {
::scobj::srs_sr630::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for srs_sr630"
hsetprop ${scobj_hpath}/id simulated true
}
hfactory ${scobj_hpath}/sensor_01 plain user float
hsetprop ${scobj_hpath}/sensor_01 read ${ns}::getSensor ${scobj_hpath} readSensor {1}
hsetprop ${scobj_hpath}/sensor_01 readSensor ${ns}::readSensor ${scobj_hpath}
@@ -230,6 +241,14 @@ proc ::scobj::srs_sr630::mkDriver { sct_controller name device_class simulation_
hsetprop ${scobj_hpath}/sensor_01 type "part"
hsetprop ${scobj_hpath}/sensor_01 nxalias "${name}_sensor_01"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/sensor_01 60
hsetprop ${scobj_hpath}/sensor_01 simulated false
} else {
::scobj::srs_sr630::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for srs_sr630"
hsetprop ${scobj_hpath}/sensor_01 simulated true
}
hfactory ${scobj_hpath}/sensor_02 plain user float
hsetprop ${scobj_hpath}/sensor_02 read ${ns}::getSensor ${scobj_hpath} readSensor {2}
hsetprop ${scobj_hpath}/sensor_02 readSensor ${ns}::readSensor ${scobj_hpath}
@@ -243,6 +262,14 @@ proc ::scobj::srs_sr630::mkDriver { sct_controller name device_class simulation_
hsetprop ${scobj_hpath}/sensor_02 type "part"
hsetprop ${scobj_hpath}/sensor_02 nxalias "${name}_sensor_02"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/sensor_02 600
hsetprop ${scobj_hpath}/sensor_02 simulated false
} else {
::scobj::srs_sr630::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for srs_sr630"
hsetprop ${scobj_hpath}/sensor_02 simulated true
}
hfactory ${scobj_hpath}/sensor_03 plain user float
hsetprop ${scobj_hpath}/sensor_03 read ${ns}::getSensor ${scobj_hpath} readSensor {3}
hsetprop ${scobj_hpath}/sensor_03 readSensor ${ns}::readSensor ${scobj_hpath}
@@ -256,6 +283,14 @@ proc ::scobj::srs_sr630::mkDriver { sct_controller name device_class simulation_
hsetprop ${scobj_hpath}/sensor_03 type "part"
hsetprop ${scobj_hpath}/sensor_03 nxalias "${name}_sensor_03"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/sensor_03 600
hsetprop ${scobj_hpath}/sensor_03 simulated false
} else {
::scobj::srs_sr630::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for srs_sr630"
hsetprop ${scobj_hpath}/sensor_03 simulated true
}
hfactory ${scobj_hpath}/sensor_04 plain user float
hsetprop ${scobj_hpath}/sensor_04 read ${ns}::getSensor ${scobj_hpath} readSensor {4}
hsetprop ${scobj_hpath}/sensor_04 readSensor ${ns}::readSensor ${scobj_hpath}
@@ -269,6 +304,14 @@ proc ::scobj::srs_sr630::mkDriver { sct_controller name device_class simulation_
hsetprop ${scobj_hpath}/sensor_04 type "part"
hsetprop ${scobj_hpath}/sensor_04 nxalias "${name}_sensor_04"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/sensor_04 600
hsetprop ${scobj_hpath}/sensor_04 simulated false
} else {
::scobj::srs_sr630::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for srs_sr630"
hsetprop ${scobj_hpath}/sensor_04 simulated true
}
hfactory ${scobj_hpath}/sensor_05 plain user float
hsetprop ${scobj_hpath}/sensor_05 read ${ns}::getSensor ${scobj_hpath} readSensor {5}
hsetprop ${scobj_hpath}/sensor_05 readSensor ${ns}::readSensor ${scobj_hpath}
@@ -282,6 +325,14 @@ proc ::scobj::srs_sr630::mkDriver { sct_controller name device_class simulation_
hsetprop ${scobj_hpath}/sensor_05 type "part"
hsetprop ${scobj_hpath}/sensor_05 nxalias "${name}_sensor_05"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/sensor_05 600
hsetprop ${scobj_hpath}/sensor_05 simulated false
} else {
::scobj::srs_sr630::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for srs_sr630"
hsetprop ${scobj_hpath}/sensor_05 simulated true
}
hfactory ${scobj_hpath}/sensor_06 plain user float
hsetprop ${scobj_hpath}/sensor_06 read ${ns}::getSensor ${scobj_hpath} readSensor {6}
hsetprop ${scobj_hpath}/sensor_06 readSensor ${ns}::readSensor ${scobj_hpath}
@@ -295,6 +346,14 @@ proc ::scobj::srs_sr630::mkDriver { sct_controller name device_class simulation_
hsetprop ${scobj_hpath}/sensor_06 type "part"
hsetprop ${scobj_hpath}/sensor_06 nxalias "${name}_sensor_06"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/sensor_06 600
hsetprop ${scobj_hpath}/sensor_06 simulated false
} else {
::scobj::srs_sr630::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for srs_sr630"
hsetprop ${scobj_hpath}/sensor_06 simulated true
}
hfactory ${scobj_hpath}/sensor_07 plain user float
hsetprop ${scobj_hpath}/sensor_07 read ${ns}::getSensor ${scobj_hpath} readSensor {7}
hsetprop ${scobj_hpath}/sensor_07 readSensor ${ns}::readSensor ${scobj_hpath}
@@ -308,6 +367,14 @@ proc ::scobj::srs_sr630::mkDriver { sct_controller name device_class simulation_
hsetprop ${scobj_hpath}/sensor_07 type "part"
hsetprop ${scobj_hpath}/sensor_07 nxalias "${name}_sensor_07"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/sensor_07 600
hsetprop ${scobj_hpath}/sensor_07 simulated false
} else {
::scobj::srs_sr630::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for srs_sr630"
hsetprop ${scobj_hpath}/sensor_07 simulated true
}
hfactory ${scobj_hpath}/sensor_08 plain user float
hsetprop ${scobj_hpath}/sensor_08 read ${ns}::getSensor ${scobj_hpath} readSensor {8}
hsetprop ${scobj_hpath}/sensor_08 readSensor ${ns}::readSensor ${scobj_hpath}
@@ -321,23 +388,17 @@ proc ::scobj::srs_sr630::mkDriver { sct_controller name device_class simulation_
hsetprop ${scobj_hpath}/sensor_08 type "part"
hsetprop ${scobj_hpath}/sensor_08 nxalias "${name}_sensor_08"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/sensor_08 600
hsetprop ${scobj_hpath}/sensor_08 simulated false
} else {
::scobj::srs_sr630::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for srs_sr630"
hsetprop ${scobj_hpath}/sensor_08 simulated true
}
hsetprop ${scobj_hpath} data "true"
hsetprop ${scobj_hpath} klass "@none"
hsetprop ${scobj_hpath} type "part"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/id 600
${sct_controller} poll ${scobj_hpath}/sensor_01 60
${sct_controller} poll ${scobj_hpath}/sensor_02 600
${sct_controller} poll ${scobj_hpath}/sensor_03 600
${sct_controller} poll ${scobj_hpath}/sensor_04 600
${sct_controller} poll ${scobj_hpath}/sensor_05 600
${sct_controller} poll ${scobj_hpath}/sensor_06 600
${sct_controller} poll ${scobj_hpath}/sensor_07 600
${sct_controller} poll ${scobj_hpath}/sensor_08 600
} else {
::scobj::srs_sr630::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for srs_sr630"
}
hsetprop ${scobj_hpath} klass ${device_class}
hsetprop ${scobj_hpath} data true
hsetprop ${scobj_hpath} debug_threshold 5
@@ -358,7 +419,9 @@ proc ::scobj::srs_sr630::add_driver {name device_class simulation_flag ip_addres
makesctcontroller sct_${name} std ${ip_address}:${tcp_port}
}
} else {
::scobj::srs_sr630::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for srs_sr630"
::scobj::srs_sr630::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for srs_sr630"
::scobj::srs_sr630::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL"
makesctcontroller sct_${name} aqadapter NULL
}
::scobj::srs_sr630::sics_log 1 "::scobj::srs_sr630::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}"
::scobj::srs_sr630::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}
@@ -376,7 +439,7 @@ namespace eval ::scobj::srs_sr630 {
proc add_srs_sr630 {name ip_address tcp_port} {
set simulation_flag "[string tolower [SplitReply [detector_simulation]]]"
::scobj::srs_sr630::add_driver ${name} "NXdetector" "${simulation_flag}" ${ip_address} ${tcp_port}
::scobj::srs_sr630::add_driver ${name} "NXdetector" ${simulation_flag} ${ip_address} ${tcp_port}
}
clientput "file evaluation of sct_srs_sr630.tcl"
@@ -415,20 +478,31 @@ proc ::scobj::srs_sr630::read_config {} {
if { ![string equal -nocase "${simulation_flag}" "false"] } {
set asyncqueue "null"
${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue"
${ns}::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL"
makesctcontroller sct_${name} aqadapter NULL
} elseif { [dict exists $v "asyncqueue"] } {
set asyncqueue [dict get $v "asyncqueue"]
if { [string equal -nocase ${asyncqueue} "sct"] } {
set ip_address [dict get $v ip]
set tcp_port [dict get $v port]
}
makesctcontroller sct_${name} std ${ip_address}:${tcp_port}
} else {
makesctcontroller sct_${name} aqadapter ${asyncqueue}
}
} else {
if { [dict exists $v "asyncprotocol"] } {
set asyncprotocol [dict get $v "asyncprotocol"]
} else {
set asyncprotocol ${name}_protocol
MakeAsyncProtocol ${asyncprotocol}
if { [dict exists $v "terminator"] } {
if { [dict exists $v "sendterminator"] } {
${asyncprotocol} sendterminator "[dict get $v "sendterminator"]"
} elseif { [dict exists $v "terminator"] } {
${asyncprotocol} sendterminator "[dict get $v "terminator"]"
}
if { [dict exists $v "replyterminator"] } {
${asyncprotocol} replyterminator "[dict get $v "replyterminator"]"
} elseif { [dict exists $v "terminator"] } {
${asyncprotocol} replyterminator "[dict get $v "terminator"]"
}
}
@@ -439,12 +513,9 @@ proc ::scobj::srs_sr630::read_config {} {
if { [dict exists $v "timeout"] } {
${asyncqueue} timeout "[dict get $v "timeout"]"
}
makesctcontroller sct_${name} aqadapter ${asyncqueue}
}
if { [string equal -nocase ${asyncqueue} "sct"] } {
${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}
} else {
${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue}
}
${ns}::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}
}
}
}

View File

@@ -10,9 +10,12 @@ proc ::scobj::west_6100::debug_log {tc_root debug_level debug_string} {
set catch_status [ catch {
set debug_threshold [hgetpropval ${tc_root} debug_threshold]
if {${debug_level} >= ${debug_threshold}} {
set fd [open "../log/west_6100_[basename ${tc_root}].log" "a"]
set line "[clock format [clock seconds] -format "%T"] ${debug_string}"
puts ${fd} "${line}"
set now [clock seconds]
set ts [clock format ${now} -format "%Y%m%d"]
set log_file_name "../log/west_6100_[basename ${tc_root}]_${ts}.log"
set fd [open "${log_file_name}" "a"]
set ts [clock format ${now} -format "%T"]
puts ${fd} "${ts} ${debug_string}"
close ${fd}
}
} catch_message ]
@@ -86,7 +89,12 @@ proc ::scobj::west_6100::checkstatus {tc_root} {
# checkstatus hook code goes here
if {[sct driving]} {
set sp "[sct target]"
set pv "[hval ${tc_root}/[sct driveable]]"
if {[hpropexists [sct] simulated] && [sct simulated] == "true"} {
set pv "${sp}"
hupdateif ${tc_root}/[sct driveable] ${sp}
} else {
set pv "[hval ${tc_root}/[sct driveable]]"
}
if { abs(${pv} - ${sp}) <= [sct tolerance] } {
if { [hpropexists [sct] settle_time] } {
if { [hpropexists [sct] settle_time_start] } {
@@ -363,6 +371,15 @@ proc ::scobj::west_6100::mkDriver { sct_controller name device_class simulation_
hsetprop ${scobj_hpath}/alarm1 type "part"
hsetprop ${scobj_hpath}/alarm1 nxalias "${name}_alarm1"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/alarm1 1
${sct_controller} write ${scobj_hpath}/alarm1
hsetprop ${scobj_hpath}/alarm1 simulated false
} else {
::scobj::west_6100::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for west_6100"
hsetprop ${scobj_hpath}/alarm1 simulated true
}
hfactory ${scobj_hpath}/alarm2 plain user float
hsetprop ${scobj_hpath}/alarm2 read ${ns}::getDecimal ${scobj_hpath} rdDecimal {14}
hsetprop ${scobj_hpath}/alarm2 rdDecimal ${ns}::rdDecimal ${scobj_hpath}
@@ -379,6 +396,15 @@ proc ::scobj::west_6100::mkDriver { sct_controller name device_class simulation_
hsetprop ${scobj_hpath}/alarm2 type "part"
hsetprop ${scobj_hpath}/alarm2 nxalias "${name}_alarm2"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/alarm2 1
${sct_controller} write ${scobj_hpath}/alarm2
hsetprop ${scobj_hpath}/alarm2 simulated false
} else {
::scobj::west_6100::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for west_6100"
hsetprop ${scobj_hpath}/alarm2 simulated true
}
hfactory ${scobj_hpath}/power plain user int
hsetprop ${scobj_hpath}/power read ${ns}::getInteger ${scobj_hpath} rdInteger {3}
hsetprop ${scobj_hpath}/power rdInteger ${ns}::rdInteger ${scobj_hpath}
@@ -392,6 +418,14 @@ proc ::scobj::west_6100::mkDriver { sct_controller name device_class simulation_
hsetprop ${scobj_hpath}/power type "part"
hsetprop ${scobj_hpath}/power nxalias "${name}_power"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/power 1
hsetprop ${scobj_hpath}/power simulated false
} else {
::scobj::west_6100::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for west_6100"
hsetprop ${scobj_hpath}/power simulated true
}
hfactory ${scobj_hpath}/powermax plain user int
hsetprop ${scobj_hpath}/powermax read ${ns}::getInteger ${scobj_hpath} rdInteger {20}
hsetprop ${scobj_hpath}/powermax rdInteger ${ns}::rdInteger ${scobj_hpath}
@@ -408,6 +442,15 @@ proc ::scobj::west_6100::mkDriver { sct_controller name device_class simulation_
hsetprop ${scobj_hpath}/powermax type "part"
hsetprop ${scobj_hpath}/powermax nxalias "${name}_powermax"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/powermax 1
${sct_controller} write ${scobj_hpath}/powermax
hsetprop ${scobj_hpath}/powermax simulated false
} else {
::scobj::west_6100::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for west_6100"
hsetprop ${scobj_hpath}/powermax simulated true
}
hfactory ${scobj_hpath}/ramprate plain user float
hsetprop ${scobj_hpath}/ramprate read ${ns}::getDecimal ${scobj_hpath} rdDecimal {24}
hsetprop ${scobj_hpath}/ramprate rdDecimal ${ns}::rdDecimal ${scobj_hpath}
@@ -424,6 +467,15 @@ proc ::scobj::west_6100::mkDriver { sct_controller name device_class simulation_
hsetprop ${scobj_hpath}/ramprate type "part"
hsetprop ${scobj_hpath}/ramprate nxalias "${name}_ramprate"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/ramprate 1
${sct_controller} write ${scobj_hpath}/ramprate
hsetprop ${scobj_hpath}/ramprate simulated false
} else {
::scobj::west_6100::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for west_6100"
hsetprop ${scobj_hpath}/ramprate simulated true
}
hfactory ${scobj_hpath}/sensor plain user float
hsetprop ${scobj_hpath}/sensor read ${ns}::getDecimal ${scobj_hpath} rdDecimal {1}
hsetprop ${scobj_hpath}/sensor rdDecimal ${ns}::rdDecimal ${scobj_hpath}
@@ -439,6 +491,14 @@ proc ::scobj::west_6100::mkDriver { sct_controller name device_class simulation_
hsetprop ${scobj_hpath}/sensor type "part"
hsetprop ${scobj_hpath}/sensor nxalias "${name}_sensor"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/sensor 1
hsetprop ${scobj_hpath}/sensor simulated false
} else {
::scobj::west_6100::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for west_6100"
hsetprop ${scobj_hpath}/sensor simulated true
}
hfactory ${scobj_hpath}/setpoint plain user float
hsetprop ${scobj_hpath}/setpoint read ${ns}::getDecimal ${scobj_hpath} rdDecimal {2}
hsetprop ${scobj_hpath}/setpoint rdDecimal ${ns}::rdDecimal ${scobj_hpath}
@@ -466,6 +526,15 @@ proc ::scobj::west_6100::mkDriver { sct_controller name device_class simulation_
hsetprop ${scobj_hpath}/setpoint type "drivable"
hsetprop ${scobj_hpath}/setpoint nxalias "${name}_setpoint"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/setpoint 1
${sct_controller} write ${scobj_hpath}/setpoint
hsetprop ${scobj_hpath}/setpoint simulated false
} else {
::scobj::west_6100::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for west_6100"
hsetprop ${scobj_hpath}/setpoint simulated true
}
hfactory ${scobj_hpath}/w_sp plain user float
hsetprop ${scobj_hpath}/w_sp read ${ns}::getDecimal ${scobj_hpath} rdDecimal {21}
hsetprop ${scobj_hpath}/w_sp rdDecimal ${ns}::rdDecimal ${scobj_hpath}
@@ -482,33 +551,21 @@ proc ::scobj::west_6100::mkDriver { sct_controller name device_class simulation_
hsetprop ${scobj_hpath}/w_sp type "part"
hsetprop ${scobj_hpath}/w_sp nxalias "${name}_w_sp"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/w_sp 1
${sct_controller} write ${scobj_hpath}/w_sp
hsetprop ${scobj_hpath}/w_sp simulated false
} else {
::scobj::west_6100::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for west_6100"
hsetprop ${scobj_hpath}/w_sp simulated true
}
hsetprop ${scobj_hpath} data "true"
hsetprop ${scobj_hpath} klass "@none"
hsetprop ${scobj_hpath} type "part"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/alarm1 1
${sct_controller} poll ${scobj_hpath}/alarm2 1
${sct_controller} poll ${scobj_hpath}/power 1
${sct_controller} poll ${scobj_hpath}/powermax 1
${sct_controller} poll ${scobj_hpath}/ramprate 1
${sct_controller} poll ${scobj_hpath}/sensor 1
${sct_controller} poll ${scobj_hpath}/setpoint 1
${sct_controller} poll ${scobj_hpath}/w_sp 1
${sct_controller} write ${scobj_hpath}/alarm1
${sct_controller} write ${scobj_hpath}/alarm2
${sct_controller} write ${scobj_hpath}/powermax
${sct_controller} write ${scobj_hpath}/ramprate
${sct_controller} write ${scobj_hpath}/setpoint
${sct_controller} write ${scobj_hpath}/w_sp
} else {
::scobj::west_6100::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for west_6100"
}
ansto_makesctdrive ${name}_setpoint ${scobj_hpath}/setpoint ${scobj_hpath}/sensor ${sct_controller}
hfactory ${scobj_hpath}/aux plain spy none
hsetprop ${scobj_hpath}/aux data "false"
hsetprop ${scobj_hpath}/aux klass "@none"
hsetprop ${scobj_hpath}/aux type "part"
hfactory ${scobj_hpath}/aux/decimal plain user int
hsetprop ${scobj_hpath}/aux/decimal read ${ns}::getInteger ${scobj_hpath} rdInteger {18}
@@ -523,6 +580,14 @@ proc ::scobj::west_6100::mkDriver { sct_controller name device_class simulation_
hsetprop ${scobj_hpath}/aux/decimal type "part"
hsetprop ${scobj_hpath}/aux/decimal nxalias "${name}_aux_decimal"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/aux/decimal 2
hsetprop ${scobj_hpath}/aux/decimal simulated false
} else {
::scobj::west_6100::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for west_6100"
hsetprop ${scobj_hpath}/aux/decimal simulated true
}
hfactory ${scobj_hpath}/aux/instatus plain user int
hsetprop ${scobj_hpath}/aux/instatus read ${ns}::getInteger ${scobj_hpath} rdInteger {133}
hsetprop ${scobj_hpath}/aux/instatus rdInteger ${ns}::rdInteger ${scobj_hpath}
@@ -535,6 +600,14 @@ proc ::scobj::west_6100::mkDriver { sct_controller name device_class simulation_
hsetprop ${scobj_hpath}/aux/instatus type "part"
hsetprop ${scobj_hpath}/aux/instatus nxalias "${name}_aux_instatus"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/aux/instatus 2
hsetprop ${scobj_hpath}/aux/instatus simulated false
} else {
::scobj::west_6100::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for west_6100"
hsetprop ${scobj_hpath}/aux/instatus simulated true
}
hfactory ${scobj_hpath}/aux/model plain user int
hsetprop ${scobj_hpath}/aux/model read ${ns}::getInteger ${scobj_hpath} rdInteger {122}
hsetprop ${scobj_hpath}/aux/model rdInteger ${ns}::rdInteger ${scobj_hpath}
@@ -548,18 +621,18 @@ proc ::scobj::west_6100::mkDriver { sct_controller name device_class simulation_
hsetprop ${scobj_hpath}/aux/model nxalias "${name}_aux_model"
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/aux/decimal 2
${sct_controller} poll ${scobj_hpath}/aux/instatus 2
${sct_controller} poll ${scobj_hpath}/aux/model 2
hsetprop ${scobj_hpath}/aux/model simulated false
} else {
::scobj::west_6100::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for west_6100"
hsetprop ${scobj_hpath}/aux/model simulated true
}
hsetprop ${scobj_hpath}/aux data "false"
hsetprop ${scobj_hpath}/aux klass "@none"
hsetprop ${scobj_hpath}/aux type "part"
hsetprop ${scobj_hpath} klass ${device_class}
hsetprop ${scobj_hpath} data true
hsetprop ${scobj_hpath} debug_threshold 5
if {[string equal -nocase "${simulation_flag}" "false"]} {
ansto_makesctdrive ${name}_setpoint ${scobj_hpath}/setpoint ${scobj_hpath}/sensor ${sct_controller}
}
# mkDriver hook code goes here
} catch_message ]
handle_exception ${catch_status} ${catch_message}
@@ -577,7 +650,9 @@ proc ::scobj::west_6100::add_driver {name device_class simulation_flag ip_addres
makesctcontroller sct_${name} modbus_ap ${ip_address}:${tcp_port}
}
} else {
::scobj::west_6100::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for west_6100"
::scobj::west_6100::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for west_6100"
::scobj::west_6100::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL"
makesctcontroller sct_${name} aqadapter NULL
}
::scobj::west_6100::sics_log 1 "::scobj::west_6100::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id}"
::scobj::west_6100::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id}
@@ -595,7 +670,7 @@ namespace eval ::scobj::west_6100 {
proc add_west_6100 {name ip_address tcp_port id} {
set simulation_flag "[string tolower [SplitReply [environment_simulation]]]"
::scobj::west_6100::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${id}"
::scobj::west_6100::add_driver ${name} "environment" ${simulation_flag} ${ip_address} ${tcp_port} ${id}
}
clientput "file evaluation of sct_west_6100.tcl"
@@ -634,20 +709,31 @@ proc ::scobj::west_6100::read_config {} {
if { ![string equal -nocase "${simulation_flag}" "false"] } {
set asyncqueue "null"
${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue"
${ns}::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL"
makesctcontroller sct_${name} aqadapter NULL
} elseif { [dict exists $v "asyncqueue"] } {
set asyncqueue [dict get $v "asyncqueue"]
if { [string equal -nocase ${asyncqueue} "sct"] } {
set ip_address [dict get $v ip]
set tcp_port [dict get $v port]
}
makesctcontroller sct_${name} modbus_ap ${ip_address}:${tcp_port}
} else {
makesctcontroller sct_${name} aqadapter ${asyncqueue}
}
} else {
if { [dict exists $v "asyncprotocol"] } {
set asyncprotocol [dict get $v "asyncprotocol"]
} else {
set asyncprotocol ${name}_protocol
MakeAsyncProtocol ${asyncprotocol}
if { [dict exists $v "terminator"] } {
if { [dict exists $v "sendterminator"] } {
${asyncprotocol} sendterminator "[dict get $v "sendterminator"]"
} elseif { [dict exists $v "terminator"] } {
${asyncprotocol} sendterminator "[dict get $v "terminator"]"
}
if { [dict exists $v "replyterminator"] } {
${asyncprotocol} replyterminator "[dict get $v "replyterminator"]"
} elseif { [dict exists $v "terminator"] } {
${asyncprotocol} replyterminator "[dict get $v "terminator"]"
}
}
@@ -658,6 +744,7 @@ proc ::scobj::west_6100::read_config {} {
if { [dict exists $v "timeout"] } {
${asyncqueue} timeout "[dict get $v "timeout"]"
}
makesctcontroller sct_${name} aqadapter ${asyncqueue}
}
set arg_list [list]
set missing_list [list]
@@ -674,11 +761,7 @@ proc ::scobj::west_6100::read_config {} {
if { [llength $missing_list] > 0 } {
error "$name is missing configuration values $missing_list"
}
if { [string equal -nocase ${asyncqueue} "sct"] } {
${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list
} else {
${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list
}
${ns}::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list
}
}
}