updated safety plugin

This commit is contained in:
Teja 2015-02-06 17:16:13 +01:00
parent 4dc1c2cdad
commit e4cc81d643
4 changed files with 168 additions and 1 deletions

View file

@ -0,0 +1,83 @@
# coding=utf-8
from __future__ import absolute_import
__author__ = "Mr Beam Team <info@mrbeam.org>"
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
__copyright__ = "Copyright (C) 2015 The Mr Beam Project - Released under terms of the AGPLv3 License"
import logging
import logging.handlers
import os
import flask
import socket
import octoprint.plugin
import octoprint.util
from octoprint.util import dict_merge
import octoprint.settings
default_settings = {
"agreed_to_safety_notes": False
}
s = octoprint.plugin.plugin_settings("lasersafetynotes", defaults=default_settings)
class LaserSafetyNotesPlugin(octoprint.plugin.SettingsPlugin,
octoprint.plugin.StartupPlugin,
octoprint.plugin.BlueprintPlugin,
octoprint.plugin.AssetPlugin,
octoprint.plugin.TemplatePlugin):
def __init__(self):
pass
##~~ StartupPlugin API
def on_startup(self, host, port):
pass
##~~ AssetPlugin API
def get_assets(self):
return {
"js": ["js/laserSafetyNotes.js"],
"less": [],
"css": []
}
##~~ SettingsPlugin API
def on_settings_load(self):
cfg = dict(
current_profile_id=s.get(["agreed_to_safety_notes"]),
)
return cfg
def on_settings_save(self, data):
if "has_agreed" in data:
has_agreed = data["has_agreed"] in octoprint.settings.valid_boolean_trues
s.setBoolean(["agreed_to_safety_notes"], has_agreed)
##~~ TemplatePlugin API
def get_template_vars(self):
d = dict()
return d
def get_template_folder(self):
#import os
#return os.path.join(os.path.dirname(os.path.realpath(__file__)), "templates")
return os.path.join(self._basefolder, "templates")
def get_template_configs(self):
return [dict(type = 'generic', custom_bindings=False)]
##~~ BlueprintPlugin API
#def get_blueprint(self):
# global blueprint
# return blueprint
__plugin_name__ = "lasersafetynotes"
__plugin_version__ = "0.1"
__plugin_implementations__ = [LaserSafetyNotesPlugin()]

View file

@ -0,0 +1,23 @@
$(function() {
function LaserSafetyNotesViewModel(params) {
var self = this;
self.settings = params[0];
self.onStartup = function(){
// self.requestData();
// self.control.showZAxis = ko.computed(function(){
// var has = self.currentProfileData()['zAxis']();
// return has;
// }); // dependency injection
};
}
// view model class, identifier, parameters for constructor, container to bind to
ADDITIONAL_VIEWMODELS.push([LaserSafetyNotesViewModel,
["settingsViewModel"],
document.getElementById("laser_safety_notes")]);
});

View file

@ -0,0 +1,62 @@
<div id="laser_safety_overlay" class="modal hide fade" data-backdrop="static" data-keyboard="false">
<div class="modal-header">
<h3><i class="icon-warning-sign"></i> {{ _('Laser Safety') }}</h3>
</div>
<div class="modal-body">
{% trans %}<p>
<strong>Heads up! Read the following, it is very important for your and other's health!</strong>
</p>
<h3>
Laser Classification:
</h3>
<p>
Your laser engraver contains a 658nm or 445nm laser diode with an output power greater than 1000mW.
According to IEC60825 this is a class 4 laser which is capable of causing injury to both
the eye and skin and will also present a fire hazard if sufficiently high output powers are used.
</p>
<h3>Safety Advisory:</h3>
<p>
Laser products emit intense laser light that can be harmful to the eyes and can cause burning by irradiation.<br/>
NEVER DIRECT AT THE EYES EVEN AT A DISTANCE REGARDLESS OF LASER CLASS!<br/>
Everybody in the line of sight must wear appropriate laser safety glasses during the laser operation. <br/>
Even when wearing laser safety glasses, never ever look direct into the laser beam.<br/>
Be always responsible regarding yourself and others.<br/>
Always operate your own assembly of the kit under permanent supervision. <br/>
<strong>Never</strong> leave the device unattended during operation. <br/>
<strong>Never</strong> put reflecting or mirroring materials under the laser. <br/>
<strong>Never</strong> put the machine on a flammable surface. <br/>
It must be operated only by persons who are aware of the risks and dangers of the operation,
especially those of class 4 laser light emissions.<br/>
If you are connecting the laser engraver to a network ensure that you properly set up the network access
as well as the machines access control. Do NOT underestimate the risk of an unsecured access from the internet to your laser engraver.
</p>
<p>
By proceeding you are agreeing, that
</p>
<ul>
<li>You understand that laser components are dangerous</li>
<li>You understand that you are responsible to build your machine according to your local regulations.
This may require extensions or alterations of the design and the construction.</li>
<li>You will always use the provided laser in a safe and responsible manner and for a legal purpose.</li>
<li>You are legally responsible for the use and also the improper use of your Mr Beam assembly.</li>
<li>You are legally responsible to grant access to your laser engraver only to introduced and authorized personnel.</li>
<li>You have connected the laser engraver to a trustful network and ensured that only authorized and introduced personnel can access it. </li>
</ul>
<p>
If you have any concerns about laser safety or if you do not agree with the conditions above
don't use this software to operate any machine emitting laser light.
</p>
<p>Thank you for reading. </p>
{% endtrans %}
</div>
<div class="modal-footer">
<a href="#" class="btn btn-danger" data-bind="click: agree">{{ _('I do fully understand and agree!') }}</a>
</div>
</div>

View file

@ -269,7 +269,6 @@ def _process_template_configs(name, implementation, configs, rules):
if not template_type in rules:
continue
rule = rules[template_type]
data = _process_template_config(name, implementation, rule, config=config, counter=counters[template_type])
if data is None:
continue