From dc4c74471f79a499137956699f4734967da54c58 Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 11 Nov 2024 14:28:21 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20~=D1=81=D1=82=D0=B8=D0=BB=D1=8C~=20=D0=B8=20?= =?UTF-8?q?=D1=81=D0=BE=D1=85=D1=80=D0=B0=D0=BD=D0=B5=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=BD=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B5=D0=BA=20=D0=B2=20jso?= =?UTF-8?q?n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- params/system_params.json | 34 +++++++++--------- src/gui/__pycache__/app.cpython-310.pyc | Bin 2366 -> 2578 bytes .../__pycache__/plot_window.cpython-310.pyc | Bin 7454 -> 7871 bytes .../__pycache__/qt_settings.cpython-310.pyc | Bin 5227 -> 5223 bytes .../settings_window.cpython-310.pyc | Bin 2319 -> 2511 bytes src/gui/app.py | 8 ++++- src/gui/plot_window.py | 22 +++++++++--- src/gui/qt_settings.py | 2 +- src/gui/settings_window.py | 17 +++++---- .../__pycache__/json_tools.cpython-310.pyc | Bin 850 -> 869 bytes src/utils/json_tools.py | 2 +- 11 files changed, 53 insertions(+), 32 deletions(-) diff --git a/params/system_params.json b/params/system_params.json index bf23a5d..f6e5bd7 100644 --- a/params/system_params.json +++ b/params/system_params.json @@ -1,19 +1,19 @@ { - "a_max_1" : 5.41, - "v_max_1" : 0.108, - "a_max_2" : 35.81, - "v_max_2" : 0.678, - "mass_1" : 257, - "mass_2" : 1, - "k_hardness_1" : 1759291, - "k_hardness_2" : 0, - "torque_max_1" : 20, - "torque_max_2" : 0, - "transmission_ratio_1" : 0.00125, - "transmission_ratio_2" : 1, - "position_start_1" : 0.080, - "position_start_2" : 0.080, - "k_prop" : 0.05, - "time_capture" : 100000, + "a_max_1": 5.41, + "v_max_1": 0.108, + "a_max_2": 35.81, + "v_max_2": 0.678, + "mass_1": 257, + "mass_2": 1, + "k_hardness_1": 1759291, + "k_hardness_2": 0, + "torque_max_1": 20, + "torque_max_2": 0, + "transmission_ratio_1": 0.00125, + "transmission_ratio_2": 1, + "position_start_1": 0.08, + "position_start_2": 0.08, + "k_prop": 0.05, + "time_capture": 100000, "UML_time_scaler": 1000 -} +} \ No newline at end of file diff --git a/src/gui/__pycache__/app.cpython-310.pyc b/src/gui/__pycache__/app.cpython-310.pyc index 1e463f2d38ae7fc5543a0ff1f2e535f12ceab85a..2788db1b0d417cb57d41cf69c18fc24bf66085cd 100644 GIT binary patch delta 518 zcmY*VJxc>Y5ZyWNW3$;@^b#cqf*)W!(MUuP5d=RQAr^KvA?Eb_j^3RJ5)j2sY@F6Y zOFPBhLVty+tnI8ta5hH-cX^MuJCE7f_u|}S?OG}&7_HZjqW>tL>>hwQ9D!-+$xF5- zywoal?dM(C*Ps*M+a?7k^E@HE#cus*xXyNL&$u@0telS8>7)@l2z0X}2+}jJ4XQf$ zq+e;Si8IDvvEhVUwUctV5k=bvepuc-KBztzK_B%Eq@o^0{fY*N+zg%@{)jp^q`wg@ z?bRyL!ge)kRs&1j+vR^PQ8%aZ-BbvNhy)05G#jKQL4v92(Axalv~b;g%eh9-OU`(P zE~Vng)57*?##0-%Z33mfR$MSe%E&u=k delta 317 zcmbOvvQLOFpO=@50SHc9HcbD)y^&9rkTNCPtCT51Gxm*nx_i zfw*|aWF?kDwG`G~)*6O*z7qZ#hAbu^764*4Am##Mo)k8)tl;FmEZs~iSton3s>!Zo zEm8#PFX90avLHekM5q7>O`*vPS<_`e{98QfsU>bX`H3YinaL$!*&>kDlTFwxRV9Ip zVl^Pa#mL1d#KgzQ!^FeL!^psXFRoqP3D2kgBTnTUCYkO6^0WK6F}D%3CZY53TZqDz*QA#x`a}W_7+j z|9}3=IsfI%e0t)^RIZWDnhHF>`>I^sb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|#?3kY)v=mL8OVdMPn z?JFE^3po0kmdxHl*$hA1zimf1c3>G(jQVq0lW7VJcGvRGjA{8|54XSv%z zT5XLFsAMaKtqcu*iQ^)~BBswpe;tGJIXgIhT-df|fu+Tp#YG8AZP_W<@>OW1LT6Ae z!F-E0-sX;ZAwJ@5=1Q*3(VD65{Y5hKI?1{^#(CL7Q18*rj4n7< z$~NlF#juQbizrcBtu`w4W*m@Yz)CyH4UfsF6i*sF?I40z{e)kxF)zGcVZsaCa3f11 a{cxp52O7S66d%t3A8B3E;hN9LJ<9)Br@ABn diff --git a/src/gui/__pycache__/qt_settings.cpython-310.pyc b/src/gui/__pycache__/qt_settings.cpython-310.pyc index 02debb7ba474d19cc76b0742bd8acf1d19ac5431..f834e679e749e42a624beb674c1a6fa2b7b47ef7 100644 GIT binary patch delta 71 zcmaE@@mzy9pO=@50SIg#8>Xjj!~ocRGr-1`^s1Gw_28fO=@mbzTs)m2^JS5@;}^Y?51v{ow< z`2F<9-Ttrc%D+j!UcK}F7lH_TR32A)RZ2c1!V&JbM7WX*> z+G|K(ltty7^_sGgUt1GO1nm|psIGo|R1c`B9O*EXS|^i!8m}6y)jxlBJb2l7VVF!3 z9fqcQVc(DRK$Wuwd+e0p3aA4X+BHy1*>CLG-3n*{S2o&w6k8yErs@^cU%eDJP-}o_ zWl#CX%hy0#kepz8nl8wY!Q$r(k|kZDilCM$^`+jAR5VVNgZ`KC75ZO^Zu}FKXn6_j zI$TLD5FTyP=Wkr#d6G=TG%H!}(MQ>?^}#Y{f(b6HAK02wvH+?Adk+9%DU790XVTcm z(P%D>)s2p&aiUl!(@DUJ8>$1>0;d3NY3sH*td~&ZK{66bPSl%_-2pV4n+~QY2h*9Na1b=r+wiA2 z2;;;`Mp|x&EGV&OSZ!#&r2i0TJ_f5$Ep)hv0;_3iP|2bxYze+;cEbs7<5^dqj%0Tr zr8fLXr>1f;DB1y!k@xI#r?YdVA)65JEm$ck9&OP!by%Hx)Td=yr`h+;z2$u{CBQ@o zYe+vKPa9{zan9B-Q-@q#2c56c2F-(~yX45h9dN|<3KrmX914XHH(;^o&_OsOhR&{( zUtzJ|g_Tx8lpRQ=3RP#{WS_d*^iKAr+gaWQi^3r+W~yMvSfd0wuAmp;7)vCvE`pg_ z7{;S0O=CG4h2j6+Yh#FFHgW!Or8s0BX;ZJ_ao_UXc1>M;8^%#G3B%{@{fv7LXe)c@ z$y+@)Rq;-Lo+uY%-2-9V$4?RgEnGONJJ~PZ_U?bo7aG24yxs9s%t!J=Y>gCi@kkYT PuQLG5yq$6Z-TLca^j#v~ delta 1087 zcmZ8g&1)1%6t7p+Q&aQR$s{p;FlH4mw#H?Hh%5NDtFWHLFaa?j?KoA&PC7GVbwvNbp1VWo*sxexr=3RMsYTcNua2_MB@ zU>69V{3=cnnnf}1UW;F!%ppoy#x?;DpK#32y38I0ljQt0m_1GE@lb`oW24lBiAmFF zu#qgHOTtmOi{3r>*~Q+Cvt1VOhgez-&4rh~8JVK;doLcFKw95@@=mRF=thO%pto(p zFz^nGo*}E)GH>izMBgWFhZ`ncv&M8&JMO1rYpA@0X5+yeEV=c{o&D#iWh`e?wg)L} zat)eipv4~|W1&dB3ESft&nwuxm;x}wQhS8bYOe4rk%_#PaU`-b6?o6`dUoi^@b*pynknhdVSe_fanWc$^&D#vni7Nr+~J zQ<0(xbx`1=Y;t$4dUgL2UPahgSZ=|6_O!7F8RUFQIzuF;>?V69N&9~@ymGk?3oW@J zY6D)0_cs%pqo*+z1OiXn<57O(&kcHQS{2hO{;TG~H{c1sIg?x#J2sPN(_Ne^d4 z%@m%F`lFnO*AL;6Drn(S(xQ>TrJmW{^0%h1=5z~XaE2J diff --git a/src/gui/app.py b/src/gui/app.py index df74016..25dfd92 100644 --- a/src/gui/app.py +++ b/src/gui/app.py @@ -16,6 +16,7 @@ class app: self.sysSettings = settingsWindow("params\system_params.json", 'System', self._update_settings) self._load_preset() + def _get_ideal_timings(self, opt: OptAlgorithm) -> list[float]: data = opt.Ts @@ -37,7 +38,8 @@ class app: system_config=self.system_params, opt=self.opt_algorithm, bool_dict=self.bool_dict, - float_dict=self.float_dict) + float_dict=self.float_dict, + show_settings_func=self._show_settings) self.uml_creator = UMLCreator(system_config=self.system_params, request_generator=self.request_generator, @@ -63,6 +65,10 @@ class app: opt=self.opt_algorithm, bool_dict=self.bool_dict, float_dict=self.float_dict) + + def _show_settings(self): + self.operSettings.show() + self.sysSettings.show() if __name__ == '__main__': diff --git a/src/gui/plot_window.py b/src/gui/plot_window.py index ac3af8b..98107b2 100644 --- a/src/gui/plot_window.py +++ b/src/gui/plot_window.py @@ -1,4 +1,5 @@ import pyqtgraph as pg +from pyqtgraph.Qt import QtWidgets import numpy as np from src.gui import qt_settings as qts @@ -12,7 +13,7 @@ class PlotWindow: operator_config: dict, opt: OptAlgorithm, bool_dict: dict, - float_dict: dict): + float_dict: dict, show_settings_func): pg.setConfigOptions(antialias=True) self.opt = opt self.bool_dict = bool_dict @@ -22,7 +23,8 @@ class PlotWindow: self.alpha = 100 #[0-255 прозрачность фона] self._getIdealTimings() - self._init_app() + self._init_ui() + self.settings_button.clicked.connect(show_settings_func) def update_data(self, @@ -39,11 +41,20 @@ class PlotWindow: self._getIdealTimings() self._updatePlots() - def _init_app(self): + def _init_ui(self): + self.widget = QtWidgets.QWidget() + layout = QtWidgets.QVBoxLayout() + self.widget.setLayout(layout) + self.win = pg.GraphicsLayoutWidget(show=True, title="") self.win.resize(1000,600) self.win.setWindowTitle('') + layout.addWidget(self.win) + self.settings_button = QtWidgets.QPushButton("Show settings") + self.settings_button.setFixedWidth(160) + layout.addWidget(self.settings_button) + self.p11, self.l11 = self._init_graph('Electrode force, closure', 'Force', 'N', 'Time', 'ms') #self.p21, _ = self._init_graph('Electrode force, compression', 'Force', 'N', 'Time', 'ms') #self.p31, _ = self._init_graph('Electrode force, compression', 'Force', 'N', 'Time', 'ms') @@ -63,8 +74,9 @@ class PlotWindow: self.p11.setAutoVisible(x=False, y=True) self.p12.setAutoVisible(x=False, y=True) self.p13.setAutoVisible(x=False, y=True) - self._updatePlots() + self.widget.setStyleSheet(qts.dark_style) + self.widget.show() def _init_graph(self, title, Yname, Yunits, Xname, Xunits): plot = self.win.addPlot(title = title) @@ -82,7 +94,7 @@ class PlotWindow: self.l12.clear() self.p13.clear() self.l13.clear() - + self._plotRealData() times = np.arange(20000)/10 self._plotIdealData(times) diff --git a/src/gui/qt_settings.py b/src/gui/qt_settings.py index 928f9f0..ca8e541 100644 --- a/src/gui/qt_settings.py +++ b/src/gui/qt_settings.py @@ -57,7 +57,7 @@ QRadioButton { """ dark_style = """ -QMainWindow { +QWidget { background-color: #0D1117; /* Тёмный, современный цвет для фона */ font-family: "Segoe UI", sans-serif; font-size: 14px; diff --git a/src/gui/settings_window.py b/src/gui/settings_window.py index 57a6908..4c052b4 100644 --- a/src/gui/settings_window.py +++ b/src/gui/settings_window.py @@ -3,6 +3,7 @@ from pyqtgraph.Qt import QtWidgets from pyqtgraph.parametertree import Parameter, ParameterTree from src.utils.json_tools import read_json, write_json +from src.gui import qt_settings as qts class settingsWindow(QtWidgets.QWidget): def __init__(self, path: str, name: str, upd_func): @@ -20,32 +21,34 @@ class settingsWindow(QtWidgets.QWidget): self.data = read_json(self.settingsPath) def write_settings(self): + self.getParams() write_json(self.settingsPath, self.data) def _getTreeStructure(self) -> list: params = [] for key, value in self.data.items(): params.append({'name': str(key), 'type': type(value).__name__, 'value': value}) + params.append({'name': 'Save', 'type': 'action'}) return params def _init_ui(self): temp = self._getTreeStructure() - self.params = Parameter.create(name='params', type='group', children=temp) - + self.params = Parameter.create(name=self.name, type='group', children=temp) + self.params.param('Save').sigActivated.connect(self.write_settings) ParamsTree = ParameterTree() - ParamsTree.setParameters(self.params) - ParamsTree.setWindowTitle('Settings ,f,f') + ParamsTree.setParameters(self.params, showTop=True) layout = QtWidgets.QGridLayout() layout.addWidget(ParamsTree, 0,0) self.setLayout(layout) - - self.show() + self.setStyleSheet(qts.white_style) + # self.show() def getParams(self) -> dict: self.data = {} for p in self.params: - self.data[p.name()] = p.value() + if p.name() != 'Save': + self.data[p.name()] = p.value() return self.data if __name__ == '__main__': diff --git a/src/utils/__pycache__/json_tools.cpython-310.pyc b/src/utils/__pycache__/json_tools.cpython-310.pyc index a0ec4c231f8da93c0d9c4d6c99ad35c599afba37..d0bd5885394afaf4704678e1c8621fa4a5c50813 100644 GIT binary patch delta 187 zcmcb__LPk`pO=@50SMY(7^eGd4h4Py;c z3QG!WFEb-UI712p3lKI#*})8k48_ulFF1T-f*DvCO4ur`C&x31^RxIBu>uV&VgnMl7|SP5Vanm- cV^sUk$Hc