kopia lustrzana https://github.com/corrscope/corrscope
Replace Trigger(nsamp_frame) parameter with fps
rodzic
878d03517d
commit
a8e91f0a1b
|
@ -48,18 +48,12 @@ class Channel:
|
||||||
del subsampling
|
del subsampling
|
||||||
del nsamp
|
del nsamp
|
||||||
|
|
||||||
# FIXME unit test
|
|
||||||
frame_time = (1 / ovgen_cfg.fps)
|
|
||||||
tsamp_frame = self.time2tsamp(frame_time)
|
|
||||||
|
|
||||||
# Create a Trigger object.
|
# Create a Trigger object.
|
||||||
tcfg = cfg.trigger or ovgen_cfg.trigger
|
tcfg = cfg.trigger or ovgen_cfg.trigger
|
||||||
self.trigger = tcfg(
|
self.trigger = tcfg(
|
||||||
wave=self.wave,
|
wave=self.wave,
|
||||||
nsamp=self.nsamp,
|
nsamp=self.nsamp,
|
||||||
subsampling=self.trigger_subsampling,
|
subsampling=self.trigger_subsampling,
|
||||||
nsamp_frame=tsamp_frame
|
fps=ovgen_cfg.fps
|
||||||
)
|
)
|
||||||
|
|
||||||
def time2tsamp(self, time: float):
|
|
||||||
return round(time * self.wave.smp_s / self.trigger_subsampling)
|
|
||||||
|
|
|
@ -20,9 +20,8 @@ if TYPE_CHECKING:
|
||||||
class ITriggerConfig:
|
class ITriggerConfig:
|
||||||
cls: Type['Trigger']
|
cls: Type['Trigger']
|
||||||
|
|
||||||
def __call__(self, wave: 'Wave', nsamp: int, subsampling: int, nsamp_frame: int):
|
def __call__(self, wave: 'Wave', nsamp: int, subsampling: int, fps: float):
|
||||||
return self.cls(wave, cfg=self, nsamp=nsamp, subsampling=subsampling,
|
return self.cls(wave, cfg=self, nsamp=nsamp, subsampling=subsampling, fps=fps)
|
||||||
nsamp_frame=nsamp_frame)
|
|
||||||
|
|
||||||
|
|
||||||
def register_trigger(config_t: Type[ITriggerConfig]):
|
def register_trigger(config_t: Type[ITriggerConfig]):
|
||||||
|
@ -38,14 +37,19 @@ def register_trigger(config_t: Type[ITriggerConfig]):
|
||||||
|
|
||||||
class Trigger(ABC):
|
class Trigger(ABC):
|
||||||
def __init__(self, wave: 'Wave', cfg: ITriggerConfig, nsamp: int, subsampling: int,
|
def __init__(self, wave: 'Wave', cfg: ITriggerConfig, nsamp: int, subsampling: int,
|
||||||
nsamp_frame: int):
|
fps: float):
|
||||||
# FIXME replace nsamp_frame with frame_time, add _time2tsamp() method
|
|
||||||
self.cfg = cfg
|
self.cfg = cfg
|
||||||
self._wave = wave
|
self._wave = wave
|
||||||
|
|
||||||
self._nsamp = nsamp
|
self._nsamp = nsamp
|
||||||
self._subsampling = subsampling
|
self._subsampling = subsampling
|
||||||
self._nsamp_frame = nsamp_frame
|
self._fps = fps
|
||||||
|
|
||||||
|
frame_dur = 1 / fps
|
||||||
|
self._nsamp_frame = self.time2tsamp(frame_dur)
|
||||||
|
|
||||||
|
def time2tsamp(self, time: float):
|
||||||
|
return round(time * self._wave.smp_s / self._subsampling)
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def get_trigger(self, index: int) -> int:
|
def get_trigger(self, index: int) -> int:
|
||||||
|
@ -94,7 +98,7 @@ class CorrelationTrigger(Trigger):
|
||||||
ITriggerConfig(),
|
ITriggerConfig(),
|
||||||
nsamp=self.ZERO_CROSSING_SCAN,
|
nsamp=self.ZERO_CROSSING_SCAN,
|
||||||
subsampling=1,
|
subsampling=1,
|
||||||
nsamp_frame=self._nsamp_frame
|
fps=self._fps
|
||||||
)
|
)
|
||||||
|
|
||||||
# Precompute tables
|
# Precompute tables
|
||||||
|
|
Ładowanie…
Reference in New Issue