dev: начало этапа идеального графика совмещено с этапом в реальном
This commit is contained in:
parent
7d71a4774f
commit
40af0afda8
@ -15,5 +15,9 @@
|
||||
"position_start_2": 0.08,
|
||||
"k_prop": 0.05,
|
||||
"time_capture": 100000,
|
||||
"UML_time_scaler": 1000
|
||||
"UML_time_scaler": 1000,
|
||||
"Closure_signal": "Closing",
|
||||
"Squeeze_signal": "Squeeze",
|
||||
"Welding_signal": "Welding",
|
||||
"Release_signal": "Relief"
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -9,7 +9,7 @@ from src.gui import PlotWindow, settingsWindow
|
||||
class app:
|
||||
def __init__(self):
|
||||
|
||||
self.parser = DiagramParser()
|
||||
|
||||
self.request_generator = Request(server_url='http://www.plantuml.com/plantuml/svg/')
|
||||
|
||||
self.operSettings = settingsWindow("params\operator_params.json", 'Operator', self._update_settings)
|
||||
@ -29,16 +29,18 @@ class app:
|
||||
|
||||
self.opt_algorithm = OptAlgorithm(operator_config=self.operator_params, system_config=self.system_params)
|
||||
self.ideal_times = self._get_ideal_timings(self.opt_algorithm)
|
||||
|
||||
self.parser.setData("trace_samples/2024_11_08-19_30_49.csv")
|
||||
self.parser = DiagramParser(system_config=self.system_params)
|
||||
self.parser.setData("trace_samples/2024_11_08-19_30_52.csv")
|
||||
self.bool_dict = self.parser.getBoolDict()
|
||||
self.float_dict = self.parser.getFloatDict()
|
||||
self.timings_dict = self.parser.getRealTimings()
|
||||
|
||||
self.plotter = PlotWindow(operator_config=self.operator_params,
|
||||
system_config=self.system_params,
|
||||
opt=self.opt_algorithm,
|
||||
bool_dict=self.bool_dict,
|
||||
float_dict=self.float_dict,
|
||||
timings_dict=self.timings_dict,
|
||||
show_settings_func=self._show_settings)
|
||||
|
||||
self.uml_creator = UMLCreator(operator_config=self.operator_params,
|
||||
@ -46,14 +48,16 @@ class app:
|
||||
request_generator=self.request_generator,
|
||||
ideal_time=self.ideal_times,
|
||||
bool_dict=self.bool_dict,
|
||||
float_dict=self.float_dict)
|
||||
float_dict=self.float_dict,
|
||||
timings_dict=self.timings_dict)
|
||||
|
||||
self.uml_creator.update_uml(operator_config=self.operator_params,
|
||||
system_config=self.system_params,
|
||||
request_generator=self.request_generator,
|
||||
ideal_time=self.ideal_times,
|
||||
bool_dict=self.bool_dict,
|
||||
float_dict=self.float_dict)
|
||||
float_dict=self.float_dict,
|
||||
timings_dict=self.timings_dict)
|
||||
|
||||
|
||||
def _update_settings(self, _):
|
||||
@ -67,13 +71,15 @@ class app:
|
||||
request_generator=self.request_generator,
|
||||
ideal_time=self.ideal_times,
|
||||
bool_dict=self.bool_dict,
|
||||
float_dict=self.float_dict)
|
||||
float_dict=self.float_dict,
|
||||
timings_dict=self.timings_dict)
|
||||
|
||||
self.plotter.update_data(operator_config=self.operator_params,
|
||||
system_config=self.system_params,
|
||||
opt=self.opt_algorithm,
|
||||
bool_dict=self.bool_dict,
|
||||
float_dict=self.float_dict)
|
||||
float_dict=self.float_dict,
|
||||
timings_dict=self.timings_dict)
|
||||
|
||||
def _show_settings(self):
|
||||
self.operSettings.show()
|
||||
|
@ -13,11 +13,14 @@ class PlotWindow:
|
||||
operator_config: dict,
|
||||
opt: OptAlgorithm,
|
||||
bool_dict: dict,
|
||||
float_dict: dict, show_settings_func):
|
||||
float_dict: dict,
|
||||
timings_dict: dict,
|
||||
show_settings_func):
|
||||
pg.setConfigOptions(antialias=True)
|
||||
self.opt = opt
|
||||
self.bool_dict = bool_dict
|
||||
self.float_dict = float_dict
|
||||
self.timings_dict = timings_dict
|
||||
self.scaler = int(system_config['UML_time_scaler'])
|
||||
self.WeldTime = operator_config['time_wielding'] #[sec]
|
||||
self.alpha = 100 #[0-255 прозрачность фона]
|
||||
@ -32,10 +35,12 @@ class PlotWindow:
|
||||
operator_config: dict,
|
||||
opt: OptAlgorithm,
|
||||
bool_dict: dict,
|
||||
float_dict: dict):
|
||||
float_dict: dict,
|
||||
timings_dict: dict):
|
||||
self.opt = opt
|
||||
self.bool_dict = bool_dict
|
||||
self.float_dict = float_dict
|
||||
self.timings_dict = timings_dict
|
||||
self.scaler = int(system_config['UML_time_scaler'])
|
||||
self.WeldTime = operator_config['time_wielding'] #[sec]
|
||||
self._getIdealTimings()
|
||||
@ -95,41 +100,54 @@ class PlotWindow:
|
||||
self.p13.clear()
|
||||
self.l13.clear()
|
||||
|
||||
self._plotRealData()
|
||||
times = np.arange(20000)/10
|
||||
self._plotIdealData(times)
|
||||
timings = self._plotRealData()
|
||||
#timings = np.arange(20000)/10
|
||||
self._plotIdealData(timings)
|
||||
|
||||
def _getIdealTimings(self):
|
||||
data = self.opt.Ts
|
||||
self.idealTime = [data['tclose'], data['tgrow'], self.opt.getMarkOpen(), data["tmovement"]]
|
||||
|
||||
def _form_idealdatGraph(self, times):
|
||||
self.idealPhase0 = (self.idealTime[0])*self.scaler #Подъезд
|
||||
self.idealPhase1 = (self.idealTime[0]+ self.idealTime[1])*self.scaler #Сжатие
|
||||
self.idealPhase2 = (self.idealTime[0]+ self.idealTime[1] + self.WeldTime)*self.scaler #Сварка
|
||||
self.idealPhase3 = (self.idealTime[0]+ self.idealTime[1] + self.idealTime[2] + self.WeldTime)*self.scaler #Разъезд
|
||||
self.idealPhase4 = (sum(self.idealTime[:4]) + self.WeldTime)*self.scaler #Последнее смыкание #TODO добавить идеальное время вместо 0.25
|
||||
self.x_splitter = np.array([[0, self.idealPhase0],
|
||||
[self.idealPhase0, self.idealPhase1],
|
||||
[self.idealPhase1, self.idealPhase2],
|
||||
[self.idealPhase2, self.idealPhase3],
|
||||
[self.idealPhase3, self.idealPhase4]])
|
||||
closure_start = self.timings_dict["closure"][0]*self.scaler
|
||||
compression_start = self.timings_dict["compression"][0]*self.scaler
|
||||
welding_start = self.timings_dict["welding"][0]*self.scaler
|
||||
opening_start = self.timings_dict["opening"][0]*self.scaler
|
||||
opening_end = self.timings_dict["opening"][1]*self.scaler
|
||||
|
||||
self.idealPhase0 = closure_start + (self.idealTime[0])*self.scaler #Подъезд
|
||||
self.idealPhase1 = compression_start + (self.idealTime[1])*self.scaler #Сжатие
|
||||
self.idealPhase2 = welding_start + (self.WeldTime)*self.scaler #Сварка
|
||||
self.idealPhase3 = opening_start + (self.idealTime[2])*self.scaler #Разъезд
|
||||
self.idealPhase4 = opening_end + (self.idealTime[3])*self.scaler #Последнее смыкание
|
||||
|
||||
self.x_splitter = np.array([[closure_start, self.idealPhase0],
|
||||
[compression_start, self.idealPhase1],
|
||||
[welding_start, self.idealPhase2],
|
||||
[opening_start, self.idealPhase3],
|
||||
[opening_end, self.idealPhase4]])
|
||||
data = []
|
||||
for time in times:
|
||||
if time <= self.idealPhase0:
|
||||
x_fe, x_me, v_fe, v_me, f = self.opt.calcPhaseClose(time/self.scaler)
|
||||
elif time <= self.idealPhase1:
|
||||
x_fe, x_me, v_fe, v_me, f = self.opt.calcPhaseGrow(time/self.scaler-self.idealTime[0])
|
||||
elif time <= self.idealPhase2:
|
||||
if time >= closure_start and time <= self.idealPhase0:
|
||||
x_fe, x_me, v_fe, v_me, f = self.opt.calcPhaseClose((time-closure_start)/self.scaler)
|
||||
elif time >= compression_start and time <= self.idealPhase1:
|
||||
x_fe, x_me, v_fe, v_me, f = self.opt.calcPhaseGrow((time-compression_start)/self.scaler)
|
||||
elif time >= welding_start and time <= self.idealPhase2:
|
||||
x_fe, x_me, v_fe, v_me, f = data[-1]
|
||||
elif time <= self.idealPhase3:
|
||||
x_fe, x_me, v_fe, v_me, f = self.opt.calcPhaseOpen(time/self.scaler-self.idealTime[0]-self.idealTime[1]-self.WeldTime)
|
||||
elif time >= opening_start and time <= self.idealPhase3:
|
||||
x_fe, x_me, v_fe, v_me, f = self.opt.calcPhaseOpen((time-opening_start)/self.scaler)
|
||||
elif time >= opening_end and time <= self.idealPhase4:
|
||||
x_fe, x_me, v_fe, v_me, f = self.opt.calcPhaseMovement((time-opening_end)/self.scaler)
|
||||
else:
|
||||
x_fe, x_me, v_fe, v_me, f = self.opt.calcPhaseMovement(time/self.scaler-sum(self.idealTime[:3])-self.WeldTime)
|
||||
if data:
|
||||
x_fe, x_me, v_fe, v_me, f = data[-1]
|
||||
else:
|
||||
x_fe, x_me, v_fe, v_me, f = 0,0,0,0,0
|
||||
data.append([x_fe, x_me, v_fe, v_me, f])
|
||||
data = np.array(data).T
|
||||
return data
|
||||
|
||||
|
||||
def _plotRealData(self):
|
||||
for i, (key, dat) in enumerate(self.float_dict.items()):
|
||||
dat = np.array(dat).T
|
||||
|
Binary file not shown.
@ -8,31 +8,30 @@ class UMLCreator:
|
||||
request_generator: Request,
|
||||
ideal_time: list[float],
|
||||
bool_dict: dict,
|
||||
float_dict: dict):
|
||||
float_dict: dict,
|
||||
timings_dict: dict):
|
||||
self._request_generator = request_generator
|
||||
self._ideal_time = ideal_time
|
||||
self.bool_dict = bool_dict
|
||||
self.float_dict = float_dict
|
||||
self.timings_dict = timings_dict
|
||||
self.scaler = int(system_config['UML_time_scaler'])
|
||||
self.WeldTime = operator_config['time_wielding']
|
||||
|
||||
|
||||
def _build_data(self):
|
||||
sig = [
|
||||
"Closing",
|
||||
"Relief",
|
||||
"Squeeze",
|
||||
"Welding"
|
||||
]
|
||||
closure = [self.bool_dict[sig[0]][1][0], self.bool_dict[sig[0]][2][0]]
|
||||
compression = [self.bool_dict[sig[2]][1][0], self.bool_dict[sig[2]][2][0]]
|
||||
opening = [self.bool_dict[sig[1]][1][0], self.bool_dict[sig[1]][-1][0]]
|
||||
|
||||
closure = self.timings_dict["closure"]
|
||||
compression = self.timings_dict["compression"]
|
||||
welding = self.timings_dict["welding"]
|
||||
opening = self.timings_dict["opening"]
|
||||
real_data = [
|
||||
[closure[0]*self.scaler, 'closure #green'],
|
||||
[closure[1]*self.scaler, '{-}'],
|
||||
[compression[0]*self.scaler+0.0001, 'compression #green'],
|
||||
[compression[1]*self.scaler, 'welding #green'],
|
||||
[compression[1]*self.scaler, '{-}'],
|
||||
[welding[0]*self.scaler+0.0001, 'welding #green'],
|
||||
[welding[1]*self.scaler, '{-}'],
|
||||
[opening[0]*self.scaler+0.0001, 'opening #green'],
|
||||
[opening[1]*self.scaler, '{-}'],
|
||||
]
|
||||
@ -101,14 +100,17 @@ class UMLCreator:
|
||||
request_generator: Request,
|
||||
ideal_time: list[float],
|
||||
bool_dict: dict,
|
||||
float_dict: dict):
|
||||
float_dict: dict,
|
||||
timings_dict: dict):
|
||||
|
||||
self._request_generator = request_generator
|
||||
self._ideal_time = ideal_time
|
||||
self.bool_dict = bool_dict
|
||||
self.float_dict = float_dict
|
||||
self.timings_dict = timings_dict
|
||||
self.scaler = int(system_config['UML_time_scaler'])
|
||||
self.WeldTime = operator_config['time_wielding']
|
||||
|
||||
|
||||
real, client, ideal, bool_ = self._build_data()
|
||||
self._generate_svg(real, client, ideal, bool_)
|
||||
|
Binary file not shown.
@ -2,28 +2,43 @@ import pandas as pd
|
||||
import numpy as np
|
||||
|
||||
class DiagramParser:
|
||||
def __init__(self):
|
||||
def __init__(self, system_config: dict):
|
||||
self.data = pd.DataFrame({})
|
||||
self.signals = [system_config["Closure_signal"],
|
||||
system_config["Squeeze_signal"],
|
||||
system_config["Welding_signal"],
|
||||
system_config["Release_signal"]]
|
||||
|
||||
self.boolDict = {}
|
||||
self.floatDict = {}
|
||||
self.timingsDict = {}
|
||||
|
||||
def setData(self, path):
|
||||
self.data = pd.read_csv(path)
|
||||
|
||||
def getBoolDict (self):
|
||||
boolDict = {}
|
||||
for signalName in self.data.columns:
|
||||
if type (self.data[signalName].iloc[0]) == np.bool:
|
||||
boolDict[signalName] = self._getBoolChanges(signalName)
|
||||
return boolDict
|
||||
self.boolDict[signalName] = self._getBoolChanges(signalName)
|
||||
|
||||
def getFloatDict (self):
|
||||
floatDict = {}
|
||||
for signalName in self.data.columns:
|
||||
if type (self.data[signalName].iloc[0]) == np.float64:
|
||||
floatDict[signalName] = self._getFloatChanges(signalName)
|
||||
return floatDict
|
||||
self.floatDict[signalName] = self._getFloatChanges(signalName)
|
||||
|
||||
self.timingsDict["closure"] = [self.boolDict[self.signals[0]][1][0], self.boolDict[self.signals[0]][2][0]]
|
||||
self.timingsDict["compression"] = [self.boolDict[self.signals[1]][1][0], self.boolDict[self.signals[1]][2][0]]
|
||||
self.timingsDict["welding"] = [self.boolDict[self.signals[2]][1][0], self.boolDict[self.signals[2]][2][0]]
|
||||
self.timingsDict["opening"] = [self.boolDict[self.signals[3]][1][0], self.boolDict[self.signals[3]][-1][0]]
|
||||
|
||||
def _getBoolChanges(self, signalName):
|
||||
def getBoolDict (self) -> dict:
|
||||
return self.boolDict
|
||||
|
||||
def getFloatDict (self) -> dict:
|
||||
return self.floatDict
|
||||
|
||||
def getRealTimings(self) -> dict:
|
||||
return self.timingsDict
|
||||
|
||||
def _getBoolChanges(self, signalName) -> list:
|
||||
timeCode = self.data['time']
|
||||
signal_values = self.data[signalName]
|
||||
changes = []
|
||||
@ -38,7 +53,7 @@ class DiagramParser:
|
||||
return changes
|
||||
|
||||
|
||||
def _getFloatChanges(self, signalName):
|
||||
def _getFloatChanges(self, signalName) -> list:
|
||||
timeCode = self.data['time']
|
||||
signal_values = self.data[signalName]
|
||||
changes = []
|
||||
|
Loading…
Reference in New Issue
Block a user