dev: добавлено отображение производительности для сварочной точки
This commit is contained in:
parent
056d9fedb8
commit
384d52309f
Binary file not shown.
Binary file not shown.
@ -1,5 +1,5 @@
|
|||||||
import pandas as pd
|
import pandas as pd
|
||||||
from PyQt5.QtWidgets import QWidget, QVBoxLayout
|
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QLabel
|
||||||
import pyqtgraph as pg
|
import pyqtgraph as pg
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from numpy import floating
|
from numpy import floating
|
||||||
@ -22,16 +22,16 @@ class idealDataBuilder(BaseIdealDataBuilder):
|
|||||||
def get_tmovementDF(self) -> pd.DataFrame:
|
def get_tmovementDF(self) -> pd.DataFrame:
|
||||||
return self._get_data(self.Ts['tmovement'], self.calcPhaseMovement)
|
return self._get_data(self.Ts['tmovement'], self.calcPhaseMovement)
|
||||||
|
|
||||||
def get_weldingDF(self, end_time: float) -> pd.DataFrame:
|
def get_weldingDF(self) -> pd.DataFrame:
|
||||||
data = []
|
data = []
|
||||||
X1, X2, V1, V2, F = self.calcPhaseGrow(self.Ts['tgrow'])
|
X1, X2, V1, V2, F = self.calcPhaseGrow(self.Ts['tgrow'])
|
||||||
data.append({"time":0, "Posicion FE":X1,"Posicion ME":X2, "Rotor Speed FE":V1, "Rotor Speed ME":V2, "Force":F})
|
data.append({"time":0, "Posicion FE":X1,"Posicion ME":X2, "Rotor Speed FE":V1, "Rotor Speed ME":V2, "Force":F})
|
||||||
data.append({"time":end_time, "Posicion FE":X1,"Posicion ME":X2, "Rotor Speed FE":V1, "Rotor Speed ME":V2, "Force":F})
|
data.append({"time":self.welding_time, "Posicion FE":X1,"Posicion ME":X2, "Rotor Speed FE":V1, "Rotor Speed ME":V2, "Force":F})
|
||||||
return pd.DataFrame(data)
|
return pd.DataFrame(data)
|
||||||
|
|
||||||
def get_ideal_timings(self) -> list[float, float, float, float]:
|
def get_ideal_timings(self) -> list[float, float, float, float]:
|
||||||
data = self.Ts
|
data = self.Ts
|
||||||
ideal_timings = [data['tclose'], data['tgrow'], self.getMarkOpen(), data["tmovement"]]
|
ideal_timings = [data['tclose'], data['tgrow'], self.welding_time, self.getMarkOpen()]
|
||||||
return ideal_timings
|
return ideal_timings
|
||||||
|
|
||||||
|
|
||||||
@ -42,39 +42,42 @@ class ProcessStage(NamedTuple):
|
|||||||
|
|
||||||
|
|
||||||
class PlotWidget(BasePlotWidget):
|
class PlotWidget(BasePlotWidget):
|
||||||
def _create_stage_ideal(self,
|
def _create_curve_ideal(self,
|
||||||
stage: str,
|
stage: str,
|
||||||
signal: str,
|
signal: str,
|
||||||
times: pd.Series,
|
start_timestamp: float,
|
||||||
dataframe: pd.DataFrame) -> Optional[pg.LinearRegionItem]:
|
finish_timestamp: float) -> Optional[pg.PlotDataItem]:
|
||||||
stage_diff = np.diff(dataframe[stage])
|
|
||||||
start_index = np.where(stage_diff == 1)[0]
|
|
||||||
finish_index = np.where(stage_diff == -1)[0]
|
|
||||||
data = self._stage_ideals[stage]
|
data = self._stage_ideals[stage]
|
||||||
|
|
||||||
if start_index.size:
|
if start_timestamp and finish_timestamp:
|
||||||
start_timestamp = times[start_index[0]]
|
|
||||||
finish_timestamp = times[finish_index[0]] if finish_index.size else times[len(times) - 1]
|
|
||||||
plot = pg.PlotDataItem(x=start_timestamp+data["time"], y=data[signal["name"]], pen=signal["pen"])
|
plot = pg.PlotDataItem(x=start_timestamp+data["time"], y=data[signal["name"]], pen=signal["pen"])
|
||||||
return plot
|
return plot
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _create_stage_region(self,
|
def _create_stage_region(self,
|
||||||
stage: str,
|
stage: str,
|
||||||
times: pd.Series,
|
start_timestamp: float,
|
||||||
dataframe: pd.DataFrame) -> Optional[pg.LinearRegionItem]:
|
finish_timestamp: float) -> Optional[pg.LinearRegionItem]:
|
||||||
stage_diff = np.diff(dataframe[stage])
|
|
||||||
start_index = np.where(stage_diff == 1)[0]
|
|
||||||
finish_index = np.where(stage_diff == -1)[0]
|
|
||||||
|
|
||||||
if start_index.size:
|
if start_timestamp and finish_timestamp:
|
||||||
start_timestamp = times[start_index[0]]
|
|
||||||
finish_timestamp = times[finish_index[0]] if finish_index.size else times[len(times) - 1]
|
|
||||||
region = pg.LinearRegionItem([start_timestamp, finish_timestamp], movable=False)
|
region = pg.LinearRegionItem([start_timestamp, finish_timestamp], movable=False)
|
||||||
region.setBrush(pg.mkBrush(self._stage_colors[stage]))
|
region.setBrush(pg.mkBrush(self._stage_colors[stage]))
|
||||||
return region
|
return region
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def _get_timestamp(self,
|
||||||
|
stage: str,
|
||||||
|
times: pd.Series,
|
||||||
|
dataframe: pd.DataFrame) -> Optional[list[float]]:
|
||||||
|
stage_diff = np.diff(dataframe[stage])
|
||||||
|
start_index = np.where(stage_diff == 1)[0]
|
||||||
|
finish_index = np.where(stage_diff == -1)[0]
|
||||||
|
if start_index.size:
|
||||||
|
start_timestamp = times[start_index[0]]
|
||||||
|
finish_timestamp = times[finish_index[0]] if finish_index.size else times[len(times) - 1]
|
||||||
|
return start_timestamp, finish_timestamp
|
||||||
|
return None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _init_plot_widget(title: str) -> tuple[pg.PlotWidget, pg.LegendItem]:
|
def _init_plot_widget(title: str) -> tuple[pg.PlotWidget, pg.LegendItem]:
|
||||||
plot_widget = pg.PlotWidget(title=title)
|
plot_widget = pg.PlotWidget(title=title)
|
||||||
@ -115,15 +118,26 @@ class PlotWidget(BasePlotWidget):
|
|||||||
settings = description["Settings"]
|
settings = description["Settings"]
|
||||||
if settings["stages"] and all([stage in dataframe_headers for stage in self._stages]):
|
if settings["stages"] and all([stage in dataframe_headers for stage in self._stages]):
|
||||||
for stage in self._stages:
|
for stage in self._stages:
|
||||||
region = self._create_stage_region(stage, time_axis, dataframe)
|
start_timestamp, finish_timestamp = self._get_timestamp(stage, time_axis, dataframe)
|
||||||
for signal in description["Ideal_signals"]:
|
region = self._create_stage_region(stage, start_timestamp, finish_timestamp)
|
||||||
ideal_plot = self._create_stage_ideal(stage, signal ,time_axis, dataframe)
|
|
||||||
if ideal_plot:
|
|
||||||
plot_widget.addItem(ideal_plot)
|
|
||||||
|
|
||||||
if region:
|
if region:
|
||||||
plot_widget.addItem(region)
|
plot_widget.addItem(region)
|
||||||
|
|
||||||
|
for signal in description["Ideal_signals"]:
|
||||||
|
ideal_plot = self._create_curve_ideal(stage, signal, start_timestamp, finish_timestamp)
|
||||||
|
if ideal_plot:
|
||||||
|
plot_widget.addItem(ideal_plot)
|
||||||
|
|
||||||
|
if settings["performance"] and all([stage in dataframe_headers for stage in self._stages]):
|
||||||
|
delta_timestamp = 0
|
||||||
|
for stage in self._stages:
|
||||||
|
start_timestamp, finish_timestamp = self._get_timestamp(stage, time_axis, dataframe)
|
||||||
|
delta_timestamp += finish_timestamp - start_timestamp
|
||||||
|
|
||||||
|
ideal_delta = self._opt.get_cycle_time()
|
||||||
|
performance = round(ideal_delta/delta_timestamp*100, 2)
|
||||||
|
performance_label = QLabel(f"Performance = {performance} %")
|
||||||
|
layout.addWidget(performance_label)
|
||||||
|
|
||||||
if settings["zoom"]:
|
if settings["zoom"]:
|
||||||
if max(time_axis) < 5.0:
|
if max(time_axis) < 5.0:
|
||||||
@ -170,8 +184,6 @@ class PlotWidget(BasePlotWidget):
|
|||||||
plot = plot_widget.plot(time_axis, dataframe[signal["name"]], pen=signal["pen"])
|
plot = plot_widget.plot(time_axis, dataframe[signal["name"]], pen=signal["pen"])
|
||||||
legend.addItem(plot, signal["name"])
|
legend.addItem(plot, signal["name"])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
layout.addWidget(plot_widget)
|
layout.addWidget(plot_widget)
|
||||||
|
|
||||||
widget.setLayout(layout)
|
widget.setLayout(layout)
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
import sys
|
import sys
|
||||||
from PyQt5 import QtWidgets
|
from PyQt5 import QtWidgets
|
||||||
import json
|
|
||||||
from os import path
|
|
||||||
|
|
||||||
from src.gui.mainGui import MainWindow
|
from src.gui.mainGui import MainWindow
|
||||||
from src.controller.monitor import DirectoryMonitor
|
from src.controller.monitor import DirectoryMonitor
|
||||||
|
|||||||
Binary file not shown.
@ -120,7 +120,8 @@ class BasePlotWidget:
|
|||||||
"Electrode Force, N & Welding Current, kA": {
|
"Electrode Force, N & Welding Current, kA": {
|
||||||
"Settings": {
|
"Settings": {
|
||||||
"zoom": False,
|
"zoom": False,
|
||||||
"stages": True
|
"stages": True,
|
||||||
|
"performance": True
|
||||||
},
|
},
|
||||||
"Real_signals": [
|
"Real_signals": [
|
||||||
{
|
{
|
||||||
@ -146,7 +147,8 @@ class BasePlotWidget:
|
|||||||
"Electrode Force, N": {
|
"Electrode Force, N": {
|
||||||
"Settings": {
|
"Settings": {
|
||||||
"zoom": True,
|
"zoom": True,
|
||||||
"stages": False
|
"stages": False,
|
||||||
|
"performance": False
|
||||||
},
|
},
|
||||||
"Real_signals": [
|
"Real_signals": [
|
||||||
{
|
{
|
||||||
@ -168,7 +170,8 @@ class BasePlotWidget:
|
|||||||
"Electrode Speed, mm/s": {
|
"Electrode Speed, mm/s": {
|
||||||
"Settings": {
|
"Settings": {
|
||||||
"zoom": False,
|
"zoom": False,
|
||||||
"stages": True
|
"stages": True,
|
||||||
|
"performance": False
|
||||||
},
|
},
|
||||||
"Real_signals": [
|
"Real_signals": [
|
||||||
{
|
{
|
||||||
@ -204,7 +207,7 @@ class BasePlotWidget:
|
|||||||
self._stage_ideals = {
|
self._stage_ideals = {
|
||||||
"Closing": self._opt.get_closingDF(),
|
"Closing": self._opt.get_closingDF(),
|
||||||
"Squeeze": self._opt.get_compressionDF(),
|
"Squeeze": self._opt.get_compressionDF(),
|
||||||
"Welding": self._opt.get_weldingDF(end_time=data[0]['time_wielding']),
|
"Welding": self._opt.get_weldingDF(),
|
||||||
"Relief": self._opt.get_openingDF()
|
"Relief": self._opt.get_openingDF()
|
||||||
}
|
}
|
||||||
@property
|
@property
|
||||||
@ -243,6 +246,7 @@ class BaseIdealDataBuilder(OptAlgorithm):
|
|||||||
def __init__(self, data: list[dict]):
|
def __init__(self, data: list[dict]):
|
||||||
operator_params, system_params = data
|
operator_params, system_params = data
|
||||||
self.mul = system_params['time_capture']
|
self.mul = system_params['time_capture']
|
||||||
|
self.welding_time = operator_params['time_wielding']
|
||||||
super().__init__(operator_params, system_params)
|
super().__init__(operator_params, system_params)
|
||||||
|
|
||||||
def _get_data(self, end_timestamp:float, func:function) -> pd.DataFrame:
|
def _get_data(self, end_timestamp:float, func:function) -> pd.DataFrame:
|
||||||
@ -265,14 +269,15 @@ class BaseIdealDataBuilder(OptAlgorithm):
|
|||||||
def get_tmovementDF(self) -> pd.DataFrame:
|
def get_tmovementDF(self) -> pd.DataFrame:
|
||||||
...
|
...
|
||||||
|
|
||||||
def get_weldingDF(self, end_time: float) -> pd.DataFrame:
|
def get_weldingDF(self) -> pd.DataFrame:
|
||||||
...
|
...
|
||||||
|
|
||||||
def get_ideal_timings(self) -> list[float, float, float, float]:
|
def get_ideal_timings(self) -> list[float, float, float, float]:
|
||||||
...
|
...
|
||||||
|
|
||||||
def update_settings(self, data: list[dict]) -> None:
|
def get_cycle_time(self) -> float:
|
||||||
...
|
result = sum(self.get_ideal_timings())
|
||||||
|
return result
|
||||||
|
|
||||||
class BaseMainWindow(QWidget):
|
class BaseMainWindow(QWidget):
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user