Ejemplo n.º 1
0
    def __init__(self):
        super().__init__()
        self.app = QApplication(sys.argv)
        self.window = gui.GUI()
        self.displayTh = display.display()
        self.dataTh = data.TestData()

        WaveGen.UZPOut.generateLUT()

        # self.datatimer = QTimer()
        # self.datatimer.setInterval(10)
        # self.datatimer.timeout.connect(self.dataTh.start)

        self.disptimer = QTimer()
        self.disptimer.setInterval(c.PERIOD_OF_DISP)
        self.disptimer.timeout.connect(self.displayTh.start)

        self.window.startScanning.connect(self.startScans)
        self.window.endScanning.connect(self.endScans)
        self.displayTh.loadedImage.connect(self.relayImage)
        # self.dataTh.loadedImage.connect(self.relayImage)
        self.sendImage.connect(self.window.showGivenImage)

        self.window.show()
        sys.exit(self.app.exec_())
Ejemplo n.º 2
0
def run():
    try:
        board = Board.Board()
        gui = Gui.GUI(board)

        gui.graphics(board)
    except KeyboardInterrupt:
        print('\nQuit')
Ejemplo n.º 3
0
def start_label():
    q_json = Queue()  #队列,用于存储json数据,自动带锁
    q_idx = Queue()  #队列,用于存储图片
    dw = Draw.draw()
    gui = Gui.GUI()
    p1 = Process(target=dw.start_draw, args=(q_json, q_idx))  # 创建两个子进程
    p2 = Process(target=gui.start_gui, args=(q_json, q_idx))
    p1.daemon = True  #设置守护进程
    p2.daemon = True
    p1.start()
    p2.run()  #在linux上p2.start()可以执行,但是在window有问题,不知道为啥,所以改成了p2.run()就可以了
    p1.join()  #阻塞父进程,让父进程等待p1进程结束父进程才结束,因为父进程在产生子进程后会异步执行
    p2.terminate()  #若p1进程结束就杀死p2进程
Ejemplo n.º 4
0
    def __init__(self):
        super().__init__()
        self.app = QApplication(sys.argv)
        self.window = gui.GUI()
        self.displayTh = display.display()
        self.dataTh = data.AnalogData()

        self.datatimer = QTimer()
        self.datatimer.setInterval(100)
        self.datatimer.timeout.connect(self.dataTh.start)

        self.disptimer = QTimer()
        self.disptimer.setInterval(2000)
        self.disptimer.timeout.connect(self.displayTh.start)

        self.window.startScanning.connect(self.startScans)
        self.window.endScanning.connect(self.endScans)
        self.displayTh.loadedImage.connect(self.relayImage)
        self.sendImage.connect(self.window.showGivenImage)

        self.window.show()
        sys.exit(self.app.exec_())
Ejemplo n.º 5
0
def minUIGame(board, playerSide, ai, useCamera):
    WHITE = True
    BLACK = False
    
    parserWhite = InputParser(board, WHITE)
    parserBlack = InputParser(board, BLACK)
    parser = parserWhite
    physInputWhite = PhysInput(WHITE)
    physInputBlack = PhysInput(BLACK)
    physInput = physInputWhite
    PvP = not ai
    chessGUI = None
    if __name__ != '__main__':
        chessGUI = Gui.GUI(physInput)
    
    while True:
        if not chessGUI:
            if showBoard:
                print()
                print(board)
                print()
        if board.isCheckmate():
            if PvP:
                if board.currentSide == WHITE: #white has no legal moves
                    winner = 'Black'
                else:
                    winner = 'White'
                display("Checkmate! {} wins!".format(winner), chessGUI, title="Game Over")
            elif board.currentSide == playerSide:
                display("Checkmate, you lost", chessGUI, title="Game Over")
            else:
                display("Checkmate! You won!", chessGUI, title="Game Over")
            return

        if board.isStalemate():
            display("Stalemate", chessGUI, title="Game Over")
            return

        if PvP or board.currentSide == playerSide:
            # printPointAdvantage(board)
            if board.currentSide == WHITE:
                parser = parserWhite
                physInput = physInputWhite
                plRep = 'Wh'
            else:
                parser = parserBlack
                physInput = physInputBlack
                plRep = 'Bl'
            if not PvP:
                plRep = 'Pl'

            if chessGUI:
                chessGUI.physInput = physInput
                command = physInput.getPlayerMove(useCamera)
            else:
                command = input(plRep + " : ")
            
            move = None
            if command.lower() == 'u':
                undoLastTwoMoves(board)
                continue
            elif command.lower() == '?':
                printCommandOptions()
                continue
            elif command.lower() == 'l':
                printAllLegalMoves(board, parser)
                continue
            elif command.lower() == 'r':
                move = getRandomMove(board, parser)
            elif command.lower() == 'p':
                print()
                print(board)
                print()
                continue
            elif command.lower() == 's' or command.lower() == 'save':
                saveGame(board)
                continue
            elif command.lower() == 'exit' or command.lower() == 'quit' \
                or command.lower() == 'q':
                return
            try:
                move = parser.convertInput(command)
            except ValueError as error:
                display("{}\nCorrect your move and press OK.".format(error), chessGUI, title="Error")
                continue
            makeMoveReadable(move, board, False)
            if PvP:
                player = "WHITE"
                if board.currentSide == BLACK:
                    player = "BLACK"
                if useCamera:
                    physInput.promptCamera(True)
                chessGUI.showinfo("Next move", "{}, make your next move and press OK.".format(player))

        else:
            #print("AI thinking...")
            move = ai.getBestMove()
            move.notation = parser.notationForMove(move)
            makeMoveReadable(move, board, True, chessGUI)
Ejemplo n.º 6
0
import Gui as gui

if __name__ == "__main__":
    app = gui.GUI()


Ejemplo n.º 7
0
 def __init__(self):
     self.data = None
     self.gui = Gui.GUI()
     self.is_visible = True
     self.data = self.gui.start(self.on_tick, 1500)
Ejemplo n.º 8
0
        # Here is the Controller created with a custom interface, here you can use a SoftwareInterface or a HardwareInterface
        controllerObject = CustomController.Controller(
            pumpA, pumpB, valveA, valveB, heater, ledRedA, ledGreenA, ledRedB,
            ledGreenB, ledGreenM, ledYellowM, colour, temperature, level, cup,
            keypad, lcd)

    controllerObject.prepare()

    # ======================== SIMULATOR GUI PREPERATIONS (IF REQUIRED) ========================

    if args.sim:
        simulator._Simulator__controller = controllerObject

        # Here is the GUI created. This is the GUI, that the simulator will use. Thereby it uses our custom controller.
        simulator._Simulator__gui = Gui.GUI(simulator._Simulator__plant,
                                            controllerObject,
                                            simulator._Simulator__monitor)

        # The GUI still has to be actived by the simulator.
        simulator.run()

    if args.hw:
        while True:
            try:
                time.sleep(0.5)
                controllerObject.update()

                print(controllerObject.state)
                sys.stdout.flush()
            except KeyboardInterrupt:
                exit(0)