java/sandbox
--- java/sandbox/RecordLoopExample.java (rev 0)
+++ java/sandbox/RecordLoopExample.java 2014-09-11 04:24:04 UTC (rev 993)
@@ -0,0 +1,29 @@
+import org.freehep.application.studio.Studio;
+import org.freehep.record.loop.RecordLoop;
+import org.freehep.record.loop.RecordLoop.Command;
+import org.freehep.record.loop.RecordLoop.State;
+
+/**
+ * This is a simple example of automating the event loop
+ * in JAS3, e.g. to get events for Wired every X seconds.
+ *
+ * @author Jeremy McCormick <[log in to unmask]>
+ */
+public class RecordLoopExample {
+
+ public static void main(String[] args) {
+ RecordLoop loop = (RecordLoop) ((Studio) Studio.getApplication()).getLookup().lookup(RecordLoop.class);
+ while (true) {
+ loop.execute(Command.NEXT);
+ try {
+ // Gets next event every 5 seconds.
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ if (loop.getState().equals(State.IDLE)) {
+ break;
+ }
+ }
+ }
+}
\ No newline at end of file