diff --git a/README.md b/README.md
index 4b9b822..5557849 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,2 @@
# FABtotum official laser plugin
-Laser Engraving utilities plugin.
+Extends Create and Projectmanager with support for laser engraving.
diff --git a/controller.php b/controller.php
index 890cfc7..fc52049 100644
--- a/controller.php
+++ b/controller.php
@@ -91,8 +91,8 @@ public function make($fileID = '')
//~ $data['z_height_values'] = array('0.1' => '0.1', '0.01' => '0.01');
// select_file
- $data['get_files_url'] = plugin_url('getFiles');
- $data['get_reacent_url'] = plugin_url('getRecentFiles');
+ $data['get_files_url'] = 'std/getFiles/laser';
+ $data['get_reacent_url'] = 'std/getRecentFiles/laser';
// task_wizard
$data['start_task_url'] = plugin_url('startTask');
@@ -190,63 +190,6 @@ public function make($fileID = '')
$this->view();
}
- /**
- * @param $data (list)
- * return array data for dataTable pluguin
- */
- private function dataTableFormat($data)
- {
- //load text helper
- $this->load->helper('text_helper');
- $aaData = array();
- foreach($data as $file){
- $td0 = '';
- $td1 = ''.$file['client_name'].''.ellipsize($file['orig_name'], 35).'';
- $td2 = ' '.$file['name'].''.ellipsize($file['name'], 35).'';
- $td3 = $file['id_file'];
- $td4 = $file['id_object'];
- $aaData[] = array($td0, $td1, $td2, $td3, $td4);
- }
- return $aaData;
- }
-
- /**
- * @param type (additive, subtractive)
- * @return json object for dataTables plugin
- * get all files
- */
- public function getFiles()
- {
- //load libraries, models, helpers
- $this->load->model('Files', 'files');
- $files = $this->files->getForCreate( 'laser' );
- $aaData = $this->dataTableFormat($files);
- $this->output->set_content_type('application/json')->set_output(json_encode(array('aaData' => $aaData)));
- }
-
- /**
- * @param type (additive, subtractive)
- * @return json object for dataTables plugin
- * get all files
- */
- public function getImageFiles()
- {
- //load libraries, models, helpers
- $this->load->model('Files', 'files');
- $files = $this->files->getByExtension( array('.jpg', '.jpeg', '.png', '.dxf') );
- $aaData = $this->dataTableFormat($files);
- $this->output->set_content_type('application/json')->set_output(json_encode(array('aaData' => $aaData)));
- }
-
- public function getRecentFiles($task_type = '')
- {
- //load libraries, models, helpers
- $this->load->model('Tasks', 'tasks');
- $files = $this->tasks->getLastCreations($task_type);
- $aaData = $this->dataTableFormat($files);
- $this->output->set_content_type('application/json')->set_output(json_encode(array('aaData' => $aaData)));
- }
-
public function startTask()
{
//load helpers
@@ -258,8 +201,15 @@ public function startTask()
$fileToCreate = $this->files->get($data['idFile'], 1);
+ //reset task monitor file
resetTaskMonitor();
- resetTrace('Please wait...');
+ $startSubtractive = doMacro('start_engraving');
+ if($startSubtractive['response'] =! 'ok'){
+ $this->output->set_content_type('application/json')->set_output(json_encode(array('start' => false, 'message' => $startSubtractive['message'])));
+ return;
+ }
+
+ resetTrace( _("Please wait...") );
//get object record
$object = $this->files->getObject($fileToCreate['id']);
@@ -276,12 +226,10 @@ public function startTask()
'start_date' => date('Y-m-d H:i:s')
);
$taskId = $this->tasks->add($taskData);
- //$taskId = 0;
- //$userID = $this->session->user['id'];
$response = array(
'start' => false,
- 'message' => 'Task Not Implemented yet.',
+ 'message' => _("Task Not Implemented yet."),
'trace' => '',
'error' => ''
);
diff --git a/scripts/py/engrave.py b/scripts/py/engrave.py
index 15facc4..ae01b79 100644
--- a/scripts/py/engrave.py
+++ b/scripts/py/engrave.py
@@ -21,20 +21,16 @@
# Import standard python module
import argparse
import time
-import gettext
# Import external modules
# Import internal modules
+from fabtotum.utils.translation import _, setLanguage
from fabtotum.fabui.config import ConfigService
from fabtotum.fabui.gpusher import GCodePusher
import fabtotum.fabui.macros.general as general_macros
import fabtotum.fabui.macros.printing as print_macros
-# Set up message catalog access
-tr = gettext.translation('mill', 'locale', fallback=True)
-_ = tr.ugettext
-
################################################################################
class Application(GCodePusher):
@@ -42,28 +38,22 @@ class Application(GCodePusher):
Milling application.
"""
- def __init__(self, log_trace, monitor_file, standalone = False, autolevel = False, finalize = True):
- super(Application, self).__init__(log_trace, monitor_file, use_stdout=standalone )
+ def __init__(self, standalone = False):
+ super(Application, self).__init__(use_stdout=standalone)
self.standalone = standalone
- self.autolevel = autolevel
- self.finalize = finalize
-
- def progress_callback(self, percentage):
- print "Progress", percentage
- def task_finalize(self):
- if self.standalone or self.finalize:
- if self.is_aborted():
- self.set_task_status(GCodePusher.TASK_ABORTING)
- else:
- self.set_task_status(GCodePusher.TASK_COMPLETING)
-
- #~ self.exec_macro("end_subtractive")
-
- if self.is_aborted():
- self.set_task_status(GCodePusher.TASK_ABORTED)
- else:
- self.set_task_status(GCodePusher.TASK_COMPLETED)
+ def task_finalize(self):
+ if self.is_aborted():
+ self.set_task_status(GCodePusher.TASK_ABORTING)
+ else:
+ self.set_task_status(GCodePusher.TASK_COMPLETING)
+
+ if self.is_aborted():
+ self.exec_macro("end_engraving_aborted")
+ self.set_task_status(GCodePusher.TASK_ABORTED)
+ else:
+ self.exec_macro("end_engraving")
+ self.set_task_status(GCodePusher.TASK_COMPLETED)
self.stop()
@@ -81,6 +71,7 @@ def file_done_callback(self):
def state_change_callback(self, state):
if state == 'paused':
self.trace( _("Engraving PAUSED") )
+ self.trace( _("Please wait until the buffered moves in totumduino are finished") )
if state == 'resumed':
self.trace( _("Engraving RESUMED") )
if state == 'aborted':
@@ -96,12 +87,11 @@ def run(self, task_id, gcode_file):
:type task_id: int
"""
- self.prepare_task(task_id, task_type='fab_laser', task_controller='plugin', gcode_file=gcode_file)
+ self.prepare_task(task_id, task_type='laser', gcode_file=gcode_file)
self.set_task_status(GCodePusher.TASK_RUNNING)
- #if self.standalone:
- #~ self.exec_macro("check_pre_print")
- #self.exec_macro("start_subtractive")
+ if self.standalone:
+ self.exec_macro("start_engraving")
self.send_file(gcode_file)
@@ -125,12 +115,8 @@ def main():
standalone = True
else:
standalone = False
-
- autolevel = False
- monitor_file = config.get('general', 'task_monitor') # TASK MONITOR FILE (write stats & task info, es: temperatures, speed, etc
- log_trace = config.get('general', 'trace') # TASK TRACE FILE
- app = Application(log_trace, monitor_file, standalone, autolevel)
+ app = Application(standalone)
app.run(task_id, gcode_file)
app.loop()
diff --git a/views/make/js.php b/views/make/js.php
index caea8fa..95200c9 100644
--- a/views/make/js.php
+++ b/views/make/js.php
@@ -13,30 +13,11 @@
var idFile ; //file to create
var idTask ;
+
$(document).ready(function() {
$('#understandSafety').on('click', understandSafety);
-
$('[data-toggle="tooltip"]').tooltip();
});
-
- /**
- * freeze ui
- */
- function freezeUI()
- {
- disableButton('.btn-prev');
- disableButton('.btn-next');
- disableButton('.top-directions');
- disableButton('.top-axisz');
- }
- /**
- *
- */
- function unFreezeUI()
- {
- enableButton('.top-directions');
- enableButton('.top-axisz');
- }
function checkWizard()
{
@@ -52,8 +33,8 @@ function checkWizard()
disableButton('.btn-next');
$('.btn-next').find('span').html('Next');
- //cmd = 'M60 S0\n';
- //fabApp.jogMdi(cmd);
+ cmd = 'M62';
+ fabApp.jogMdi(cmd);
break;
case 2: // Safety
@@ -61,8 +42,8 @@ function checkWizard()
disableButton('.btn-next');
$('.btn-next').find('span').html('Next');
- //cmd = 'M60 S0\n';
- //fabApp.jogMdi(cmd);
+ cmd = 'M62';
+ fabApp.jogMdi(cmd);
break;
case 3: // Calibration
@@ -70,14 +51,16 @@ function checkWizard()
disableButton('.btn-next');
$('.btn-next').find('span').html('Engrave');
- //cmd = 'M60 S10\nM300\n';
- //fabApp.jogMdi(cmd);
+ cmd = 'M60 S10\nM300\n';
+ fabApp.jogMdi(cmd);
break;
case 4: // Execution
;
// do nothing
+ cmd = 'M62';
+ fabApp.jogMdi(cmd);
startTask();
return false;
@@ -88,18 +71,23 @@ function checkWizard()
}
}
- function setLaserPWM(action, value)
+ function jogSetAsZero()
{
- console.log(action, value);
- message="Laser PWM set to: " + value;
- showActionAlert(message);
+ console.log('set as zero');
+ enableButton('.btn-next');
+ return false;
+ }
+
+ function understandSafety()
+ {
+ enableButton('.btn-next');
+ return false;
}
function startTask()
{
console.log('Starting task');
- is_task_on = true;
- openWait('Initializing');
+ openWait('' + "".format(""), "");
var data = {
idFile:idFile
@@ -110,40 +98,28 @@ function startTask()
data: data,
url: '',
dataType: 'json'
- }).done(function(response) {
+ }).done(function(response) {
if(response.start == false){
$('.wizard').wizard('selectedItem', { step: 2 });
- showErrorAlert('Error', response.message);
+ fabApp.showErrorAlert(response.message);
}else{
-
- //setInterval(timer, 1000);
- //setInterval(jsonMonitor, 1000);
- idTask = response.id_task;
-
- fabApp.resetTemperaturesPlot(50);
- setTimeout(initGraph, 1000);
- //~ setTemperaturesSlidersValue(response.temperatures.extruder, response.temperatures.bed);
-
+ idTask = response.id_task;
initRunningTaskPage();
updateZOverride(0);
+
+ ga('send', 'event', 'laser', 'start', 'laser started');
}
closeWait();
})
}
- function understandSafety()
- {
- enableButton('.btn-next');
- return false;
- }
-
- function jogSetAsZero()
+ function setLaserPWM(action, value)
{
- console.log('set as zero');
- enableButton('.btn-next');
- return false;
+ console.log(action, value);
+ message="Laser PWM set to: " + value;
+ showActionAlert(message);
}