Wrapper code for legacy drivers.
This commit is contained in:
@@ -27,8 +27,8 @@ proc ::scobj::protekmm::sics_log {debug_level debug_string} {
|
||||
} catch_message ]
|
||||
}
|
||||
|
||||
proc ::scobj::protekmm::mkDriver { sct_controller name } {
|
||||
::scobj::protekmm::sics_log 9 "::scobj::protekmm::mkDriver for ${name}"
|
||||
proc ::scobj::protekmm::mkDriver { sct_controller name id datype } {
|
||||
::scobj::protekmm::sics_log 9 "::scobj::protekmm::mkDriver ${sct_controller} ${name} ${id} ${datype}"
|
||||
set ns "[namespace current]"
|
||||
set catch_status [ catch {
|
||||
|
||||
@@ -41,7 +41,7 @@ proc ::scobj::protekmm::mkDriver { sct_controller name } {
|
||||
hsetprop ${scobj_hpath} klass environment
|
||||
hsetprop ${scobj_hpath} debug_threshold 5
|
||||
# mkDriver hook code starts
|
||||
MakeProtek $name $sct_controller
|
||||
MakeProtek $name $sct_controller $id $datype
|
||||
# mkDriver hook code ends
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
@@ -54,9 +54,9 @@ namespace eval ::scobj::protekmm {
|
||||
namespace export mkDriver
|
||||
}
|
||||
|
||||
proc add_protekmm {name IP port} {
|
||||
proc add_protekmm {name IP port id datype} {
|
||||
set catch_status [ catch {
|
||||
::scobj::protekmm::sics_log 9 "add_protekmm ${name} ${IP} ${port}"
|
||||
::scobj::protekmm::sics_log 9 "add_protekmm ${name} ${IP} ${port} ${id} ${datype}"
|
||||
if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} {
|
||||
if {[string equal -nocase "aqadapter" "${IP}"]} {
|
||||
::scobj::protekmm::sics_log 9 "makesctcontroller sct_${name} aqadapter ${port}"
|
||||
@@ -68,8 +68,8 @@ proc add_protekmm {name IP port} {
|
||||
} else {
|
||||
::scobj::protekmm::sics_log 9 "[environment_simulation] => No sctcontroller for protekmm"
|
||||
}
|
||||
::scobj::protekmm::sics_log 1 "::scobj::protekmm::mkDriver sct_${name} ${name}"
|
||||
::scobj::protekmm::mkDriver sct_${name} ${name}
|
||||
::scobj::protekmm::sics_log 1 "::scobj::protekmm::mkDriver sct_${name} ${name} ${id} ${datype}"
|
||||
::scobj::protekmm::mkDriver sct_${name} ${name} ${id} ${datype}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
@@ -80,14 +80,17 @@ clientput "file evaluation of sct_protekmm.tcl"
|
||||
proc ::scobj::protekmm::read_config {} {
|
||||
set catch_status [ catch {
|
||||
set ns "::scobj::protekmm"
|
||||
dict for {k v} $::config_dict {
|
||||
if { [dict exists $v "implementation"] } {
|
||||
if { !([dict exists $v "name"] && [dict exists $v "enabled"]) } {
|
||||
dict for {k u} $::config_dict {
|
||||
if { [dict exists $u "implementation"] } {
|
||||
if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } {
|
||||
continue
|
||||
}
|
||||
set name [dict get $v name]
|
||||
set enabled [string tolower [dict get $v "enabled"]]
|
||||
set implementation [dict get $v "implementation"]
|
||||
set enabled [string tolower [dict get $u "enabled"]]
|
||||
if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } {
|
||||
continue
|
||||
}
|
||||
set name [dict get $u name]
|
||||
set implementation [dict get $u "implementation"]
|
||||
if { !([dict exists $::config_dict $implementation]) } {
|
||||
continue
|
||||
}
|
||||
@@ -96,41 +99,54 @@ proc ::scobj::protekmm::read_config {} {
|
||||
continue
|
||||
}
|
||||
if { [string equal -nocase [dict get $v "driver"] "protekmm"] } {
|
||||
if { [string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"] } {
|
||||
if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } {
|
||||
set asyncqueue "null"
|
||||
${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue"
|
||||
} elseif { [dict exists $v "asyncqueue"] } {
|
||||
set asyncqueue [dict get $v "asyncqueue"]
|
||||
if { [string equal -nocase ${asyncqueue} "sct"] } {
|
||||
set IP [dict get $v ip]
|
||||
set 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
|
||||
if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } {
|
||||
set asyncqueue "null"
|
||||
${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue"
|
||||
} elseif { [dict exists $v "asyncqueue"] } {
|
||||
set asyncqueue [dict get $v "asyncqueue"]
|
||||
if { [string equal -nocase ${asyncqueue} "sct"] } {
|
||||
set IP [dict get $v ip]
|
||||
set PORT [dict get $v port]
|
||||
MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${IP} ${PORT}
|
||||
if { [dict exists $v "timeout"] } {
|
||||
${asyncqueue} timeout "[dict get $v "timeout"]"
|
||||
}
|
||||
} 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"]"
|
||||
}
|
||||
}
|
||||
if { [string equal -nocase ${asyncqueue} "sct"] } {
|
||||
add_protekmm ${name} ${IP} ${PORT}
|
||||
} else {
|
||||
add_protekmm ${name} "aqadapter" ${asyncqueue}
|
||||
set asyncqueue ${name}_queue
|
||||
set IP [dict get $v ip]
|
||||
set PORT [dict get $v port]
|
||||
MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${IP} ${PORT}
|
||||
if { [dict exists $v "timeout"] } {
|
||||
${asyncqueue} timeout "[dict get $v "timeout"]"
|
||||
}
|
||||
}
|
||||
set arg_list [list]
|
||||
set missing_list [list]
|
||||
foreach arg {id datype} {
|
||||
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"
|
||||
}
|
||||
if { [string equal -nocase ${asyncqueue} "sct"] } {
|
||||
add_protekmm ${name} ${IP} ${PORT} {*}$arg_list
|
||||
} else {
|
||||
add_protekmm ${name} "aqadapter" ${asyncqueue} {*}$arg_list
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user