chore: без укакзания csv запускается в режиме демонстрации идеальных данных

This commit is contained in:
Andrew 2024-11-12 14:34:07 +03:00
parent 0587ca1a06
commit b6b7de2fcb
8 changed files with 74 additions and 55 deletions

View File

@ -20,6 +20,9 @@ class app:
self.operator_params = read_json("params/operator_params.json") self.operator_params = read_json("params/operator_params.json")
self.system_params = read_json("params/system_params.json") self.system_params = read_json("params/system_params.json")
self.parser = DiagramParser(system_config=self.system_params)
self.parser.setData("trace_samples/2024_11_08-19_30_52.csv")
self.opt_algorithm = OptAlgorithm(operator_config=self.operator_params, system_config=self.system_params) self.opt_algorithm = OptAlgorithm(operator_config=self.operator_params, system_config=self.system_params)
generator = Request(server_url='http://www.plantuml.com/plantuml/svg/') generator = Request(server_url='http://www.plantuml.com/plantuml/svg/')
self.operSettings = settingsWindow("params\operator_params.json", 'Operator', self._update_settings) self.operSettings = settingsWindow("params\operator_params.json", 'Operator', self._update_settings)
@ -29,8 +32,7 @@ class app:
self.uml_creator = UMLCreator(request_generator=generator) self.uml_creator = UMLCreator(request_generator=generator)
self.ideal_times = self._get_ideal_timings(self.opt_algorithm) self.ideal_times = self._get_ideal_timings(self.opt_algorithm)
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.bool_dict = self.parser.getBoolDict()
self.float_dict = self.parser.getFloatDict() self.float_dict = self.parser.getFloatDict()
self.timings_dict = self.parser.getRealTimings() self.timings_dict = self.parser.getRealTimings()

View File

@ -88,8 +88,10 @@ class PlotWindow:
self.p13.clear() self.p13.clear()
self.l13.clear() self.l13.clear()
if self.theor_mode:
timings = np.arange(20000)/10
else:
timings = self._plotRealData() timings = self._plotRealData()
#timings = np.arange(20000)/10
self._plotIdealData(timings) self._plotIdealData(timings)
def _getIdealTimings(self): def _getIdealTimings(self):
@ -97,6 +99,14 @@ class PlotWindow:
self.idealTime = [data['tclose'], data['tgrow'], self.opt.getMarkOpen(), data["tmovement"]] self.idealTime = [data['tclose'], data['tgrow'], self.opt.getMarkOpen(), data["tmovement"]]
def _form_idealdatGraph(self, times): def _form_idealdatGraph(self, times):
if self.theor_mode:
closure_start = 0
compression_start = self.idealTime[0]*self.scaler
welding_start = sum(self.idealTime[:2])*self.scaler
opening_start = (sum(self.idealTime[:2])+ self.WeldTime)*self.scaler
opening_end = (sum(self.idealTime[:3])+ self.WeldTime)*self.scaler
else:
closure_start = self.timings_dict["closure"][0]*self.scaler closure_start = self.timings_dict["closure"][0]*self.scaler
compression_start = self.timings_dict["compression"][0]*self.scaler compression_start = self.timings_dict["compression"][0]*self.scaler
welding_start = self.timings_dict["welding"][0]*self.scaler welding_start = self.timings_dict["welding"][0]*self.scaler

View File

@ -7,7 +7,7 @@ class UMLCreator:
def _build_data(self): def _build_data(self):
if not self.theor_mode:
closure = self.timings_dict["closure"] closure = self.timings_dict["closure"]
compression = self.timings_dict["compression"] compression = self.timings_dict["compression"]
welding = self.timings_dict["welding"] welding = self.timings_dict["welding"]
@ -23,6 +23,20 @@ class UMLCreator:
[opening[1]*self.scaler, '{-}'], [opening[1]*self.scaler, '{-}'],
] ]
ideal_data = [
[closure[0] * self.scaler, 'closure #yellow'],
[(self._ideal_time[0]+closure[0]) * self.scaler, '{-}'],
[compression[0] * self.scaler, 'compression #yellow'],
[(compression[0] + self._ideal_time[1]) * self.scaler, '{-}'],
[welding[0] * self.scaler, 'welding #yellow'],
[(welding[0] + self.WeldTime)*self.scaler, '{-}'],
[opening[0] * self.scaler, 'opening #yellow'],
[(opening[0] + self._ideal_time[2]) * self.scaler, '{-}'],
]
else:
real_data = []
client_data = [ client_data = [
[0.0 * self.scaler, 'closure'], [0.0 * self.scaler, 'closure'],
[0.165 * self.scaler, '{-}'], [0.165 * self.scaler, '{-}'],
@ -46,19 +60,11 @@ class UMLCreator:
] ]
return real_data, client_data, ideal_data, self.bool_dict return real_data, client_data, ideal_data, self.bool_dict
def _get_time(self, signals = '', states = ''):
res = []
for i, sig in enumerate(signals):
if states: state = states[i]
else: state = 'high'
index1 = next ((i for i, _ in enumerate(self.bool_dict[sig]) if _[1]==state), -1)
time = self.bool_dict[sig][index1][0]
res.append(time)
return res
def _generate_svg(self, real_data, client_data, ideal_data, bool_data) -> None: def _generate_svg(self, real_data, client_data, ideal_data, bool_data) -> None:
try: try:
self._request_generator.clear() self._request_generator.clear()
if not self.theor_mode:
self._request_generator.addLineStyle('biba', 'red', 2) self._request_generator.addLineStyle('biba', 'red', 2)
for i, [signal, changes] in enumerate(bool_data.items()): for i, [signal, changes] in enumerate(bool_data.items()):
@ -71,6 +77,7 @@ class UMLCreator:
self._request_generator.addConcise('RD', 'Real data') self._request_generator.addConcise('RD', 'Real data')
self._request_generator.setTimestamps('RD', real_data) self._request_generator.setTimestamps('RD', real_data)
self._request_generator.addConcise('CD', 'Client data') self._request_generator.addConcise('CD', 'Client data')
self._request_generator.setTimestamps('CD', client_data) self._request_generator.setTimestamps('CD', client_data)
self._request_generator.addConcise('ID', 'Ideal data') self._request_generator.addConcise('ID', 'Ideal data')

View File

@ -17,7 +17,7 @@ class DiagramParser:
def setData(self, path): def setData(self, path):
if not path: if not path:
self.theor_mode = True self.theor_mode = True
else:
self.data = pd.read_csv(path) self.data = pd.read_csv(path)
for signalName in self.data.columns: for signalName in self.data.columns:
@ -31,7 +31,7 @@ class DiagramParser:
self.timingsDict["closure"] = [self.boolDict[self.signals[0]][1][0], self.boolDict[self.signals[0]][2][0]] 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["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["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]] self.timingsDict["opening"] = [self.boolDict[self.signals[3]][1][0], self.boolDict[self.signals[3]][2][0]]
def getBoolDict (self) -> dict: def getBoolDict (self) -> dict:
return self.boolDict return self.boolDict