def _get_app_timeline(self, store, app, reverse=False): usage_stats = store.query_catalog(Catalog.CATALOG_LOGS, "usage_stats.usage_stats") if usage_stats == None: return None time_stats = {} for stat in usage_stats.subsection_items: name = stat.get_subvaluebyname("activity_name") if name.startswith(app.name) == False: continue time = stat.get_subvaluebyname("last_run") if type(time) != int: if time.isdigit() == False: print "Non-digit timestamp??" continue time = int(time) if time in time_stats: time_stats[time].append(name) else: time_stats[time] = [name] sorted_keys = sorted(time_stats.keys(), reverse=reverse) timeline = Timeline() for key in sorted_keys: for stat in time_stats[key]: timeline.add_item(TimelineItem(stat, "fa-sliders", key)) timeline_items = timeline.get_items() if len(timeline_items) == 0: return None return timeline_items
def reset_running_clock(self, *args): if self.ui_state == UI_STATE.RUNNING_CLOCK: return self.ui_state = UI_STATE.RUNNING_CLOCK self.state.reset_running_clock() clock = self.state.running_clock.to_timer_clock(self.state.now) self.reset_and_show_notify( "Timer is set.", "Count down {}.\nNotify at {}".format( clock.to_timer_clock(self.state.now), clock.to_alarm_clock(self.state.now))) self.alarm_timeline = Timeline( self.generate_alarm_timeline(clock.duration)) self.alarm_timeline.start()
def parse(self, node): self.id = int(node.attrib['id']) self.name = node.attrib['name'] self.length_ms = float(node.attrib['length']) self.length = self.length_ms / 1000.0 self.loop = node.attrib.get('looping', 'true') != 'false' for elem in node: if elem.tag == 'mainline': self.parse_mainline(elem) elif elem.tag == 'timeline': t = Timeline(elem) self.timeline[t.get_id()] = t
def __init__(self): self.lightBoard = self.makeLightBoard() self.ableton = Ableton() self.timeline = Timeline() self.filterMin = 60 self.filterMax = 135 self.houseLights = [ 1, 2, 3, 4, 5, 6, 11, 12, 13, 14, 15, 16, 17, 18, 22 ] self.sideRight = [11, 12, 13, 14] self.allLightsUsed = [2, 11, 12, 15, 16, 25] self.allLightsUsedExceptChannelTwo = [11, 12, 15, 16, 25] self.lightNormal = 75 self.lightMin = 0 self.lightMax = 100 self.startPerformance()
def simulation(start_day=4, start_hour=8, duration_in_days=14 + 7 / 24, seed=3): """Runs full simulation and returns log""" lambdas_vec_weekday, lambdas_vec_weekend, behaviour_freqs, user_behaviour_df, df, prior_a, prior_b, action_time_vec\ = preprocess() np.random.seed(seed) sim_log = [] timeline = Timeline(lambdas_vec_weekend, lambdas_vec_weekday, start_day=start_day, duration_in_days=duration_in_days, start_hour=start_hour) timeline.simulate_server_init_times() for (i, time) in enumerate(timeline.server_init_times): user = User(i, time, behaviour_freqs, user_behaviour_df, df, prior_a, prior_b, action_time_vec) user.interact() sim_log += user.log sim_log_df = pd.DataFrame(sim_log, columns=['uId', 'storeId', 'action', 'eventTime']).sort_values('eventTime') sim_log_df.to_csv('simulation_results.csv')
def create_timeline(self): self.timeline = Timeline() return self.timeline