calling makesctcontroller and mkDriver from read_config

This commit is contained in:
Douglas Clowes
2014-11-04 12:13:34 +11:00
parent cd64a3de3d
commit aa9942b2b6

View File

@ -1735,11 +1735,20 @@ def put_read_config(MyDriver):
txt += [' if { ![string equal -nocase "${simulation_flag}" "false"] } {']
txt += [' set asyncqueue "null"']
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 += [' set asyncqueue [dict get $v "asyncqueue"]']
txt += [' if { [string equal -nocase ${asyncqueue} "sct"] } {']
txt += [' set ip_address [dict get $v ip]']
txt += [' set tcp_port [dict get $v port]']
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 += [' if { [dict exists $v "asyncprotocol"] } {']
@ -1765,17 +1774,18 @@ def put_read_config(MyDriver):
txt += [' if { [dict exists $v "timeout"] } {']
txt += [' ${asyncqueue} timeout "[dict get $v "timeout"]"']
txt += [' }']
txt += [' makesctcontroller sct_${name} aqadapter ${asyncqueue}']
txt += [' }']
if 'add_args_lst' in MyDriver:
if 'make_args_lst' in MyDriver:
txt += [' set arg_list [list]']
txt += [' set missing_list [list]']
default_list = []
for arg in [key for key in MyDriver['add_args_lst'] if MyDriver['add_args_map'][key] is not None]:
default_list += [arg, MyDriver['add_args_map'][arg]]
for arg in [key for key in MyDriver['make_args_lst'] if MyDriver['make_args_map'][key] is not None]:
default_list += [arg, MyDriver['make_args_map'][arg]]
if len(default_list) > 0:
txt += [' array unset default_map']
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 += [' lappend arg_list "[dict get $u $arg]"']
txt += [' } elseif {[dict exists $v $arg]} {']
@ -1791,17 +1801,10 @@ def put_read_config(MyDriver):
txt += [' if { [llength $missing_list] > 0 } {']
txt += [' error "$name is missing configuration values $missing_list"']
txt += [' }']
txt += [' if { [string equal -nocase ${asyncqueue} "sct"] } {']
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 += [' }']
make_args = ' {*}$arg_list'
else:
txt += [' if { [string equal -nocase ${asyncqueue} "sct"] } {']
txt += [' ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}']
txt += [' } else {']
txt += [' ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue}']
txt += [' }']
make_args = ''
txt += [' ${ns}::mkDriver sct_${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}' + make_args]
txt += [' }']
txt += [' }']
txt += [' }']