-
Notifications
You must be signed in to change notification settings - Fork 49
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
Add support for Astrohaven dome #188
Conversation
Includes a simulator for the PLC (programmable logic controller) that controls the dome's motors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this is the same PR as before but with squashed commits. Added some comments here but there were some other comments in old PR).
pocs/dome/abstract_serial_dome.py
Outdated
def is_connected(self): | ||
"""True if connected to the hardware or driver.""" | ||
if self.ser: | ||
return self.ser.is_connected |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like we should be setting the self._is_connected
property and then returning that. Not that someone should be messing with the private variable, but this would get it out of sync.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've decided that it doesn't make great sense to put the _is_connected in the base class, AbstractDome, in part because of issues exactly like this. So, I'm inclined to respond to this feedback by stripping it out from AbstractDome, and implementing it in the sub-classes as appropriate to the means to establishing that connection.
pocs/dome/abstract_serial_dome.py
Outdated
return False | ||
|
||
def connect(self): | ||
""" Connects to the device via the serial port (`self._port`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't like advertising a private variable in the docstring. But I still kind of think the port shouldn't be private anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, will move it to public.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though I assume you agree that port shouldn't be changed, right?
pocs/dome/abstract_serial_dome.py
Outdated
except OSError as err: | ||
self.logger.error("OS error: {0}".format(err)) | ||
except error.BadSerialConnection as err: | ||
self.logger.warning('Could not create serial connection to mount.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still refers to mount here and in line below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed locally, will push later.
pocs/dome/abstract_serial_dome.py
Outdated
self.logger.debug("Closing serial port for dome") | ||
self._is_connected = self.ser.disconnect() | ||
|
||
def verifyConnected(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
verify_connected
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done locally.
pocs/tests/test_astrohaven_dome.py
Outdated
import pytest | ||
import serial | ||
|
||
from pocs.dome import CreateDomeFromConfig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be create_dome_from_config
but I couldn't comment on file up above and must have skipped it in previous review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
pocs/dome/astrohaven.py
Outdated
return self.is_closed | ||
|
||
@property | ||
def state(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment in other PR was about switching this to status
. You seem to be using read_latest_state
for all decision making so this seems like it is for a user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is for the end user. Will create another issue/branch/PR for general changes to the dome API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filed issue #189 for this.
pocs/dome/astrohaven.py
Outdated
return chr(data[-1]) | ||
return None | ||
|
||
def nudge_shutter(self, send, target_feedback): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docstrings missing. Important here where there are parameters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
pocs/dome/astrohaven.py
Outdated
return feedback == target_feedback | ||
|
||
def full_move(self, send, target_feedback): | ||
"""Send a command code until the target_feedback is recieved, or a timeout is reached.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Document the parameters. Not sure if send
should be bytes or a string nor what target_feedback
represents.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
pocs/dome/astrohaven.py
Outdated
feedback = self.read_latest_state() | ||
return feedback == target_feedback | ||
|
||
def full_move(self, send, target_feedback): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this should just be named open_shutter
or open
. When I think of a dome moving I think of it rotating. For consistency with (eventual) other dome subclasses I think an open
method makes the most sense. All domes open in some way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
full_move goes in either direction, i.e. opens or closes, o it moves from whatever the current position is to the commanded position (i.e. until target_feedback is the output).
Also renamed internal methods to have a leading underscore. Tried to be more consistent in describing the Astrohaven protocol (command vs. action).
Codecov Report
@@ Coverage Diff @@
## develop #188 +/- ##
==========================================
- Coverage 80.52% 80.13% -0.4%
==========================================
Files 39 42 +3
Lines 2794 3136 +342
Branches 354 404 +50
==========================================
+ Hits 2250 2513 +263
- Misses 435 490 +55
- Partials 109 133 +24
Continue to review full report at Codecov.
|
only. Modified existing code to make it readily apparent that it is a presentation string and NOT a keyword or enum. Fixed imports in the dome code to be root relative (~absolute), and to be imports of packages and modules, not symbols in modules.
…n_dome.py::test_open_and_close_slit
Fix error dereferencing SerialData.ser in __del__. Issue panoptes#194.
PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm approving so you are not blocked by me as I think this is good. See comment about self.ser
.
pocs/utils/rs232.py
Outdated
@@ -210,7 +211,7 @@ def __del__(self): | |||
# If an exception is thrown when running __init__, then self.ser may not have | |||
# been set, in which case reading that field will generate a NameError. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update comment to reflect error.
pocs/dome/abstract_serial_dome.py
Outdated
baudrate = int(cfg.get('baudrate', 9600)) | ||
|
||
# Setup our serial connection to the given port. | ||
self.ser = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only other comment was about turning this into self.serial
so we have self.serial.ser
instead of self.ser.ser
, which is more consistent with the mount. Any reason you want to keep it this way?
Includes a simulator for the PLC (programmable logic controller) that controls the dome's motors.
Addresses #134, though there is not yet any integration of domes into the state machine.