Skip to content

Commit

Permalink
FEAT: powerful two line (...and white space python) change that allow…
Browse files Browse the repository at this point in the history
…s for multishot trees, now to write the multishot tests
  • Loading branch information
joshc-slac committed Sep 4, 2024
1 parent 955c2e1 commit 98a646d
Showing 1 changed file with 58 additions and 56 deletions.
114 changes: 58 additions & 56 deletions beams/tree_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,36 +171,37 @@ def work_func(myself,
comp_condition: Callable[[Any], bool],
volatile_status: VolatileStatus,
wait_for_tick: Event()):
py_trees.console.logdebug(f"WAITING FOR INIT {os.getpid()} "
f"from node: {self.name}")
wait_for_tick.wait()

# Set to running
value = 0

# While termination_check is not True
while not comp_condition(): # TODO check work_gate.is_set()
py_trees.console.logdebug(
f"CALLING CAGET FROM {os.getpid()} from node: " f"{self.name}"
)
value = caget(self.termination_check.pv)

while myself.do_work.value:
py_trees.console.logdebug(f"WAITING FOR INIT {os.getpid()} "
f"from node: {self.name}")
wait_for_tick.wait()

# Set to running
value = 0

# While termination_check is not True
while not comp_condition(): # TODO check work_gate.is_set()
py_trees.console.logdebug(
f"CALLING CAGET FROM {os.getpid()} from node: " f"{self.name}"
)
value = caget(self.termination_check.pv)

if comp_condition():
volatile_status.set_value(py_trees.common.Status.SUCCESS)
py_trees.console.logdebug(
f"{self.name}: Value is {value}, BT Status: "
f"{volatile_status.get_value()}"
)

# specific caput logic to SetPVActionItem
caput(self.pv, self.value)
time.sleep(self.loop_period_sec)

# one last check
if comp_condition():
volatile_status.set_value(py_trees.common.Status.SUCCESS)
py_trees.console.logdebug(
f"{self.name}: Value is {value}, BT Status: "
f"{volatile_status.get_value()}"
)

# specific caput logic to SetPVActionItem
caput(self.pv, self.value)
time.sleep(self.loop_period_sec)

# one last check
if comp_condition():
volatile_status.set_value(py_trees.common.Status.SUCCESS)
else:
volatile_status.set_value(py_trees.common.Status.FAILURE)
else:
volatile_status.set_value(py_trees.common.Status.FAILURE)

comp_cond = self.termination_check.get_condition_function()

Expand All @@ -226,36 +227,37 @@ def work_func(myself,
comp_condition: Callable[[Any], bool],
volatile_status: VolatileStatus,
wait_for_tick: Event()):
py_trees.console.logdebug(f"WAITING FOR INIT {os.getpid()} "
f"from node: {self.name}")
wait_for_tick.wait()

# Set to running
value = 0

# While termination_check is not True
while not comp_condition(): # TODO check work_gate.is_set()
py_trees.console.logdebug(
f"CALLING CAGET FROM {os.getpid()} from node: " f"{self.name}"
)
value = caget(self.pv)

while myself.do_work.value:
py_trees.console.logdebug(f"WAITING FOR INIT {os.getpid()} "
f"from node: {self.name}")
wait_for_tick.wait()

# Set to running
value = 0

# While termination_check is not True
while not comp_condition(): # TODO check work_gate.is_set()
py_trees.console.logdebug(
f"CALLING CAGET FROM {os.getpid()} from node: " f"{self.name}"
)
value = caget(self.pv)

if comp_condition():
volatile_status.set_value(py_trees.common.Status.SUCCESS)
py_trees.console.logdebug(
f"{self.name}: Value is {value}, BT Status: "
f"{volatile_status.get_value()}"
)

# specific caput logic to IncPVActionItem
caput(self.pv, value + self.increment)
time.sleep(self.loop_period_sec)

# one last check
if comp_condition():
volatile_status.set_value(py_trees.common.Status.SUCCESS)
py_trees.console.logdebug(
f"{self.name}: Value is {value}, BT Status: "
f"{volatile_status.get_value()}"
)

# specific caput logic to IncPVActionItem
caput(self.pv, value + self.increment)
time.sleep(self.loop_period_sec)

# one last check
if comp_condition():
volatile_status.set_value(py_trees.common.Status.SUCCESS)
else:
volatile_status.set_value(py_trees.common.Status.FAILURE)
else:
volatile_status.set_value(py_trees.common.Status.FAILURE)

comp_cond = self.termination_check.get_condition_function()

Expand Down

0 comments on commit 98a646d

Please sign in to comment.