class RealTimePanelController(Observer):
    def __init__(self, real_time_subplots, app_controller):
        self.real_time_subplots = real_time_subplots
        self.app_controller = app_controller
        self.subplot_factory = RealTimeSubplotFactory()
        self.property_parser = PropertiesParser()

    def create_panel(self, panel_parent):
        self.panel = RealTimePanel(
            panel_parent, self.real_time_subplots, self.property_parser.get_property("Real-Time Plots")
        )
        self.panel.add_panel_observers(self)

    def start_plotting(self):
        self.panel.startTimer()
        self.app_controller.start_data_acquisition()

    def stop_plotting(self, save):
        self.panel.stop_timer()
        self.panel.Hide()
        self.app_controller.stop_data_acquisition(save)

    def update(self, event):
        if event == "start":
            self.start_plotting()
        elif event == "stop":
            self.stop_plotting(True)
        elif isinstance(event, PlotTypesChangedObservableEvent):
            self._create_subplots(event.list_of_plots)

    def _create_subplots(self, list_of_subplots):
        self.real_time_subplots = self.subplot_factory.create_subplots(list_of_subplots)
        self.panel.update_subplots(self.real_time_subplots)
Ejemplo n.º 2
0
    def _init_real_time_subplots(self):
        plots_to_display = self.properties_parser.get_property("Real-Time Plots")

        if isinstance(plots_to_display, str):
            plots_to_display = real_time_plot_types

        factory = RealTimeSubplotFactory()
        return factory.create_subplots(plots_to_display)