@@ -424,6 +424,25 @@ async def _eject_ball(self, eject_request: OutgoingBall, eject_try: int) -> bool
424
424
result = await self ._handle_confirm (eject_request , ball_eject_process , incoming_ball_at_target ,
425
425
eject_try )
426
426
await self .ball_device .ball_count_handler .end_eject (ball_eject_process , result )
427
+
428
+ self .info_log ("Eject successful, looking for missing balls" )
429
+ new_balls = await self .ball_device .ball_count_handler .counter .count_balls ()
430
+ old_balls = self .ball_device .counted_balls
431
+ self .info_log ("Found %s physical balls and %s expected balls" , new_balls , old_balls )
432
+ if new_balls < old_balls :
433
+ # Post that the ball is lost
434
+ await self .ball_device .lost_idle_ball ()
435
+ # Cancel the eject queue for the lost ball
436
+ self .info_log ("How many ejects are requested? %s" , self .ball_device .requested_balls )
437
+ self .info_log ("Playfield ejects requested? %s" , self .machine .playfields .playfield .num_balls_requested )
438
+ for _ in range (0 , old_balls - new_balls ):
439
+ self .info_log ("Cancelling one queued request" )
440
+ self ._eject_queue .get_nowait ()
441
+ self ._eject_queue .task_done ()
442
+ self .info_log ("Necessary queue requests are completed. Updating ball count to %s." % new_balls )
443
+ self .ball_device .ball_count_handler ._set_ball_count (new_balls )
444
+
445
+
427
446
return result
428
447
except asyncio .CancelledError :
429
448
ball_eject_process .cancel ()
0 commit comments