Merge branch 'fix-TWC-performance-calc' into feature-client-trace-modifier
This commit is contained in:
commit
ff1a6ae802
@ -24,10 +24,34 @@ class DataConverter(BaseDataConverter):
|
|||||||
# TODO: Осмысленное сообщение в лог. Без traceback и прочего подобного.
|
# TODO: Осмысленное сообщение в лог. Без traceback и прочего подобного.
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _fix_headers(dataframe: pd.DataFrame) -> pd.DataFrame:
|
||||||
|
correct_columns = [
|
||||||
|
"time", "Closing", "Electrode Force, N FE", "Electrode Force, N ME",
|
||||||
|
"Force Control FE", "Force Control ME", "Hold Position ME", "Oncomming",
|
||||||
|
"Position Control FE", "Position Control ME", "Relief",
|
||||||
|
"Rotor Position, mm FE", "Rotor Position, mm ME",
|
||||||
|
"Rotor Speed, mm/s FE", "Rotor Speed, mm/s ME",
|
||||||
|
"Squeeze", "Welding", "Welding Current ME", "Welding Voltage ME"
|
||||||
|
]
|
||||||
|
try:
|
||||||
|
correct_mapping = {name.lower(): name for name in correct_columns}
|
||||||
|
new_columns = []
|
||||||
|
for col in dataframe.columns:
|
||||||
|
fixed_col = correct_mapping.get(col.lower(), col)
|
||||||
|
new_columns.append(fixed_col)
|
||||||
|
dataframe.columns = new_columns
|
||||||
|
return dataframe
|
||||||
|
except:
|
||||||
|
# TODO: Обработка исключений!
|
||||||
|
# TODO: Осмысленное сообщение в лог. Без traceback и прочего подобного.
|
||||||
|
return None
|
||||||
|
|
||||||
def convert_data(self, files: list[str]) -> None:
|
def convert_data(self, files: list[str]) -> None:
|
||||||
try:
|
try:
|
||||||
dataframes = [pd.read_csv(file) if file != '' else None for file in files]
|
dataframes = [pd.read_csv(file) if file != '' else None for file in files]
|
||||||
converted_dataframes = list(map(self._replace_bool, dataframes))
|
renamed_dataframes = list(map(self._fix_headers, dataframes))
|
||||||
|
converted_dataframes = list(map(self._replace_bool, renamed_dataframes))
|
||||||
except:
|
except:
|
||||||
# TODO: Обработка исключений!
|
# TODO: Обработка исключений!
|
||||||
# Get the traceback object
|
# Get the traceback object
|
||||||
|
|||||||
@ -28,6 +28,8 @@ class ChannelTimings():
|
|||||||
TWC_time: float = 0.0
|
TWC_time: float = 0.0
|
||||||
ideal_time: float = 0.0
|
ideal_time: float = 0.0
|
||||||
client_time: float = 0.0
|
client_time: float = 0.0
|
||||||
|
TWC_start: float = 0.0
|
||||||
|
TWC_end: float = 0.0
|
||||||
worst_performance: float = 2
|
worst_performance: float = 2
|
||||||
worst_timeframe: list = field(default_factory=lambda: [0, 0])
|
worst_timeframe: list = field(default_factory=lambda: [0, 0])
|
||||||
|
|
||||||
@ -178,7 +180,9 @@ class CustomPlotLayout(pg.GraphicsLayoutWidget):
|
|||||||
|
|
||||||
self.addItem(plot_item, widget_num, 0)
|
self.addItem(plot_item, widget_num, 0)
|
||||||
|
|
||||||
navigator = NavigatorPlot(plot_timings.worst_timeframe, main_plot)
|
timings = ChannelTimings()
|
||||||
|
if self.property('performance'):timings:ChannelTimings = self.property('performance')
|
||||||
|
navigator = NavigatorPlot(timings.worst_timeframe, main_plot)
|
||||||
if navigator is not None:
|
if navigator is not None:
|
||||||
self.addItem(navigator, widget_num+1, 0)
|
self.addItem(navigator, widget_num+1, 0)
|
||||||
|
|
||||||
@ -236,6 +240,7 @@ class PlotItemGenerator:
|
|||||||
point_data: PointPassport = data
|
point_data: PointPassport = data
|
||||||
ideal_data = copy.deepcopy(point_data.ideal_data)
|
ideal_data = copy.deepcopy(point_data.ideal_data)
|
||||||
is_last = (cur_point == len(points_pocket) - 1)
|
is_last = (cur_point == len(points_pocket) - 1)
|
||||||
|
is_first = (cur_point == 0)
|
||||||
|
|
||||||
if self._ideal_mode:
|
if self._ideal_mode:
|
||||||
timings, point_data.events, point_data.timeframe = self._generate_synthetic_events(timings, ideal_data)
|
timings, point_data.events, point_data.timeframe = self._generate_synthetic_events(timings, ideal_data)
|
||||||
@ -265,14 +270,13 @@ class PlotItemGenerator:
|
|||||||
self._add_ideal_signals(plot_item, legend, ideal_data, point_data.events, description["Ideal_signals"], pyqt_container.curves, is_last)
|
self._add_ideal_signals(plot_item, legend, ideal_data, point_data.events, description["Ideal_signals"], pyqt_container.curves, is_last)
|
||||||
|
|
||||||
if settings["performance"]:
|
if settings["performance"]:
|
||||||
timings = self._calc_performance(timings, point_data, ideal_data, is_last)
|
timings = self._calc_performance(timings, point_data, ideal_data, is_first, is_last)
|
||||||
|
|
||||||
self._parent._update_status(widget_steps, point_steps, widget_num, cur_point)
|
self._parent._update_status(widget_steps, point_steps, widget_num, cur_point)
|
||||||
|
|
||||||
# Добавляем реальные сигналы
|
# Добавляем реальные сигналы
|
||||||
if not self._ideal_mode:
|
if not self._ideal_mode:
|
||||||
self._add_real_signals(plot_item, dataframe, description["Real_signals"], legend, pyqt_container.curves)
|
self._add_real_signals(plot_item, dataframe, description["Real_signals"], legend, pyqt_container.curves)
|
||||||
|
|
||||||
return (plot_item, timings)
|
return (plot_item, timings)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -442,23 +446,25 @@ class PlotItemGenerator:
|
|||||||
timings:ChannelTimings,
|
timings:ChannelTimings,
|
||||||
point_data: PointPassport,
|
point_data: PointPassport,
|
||||||
ideal_data:dict,
|
ideal_data:dict,
|
||||||
|
is_first:bool,
|
||||||
is_last:bool) -> ChannelTimings:
|
is_last:bool) -> ChannelTimings:
|
||||||
if is_last:
|
if is_first:
|
||||||
if not self._ideal_mode:
|
if not self._ideal_mode:
|
||||||
TWC_delta = sum([point_data.events[stage][1] - point_data.events[stage][0]
|
timings.TWC_start = point_data.events["Closing"][0]
|
||||||
for stage in ["Closing", "Squeeze", "Welding"]])
|
ideal_delta = ideal_data["Ideal cycle"]
|
||||||
else: TWC_delta = 0
|
elif is_last:
|
||||||
|
if not self._ideal_mode:
|
||||||
|
timings.TWC_end = point_data.events["Relief"][1]
|
||||||
|
timings.TWC_time = timings.TWC_end - timings.TWC_start
|
||||||
|
timings.worst_timeframe = [timings.TWC_start, timings.TWC_end]
|
||||||
ideal_delta = sum(ideal_data["Ideal timings"][0:3])
|
ideal_delta = sum(ideal_data["Ideal timings"][0:3])
|
||||||
else:
|
else:
|
||||||
if not self._ideal_mode: TWC_delta = point_data.timeframe[1] - point_data.timeframe[0]
|
|
||||||
else: TWC_delta = 0
|
|
||||||
ideal_delta = ideal_data["Ideal cycle"]
|
ideal_delta = ideal_data["Ideal cycle"]
|
||||||
|
|
||||||
timings.TWC_time += TWC_delta
|
|
||||||
timings.ideal_time += ideal_delta
|
timings.ideal_time += ideal_delta
|
||||||
curr_perf = ideal_delta/TWC_delta if TWC_delta != 0 else 1
|
#curr_perf = ideal_delta/TWC_delta if TWC_delta != 0 else 1
|
||||||
|
|
||||||
if curr_perf < timings.worst_performance:
|
if False: #curr_perf < timings.worst_performance:
|
||||||
timings.worst_performance = curr_perf
|
timings.worst_performance = curr_perf
|
||||||
timings.worst_timeframe = point_data.timeframe
|
timings.worst_timeframe = point_data.timeframe
|
||||||
return timings
|
return timings
|
||||||
@ -535,6 +541,7 @@ class NavigatorPlot(pg.PlotItem):
|
|||||||
"""
|
"""
|
||||||
Связывает изменения навигатора и других графиков друг с другом
|
Связывает изменения навигатора и других графиков друг с другом
|
||||||
"""
|
"""
|
||||||
|
self._sync_main_plot_with_navigator(main_plot, self.ROI_region)
|
||||||
self.ROI_region.sigRegionChanged.connect(
|
self.ROI_region.sigRegionChanged.connect(
|
||||||
lambda: self._sync_main_plot_with_navigator(main_plot, self.ROI_region)
|
lambda: self._sync_main_plot_with_navigator(main_plot, self.ROI_region)
|
||||||
)
|
)
|
||||||
@ -559,8 +566,10 @@ class NavigatorPlot(pg.PlotItem):
|
|||||||
x_downsampled, y_downsampled = self._downsample_data(x, y, max_points=1000)
|
x_downsampled, y_downsampled = self._downsample_data(x, y, max_points=1000)
|
||||||
self.plot(x_downsampled, y_downsampled, pen=signal_pen, name=curve_name)
|
self.plot(x_downsampled, y_downsampled, pen=signal_pen, name=curve_name)
|
||||||
|
|
||||||
self.ROI_region = pg.LinearRegionItem(values=time_region, movable=True, brush=pg.mkBrush(0, 0, 255, 100), pen=pg.mkPen(width=4))
|
self.ROI_region = pg.LinearRegionItem(movable=True, brush=pg.mkBrush(0, 0, 255, 100), pen=pg.mkPen(width=4))
|
||||||
|
|
||||||
self.ROI_region.setBounds([0, x[-1]])
|
self.ROI_region.setBounds([0, x[-1]])
|
||||||
|
self.ROI_region.setRegion(time_region)
|
||||||
self.addItem(self.ROI_region)
|
self.addItem(self.ROI_region)
|
||||||
self.getViewBox().setLimits(xMin=0, xMax=x[-1])
|
self.getViewBox().setLimits(xMin=0, xMax=x[-1])
|
||||||
|
|
||||||
|
|||||||
7457
trace_samples/point_40000_2025_01_31-14_21_43.csv
Normal file
7457
trace_samples/point_40000_2025_01_31-14_21_43.csv
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user