comparison ExperimentGui.java @ 10:3dd7636ca811

Add facility for printing out debugging info. Ignore-this: 8073cadd49dcc4a7e7cc81dd25f90e89
author Marcus Pearce <m.pearce@gold.ac.uk>
date Fri, 04 Nov 2011 17:44:38 +0000
parents 5080b65e6963
children 9fc8683b8fed
comparison
equal deleted inserted replaced
9:46c6d604e32c 10:3dd7636ca811
1 /*============================================================================= 1 /*=============================================================================
2 * File: ExperimentGui.java 2 * File: ExperimentGui.java
3 * Author: Marcus Pearce <m.pearce@gold.ac.uk> 3 * Author: Marcus Pearce <m.pearce@gold.ac.uk>
4 * Created: <2007-02-14 16:42:31 marcusp> 4 * Created: <2007-02-14 16:42:31 marcusp>
5 * Time-stamp: <2010-11-18 11:46:46 marcusp> 5 * Time-stamp: <2011-11-04 17:41:45 marcusp>
6 *============================================================================= 6 *=============================================================================
7 */ 7 */
8 8
9 import java.awt.*; 9 import java.awt.*;
10 import javax.swing.*; 10 import javax.swing.*;
29 /* Whether we are accepting responses */ 29 /* Whether we are accepting responses */
30 private Boolean acceptingResponses; 30 private Boolean acceptingResponses;
31 31
32 /* accessors */ 32 /* accessors */
33 public Boolean getAcceptingResponses() { return acceptingResponses; } 33 public Boolean getAcceptingResponses() { return acceptingResponses; }
34 public void setAcceptingResponses(Boolean b) { acceptingResponses = b; } 34 public void setAcceptingResponses(Boolean b) {
35 if (exp.getDebug())
36 System.out.println("Changing acceptingResponses from " + acceptingResponses + " to " + b);
37 acceptingResponses = b;
38 }
35 public Experiment getExperiment() { return exp; } 39 public Experiment getExperiment() { return exp; }
36 public InstructionsPanel getInstructionsPanel() { return instructionsPanel; } 40 public InstructionsPanel getInstructionsPanel() { return instructionsPanel; }
37 public StimulusPanel getStimulusPanel() { return stimulusPanel; } 41 public StimulusPanel getStimulusPanel() { return stimulusPanel; }
38 public SubjectDataPanel getSubjectDataPanel() { return subjectDataPanel; } 42 public SubjectDataPanel getSubjectDataPanel() { return subjectDataPanel; }
39 public InterBlockPanel getInterBlockPanel() { return interBlockPanel; } 43 public InterBlockPanel getInterBlockPanel() { return interBlockPanel; }
155 159
156 int clockUnit = 0; 160 int clockUnit = 0;
157 boolean clockTicking = false; 161 boolean clockTicking = false;
158 162
159 while(oi.hasNext()) { 163 while(oi.hasNext()) {
160 //System.out.println("Ticking = " + clockTicking + 164 if (exp.getDebug())
161 // "; clockUnit = " + clockUnit); 165 System.out.println("Ticking = " + clockTicking +
166 "; clockUnit = " + clockUnit +
167 "; currentOnset = " + currentOnset +
168 "; nextEventOnset = " + nextEventOnset +
169 "; nextClockStartTime = " + nextClockStartTime +
170 "; probe = " + probe);
162 if (clockTicking == true && clockUnit == 0) 171 if (clockTicking == true && clockUnit == 0)
163 tick(nMinutes); 172 tick(nMinutes);
164 173
165 if (currentOnset == nextClockStartTime) { 174 if (currentOnset == nextClockStartTime) {
166 //new Thread(clock).start(); 175 //new Thread(clock).start();
182 //clock.reset(); 191 //clock.reset();
183 //showClock(); 192 //showClock();
184 //tick(nMinutes); 193 //tick(nMinutes);
185 break; 194 break;
186 case BEFORE_PROBE: 195 case BEFORE_PROBE:
187 //System.out.println("BEFORE_PROBE: acceptingResponses = " + 196 if (exp.getDebug())
188 // acceptingResponses); 197 System.out.println("BEFORE_PROBE: acceptingResponses = " +
198 acceptingResponses);
189 if (acceptingResponses == true) 199 if (acceptingResponses == true)
190 exp.getCurrentBlock().addResponse(0, System.nanoTime()); 200 exp.getCurrentBlock().addResponse(0, System.nanoTime());
191 else 201 else
192 acceptingResponses = true; 202 setAcceptingResponses(true);
193 //tick(nMinutes); 203 //tick(nMinutes);
194 clockTicking = false; 204 clockTicking = false;
195 break; 205 break;
196 case PROBE: 206 case PROBE:
197 case PROBE_EX: 207 case PROBE_EX:
198 case PROBE_UNEX: 208 case PROBE_UNEX:
199 //System.out.println("PROBE_{UN,}EX: acceptingResponses = " 209 if (exp.getDebug())
200 // + acceptingResponses); 210 System.out.println("PROBE_{UN,}EX: acceptingResponses = "
211 + acceptingResponses);
201 clock.showFullClock = false; 212 clock.showFullClock = false;
202 clock.repaint(); 213 clock.repaint();
203 break; 214 break;
204 case AFTER_PROBE: 215 case AFTER_PROBE:
205 //clock.showFullClock = false; 216 //clock.showFullClock = false;
210 System.out.println("Unexpected probe id: " + probe); 221 System.out.println("Unexpected probe id: " + probe);
211 break; 222 break;
212 } 223 }
213 // Update probe identifier and onset 224 // Update probe identifier and onset
214 probe = (ProbeID)pi.next(); 225 probe = (ProbeID)pi.next();
226 if (exp.getDebug())
227 System.out.println("Next probe = " + probe);
215 nextEventOnset =((Long)(oi.next())).longValue(); 228 nextEventOnset =((Long)(oi.next())).longValue();
216 } 229 }
217 // sleep for a tatum 230 // sleep for a tatum
218 try { Thread.sleep(tatumInMilliseconds); } 231 try { Thread.sleep(tatumInMilliseconds); }
219 catch (InterruptedException e) {} 232 catch (InterruptedException e) {}