public void run() { // we'll break on interrupts try { while (true) { machine.runCommand(new replicatorg.drivers.commands.UpdateManualControl()); // driver.readTemperature(); Thread.sleep(700); // update every .7 s } } catch (InterruptedException e) { } }
private ControlPanelWindow(MachineInterface newMachine) { super("Control Panel"); Image icon = Base.getImage("images/icon.gif", this); setIconImage(icon); // save our machine! machine = newMachine; machine.runCommand(new InvalidatePosition()); // Listen to it-- stop and close if we're in build mode. Base.getMachineLoader().addMachineListener(this); // default behavior setDefaultCloseOperation(DISPOSE_ON_CLOSE); // no menu bar. setJMenuBar(createMenuBar()); chooser = new JColorChooser(Color.BLACK); ActionListener okListener = new ActionListener() { public void actionPerformed(ActionEvent e) { Color ledColor = chooser.getColor(); Base.logger.severe("running setLedStrip"); try { machine.getDriver().setLedStrip(ledColor, 0); } catch (replicatorg.drivers.RetryException f) { Base.logger.severe("foo" + f.toString()); } // machine.runCommand(new SetLedStrip(ledColor, 0)); ledStripButton.setText(ShowColorChooserAction.buttonStringFromColor(ledColor)); } }; ledStripButton = new JButton(new ShowColorChooserAction(this, chooser, okListener, null, Color.BLACK)); // create all our GUI interfaces mainPanel = new JPanel(); mainPanel.setLayout(new MigLayout("gap 5, ins 5, flowy")); jogPanel = new JogPanel(machine); mainPanel.add(jogPanel, "split 4, growx, growy"); mainPanel.add(createActivationPanel(), "split, growx"); if (newMachine.getMachineType() == MachineType.THE_REPLICATOR) { mainPanel.add(ledStripButton, "growx"); // mainPanel.add(createBeepPanel(), "growx"); } mainPanel.add(alternateToolsPanel(), "newline, growy"); this.setResizable(false); add(mainPanel); // add our listener hooks. addWindowListener(this); // addWindowFocusListener(this); // addWindowStateListener(this); // start our various threads. updateThread = new UpdateThread(this); updateThread.start(); pollThread = new PollThread(machine); pollThread.start(); }