Commit 93e8efe9 authored by Andrey Filippov's avatar Andrey Filippov
Browse files

testing if did is sane

parent 1d60252a
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -381,6 +381,9 @@ public class EventLoggerFileInfo implements Comparable<EventLoggerFileInfo> {
					bb_payload.order(ByteOrder.LITTLE_ENDIAN);
					@SuppressWarnings("rawtypes")
					Did_ins did_ins = type_ins_2 ? (new Did_ins_2(bb_payload)) : (new Did_ins_1(bb_payload));
					if (!did_ins.isDidSane()) {
						continue;
					}
//					double full_time = did_ins.getDoubleTime();
					int [] week_time = did_ins.getWeekTimeMs();
					if (week_time0 == null) {
@@ -395,12 +398,23 @@ public class EventLoggerFileInfo implements Comparable<EventLoggerFileInfo> {
					sx2 += ts_master * ts_master;
					sy +=  ts_gnss;
					sxy += ts_master * ts_gnss;
					if (debugLevel > 0) { // -1
					if (sy>2*sx) { // -1
						System.out.println (
								String.format("%6d %10.6f %10.6f", nrec, ts_master, ts_gnss));
								String.format("%6d %10.6f %10.6f", nrec, ts_master, ts_gnss)+" sx="+sx+" sy="+sy);
						System.out.println(Did_strobe_in_time.getWeekTimeMsDelta(week_time0, week_time));
					}
					
					if ((sy>2*sx) || (debugLevel > 0)) { // -1
						System.out.println (
								String.format("%6d %10.6f %10.6f", nrec, ts_master, ts_gnss)+" sx="+sx+" sy="+sy);
					}
				}
			}
			if (s0 == 0){
				System.out.println("calibrateFromDidIns(): no valid records available, aborting.");
				return false;
			}

			double d = (s0 * sx2 - sx * sx);
			double a = (sxy * s0 - sy * sx) / d;
			double b = (sx2 * sy - sx * sxy) / d;