calling makesctcontroller and mkDriver from read_config
This commit is contained in:
@ -1735,12 +1735,21 @@ def put_read_config(MyDriver):
|
|||||||
txt += [' if { ![string equal -nocase "${simulation_flag}" "false"] } {']
|
txt += [' if { ![string equal -nocase "${simulation_flag}" "false"] } {']
|
||||||
txt += [' set asyncqueue "null"']
|
txt += [' set asyncqueue "null"']
|
||||||
txt += [' ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue"']
|
txt += [' ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue"']
|
||||||
|
txt += [' ${ns}::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL"']
|
||||||
|
txt += [' makesctcontroller sct_${name} aqadapter NULL']
|
||||||
txt += [' } elseif { [dict exists $v "asyncqueue"] } {']
|
txt += [' } elseif { [dict exists $v "asyncqueue"] } {']
|
||||||
txt += [' set asyncqueue [dict get $v "asyncqueue"]']
|
txt += [' set asyncqueue [dict get $v "asyncqueue"]']
|
||||||
txt += [' if { [string equal -nocase ${asyncqueue} "sct"] } {']
|
txt += [' if { [string equal -nocase ${asyncqueue} "sct"] } {']
|
||||||
txt += [' set ip_address [dict get $v ip]']
|
txt += [' set ip_address [dict get $v ip]']
|
||||||
txt += [' set tcp_port [dict get $v port]']
|
txt += [' set tcp_port [dict get $v port]']
|
||||||
txt += [' }']
|
if 'protocol_args' in MyDriver:
|
||||||
|
protocol_args = ' ' + MyDriver['protocol_args']
|
||||||
|
else:
|
||||||
|
protocol_args = ''
|
||||||
|
txt += [' makesctcontroller sct_${name} %s ${ip_address}:${tcp_port} %s' % (MyDriver['protocol'], protocol_args)]
|
||||||
|
txt += [' } else {']
|
||||||
|
txt += [' makesctcontroller sct_${name} aqadapter ${asyncqueue}']
|
||||||
|
txt += [' }']
|
||||||
txt += [' } else {']
|
txt += [' } else {']
|
||||||
txt += [' if { [dict exists $v "asyncprotocol"] } {']
|
txt += [' if { [dict exists $v "asyncprotocol"] } {']
|
||||||
txt += [' set asyncprotocol [dict get $v "asyncprotocol"]']
|
txt += [' set asyncprotocol [dict get $v "asyncprotocol"]']
|
||||||
@ -1765,17 +1774,18 @@ def put_read_config(MyDriver):
|
|||||||
txt += [' if { [dict exists $v "timeout"] } {']
|
txt += [' if { [dict exists $v "timeout"] } {']
|
||||||
txt += [' ${asyncqueue} timeout "[dict get $v "timeout"]"']
|
txt += [' ${asyncqueue} timeout "[dict get $v "timeout"]"']
|
||||||
txt += [' }']
|
txt += [' }']
|
||||||
|
txt += [' makesctcontroller sct_${name} aqadapter ${asyncqueue}']
|
||||||
txt += [' }']
|
txt += [' }']
|
||||||
if 'add_args_lst' in MyDriver:
|
if 'make_args_lst' in MyDriver:
|
||||||
txt += [' set arg_list [list]']
|
txt += [' set arg_list [list]']
|
||||||
txt += [' set missing_list [list]']
|
txt += [' set missing_list [list]']
|
||||||
default_list = []
|
default_list = []
|
||||||
for arg in [key for key in MyDriver['add_args_lst'] if MyDriver['add_args_map'][key] is not None]:
|
for arg in [key for key in MyDriver['make_args_lst'] if MyDriver['make_args_map'][key] is not None]:
|
||||||
default_list += [arg, MyDriver['add_args_map'][arg]]
|
default_list += [arg, MyDriver['make_args_map'][arg]]
|
||||||
if len(default_list) > 0:
|
if len(default_list) > 0:
|
||||||
txt += [' array unset default_map']
|
txt += [' array unset default_map']
|
||||||
txt += [' array set default_map [list %s]' % ' '.join(default_list)]
|
txt += [' array set default_map [list %s]' % ' '.join(default_list)]
|
||||||
txt += [' foreach arg {' + ' '.join(MyDriver['add_args_lst']) + '} {']
|
txt += [' foreach arg {' + ' '.join(MyDriver['make_args_lst']) + '} {']
|
||||||
txt += [' if {[dict exists $u $arg]} {']
|
txt += [' if {[dict exists $u $arg]} {']
|
||||||
txt += [' lappend arg_list "[dict get $u $arg]"']
|
txt += [' lappend arg_list "[dict get $u $arg]"']
|
||||||
txt += [' } elseif {[dict exists $v $arg]} {']
|
txt += [' } elseif {[dict exists $v $arg]} {']
|
||||||
@ -1791,17 +1801,10 @@ def put_read_config(MyDriver):
|
|||||||
txt += [' if { [llength $missing_list] > 0 } {']
|
txt += [' if { [llength $missing_list] > 0 } {']
|
||||||
txt += [' error "$name is missing configuration values $missing_list"']
|
txt += [' error "$name is missing configuration values $missing_list"']
|
||||||
txt += [' }']
|
txt += [' }']
|
||||||
txt += [' if { [string equal -nocase ${asyncqueue} "sct"] } {']
|
make_args = ' {*}$arg_list'
|
||||||
txt += [' ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list']
|
|
||||||
txt += [' } else {']
|
|
||||||
txt += [' ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list']
|
|
||||||
txt += [' }']
|
|
||||||
else:
|
else:
|
||||||
txt += [' if { [string equal -nocase ${asyncqueue} "sct"] } {']
|
make_args = ''
|
||||||
txt += [' ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}']
|
txt += [' ${ns}::mkDriver sct_${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}' + make_args]
|
||||||
txt += [' } else {']
|
|
||||||
txt += [' ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue}']
|
|
||||||
txt += [' }']
|
|
||||||
txt += [' }']
|
txt += [' }']
|
||||||
txt += [' }']
|
txt += [' }']
|
||||||
txt += [' }']
|
txt += [' }']
|
||||||
|
Reference in New Issue
Block a user