Regen SCT drivers

This commit is contained in:
Douglas Clowes
2014-09-29 14:43:56 +10:00
parent a9c0cf3df6
commit e4b88fd2ad
34 changed files with 1374 additions and 932 deletions

View File

@@ -240,14 +240,14 @@ proc ::scobj::isotech_ps::write_voltage {tc_root nextState cmd_str} {
handle_exception ${catch_status} ${catch_message}
}
proc ::scobj::isotech_ps::mkDriver { sct_controller name ip_address tcp_port } {
::scobj::isotech_ps::sics_log 9 "::scobj::isotech_ps::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port}"
proc ::scobj::isotech_ps::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port } {
::scobj::isotech_ps::sics_log 9 "::scobj::isotech_ps::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}"
set ns "[namespace current]"
set catch_status [ catch {
MakeSICSObj ${name} SCT_OBJECT
sicslist setatt ${name} klass environment
sicslist setatt ${name} klass ${device_class}
sicslist setatt ${name} long_name ${name}
set scobj_hpath /sics/${name}
@@ -303,16 +303,16 @@ proc ::scobj::isotech_ps::mkDriver { sct_controller name ip_address tcp_port } {
hsetprop ${scobj_hpath} klass "@none"
hsetprop ${scobj_hpath} type "part"
if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} {
if {[string equal -nocase "${simulation_flag}" "false"]} {
${sct_controller} poll ${scobj_hpath}/amps 5
${sct_controller} poll ${scobj_hpath}/relay 5
${sct_controller} poll ${scobj_hpath}/volts 5
${sct_controller} write ${scobj_hpath}/relay
${sct_controller} write ${scobj_hpath}/volts
} else {
::scobj::isotech_ps::sics_log 9 "[environment_simulation] => No poll/write for isotech_ps"
::scobj::isotech_ps::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for isotech_ps"
}
hsetprop ${scobj_hpath} klass environment
hsetprop ${scobj_hpath} klass ${device_class}
hsetprop ${scobj_hpath} data true
hsetprop ${scobj_hpath} debug_threshold 5
# mkDriver hook code goes here
@@ -320,43 +320,51 @@ proc ::scobj::isotech_ps::mkDriver { sct_controller name ip_address tcp_port } {
handle_exception ${catch_status} ${catch_message}
}
proc ::scobj::isotech_ps::add_driver {name device_class simulation_flag ip_address tcp_port} {
set catch_status [ catch {
::scobj::isotech_ps::sics_log 9 "::scobj::isotech_ps::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}"
if {[string equal -nocase "${simulation_flag}" "false"]} {
if {[string equal -nocase "aqadapter" "${ip_address}"]} {
::scobj::isotech_ps::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}"
makesctcontroller sct_${name} aqadapter ${tcp_port}
} else {
::scobj::isotech_ps::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port} \"\\r\""
makesctcontroller sct_${name} std ${ip_address}:${tcp_port} "\r"
}
} else {
::scobj::isotech_ps::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for isotech_ps"
::scobj::isotech_ps::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL"
makesctcontroller sct_${name} aqadapter NULL
}
::scobj::isotech_ps::sics_log 1 "::scobj::isotech_ps::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}"
::scobj::isotech_ps::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
namespace eval ::scobj::isotech_ps {
namespace export debug_threshold
namespace export debug_log
namespace export sics_log
namespace export mkDriver
namespace export add_driver
}
proc add_isotech_ps {name ip_address tcp_port} {
set catch_status [ catch {
::scobj::isotech_ps::sics_log 9 "add_isotech_ps ${name} ${ip_address} ${tcp_port}"
if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} {
if {[string equal -nocase "aqadapter" "${ip_address}"]} {
::scobj::isotech_ps::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}"
makesctcontroller sct_${name} aqadapter ${tcp_port}
} else {
::scobj::isotech_ps::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port} \"\\r\""
makesctcontroller sct_${name} std ${ip_address}:${tcp_port} "\r"
}
} else {
::scobj::isotech_ps::sics_log 9 "[environment_simulation] => Null sctcontroller for isotech_ps"
::scobj::isotech_ps::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL"
makesctcontroller sct_${name} aqadapter NULL
}
::scobj::isotech_ps::sics_log 1 "::scobj::isotech_ps::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}"
::scobj::isotech_ps::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
set simulation_flag "[string tolower [SplitReply [environment_simulation]]]"
::scobj::isotech_ps::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port}
}
clientput "file evaluation of isotech_ps_sct.tcl"
::scobj::isotech_ps::sics_log 9 "file evaluation of isotech_ps_sct.tcl"
clientput "file evaluation of sct_isotech_ps.tcl"
::scobj::isotech_ps::sics_log 9 "file evaluation of sct_isotech_ps.tcl"
proc ::scobj::isotech_ps::read_config {} {
set catch_status [ catch {
set ns "::scobj::isotech_ps"
dict for {k u} $::config_dict {
if { [dict exists $u "implementation"] } {
set simulation_flag "[string tolower [SplitReply [environment_simulation]]]"
set device_class "environment"
if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } {
continue
}
@@ -364,6 +372,12 @@ proc ::scobj::isotech_ps::read_config {} {
if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } {
continue
}
if { [dict exists $u "simulation_group"] } {
set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]]
}
if { [dict exists $u "device_class"] } {
set device_class "[dict get $u "device_class"]"
}
set name [dict get $u name]
set implementation [dict get $u "implementation"]
if { !([dict exists $::config_dict $implementation]) } {
@@ -374,9 +388,9 @@ proc ::scobj::isotech_ps::read_config {} {
continue
}
if { [string equal -nocase [dict get $v "driver"] "isotech_ps"] } {
if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } {
if { ![string equal -nocase "${simulation_flag}" "false"] } {
set asyncqueue "null"
${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue"
${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"] } {
@@ -403,9 +417,9 @@ proc ::scobj::isotech_ps::read_config {} {
}
}
if { [string equal -nocase ${asyncqueue} "sct"] } {
add_isotech_ps ${name} ${ip_address} ${tcp_port}
${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}
} else {
add_isotech_ps ${name} "aqadapter" ${asyncqueue}
${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue}
}
}
}