Commit 5566d877 authored by Pierre-Antoine Rouby's avatar Pierre-Antoine Rouby
Browse files

Solver: Fix run order.

Showing with 35 additions and 21 deletions
+35 -21
......@@ -149,6 +149,7 @@ class AbstractSolver(object):
def run_input_data_fomater(self):
if self._cmd_input == "":
self._run_next()
return True
cmd = self._cmd_input
......@@ -156,7 +157,7 @@ class AbstractSolver(object):
cmd = cmd.replace("@input", self.input_param())
cmd = cmd.replace("@dir", self._process.workingDirectory())
print(f"+ {cmd}")
print(f"! {cmd}")
cmd = cmd.split()
exe = cmd[0]
......@@ -169,7 +170,9 @@ class AbstractSolver(object):
return True
def run_solver(self):
print("run solver")
if self._cmd_solver == "":
self._run_next()
return True
cmd = self._cmd_solver
......@@ -177,7 +180,7 @@ class AbstractSolver(object):
cmd = cmd.replace("@input", self.input_param())
cmd = cmd.replace("@dir", self._process.workingDirectory())
print(f"+ {cmd}")
print(f"! {cmd}")
cmd = cmd.split()
exe = cmd[0]
......@@ -192,13 +195,15 @@ class AbstractSolver(object):
def run_output_data_fomater(self):
if self._cmd_output == "":
self._run_next()
return True
cmd = self._cmd_output
cmd = cmd.replace("@path", self._path_output)
cmd = cmd.replace("@input", self.input_param())
cmd = cmd.replace("@dir", self._process.workingDirectory())
print(f"+ {cmd}")
print(f"! {cmd}")
cmd = cmd.split()
exe = cmd[0]
......@@ -216,32 +221,36 @@ class AbstractSolver(object):
for x in s.split('\n'):
self._output.put(x)
def _finished(self, exit_code, exit_status):
if self._output is not None:
self._output.put(exit_code)
def _run_next(self):
self._step += 1
if self._step < len(self._runs):
self._runs[self._step]()
self._step += 1
else:
self._status = STATUS.STOPED
def run(self, process, output_queue):
self._process = process
self._output = output_queue
def _finished(self, exit_code, exit_status):
if self._output is not None:
self._output.put(exit_code)
self._run_next()
def run(self, process = None, output_queue = None):
if process is not None:
self._process = process
if output_queue is not None:
self._output = output_queue
self._process.readyRead.connect(self._data_ready)
self._process.finished.connect(self._finished)
self._step = 0
self._runs = [
self.run_input_data_fomater,
self.run_solver,
self.run_output_data_fomater,
]
self._runs[self._step]()
self._step += 1
self._step = 0
# Run first step
self._runs[0]()
def kill(self):
if self._process is None:
......@@ -252,16 +261,13 @@ class AbstractSolver(object):
return True
def start(self, process = None):
if process is not None:
self._process = process
if _signal:
if self._status == STATUS.PAUSED:
os.kill(self._process.pid(), SIGCONT)
self._status = STATUS.RUNNING
return True
self.run_solver()
self.run(process)
return True
def pause(self):
......
......@@ -123,7 +123,10 @@ class SolverLogWindow(ASubMainWindow, ListedSubWindow):
self.update()
self._log(f" *** Run solver {self._solver.name}", color="blue")
self._solver.run(self._process, self._output)
self._solver.run(
process = self._process,
output_queue = self._output
)
def new_process(self, parent):
new = QProcess(parent)
......@@ -180,9 +183,14 @@ class SolverLogWindow(ASubMainWindow, ListedSubWindow):
self._log(s)
def start(self):
self._log(" *** Start", color="blue")
if self._solver.is_stoped():
self._log(f" *** Export study {self._solver.name}", color="blue")
self._solver.export(self._study, self._workdir, qlog = self._output)
self.update()
self._process = self.new_process(self._parent)
self._log(" *** Start", color="blue")
self._solver.start(self._process)
self.find(QAction, "action_start").setEnabled(False)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment