Skip to content

Commit

Permalink
good nits p2
Browse files Browse the repository at this point in the history
  • Loading branch information
joshc-slac committed Oct 23, 2024
1 parent d898706 commit 53b006f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 23 deletions.
11 changes: 8 additions & 3 deletions beams/tests/mock_iocs/IM2L0.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,14 @@ class FilterWheelValue(str, Enum):

class MockIML20(PVGroup):
"""
An IOC with three uncoupled read/writable PVs.
# An IOC with three uncoupled read/writable PVs.
Scalar PVs
# Scalar PVs:
* IM2L0:XTES:CLZ.RBV - Zoom motor percentage of actuation
* IM2L0:XTES:CLF.RBV - Focus motor percentage of actuation
* Enum PVs:
* IM2L0:XTES:MMS:STATE:GET_RBV - enumerated state of imager target
* IM2L0:XTES:MFW:GET_RBV - enumerated state of filter wheel "actuation"
----------
"""

Expand All @@ -48,7 +53,7 @@ class MockIML20(PVGroup):
name="CLF.RBV",
value=0,
dtype=float,
doc="Represents percentage of zoom actuated by zoom motor",
doc="Represents percentage of focus actuated by focus motor",
)
im2l0_filter_wheel = pvproperty(
name="MFW:GET_RBV",
Expand Down
2 changes: 2 additions & 0 deletions beams/tests/test_tree_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def test_father_tree_execution(request):

assert check_insert == 1


def test_save_tree_item_round_trip(tmp_path: Path):
filepath = tmp_path / "temp_egg.json"
item = CheckAndDoItem(name="test_save_tree_item_round_trip")
Expand All @@ -76,6 +77,7 @@ def test_save_tree_item_round_trip(tmp_path: Path):
assert isinstance(loaded_tree.root, CheckAndDo)
assert loaded_tree.root.name == item.name


def test_stop_hitting_yourself(request):
run_example_ioc(
"beams.tests.mock_iocs.IM2L0",
Expand Down
2 changes: 1 addition & 1 deletion beams/tree_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def get_tree(self) -> ActionNode:
def work_func(comp_condition: Evaluatable) -> py_trees.common.Status:
try:
# Set to running
value = caget(self.pv) # double caget, this
value = caget(self.pv) # double caget, this is uneeded as currently the comp_condition has caget baked in

if comp_condition():
return py_trees.common.Status.SUCCESS
Expand Down
38 changes: 19 additions & 19 deletions beams/typing_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,32 @@
from beams.behavior_tree.VolatileStatus import VolatileStatus

'''
Evaluatable: function handle that returns a boolean , accpeting arbitrary arugments
# Evaluatable: function handle that returns a boolean , accpeting arbitrary arugments
'''
Evaluatable = Callable[..., bool]

'''
Defines signature for an ActionNode work loop function handle.
This is neccisated by how beams.behavior_tree.ActionWoker expects to spawn the work process via base class beams.sequencer.helpers.Worker
Parameter Types:
Value: volatile indicating work remains to be performed (tree is still ticking, program still running)
str: name of process
Event: work gate reflecting py_trees state of node with respect to tree
VolatileStatus: mechanism to signal from this process to other processes what the py_trees.common.Status of this node is
Evaluatable: this is a completion condition that allows exit of the while loop within the work loop which will wait for a py_trees "initialise"
call to reset the Event (work gate) such that meaningful work can resume on this process
Queue: logging queue
Callable: mechanism to get logger
Return Types:
None
# Defines signature for an ActionNode work loop function handle.
# This is neccisated by how beams.behavior_tree.ActionWoker expects to spawn the work process via base class beams.sequencer.helpers.Worker
# Parameter Types:
# Value: volatile indicating work remains to be performed (tree is still ticking, program still running)
# str: name of process
# Event: work gate reflecting py_trees state of node with respect to tree
# VolatileStatus: mechanism to signal from this process to other processes what the py_trees.common.Status of this node is
# Evaluatable: this is a completion condition that allows exit of the while loop within the work loop which will wait for a py_trees "initialise"
# call to reset the Event (work gate) such that meaningful work can resume on this process
# Queue: logging queue
# Callable: mechanism to get logger
# Return Types:
# None
'''
ActionNodeWorkLoop = Callable[[Value, str, Event, VolatileStatus, Evaluatable, Queue, Callable], None]

'''
Work function handle of function to be called during the RUNNING state of an ActionNode
Parameter Types:
Evaluatable: determines what py_trees.common.Status to return
Return Types:
py_trees.common.Status: reflects return type from this node with respect to tree logic
# Work function handle of function to be called during the RUNNING state of an ActionNode
# Parameter Types:
# Evaluatable: determines what py_trees.common.Status to return
# Return Types:
# py_trees.common.Status: reflects return type from this node with respect to tree logic
'''
ActionNodeWorkFunction = Callable[[Evaluatable], py_trees.common.Status]

0 comments on commit 53b006f

Please sign in to comment.