diff --git a/js/kiri.js b/js/kiri.js index 2fe96de6..f1fbf3d5 100644 --- a/js/kiri.js +++ b/js/kiri.js @@ -36,6 +36,8 @@ self.kiri.license = exports.LICENSE; nozzleSize: 1, gcodePre: 1, gcodePost: 1, + gcodeProc: 1, + gcodeFExt: 1, gcodeFan: 1, gcodeTrack: 1, gcodeLayer: 1 @@ -226,6 +228,7 @@ self.kiri.license = exports.LICENSE; spindleMax: 0, // CAM gcodePre: [], // FDM/CAM header script gcodePost: [], // FDM/CAM footer script + gcodeProc: "", // FDM post processor script gcodeFan: "", // FDM fan command gcodeTrack: "", // FDM progress command gcodeLayer: "", // FDM layer output @@ -952,12 +955,18 @@ self.kiri.license = exports.LICENSE; var pre = (MODE === MODES.CAM ? "cnc-" : "print-") + (printSeq.toString().padStart(3,"0")), filename = pre,// + (new Date().getTime().toString(36)), fileext = settings.device.gcodeFExt || "gcode", + codeproc = settings.device.gcodeProc, octo_host, octo_apik, grid_host, grid_apik, grid_target; + // run gcode post processor function (when supplied and valid) + if (codeproc && self[codeproc]) { + gcode = self[codeproc](gcode); + } + function getBlob() { return new Blob( [gcode], @@ -2810,6 +2819,7 @@ self.kiri.license = exports.LICENSE; gcodeLayer: valueOf(cmd.layer, []), gcodePre: valueOf(code.pre, []), gcodePost: valueOf(code.post, []), + gcodeProc: valueOf(code.proc, ''), gcodeDwell: valueOf(code.dwell, []), gcodeChange: valueOf(code['tool-change'], []), gcodeFExt: valueOf(code['file-ext'], 'gcode'), diff --git a/js/web-server.js b/js/web-server.js index 33b26ae1..e95170b2 100644 --- a/js/web-server.js +++ b/js/web-server.js @@ -76,8 +76,8 @@ function lastmod(path) { * @param {Function} fn * @returns {*} */ -function getCachedFile(filePath, fn) { - var cachePath = "cache/"+filePath.replace(/\//g,"_"), +function getCachedFile(filePath, cachePath, fn) { + var cachePath = "cache/" + cachePath.replace(/\//g,'_'), cached = fileCache[filePath], now = time(); @@ -160,16 +160,24 @@ function htmlScript(prefix, list) { function concatCode(array) { var code = [], cached, - path; + cachepath, + filepath; - array.forEach(file => { - path = file.charAt(0) === '/' ? file : codePrefix + file + ".js"; - cached = getCachedFile(path, function(path) { - return uglify.minify(path).code; + array.forEach((file, index) => { + if (file.charAt(0) === "/") { + filepath = file; + cachepath = "js_mod" + file.replace(/\//g,'_'); + array[index] = cachepath.substring(3).replace('.js',''); + fileMap[cachepath.replace("js_","js/")] = filepath; + } else { + filepath = codePrefix + file + ".js"; + cachepath = filepath; + } + cached = getCachedFile(filepath, cachepath, function(path) { + return uglify.minify(filepath).code; }); code.push(cached); }); - return code.join(''); } @@ -491,6 +499,10 @@ function handleJS(req, res, next) { fpath = jspos > 0 ? spath.substring(0,jspos+3) : spath, cached = fileCache[fpath]; + if (fileMap[fpath]) { + fpath = fileMap[fpath]; + } + fs.stat(fpath, (err, f) => { if (err || !f) return reply404(req, res); @@ -684,6 +696,7 @@ var ver = require('../js/license.js'), startTime = time(), codePrefix = "js/", fileCache = {}, + fileMap = {}, filters_fdm = [], filters_cam = [], modPaths = [], diff --git a/web/kiri/filter/FDM/XYZ.daVinci.Mini.w b/web/kiri/filter/FDM/XYZ.daVinci.Mini.w new file mode 100644 index 00000000..4f25372a --- /dev/null +++ b/web/kiri/filter/FDM/XYZ.daVinci.Mini.w @@ -0,0 +1,35 @@ +{ + "pre":[ + "; filename = kirimoto.gcode", + "; machine = dv1MW0A000", + "T0 ; select extruder #0", + "M104 S{temp} ; set nozzle temp", + "M109 S{temp} ; wait for nozzle to heat", + "M82 ; absolute extrusion mode", + "G28 ; home", + "G1 Z15 F6000 ; lower platform 15mm", + "G92 E0 ; zero out extruder position", + "G1 F200 E3 ; prime the extruder 3mm" + ], + "post":[ + "M107 ; fan off", + "M104 S0 ; set nozzle temp to 0", + "M140 S0 ; set bed temp to 0", + "G92 E0 ; zero out extruder position", + "G1 E-1 F300 ; retract filament", + "G28 X0 Y0 ; home X Y", + "M84 ; disable steppers" + ], + "cmd":{ + "fan_power": "M106 S{fan_speed}" + }, + "proc": "btoa", + "file-ext": "3w", + "settings":{ + "origin_center": false, + "extrude_abs": true, + "bed_width": 150, + "bed_depth": 150, + "build_height": 150 + } +}