private IEnumerable <ExecutionSnapshot> getInterestingSnapshots(IEnumerable <byte> pins) { lastSnapshot = null; foreach (var currentSnapshot in getSnapshots(pins)) { if (currentSnapshot.IsDifferentThan(lastSnapshot)) { lastSnapshot = currentSnapshot; yield return(currentSnapshot); } } }
private IEnumerable <ExecutionSnapshot> getSnapshots(IEnumerable <byte> pins) { sketch.WriteSerial(program); while (currentTime <= targetTime) { sketch.SetMillis(currentTime); sketch.Loop(); ExecutionSnapshot currentSnapshot = new ExecutionSnapshot(); currentSnapshot.ms = currentTime; for (int i = 0; i < currentSnapshot.pins.Length; i++) { currentSnapshot.pins[i] = (byte)(pins.Contains(pinMap[i]) ? (sketch.GetPinValue(pinMap[i]) == 0 ? 0 : 1) : 0); } yield return(currentSnapshot); currentTime++; } }
public bool IsDifferentThan(ExecutionSnapshot other) { return(other == null || !pins.SequenceEqual(other.pins)); }