Return durations of sleep stages for in-progress session.
177481
def current_sleep_breakdown(self):
        """"""
        try:
            stages = self.intervals[0]['stages']
            breakdown = {'awake': 0, 'light': 0, 'deep': 0, 'rem': 0}
            for stage in stages:
                if stage['stage'] == 'awake':
                    breakdown['awake'] += stage['duration']
                elif stage['stage'] == 'light':
                    breakdown['light'] += stage['duration']
                elif stage['stage'] == 'deep':
                    breakdown['deep'] += stage['duration']
                elif stage['stage'] == 'rem':
                    breakdown['rem'] += stage['duration']
        except KeyError:
            breakdown = None
        return breakdown
1245183
def num_time_steps(self):
    """"""

    num_time_steps = sum(t.num_time_steps for t in self.trajectories)
    return num_time_steps + self.num_completed_time_steps
14977
def input_stages(self):
        """"""
        if self._properties.get("inputStages") is None:
            return []
        return [
            _helpers._int_or_none(entry)
            for entry in self._properties.get("inputStages")
        ]
904665
def build_duration(self):
        """"""

        return int(self.state.build_done) - int(self.state.build)
850018
def delays(self, delays=[]):
        
        if delays:
            return self._session.put(
                self.__v1() + "/delays", data=json.dumps(delays)).json()
        else:
            return self._session.get(self.__v1() + "/delays").json()
1084643
def duration(self):
        """"""
        self._duration = self.lib.iperf_get_test_duration(self._test)
        return self._duration
441575
def get_sleepstage(self, stage_idx=None):
        """"""
        if self.annot is None:  # remove if buttons are disabled
            error_dialog = QErrorMessage()
            error_dialog.setWindowTitle('Error getting sleep stage')
            error_dialog.showMessage('No score file loaded')
            error_dialog.exec()
            return

        window_start = self.parent.value('window_start')
        window_length = self.parent.value('window_length')

        if window_length != self.epoch_length:
            msg = ('Zoom to ' + str(self.epoch_length) + ' (epoch length) ' +
                   'for sleep scoring.')
            error_dialog = QErrorMessage()
            error_dialog.setWindowTitle('Error getting sleep stage')
            error_dialog.showMessage(msg)
            error_dialog.exec()
            lg.debug(msg)
            return

        try:
            self.annot.set_stage_for_epoch(window_start,
                                           STAGE_NAME[stage_idx])

        except KeyError:
            msg = ('The start of the window does not correspond to any epoch ' +
                   'in sleep scoring file.\n\n'
                   'Switch to the appropriate window length in View, then use '
                   'Navigation --> Line Up with Epoch to line up the window.')
            error_dialog = QErrorMessage()
            error_dialog.setWindowTitle('Error getting sleep stage')
            error_dialog.showMessage(msg)
            error_dialog.exec()
            lg.debug(msg)

        else:
            lg.debug('User staged ' + str(window_start) + ' as ' +
                     STAGE_NAME[stage_idx])

            self.set_stage_index()
            self.parent.overview.mark_stages(window_start, window_length,
                                             STAGE_NAME[stage_idx])
            self.display_stats()
            self.parent.traces.page_next()
1078847
function _Process_sleep(time)
{
	return __Scheduler_binding(function(callback) {
		var id = setTimeout(function() {
			callback(__Scheduler_succeed(__Utils_Tuple0));
		}, time);

		return function() { clearTimeout(id); };
	});
}
348584
def SESSION_TIME(stats, info):
    
    duration = time.time() - stats.started_time
    secs = int(duration)
    msecs = int((duration - secs) * 1000)
    info.append(('session_time', '%d.%d' % (secs, msecs)))
726634
def sleep
      current_time = ::ROS::Time.now
      if @last_time > current_time
        @last_time = current_time
      end
      elapsed = current_time - @last_time
      time_to_sleep = @sleep_duration - elapsed
      if time_to_sleep.to_sec > 0.0
        time_to_sleep.sleep
      end
      @last_time = @last_time + @sleep_duration

      # detect time jumping forwards, as well as loops that are
      # inherently too slow
      if (current_time - @last_time).to_sec > @sleep_duration.to_sec * 2
        @last_time = current_time
      end
      nil
    end
1153731
def _check_sleep(self, idx):
        """"""

        # TODO: There are some cases where it would be ok to do this...
        if not self.fake_time.slept[idx]:
            errstr = (
                "%s() function is not calling wpilib.Timer.delay() in its loop!"
                % self.mode_map[self.mode]
            )
            raise RuntimeError(errstr)

        self.fake_time.slept[idx] = False
1205130
def get_min_sec_from_morning(self):
        
        mins = []
        for timerange in self.timeranges:
            mins.append(timerange.get_sec_from_morning())
        return min(mins)
988585
def getChargeTimeElapsed(self):
    """"""
    command = '$GS'
    status = self.sendCommand(command)
    if int(status[1]) == 3:
      return int(status[2])
    else:
      return 0
1114022
def stages(self):
        
        stages = list()
        for data in self.data.stages:
            stages.append(StageInstance(session=self._session, data=data, pipeline=self))

        return stages
26456
def current_values(self):
        """"""
        current_dict = {
            'date': self.current_session_date,
            'score': self.current_sleep_score,
            'stage': self.current_sleep_stage,
            'breakdown': self.current_sleep_breakdown,
            'tnt': self.current_tnt,
            'bed_temp': self.current_bed_temp,
            'room_temp': self.current_room_temp,
            'resp_rate': self.current_resp_rate,
            'heart_rate': self.current_heart_rate,
            'processing': self.current_session_processing,
        }
        return current_dict
918414
def get_user_timer(self, index):
        """"""

        err, tick = self.clock_manager.get_tick(index)
        return [err, tick]
434059
def latencies(self):
        
        return [(shard_id, shard.ws.latency) for shard_id, shard in self.shards.items()]