Commit b7d428d8 authored by Valentin Valls's avatar Valentin Valls
Browse files

Update the regulation plot with the TimeCurvePlot

parent b8354cc9
...@@ -2010,16 +2010,14 @@ class RegPlot: ...@@ -2010,16 +2010,14 @@ class RegPlot:
def create_plot(self): def create_plot(self):
# Declare a CurvePlot (see bliss.flint.client.plots) # Declare and setup the plot
self.fig = get_flint().get_plot( self.fig = get_flint().get_plot(
plot_class="Plot1D", plot_class="TimeCurvePlot",
name=self.loop.name, name=self.loop.name,
unique_name=f"regul_plot_{self.loop.name}", unique_name=f"regul_plot_{self.loop.name}",
closeable=True, closeable=True,
selected=True, selected=True,
) )
self.fig.submit("setGraphXLabel", "Time (s)")
self.fig.submit( self.fig.submit(
"setGraphYLabel", "setGraphYLabel",
f"Processed value ({self.loop.input.config.get('unit','')})", f"Processed value ({self.loop.input.config.get('unit','')})",
...@@ -2031,13 +2029,14 @@ class RegPlot: ...@@ -2031,13 +2029,14 @@ class RegPlot:
) )
self.fig.submit("setGraphGrid", which=True) self.fig.submit("setGraphGrid", which=True)
self.fig.submit( # Define the plot content
"setDataMargins", self.fig.select_curve("setpoint", color="blue", linestyle="-", z=2)
xMinMargin=0.0, self.fig.select_curve("input", color="red", linestyle="-", z=2)
xMaxMargin=0.0, self.fig.select_curve(
yMinMargin=0.1, "output", color="green", linestyle="-", yaxis="right", z=2
yMaxMargin=0.1,
) )
self.fig.select_curve("deadband_high", color="blue", linestyle="--", z=2)
self.fig.select_curve("deadband_low", color="blue", linestyle="--", z=2)
def is_plot_active(self): def is_plot_active(self):
if self.fig is None: if self.fig is None:
...@@ -2073,39 +2072,22 @@ class RegPlot: ...@@ -2073,39 +2072,22 @@ class RegPlot:
self.loop._store_history_data() self.loop._store_history_data()
try: try:
self.fig.submit("setAutoReplot", False)
self.fig.add_data(self.loop.history_data["time"], field="time")
self.fig.add_data(self.loop.history_data["input"], field="Input")
self.fig.add_data(self.loop.history_data["output"], field="Output")
self.fig.add_data(self.loop.history_data["setpoint"], field="Setpoint")
dbp = [ dbp = [
x + self.loop.deadband for x in self.loop.history_data["setpoint"] x + self.loop.deadband for x in self.loop.history_data["setpoint"]
] ]
dbm = [ dbm = [
x - self.loop.deadband for x in self.loop.history_data["setpoint"] x - self.loop.deadband for x in self.loop.history_data["setpoint"]
] ]
self.fig.add_data(dbp, field="Deadband_high")
self.fig.add_data(dbm, field="Deadband_low")
# Update curves plot (refreshes the plot widget) # Update curves plot (refreshes the plot widget)
# select_data takes all kwargs of the associated plot methode (e.g. silx => addCurve(kwargs) ) self.fig.set_data(
self.fig.select_data( time=self.loop.history_data["time"],
"time", "Setpoint", color="blue", linestyle="-", z=2 input=self.loop.history_data["input"],
output=self.loop.history_data["output"],
setpoint=self.loop.history_data["setpoint"],
deadband_high=dbp,
deadband_low=dbm,
) )
self.fig.select_data("time", "Input", color="red", linestyle="-", z=2)
self.fig.select_data(
"time", "Output", color="green", linestyle="-", yaxis="right", z=2
)
self.fig.select_data(
"time", "Deadband_high", color="blue", linestyle="--", z=2
)
self.fig.select_data(
"time", "Deadband_low", color="blue", linestyle="--", z=2
)
self.fig.submit("setAutoReplot", True)
except (gevent.timeout.Timeout, Exception): except (gevent.timeout.Timeout, Exception):
log_debug(self, "Error while plotting the data", exc_info=True) log_debug(self, "Error while plotting the data", exc_info=True)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment