From 8ab87312b3e30f09b545d09986a31a897214a5be Mon Sep 17 00:00:00 2001 From: peteruithoven Date: Tue, 22 Oct 2013 13:51:02 +0200 Subject: [PATCH] Replacing variables in endcode on API:printer/stop --- src/rest/api/api_printer.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/rest/api/api_printer.lua b/src/rest/api/api_printer.lua index b4d085f..bc90205 100644 --- a/src/rest/api/api_printer.lua +++ b/src/rest/api/api_printer.lua @@ -106,6 +106,8 @@ end function M.stop_POST(request, response) + log:info("API:printer/stop") + if not accessManager.hasControl(request.remoteAddress) then response:setFail("No control access") return @@ -114,8 +116,14 @@ function M.stop_POST(request, response) local argId = request:get("id") local printer,msg = printerUtils.createPrinterOrFail(argId, response) if not printer then return end - - local endGcode = settings.get('printer.endgcode') + + -- replacing {printingTemp} and {preheatTemp} in endgcode + local printingTemperature = settings.get('printer.temperature') + local preheatTemperature = settings.get('printer.heatup.temperature') + local endGcode = settings.get('printer.endgcode') + endGcode = string.gsub(endGcode,"{printingTemp}",printingTemperature) + endGcode = string.gsub(endGcode,"{preheatTemp}",preheatTemperature) + local rv,msg = printer:stopPrint(endGcode) response:addData('id', argId)