Project

General

Profile

Revision 517

Added by Greg Tress about 16 years ago

minor visual and network tweaks

View differences:

Colonet.java
423 423
	}
424 424
	
425 425
	public void connect () {
426
	    lblConnectionStatus.setText("Status: Connecting...");
426 427
	    webcamLoader = new WebcamLoader(this);
427 428
		dataUpdater = new DataUpdater();
428
		paintThread = new Thread(this, "paintThread");
429 429
		csi = new ColonetServerInterface(this);
430 430
		csi.connect(txtHost.getText(), txtPort.getText());
431
		if (!csi.isReady())
431
		if (!csi.isReady()) {
432
		    lblConnectionStatus.setText("Status: Offline");
432 433
			return;
433
		btnConnect.setEnabled(false);
434
	    }
435
		btnConnect.setText("Disconnect");
434 436
		lblConnectionStatus.setText("Status: Connected");
435
		//paintThread.start();
436 437
		dataUpdater.start();
437 438
		webcamLoader.start();
438 439
	}
439 440
	
440 441
	public void disconnect () {
441
	    btnConnect.setEnabled(true);
442
	    lblConnectionStatus.setText("Status: Disconnecting...");
443
	    dataUpdater.interrupt();
444
	    csi.disconnect();
445
	    csi = null;
446
	    btnConnect.setText("Connect");
442 447
	    lblConnectionStatus.setText("Status: Disconnected");
443
	    try { paintThread.interrupt(); } catch (Exception e) { }
444
		
445 448
	}
446 449
	
447 450
	/**
......
699 702
		
700 703
		    // General Actions
701 704
		    if (source == btnConnect) {
702
			    connect();
705
		        if (csi == null)
706
			        connect();
707
			    else
708
			        disconnect();
703 709
		    } else if (source == btnGetXBeeIDs) {
704 710
			    csi.sendXBeeIDRequest();
705 711
		    } else if (source == btnAssignID) {
......
798 804
	*
799 805
	*/
800 806
	class DataUpdater extends Thread {
801
		final int DATAUPDATER_DELAY = 800;
807
		final int DATAUPDATER_DELAY = 400;
802 808
		
803 809
		public DataUpdater () {
804 810
			super("Colonet DataUpdater");
......
861 867
		BufferedImage buffer;
862 868
	
863 869
		public WebcamPanel () {
864
			super(false);
870
			super(true);
865 871
		}
866 872
		
867 873
		public synchronized void setImage (BufferedImage newimg) {
......
946 952
			
947 953
			//Display buffered content
948 954
			g.drawImage(buffer, 0, 0, this);
949
			txtMatrix.append("p");
950 955
		}
951 956
	
952 957
	}

Also available in: Unified diff