示例#1
0
 def _ball_left(self, future):
     if future.cancelled():
         return
     self._last_count -= 1
     self.record_activity(BallLostActivity())
     self.trigger_recount()
     self.trigger_activity()
示例#2
0
    def _ball_left(self, future):
        if future.cancelled():
            return

        self.debug_log("SC: Ball left. Old count: %s", self._last_count)
        if not self._is_unreliable:
            # only do this is count it reliable
            self._last_count -= 1
            self.record_activity(BallLostActivity())
        self.trigger_recount()
        self.trigger_activity()
示例#3
0
    async def _run(self):
        self._trigger_recount.set()
        while True:
            new_count = await self._recount()
            self._count_stable.set()

            if self._last_count is None:
                self._last_count = new_count
            elif self._last_count < 0:
                raise AssertionError("Count may never be negative")

            if self.is_jammed() and new_count == 1:
                # only jam is active. keep previous count
                self.debug_log(
                    "Counter is jammed. Only jam is active. Will no longer trust count."
                )
                # ball potentially returned
                if not self._is_unreliable:
                    self.trigger_activity()
                    self.record_activity(BallReturnActivity())
                    self._is_unreliable = True
                continue

            self._is_unreliable = False

            if new_count == self._last_count:
                # count did not change
                continue

            if new_count > self._last_count:
                # new ball
                for _ in range(new_count - self._last_count):
                    try:
                        last_entrance = self._entrances.pop(0)
                    except IndexError:
                        last_entrance = -1000

                    if last_entrance > self.machine.clock.get_time(
                    ) - self.config['entrance_event_timeout']:
                        self.record_activity(BallEntranceActivity())
                    else:
                        self.record_activity(UnknownBallActivity())
            elif new_count < self._last_count:
                # lost ball
                for _ in range(self._last_count - new_count):
                    self.record_activity(BallLostActivity())

            # update count
            self._last_count = new_count
            self.trigger_activity()
示例#4
0
 def _ball_left(self, future):
     del future
     self._last_count -= 1
     self.record_activity(BallLostActivity())
     self.trigger_activity()