dev: roboter, gui и plotter соединены воедино
This commit is contained in:
parent
731824918a
commit
ef58b7e2f5
@ -1,5 +1,7 @@
|
|||||||
{
|
{
|
||||||
"Electrode Force, N & Welding Current, kA": {
|
"Online Path Scanner": {
|
||||||
|
|
||||||
|
"Electrode Force, N & Welding Current, kA": {
|
||||||
"Settings": {
|
"Settings": {
|
||||||
"zoom": false,
|
"zoom": false,
|
||||||
"stages": true,
|
"stages": true,
|
||||||
@ -99,4 +101,225 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"Report Editor": {
|
||||||
|
|
||||||
|
"Electrode Force, N & Welding Current, kA": {
|
||||||
|
"Settings": {
|
||||||
|
"zoom": false,
|
||||||
|
"stages": true,
|
||||||
|
"performance": true,
|
||||||
|
"ideals": true,
|
||||||
|
"mirror ME": false,
|
||||||
|
"workpiece": false,
|
||||||
|
"force compensation FE": false,
|
||||||
|
"force accuracy":true
|
||||||
|
},
|
||||||
|
"Real_signals": [
|
||||||
|
{
|
||||||
|
"name": "Electrode Force, N ME",
|
||||||
|
"pen": "r"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Electrode Force, N FE",
|
||||||
|
"pen": "w"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Ideal_signals": [
|
||||||
|
{
|
||||||
|
"name": "Force",
|
||||||
|
"pen": {"color": "g", "width":3}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
"Electrode Position, mm": {
|
||||||
|
"Settings": {
|
||||||
|
"zoom": false,
|
||||||
|
"stages": true,
|
||||||
|
"performance": false,
|
||||||
|
"ideals": true,
|
||||||
|
"mirror ME": true,
|
||||||
|
"workpiece": true,
|
||||||
|
"force compensation FE": true,
|
||||||
|
"force accuracy":false
|
||||||
|
},
|
||||||
|
"Real_signals": [
|
||||||
|
{
|
||||||
|
"name": "Rotor Position, mm ME",
|
||||||
|
"pen": {"color": "r", "width":2}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Rotor Position, mm FE",
|
||||||
|
"pen": {"color": "w", "width":2}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Ideal_signals": [
|
||||||
|
{
|
||||||
|
"name": "Position ME",
|
||||||
|
"pen": {"color": "g", "width":4}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Position FE",
|
||||||
|
"pen": {"color": "b", "width":4}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
"Electrode Speed, mm/s": {
|
||||||
|
"Settings": {
|
||||||
|
"zoom": false,
|
||||||
|
"stages": true,
|
||||||
|
"performance": false,
|
||||||
|
"ideals": true,
|
||||||
|
"mirror ME": false,
|
||||||
|
"workpiece": false,
|
||||||
|
"force compensation FE": false,
|
||||||
|
"force accuracy":false
|
||||||
|
},
|
||||||
|
"Real_signals": [
|
||||||
|
{
|
||||||
|
"name": "Rotor Speed, mm/s ME",
|
||||||
|
"pen": "r",
|
||||||
|
"zoom": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Rotor Speed, mm/s FE",
|
||||||
|
"pen": "w",
|
||||||
|
"zoom": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Ideal_signals": [
|
||||||
|
{
|
||||||
|
"name": "Rotor Speed ME",
|
||||||
|
"pen": {"color": "g", "width":3},
|
||||||
|
"zoom": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Rotor Speed FE",
|
||||||
|
"pen": {"color": "b", "width":3},
|
||||||
|
"zoom": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Client Trace Watcher":{
|
||||||
|
|
||||||
|
"Client Trace": {
|
||||||
|
"Settings": {
|
||||||
|
"zoom": false,
|
||||||
|
"stages": true
|
||||||
|
},
|
||||||
|
"Real_signals": [
|
||||||
|
{
|
||||||
|
"name": "Electrode Force, N ME",
|
||||||
|
"pen": "r"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Electrode Position, mm ME",
|
||||||
|
"pen": "g"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Electrode Speed, mm ME",
|
||||||
|
"pen": "b"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Cartesian Tool Speed, mm/s ME",
|
||||||
|
"pen": "w"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Ideal_signals": []
|
||||||
|
},
|
||||||
|
|
||||||
|
"TCW Trace": {
|
||||||
|
"Settings": {
|
||||||
|
"stages": true,
|
||||||
|
"ideals": true,
|
||||||
|
"mirror ME": true,
|
||||||
|
"workpiece": true,
|
||||||
|
"force compensation FE": true
|
||||||
|
},
|
||||||
|
"Real_signals": [],
|
||||||
|
"Ideal_signals": [
|
||||||
|
{
|
||||||
|
"name": "Force",
|
||||||
|
"pen": {"color": "r", "width":4}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Position ME",
|
||||||
|
"pen": {"color": "g", "width":4}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Position FE",
|
||||||
|
"pen": {"color": "b", "width":4}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Rotor Speed ME",
|
||||||
|
"pen": {"color": "w", "width":3},
|
||||||
|
"zoom": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Rotor Speed FE",
|
||||||
|
"pen": {"color": "w", "width":3},
|
||||||
|
"zoom": false
|
||||||
|
}
|
||||||
|
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
"Combined Trace": {
|
||||||
|
"Settings": {
|
||||||
|
"stages": true,
|
||||||
|
"performance": false,
|
||||||
|
"ideals": true,
|
||||||
|
"workpiece": false
|
||||||
|
},
|
||||||
|
"Real_signals": [
|
||||||
|
{
|
||||||
|
"name": "Electrode Force, N ME",
|
||||||
|
"pen": "r"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Electrode Position, mm ME",
|
||||||
|
"pen": "g"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Electrode Speed, mm ME",
|
||||||
|
"pen": "b"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Cartesian Tool Speed, mm/s ME",
|
||||||
|
"pen": "w"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Ideal_signals": [
|
||||||
|
{
|
||||||
|
"name": "Force",
|
||||||
|
"pen": {"color": "r", "width":4}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Position ME",
|
||||||
|
"pen": {"color": "g", "width":4}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Position FE",
|
||||||
|
"pen": {"color": "b", "width":4}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Rotor Speed ME",
|
||||||
|
"pen": {"color": "w", "width":3},
|
||||||
|
"zoom": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Rotor Speed FE",
|
||||||
|
"pen": {"color": "w", "width":3},
|
||||||
|
"zoom": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -107,6 +107,9 @@ class BaseMediator:
|
|||||||
def prerender(self, data:list[str]) -> None:
|
def prerender(self, data:list[str]) -> None:
|
||||||
...
|
...
|
||||||
|
|
||||||
|
def set_mode(self, mode: int) -> None:
|
||||||
|
...
|
||||||
|
|
||||||
class BaseDirectoryMonitor:
|
class BaseDirectoryMonitor:
|
||||||
|
|
||||||
update_timer = QTimer()
|
update_timer = QTimer()
|
||||||
@ -219,6 +222,9 @@ class BasePlotWidget:
|
|||||||
def build_raw_trace(self, data:pd.DataFrame) -> None:
|
def build_raw_trace(self, data:pd.DataFrame) -> None:
|
||||||
...
|
...
|
||||||
|
|
||||||
|
def set_mode(self, mode:int) -> None:
|
||||||
|
...
|
||||||
|
|
||||||
class BaseController(QObject):
|
class BaseController(QObject):
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
|
|||||||
@ -12,7 +12,7 @@ class Controller(BaseController):
|
|||||||
signal_status_text = pyqtSignal(str)
|
signal_status_text = pyqtSignal(str)
|
||||||
|
|
||||||
def set_working_mode(self, mode:int) -> None:
|
def set_working_mode(self, mode:int) -> None:
|
||||||
self._file_manager.set_mode(mode)
|
self._mediator.set_mode(mode)
|
||||||
|
|
||||||
def update_plots(self) -> None:
|
def update_plots(self) -> None:
|
||||||
self._file_manager.replot_all()
|
self._file_manager.replot_all()
|
||||||
|
|||||||
@ -49,5 +49,9 @@ class Mediator(BaseMediator):
|
|||||||
def prerender(self, data:list[str]) -> None:
|
def prerender(self, data:list[str]) -> None:
|
||||||
self._trace_processor.prerender(data)
|
self._trace_processor.prerender(data)
|
||||||
|
|
||||||
|
def set_mode(self, mode: int) -> None:
|
||||||
|
self._plot.set_mode(mode)
|
||||||
|
self._file_manager.set_mode(mode)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -31,7 +31,7 @@ class PassportFormer(BasePointPassportFormer):
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
dataframe, events = data
|
dataframe, events = data
|
||||||
point_quantity = len(events["Welding"][0])
|
point_quantity = len(events["Squeeze"][0])
|
||||||
data_passport = self._form_graphic_passport(dataframe, events, point_quantity)
|
data_passport = self._form_graphic_passport(dataframe, events, point_quantity)
|
||||||
return_data = [data_passport]
|
return_data = [data_passport]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@ -39,7 +39,8 @@ class PlotWidget(BasePlotWidget):
|
|||||||
|
|
||||||
def __init__(self, controller:BaseController):
|
def __init__(self, controller:BaseController):
|
||||||
super().__init__(controller=controller)
|
super().__init__(controller=controller)
|
||||||
self._plt_channels = read_json("params/plot_structure_params.json")
|
self._plt_structures = read_json("params/plot_structure_params.json")
|
||||||
|
self._plt_channels = None
|
||||||
|
|
||||||
def build(self, data: list[GraphicPassport]) -> None:
|
def build(self, data: list[GraphicPassport]) -> None:
|
||||||
"""
|
"""
|
||||||
@ -73,6 +74,18 @@ class PlotWidget(BasePlotWidget):
|
|||||||
|
|
||||||
self._mediator.notify(self, [container_widget])
|
self._mediator.notify(self, [container_widget])
|
||||||
|
|
||||||
|
def set_mode(self, mode:int) -> None:
|
||||||
|
match mode:
|
||||||
|
case 1:
|
||||||
|
self._plt_channels = self._plt_structures["Online Path Scanner"]
|
||||||
|
print (1)
|
||||||
|
case 2:
|
||||||
|
self._plt_channels = self._plt_structures["Report Editor"]
|
||||||
|
print (2)
|
||||||
|
case 3:
|
||||||
|
self._plt_channels = self._plt_structures["Client Trace Watcher"]
|
||||||
|
print(3)
|
||||||
|
|
||||||
def _build_raw_plotitem(self,
|
def _build_raw_plotitem(self,
|
||||||
dataframe:pd.DataFrame,
|
dataframe:pd.DataFrame,
|
||||||
pyqt_container:PlotItems) -> pg.GraphicsLayoutWidget:
|
pyqt_container:PlotItems) -> pg.GraphicsLayoutWidget:
|
||||||
@ -149,7 +162,7 @@ class PlotWidget(BasePlotWidget):
|
|||||||
def _update_status(self, widgsteps:int, pointsteps:int, cur_widg:int, cur_point:int):
|
def _update_status(self, widgsteps:int, pointsteps:int, cur_widg:int, cur_point:int):
|
||||||
if self._datalen:
|
if self._datalen:
|
||||||
sycle_start = self._datastep/self._datalen*100 + 1
|
sycle_start = self._datastep/self._datalen*100 + 1
|
||||||
period1 = 100/self._datalen
|
period1 = 99/self._datalen
|
||||||
else:
|
else:
|
||||||
sycle_start = 1
|
sycle_start = 1
|
||||||
period1 = 100
|
period1 = 100
|
||||||
@ -157,7 +170,7 @@ class PlotWidget(BasePlotWidget):
|
|||||||
period2 = period1/widgsteps if widgsteps != 0 else period1
|
period2 = period1/widgsteps if widgsteps != 0 else period1
|
||||||
period3 = period2/pointsteps if pointsteps != 0 else period2
|
period3 = period2/pointsteps if pointsteps != 0 else period2
|
||||||
|
|
||||||
progress = sycle_start + period2*cur_widg + period3*cur_point
|
progress = int(sycle_start + period2*cur_widg + period3*cur_point)
|
||||||
self._controller.update_progress(progress)
|
self._controller.update_progress(progress)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -5,6 +5,7 @@ from dataclasses import dataclass, field
|
|||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
from loguru import logger
|
||||||
|
|
||||||
from base.base import (BaseKukaDataParser, BaseKukaTextParser,
|
from base.base import (BaseKukaDataParser, BaseKukaTextParser,
|
||||||
BaseTraceStageDetector, BaseTextStageDetector,
|
BaseTraceStageDetector, BaseTextStageDetector,
|
||||||
@ -273,9 +274,9 @@ class TraceProcessor(BaseRawTraceProcessor):
|
|||||||
trace_df = self._unpack_trace(dat_filepath)
|
trace_df = self._unpack_trace(dat_filepath)
|
||||||
text_data = self._unpack_text(txt_filepath)
|
text_data = self._unpack_text(txt_filepath)
|
||||||
events = self._detect_stages(trace_df, text_data)
|
events = self._detect_stages(trace_df, text_data)
|
||||||
print (events)
|
dataframe = self._rename_df_columns(trace_df)
|
||||||
|
|
||||||
self._mediator.notify(self, [trace_df, events])
|
self._mediator.notify(self, [dataframe, events])
|
||||||
|
|
||||||
def update_settings(self, data:Settings) -> None:
|
def update_settings(self, data:Settings) -> None:
|
||||||
self._settings = data
|
self._settings = data
|
||||||
@ -299,6 +300,17 @@ class TraceProcessor(BaseRawTraceProcessor):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
def _normalize_events(events:dict[list]) -> dict[list]:
|
||||||
|
max_len = max([len(item_list[0]) if key != "Oncomming" else len(item_list[0])-1 for key, item_list in events.items() ])
|
||||||
|
for key, item_list in events.items():
|
||||||
|
list_len = len(item_list[0])
|
||||||
|
if list_len < max_len:
|
||||||
|
logger.warning(f"_normalize_events - Ошибка детекции событий {key}: ожидалось {max_len} событий, получено {list_len}")
|
||||||
|
for i in range (max_len - list_len):
|
||||||
|
events[key][0].append(0)
|
||||||
|
events[key][1].append(1)
|
||||||
|
return events
|
||||||
|
@staticmethod
|
||||||
def _form_events(trace_stages:list, welding_stages:list) -> dict[list]:
|
def _form_events(trace_stages:list, welding_stages:list) -> dict[list]:
|
||||||
idx = 0
|
idx = 0
|
||||||
events = {
|
events = {
|
||||||
@ -327,8 +339,47 @@ class TraceProcessor(BaseRawTraceProcessor):
|
|||||||
else:
|
else:
|
||||||
events[trace_stages[i]['stage']][0].append(trace_stages[i]['start_time'])
|
events[trace_stages[i]['stage']][0].append(trace_stages[i]['start_time'])
|
||||||
events[trace_stages[i]['stage']][1].append(trace_stages[i]['end_time'])
|
events[trace_stages[i]['stage']][1].append(trace_stages[i]['end_time'])
|
||||||
return events
|
normalized_events = TraceProcessor._normalize_events(events)
|
||||||
|
return normalized_events
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _rename_df_columns(dataframe: pd.DataFrame) -> pd.DataFrame:
|
||||||
|
correct_mapping = {
|
||||||
|
"time": ["Time", "Timestamp"],
|
||||||
|
"Tool Coordinate, mm X": ["X_Act"],
|
||||||
|
"Tool Coordinate, mm Y": ["Y_Act"],
|
||||||
|
"Tool Coordinate, mm Z": ["Z_Act"],
|
||||||
|
"Electrode Force, N ME": ["DriveMotorTorq_Act7"],
|
||||||
|
"Electrode Position, mm ME": ["AxisPos_Act7"],
|
||||||
|
"Electrode Speed, mm ME": ["AxisVel_Act7"],
|
||||||
|
"Rotor Position, mm FE": ["DriveMotorPos_Act7"],
|
||||||
|
"Rotor Speed, mm/s ME": ["DriveMotorVel_Act7"],
|
||||||
|
"Rotor Current, A ME": ["DriveMotorCurr_Act7"],
|
||||||
|
"Cartesian Tool Speed, mm/s ME": ["CartVel_Act"],
|
||||||
|
}
|
||||||
|
|
||||||
|
working_mapping = {key: [item.lower() for item in items] for key, items in correct_mapping.items()}
|
||||||
|
|
||||||
|
try:
|
||||||
|
new_columns = {}
|
||||||
|
for col in dataframe.columns:
|
||||||
|
col_lower = col.lower()
|
||||||
|
for key, values in working_mapping.items():
|
||||||
|
if col_lower in values:
|
||||||
|
new_columns[col] = key
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
new_columns[col] = col
|
||||||
|
|
||||||
|
dataframe.rename(columns=new_columns, inplace=True)
|
||||||
|
dataframe = dataframe.loc[:, ~dataframe.columns.duplicated()]
|
||||||
|
return dataframe
|
||||||
|
except AttributeError as e:
|
||||||
|
logger.error(f"_rename_df_columns - AttributeError: Проверьте, что переданный объект является DataFrame. {e}")
|
||||||
|
return None
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"_rename_df_columns - Непредвиденная ошибка: {e}")
|
||||||
|
return None
|
||||||
|
|
||||||
"Перемещение"
|
"Перемещение"
|
||||||
#FUNCTION/PROCEDURE: SW_RSP030TL01_SN - какое-то перемещение
|
#FUNCTION/PROCEDURE: SW_RSP030TL01_SN - какое-то перемещение
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user