import json from juce_init import START_JUCE_COMPONENT from gui_test import MainContentComponent from client_socket import SocketRobotArm import time class MyApp: with open("./robots.json", "r") as file: robots = json.load(file) def __init__(self): self.startRobot() self.startGui() def startGui(self): self.gui_app = START_JUCE_COMPONENT( MainContentComponent, name="ROBOT GUI", robotPanel={ "robots": self.robots, "updateRobot": self.updateRobot, "status": self.robot_app.get_status, }, statusPanel={ "status": self.robot_app.get_status, } ) def startRobot(self): self.robot_app = SocketRobotArm() def updateRobot(self, robot): if robot in self.robots: selected_robot = robot selected_robot = {"name": "test", "host": "127.0.0.1", "slave_id": 11} if self.robot_app.status == "connected": self.robot_app.close() time.sleep(0.3) else: self.robot_app.connect(selected_robot["host"], selected_robot["slave_id"]) if __name__ == "__main__": MyApp()