2013-12-20 16:29:46 +01:00
|
|
|
--
|
|
|
|
-- This file is part of the Doodle3D project (http://doodle3d.com).
|
|
|
|
--
|
|
|
|
-- @copyright 2013, Doodle3D
|
|
|
|
-- @license This software is licensed under the terms of the GNU GPL v2 or later.
|
|
|
|
-- See file LICENSE.txt or visit http://www.gnu.org/licenses/gpl.html for full license details.
|
|
|
|
|
|
|
|
|
2013-10-10 12:11:16 +02:00
|
|
|
local log = require('util.logger')
|
|
|
|
local utils = require('util.utils')
|
|
|
|
local printDriver = require('print3d')
|
|
|
|
|
2014-04-25 14:51:29 +02:00
|
|
|
local MOD_ABBR = "UPRN"
|
|
|
|
|
2013-10-14 18:11:15 +02:00
|
|
|
local SUPPORTED_PRINTERS = {
|
2013-08-28 18:33:48 +02:00
|
|
|
rigidbot = "Rigidbot",
|
|
|
|
ultimaker = "Ultimaker",
|
2015-06-08 15:34:07 +02:00
|
|
|
ultimaker2 = "Ultimaker 2",
|
|
|
|
ultimaker2go = "Ultimaker 2 Go",
|
2013-08-28 18:33:48 +02:00
|
|
|
makerbot_replicator2 = "MakerBot Replicator2",
|
2013-12-05 16:24:43 +01:00
|
|
|
makerbot_replicator2x = "MakerBot Replicator2x",
|
2013-08-28 18:33:48 +02:00
|
|
|
makerbot_thingomatic = "MakerBot Thing-o-matic",
|
2015-06-10 17:48:09 +02:00
|
|
|
wanhao_duplicator4 = "Wanhao Duplicator 4",
|
2013-08-28 18:33:48 +02:00
|
|
|
printrbot = "Printrbot",
|
|
|
|
bukobot = "Bukobot",
|
|
|
|
cartesio = "Cartesio",
|
|
|
|
cyrus = "Cyrus",
|
|
|
|
delta_rostockmax = "Delta RostockMax",
|
|
|
|
deltamaker = "Deltamaker",
|
|
|
|
eventorbot = "EventorBot",
|
|
|
|
felix = "Felix",
|
|
|
|
gigabot = "Gigabot",
|
|
|
|
kossel = "Kossel",
|
|
|
|
leapfrog_creatr = "LeapFrog Creatr",
|
|
|
|
lulzbot_aO_101 = "LulzBot AO-101",
|
2015-05-27 17:53:53 +02:00
|
|
|
lulzbot_taz_4 = "LulzBot TAZ 4",
|
2013-08-28 18:33:48 +02:00
|
|
|
makergear_m2 = "MakerGear M2",
|
|
|
|
makergear_prusa = "MakerGear Prusa",
|
|
|
|
makibox = "Makibox",
|
|
|
|
orca_0_3 = "Orca 0.3",
|
|
|
|
ord_bot_hadron = "ORD Bot Hadron",
|
|
|
|
printxel_3d = "Printxel 3D",
|
|
|
|
prusa_i3 = "Prusa I3",
|
|
|
|
prusa_iteration_2 = "Prusa Iteration 2",
|
|
|
|
rapman = "RapMan",
|
|
|
|
reprappro_huxley = "RepRapPro Huxley",
|
|
|
|
reprappro_mendel = "RepRapPro Mendel",
|
|
|
|
robo_3d_printer = "RoBo 3D Printer",
|
|
|
|
shapercube = "ShaperCube",
|
|
|
|
tantillus = "Tantillus",
|
2013-10-28 00:58:14 +01:00
|
|
|
vision_3d_printer = "Vision 3D Printer",
|
2014-01-30 13:21:21 +01:00
|
|
|
minifactory = "miniFactory",
|
2014-05-22 15:15:54 +02:00
|
|
|
builder3d = "Builder 3D",
|
|
|
|
bigbuilder3d = "Big Builder 3D",
|
2014-05-28 17:08:49 +02:00
|
|
|
mamba3d = "Mamba3D",
|
2014-10-09 16:24:55 +02:00
|
|
|
_3Dison_plus = "3Dison plus",
|
2013-10-28 00:58:14 +01:00
|
|
|
marlin_generic = "Generic Marlin Printer",
|
2015-06-09 16:13:58 +02:00
|
|
|
makerbot_generic = "Generic Makerbot Printer",
|
2015-08-21 13:59:38 +02:00
|
|
|
doodle_dream = "Doodle Dream",
|
2015-08-21 15:39:32 +02:00
|
|
|
colido_2_0_plus = "ColiDo 2.0 Plus",
|
2015-08-21 13:59:38 +02:00
|
|
|
colido_m2020 = "ColiDo M2020",
|
|
|
|
colido_x3045 = "ColiDo X3045",
|
|
|
|
colido_compact = "ColiDo Compact",
|
2016-02-24 15:26:06 +01:00
|
|
|
colido_diy = "ColiDo DIY",
|
2016-02-24 11:44:12 +01:00
|
|
|
craftbot_plus = "CraftBot PLUS"
|
2013-08-28 18:33:48 +02:00
|
|
|
}
|
2013-10-14 18:11:15 +02:00
|
|
|
local SUPPORTED_BAUDRATES = {
|
2013-08-28 18:33:48 +02:00
|
|
|
["115200"] = "115200 bps",
|
|
|
|
["2500000"] = "2500000 bps"
|
|
|
|
}
|
|
|
|
|
|
|
|
local M = {}
|
|
|
|
|
|
|
|
function M.supportedPrinters()
|
|
|
|
return SUPPORTED_PRINTERS
|
|
|
|
end
|
|
|
|
|
|
|
|
function M.supportedBaudRates()
|
|
|
|
return SUPPORTED_BAUDRATES
|
|
|
|
end
|
|
|
|
|
2013-10-10 12:11:16 +02:00
|
|
|
|
|
|
|
|
|
|
|
--returns a printer instance or nil (and sets error state on response in the latter case)
|
|
|
|
function M.createPrinterOrFail(deviceId, response)
|
|
|
|
|
2014-05-12 13:46:38 +02:00
|
|
|
--log:info(MOD_ABBR, "API:printer:createPrinterOrFail: "..utils.dump(deviceId))
|
2014-04-25 14:51:29 +02:00
|
|
|
local rv,msg,printer = nil, nil, nil
|
2013-10-14 18:11:15 +02:00
|
|
|
|
2013-10-10 12:11:16 +02:00
|
|
|
if deviceId == nil or deviceId == "" then
|
|
|
|
printer,msg = printDriver.getPrinter()
|
2013-10-14 18:11:15 +02:00
|
|
|
else
|
2013-10-10 12:11:16 +02:00
|
|
|
printer,msg = printDriver.getPrinter(deviceId)
|
|
|
|
end
|
2013-10-14 18:11:15 +02:00
|
|
|
|
2013-10-10 12:11:16 +02:00
|
|
|
if not printer then
|
2014-03-12 16:36:16 +01:00
|
|
|
if response ~= nil then
|
|
|
|
response:setError("could not open printer driver (" .. msg .. ")")
|
|
|
|
response:addData('id', deviceId)
|
|
|
|
end
|
2013-10-10 12:11:16 +02:00
|
|
|
return nil
|
|
|
|
end
|
|
|
|
|
2014-04-25 14:51:29 +02:00
|
|
|
-- only log these log setup errors, do not let them prevent further request handling
|
|
|
|
|
|
|
|
rv,msg = printer:setLocalLogStream(log:getStream())
|
|
|
|
if not rv then
|
|
|
|
log:error(MOD_ABBR, "could not set log stream in Lua binding (" .. msg .. ")")
|
|
|
|
end
|
|
|
|
|
|
|
|
rv,msg = printer:setLocalLogLevel(log:getLevel())
|
|
|
|
if not rv then
|
|
|
|
log:error(MOD_ABBR, "could not set log level '" .. log:getLevel() .. "' in Lua binding (" .. msg .. ")")
|
|
|
|
end
|
2014-04-17 14:15:36 +02:00
|
|
|
|
2013-10-10 12:11:16 +02:00
|
|
|
return printer
|
|
|
|
end
|
|
|
|
|
2013-08-28 18:33:48 +02:00
|
|
|
return M
|