127 lines
4.8 KiB
Tcl
127 lines
4.8 KiB
Tcl
# Generated driver for west4100
|
|
# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent
|
|
#
|
|
|
|
namespace eval ::scobj::west4100 {
|
|
set debug_threshold 5
|
|
}
|
|
|
|
proc ::scobj::west4100::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/west4100_[basename ${tc_root}].log" "a"]
|
|
set line "[clock format [clock seconds] -format "%T"] ${debug_string}"
|
|
puts ${fd} "${line}"
|
|
close ${fd}
|
|
}
|
|
} catch_message ]
|
|
}
|
|
|
|
proc ::scobj::west4100::sics_log {debug_level debug_string} {
|
|
set catch_status [ catch {
|
|
set debug_threshold ${::scobj::west4100::debug_threshold}
|
|
if {${debug_level} >= ${debug_threshold}} {
|
|
sicslog "::scobj::west4100::${debug_string}"
|
|
}
|
|
} catch_message ]
|
|
}
|
|
|
|
proc ::scobj::west4100::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port dev_id } {
|
|
::scobj::west4100::sics_log 9 "::scobj::west4100::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${dev_id}"
|
|
set ns "[namespace current]"
|
|
set catch_status [ catch {
|
|
|
|
# mkWrapper hook code starts
|
|
::environment::temperature::mkwest400 ${name} ${ip_address} ${dev_id}
|
|
# mkWrapper hook code ends
|
|
} catch_message ]
|
|
handle_exception ${catch_status} ${catch_message}
|
|
}
|
|
|
|
proc ::scobj::west4100::add_driver {name device_class simulation_flag ip_address tcp_port dev_id} {
|
|
set catch_status [ catch {
|
|
::scobj::west4100::sics_log 9 "::scobj::west4100::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${dev_id}"
|
|
::scobj::west4100::sics_log 9 "No sctcontroller for west4100"
|
|
::scobj::west4100::sics_log 1 "::scobj::west4100::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${dev_id}"
|
|
::scobj::west4100::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${dev_id}
|
|
} catch_message ]
|
|
handle_exception ${catch_status} ${catch_message}
|
|
}
|
|
|
|
namespace eval ::scobj::west4100 {
|
|
namespace export debug_threshold
|
|
namespace export debug_log
|
|
namespace export sics_log
|
|
namespace export mkDriver
|
|
namespace export add_driver
|
|
}
|
|
|
|
proc add_west4100 {name ip_address tcp_port dev_id} {
|
|
set simulation_flag "[string tolower [SplitReply [environment_simulation]]]"
|
|
::scobj::west4100::add_driver ${name} "environment" ${simulation_flag} ${ip_address} ${tcp_port} ${dev_id}
|
|
}
|
|
|
|
clientput "file evaluation of west4100_sct.tcl"
|
|
::scobj::west4100::sics_log 9 "file evaluation of west4100_sct.tcl"
|
|
|
|
proc ::scobj::west4100::read_config {} {
|
|
set catch_status [ catch {
|
|
set ns "::scobj::west4100"
|
|
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
|
|
}
|
|
set enabled [string tolower [dict get $u "enabled"]]
|
|
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]) } {
|
|
continue
|
|
}
|
|
set v [dict get $::config_dict $implementation]
|
|
if { !([dict exists $v "driver"]) } {
|
|
continue
|
|
}
|
|
if { [string equal -nocase [dict get $v "driver"] "west4100"] } {
|
|
::scobj::west4100::sics_log 9 "No sctcontroller for west4100"
|
|
set arg_list [list]
|
|
set missing_list [list]
|
|
foreach arg {dev_id} {
|
|
if {[dict exists $u $arg]} {
|
|
lappend arg_list "[dict get $u $arg]"
|
|
} elseif {[dict exists $v $arg]} {
|
|
lappend arg_list "[dict get $v $arg]"
|
|
} else {
|
|
${ns}::sics_log 9 "Missing configuration value $arg"
|
|
lappend missing_list $arg
|
|
}
|
|
}
|
|
if { [llength $missing_list] > 0 } {
|
|
error "$name is missing configuration values $missing_list"
|
|
}
|
|
${ns}::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list
|
|
}
|
|
}
|
|
}
|
|
} catch_message ]
|
|
handle_exception ${catch_status} ${catch_message}
|
|
}
|
|
|
|
if { [info exists ::config_dict] } {
|
|
::scobj::west4100::read_config
|
|
} else {
|
|
::scobj::west4100::sics_log 5 "No config dict"
|
|
}
|