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

SW-4141 component improvements #1838

Merged
merged 8 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from 7 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
23 changes: 19 additions & 4 deletions octoprint_mrbeam/analytics/usage_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ def _get_job_time(self, usage_data):
Returns:
int: job time in seconds, -1 if it could not be found
"""
if self.JOB_TIME_KEY not in usage_data:
if usage_data is None or self.JOB_TIME_KEY not in usage_data:
self._logger.error(
"No job time found in %s, returning 0 - %s",
usage_data,
Expand Down Expand Up @@ -410,6 +410,9 @@ def reset_prefilter_usage(self, serial):
if serial is None:
serial = self.UNKNOWN_SERIAL_KEY
self._set_job_time([self.AIRFILTER_KEY, serial, self.PREFILTER_KEY], 0)
self._logger.info(
"Reset prefilter usage data from {}".format(self.get_prefilter_usage())
)
self.start_time_prefilter = -1
self._write_usage_data()
self.write_usage_analytics(action="reset_prefilter")
Expand All @@ -430,6 +433,11 @@ def reset_carbon_filter_usage(self, serial):
[self.AIRFILTER_KEY, serial, self.CARBON_FILTER_KEY],
0,
)
self._logger.info(
"Reset carbon filter usage data from {}".format(
self.get_carbon_filter_usage()
)
)
self.start_time_prefilter = -1
self._write_usage_data()
self.write_usage_analytics(action="reset_carbon_filter")
Expand All @@ -447,12 +455,16 @@ def reset_laser_head_usage(self, serial):
if serial is None:
serial = self.UNKNOWN_SERIAL_KEY
self._set_job_time([self.LASER_HEAD_KEY, serial], 0)
self._logger.info(
"Reset laser head usage data from {}".format(self.get_laser_head_usage())
)
self.start_time_laser_head = -1
self._write_usage_data()
self.write_usage_analytics(action="reset_laser_head")

def reset_gantry_usage(self):
self._set_job_time([self.GANTRY_KEY], 0)
self._logger.info("Reset gantry usage data {}".format(self.get_gantry_usage()))
self.start_time_gantry = -1
self._write_usage_data()
self.write_usage_analytics(action="reset_gantry")
Expand Down Expand Up @@ -920,7 +932,10 @@ def _calculate_af2_filter_usage(self, filter_stage):

# calculate the percentage
time_percentage = self._get_percentage_from_time(
stage_usage_time, self._airfilter.get_lifespans(filter_stage)[0]
stage_usage_time,
self._airfilter.get_lifespans(filter_stage)[0]
if self._airfilter.get_lifespans(filter_stage)
else 0.1,
Josef-MrBeam marked this conversation as resolved.
Show resolved Hide resolved
)

# calculate the total percentage
Expand Down Expand Up @@ -976,9 +991,9 @@ def _calculate_af3_filter_usage(self, filter_stage):
)

# calculate the total percentage
total_percentage = max(pressure_percentage, time_percentage)
total_percentage = max(pressure_percentage, min(time_percentage, 80))
logger.debug(
"pressure_percentage: {} time_percentage: {} rpm_percentage: {} total percentag: {}".format(
"pressure_percentage: {} time_percentage: {} rpm_percentage: {} total percentage: {}".format(
pressure_percentage, time_percentage, rpm_percentage, total_percentage
)
)
Expand Down
9 changes: 9 additions & 0 deletions octoprint_mrbeam/files/material_settings/materials.csv
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,15 @@ MrB II Dreamcut x,,#54392e,Engrave,0-25,2000-2000,1,3,0,no,
MrB II Dreamcut x,,#54392e,3,100,1500,1,3,0,no,
MrB II Dreamcut x,,#d91f48,Engrave,0-40,1500-1500,1,3,0,no,
MrB II Dreamcut x,,#d91f48,3,100,1500,1,3,0,no,
MrB II Dreamcut x,Glitter Felt,#000000,3,100,1600,1,3,0,no,
MrB II Dreamcut x,,#ff0000,3,100,1800,1,3,0,no,
MrB II Dreamcut x,,#0d48bb,3,100,1500,2,3,0,no,
MrB II Dreamcut x,,#8e8b98,3,100,500,2,3,0,no,
MrB II Dreamcut x,,#c2ae59,3,100,1300,1,3,0,no,
MrB II Dreamcut x,,#db97b7,3,100,500,3,3,0,no,
MrB II Dreamcut x,,#910786,3,100,1000,1,3,0,no,
MrB II Dreamcut x,,#b758ac,3,100,500,3,3,0,no,
MrB II Dreamcut x,,#ccc8d5,3,100,150,6,3,0,no,
MrB II Dreamcut x,Finn Cardboard,#c7c97c,Engrave,0-60,2000-2000,1,3,0,no,
MrB II Dreamcut x,,#c7c97c,"0,9",100,2000,2,3,0,no,
MrB II Dreamcut x,,#c7c97c,"1,5",100,1500,2,3,0,no,
Expand Down
12 changes: 6 additions & 6 deletions octoprint_mrbeam/iobeam/airfilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ class AirFilter(object):
(1880, 100),
]
AF3_PRESSURE_GRAPH_PREFILTER = [
(100, 0),
(300, 20),
(620, 40),
(800, 60),
(980, 80),
(1200, 100),
(70, 0),
(170, 20),
(300, 40),
(500, 60),
(700, 80),
(800, 100),
]
AF3_RPM_GRAPH = [
(9860, 0),
Expand Down
2 changes: 1 addition & 1 deletion octoprint_mrbeam/iobeam/lid_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ def serve_pictures(
self._plugin.user_notification_system.show_notifications(
self._plugin.user_notification_system.get_notification(
"err_cam_conn_err",
error_code=ErrorCodes.E_1006,
err_code=ErrorCodes.E_1006,
)
)
cam.async_capture() # starts capture with new settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
prefilter_stages: 1
carbonfilter_stages: 1
prefilter:
- lifespan: 320
- lifespan: 150
shopify_link: 'maintenance/af3/pf1' # no utm parameters needed, as the redirect already use these
carbonfilter:
- lifespan: 1120
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ $(function () {
),
safety_notes: "",
type: "collection",
url: gettext("https://www.mr-beam.org/en/collections/filz"),
url: gettext(
"https://www.mr-beam.org/en/collections/filz-schaumstoff"
),
},
"Fabric Cotton": null,
"Fabric Polyester": null,
Expand Down Expand Up @@ -480,6 +482,19 @@ $(function () {
type: null,
url: null,
},
"Glitter Felt": {
name: gettext("Glitter Felt"),
img: "Glitter-Felt.png",
description: "",
hints: "",
safety_notes: gettext(
"Please mirror your file and only cut from the back so that the reflective side is facing down! Reflective materials that are lasered from the front can damage the laser lens!"
),
type: "product",
url: gettext(
"https://www.mr-beam.org/en/products/mr-beam-glitzer-acryl-filz"
),
},
};
///// EDIT MATERIAL SETTINGS ABOVE THIS LINE ////////`

Expand Down
4 changes: 2 additions & 2 deletions tests/analytics/test_usage_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def test_prefilter_usage_af3(usage_handler, mrbeam_plugin):
usage = usage_handler.get_prefilter_usage()

# Assert
assert usage == 48
assert usage == 80


# test set pressure
Expand Down Expand Up @@ -430,7 +430,7 @@ def test_set_fan_test_rpm(usage_handler, mrbeam_plugin):
"graph, value, expected",
[
(AirFilter.AF3_PRESSURE_GRAPH_CARBON_FILTER, 900, 25),
(AirFilter.AF3_PRESSURE_GRAPH_PREFILTER, 700, 48),
(AirFilter.AF3_PRESSURE_GRAPH_PREFILTER, 700, 80),
(AirFilter.AF3_RPM_GRAPH, 9870, 5),
],
)
Expand Down
8 changes: 4 additions & 4 deletions tests/iobeam/test_airfilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def test_profile_for_airfilter_8(air_filter):
"carbonfilter_stages": 1,
"prefilter": [
{
"lifespan": 320,
"lifespan": 150,
"shopify_link": "maintenance/af3/pf1",
},
],
Expand Down Expand Up @@ -333,7 +333,7 @@ def test_get_lifespan_for_airfilter_1_carbonfilter(air_filter):
(3, 40),
(4, 40),
(5, 40),
(8, 320),
(8, 150),
(None, 40),
],
)
Expand All @@ -356,7 +356,7 @@ def test_get_lifespan_for_prefilter(model_id, expected_lifespan, air_filter):
(3, [80]),
(4, [80]),
(5, [40]),
(8, [320]),
(8, [150]),
(None, [40]),
],
)
Expand Down Expand Up @@ -436,7 +436,7 @@ def test_get_list_of_lifespans_for_prefilter(air_filter, mrbeam_plugin):
lifespan = air_filter.get_lifespans("prefilter")

# Assert
assert lifespan == [320]
assert lifespan == [150]


def test_get_list_of_lifespans_for_carbonfilter(air_filter, mrbeam_plugin):
Expand Down