Skip to content

Commit

Permalink
SW-3961 stable release v0.15.0 (#1830)
Browse files Browse the repository at this point in the history
  • Loading branch information
Josef-MrBeam authored Oct 24, 2023
2 parents fda8d7e + 9d26b1d commit 735a6de
Show file tree
Hide file tree
Showing 63 changed files with 4,133 additions and 890 deletions.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions cypress/e2e/settings/maintenance.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ describe("Maintenance", function () {
expect(resp.status).to.eq(200);
});
});
cy.get('[data-test="maintenance-links-buy-now-heavy-duty-pre-filter"]')
.invoke("attr", "href")
.then((myLink) => {
cy.request(myLink).then((resp) => {
expect(resp.status).to.eq(200);
});
});
});
// status code no exist
it("Air Filter: Main-filter", function () {
Expand Down
147 changes: 120 additions & 27 deletions octoprint_mrbeam/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@

del get_versions

from octoprint_mrbeam.iobeam.airfilter import airfilter, AirFilter
from octoprint_mrbeam.iobeam.iobeam_handler import ioBeamHandler, IoBeamEvents
from octoprint_mrbeam.iobeam.onebutton_handler import oneButtonHandler
from octoprint_mrbeam.iobeam.interlock_handler import interLockHandler
Expand Down Expand Up @@ -233,6 +234,12 @@ def initialize(self):
self._event_bus.subscribe(
MrBeamEvents.LASER_HEAD_READ, self._on_laserhead_ready
)
self._event_bus.subscribe(
MrBeamEvents.AIRFILTER_CHANGED, self.on_airfilter_changed
)
self._event_bus.subscribe(
MrBeamEvents.USAGE_DATA_CHANGED, self.on_usage_data_changed
)

self.start_time_ntp_timer()

Expand Down Expand Up @@ -282,6 +289,7 @@ def initialize(self):
self.wizard_config = WizardConfig(self)
self.job_time_estimation = JobTimeEstimation(self)
self.mrb_file_manager = mrbFileManager(self)
self.airfilter = airfilter(self)

self._logger.info("MrBeamPlugin initialized!")
self.mrbeam_plugin_initialized = True
Expand Down Expand Up @@ -509,6 +517,7 @@ def get_settings_defaults(self):
)

def on_settings_load(self):
self._send_maintenance_information(trigger=MrBeamEvents.SETTINGS_LOAD)
return dict(
svgDPI=self._settings.get(["svgDPI"]),
dxfScale=self._settings.get(["dxfScale"]),
Expand Down Expand Up @@ -567,16 +576,7 @@ def on_settings_load(self):
model_id=self.laserhead_handler.get_current_used_lh_model_id(),
model_supported=self.laserhead_handler.is_current_used_lh_model_supported(),
),
usage=dict(
totalUsage=self.usage_handler.get_total_usage(),
prefilterUsage=self.usage_handler.get_prefilter_usage(),
carbonFilterUsage=self.usage_handler.get_carbon_filter_usage(),
laserHeadUsage=self.usage_handler.get_laser_head_usage(),
gantryUsage=self.usage_handler.get_gantry_usage(),
prefilterLifespan=self.usage_handler.get_prefilter_lifespan(),
laserHeadLifespan=self.laserhead_handler.current_laserhead_lifespan,
),
heavyDutyPrefilter=self._settings.get(["heavyDutyPrefilter"]),
heavyDutyPrefilter=self.is_heavy_duty_prefilter_enabled(),
tour_auto_launch=self._settings.get(["tour_auto_launch"]),
hw_features=dict(
has_compressor=self.compressor_handler.has_compressor(),
Expand All @@ -588,6 +588,65 @@ def on_settings_load(self):
isFirstRun=self.isFirstRun(),
)

def _get_usage_data_dict(self):
return dict(
totalUsage=self.usage_handler.get_total_usage(),
prefilterUsage=self.usage_handler.get_prefilter_usage(),
carbonFilterUsage=self.usage_handler.get_carbon_filter_usage(),
laserHeadUsage=self.usage_handler.get_laser_head_usage(),
gantryUsage=self.usage_handler.get_gantry_usage(),
carbonfilterShopify=self.airfilter.get_shopify_links(
AirFilter.CARBONFILTER
),
prefilterShopify=self.airfilter.get_shopify_links(AirFilter.PREFILTER),
prefilterHeavyDutyShopify=self.airfilter.get_shopify_links(
AirFilter.PREFILTER, heavy_duty=True
),
laserHeadLifespan=self.laserhead_handler.current_laserhead_lifespan,
)

def on_airfilter_changed(self, event, payload):
"""
On airfilter changed event, send maintenance information to frontend.
Args:
event: event name
payload: event payload
Returns:
None
"""
self._send_maintenance_information(trigger=MrBeamEvents.AIRFILTER_CHANGED)

def on_usage_data_changed(self, event, payload):
"""
On usage data changed event, send maintenance information to frontend.
Args:
event: event name
payload: event payload
Returns:
None
"""
if self.airfilter is not None:
self._send_maintenance_information(trigger=MrBeamEvents.USAGE_DATA_CHANGED)

def _send_maintenance_information(self, trigger=None):
"""
Send maintenance information to frontend.
Args:
trigger: trigger of the send
Returns:
None
"""
self._plugin_manager.send_plugin_message(
"mrbeam",
dict(maintenance_information=self._get_usage_data_dict(), trigger=trigger),
)

def on_settings_save(self, data):
"""See
octoprint.plugins.types.SettingsPlugin.get_settings_preprocessors to
Expand Down Expand Up @@ -659,9 +718,7 @@ def on_settings_save(self, data):
if "leds" in data and "fps" in data["leds"]:
self._settings.set_int(["leds", "fps"], data["leds"]["fps"])
if "heavyDutyPrefilter" in data:
self._settings.set_boolean(
["heavyDutyPrefilter"], data["heavyDutyPrefilter"]
)
self.set_heavy_duty_prefilter(data["heavyDutyPrefilter"])
except Exception as e:
self._logger.exception("Exception in on_settings_save() ")
raise e
Expand All @@ -672,6 +729,16 @@ def on_settings_save(self, data):
# saved settings simpultaneously.
octoprint.plugin.SettingsPlugin.on_settings_save(self, data)

def set_heavy_duty_prefilter(self, value):
if value != self._settings.get(["heavyDutyPrefilter"]):
self._send_maintenance_information(
trigger=MrBeamEvents.HEAVY_DUTY_PREFILTER_CHANGED
)
self._settings.set_boolean(["heavyDutyPrefilter"], value)

def is_heavy_duty_prefilter_enabled(self):
return self._settings.get(["heavyDutyPrefilter"])

def on_shutdown(self):
self._shutting_down = True
self._logger.debug("Mr Beam Plugin stopping...")
Expand Down Expand Up @@ -733,6 +800,7 @@ def get_assets(self):
"js/app/view-models/settings/camera.js",
"js/app/view-models/settings/backlash.js",
"js/app/view-models/settings/leds.js",
"js/app/view-models/settings/about.js",
"js/app/helpers/path-magic.js",
"js/lib/simplify.js",
"js/lib/clipper.js",
Expand Down Expand Up @@ -1002,7 +1070,7 @@ def get_template_configs(self):
name=gettext("About This Mr Beam"),
template="settings/about_settings.jinja2",
suffix="_about",
custom_bindings=False,
custom_bindings=True,
),
dict(
type="settings",
Expand Down Expand Up @@ -1165,13 +1233,6 @@ def wifi_wizard_api(self):
def lasersafety_wizard_api(self, data):
from flask.ext.login import current_user

# get JSON from request data, or send user back home
data = request.values
if hasattr(request, "json") and request.json:
data = request.json
else:
return make_response("Unable to interpret request", 400)

# check if username is ok
username = data.get("username", "")
if (
Expand Down Expand Up @@ -2085,11 +2146,31 @@ def on_api_command(self, command, data):
elif command == "review_data":
return self.review_handler.save_review_data(data)
elif command == "reset_prefilter_usage":
return self.usage_handler.reset_prefilter_usage()
if "serial" not in data:
return make_response("Missing serial", 400)
serial = data.get("serial", None)
self.usage_handler.reset_prefilter_usage(serial)
self._send_maintenance_information(
trigger=MrBeamEvents.USAGE_DATA_RESET_PREFILTER
)
return NO_CONTENT
elif command == "reset_carbon_filter_usage":
return self.usage_handler.reset_carbon_filter_usage()
if "serial" not in data:
return make_response("Missing serial", 400)
serial = data.get("serial", None)
self.usage_handler.reset_carbon_filter_usage(serial)
self._send_maintenance_information(
trigger=MrBeamEvents.USAGE_DATA_RESET_CARBON_FILTER
)
return NO_CONTENT
elif command == "reset_laser_head_usage":
return self.usage_handler.reset_laser_head_usage()
self.usage_handler.reset_laser_head_usage(
self.laserhead_handler.get_current_used_lh_data()["serial"]
)
self._send_maintenance_information(
trigger=MrBeamEvents.USAGE_DATA_RESET_LASER_HEAD
)
return NO_CONTENT
elif command == "reset_gantry_usage":
return self.usage_handler.reset_gantry_usage()
elif command == "material_settings":
Expand Down Expand Up @@ -2657,7 +2738,7 @@ def _convert_to_engine(self, profile_path):
##~~ Event Handler Plugin API

def on_event(self, event, payload):
if event is not MrBeamEvents.ANALYTICS_DATA:
if event != MrBeamEvents.ANALYTICS_DATA:
self._logger.info("on_event %s: %s", event, payload)

if event == MrBeamEvents.BOOT_GRACE_PERIOD_END:
Expand Down Expand Up @@ -2853,9 +2934,9 @@ def get_mrb_state(self):
"""
if self.mrbeam_plugin_initialized:
try:
return dict(
state_dict = dict(
laser_temp=self.temperature_manager.get_temperature(),
fan_connected=self.dust_manager.is_fan_connected(),
fan_connected=self.airfilter.connected,
fan_state=self.dust_manager.get_fan_state(),
fan_rpm=self.dust_manager.get_fan_rpm(),
fan_dust=self.dust_manager.get_dust(),
Expand All @@ -2872,7 +2953,14 @@ def get_mrb_state(self):
laser_model=self.laserhead_handler.get_current_used_lh_data()[
"model"
],
airfilter_serial=self.airfilter.serial,
airfilter_model=self.airfilter.model,
airfilter_model_id=self.airfilter.model_id,
airfilter_pressure=self.airfilter.pressure,
airfilter_temperatures=self.airfilter.temperatures,
)
return collections.OrderedDict(sorted(state_dict.items()))

except:
self._logger.exception("Exception while collecting mrb_state data.")
else:
Expand Down Expand Up @@ -3184,6 +3272,11 @@ def _get_mac_addresses(self):
self._mac_addrs = interfaces
return self._mac_addrs

def send_mrb_state(self):
self._plugin_manager.send_plugin_message(
"mrbeam", dict(mrb_state=self.get_mrb_state())
)


# # MR_BEAM_OCTOPRINT_PRIVATE_API_ACCESS
# # Per default OP always accepts .stl files.
Expand Down
4 changes: 1 addition & 3 deletions octoprint_mrbeam/analytics/analytics_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ def analyticsHandler(plugin):
class AnalyticsHandler(object):
QUEUE_MAXSIZE = 1000
UNKNOWN_VALUE = "unknown"
ANALYTICS_LOG_VERSION = (
29 # bumped for SW-1157 add laser head max temperature and summer month offset
)
ANALYTICS_LOG_VERSION = 30 # bumped for SW-2320 add pressure drop to analytics

def __init__(self, plugin):
self._plugin = plugin
Expand Down
Loading

0 comments on commit 735a6de

Please sign in to comment.