Conversation
* `Timeout` renamed to `Timer` to reflect usage. Note, I did not rename the serialutil equivalent. * Generic helper method in POCS to wait for events, essentially a wrapper around the `Timer`. * Cleanup of `observing` and `pointing` states to use `wait_for_events`
| """Wait for event(s) to be set. | ||
|
|
||
| This method will wait for a maximum of `timeout` seconds for all of the | ||
| `events` to complete. The loop will `check_messages` each time in case of |
There was a problem hiding this comment.
Will check at least every sleep_delay seconds for the events to be done, and also for interrupts and bad weather. Will log debug messages approximately every status_interval seconds, and will output status messages approximately every status_interval seconds.
There was a problem hiding this comment.
Thanks, I think I was getting lazy. :)
| raise error.Timeout | ||
|
|
||
| # Sleep for a little bit. | ||
| time.sleep(sleep_delay.value) |
There was a problem hiding this comment.
The .value makes me think you're passing in an astropy time quantity rather than the documented float.
There was a problem hiding this comment.
Changed to support both. It was somewhere in between.
| break | ||
|
|
||
| now = current_time() | ||
| if now >= next_msg_time: |
There was a problem hiding this comment.
FWIW, you could choose to use Timer for this too, but that isn't trivial because it isn't a PeriodicTimer. Perhaps we should write such a class... sometime.
| MAX_EXTRA_TIME = 60 # seconds | ||
|
|
||
|
|
||
| def on_enter(event_data): |
There was a problem hiding this comment.
Can probably streamline the docstring now.
| if wait_time > timeout: | ||
| raise error.Timeout("Timeout waiting for pointing image") | ||
| # Start the exposure | ||
| camera_event = primary_camera.take_observation( |
There was a problem hiding this comment.
Is the type of camera_event list of events? If so, please rename as camera_events, observation_done_events, or some such.
There was a problem hiding this comment.
Here it's just a single event. The wait_for_events handles either a single Event or a list.
|
|
||
| # This is a streamlined variant of PySerial's serialutil.Timeout. | ||
| class Timeout(object): | ||
| class Timer(object): |
There was a problem hiding this comment.
I suppose this is a good change since I see we already have an error type called Timeout. However, note also that we're using threading.Timer in some places. If you are concerned by that, you could consider calling this TimeLimit, which is not a symbol that we use.
|
I forgot to say, can you come up with any kind of focused test? |
* Add basic tests * Update docstrings * Handle Quantity for timeout and sleep_delay better
…ic-wait-events-function
Codecov Report
@@ Coverage Diff @@
## develop #625 +/- ##
==========================================
Coverage ? 67.92%
==========================================
Files ? 65
Lines ? 5690
Branches ? 798
==========================================
Hits ? 3865
Misses ? 1615
Partials ? 210
Continue to review full report at Codecov.
|
* Adding an `overwrite` param to `write_fits`. * Testing images have same filename, so overwrite each other. * Cleanup of some astropy units
This reverts commit 9358ae1.
|
Note that test coverage should increase after #627. |
…ic-wait-events-function
* Fixing tests by deleting POCSTIME so timer works correctly
Timeoutrenamed toTimerto reflect usage. Note, I did not rename the serialutil equivalent.Timer.observingandpointingstates to usewait_for_events