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

Report broken i2c status in front-end #1391

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
40 changes: 19 additions & 21 deletions octoprint_mrbeam/iobeam/dust_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,37 +143,35 @@ def _subscribe(self):
self._event_bus.subscribe(OctoPrintEvents.SHUTDOWN, self._onEvent)

def _handle_fan_data(self, args):
err = False
if args["state"] is not None:
self._state = args["state"]
else:
err = True
if args["dust"] is not None:
self._dust = args["dust"]

if self._printer.is_printing():
self._job_dust_values.append(self._dust)
else:
err = True
if args["rpm"] is not None:
self._rpm = args["rpm"]
else:
err = True
self._state = args.get("state", self._state)
self._dust = args.get("dust", self._dust)
if args.get("dust") and self._printer.is_printing():
self._job_dust_values.append(self._dust)
self._rpm = args.get("rpm", self._rpm)

self._connected = args["connected"]
self._connected = args.get("connected", self._connected)

if self._connected is not None:
self._unboost_timer_interval()

if not err:
if self._connected:
# as long as iobeam does not report the fan missing,
# the latest data is good.
# This will not trigger if the data didn't change, even if the fan is connected.
# However, the values should constantly change during a laserjob. If they don't,
# then this is a safeguard to stop the laser job as we don't detect exhaust
self._logger.warning("UPDATING")
self._data_ts = time.time()

self._validate_values()
self._send_dust_to_analytics(self._dust)
if args.get("dust"):
self._send_dust_to_analytics(self._dust)

self._last_rpm_values.append(self._rpm)
if args.get("rpm"):
self._last_rpm_values.append(self._rpm)

def _on_command_response(self, args):
# This does not seem to be helpful... - Axel
self._logger.debug("Fan command response: %s", args)
if args["success"]:
if (
Expand Down Expand Up @@ -474,7 +472,7 @@ def _validate_values(self):
trigger=msg, analytics="invalid-old-fan-data", log_message=msg
)

elif self._connected == False:
elif not self._connected:
result = False
msg = "Air filter is not connected: state:{state}, rpm:{rpm}, dust:{dust}, connected:{connected}, age:{age:.2f}s".format(
state=self._state,
Expand Down
14 changes: 12 additions & 2 deletions octoprint_mrbeam/iobeam/hw_malfunction_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,16 @@ def show_hw_malfunction_notification(self):
)

for malfunction_id, data in messages_sorted:
if malfunction_id == self.MALFUNCTION_ID_BOTTOM_OPEN:
if malfunction_id == "i2c_bus_malfunction":
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Constant?

notifications.append(
self._user_notification_system.get_notification(
notification_id=malfunction_id,
err_msg=data.get("msg", None),
replay=True,
)
)

elif malfunction_id == self.MALFUNCTION_ID_BOTTOM_OPEN:
notifications.append(
self._user_notification_system.get_notification(
notification_id="err_bottom_open", replay=True
Expand All @@ -117,7 +126,8 @@ def show_hw_malfunction_notification(self):
)
)

self._user_notification_system.show_notifications(notifications)
# Only send a single error message at a time
self._user_notification_system.show_notifications(notifications[0])

def get_messages_to_show(self):
return self._messages_to_show
Loading