Skip to content

Instantly share code, notes, and snippets.

@zepinto
Created February 21, 2017 14:00
Show Gist options
  • Save zepinto/abbfc9a06f4798ff8a364f26e2a4e715 to your computer and use it in GitHub Desktop.
Save zepinto/abbfc9a06f4798ff8a364f26e2a4e715 to your computer and use it in GitHub Desktop.
Print starting times of maneuvers inside plans.
package pt.lsts.imc.lsf.batch;
import pt.lsts.imc.IMCDefinition;
import pt.lsts.imc.PlanControlState;
import pt.lsts.imc.PlanControlState.STATE;
import pt.lsts.imc.lsf.UnserializedMessage;
public class ManeuverTimes {
public static void main(String[] args) throws Exception {
LsfBatch batch = LsfBatch.selectFolders();
UnserializedMessage msg;
PlanControlState last = null;
PlanControlState planStart = null;
while ((msg = batch.next()) != null) {
switch (msg.getMgId()) {
case PlanControlState.ID_STATIC:
PlanControlState cur = (PlanControlState) msg.deserialize();
if (cur.getState() == STATE.BLOCKED)
continue;
if (last != null && cur.getState() == STATE.INITIALIZING && !cur.getPlanId().equals(last.getPlanId())) {
System.out.println(cur.getDate() + ", " + cur.getPlanId());
planStart = cur;
}
if (last != null && (cur.getManType() != last.getManType() || cur.getState() != last.getState())) {
String time = "0.000";
if (planStart != null)
time = "\t" + (cur.getTimestamp() - planStart.getTimestamp());
if (cur.getState() == STATE.EXECUTING)
System.out.println(time + ", " + IMCDefinition.getInstance().getMessageName(cur.getManType()));
}
last = cur;
default:
break;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment