added cache length setting

This commit is contained in:
2023-10-27 12:35:04 +02:00
parent 9b3e2c1e01
commit 2a5c471faa
2 changed files with 12 additions and 6 deletions

View File

@ -6,17 +6,19 @@ warnings.filterwarnings("error")
import argparse import argparse
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument("pvname") parser.add_argument("pvname")
parser.add_argument("-n", "--num", type=int, default=1000)
clargs = parser.parse_args() clargs = parser.parse_args()
from functools import partial
from animation import Animation from animation import Animation
from plots import Plot0D, Plot1D, Plot2D from plots import Plot0D, Plot1D, Plot2D
from sources import Camera, Source from sources import Camera, Source
def decide_src_fun(pvname): def decide_src_fun(pvname, num):
pvname = pvname.upper() pvname = pvname.upper()
if pvname.endswith(":FPICTURE"): if pvname.endswith(":FPICTURE"):
@ -33,7 +35,9 @@ def decide_src_fun(pvname):
if src.nelm == 1: if src.nelm == 1:
print("Scalar") print("Scalar")
fun = Plot0D if num <= 0:
num = None
fun = partial(Plot0D, num)
else: else:
print("Curve") print("Curve")
fun = Plot1D fun = Plot1D
@ -43,7 +47,8 @@ def decide_src_fun(pvname):
pvname = clargs.pvname pvname = clargs.pvname
src, fun = decide_src_fun(pvname) num = clargs.num
src, fun = decide_src_fun(pvname, num)
Animation(src, fun) Animation(src, fun)

View File

@ -39,11 +39,12 @@ def hist(values, bins="auto"):
class Plot0D: class Plot0D:
def __init__(self, *args, **kwargs): def __init__(self, num, *args, **kwargs):
self.fig, axs = plt.subplots(1, 2) self.fig, axs = plt.subplots(1, 2)
self.ax_time, self.ax_hist = ax_time, ax_hist = axs self.ax_time, self.ax_hist = ax_time, ax_hist = axs
self.cache = Cache() print("cache length", num or "infinite")
self.cache = Cache(num)
lines = ax_time.plot([0], [0]) lines = ax_time.plot([0], [0])
self.plot_time = lines[0] #TODO: wtf? self.plot_time = lines[0] #TODO: wtf?