Fixed some flaws in execute/execute_wait/simulate procedures (Simulate button was not cleared after a foreground simulation)

This commit is contained in:
Stefan Schippers 2020-09-24 02:20:09 +02:00
parent b7d724dcab
commit da74e5ad36
1 changed files with 15 additions and 12 deletions

View File

@ -39,7 +39,7 @@ proc set_ne { var val } {
### ###
# execute service function # execute service function
proc execute_fileevent {id} { proc execute_fileevent {id} {
global execute_id execute_pipe execute_data execute_cmd execute_wait_flag simulate_oldbg global execute_pipe execute_data execute_cmd simulate_oldbg
global execute_status execute_callback global execute_status execute_callback
append execute_data($id) [read $execute_pipe($id) 1024] append execute_data($id) [read $execute_pipe($id) 1024]
if {[eof $execute_pipe($id)]} { if {[eof $execute_pipe($id)]} {
@ -56,6 +56,7 @@ proc execute_fileevent {id} {
} }
} else { } else {
if { $execute_status($id) } { if { $execute_status($id) } {
set status 1
viewdata "Completed: $execute_cmd($id)\nstderr:\n$err\ndata:\n$execute_data($id)" ro viewdata "Completed: $execute_cmd($id)\nstderr:\n$err\ndata:\n$execute_data($id)" ro
} }
} }
@ -75,13 +76,11 @@ proc execute_fileevent {id} {
proc execute_wait {status args} { proc execute_wait {status args} {
global execute_pipe execute_wait_flag global execute_pipe
xschem set semaphore [expr [xschem get semaphore] +1] xschem set semaphore [expr [xschem get semaphore] +1]
set execute_wait_flag 1
set id [eval execute $status $args] set id [eval execute $status $args]
vwait execute_pipe($id) vwait execute_pipe($id)
xschem set semaphore [expr [xschem get semaphore] -1] xschem set semaphore [expr [xschem get semaphore] -1]
unset execute_wait_flag
return $id return $id
} }
@ -98,15 +97,15 @@ proc execute {status args} {
} else { } else {
incr execute_id incr execute_id
} }
set pipe [open "|$args" r]
set execute_status($execute_id) $status
set execute_pipe($execute_id) $pipe
set execute_cmd($execute_id) $args
set execute_data($execute_id) ""
set id $execute_id set id $execute_id
set pipe [open "|$args" r]
set execute_status($id) $status
set execute_pipe($id) $pipe
set execute_cmd($id) $args
set execute_data($id) ""
fconfigure $pipe -blocking 0 fconfigure $pipe -blocking 0
fileevent $pipe readable "execute_fileevent $id" fileevent $pipe readable "execute_fileevent $id"
return $execute_id return $id
} }
proc netlist {source_file show netlist_file} { proc netlist {source_file show netlist_file} {
@ -668,7 +667,7 @@ proc simulate {{callback {}}} {
## $d : netlist directory ## $d : netlist directory
global netlist_dir netlist_type computerfarm terminal current_dirname sim global netlist_dir netlist_type computerfarm terminal current_dirname sim
global execute_callback global execute_callback XSCHEM_SHAREDIR
set_sim_defaults set_sim_defaults
if { [select_netlist_dir 0] ne {}} { if { [select_netlist_dir 0] ne {}} {
@ -695,9 +694,13 @@ proc simulate {{callback {}}} {
} else { } else {
set id [$fg $st sh -c "cd $netlist_dir; $cmd"] set id [$fg $st sh -c "cd $netlist_dir; $cmd"]
set execute_callback($id) $callback set execute_callback($id) $callback
if {$fg eq {execute_wait}} {
eval $execute_callback($id); unset execute_callback($id)
}
} }
} }
} }
proc gaw_echoline {} { proc gaw_echoline {} {
global gaw_fd global gaw_fd
gets $gaw_fd line gets $gaw_fd line
@ -756,7 +759,7 @@ proc waves {} {
## $s : schematic name (opamp) ## $s : schematic name (opamp)
## $d : netlist directory ## $d : netlist directory
global netlist_dir netlist_type computerfarm terminal current_dirname sim gaw_fd global netlist_dir netlist_type computerfarm terminal current_dirname sim gaw_fd XSCHEM_SHAREDIR
set_sim_defaults set_sim_defaults
if { [select_netlist_dir 0] ne {}} { if { [select_netlist_dir 0] ne {}} {