+ def value(self):
+ return tuple(self._output.values())
+
+ def set_values(self, kwargs: dict) -> None:
+ for key, val in kwargs.items():
+ if key in self._output:
+ self._output[key] = val
+ else:
+ raise KeyError(f"The key {key} is not defined.")
+
+
+ trigger_id = callback_context.triggered[0]["prop_id"].split(".")[0]
+
+ d_start = datetime(int(d_start[0:4]), int(d_start[5:7]),
+ int(d_start[8:10]))
+ d_end = datetime(int(d_end[0:4]), int(d_end[5:7]), int(d_end[8:10]))
+
+ output = RetunValue()
+
+ if trigger_id == "btn-ctrl-add":
+ # Add selected test to the list of tests in store:
+ if phy and area and test and cores and framesizes and testtypes:
+ if store_sel is None:
+ store_sel = list()
+ for core in cores:
+ for framesize in framesizes:
+ for ttype in testtypes:
+ tid = (
+ f"{phy.replace('af_xdp', 'af-xdp')}-"
+ f"{area}-"
+ f"{framesize.lower()}-"
+ f"{core.lower()}-"
+ f"{test}-"
+ f"{ttype.lower()}"
+ )
+ if tid not in [itm["id"] for itm in store_sel]:
+ store_sel.append({
+ "id": tid,
+ "phy": phy,
+ "area": area,
+ "test": test,
+ "framesize": framesize.lower(),
+ "core": core.lower(),
+ "testtype": ttype.lower()
+ })
+ output.set_values({
+ "selected-tests-data": store_sel,
+ "cl-selected-options": _list_tests(),
+ "dd-ctrl-phy-value": None,
+ "dd-ctrl-area-value": None,
+ "dd-ctrl-test-value": None,
+ })
+
+ elif trigger_id in ("btn-sel-display", "dpr-period"):
+ fig_tput, fig_lat = graph_trending_tput(
+ self.data, store_sel, self.layout, d_start, d_end
+ )
+ output.set_values({
+ "graph-tput-figure": \
+ fig_tput if fig_tput else self.NO_GRAPH,
+ "graph-tput-style": \
+ self.STYLE_BLOCK if fig_tput else self.STYLE_HIDEN,
+ "div-tput-metadata-style": \
+ self.STYLE_INLINE if fig_tput else self.STYLE_HIDEN,
+ "graph-lat-figure": \
+ fig_lat if fig_lat else self.NO_GRAPH,
+ "graph-lat-style": \
+ self.STYLE_BLOCK if fig_lat else self.STYLE_HIDEN,
+ "div-lat-metadata-style": \
+ self.STYLE_INLINE if fig_lat else self.STYLE_HIDEN
+ })
+
+ elif trigger_id == "btn-sel-remove":
+ if list_sel:
+ new_store_sel = list()
+ for item in store_sel:
+ if item["id"] not in list_sel:
+ new_store_sel.append(item)
+ store_sel = new_store_sel
+ if store_sel:
+ fig_tput, fig_lat = graph_trending_tput(
+ self.data, store_sel, self.layout, d_start, d_end
+ )
+ output.set_values({
+ "graph-tput-figure": \
+ fig_tput if fig_tput else self.NO_GRAPH,
+ "graph-tput-style": \
+ self.STYLE_BLOCK if fig_tput else self.STYLE_HIDEN,
+ "div-tput-metadata-style": \
+ self.STYLE_INLINE if fig_tput else self.STYLE_HIDEN,
+ "graph-lat-figure": \
+ fig_lat if fig_lat else self.NO_GRAPH,
+ "graph-lat-style": \
+ self.STYLE_BLOCK if fig_lat else self.STYLE_HIDEN,
+ "div-lat-metadata-style": \
+ self.STYLE_INLINE if fig_lat else self.STYLE_HIDEN,
+ "selected-tests-data": store_sel,
+ "cl-selected-options": _list_tests()
+ })
+ else:
+ output.set_values({
+ "graph-tput-figure": self.NO_GRAPH,
+ "graph-tput-style": self.STYLE_HIDEN,
+ "div-tput-metadata-style": self.STYLE_HIDEN,
+ "graph-lat-figure": self.NO_GRAPH,
+ "graph-lat-style": self.STYLE_HIDEN,
+ "div-lat-metadata-style": self.STYLE_HIDEN,
+ "selected-tests-data": store_sel,
+ "cl-selected-options": _list_tests()
+ })
+
+ return output.value()