Retain aircraft through native landing and qualify bounded input diagnostics
This commit is contained in:
@@ -109,7 +109,7 @@ def perform_approach(guard, keyboard, mouse, observe, geometry, calibration, rep
|
||||
'target': list(target), 'deadline_monotonic': deadline, 'started_monotonic': clock(),
|
||||
'finished_monotonic': None, 'motions': [], 'events': [], 'stops': [],
|
||||
'samples': [], 'cumulative_horizontal_m': 0., 'unconfirmed_held_key': None,
|
||||
'paired_release_errors': []}
|
||||
'paired_release_errors': [], 'release_timings': []}
|
||||
report['approach_proof'] = state
|
||||
previous = None; held = False; turn_count = 0; pixels = 0; pulse_count = 0
|
||||
largest_stop = None; active_turn = None
|
||||
@@ -226,11 +226,35 @@ def perform_approach(guard, keyboard, mouse, observe, geometry, calibration, rep
|
||||
require(growing < 2 and flips <= 2, 'Native heading failed to converge')
|
||||
s = after
|
||||
|
||||
def release():
|
||||
def release(not_before=None, cleanup=False):
|
||||
nonlocal held
|
||||
# At most two checks per normal pulse and one finally release attempt.
|
||||
# These are diagnostic times, never authority to skip a fresh guard.
|
||||
timing = {'cleanup': cleanup, 'guards': [], 'up_attempted_monotonic': None,
|
||||
'up_returned_monotonic': None}
|
||||
state['release_timings'].append(timing)
|
||||
def checked():
|
||||
record = {'entered_monotonic': clock(), 'returned_monotonic': None}
|
||||
timing['guards'].append(record)
|
||||
try:
|
||||
guard.check()
|
||||
except Exception as error:
|
||||
record['error'] = str(error)
|
||||
raise
|
||||
finally:
|
||||
record['returned_monotonic'] = clock()
|
||||
# A native context failure does not prevent an owned release; only the
|
||||
# full live private display/process/focus proof authorizes that release.
|
||||
guard.check(); keyboard.send('W', False)
|
||||
# Use the initial minimum hold to perform that proof instead of adding
|
||||
# an unconditional 50ms before its already substantial runtime.
|
||||
checked()
|
||||
remaining = 0. if not_before is None else not_before-clock()
|
||||
if remaining > 0:
|
||||
sleep(remaining)
|
||||
checked() # waiting invalidates the preceding ownership proof
|
||||
timing['up_attempted_monotonic'] = clock()
|
||||
keyboard.send('W', False)
|
||||
timing['up_returned_monotonic'] = clock()
|
||||
state['events'].append({'key': 'W', 'down': False, 'monotonic': clock()})
|
||||
end = clock()+.35
|
||||
while True:
|
||||
@@ -275,8 +299,7 @@ def perform_approach(guard, keyboard, mouse, observe, geometry, calibration, rep
|
||||
notify({'kind': 'press-pending', 'key': 'W'})
|
||||
keyboard.send('W', True); pressed = clock()
|
||||
state['events'].append({'key': 'W', 'down': True, 'monotonic': pressed})
|
||||
sleep(.05)
|
||||
release()
|
||||
release(not_before=pressed+.05)
|
||||
released = state['events'][-1]['monotonic']
|
||||
require(released-pressed <= .4, 'Actual W hold exceeded 400ms approach bound')
|
||||
pulse_count += 1
|
||||
@@ -301,7 +324,7 @@ def perform_approach(guard, keyboard, mouse, observe, geometry, calibration, rep
|
||||
raise
|
||||
finally:
|
||||
if held:
|
||||
try: release()
|
||||
try: release(cleanup=True)
|
||||
except Exception as error: state['paired_release_errors'].append(str(error))
|
||||
state['finished_monotonic'] = clock()
|
||||
notify({'kind': 'approach-finished', 'successful': state['completed']})
|
||||
|
||||
Reference in New Issue
Block a user