예제 #1
0
 def twin_mock_timer(self):
     self.timings = Timings()
     self.timer_a = Timer()
     self.timer_b = Timer()
     self.timer_a.duration = 3
     self.timer_b.duration = 5
     self.timings.aggregate.append(self.timer_a)
     self.timings.aggregate.append(self.timer_b)
예제 #2
0
   def updateCountdown(self):

      flashTime = Timer(min=1,sec=0) # Time when start to flashing
      finish = Timer() # Time is end
      
      self.countdown.dec() # Decrement the countdown
      self.label.set_text('- '+str(self.countdown))
      if self.countdown < flashTime:# If we are up to 1 minute to the alarm
         if self.label.get_visible(): # we toggle visible status of the label
            self.label.hide()
         else:
            self.label.show()
      if self.countdown == finish: # if countdown is zero, we stop cycling
         self.hide()               # make the self disappear
         return False # and stop the countdown
   
      return True # Otherwise we continue to cycle
예제 #3
0
 def start(self): # Start countdown
    
    if self.countdown == Timer(): # If the countdown is on zero we do nothing
       return False 
    # Otherwise ...
    self.show_all()
    GLib.timeout_add_seconds(1,self.updateCountdown)      
    return True
예제 #4
0
 def test_timer_pause(self):
     self.timer = Timer()
     self.timer.start()
     time.sleep(1)
     self.timer.pause()
     time.sleep(1)
     self.timer.restart()
     time.sleep(1)
     self.timer.stop()
     self.assertGreaterEqual(self.timer.duration, 2, "?")
예제 #5
0
   def __init__(self):

      Gtk.Window.__init__(self,title='Alarm')
      self.hbox = Gtk.Box(spacing=6)
      self.label = Gtk.Label('')
      self.countdown = Timer(hour=0,min=8,sec=0) # Add to the label a countdown

      self.hbox.pack_start(self.label, True, True, 0)
      self.set_name('AlarmWindow')
      self.label.set_name('Alarm')
      self.add(self.hbox)
예제 #6
0
 def __init__(self, server_id, raid_boss, default_channel, event_loop):
     self.server_id = server_id
     self.raid_boss = raid_boss
     self.raid_time = raid_boss.get_raid_time()
     self.raid_state = RaidState.LOBBY
     self.default_channel = default_channel
     self.event_loop = event_loop
     self.players = []
     self.current_player = None
     self.current_player_index = -1
     self.timer = Timer(15, event_loop, self.start_raid, default_channel, force=True)
     self.timer.set_event(10, self.announce_time_left, default_channel)
     self.timer.start()
예제 #7
0
    async def start_raid(self, channel, force=False):

        if len(self.players) == 0:
            await channel.send(messages.data['raid_not_enough_players'])
            raid_manager.end_raid(self.server_id)
            return

        if force:
            await channel.send(messages.data['force_raid_start'])

        # Go to player turn
        self.raid_state = RaidState.PLAYER_TURN
        self.timer = Timer(self.raid_time, self.event_loop, self.end_raid, self.default_channel, force=True)
        self.timer.start()

        # Show raid info
        await command_raid_info.show_info(channel)

        await self.next_player(channel)
예제 #8
0
   def setTimeLabel(self):

      day = ['lu','ma','me','gi','ve','sa','do']
      self.label.set_text(time.strftime('%H:%M:%S')) # Set the label to the current time
      # Next we control if in five minutes start a new program.
      now = time.localtime()
      today = now.tm_wday
      hour = now.tm_hour
      minutes = now.tm_min
      
      timeNow = Timer(hour=hour,min=minutes)
      
      for index in range(0,8): # This is necessary cause changing directly min field in the timer
         timeNow.incMin()      # won't change the hour too.

      if timeNow in self.schedule[day[today]] and not self.alarm.get_property('visible'):
         self.alarm.reset() # Reset the countdown of the self
         self.alarm.start() # start the countdown
      
      return True
예제 #9
0
 def __init__(self):
     self.aggregate = []
     self.timer = Timer()
     self.last_time = 0
예제 #10
0
 def timer_start(self):
     try:
         self.timer = Timer()
         self.timer.start()
     except ArithmeticError:
         self.timer.start_time = 0
예제 #11
0
 def test_now(self):
     self.timer = Timer()
     self.assertGreaterEqual(self.timer.serial_time(), 0, "?")
예제 #12
0
 def test_timer_with_wait(self):
     self.timer = Timer()
     self.timer.start()
     time.sleep(1)
     self.timer.stop()
     self.assertGreaterEqual(self.timer.end_time, self.timer.start_time, "?")
예제 #13
0
 def reset(self): # Reset the counter
    self.countdown = Timer(hour=0,min=8,sec=0)