From 2dda3a0e32f7cfb108775fe8527ba02bb3dfdfd7 Mon Sep 17 00:00:00 2001 From: Eyal Soha Date: Tue, 10 Jul 2018 07:58:17 +0300 Subject: [PATCH 01/32] Always run the GCodeAnalyser, even if the slicer provided analysis The analysis from the Slicer or other sources is sent to the GCodeAnalyser, which can use it or ignore it. This fixes https://github.com/foosel/OctoPrint/issues/2445#issuecomment-403599347 This fixes https://github.com/eyal0/OctoPrint-PrintTimeGenius/issues/13 --- .editorconfig | 1 + src/octoprint/filemanager/__init__.py | 15 ++++++--------- src/octoprint/filemanager/analysis.py | 5 ++++- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.editorconfig b/.editorconfig index d8d42bbc9..bf65494f2 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,6 +11,7 @@ trim_trailing_whitespace = true [**.py] indent_style = tab +indent_size = 4 [src/octoprint/static/js/app/**.js] indent_style = space diff --git a/src/octoprint/filemanager/__init__.py b/src/octoprint/filemanager/__init__.py index 01622b837..44cd9e4f1 100644 --- a/src/octoprint/filemanager/__init__.py +++ b/src/octoprint/filemanager/__init__.py @@ -256,7 +256,7 @@ class FileManager(object): file_name = storage_manager.split_path(path) # we'll use the default printer profile for the backlog since we don't know better - queue_entry = QueueEntry(file_name, entry, file_type, storage_type, path, self._printer_profile_manager.get_default()) + queue_entry = QueueEntry(file_name, entry, file_type, storage_type, path, self._printer_profile_manager.get_default(), None) if self._analysis_queue.enqueue(queue_entry, high_priority=high_priority): counter += 1 @@ -476,12 +476,9 @@ class FileManager(object): path_in_storage = self._storage(destination).add_file(path, file_object, links=links, printer_profile=printer_profile, allow_overwrite=allow_overwrite, display=display) - if analysis is None: - queue_entry = self._analysis_queue_entry(destination, path_in_storage, printer_profile=printer_profile) - if queue_entry: - self._analysis_queue.enqueue(queue_entry, high_priority=True) - else: - self._add_analysis_result(destination, path, analysis) + queue_entry = self._analysis_queue_entry(destination, path_in_storage, printer_profile=printer_profile, analysis=analysis) + if queue_entry: + self._analysis_queue.enqueue(queue_entry, high_priority=True) _, name = self._storage(destination).split_path(path_in_storage) eventManager().fire(Events.FILE_ADDED, dict(storage=destination, @@ -700,7 +697,7 @@ class FileManager(object): def _on_analysis_finished(self, entry, result): self._add_analysis_result(entry.location, entry.path, result) - def _analysis_queue_entry(self, destination, path, printer_profile=None): + def _analysis_queue_entry(self, destination, path, printer_profile=None, analysis=None): if printer_profile is None: printer_profile = self._printer_profile_manager.get_current_or_default() @@ -709,6 +706,6 @@ class FileManager(object): file_type = get_file_type(absolute_path) if file_type: - return QueueEntry(file_name, path, file_type[-1], destination, absolute_path, printer_profile) + return QueueEntry(file_name, path, file_type[-1], destination, absolute_path, printer_profile, analysis) else: return None diff --git a/src/octoprint/filemanager/analysis.py b/src/octoprint/filemanager/analysis.py index 65bd5f849..60902311d 100644 --- a/src/octoprint/filemanager/analysis.py +++ b/src/octoprint/filemanager/analysis.py @@ -20,7 +20,7 @@ from octoprint.events import Events, eventManager from octoprint.settings import settings -class QueueEntry(collections.namedtuple("QueueEntry", "name, path, type, location, absolute_path, printer_profile")): +class QueueEntry(collections.namedtuple("QueueEntry", "name, path, type, location, absolute_path, printer_profile, analysis")): """ A :class:`QueueEntry` for processing through the :class:`AnalysisQueue`. Wraps the entry's properties necessary for processing. @@ -33,6 +33,7 @@ class QueueEntry(collections.namedtuple("QueueEntry", "name, path, type, locatio location (str): Location the file is located on. absolute_path (str): Absolute path on disk through which to access the file. printer_profile (PrinterProfile): :class:`PrinterProfile` which to use for analysis. + analysis (dict): :class:`GcodeAnalysisQueue` results from prior analysis, or ``None`` if there is none. """ def __str__(self): @@ -341,6 +342,8 @@ class GcodeAnalysisQueue(AbstractAnalysisQueue): import sys import yaml + if self._current.analysis: + return self._current.analysis try: throttle = settings().getFloat(["gcodeAnalysis", "throttle_highprio"]) if high_priority \ else settings().getFloat(["gcodeAnalysis", "throttle_normalprio"]) From 1cff2581db7acb9caa60c34713c61bba5c3493f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 17 Jul 2018 14:38:12 +0200 Subject: [PATCH 02/32] OctoPi support => Pi support * changed model detection implementation to use device-tree * now active if running on a Pi, regardless whether that runs OctoPi or not * detect undervoltage/overheat issues via vcgencmd and report back on UI --- .../plugins/octopi_support/__init__.py | 176 ------------ .../static/css/octopi_support.css | 3 - .../static/js/octopi_support.js | 50 ---- src/octoprint/plugins/pi_support/__init__.py | 259 ++++++++++++++++++ .../pi_support/static/css/pi_support.css | 8 + .../pi_support/static/js/pi_support.js | 90 ++++++ .../templates/pi_support_about_octopi.jinja2} | 2 +- .../templates/pi_support_navbar.jinja2 | 4 + src/octoprint/settings.py | 2 +- tests/plugins/test_octopi_support.py | 89 ------ tests/plugins/test_pi_support.py | 151 ++++++++++ 11 files changed, 514 insertions(+), 320 deletions(-) delete mode 100644 src/octoprint/plugins/octopi_support/__init__.py delete mode 100644 src/octoprint/plugins/octopi_support/static/css/octopi_support.css delete mode 100644 src/octoprint/plugins/octopi_support/static/js/octopi_support.js create mode 100644 src/octoprint/plugins/pi_support/__init__.py create mode 100644 src/octoprint/plugins/pi_support/static/css/pi_support.css create mode 100644 src/octoprint/plugins/pi_support/static/js/pi_support.js rename src/octoprint/plugins/{octopi_support/templates/octopi_support_about.jinja2 => pi_support/templates/pi_support_about_octopi.jinja2} (87%) create mode 100644 src/octoprint/plugins/pi_support/templates/pi_support_navbar.jinja2 delete mode 100644 tests/plugins/test_octopi_support.py create mode 100644 tests/plugins/test_pi_support.py diff --git a/src/octoprint/plugins/octopi_support/__init__.py b/src/octoprint/plugins/octopi_support/__init__.py deleted file mode 100644 index f025c1ea6..000000000 --- a/src/octoprint/plugins/octopi_support/__init__.py +++ /dev/null @@ -1,176 +0,0 @@ -# coding=utf-8 -from __future__ import absolute_import, division, print_function - -__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html' -__copyright__ = "Copyright (C) 2017 The OctoPrint Project - Released under terms of the AGPLv3 License" - -import flask -import os - -from flask_babel import gettext - -import octoprint.plugin - -_OCTOPI_VERSION_PATH = "/etc/octopi_version" -_CPUINFO_PATH = "/proc/cpuinfo" - -# based on https://elinux.org/RPi_HardwareHistory#Which_Pi_have_I_got.3F -_RPI_REVISION_MAP = { - "Beta": "1B (Beta)", - "0002": "1B", - "0003": "1B", - "0004": "1B", - "0005": "1B", - "0006": "1B", - "0007": "1A", - "0008": "1A", - "0009": "1A", - "000d": "1B", - "000e": "1B", - "000f": "1B", - "0010": "B+", - "0011": "CM1", - "0012": "A+", - "0013": "B+", - "0014": "CM1", - "0015": "A+", - "a01040": "2B", - "a01041": "2B", - "a21041": "2B", - "a22042": "2B", - "900021": "A+", - "900032": "B+", - "900092": "Zero", - "900093": "Zero", - "920093": "Zero", - "9000c1": "Zero W", - "a02082": "3B", - "a020a0": "CM3", - "a22082": "3B", - "a32082": "3B", - "a020d3": "3B+" -} - - -def get_octopi_version(): - with open(_OCTOPI_VERSION_PATH, "r") as f: - version_line = f.readline() - return version_line.strip() - - -def get_pi_cpuinfo(): - fields = dict(revision="Revision", - hardware="Hardware", - serial="Serial") - - result = dict() - with open(_CPUINFO_PATH) as f: - for line in f: - if not line: - continue - - for key, prefix in fields.items(): - if line.startswith(prefix): - result[key] = line[line.index(":") + 1:].strip() - - return result - - -def get_pi_model(hardware, revision): - if hardware not in ("BCM2835",): - return "unknown" - - if revision.startswith("1000"): - # strip flag for over-volted (https://elinux.org/RPi_HardwareHistory#Which_Pi_have_I_got.3F) - revision = revision[4:] - - return _RPI_REVISION_MAP.get(revision.lower(), "unknown") - - -class OctoPiSupportPlugin(octoprint.plugin.EnvironmentDetectionPlugin, - octoprint.plugin.SimpleApiPlugin, - octoprint.plugin.AssetPlugin, - octoprint.plugin.TemplatePlugin): - - # noinspection PyMissingConstructor - def __init__(self): - self._version = None - self._cpuinfo = None - self._model = None - - #~~ EnvironmentDetectionPlugin - - def get_additional_environment(self): - return dict(version=self._get_version(), - revision=self._get_cpuinfo().get("revision", "unknown"), - model=self._get_model()) - - #~~ SimpleApiPlugin - - def on_api_get(self, request): - return flask.jsonify(version=self._get_version()) - - #~~ AssetPlugin - - def get_assets(self): - return dict( - js=["js/octopi_support.js"], - css=["css/octopi_support.css"] - ) - - #~~ TemplatePlugin - - def get_template_configs(self): - return [ - dict(type="about", name="About OctoPi", template="octopi_support_about.jinja2") - ] - - def get_template_vars(self): - return dict(version=self._get_version()) - - #~~ Helpers - - def _get_version(self): - if self._version is None: - try: - self._version = get_octopi_version() - except: - self._logger.exception("Error while reading OctoPi version from file {}".format(_OCTOPI_VERSION_PATH)) - self._version = "unknown" - return self._version - - def _get_model(self): - if self._model is None: - try: - cpuinfo = self._get_cpuinfo() - self._model = get_pi_model(cpuinfo.get("hardware", "unknown"), - cpuinfo.get("revision", "unknown")) - except: - self._logger.exception("Error while detecting RPi model") - self._model = "unknown" - return self._model - - def _get_cpuinfo(self): - if self._cpuinfo is None: - try: - self._cpuinfo = get_pi_cpuinfo() - except: - self._logger.exception("Error while fetching cpu info") - self._cpuinfo = dict() - return self._cpuinfo - -__plugin_name__ = "OctoPi Support Plugin" -__plugin_author__ = "Gina Häußge" -__plugin_description__ = "Provides additional information about your OctoPi instance in the UI." -__plugin_disabling_discouraged__ = gettext("Without this plugin OctoPrint will no longer be able to " - "provide additional information about your OctoPi instance," - "which will make it more tricky to help you if you need support.") -__plugin_license__ = "AGPLv3" - -def __plugin_check__(): - from octoprint.util.platform import get_os - return get_os() == "linux" and os.path.exists(_OCTOPI_VERSION_PATH) - -def __plugin_load__(): - global __plugin_implementation__ - __plugin_implementation__ = OctoPiSupportPlugin() diff --git a/src/octoprint/plugins/octopi_support/static/css/octopi_support.css b/src/octoprint/plugins/octopi_support/static/css/octopi_support.css deleted file mode 100644 index 61b3a10ef..000000000 --- a/src/octoprint/plugins/octopi_support/static/css/octopi_support.css +++ /dev/null @@ -1,3 +0,0 @@ -#octopi_support_footer { - white-space: nowrap; -} diff --git a/src/octoprint/plugins/octopi_support/static/js/octopi_support.js b/src/octoprint/plugins/octopi_support/static/js/octopi_support.js deleted file mode 100644 index b27e32c96..000000000 --- a/src/octoprint/plugins/octopi_support/static/js/octopi_support.js +++ /dev/null @@ -1,50 +0,0 @@ -(function (global, factory) { - if (typeof define === "function" && define.amd) { - define(["OctoPrintClient"], factory); - } else { - factory(global.OctoPrintClient); - } -})(this, function(OctoPrintClient) { - var OctoPrintOctoPiSupportClient = function(base) { - this.base = base; - }; - - OctoPrintOctoPiSupportClient.prototype.get = function(opts) { - return this.base.get(this.base.getSimpleApiUrl("octopi_support")); - }; - - OctoPrintClient.registerPluginComponent("octopi_support", OctoPrintOctoPiSupportClient); - return OctoPrintOctoPiSupportClient; -}); - -$(function() { - - function OctoPiSupportViewModel(parameters) { - var self = this; - - self.requestData = function() { - OctoPrint.plugins.octopi_support.get() - .done(function(response) { - $("#octopi_support_footer").remove(); - if (!response.version) return; - - var octoPrintVersion = $(".footer span.version"); - var octoPiVersion = $(" " + gettext("running on") + " " + gettext("OctoPi") - + " " + response.version + "") - $(octoPiVersion).insertAfter(octoPrintVersion); - }) - }; - - self.onStartup = function() { - self.requestData(); - }; - - self.onServerReconnect = function() { - self.requestData(); - }; - } - - OCTOPRINT_VIEWMODELS.push({ - construct: OctoPiSupportViewModel - }); -}); diff --git a/src/octoprint/plugins/pi_support/__init__.py b/src/octoprint/plugins/pi_support/__init__.py new file mode 100644 index 000000000..c3c1645ed --- /dev/null +++ b/src/octoprint/plugins/pi_support/__init__.py @@ -0,0 +1,259 @@ +# coding=utf-8 +from __future__ import absolute_import, division, print_function + +__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html' +__copyright__ = "Copyright (C) 2017 The OctoPrint Project - Released under terms of the AGPLv3 License" + +import flask +import os +import sarge + +from flask_babel import gettext +from octoprint.util import RepeatedTimer + +import octoprint.plugin + +_PROC_DT_MODEL_PATH = "/proc/device-tree/model" +_OCTOPI_VERSION_PATH = "/etc/octopi_version" +_VCGENCMD = "/usr/bin/vcgencmd" + +### uncomment for local debugging +#_PROC_DT_MODEL_PATH = "fake_model.txt" +#_OCTOPI_VERSION_PATH = "fake_octopi.txt" + +# see https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=147781&start=50#p972790 +_FLAG_UNDERVOLTAGE = 1 << 0 +_FLAG_FREQ_CAPPED = 1 << 1 +_FLAG_THROTTLED = 1 << 2 +_FLAG_PAST_UNDERVOLTAGE = 1 << 16 +_FLAG_PAST_FREQ_CAPPED = 1 << 17 +_FLAG_PAST_THROTTLED = 1 << 18 + + +class ThrottleState(object): + @classmethod + def from_value(cls, value): + if value == 0: + return ThrottleState() + + kwargs = dict(undervoltage=_FLAG_UNDERVOLTAGE & value == _FLAG_UNDERVOLTAGE, + freq_capped=_FLAG_FREQ_CAPPED & value == _FLAG_FREQ_CAPPED, + throttled=_FLAG_THROTTLED & value == _FLAG_THROTTLED, + past_undervoltage=_FLAG_PAST_UNDERVOLTAGE & value == _FLAG_PAST_UNDERVOLTAGE, + past_freq_capped=_FLAG_PAST_FREQ_CAPPED & value == _FLAG_PAST_FREQ_CAPPED, + past_throttled=_FLAG_PAST_THROTTLED & value == _FLAG_PAST_THROTTLED) + return ThrottleState(**kwargs) + + def __init__(self, **kwargs): + self._undervoltage = False + self._freq_capped = False + self._throttled = False + self._past_undervoltage = False + self._past_freq_capped = False + self._past_throttled = False + + for key, value in kwargs.items(): + local_key = "_{}".format(key) + if hasattr(self, local_key) and isinstance(value, bool): + setattr(self, local_key, value) + + @property + def current_undervoltage(self): + return self._undervoltage + + @property + def past_undervoltage(self): + return self._past_undervoltage + + @property + def current_overheat(self): + return self._freq_capped + + @property + def past_overheat(self): + return self._past_freq_capped + + @property + def current_issue(self): + return self._undervoltage or self._freq_capped or self._throttled + + @property + def past_issue(self): + return self._past_undervoltage or self._past_freq_capped or self._past_throttled + + def __eq__(self, other): + if not isinstance(other, ThrottleState): + return False + + return self._undervoltage == other._undervoltage \ + and self._freq_capped == other._freq_capped \ + and self._throttled == other._throttled \ + and self._past_undervoltage == other._past_undervoltage \ + and self._past_freq_capped == other._past_freq_capped \ + and self._past_throttled == other._past_throttled + + def as_dict(self): + return dict(current_undervoltage=self.current_undervoltage, + past_undervoltage=self.past_undervoltage, + current_overheat=self.current_overheat, + past_overheat=self.past_overheat, + current_issue=self.current_issue, + past_issue=self.past_issue) + + +_proc_dt_model = None +def get_proc_dt_model(): + global _proc_dt_model + + if _proc_dt_model is None: + with open(_PROC_DT_MODEL_PATH, "r") as f: + _proc_dt_model = f.readline().strip() + + return _proc_dt_model + + +def get_vcgencmd_throttled_state(): + output = sarge.get_stdout([_VCGENCMD, "get_throttled"]) + #output = "throttled=0x70005" # for local debugging + if not "throttled=0x" in output: + raise ValueError("cannot parse vcgencmd get_throttled output: {}".format(output)) + + value = int(output[len("throttled="):], 0) + return ThrottleState.from_value(value) + + +def is_octopi(): + return os.path.exists(_OCTOPI_VERSION_PATH) + + +_octopi_version = None +def get_octopi_version(): + global _octopi_version + + if _octopi_version is None: + with open(_OCTOPI_VERSION_PATH, "r") as f: + _octopi_version = f.readline().strip() + + return _octopi_version + + +class PiSupportPlugin(octoprint.plugin.EnvironmentDetectionPlugin, + octoprint.plugin.SimpleApiPlugin, + octoprint.plugin.AssetPlugin, + octoprint.plugin.TemplatePlugin, + octoprint.plugin.StartupPlugin): + + # noinspection PyMissingConstructor + def __init__(self): + self._throttle_state = ThrottleState() + self._throttle_check = None + + #~~ EnvironmentDetectionPlugin + + def get_additional_environment(self): + result = dict(model=get_proc_dt_model()) + + if is_octopi(): + result.update(dict(octopi_version=get_octopi_version())) + + return result + + #~~ SimpleApiPlugin + + def on_api_get(self, request): + try: + state = get_vcgencmd_throttled_state() + except: + self._logger.exception("Got an error while trying to fetch the current throttle state via {}".format(_VCGENCMD)) + state = ThrottleState() + + result = dict(throttle_state=state.as_dict()) + result.update(self.get_additional_environment()) + return flask.jsonify(**result) + + #~~ AssetPlugin + + def get_assets(self): + return dict( + js=["js/pi_support.js"], + css=["css/pi_support.css"] + ) + + #~~ TemplatePlugin + + def get_template_configs(self): + configs = [] + + if is_octopi(): + configs.append(dict(type="about", name="About OctoPi", template="pi_support_about_octopi.jinja2")) + + return configs + + def get_template_vars(self): + return self.get_additional_environment() + + #~~ StartupPlugin + + def on_after_startup(self): + self._throttle_check = RepeatedTimer(self._check_throttled_state_interval, + self._check_throttled_state, + run_first=True) + self._throttle_check.start() + + #~~ Helpers + + def _check_throttled_state_interval(self): + if self._throttle_state.current_undervoltage or self._throttle_state.current_overheat: + # check state every 30s if something's currently amiss + return 30 + else: + # check state every 5min if nothing's currently amiss + return 300 + + def _check_throttled_state(self): + try: + state = get_vcgencmd_throttled_state() + except: + self._logger.exception("Got an error while trying to fetch the current throttle state via {}".format(_VCGENCMD)) + return + + if self._throttle_state == state: + # no change + return + + self._throttle_state = state + + if state.current_issue or state.past_issue: + message = "This Raspberry Pi is reporting problems that might lead to bad performance or errors caused by overheating or insufficient power." + if self._throttle_state.current_undervoltage or self._throttle_state.past_undervoltage: + message += "\n!!! UNDERVOLTAGE REPORTED !!! Make sure that the power supply and power cable are capable of supplying enough voltage and current to your Pi." + if self._throttle_state.current_overheat or self._throttle_state.past_overheat: + message += "\n!!! FREQUENCY CAPPING DUE TO OVERHEATING REPORTED !!! Improve cooling on the Pi's CPU and GPU." + self._logger.warn(message) + + self._plugin_manager.send_plugin_message(self._identifier, dict(type="throttle_state", + state=self._throttle_state.as_dict())) + + +__plugin_name__ = "Pi Support Plugin" +__plugin_author__ = "Gina Häußge" +__plugin_description__ = "Provides additional information about your Pi in the UI." +__plugin_disabling_discouraged__ = gettext("Without this plugin OctoPrint will no longer be able to " + "provide additional information about your Pi," + "which will make it more tricky to help you if you need support.") +__plugin_license__ = "AGPLv3" + +def __plugin_check__(): + from octoprint.util.platform import get_os + if get_os() != "linux" or not os.path.exists(_PROC_DT_MODEL_PATH): + return False + + proc_dt_model = get_proc_dt_model() + if proc_dt_model is None: + return False + + return "raspberry pi" in proc_dt_model.lower() + +def __plugin_load__(): + global __plugin_implementation__ + __plugin_implementation__ = PiSupportPlugin() diff --git a/src/octoprint/plugins/pi_support/static/css/pi_support.css b/src/octoprint/plugins/pi_support/static/css/pi_support.css new file mode 100644 index 000000000..c6065b7ed --- /dev/null +++ b/src/octoprint/plugins/pi_support/static/css/pi_support.css @@ -0,0 +1,8 @@ +#octopi_support_footer { + white-space: nowrap; +} + +.pi_support_state_pulsate { + animation: pulsate 1s ease-out; + animation-iteration-count: infinite; +} diff --git a/src/octoprint/plugins/pi_support/static/js/pi_support.js b/src/octoprint/plugins/pi_support/static/js/pi_support.js new file mode 100644 index 000000000..c2050966e --- /dev/null +++ b/src/octoprint/plugins/pi_support/static/js/pi_support.js @@ -0,0 +1,90 @@ +(function (global, factory) { + if (typeof define === "function" && define.amd) { + define(["OctoPrintClient"], factory); + } else { + factory(global.OctoPrintClient); + } +})(this, function(OctoPrintClient) { + var OctoPrintPiSupportClient = function(base) { + this.base = base; + }; + + OctoPrintPiSupportClient.prototype.get = function(opts) { + return this.base.get(this.base.getSimpleApiUrl("pi_support")); + }; + + OctoPrintClient.registerPluginComponent("pi_support", OctoPrintPiSupportClient); + return OctoPrintPiSupportClient; +}); + +$(function() { + + function PiSupportViewModel(parameters) { + var self = this; + + self.model = ko.observable(); + + self.currentUndervoltage = ko.observable(false); + self.currentOverheat = ko.observable(false); + self.pastUndervoltage = ko.observable(false); + self.pastOverheat = ko.observable(false); + self.currentIssue = ko.observable(false); + self.pastIssue = ko.observable(false); + + self.requestData = function() { + OctoPrint.plugins.pi_support.get() + .done(function(response) { + // Raspberry Pi model + self.model(response.model); + + // Throttle state + self.fromThrottleState(response.throttle_state); + + // OctoPi version + $("#octopi_support_footer").remove(); + if (!response.octopi_version) return; + + var octoPrintVersion = $(".footer span.version"); + var octoPiVersion = $(" " + gettext("running on") + " " + gettext("OctoPi") + + " " + response.octopi_version + "") + $(octoPiVersion).insertAfter(octoPrintVersion); + }) + }; + + self.fromThrottleState = function(state) { + self.currentUndervoltage(state.current_undervoltage); + self.pastUndervoltage(state.past_undervoltage); + self.currentOverheat(state.current_overheat); + self.pastOverheat(state.past_overheat); + self.currentIssue(state.current_issue); + self.pastIssue(state.past_issue); + }; + + self.issuePopoverContent = function() { + return "

- " + gettext("Undervoltage. Make sure your power supply and cabling are providing enough power to the Pi.") + "

" + + "

- " + gettext("Frequency capping due to overheat. Improve cooling of the CPU and GPU.") + "

" + + "

" + gettext("A blinking icon indicates an accute issue!") + "

" + }; + + self.onStartup = function() { + self.requestData(); + }; + + self.onServerReconnect = function() { + self.requestData(); + }; + + self.onDataUpdaterPluginMessage = function(plugin, data) { + if (plugin !== "pi_support") return; + if (!data.hasOwnProperty("state") || !data.hasOwnProperty("type")) return; + if (data.type !== "state") return; + + self.fromThrottleState(data.state); + } + } + + OCTOPRINT_VIEWMODELS.push({ + construct: PiSupportViewModel, + elements: ["#navbar_plugin_pi_support"] + }); +}); diff --git a/src/octoprint/plugins/octopi_support/templates/octopi_support_about.jinja2 b/src/octoprint/plugins/pi_support/templates/pi_support_about_octopi.jinja2 similarity index 87% rename from src/octoprint/plugins/octopi_support/templates/octopi_support_about.jinja2 rename to src/octoprint/plugins/pi_support/templates/pi_support_about_octopi.jinja2 index 6dcb2d674..57a55ea84 100644 --- a/src/octoprint/plugins/octopi_support/templates/octopi_support_about.jinja2 +++ b/src/octoprint/plugins/pi_support/templates/pi_support_about_octopi.jinja2 @@ -2,7 +2,7 @@

The ready-to-go Raspberry Pi image with OctoPrint

-

Version {{ plugin_octopi_support_version }}

+

Version {{ plugin_pi_support_octopi_version }}, running on {{ plugin_pi_support_model }}