select adists fixed

adists_new
Youcef AOUAD 2024-07-17 14:24:26 +02:00
parent 7f2ff9d341
commit 3c82148f44
2 changed files with 149 additions and 3 deletions

View File

@ -71,6 +71,7 @@ from View.AdditionalFiles.Window import AddFileListWindow
from View.REPLines.Window import REPLineListWindow from View.REPLines.Window import REPLineListWindow
from View.SolverParameters.Window import SolverParametersWindow from View.SolverParameters.Window import SolverParametersWindow
from View.RunSolver.Window import SelectSolverWindow, SolverLogWindow from View.RunSolver.Window import SelectSolverWindow, SolverLogWindow
from View.RunSolver.WindowAdisTS import SelectSolverWindowAdisTS
from View.CheckList.Window import CheckListWindow from View.CheckList.Window import CheckListWindow
from View.Results.Window import ResultsWindow from View.Results.Window import ResultsWindow
from View.Results.ReadingResultsDialog import ReadingResultsDialog from View.Results.ReadingResultsDialog import ReadingResultsDialog
@ -1261,10 +1262,18 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
if self._study is None: if self._study is None:
return return
solver = next(filter(lambda x: x._type == "adistslc", self.conf.solvers)) #solver = next(filter(lambda x: x._type == "adistslc", self.conf.solvers))
#solver = next(filter(lambda x: x.name == "AdisTS-LC", self.conf.solvers)) #solver = next(filter(lambda x: x.name == "AdisTS-LC", self.conf.solvers))
print(solver._type) #print(solver._type)
self.run_solver(solver) #self.run_solver(solver)
run = SelectSolverWindowAdisTS(
study=self._study,
config=self.conf,
parent=self
)
if run.exec():
self.run_solver(run.solver)
def run_solver(self, solver): def run_solver(self, solver):
if self._study is None: if self._study is None:

View File

@ -0,0 +1,137 @@
# WindowAdisTS.py -- Pamhyr
# Copyright (C) 2023-2024 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# -*- coding: utf-8 -*-
import os
import logging
import tempfile
from queue import Queue
from tools import trace, timer, logger_exception
from View.Tools.PamhyrWindow import PamhyrDialog, PamhyrWindow
from PyQt5.QtGui import (
QKeySequence,
)
from PyQt5.QtCore import (
Qt, QVariant, QAbstractTableModel,
QCoreApplication, QModelIndex, pyqtSlot,
QRect, QTimer, QProcess,
)
from PyQt5.QtWidgets import (
QDialogButtonBox, QPushButton, QLineEdit,
QFileDialog, QTableView, QAbstractItemView,
QUndoStack, QShortcut, QAction, QItemDelegate,
QComboBox, QVBoxLayout, QHeaderView, QTabWidget,
QTextEdit,
)
from View.RunSolver.Log.Window import SolverLogFileWindow
from View.Results.ReadingResultsDialog import ReadingResultsDialog
try:
from signal import SIGTERM, SIGSTOP, SIGCONT
_signal = True
except Exception:
_signal = False
_translate = QCoreApplication.translate
logger = logging.getLogger()
class SelectSolverWindowAdisTS(PamhyrDialog):
_pamhyr_ui = "SelectSolver"
_pamhyr_name = "Select solver"
def __init__(self, study=None, config=None,
parent=None):
self._solver = None
name = _translate("Solver", "Select solver")
super(SelectSolverWindowAdisTS, self).__init__(
title=name,
study=study,
config=config,
options=[],
parent=parent
)
self.setup_combobox()
self.setup_connections()
self.select_last_solver()
def setup_combobox(self):
#solvers = self._config.solvers
#solvers mage
solvers = list(filter(lambda x: "mage" not in x._type, self._config.solvers))
solvers_name = list(
map(
self._format_solver_name,
solvers
)
)
self.combobox_add_items("comboBox", solvers_name)
def setup_connections(self):
self.find(QPushButton, "pushButton_run").clicked.connect(self.accept)
self.find(QPushButton, "pushButton_cancel")\
.clicked.connect(self.reject)
def select_last_solver(self):
solvers = self._config.solvers
last = self._config.last_solver_name
solver = list(
filter(
lambda s: s.name == last,
solvers
)
)
if len(solver) != 0:
self.set_combobox_text(
"comboBox",
self._format_solver_name(solver[0])
)
def _format_solver_name(self, solver):
return f"{solver.name} - ({solver._type})"
@property
def solver(self):
return self._solver
def accept(self):
solver_name = self.get_combobox_text("comboBox")
solver_name = solver_name.rsplit(" - ", 1)[0]
self._config.update_last_solver_used(solver_name)
self._solver = next(
filter(
lambda s: s.name == solver_name,
self._config.solvers
)
)
super(SelectSolverWindowAdisTS, self).accept()