Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix shutter position consts and logic for setting shutter pos #63

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/pmacfiltercontrol/pmacFilterControlWrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
15,
]

SHUTTER_CLOSED = "CLOSED"
SHUTTER_OPEN = "OPEN"
SHUTTER_CLOSED = 0
SHUTTER_OPEN = 1


def _if_connected(func: Callable) -> Callable:
Expand Down Expand Up @@ -851,7 +851,7 @@ async def _set_shutter(self, shutter_state: int) -> None:

await caput(f"{self.motors}:SHUTTER", pos, wait=False, throw=False)

def _set_shutter_pos(self, val: float, shutter_state: str) -> None:
def _set_shutter_pos(self, val: float, shutter_state: int) -> None:
"""
Set the shutter position count value.

Expand All @@ -862,7 +862,9 @@ def _set_shutter_pos(self, val: float, shutter_state: str) -> None:
if shutter_state == SHUTTER_CLOSED:
self._configure_param({"shutter_closed_position": val})

current_shutter_state = "CLOSED" if self.shutter.get() == 0 else "OPEN"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GDYendell The reason I changed it to ints was because of this line. It would then pass a string into _set_shutter() which expects 0, otherwise the else is triggered. So pretty much it would always trigger the else clause as they were strings.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand. You haven't changed the conditional, it is still checking self.shutter.get() == 0, you have only changed the assignment to be an int rather than a string, which just changes the value passed to self._set_shutter (which does make sense to me, just the explanation does not).

current_shutter_state = (
SHUTTER_CLOSED if self.shutter.get() == 0 else SHUTTER_OPEN
)
if current_shutter_state == shutter_state:
self._set_shutter(shutter_state)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this wrong? Shouldn't it only call set if the current value does not match the new value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So _set_shutter_pos() only updates the stored position value and doesn't actually move the shutter, _set_shutter() does. This line was added to make sure the shutter updated it's position if in the currently selected state.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e.g. if in the SHUTTER_CLOSED state, but the shutter_pos_closed is updated from 50 cts to 100 cts, it will then trigger the shutter to move to 100 cts


Expand Down