dev: добавлена строка эффективности + добавлено сохранение UML в директорию
This commit is contained in:
parent
7c09dde2d1
commit
1a36aa217b
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -7,9 +7,9 @@ from src.gui import Plotter, settingsWindow
|
||||
|
||||
|
||||
class tabWidgetGenerator:
|
||||
def __init__(self):
|
||||
def __init__(self, directory_to_save):
|
||||
self.UMLgenerator = Request(server_url='http://www.plantuml.com/plantuml/svg/')
|
||||
self.uml_creator = UMLCreator(request_generator=self.UMLgenerator)
|
||||
self.uml_creator = UMLCreator(request_generator=self.UMLgenerator, path_to_save=directory_to_save)
|
||||
self.operator_params = read_json("params/operator_params.json")
|
||||
self.system_params = read_json("params/system_params.json")
|
||||
self.operSettings = settingsWindow("params\operator_params.json", 'Operator', self._update)
|
||||
@ -21,6 +21,7 @@ class tabWidgetGenerator:
|
||||
self.float_dicts = []
|
||||
self.timings_dicts = []
|
||||
self.modes = []
|
||||
self.names = []
|
||||
|
||||
def get_widget(self, path):
|
||||
self.paths.append(path)
|
||||
@ -35,6 +36,7 @@ class tabWidgetGenerator:
|
||||
return ideal_time
|
||||
|
||||
def _getParsedData(self, path):
|
||||
self.names.append(path)
|
||||
parser = DiagramParser(system_config=self.system_params)
|
||||
parser.setData(path)
|
||||
self.bool_dicts.append(parser.getBoolDict())
|
||||
@ -66,7 +68,8 @@ class tabWidgetGenerator:
|
||||
bool_dict=self.bool_dicts[i],
|
||||
float_dict=self.float_dicts[i],
|
||||
mode = self.modes[i],
|
||||
timings_dict=self.timings_dicts[i])
|
||||
timings_dict=self.timings_dicts[i],
|
||||
name = self.names[i])
|
||||
|
||||
|
||||
def _show_settings(self):
|
||||
|
@ -1,5 +1,6 @@
|
||||
import pyqtgraph as pg
|
||||
from pyqtgraph.Qt import QtWidgets
|
||||
from PyQt5.QtCore import Qt
|
||||
import numpy as np
|
||||
|
||||
from src.gui import qt_settings as qts
|
||||
@ -34,6 +35,7 @@ class Plotter:
|
||||
self.WeldTime = operator_config['time_wielding'] #[sec]
|
||||
self.WeldData = self.opt.calcPhaseGrow(self.idealTime[1])
|
||||
self._updatePlots()
|
||||
|
||||
|
||||
def _init_ui(self):
|
||||
self.widget = QtWidgets.QWidget()
|
||||
@ -47,7 +49,15 @@ class Plotter:
|
||||
layout.addWidget(self.win)
|
||||
self.settings_button = QtWidgets.QPushButton("Show settings")
|
||||
self.settings_button.setFixedWidth(160)
|
||||
layout.addWidget(self.settings_button)
|
||||
info_layout = QtWidgets.QHBoxLayout()
|
||||
layout.addLayout(info_layout)
|
||||
info_layout.addWidget(self.settings_button, alignment = Qt.AlignLeft)
|
||||
info_layout.setSpacing(20)
|
||||
self.efficiency = QtWidgets.QLabel()
|
||||
info_layout.addWidget(self.efficiency, alignment = Qt.AlignRight)
|
||||
|
||||
|
||||
|
||||
|
||||
self.p11, self.l11 = self._init_graph('Electrode force, closure', 'Force', 'N', 'Time', 'ms')
|
||||
#self.p21, _ = self._init_graph('Electrode force, compression', 'Force', 'N', 'Time', 'ms')
|
||||
@ -90,6 +100,25 @@ class Plotter:
|
||||
if not self.theor_mode:
|
||||
self._plotRealData()
|
||||
self._form_idealdatGraph()
|
||||
self._calcOurScore()
|
||||
|
||||
def _calcOurScore (self):
|
||||
success = []
|
||||
start = np.array(self.timings_dict["closure"])[:, 0]
|
||||
end = np.array(self.timings_dict["opening"])[:, 1]
|
||||
points_timings = end-start
|
||||
|
||||
ideal_time = sum(self.idealTime[:3])+self.WeldTime
|
||||
for point in points_timings:
|
||||
success.append(int(ideal_time/point * 100))
|
||||
if len(success) > 1:
|
||||
maxS = max(success)
|
||||
minS = min(success)
|
||||
average = int(sum(success[:])/len(success))
|
||||
self.efficiency.setText(f'Efficiency Maximum: {maxS}%, Average: {average}%, Minimum: {minS}%' )
|
||||
else:
|
||||
self.efficiency.setText(f'Efficiency Maximum: {success[0]}' )
|
||||
self.efficiency.setStyleSheet(qts.BigSuccessLabel)
|
||||
|
||||
|
||||
def _form_idealdatGraph(self):
|
||||
|
@ -233,7 +233,13 @@ QPushButton:disabled {
|
||||
}
|
||||
|
||||
"""
|
||||
|
||||
BigSuccessLabel = """
|
||||
QLabel {
|
||||
color: #ffffff;
|
||||
font-size: 26px;
|
||||
font-weight: bold;
|
||||
font-family: "Segoe UI", sans-serif;
|
||||
}"""
|
||||
|
||||
colors = [
|
||||
'#FF6F61', # яркий коралловый
|
||||
|
11
src/main.py
11
src/main.py
@ -53,7 +53,8 @@ class MainWindow(QMainWindow):
|
||||
|
||||
self.tabs = QTabWidget()
|
||||
self.tabs.setStyleSheet(qts.dark_style)
|
||||
self.tabGen = tabWidgetGenerator()
|
||||
self.tabGen = tabWidgetGenerator(directory_to_watch)
|
||||
self.handle_new_file()
|
||||
self.setCentralWidget(self.tabs)
|
||||
|
||||
# self.setWindowIcon(QIcon("path_to_icon.png"))
|
||||
@ -70,9 +71,13 @@ class MainWindow(QMainWindow):
|
||||
|
||||
self.watcher_thread.start()
|
||||
|
||||
def handle_new_file(self, file_path):
|
||||
def handle_new_file(self, file_path = None):
|
||||
time.sleep(0.2)
|
||||
file_name = os.path.basename(file_path)
|
||||
if file_path:
|
||||
file_name = os.path.basename(file_path)
|
||||
else:
|
||||
file_path = None
|
||||
file_name = 'Ideal'
|
||||
|
||||
tab_widget = self.tabGen.get_widget(path=file_path)
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
@ -2,8 +2,9 @@ from src.uml.request_generator import Request
|
||||
|
||||
|
||||
class UMLCreator:
|
||||
def __init__(self, request_generator: Request):
|
||||
def __init__(self, request_generator: Request, path_to_save: str):
|
||||
self._request_generator = request_generator
|
||||
self.path_to_save = path_to_save
|
||||
|
||||
|
||||
def _build_data(self):
|
||||
@ -77,13 +78,14 @@ class UMLCreator:
|
||||
|
||||
self._request_generator.addConcise('RD', 'Real data')
|
||||
self._request_generator.setTimestamps('RD', real_data)
|
||||
else: self.name = self.path_to_save + '/Ideal'
|
||||
|
||||
self._request_generator.addConcise('CD', 'Client data')
|
||||
self._request_generator.setTimestamps('CD', client_data)
|
||||
self._request_generator.addConcise('ID', 'Ideal data')
|
||||
self._request_generator.setTimestamps('ID', ideal_data)
|
||||
try:
|
||||
self._request_generator.generateSVG()
|
||||
self._request_generator.generateSVG(self.name)
|
||||
except Exception as e:
|
||||
print(f"SVG generate error: {e}")
|
||||
|
||||
@ -94,13 +96,15 @@ class UMLCreator:
|
||||
bool_dict: dict,
|
||||
float_dict: dict,
|
||||
timings_dict: dict,
|
||||
mode: bool):
|
||||
mode: bool,
|
||||
name:str):
|
||||
|
||||
self._ideal_time = ideal_time
|
||||
self.bool_dict = bool_dict
|
||||
self.float_dict = float_dict
|
||||
self.timings_dict = timings_dict
|
||||
self.theor_mode = mode
|
||||
self.name = name
|
||||
self.scaler = int(system_config['UML_time_scaler'])
|
||||
self.WeldTime = operator_config['time_wielding']
|
||||
|
||||
|
@ -48,10 +48,10 @@ class Request:
|
||||
def addLineStyle(self, name, color = 'green', thicknes = 1):
|
||||
self.lineStyles[name] = [f'LineColor {color}', f'LineThickness {thicknes}']
|
||||
|
||||
def generateSVG(self):
|
||||
self._compileUML()
|
||||
filename = abspath('UML.txt')
|
||||
self.server.processes_file(filename, outfile='UML.svg')
|
||||
def generateSVG(self, name):
|
||||
self._compileUML(name)
|
||||
filename = abspath(f'{name}.txt')
|
||||
self.server.processes_file(filename, outfile=f'{name}.svg')
|
||||
#result = self.server.processes(self.stringUML)
|
||||
#return result
|
||||
|
||||
@ -82,7 +82,7 @@ class Request:
|
||||
def _addVariables(self):
|
||||
for var in self.variables: self.reqArr.append(str(var))
|
||||
|
||||
def _compileUML(self):
|
||||
def _compileUML(self, name):
|
||||
self._addHeader()
|
||||
self._addVariables()
|
||||
|
||||
@ -92,7 +92,7 @@ class Request:
|
||||
|
||||
self._endUML()
|
||||
self.stringUML = [line + '\n' for line in self.reqArr]
|
||||
with open('UML.txt', 'w', encoding='utf-8') as file:
|
||||
with open(f'{name}.txt', 'w', encoding='utf-8') as file:
|
||||
file.writelines(self.stringUML)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user