Wrap generated driver code in 'catch' and handle_exception blocks
This commit is contained in:
@ -7,16 +7,19 @@ namespace eval ::scobj::shutters {
|
||||
}
|
||||
|
||||
proc ::scobj::shutters::debug_log {debug_level debug_string} {
|
||||
set catch_status [ catch {
|
||||
if {${debug_level} >= ${::scobj::shutters::debug_threshold}} {
|
||||
set fd [open "/tmp/shutters.log" "a"]
|
||||
set line "[clock format [clock seconds] -format "%T"] ${debug_string}"
|
||||
puts ${fd} "${line}"
|
||||
close ${fd}
|
||||
}
|
||||
} catch_message ]
|
||||
}
|
||||
|
||||
# check function for hset change
|
||||
proc ::scobj::shutters::checkrange {tc_root} {
|
||||
set catch_status [ catch {
|
||||
debug_log 1 "checkrange tc_root=${tc_root} sct=[sct] target=[sct target]"
|
||||
set setpoint [sct target]
|
||||
if { [hpropexists [sct] lowerlimit] } {
|
||||
@ -35,10 +38,13 @@ proc ::scobj::shutters::checkrange {tc_root} {
|
||||
error "setpoint ${setpoint} violates limits (${lolimit}..${hilimit}) on [sct]"
|
||||
}
|
||||
return OK
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
# function to request the read of a parameter on a device
|
||||
proc ::scobj::shutters::getValue {tc_root nextState cmd_str} {
|
||||
set catch_status [ catch {
|
||||
debug_log 1 "getValue tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
hdelprop [sct] geterror
|
||||
@ -47,16 +53,22 @@ proc ::scobj::shutters::getValue {tc_root nextState cmd_str} {
|
||||
debug_log 1 "getValue sct send ${cmd}"
|
||||
sct send "${cmd}"
|
||||
return ${nextState}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
# function to check the write parameter on a device
|
||||
proc ::scobj::shutters::noResponse {tc_root} {
|
||||
set catch_status [ catch {
|
||||
debug_log 1 "noResponse tc_root=${tc_root} sct=[sct] resp=[sct result]"
|
||||
return "idle"
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
# function to parse the read of a parameter on a device
|
||||
proc ::scobj::shutters::read_switch_pair {tc_root} {
|
||||
set catch_status [ catch {
|
||||
debug_log 1 "read_switch_pair tc_root=${tc_root} sct=[sct] result=[sct result]"
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
hdelprop [sct] geterror
|
||||
@ -66,7 +78,7 @@ proc ::scobj::shutters::read_switch_pair {tc_root} {
|
||||
if {[string equal -nocase -length 7 ${data} "ASCERR:"]} {
|
||||
# the protocol driver has reported an error
|
||||
sct geterror "${data}"
|
||||
return -code error "[sct geterror]"
|
||||
error "[sct geterror]"
|
||||
}
|
||||
# hook code starts
|
||||
if { [string equal -nocase -length 1 "${data}" "?"] } {
|
||||
@ -93,7 +105,7 @@ proc ::scobj::shutters::read_switch_pair {tc_root} {
|
||||
# hook code ends
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
debug_log 1 "[sct] error: [sct geterror]"
|
||||
return -code error "[sct geterror]"
|
||||
error "[sct geterror]"
|
||||
}
|
||||
if { ${data} != [sct oldval] } {
|
||||
debug_log 1 "[sct] changed to new:${data}, from old:[sct oldval]"
|
||||
@ -102,10 +114,13 @@ proc ::scobj::shutters::read_switch_pair {tc_root} {
|
||||
sct utime readtime
|
||||
}
|
||||
return ${nextState}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
# function to write a parameter value on a device
|
||||
proc ::scobj::shutters::setValue {tc_root nextState cmd_str} {
|
||||
set catch_status [ catch {
|
||||
debug_log 1 "setValue tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
hdelprop [sct] geterror
|
||||
@ -122,10 +137,13 @@ proc ::scobj::shutters::setValue {tc_root nextState cmd_str} {
|
||||
sct send "${cmd}"
|
||||
}
|
||||
return ${nextState}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
# function to write a parameter value on a device
|
||||
proc ::scobj::shutters::write_switch {tc_root nextState cmd_str} {
|
||||
set catch_status [ catch {
|
||||
debug_log 1 "write_switch tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
hdelprop [sct] geterror
|
||||
@ -143,7 +161,7 @@ proc ::scobj::shutters::write_switch {tc_root nextState cmd_str} {
|
||||
# hook code ends
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
debug_log 1 "[sct] error: [sct geterror]"
|
||||
return -code error "[sct geterror]"
|
||||
error "[sct geterror]"
|
||||
}
|
||||
if { [hpropexists [sct] driving] } {
|
||||
if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } {
|
||||
@ -155,6 +173,8 @@ proc ::scobj::shutters::write_switch {tc_root nextState cmd_str} {
|
||||
sct send "${cmd}"
|
||||
}
|
||||
return ${nextState}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
proc ::scobj::shutters::mk_sct_shutters { sct_controller name } {
|
||||
@ -230,7 +250,7 @@ proc ::scobj::shutters::mk_sct_shutters { sct_controller name } {
|
||||
# hook code starts
|
||||
# hook code ends
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message} "in ${ns}::mk_sct_shutters"
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
namespace eval ::scobj::shutters {
|
||||
@ -239,6 +259,7 @@ namespace eval ::scobj::shutters {
|
||||
}
|
||||
|
||||
proc add_shutters {name IP port} {
|
||||
set catch_status [ catch {
|
||||
set ns "::scobj::shutters"
|
||||
${ns}::debug_log 1 "add_shutters ${name} ${IP} ${port}"
|
||||
if {[SplitReply [motor_simulation]]=="false"} {
|
||||
@ -253,6 +274,8 @@ proc add_shutters {name IP port} {
|
||||
${ns}::debug_log 1 "mk_sct_shutters sct_${name} ${name}"
|
||||
${ns}::mk_sct_shutters sct_${name} ${name}
|
||||
close ${fd}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
puts stdout "file evaluation of sct_shutters.tcl"
|
||||
|
@ -7,16 +7,19 @@ namespace eval ::scobj::tank {
|
||||
}
|
||||
|
||||
proc ::scobj::tank::debug_log {debug_level debug_string} {
|
||||
set catch_status [ catch {
|
||||
if {${debug_level} >= ${::scobj::tank::debug_threshold}} {
|
||||
set fd [open "/tmp/tank.log" "a"]
|
||||
set line "[clock format [clock seconds] -format "%T"] ${debug_string}"
|
||||
puts ${fd} "${line}"
|
||||
close ${fd}
|
||||
}
|
||||
} catch_message ]
|
||||
}
|
||||
|
||||
# check function for hset change
|
||||
proc ::scobj::tank::checkrange {tc_root} {
|
||||
set catch_status [ catch {
|
||||
debug_log 1 "checkrange tc_root=${tc_root} sct=[sct] target=[sct target]"
|
||||
set setpoint [sct target]
|
||||
if { [hpropexists [sct] lowerlimit] } {
|
||||
@ -35,10 +38,13 @@ proc ::scobj::tank::checkrange {tc_root} {
|
||||
error "setpoint ${setpoint} violates limits (${lolimit}..${hilimit}) on [sct]"
|
||||
}
|
||||
return OK
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
# function to request the read of a parameter on a device
|
||||
proc ::scobj::tank::getValue {tc_root nextState cmd_str} {
|
||||
set catch_status [ catch {
|
||||
debug_log 1 "getValue tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
hdelprop [sct] geterror
|
||||
@ -47,16 +53,22 @@ proc ::scobj::tank::getValue {tc_root nextState cmd_str} {
|
||||
debug_log 1 "getValue sct send ${cmd}"
|
||||
sct send "${cmd}"
|
||||
return ${nextState}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
# function to check the write parameter on a device
|
||||
proc ::scobj::tank::noResponse {tc_root} {
|
||||
set catch_status [ catch {
|
||||
debug_log 1 "noResponse tc_root=${tc_root} sct=[sct] resp=[sct result]"
|
||||
return "idle"
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
# function to parse the read of a parameter on a device
|
||||
proc ::scobj::tank::read_switch {tc_root} {
|
||||
set catch_status [ catch {
|
||||
debug_log 1 "read_switch tc_root=${tc_root} sct=[sct] result=[sct result]"
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
hdelprop [sct] geterror
|
||||
@ -66,7 +78,7 @@ proc ::scobj::tank::read_switch {tc_root} {
|
||||
if {[string equal -nocase -length 7 ${data} "ASCERR:"]} {
|
||||
# the protocol driver has reported an error
|
||||
sct geterror "${data}"
|
||||
return -code error "[sct geterror]"
|
||||
error "[sct geterror]"
|
||||
}
|
||||
# hook code starts
|
||||
if { [string equal -nocase -length 1 "${data}" "?"] } {
|
||||
@ -90,7 +102,7 @@ proc ::scobj::tank::read_switch {tc_root} {
|
||||
# hook code ends
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
debug_log 1 "[sct] error: [sct geterror]"
|
||||
return -code error "[sct geterror]"
|
||||
error "[sct geterror]"
|
||||
}
|
||||
if { ${data} != [sct oldval] } {
|
||||
debug_log 1 "[sct] changed to new:${data}, from old:[sct oldval]"
|
||||
@ -99,10 +111,13 @@ proc ::scobj::tank::read_switch {tc_root} {
|
||||
sct utime readtime
|
||||
}
|
||||
return ${nextState}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
# function to write a parameter value on a device
|
||||
proc ::scobj::tank::setValue {tc_root nextState cmd_str} {
|
||||
set catch_status [ catch {
|
||||
debug_log 1 "setValue tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
hdelprop [sct] geterror
|
||||
@ -119,6 +134,8 @@ proc ::scobj::tank::setValue {tc_root nextState cmd_str} {
|
||||
sct send "${cmd}"
|
||||
}
|
||||
return ${nextState}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
proc ::scobj::tank::mk_sct_tank { sct_controller name } {
|
||||
@ -186,7 +203,7 @@ proc ::scobj::tank::mk_sct_tank { sct_controller name } {
|
||||
# hook code starts
|
||||
# hook code ends
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message} "in ${ns}::mk_sct_tank"
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
namespace eval ::scobj::tank {
|
||||
@ -195,6 +212,7 @@ namespace eval ::scobj::tank {
|
||||
}
|
||||
|
||||
proc add_tank {name IP port} {
|
||||
set catch_status [ catch {
|
||||
set ns "::scobj::tank"
|
||||
${ns}::debug_log 1 "add_tank ${name} ${IP} ${port}"
|
||||
if {[SplitReply [motor_simulation]]=="false"} {
|
||||
@ -209,6 +227,8 @@ proc add_tank {name IP port} {
|
||||
${ns}::debug_log 1 "mk_sct_tank sct_${name} ${name}"
|
||||
${ns}::mk_sct_tank sct_${name} ${name}
|
||||
close ${fd}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
puts stdout "file evaluation of sct_tank.tcl"
|
||||
|
@ -745,12 +745,14 @@ def put_preamble(MyDriver):
|
||||
txt += ['}']
|
||||
txt += ['']
|
||||
txt += ['proc %s::debug_log {debug_level debug_string} {' % MyDriver['namespace']]
|
||||
txt += [' set catch_status [ catch {']
|
||||
txt += [' if {${debug_level} >= ${%s::debug_threshold}} {' % MyDriver['namespace']]
|
||||
txt += [' set fd [open "/tmp/%s.log" "a"]' % MyDriver['name']]
|
||||
txt += [' set line "[clock format [clock seconds] -format "%T"] ${debug_string}"']
|
||||
txt += [' puts ${fd} "${line}"']
|
||||
txt += [' close ${fd}']
|
||||
txt += [' }']
|
||||
txt += [' } catch_message ]']
|
||||
txt += ['}']
|
||||
emit(txt)
|
||||
|
||||
@ -758,6 +760,7 @@ def put_write_function(MyDriver, func):
|
||||
txt = ['']
|
||||
txt += ['# function to write a parameter value on a device']
|
||||
txt += ['proc %s::%s {tc_root nextState cmd_str} {' % (MyDriver['namespace'], func)]
|
||||
txt += [' set catch_status [ catch {']
|
||||
txt += [' debug_log 1 "%s tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"' % func]
|
||||
txt += [' if { [hpropexists [sct] geterror] } {']
|
||||
txt += [' hdelprop [sct] geterror']
|
||||
@ -770,7 +773,7 @@ def put_write_function(MyDriver, func):
|
||||
txt += ['# hook code ends']
|
||||
txt += [' if { [hpropexists [sct] geterror] } {']
|
||||
txt += [' debug_log 1 "[sct] error: [sct geterror]"']
|
||||
txt += [' return -code error "[sct geterror]"']
|
||||
txt += [' error "[sct geterror]"']
|
||||
txt += [' }']
|
||||
txt += [' if { [hpropexists [sct] driving] } {']
|
||||
txt += [' if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } {']
|
||||
@ -782,6 +785,8 @@ def put_write_function(MyDriver, func):
|
||||
txt += [' sct send "${cmd}"']
|
||||
txt += [' }']
|
||||
txt += [' return ${nextState}']
|
||||
txt += [' } catch_message ]']
|
||||
txt += [' handle_exception ${catch_status} ${catch_message}']
|
||||
txt += ['}']
|
||||
emit(txt)
|
||||
|
||||
@ -789,12 +794,15 @@ def put_check_function(MyDriver, func):
|
||||
txt = ['']
|
||||
txt += ['# function to check the write parameter on a device']
|
||||
txt += ['proc %s::%s {tc_root} {' % (MyDriver['namespace'], func)]
|
||||
txt += [' set catch_status [ catch {']
|
||||
txt += [' debug_log 1 "%s tc_root=${tc_root} sct=[sct] resp=[sct result]"' % func]
|
||||
if func in MyDriver['Funcs'] and len(MyDriver['Funcs'][func]['text']) > 0:
|
||||
txt += ['# hook code starts']
|
||||
txt += MyDriver['Funcs'][func]['text']
|
||||
txt += ['# hook code ends']
|
||||
txt += [' return "idle"']
|
||||
txt += [' } catch_message ]']
|
||||
txt += [' handle_exception ${catch_status} ${catch_message}']
|
||||
txt += ['}']
|
||||
emit(txt)
|
||||
|
||||
@ -802,6 +810,7 @@ def put_fetch_function(MyDriver, func):
|
||||
txt = ['']
|
||||
txt += ['# function to request the read of a parameter on a device']
|
||||
txt += ['proc %s::%s {tc_root nextState cmd_str} {' % (MyDriver['namespace'], func)]
|
||||
txt += [' set catch_status [ catch {']
|
||||
txt += [' debug_log 1 "%s tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"' % func]
|
||||
txt += [' if { [hpropexists [sct] geterror] } {']
|
||||
txt += [' hdelprop [sct] geterror']
|
||||
@ -813,11 +822,13 @@ def put_fetch_function(MyDriver, func):
|
||||
txt += ['# hook code ends']
|
||||
txt += [' if { [hpropexists [sct] geterror] } {']
|
||||
txt += [' debug_log 1 "[sct] error: [sct geterror]"']
|
||||
txt += [' return -code error "[sct geterror]"']
|
||||
txt += [' error "[sct geterror]"']
|
||||
txt += [' }']
|
||||
txt += [' debug_log 1 "%s sct send ${cmd}"' % func]
|
||||
txt += [' sct send "${cmd}"']
|
||||
txt += [' return ${nextState}']
|
||||
txt += [' } catch_message ]']
|
||||
txt += [' handle_exception ${catch_status} ${catch_message}']
|
||||
txt += ['}']
|
||||
emit(txt)
|
||||
|
||||
@ -825,6 +836,7 @@ def put_read_function(MyDriver, func):
|
||||
txt = ['']
|
||||
txt += ['# function to parse the read of a parameter on a device']
|
||||
txt += ['proc %s::%s {tc_root} {' % (MyDriver['namespace'], func)]
|
||||
txt += [' set catch_status [ catch {']
|
||||
txt += [' debug_log 1 "%s tc_root=${tc_root} sct=[sct] result=[sct result]"' % func]
|
||||
txt += [' if { [hpropexists [sct] geterror] } {']
|
||||
txt += [' hdelprop [sct] geterror']
|
||||
@ -834,7 +846,7 @@ def put_read_function(MyDriver, func):
|
||||
txt += [' if {[string equal -nocase -length 7 ${data} "ASCERR:"]} {']
|
||||
txt += [' # the protocol driver has reported an error']
|
||||
txt += [' sct geterror "${data}"']
|
||||
txt += [' return -code error "[sct geterror]"']
|
||||
txt += [' error "[sct geterror]"']
|
||||
txt += [' }']
|
||||
if func in MyDriver['Funcs'] and len(MyDriver['Funcs'][func]['text']) > 0:
|
||||
txt += ['# hook code starts']
|
||||
@ -842,7 +854,7 @@ def put_read_function(MyDriver, func):
|
||||
txt += ['# hook code ends']
|
||||
txt += [' if { [hpropexists [sct] geterror] } {']
|
||||
txt += [' debug_log 1 "[sct] error: [sct geterror]"']
|
||||
txt += [' return -code error "[sct geterror]"']
|
||||
txt += [' error "[sct geterror]"']
|
||||
txt += [' }']
|
||||
txt += [' if { ${data} != [sct oldval] } {']
|
||||
txt += [' debug_log 1 "[sct] changed to new:${data}, from old:[sct oldval]"']
|
||||
@ -851,6 +863,8 @@ def put_read_function(MyDriver, func):
|
||||
txt += [' sct utime readtime']
|
||||
txt += [' }']
|
||||
txt += [' return ${nextState}']
|
||||
txt += [' } catch_message ]']
|
||||
txt += [' handle_exception ${catch_status} ${catch_message}']
|
||||
txt += ['}']
|
||||
emit(txt)
|
||||
|
||||
@ -858,6 +872,7 @@ def put_checkrange_function(MyDriver, func):
|
||||
txt = ['']
|
||||
txt += ['# check function for hset change']
|
||||
txt += ['proc %s::%s {tc_root} {' % (MyDriver['namespace'], func)]
|
||||
txt += [' set catch_status [ catch {']
|
||||
txt += [' debug_log 1 "%s tc_root=${tc_root} sct=[sct] target=[sct target]"' % func]
|
||||
txt += [' set setpoint [sct target]']
|
||||
txt += [' if { [hpropexists [sct] lowerlimit] } {']
|
||||
@ -880,6 +895,8 @@ def put_checkrange_function(MyDriver, func):
|
||||
txt += [' error "setpoint ${setpoint} violates limits (${lolimit}..${hilimit}) on [sct]"']
|
||||
txt += [' }']
|
||||
txt += [' return OK']
|
||||
txt += [' } catch_message ]']
|
||||
txt += [' handle_exception ${catch_status} ${catch_message}']
|
||||
txt += ['}']
|
||||
emit(txt)
|
||||
|
||||
@ -887,6 +904,7 @@ def put_checklimits_function(MyDriver, func):
|
||||
txt = ['']
|
||||
txt += ['# checklimits function for driveable interface']
|
||||
txt += ['proc %s::%s {tc_root} {' % (MyDriver['namespace'], func)]
|
||||
txt += [' set catch_status [ catch {']
|
||||
txt += [' debug_log 1 "%s tc_root=${tc_root} sct=[sct] target=[sct target]"' % func]
|
||||
txt += [' set setpoint [sct target]']
|
||||
txt += [' if { [hpropexists [sct] lowerlimit] } {']
|
||||
@ -910,6 +928,8 @@ def put_checklimits_function(MyDriver, func):
|
||||
txt += [' error "setpoint ${setpoint} violates limits (${lolimit}..${hilimit}) on [sct]"']
|
||||
txt += [' }']
|
||||
txt += [' return OK']
|
||||
txt += [' } catch_message ]']
|
||||
txt += [' handle_exception ${catch_status} ${catch_message}']
|
||||
txt += ['}']
|
||||
emit(txt)
|
||||
|
||||
@ -917,6 +937,7 @@ def put_checkstatus_function(MyDriver, func):
|
||||
txt = ['']
|
||||
txt += ['# checkstatus function for driveable interface']
|
||||
txt += ['proc %s::%s {tc_root} {' % (MyDriver['namespace'], func)]
|
||||
txt += [' set catch_status [ catch {']
|
||||
if func in MyDriver['Funcs'] and len(MyDriver['Funcs'][func]['text']) > 0:
|
||||
txt += ['# hook code starts']
|
||||
txt += MyDriver['Funcs'][func]['text']
|
||||
@ -932,6 +953,8 @@ def put_checkstatus_function(MyDriver, func):
|
||||
txt += [' } else {']
|
||||
txt += [' return "idle"']
|
||||
txt += [' }']
|
||||
txt += [' } catch_message ]']
|
||||
txt += [' handle_exception ${catch_status} ${catch_message}']
|
||||
txt += ['}']
|
||||
emit(txt)
|
||||
|
||||
@ -939,6 +962,7 @@ def put_halt_function(MyDriver, func):
|
||||
txt = ['']
|
||||
txt += ['# halt function for driveable interface']
|
||||
txt += ['proc %s::%s {tc_root} {' % (MyDriver['namespace'], func)]
|
||||
txt += [' set catch_status [ catch {']
|
||||
txt += [' debug_log 1 "%s tc_root=${tc_root} sct=[sct] driving=[sct driving]"' % func]
|
||||
txt += [' ### TODO hset [sct] [hval [sct]]']
|
||||
if func in MyDriver['Funcs'] and len(MyDriver['Funcs'][func]['text']) > 0:
|
||||
@ -947,6 +971,8 @@ def put_halt_function(MyDriver, func):
|
||||
txt += ['# hook code ends']
|
||||
txt += [' sct driving 0']
|
||||
txt += [' return "idle"']
|
||||
txt += [' } catch_message ]']
|
||||
txt += [' handle_exception ${catch_status} ${catch_message}']
|
||||
txt += ['}']
|
||||
emit(txt)
|
||||
|
||||
@ -954,6 +980,7 @@ def put_pid_function(MyDriver, func):
|
||||
txt = ['']
|
||||
txt += ['# pid function for PID control']
|
||||
txt += ['proc %s::%s {tc_root sp pv} {' % (MyDriver['namespace'], func)]
|
||||
txt += [' set catch_status [ catch {']
|
||||
txt += [' debug_log 1 "%s tc_root=${tc_root} sct=[sct] pv=${pv} sp=${sp}"' % func]
|
||||
txt += [' sct pid_error [expr ${sp} - ${pv}]']
|
||||
txt += [' set p_value [expr [sct pid_pvalue] * [sct pid_error]]']
|
||||
@ -973,6 +1000,8 @@ def put_pid_function(MyDriver, func):
|
||||
txt += MyDriver['Funcs'][func]['text']
|
||||
txt += ['# hook code ends']
|
||||
txt += [' sct pid_output ${pid}']
|
||||
txt += [' } catch_message ]']
|
||||
txt += [' handle_exception ${catch_status} ${catch_message}']
|
||||
txt += [' return ${pid}']
|
||||
txt += ['}']
|
||||
emit(txt)
|
||||
@ -1134,7 +1163,7 @@ def put_mk_sct_driver(MyDriver):
|
||||
txt += MyDriver['Funcs']['mkDriver']['text']
|
||||
txt += ['# hook code ends']
|
||||
txt += [' } catch_message ]']
|
||||
txt += [' handle_exception ${catch_status} ${catch_message} "in ${ns}::mk_sct_%s"' % MyDriver['name']]
|
||||
txt += [' handle_exception ${catch_status} ${catch_message}']
|
||||
txt += ['}']
|
||||
emit(txt)
|
||||
|
||||
@ -1150,6 +1179,7 @@ def put_postamble(MyDriver):
|
||||
else:
|
||||
line = 'proc add_%s {name IP port} {' % MyDriver['name']
|
||||
txt += [line]
|
||||
txt += [' set catch_status [ catch {']
|
||||
txt += [' set ns "%s"' % MyDriver['namespace']]
|
||||
txt += [' ${ns}::debug_log 1 "add_%s ${name} ${IP} ${port}"' % MyDriver['name']]
|
||||
txt += [' if {[SplitReply [%s]]=="false"} {' % MyDriver['simulation_group']]
|
||||
@ -1181,6 +1211,8 @@ def put_postamble(MyDriver):
|
||||
#txt += [' ${ns}::debug_log 1 "makesctemon ${name} /sics/${name}/emon/monmode /sics/${name}/emon/isintol /sics/${name}/emon/errhandler"']
|
||||
# txt += [' makesctemon ${name} /sics/${name}/emon/monmode /sics/${name}/emon/isintol /sics/${name}/emon/errhandler']
|
||||
txt += [' close ${fd}']
|
||||
txt += [' } catch_message ]']
|
||||
txt += [' handle_exception ${catch_status} ${catch_message}']
|
||||
txt += ['}']
|
||||
txt += ['']
|
||||
txt += ['puts stdout "file evaluation of sct_%s.tcl"' % MyDriver['name']]
|
||||
|
Reference in New Issue
Block a user