Skip to content

Commit

Permalink
fix feature: LoopByCount
Browse files Browse the repository at this point in the history
  • Loading branch information
annie-xd-wang committed Nov 11, 2024
1 parent 88e20e4 commit 7c2b613
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions src/navigate/model/features/common_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,27 +471,37 @@ def __init__(self, model, steps=1):
self.data_frames = 1

#: bool: Initialization flag
self.initialized = False
self.initialized = VariableWithLock(bool)
self.initialized.value = False

#: dict: A dictionary defining the configuration for the loop control process.
self.config_table = {
"signal": {
"init": self.pre_signal_func,
"init": self.pre_func,
"main": self.signal_func,
},
"data": {"main": self.data_func},
"data": {
"init": self.pre_func,
"main": self.data_func
},
}

def pre_signal_func(self):
def pre_func(self):
"""Initialize loop parameters"""
if self.initialized:
if self.initialized.value:
return
self.initialized = True

with self.initialized as initialized:
if initialized.value:
return

self.get_steps()

self.get_steps()
self.signals = self.steps
self.data_frames = self.steps
initialized.value = True

self.signals = self.steps
self.data_frames = self.steps
logger.debug(f"LoopByCount-initialize: {self.signals}, {self.data_frames}")

def signal_func(self):
"""Control the signal acquisition loop and update the remaining steps.
Expand Down

0 comments on commit 7c2b613

Please sign in to comment.