Skip to content

Commit

Permalink
Adding error check for more common errors with less of a wait (MCS-19…
Browse files Browse the repository at this point in the history
…82), check if scene is selected before using quick action buttons.
  • Loading branch information
rartiss55 committed Dec 4, 2023
1 parent 0967602 commit 63aeeec
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
19 changes: 17 additions & 2 deletions webenabled/mcs_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,15 @@ def _post_step_and_get_output(self, action: str, params=None):

return action_to_return, images, step_output

def check_for_error(self, elapsed):
# Shouldn't need to wait very long for errors like "invalid action"
secs_to_check = 1.0
if (elapsed > secs_to_check):
error_file_list = glob.glob(
self.step_output_dir + "/error_*.json")

return len(error_file_list) > 0

def get_images_and_step_output(self, startup=False, init_scene=False):
"""Watch the output directory and return the latest images and step
output that appears. If it does not appear in <timeout> seconds, then
Expand All @@ -214,8 +223,14 @@ def get_images_and_step_output(self, startup=False, init_scene=False):
self.img_name = self.blank_path
return [self.img_name], self.step_output

if elapsed > IMAGE_WAIT_TIMEOUT:
self.logger.info("Timeout waiting for image")
quick_error_check = self.check_for_error(elapsed)

if elapsed > IMAGE_WAIT_TIMEOUT or quick_error_check:
log_message = "Timeout waiting for image"
if (quick_error_check):
log_message = "Error returned from MCS controller."

self.logger.info(log_message)

list_of_error_files = glob.glob(
self.step_output_dir + "/error_*.json")
Expand Down
7 changes: 6 additions & 1 deletion webenabled/templates/mcs_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,11 @@ <h1>Machine Common Sense</h1>
}

function runMultipleActions(action, totalCount) {
if (document.getElementById('scene-filename').innerHTML == "None - Please select a scene.") {
alert("Please select a scene before attempting an action.");
return;
}

console.log('run multiple actions: ' + action + ' x ' + totalCount);
processingKeypress = true;
loadingSpinner(true);
Expand Down Expand Up @@ -835,7 +840,7 @@ <h1>Machine Common Sense</h1>
return;
}

if (document.getElementById('scene-filename').innerHTML == "None") {
if (document.getElementById('scene-filename').innerHTML == "None - Please select a scene.") {
alert("Please select a scene before attempting an action.");
return;
}
Expand Down

0 comments on commit 63aeeec

Please sign in to comment.