This commit is contained in:
Kseninia Mikhaylova 2024-10-15 15:07:14 +03:00
parent 8e7be135b4
commit d9305bd88e
119 changed files with 5 additions and 106 deletions

View File

@ -23,7 +23,7 @@ class Status(QWidget):
self.layout.addWidget(self.statusLabel) self.layout.addWidget(self.statusLabel)
self.setLayout(self.layout) self.setLayout(self.layout)
self.setFixedSize(200, 100) # Установка фиксированного размера виджета self.setFixedHeight(100)
def paintEvent(self, event): def paintEvent(self, event):
# Установка цвета фона # Установка цвета фона

View File

@ -1,96 +0,0 @@
import os
import sys
import glob
import time
import traceback
from pathlib import Path
from functools import wraps
try:
import popsicle as juce
except ImportError:
folder = Path(__file__).parent.parent / "build"
for ext in ["*.so", "*.pyd"]:
path_to_search = folder / "**" / ext
for f in glob.iglob(str(path_to_search), recursive=True):
if os.path.isfile(f):
sys.path.append(str(Path(f).parent))
break
import popsicle as juce
def START_JUCE_COMPONENT(ComponentClass, name, **kwargs):
class DefaultWindow(juce.DocumentWindow):
component = None
def __init__(self):
super().__init__(
juce.JUCEApplication.getInstance().getApplicationName(),
juce.Desktop.getInstance()
.getDefaultLookAndFeel()
.findColour(juce.ResizableWindow.backgroundColourId),
juce.DocumentWindow.allButtons,
True,
)
self.component = ComponentClass(**kwargs)
self.setResizable(True, True)
self.setContentNonOwned(self.component, True)
self.centreWithSize(
self.component.getWidth(),
self.component.getHeight() + self.getTitleBarHeight(),
)
self.setAlwaysOnTop(kwargs.get("alwaysOnTop", False))
self.setVisible(True)
def __del__(self):
self.clearContentComponent()
if self.component:
self.component.setVisible(False)
del self.component
def closeButtonPressed(self):
juce.JUCEApplication.getInstance().systemRequestedQuit()
class DefaultApplication(juce.JUCEApplication):
window = None
def __init__(self):
super().__init__()
def getApplicationName(self):
return name
def getApplicationVersion(self):
return "1.0"
def initialise(self, commandLineParameters):
self.window = DefaultWindow()
juce.MessageManager.callAsync(lambda: juce.Process.makeForegroundProcess())
def shutdown(self):
if self.window:
del self.window
def systemRequestedQuit(self):
self.quit()
# def unhandledException(self, ex: Exception, file: str, line: int):
# if hasattr(ex, "__traceback__"):
# print("Traceback (most recent call last):")
# traceback.print_tb(ex.__traceback__)
# print(ex)
# if isinstance(ex, KeyboardInterrupt):
# juce.JUCEApplication.getInstance().systemRequestedQuit()
juce.START_JUCE_APPLICATION(
DefaultApplication,
catchExceptionsAndContinue=kwargs.get("catchExceptionsAndContinue", False),
)
return DefaultApplication

View File

@ -33,13 +33,9 @@ class SocketRobotArm:
self.socket = None self.socket = None
self.host = None self.host = None
self.port = 9760 self.port = 9760
self.slave_id = None
self.status: SocketRobotArm.Status = "not_connected" self.status: SocketRobotArm.Status = "not_connected"
# self.host = MODBUS_SERVER_HOST
# if kwargs['test'] or len(sys.argv) and "--test" in sys.argv:
# self.host = "127.0.0.1"
# self.port = 65432
self.physics_client = None self.physics_client = None
self.body_id = None self.body_id = None
threading.Thread(target=self.run_pybullet, daemon=True).start() threading.Thread(target=self.run_pybullet, daemon=True).start()
@ -65,8 +61,7 @@ class SocketRobotArm:
self.socket.close() self.socket.close()
self.socket = None self.socket = None
self.status = "not_connected" self.status = "not_connected"
# self.socket = None self.slave_id = None
# sys.exit()
def connect(self, host, slave_id): def connect(self, host, slave_id):
self.host = host self.host = host

View File

@ -24,7 +24,7 @@ def two_byte_convert(result):
return value return value
def bulb(addr, new_state, client): def bulb(addr, new_state, client, slave_id):
try: try:
coils = client.read_coils(addr, 1, MODBUS_SLAVE_ID) coils = client.read_coils(addr, 1, MODBUS_SLAVE_ID)
# print("читаем начальное состояние", coils.bits) # print("читаем начальное состояние", coils.bits)

Some files were not shown because too many files have changed in this diff Show More