Change IP/PORT to ip_address/tcp_port and add to mkDriver sig
This facilitates use in mkDriver hook code
This commit is contained in:
@ -1392,15 +1392,15 @@ def put_group(MyDriver, MyGroup):
|
||||
def put_mkDriver(MyDriver):
|
||||
txt = ['']
|
||||
if 'make_args' in MyDriver:
|
||||
line = 'proc %s::mkDriver { sct_controller name %s } {' % (MyDriver['namespace'], MyDriver['make_args'])
|
||||
line = 'proc %s::mkDriver { sct_controller name ip_address tcp_port %s } {' % (MyDriver['namespace'], MyDriver['make_args'])
|
||||
else:
|
||||
line = 'proc %s::mkDriver { sct_controller name } {' % (MyDriver['namespace'])
|
||||
line = 'proc %s::mkDriver { sct_controller name ip_address tcp_port } {' % (MyDriver['namespace'])
|
||||
txt += [line]
|
||||
if 'make_args' in MyDriver:
|
||||
make_args = ' '.join(["${%s}"%arg for arg in MyDriver['make_args'].split()])
|
||||
txt += [' %s::sics_log 9 "%s::mkDriver ${sct_controller} ${name} %s"' % (MyDriver['namespace'], MyDriver['namespace'], make_args)]
|
||||
txt += [' %s::sics_log 9 "%s::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} %s"' % (MyDriver['namespace'], MyDriver['namespace'], make_args)]
|
||||
else:
|
||||
txt += [' %s::sics_log 9 "%s::mkDriver for ${name}"' % (MyDriver['namespace'], MyDriver['namespace'])]
|
||||
txt += [' %s::sics_log 9 "%s::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port}"' % (MyDriver['namespace'], MyDriver['namespace'])]
|
||||
txt += [' set ns "[namespace current]"']
|
||||
txt += [' set catch_status [ catch {']
|
||||
txt += ['']
|
||||
@ -1464,42 +1464,42 @@ def put_postamble(MyDriver):
|
||||
txt += ['}']
|
||||
txt += ['']
|
||||
if 'add_args' in MyDriver:
|
||||
line = 'proc add_%s {name IP port %s} {' % (MyDriver['name'], MyDriver['add_args'])
|
||||
line = 'proc add_%s {name ip_address tcp_port %s} {' % (MyDriver['name'], MyDriver['add_args'])
|
||||
else:
|
||||
line = 'proc add_%s {name IP port} {' % MyDriver['name']
|
||||
line = 'proc add_%s {name ip_address tcp_port} {' % MyDriver['name']
|
||||
txt += [line]
|
||||
txt += [' set catch_status [ catch {']
|
||||
if 'make_args' in MyDriver:
|
||||
make_args = ' '.join(["${%s}"%arg for arg in MyDriver['make_args'].split()])
|
||||
txt += [' %s::sics_log 9 "add_%s ${name} ${IP} ${port} %s"' % (MyDriver['namespace'], MyDriver['name'], make_args)]
|
||||
txt += [' %s::sics_log 9 "add_%s ${name} ${ip_address} ${tcp_port} %s"' % (MyDriver['namespace'], MyDriver['name'], make_args)]
|
||||
else:
|
||||
txt += [' %s::sics_log 9 "add_%s ${name} ${IP} ${port}"' % (MyDriver['namespace'], MyDriver['name'])]
|
||||
txt += [' %s::sics_log 9 "add_%s ${name} ${ip_address} ${tcp_port}"' % (MyDriver['namespace'], MyDriver['name'])]
|
||||
if ('WrapperProperty' in MyDriver) and ('nosctcontroller' in MyDriver['WrapperProperty']):
|
||||
txt += [' %s::sics_log 9 "No sctcontroller for %s"' % (MyDriver['namespace'], MyDriver['name'])]
|
||||
else:
|
||||
txt += [' if {[string equal -nocase [SplitReply [%s]] "false"]} {' % MyDriver['simulation_group']]
|
||||
txt += [' if {[string equal -nocase "aqadapter" "${IP}"]} {']
|
||||
txt += [' %s::sics_log 9 "makesctcontroller sct_${name} aqadapter ${port}"' % MyDriver['namespace']]
|
||||
txt += [' makesctcontroller sct_${name} aqadapter ${port}']
|
||||
txt += [' if {[string equal -nocase "aqadapter" "${ip_address}"]} {']
|
||||
txt += [' %s::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}"' % MyDriver['namespace']]
|
||||
txt += [' makesctcontroller sct_${name} aqadapter ${tcp_port}']
|
||||
txt += [' } else {']
|
||||
if 'protocol_args' in MyDriver:
|
||||
protocol_args = MyDriver['protocol_args'].replace('\\', '\\\\').replace('"', '\\"')
|
||||
txt += [' %s::sics_log 9 "makesctcontroller sct_${name} %s ${IP}:${port} %s"' % (MyDriver['namespace'], MyDriver['protocol'], protocol_args)]
|
||||
txt += [' makesctcontroller sct_${name} %s ${IP}:${port} %s' % (MyDriver['protocol'], MyDriver['protocol_args'])]
|
||||
txt += [' %s::sics_log 9 "makesctcontroller sct_${name} %s ${ip_address}:${tcp_port} %s"' % (MyDriver['namespace'], MyDriver['protocol'], protocol_args)]
|
||||
txt += [' makesctcontroller sct_${name} %s ${ip_address}:${tcp_port} %s' % (MyDriver['protocol'], MyDriver['protocol_args'])]
|
||||
else:
|
||||
txt += [' %s::sics_log 9 "makesctcontroller sct_${name} %s ${IP}:${port}"' % (MyDriver['namespace'], MyDriver['protocol'])]
|
||||
txt += [' makesctcontroller sct_${name} %s ${IP}:${port}' % 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 += [' }']
|
||||
txt += [' } else {']
|
||||
txt += [' %s::sics_log 9 "[%s] => No sctcontroller for %s"' % (MyDriver['namespace'], MyDriver['simulation_group'], MyDriver['name'])]
|
||||
txt += [' }']
|
||||
if 'make_args' in MyDriver:
|
||||
make_args = ' '.join(["${%s}"%arg for arg in MyDriver['make_args'].split()])
|
||||
txt += [' %s::sics_log 1 "%s::mkDriver sct_${name} ${name} %s"' % (MyDriver['namespace'], MyDriver['namespace'], make_args)]
|
||||
txt += [' %s::mkDriver sct_${name} ${name} %s' % (MyDriver['namespace'], make_args)]
|
||||
txt += [' %s::sics_log 1 "%s::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} %s"' % (MyDriver['namespace'], MyDriver['namespace'], make_args)]
|
||||
txt += [' %s::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} %s' % (MyDriver['namespace'], make_args)]
|
||||
else:
|
||||
txt += [' %s::sics_log 1 "%s::mkDriver sct_${name} ${name}"' % (MyDriver['namespace'], MyDriver['namespace'])]
|
||||
txt += [' %s::mkDriver sct_${name} ${name}' % (MyDriver['namespace'])]
|
||||
txt += [' %s::sics_log 1 "%s::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}"' % (MyDriver['namespace'], MyDriver['namespace'])]
|
||||
txt += [' %s::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}' % (MyDriver['namespace'])]
|
||||
# TODO
|
||||
#txt += [' %s::sics_log "makesctemon ${name} /sics/${name}/emon/monmode /sics/${name}/emon/isintol /sics/${name}/emon/errhandler"' % (MyDriver['namespace'])]
|
||||
# txt += [' makesctemon ${name} /sics/${name}/emon/monmode /sics/${name}/emon/isintol /sics/${name}/emon/errhandler']
|
||||
@ -1541,8 +1541,8 @@ def put_read_config(MyDriver):
|
||||
txt += [' } elseif { [dict exists $v "asyncqueue"] } {']
|
||||
txt += [' set asyncqueue [dict get $v "asyncqueue"]']
|
||||
txt += [' if { [string equal -nocase ${asyncqueue} "sct"] } {']
|
||||
txt += [' set IP [dict get $v ip]']
|
||||
txt += [' set PORT [dict get $v port]']
|
||||
txt += [' set ip_address [dict get $v ip]']
|
||||
txt += [' set tcp_port [dict get $v port]']
|
||||
txt += [' }']
|
||||
txt += [' } else {']
|
||||
txt += [' if { [dict exists $v "asyncprotocol"] } {']
|
||||
@ -1556,9 +1556,9 @@ def put_read_config(MyDriver):
|
||||
txt += [' }']
|
||||
txt += [' }']
|
||||
txt += [' set asyncqueue ${name}_queue']
|
||||
txt += [' set IP [dict get $v ip]']
|
||||
txt += [' set PORT [dict get $v port]']
|
||||
txt += [' MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${IP} ${PORT}']
|
||||
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 += [' }']
|
||||
@ -1580,13 +1580,13 @@ def put_read_config(MyDriver):
|
||||
txt += [' error "$name is missing configuration values $missing_list"']
|
||||
txt += [' }']
|
||||
txt += [' if { [string equal -nocase ${asyncqueue} "sct"] } {']
|
||||
txt += [' add_%s ${name} ${IP} ${PORT} {*}$arg_list' % MyDriver['name']]
|
||||
txt += [' add_%s ${name} ${ip_address} ${tcp_port} {*}$arg_list' % MyDriver['name']]
|
||||
txt += [' } else {']
|
||||
txt += [' add_%s ${name} "aqadapter" ${asyncqueue} {*}$arg_list' % MyDriver['name']]
|
||||
txt += [' }']
|
||||
else:
|
||||
txt += [' if { [string equal -nocase ${asyncqueue} "sct"] } {']
|
||||
txt += [' add_%s ${name} ${IP} ${PORT}' % MyDriver['name']]
|
||||
txt += [' add_%s ${name} ${ip_address} ${tcp_port}' % MyDriver['name']]
|
||||
txt += [' } else {']
|
||||
txt += [' add_%s ${name} "aqadapter" ${asyncqueue}' % MyDriver['name']]
|
||||
txt += [' }']
|
||||
|
Reference in New Issue
Block a user