Project

General

Profile

Revision 633

adjusted data update period

View differences:

trunk/code/projects/colonet/client/Colonet.java
1

  
2 1
import javax.swing.*;
3 2
import javax.swing.event.*;
4 3
import javax.imageio.*;
......
124 123
	}
125 124

  
126 125
	public void destroy () {
127
	    if (csi != null) {
128
		    csi.disconnect();
126
		if (csi != null) {
127
			csi.disconnect();
129 128
		}
130 129
	}
131 130

  
......
234 233
		panelRobotControl.add(panelRobotDirection);
235 234
		panelRobotControl.add(panelRobotCommands);
236 235

  
237

  
238 236
		// Task Manager
239 237
		panelTaskManager = new JPanel();
240 238
		panelTaskManager.setLayout(new BorderLayout());
......
816 814
	*
817 815
	*/
818 816
	class DataUpdater extends Thread {
819
		final int DATAUPDATER_DELAY = 3000;
817
		final int DATAUPDATER_DELAY = 200;
820 818
		public DataUpdater () {
821 819
			super("Colonet DataUpdater");
822 820
		}
823 821

  
824 822
		public synchronized void run () {
825
			String line;
826 823
			while (true) {
827 824
				try {
828 825
					//request more data
829 826
					if (csi != null && csi.isReady()) {
830 827
						csi.sendPositionRequest();
831 828
						csi.sendXBeeIDRequest();
832
			            for (Map.Entry<Integer,RobotIcon> entry : robotIcons.entrySet()) {
833
				            RobotIcon r = entry.getValue();
834
				           	int id = r.id;
835
				            if (id >= 0) {
836
						        csi.sendBatteryRequest(id);
837
						        System.out.println("Sent battery request (" + id + ")");
838
					        }
829
						for (Map.Entry<Integer,RobotIcon> entry : robotIcons.entrySet()) {
830
							RobotIcon r = entry.getValue();
831
				           		int id = r.id;
832
				            		if (id >= 0) {
833
						        	csi.sendBatteryRequest(id);
834
						        	System.out.println("Sent battery request (" + id + ")");
835
					        	}
839 836
						}
840 837
					}
841 838
					Thread.sleep(DATAUPDATER_DELAY);
trunk/code/projects/colonet/client/ColonetServerInterface.java
528 528
				System.out.println("Got unknown data: " + line + "\n");
529 529
			}
530 530
		}
531

  
532 531
	}
533

  
534 532
}

Also available in: Unified diff