def _preprocess(self): # Set time offsets starttime = min([ trace.get_init_time() for trace in self.traces ]) for trace in self.traces: trace.time_offset = trace.get_init_time() - starttime trace_times = [ trace.get_next_event_time() for trace in self.traces ] if self.export_data: place_counters = [place_counter_name(p) for p in self.project.nets[0].places() if p.trace_tokens] ri = ExportRunInstance( self, [ t for t in self.project.nets[0].transitions() if t.trace_fire ], [ (p, i) for p in self.project.nets[0].places() for i, tracing in enumerate(p.trace_tokens_functions) if tracing.return_numpy_type != 'O' ], ExportRunInstance.basic_header + place_counters) else: ri = RunInstance( self.project, self.process_count) index = 0 timeline = Table([("process", "<i4"), ("pointer", "<i4")], 100) full_timeline = Table([("process", "<i4"), ("pointer", "<i4")], 100) while True: # Searching for trace with minimal event time minimal_time_index = utils.index_of_minimal_value(trace_times) if minimal_time_index is None: break trace = self.traces[minimal_time_index] full_timeline.add_row((minimal_time_index, trace.pointer)) # Timeline update if trace.is_next_event_visible(): timeline.add_row(full_timeline[index]) trace.process_event(ri) trace_times[minimal_time_index] = trace.get_next_event_time() index += 1 self.data = Table([], 0) if self.export_data: self.data = ri.get_table() timeline.trim() full_timeline.trim() self.timeline, self.full_timeline = timeline, full_timeline self.missed_receives = ri.missed_receives
def tokens_count(table, processes, places, collapse=True): required = ["Event", "Process", "Time"] + \ [place_counter_name(place) for place in places] header = table.header if not all(item in header for item in required): return f_eq = lambda x, y: x == y filters = [("Event", f_eq, 'C')] names, values = [], [] for place in places: columns = ["Time", place_counter_name(place)] for p in processes: names.append("{0}@{1}".format(place.get_name_or_id(), p)) counts = table.select(columns, filters + [("Process", f_eq, p)]) values.append((counts[columns[0]], counts[columns[1]])) return ("Number of tokens", charts.place_chart(names, values, "Number of tokens in places", "Time", "Count"))
def tokens_count(table, processes, places, collapse=True): required = ["Event", "Process", "Time"] + \ [place_counter_name(place) for place in places] header = table.header if not all(item in header for item in required): return f_eq = lambda x, y: x == y filters = [("Event", f_eq, 'C')] names, values = [], [] for place in places: columns = ["Time", place_counter_name(place)] for p in processes: names.append("{0}@{1}".format(place.get_name_or_id(), p)) counts = table.select(columns, filters + [("Process", f_eq, p)]) values.append((counts[columns[0]], counts[columns[1]])) return ("Number of tokens", charts.place_chart( names, values, "Number of tokens in places", "Time", "Count"))