X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=altoslib%2FAltosReplayReader.java;h=bcabf750c2b424fccfad3f34de8cb8b5d25e58d8;hb=3ed101d634968666cd3ee2d8c49737970caf406b;hp=24b425b78a2bc797f93cf77bdd6b405d1d318f58;hpb=c8dbcaf69cd538a31ab6e2b568237ae7c8656a9a;p=fw%2Faltos diff --git a/altoslib/AltosReplayReader.java b/altoslib/AltosReplayReader.java index 24b425b7..bcabf750 100644 --- a/altoslib/AltosReplayReader.java +++ b/altoslib/AltosReplayReader.java @@ -16,7 +16,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_12; +package org.altusmetrum.altoslib_14; import java.io.*; import java.util.*; @@ -31,17 +31,19 @@ class AltosReplay extends AltosDataListener implements Runnable { AltosState state; AltosRecordSet record_set; double last_time = AltosLib.MISSING; - Semaphore semaphore = new Semaphore(1);; + Semaphore semaphore = new Semaphore(1); boolean done = false; public void set_time(double time) { - if (last_time != AltosLib.MISSING) { - semaphore.release(); - double delay = Math.min(time - last_time,10); - if (delay > 0) { - try { - Thread.sleep((int) (delay * 1000)); - } catch (InterruptedException ie) { + if (time > -2) { + if (last_time != AltosLib.MISSING) { + semaphore.release(); + double delay = Math.min(time - last_time,10); + if (delay > 0) { + try { + Thread.sleep((int) (delay * 1000)); + } catch (InterruptedException ie) { + } } } } @@ -70,7 +72,10 @@ class AltosReplay extends AltosDataListener implements Runnable { public void set_apogee_voltage(double volts) { state.set_apogee_voltage(volts); } public void set_main_voltage(double volts) { state.set_main_voltage(volts); } - public void set_gps(AltosGPS gps) { state.set_gps(gps); } + public void set_gps(AltosGPS gps, boolean set_location, boolean set_sats) { + super.set_gps(gps, set_location, set_sats); + state.set_gps(gps, set_location, set_sats); + } public void set_orient(double orient) { state.set_orient(orient); } public void set_gyro(double roll, double pitch, double yaw) { state.set_gyro(roll, pitch, yaw); } @@ -81,6 +86,7 @@ class AltosReplay extends AltosDataListener implements Runnable { public void set_igniter_voltage(double[] voltage) { state.set_igniter_voltage(voltage); } public void set_pyro_fired(int pyro_mask) { state.set_pyro_fired(pyro_mask); } public void set_companion(AltosCompanion companion) { state.set_companion(companion); } + public void set_motor_pressure(double motor_pressure) { state.set_motor_pressure(motor_pressure); } public void run () { /* Run the flight */ @@ -105,31 +111,17 @@ public class AltosReplayReader extends AltosFlightReader { File file; AltosReplay replay; Thread t; - int reads; public AltosCalData cal_data() { return replay.state.cal_data(); } public AltosState read() { - switch (reads) { - case 0: - /* Tell the display that we're in pad mode */ - replay.state.set_state(AltosLib.ao_flight_pad); - break; - case 1: - t = new Thread(replay); - t.start(); - /* fall through */ - default: - /* Wait for something to change */ - try { - replay.semaphore.acquire(); - } catch (InterruptedException ie) { - } - break; + /* Wait for something to change */ + try { + replay.semaphore.acquire(); + } catch (InterruptedException ie) { } - reads++; /* When done, let the display know */ if (replay.done) @@ -146,9 +138,10 @@ public class AltosReplayReader extends AltosFlightReader { public File backing_file() { return file; } public AltosReplayReader(AltosRecordSet record_set, File in_file) { - reads = 0; file = in_file; name = file.getName(); replay = new AltosReplay(record_set); + t = new Thread(replay); + t.start(); } }