a stab at turning on rudimentary logging for telefiretwo
[fw/altos] / micropeak / MicroStats.java
index abc1296bbcee04d4abca80aa2b253bcd1e8ab0a0..b9637536c0a3ca87212ee0d6262ce4ce9cbc088f 100644 (file)
@@ -3,7 +3,8 @@
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,8 +19,8 @@
 package org.altusmetrum.micropeak;
 
 import java.io.*;
-import org.altusmetrum.altoslib_1.*;
-import org.altusmetrum.altosuilib_1.*;
+import org.altusmetrum.altoslib_11.*;
+import org.altusmetrum.altosuilib_11.*;
 
 public class MicroStats {
        double          coast_height;
@@ -150,6 +151,43 @@ public class MicroStats {
                return descent_height() / descent_duration();
        }
 
+       public static final int state_startup = -1;
+       public static final int state_pad = 0;
+       public static final int state_boost = 1;
+       public static final int state_coast = 2;
+       public static final int state_descent = 3;
+       public static final int state_landed = 4;
+
+       static final String state_names[] = {
+               "pad",
+               "boost",
+               "coast",
+               "descent",
+               "landed"
+       };
+
+       public int state(double t) {
+               if (t >= landed_time)
+                       return state_landed;
+               if (t >= apogee_time)
+                       return state_descent;
+               if (t >= coast_time)
+                       return state_coast;
+               if (t >= 0)
+                       return state_boost;
+               return state_pad;
+       }
+
+       public static String state_name(int state) {
+               if (state < 0 || state > state_landed)
+                       return "unknown";
+               return state_names[state];
+       }
+
+       public String state_name(double t) {
+               return state_name(state(t));
+       }
+
        public MicroStats(MicroData data) {
 
                this.data = data;