Commit 858544ce authored by Nicholas Gar Hei Chan's avatar Nicholas Gar Hei Chan
Browse files

Added prototype probe sequence

parent 6241cf2a
......@@ -29,6 +29,8 @@ class AutofdpPlugin(octoprint.plugin.SettingsPlugin,
self.curr_layer = 0
self.num_layers = 0
self.offsets = dict([('x', 0), ('y', 0), ('z', 0)])
##~~ SimpleApiPlugin mixin
def get_api_commands(self):
return dict(
......@@ -46,6 +48,7 @@ class AutofdpPlugin(octoprint.plugin.SettingsPlugin,
self.send_layer(self.curr_layer)
if command == "test_command":
self._logger.info(data)
self.probe_point(10,10,10)
##~~ EventHandlerPlugin mixin
......@@ -64,6 +67,9 @@ class AutofdpPlugin(octoprint.plugin.SettingsPlugin,
if event == 'FileSelected':
self._logger.info('File selected: "{}" at path "{}"'.format(payload['name'], payload['path']))
self.process_gcode(payload)
self._logger.info(self._printer.get_current_data())
self._logger.info('GCODE Processed: {} layers'.format(self.num_layers))
self.send_layer(0)
if event == 'Dwelling': #G4 command received
......@@ -71,6 +77,9 @@ class AutofdpPlugin(octoprint.plugin.SettingsPlugin,
self._printer.commands('G0 X10 Y10')
if event == 'Waiting': #M0, M1, M226 received
self._logger.info('Waiting')
if event == 'ZChange':
data = self._printer.get_current_data()
self._logger.info('Layer changed. currentZ = {}'.format(data))
##~~ TemplatePlugin mixin
......@@ -79,7 +88,7 @@ class AutofdpPlugin(octoprint.plugin.SettingsPlugin,
dict(type="tab", custom_bindings=True),
dict(type="settings", custom_bindings=False)
]
# def get_template_vars(self):
# return dict(x_offset=self._settings.get(["x_offset"]),
# y_offset=self._settings.get(["y_offset"]),
......@@ -87,8 +96,10 @@ class AutofdpPlugin(octoprint.plugin.SettingsPlugin,
##~~ StartupPlugin mixin
def on_after_startup(self):
self._logger.info("autoFDP starting...")
self._logger.info(self._settings.get(["x_offset"]))
self._logger.info("autoFDP starting, retrieving saved settings...")
self.offsets['x'] = float(self._settings.get(['x_offset']))
self.offsets['y'] = float(self._settings.get(['y_offset']))
self.offsets['z'] = float(self._settings.get(['z_offset']))
##~~ SettingsPlugin mixin
......@@ -104,9 +115,9 @@ class AutofdpPlugin(octoprint.plugin.SettingsPlugin,
octoprint.plugin.SettingsPlugin.on_settings_save(self, data)
self._logger.info("SETTINGS HAVE BEEN CHANGED")
#TODO: PROBE UPDATE CODE HERE
test = self._settings.get(["x_offset"])
self._logger.info(test)
self._logger.info(str(type(test)))
self.offsets['x'] = float(self._settings.get(['x_offset']))
self.offsets['y'] = float(self._settings.get(['y_offset']))
self.offsets['z'] = float(self._settings.get(['z_offset']))
##~~ AssetPlugin mixin
def get_assets(self):
......@@ -117,7 +128,34 @@ class AutofdpPlugin(octoprint.plugin.SettingsPlugin,
#css=["css/autoFDP.css"],
#less=["less/autoFDP.less"]
)
##~~ CUSTOM FUNCTIONS FOR FAULT DETECTION PROBE
def sample_layer(self):
def probe_point(self, x, y, z):
"""
Probe at selected x,y,z position. Move probe to point, extend probe, measure output, and report result
"""
self._logger.info('STARTING PROBE SEQUENCE')
probe_x = x - self.offsets['x']
probe_y = y - self.offsets['y']
probe_z = z + self.offsets['z']
# Go to 2mm above the sample position, accounting for tool offset
self._printer.commands('G0 X{} Y{} Z{}'.format(x+self.offsets['x'],
y+self.offsets['y'],
z+self.offsets['z']))
#TODO: EXTEND PROBE HERE
#TODO: READ PROBE VALUE HERE
#TODO: RETURN PROBE READING HERE
return True
##~~ Softwareupdate hook
def get_update_information(self):
......
......@@ -20,6 +20,10 @@ $(function() {
self.current_layer = ko.observable("N/A");
self.total_layers = ko.observable("N/A");
self.svg_test = function() {
console.log("hello");
}
self.onDataUpdaterPluginMessage = function(plugin, data) {
if (plugin != "autoFDP") {
return;
......
......@@ -44,6 +44,6 @@
</div>
<div class="form-actions">
<button type="button" class="btn btn-primary">Process GCODE</button>
<button type="button" class="btn btn-primary" data-bind="click: test_command">Process GCODE</button>
<button type="button" class="btn">Reset to defaults</button>
</div>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment