0
0
mirror of https://github.com/Doodle3D/doodle3d-firmware.git synced 2024-12-22 11:03:48 +01:00

Do not generate error when printer device exists without accompanying server. Fixes https://github.com/Doodle3D/doodle3d-client/issues/139.

This commit is contained in:
Wouter R 2013-12-20 17:11:58 +01:00
parent fc9460fc82
commit d254beb1ab
3 changed files with 13 additions and 19 deletions

View File

@ -29,10 +29,8 @@ local function operationsAccessOrFail(request, response)
end end
local rv, printerState = printerAPI.state(request, response, true) local rv, printerState = printerAPI.state(request, response, true)
if(rv == false) then -- NOTE: rv being false means a printer device exists but no server is running for it, so it cannot be 'busy'
response:setError("Could not get printer state") if rv == false then return true end
return false
end
if printerState == 'buffering' or printerState == 'printing' or printerState == 'stopping' then if printerState == 'buffering' or printerState == 'printing' or printerState == 'stopping' then
response:setFail("Printer is busy, please wait") response:setFail("Printer is busy, please wait")
@ -97,16 +95,16 @@ function M.all_GET(request, response)
end end
--- Reset specific setting to default value --- Reset specific setting to default value
-- When an setting has a subSection only the setting in it's current subSection is reset. -- When an setting has a subSection only the setting in it's current subSection is reset.
-- For example you want to reset setting _printer.startcode_ -- For example you want to reset setting _printer.startcode_
-- and it has it's _subSection_ set to 'printer_type' -- and it has it's _subSection_ set to 'printer_type'
-- and printer.type is set to 'ultimaker' then -- and printer.type is set to 'ultimaker' then
-- only the printer.startcode under the ultimaker subsection is removed. -- only the printer.startcode under the ultimaker subsection is removed.
function M.reset_POST(request, response) function M.reset_POST(request, response)
--log:info("API:reset"); --log:info("API:reset");
if not operationsAccessOrFail(request, response) then return end if not operationsAccessOrFail(request, response) then return end
response:setSuccess() response:setSuccess()
for k,v in pairs(request:getAll()) do for k,v in pairs(request:getAll()) do
--log:info(" "..k..": "..v); --log:info(" "..k..": "..v);
local r,m = settings.reset(k); local r,m = settings.reset(k);
@ -115,12 +113,12 @@ function M.reset_POST(request, response)
end end
end end
--- Reset all settings to default value --- Reset all settings to default value
function M.resetall_POST(request, response) function M.resetall_POST(request, response)
if not operationsAccessOrFail(request, response) then return end if not operationsAccessOrFail(request, response) then return end
response:setSuccess() response:setSuccess()
settings.resetAll() settings.resetAll()
for k,v in pairs(settings.getAll()) do for k,v in pairs(settings.getAll()) do
response:addData(k,v) response:addData(k,v)
end end

View File

@ -29,10 +29,8 @@ local function operationsAccessOrFail(request, response)
end end
local rv, printerState = printerAPI.state(request, response, true) local rv, printerState = printerAPI.state(request, response, true)
if(rv == false) then -- NOTE: rv being false means a printer device exists but no server is running for it, so it cannot be 'busy'
response:setError("Could not get printer state") if rv == false then return true end
return false
end
if printerState == 'buffering' or printerState == 'printing' or printerState == 'stopping' then if printerState == 'buffering' or printerState == 'printing' or printerState == 'stopping' then
response:setFail("Printer is busy, please wait") response:setFail("Printer is busy, please wait")

View File

@ -34,10 +34,8 @@ local function operationsAccessOrFail(request, response)
end end
local rv, printerState = printerAPI.state(request, response, true) local rv, printerState = printerAPI.state(request, response, true)
if(rv == false) then -- NOTE: rv being false means a printer device exists but no server is running for it, so it cannot be 'busy'
response:setError("Could not get printer state") if rv == false then return true end
return false
end
if printerState == 'buffering' or printerState == 'printing' or printerState == 'stopping' then if printerState == 'buffering' or printerState == 'printing' or printerState == 'stopping' then
response:setFail("Printer is busy, please wait") response:setFail("Printer is busy, please wait")