Make protocol_args like {add,make}_args and add nosctcontroller in read_config
This commit is contained in:
@ -933,6 +933,13 @@ def build_driver(MyDriver, TheTree):
|
|||||||
arg_map = MyDriver['make_args_map']
|
arg_map = MyDriver['make_args_map']
|
||||||
for arg in arg_map:
|
for arg in arg_map:
|
||||||
print ' %s:' % arg, arg_map[arg]
|
print ' %s:' % arg, arg_map[arg]
|
||||||
|
if 'protocol_args' in MyDriver:
|
||||||
|
MyDriver['protocol_args_lst'], MyDriver['protocol_args_map'] = parse_args(MyDriver['protocol_args'])
|
||||||
|
if Verbose:
|
||||||
|
print "PROTOCOL_ARGS:", MyDriver['protocol_args']
|
||||||
|
arg_map = MyDriver['protocol_args_map']
|
||||||
|
for arg in arg_map:
|
||||||
|
print ' %s:' % arg, arg_map[arg]
|
||||||
if 'add_args_lst' in MyDriver and 'make_args_lst' in MyDriver:
|
if 'add_args_lst' in MyDriver and 'make_args_lst' in MyDriver:
|
||||||
if MyDriver['add_args_lst'] != MyDriver['make_args_lst']:
|
if MyDriver['add_args_lst'] != MyDriver['make_args_lst']:
|
||||||
print "Add_Args:", MyDriver['add_args_lst']
|
print "Add_Args:", MyDriver['add_args_lst']
|
||||||
@ -999,6 +1006,8 @@ def dump_driver(MyDriver):
|
|||||||
Comments += ['add_args_map']
|
Comments += ['add_args_map']
|
||||||
Comments += ['make_args_lst']
|
Comments += ['make_args_lst']
|
||||||
Comments += ['make_args_map']
|
Comments += ['make_args_map']
|
||||||
|
Comments += ['protocol_args_lst']
|
||||||
|
Comments += ['protocol_args_map']
|
||||||
Deferred = ['Groups', 'Funcs', 'Deferred', 'name'] + Comments
|
Deferred = ['Groups', 'Funcs', 'Deferred', 'name'] + Comments
|
||||||
for Comment in sorted(Comments):
|
for Comment in sorted(Comments):
|
||||||
if Comment in MyDriver:
|
if Comment in MyDriver:
|
||||||
@ -1639,9 +1648,18 @@ def put_add_driver(MyDriver):
|
|||||||
txt += [' makesctcontroller sct_${name} aqadapter ${tcp_port}']
|
txt += [' makesctcontroller sct_${name} aqadapter ${tcp_port}']
|
||||||
txt += [' } else {']
|
txt += [' } else {']
|
||||||
if 'protocol_args' in MyDriver:
|
if 'protocol_args' in MyDriver:
|
||||||
protocol_args = MyDriver['protocol_args'].replace('\\', '\\\\').replace('"', '\\"')
|
protocol_args = []
|
||||||
txt += [' %s::sics_log 9 "makesctcontroller sct_${name} %s ${ip_address}:${tcp_port} %s"' % (MyDriver['namespace'], MyDriver['protocol'], protocol_args)]
|
for arg in MyDriver['protocol_args_lst']:
|
||||||
txt += [' makesctcontroller sct_${name} %s ${ip_address}:${tcp_port} %s' % (MyDriver['protocol'], MyDriver['protocol_args'])]
|
if 'add_args_lst' in MyDriver and arg in MyDriver['add_args_lst']:
|
||||||
|
protocol_args.append('${%s}' % arg)
|
||||||
|
elif arg in MyDriver['protocol_args_map'] and MyDriver['protocol_args_map'][arg] is not None:
|
||||||
|
protocol_args.append(MyDriver['protocol_args_map'][arg])
|
||||||
|
else:
|
||||||
|
PrintPostError('Protocol arg %s is not in add_args and has no default' % arg)
|
||||||
|
tmp = ' '.join(protocol_args).replace('\\', '\\\\').replace('"', '\\"')
|
||||||
|
txt += [' %s::sics_log 9 "makesctcontroller sct_${name} %s ${ip_address}:${tcp_port} %s"' % (MyDriver['namespace'], MyDriver['protocol'], tmp)]
|
||||||
|
tmp = ' '.join(protocol_args)
|
||||||
|
txt += [' makesctcontroller sct_${name} %s ${ip_address}:${tcp_port} %s' % (MyDriver['protocol'], tmp)]
|
||||||
else:
|
else:
|
||||||
txt += [' %s::sics_log 9 "makesctcontroller sct_${name} %s ${ip_address}:${tcp_port}"' % (MyDriver['namespace'], MyDriver['protocol'])]
|
txt += [' %s::sics_log 9 "makesctcontroller sct_${name} %s ${ip_address}:${tcp_port}"' % (MyDriver['namespace'], MyDriver['protocol'])]
|
||||||
txt += [' makesctcontroller sct_${name} %s ${ip_address}:${tcp_port}' % MyDriver['protocol']]
|
txt += [' makesctcontroller sct_${name} %s ${ip_address}:${tcp_port}' % MyDriver['protocol']]
|
||||||
@ -1732,50 +1750,77 @@ def put_read_config(MyDriver):
|
|||||||
txt += [' continue']
|
txt += [' continue']
|
||||||
txt += [' }']
|
txt += [' }']
|
||||||
txt += [' if { [string equal -nocase [dict get $v "driver"] "%s"] } {' % MyDriver['name']]
|
txt += [' if { [string equal -nocase [dict get $v "driver"] "%s"] } {' % MyDriver['name']]
|
||||||
txt += [' if { ![string equal -nocase "${simulation_flag}" "false"] } {']
|
if ('WrapperProperty' in MyDriver) and ('nosctcontroller' in MyDriver['WrapperProperty']):
|
||||||
txt += [' set asyncqueue "null"']
|
txt += [' %s::sics_log 9 "No sctcontroller for %s"' % (MyDriver['namespace'], MyDriver['name'])]
|
||||||
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:
|
else:
|
||||||
protocol_args = ''
|
txt += [' if { ![string equal -nocase "${simulation_flag}" "false"] } {']
|
||||||
txt += [' makesctcontroller sct_${name} %s ${ip_address}:${tcp_port} %s' % (MyDriver['protocol'], protocol_args)]
|
txt += [' set asyncqueue "null"']
|
||||||
txt += [' } else {']
|
txt += [' ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue"']
|
||||||
txt += [' makesctcontroller sct_${name} aqadapter ${asyncqueue}']
|
txt += [' ${ns}::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL"']
|
||||||
txt += [' }']
|
txt += [' makesctcontroller sct_${name} aqadapter NULL']
|
||||||
txt += [' } else {']
|
txt += [' } elseif { [dict exists $v "asyncqueue"] } {']
|
||||||
txt += [' if { [dict exists $v "asyncprotocol"] } {']
|
txt += [' set asyncqueue [dict get $v "asyncqueue"]']
|
||||||
txt += [' set asyncprotocol [dict get $v "asyncprotocol"]']
|
txt += [' if { [string equal -nocase ${asyncqueue} "sct"] } {']
|
||||||
txt += [' } else {']
|
txt += [' set ip_address [dict get $v ip]']
|
||||||
txt += [' set asyncprotocol ${name}_protocol']
|
txt += [' set tcp_port [dict get $v port]']
|
||||||
txt += [' MakeAsyncProtocol ${asyncprotocol}']
|
if 'protocol_args_lst' in MyDriver:
|
||||||
txt += [' if { [dict exists $v "sendterminator"] } {']
|
txt += [' set arg_list [list]']
|
||||||
txt += [' ${asyncprotocol} sendterminator "[dict get $v "sendterminator"]"']
|
txt += [' set missing_list [list]']
|
||||||
txt += [' } elseif { [dict exists $v "terminator"] } {']
|
default_list = []
|
||||||
txt += [' ${asyncprotocol} sendterminator "[dict get $v "terminator"]"']
|
for arg in [key for key in MyDriver['protocol_args_lst'] if MyDriver['protocol_args_map'][key] is not None]:
|
||||||
txt += [' }']
|
default_list += [arg, MyDriver['protocol_args_map'][arg]]
|
||||||
txt += [' if { [dict exists $v "replyterminator"] } {']
|
if len(default_list) > 0:
|
||||||
txt += [' ${asyncprotocol} replyterminator "[dict get $v "replyterminator"]"']
|
txt += [' array unset default_map']
|
||||||
txt += [' } elseif { [dict exists $v "terminator"] } {']
|
txt += [' array set default_map [list %s]' % ' '.join(default_list)]
|
||||||
txt += [' ${asyncprotocol} replyterminator "[dict get $v "terminator"]"']
|
txt += [' foreach arg {' + ' '.join(MyDriver['protocol_args_lst']) + '} {']
|
||||||
txt += [' }']
|
txt += [' if {[dict exists $u $arg]} {']
|
||||||
txt += [' }']
|
txt += [' lappend arg_list "[dict get $u $arg]"']
|
||||||
txt += [' set asyncqueue ${name}_queue']
|
txt += [' } elseif {[dict exists $v $arg]} {']
|
||||||
txt += [' set ip_address [dict get $v ip]']
|
txt += [' lappend arg_list "[dict get $v $arg]"']
|
||||||
txt += [' set tcp_port [dict get $v port]']
|
if len(default_list) > 0:
|
||||||
txt += [' MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${ip_address} ${tcp_port}']
|
txt += [' } elseif {[info exists default_map($arg)]} {']
|
||||||
txt += [' if { [dict exists $v "timeout"] } {']
|
txt += [' lappend arg_list $default_map($arg)']
|
||||||
txt += [' ${asyncqueue} timeout "[dict get $v "timeout"]"']
|
txt += [' } else {']
|
||||||
txt += [' }']
|
txt += [' ${ns}::sics_log 9 "Missing configuration value $arg"']
|
||||||
txt += [' makesctcontroller sct_${name} aqadapter ${asyncqueue}']
|
txt += [' lappend missing_list $arg']
|
||||||
txt += [' }']
|
txt += [' }']
|
||||||
|
txt += [' }']
|
||||||
|
txt += [' if { [llength $missing_list] > 0 } {']
|
||||||
|
txt += [' error "$name is missing configuration values $missing_list"']
|
||||||
|
txt += [' }']
|
||||||
|
protocol_args = ' {*}$arg_list'
|
||||||
|
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"] } {']
|
||||||
|
txt += [' set asyncprotocol [dict get $v "asyncprotocol"]']
|
||||||
|
txt += [' } else {']
|
||||||
|
txt += [' set asyncprotocol ${name}_protocol']
|
||||||
|
txt += [' MakeAsyncProtocol ${asyncprotocol}']
|
||||||
|
txt += [' if { [dict exists $v "sendterminator"] } {']
|
||||||
|
txt += [' ${asyncprotocol} sendterminator "[dict get $v "sendterminator"]"']
|
||||||
|
txt += [' } elseif { [dict exists $v "terminator"] } {']
|
||||||
|
txt += [' ${asyncprotocol} sendterminator "[dict get $v "terminator"]"']
|
||||||
|
txt += [' }']
|
||||||
|
txt += [' if { [dict exists $v "replyterminator"] } {']
|
||||||
|
txt += [' ${asyncprotocol} replyterminator "[dict get $v "replyterminator"]"']
|
||||||
|
txt += [' } elseif { [dict exists $v "terminator"] } {']
|
||||||
|
txt += [' ${asyncprotocol} replyterminator "[dict get $v "terminator"]"']
|
||||||
|
txt += [' }']
|
||||||
|
txt += [' }']
|
||||||
|
txt += [' set asyncqueue ${name}_queue']
|
||||||
|
txt += [' set ip_address [dict get $v ip]']
|
||||||
|
txt += [' set tcp_port [dict get $v port]']
|
||||||
|
txt += [' MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${ip_address} ${tcp_port}']
|
||||||
|
txt += [' if { [dict exists $v "timeout"] } {']
|
||||||
|
txt += [' ${asyncqueue} timeout "[dict get $v "timeout"]"']
|
||||||
|
txt += [' }']
|
||||||
|
txt += [' makesctcontroller sct_${name} aqadapter ${asyncqueue}']
|
||||||
|
txt += [' }']
|
||||||
if 'make_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]']
|
||||||
|
Reference in New Issue
Block a user