Allow sct drivers to get device_class and simulation_group from ini file
This commit is contained in:
@ -1364,7 +1364,7 @@ def put_group(MyDriver, MyGroup):
|
||||
txt += [' hsetprop ${scobj_hpath} %s "%s"' % (key, MyGroup['GroupProperty'][key])]
|
||||
if readable_or_writeable:
|
||||
txt += ['']
|
||||
txt += [' if {[string equal -nocase [SplitReply [%s]] "false"]} {' % MyDriver['simulation_group']]
|
||||
txt += [' if {[string equal -nocase "${simulation_flag}" "false"]} {']
|
||||
for var in sorted(MyGroup['Vars']):
|
||||
MyVar = MyGroup['Vars'][var]
|
||||
nodename = groupname + MyVar['name']
|
||||
@ -1385,7 +1385,7 @@ def put_group(MyDriver, MyGroup):
|
||||
driveable = '${name}_' + make_path(MyVar)
|
||||
MyDriver['Deferred'] += ['ansto_makesctdrive %s ${scobj_hpath}/%s ${scobj_hpath}/%s ${sct_controller}' % (driveable, nodename, MyVar['driveable'])]
|
||||
txt += [' } else {']
|
||||
txt += [' %s::sics_log 9 "[%s] => No poll/write for %s"' % (MyDriver['namespace'], MyDriver['simulation_group'], MyDriver['name'])]
|
||||
txt += [' %s::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for %s"' % (MyDriver['namespace'], MyDriver['name'])]
|
||||
txt += [' }']
|
||||
for grp in sorted(MyGroup['Groups']):
|
||||
txt += put_group(MyDriver, MyGroup['Groups'][grp])
|
||||
@ -1394,15 +1394,15 @@ def put_group(MyDriver, MyGroup):
|
||||
def put_mkDriver(MyDriver):
|
||||
txt = ['']
|
||||
if 'make_args' in MyDriver:
|
||||
line = 'proc %s::mkDriver { sct_controller name ip_address tcp_port %s } {' % (MyDriver['namespace'], MyDriver['make_args'])
|
||||
line = 'proc %s::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port %s } {' % (MyDriver['namespace'], MyDriver['make_args'])
|
||||
else:
|
||||
line = 'proc %s::mkDriver { sct_controller name ip_address tcp_port } {' % (MyDriver['namespace'])
|
||||
line = 'proc %s::mkDriver { sct_controller name device_class simulation_flag 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} ${ip_address} ${tcp_port} %s"' % (MyDriver['namespace'], MyDriver['namespace'], make_args)]
|
||||
txt += [' %s::sics_log 9 "%s::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} %s"' % (MyDriver['namespace'], MyDriver['namespace'], make_args)]
|
||||
else:
|
||||
txt += [' %s::sics_log 9 "%s::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port}"' % (MyDriver['namespace'], MyDriver['namespace'])]
|
||||
txt += [' %s::sics_log 9 "%s::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}"' % (MyDriver['namespace'], MyDriver['namespace'])]
|
||||
txt += [' set ns "[namespace current]"']
|
||||
txt += [' set catch_status [ catch {']
|
||||
txt += ['']
|
||||
@ -1425,7 +1425,7 @@ def put_mkDriver(MyDriver):
|
||||
ms_line = ' MakeSICSObj ${name} SCT_OBJECT'
|
||||
txt += [ms_line]
|
||||
txt += ['']
|
||||
txt += [' sicslist setatt ${name} klass %s' % MyDriver['class']]
|
||||
txt += [' sicslist setatt ${name} klass ${device_class}']
|
||||
txt += [' sicslist setatt ${name} long_name ${name}']
|
||||
if 'DriverProperty' in MyDriver:
|
||||
for key in MyDriver['DriverProperty']:
|
||||
@ -1436,11 +1436,11 @@ def put_mkDriver(MyDriver):
|
||||
for group in sorted(MyDriver['Groups']):
|
||||
txt += put_group(MyDriver, MyDriver['Groups'][group])
|
||||
|
||||
txt += [' hsetprop ${scobj_hpath} klass %s' % MyDriver['class']]
|
||||
txt += [' hsetprop ${scobj_hpath} klass ${device_class}']
|
||||
txt += [' hsetprop ${scobj_hpath} data true']
|
||||
txt += [' hsetprop ${scobj_hpath} debug_threshold %s' % str(MyDriver['debug_threshold'])]
|
||||
if len(MyDriver['Deferred']) > 0:
|
||||
txt += [' if {[string equal -nocase [SplitReply [%s]] "false"]} {' % MyDriver['simulation_group']]
|
||||
txt += [' if {[string equal -nocase "${simulation_flag}" "false"]} {']
|
||||
for line in MyDriver['Deferred']:
|
||||
txt += [' ' + line]
|
||||
txt += [' }']
|
||||
@ -1458,28 +1458,21 @@ def put_mkDriver(MyDriver):
|
||||
|
||||
def put_postamble(MyDriver):
|
||||
txt = ['']
|
||||
txt += ['namespace eval %s {' % MyDriver['namespace']]
|
||||
txt += [' namespace export debug_threshold']
|
||||
txt += [' namespace export debug_log']
|
||||
txt += [' namespace export sics_log']
|
||||
txt += [' namespace export mkDriver']
|
||||
txt += ['}']
|
||||
txt += ['']
|
||||
if 'add_args' in MyDriver:
|
||||
line = 'proc add_%s {name ip_address tcp_port %s} {' % (MyDriver['name'], MyDriver['add_args'])
|
||||
line = 'proc %s::add_driver {name device_class simulation_flag ip_address tcp_port %s} {' % (MyDriver['namespace'], MyDriver['add_args'])
|
||||
else:
|
||||
line = 'proc add_%s {name ip_address tcp_port} {' % MyDriver['name']
|
||||
line = 'proc %s::add_driver {name device_class simulation_flag ip_address tcp_port} {' % (MyDriver['namespace'])
|
||||
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_address} ${tcp_port} %s"' % (MyDriver['namespace'], MyDriver['name'], make_args)]
|
||||
txt += [' %s::sics_log 9 "%s::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} %s"' % (MyDriver['namespace'], MyDriver['namespace'], make_args)]
|
||||
else:
|
||||
txt += [' %s::sics_log 9 "add_%s ${name} ${ip_address} ${tcp_port}"' % (MyDriver['namespace'], MyDriver['name'])]
|
||||
txt += [' %s::sics_log 9 "%s::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}"' % (MyDriver['namespace'], MyDriver['namespace'])]
|
||||
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 "${simulation_flag}" "false"]} {']
|
||||
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}']
|
||||
@ -1493,15 +1486,15 @@ def put_postamble(MyDriver):
|
||||
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 += [' %s::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for %s"' % (MyDriver['namespace'], 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} ${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)]
|
||||
txt += [' %s::sics_log 1 "%s::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} %s"' % (MyDriver['namespace'], MyDriver['namespace'], make_args)]
|
||||
txt += [' %s::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} %s' % (MyDriver['namespace'], make_args)]
|
||||
else:
|
||||
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'])]
|
||||
txt += [' %s::sics_log 1 "%s::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}"' % (MyDriver['namespace'], MyDriver['namespace'])]
|
||||
txt += [' %s::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${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']
|
||||
@ -1509,6 +1502,27 @@ def put_postamble(MyDriver):
|
||||
txt += [' handle_exception ${catch_status} ${catch_message}']
|
||||
txt += ['}']
|
||||
txt += ['']
|
||||
txt += ['namespace eval %s {' % MyDriver['namespace']]
|
||||
txt += [' namespace export debug_threshold']
|
||||
txt += [' namespace export debug_log']
|
||||
txt += [' namespace export sics_log']
|
||||
txt += [' namespace export mkDriver']
|
||||
txt += [' namespace export add_driver']
|
||||
txt += ['}']
|
||||
txt += ['']
|
||||
if 'add_args' in MyDriver:
|
||||
line = 'proc add_%s {name ip_address tcp_port %s} {' % (MyDriver['name'], MyDriver['add_args'])
|
||||
else:
|
||||
line = 'proc add_%s {name ip_address tcp_port} {' % MyDriver['name']
|
||||
txt += [line]
|
||||
txt += [' set simulation_flag "[string tolower [SplitReply [%s]]]"' % MyDriver['simulation_group']]
|
||||
line = ' %s::add_driver ${name} "%s" "${simulation_flag}" ${ip_address} ${tcp_port}' % (MyDriver['namespace'], MyDriver['class'])
|
||||
if 'add_args' in MyDriver:
|
||||
for arg in MyDriver['add_args'].split():
|
||||
line += ' "${%s}"' % arg
|
||||
txt += [line]
|
||||
txt += ['}']
|
||||
txt += ['']
|
||||
txt += ['clientput "file evaluation of sct_%s.tcl"' % MyDriver['name']]
|
||||
txt += ['%s::sics_log 9 "file evaluation of sct_%s.tcl"' % (MyDriver['namespace'], MyDriver['name'])]
|
||||
emit(txt)
|
||||
@ -1520,6 +1534,8 @@ def put_read_config(MyDriver):
|
||||
txt += [' set ns "%s"' % MyDriver['namespace']]
|
||||
txt += [' dict for {k u} $::config_dict {']
|
||||
txt += [' if { [dict exists $u "implementation"] } {']
|
||||
txt += [' set simulation_flag "[string tolower [SplitReply [%s]]]"' % MyDriver['simulation_group']]
|
||||
txt += [' set device_class "%s"' % MyDriver['class']]
|
||||
txt += [' if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } {']
|
||||
txt += [' continue']
|
||||
txt += [' }']
|
||||
@ -1527,6 +1543,12 @@ def put_read_config(MyDriver):
|
||||
txt += [' if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } {']
|
||||
txt += [' continue']
|
||||
txt += [' }']
|
||||
txt += [' if { [dict exists $u "simulation_group"] } {']
|
||||
txt += [' set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]]']
|
||||
txt += [' }']
|
||||
txt += [' if { [dict exists $u "device_class"] } {']
|
||||
txt += [' set device_class "[dict get $u "device_class"]"']
|
||||
txt += [' }']
|
||||
txt += [' set name [dict get $u name]']
|
||||
txt += [' set implementation [dict get $u "implementation"]']
|
||||
txt += [' if { !([dict exists $::config_dict $implementation]) } {']
|
||||
@ -1537,9 +1559,9 @@ def put_read_config(MyDriver):
|
||||
txt += [' continue']
|
||||
txt += [' }']
|
||||
txt += [' if { [string equal -nocase [dict get $v "driver"] "%s"] } {' % MyDriver['name']]
|
||||
txt += [' if { ![string equal -nocase [SplitReply [%s]] "false"] } {' % MyDriver['simulation_group']]
|
||||
txt += [' if { ![string equal -nocase "${simulation_flag}" "false"] } {']
|
||||
txt += [' set asyncqueue "null"']
|
||||
txt += [' ${ns}::sics_log 9 "[%s] => using null asyncqueue"' % MyDriver['simulation_group']]
|
||||
txt += [' ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue"']
|
||||
txt += [' } elseif { [dict exists $v "asyncqueue"] } {']
|
||||
txt += [' set asyncqueue [dict get $v "asyncqueue"]']
|
||||
txt += [' if { [string equal -nocase ${asyncqueue} "sct"] } {']
|
||||
@ -1582,15 +1604,15 @@ 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_address} ${tcp_port} {*}$arg_list' % MyDriver['name']]
|
||||
txt += [' ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list']
|
||||
txt += [' } else {']
|
||||
txt += [' add_%s ${name} "aqadapter" ${asyncqueue} {*}$arg_list' % MyDriver['name']]
|
||||
txt += [' ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list']
|
||||
txt += [' }']
|
||||
else:
|
||||
txt += [' if { [string equal -nocase ${asyncqueue} "sct"] } {']
|
||||
txt += [' add_%s ${name} ${ip_address} ${tcp_port}' % MyDriver['name']]
|
||||
txt += [' ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}']
|
||||
txt += [' } else {']
|
||||
txt += [' add_%s ${name} "aqadapter" ${asyncqueue}' % MyDriver['name']]
|
||||
txt += [' ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue}']
|
||||
txt += [' }']
|
||||
txt += [' }']
|
||||
txt += [' }']
|
||||
|
Reference in New Issue
Block a user