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 a2c883f commit fb2f291
Showing 1 changed file with 52 additions and 50 deletions.
102 changes: 52 additions & 50 deletions beams/tree_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,33 +171,34 @@ 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()

# 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()

# 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 @@ -223,33 +224,34 @@ 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()

# 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()

# 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 fb2f291

Please sign in to comment.