diff --git a/projects/tentacles/src/python/gcode.py b/projects/tentacles/src/python/gcode.py index c2761a4..4131aef 100644 --- a/projects/tentacles/src/python/gcode.py +++ b/projects/tentacles/src/python/gcode.py @@ -37,6 +37,7 @@ class GcodeAnalysis: max_bed: int max_end: int filament: str + nozzle: int def parse_point(point: str) -> Tuple[int, int]: @@ -88,6 +89,11 @@ def analyze_gcode_str(text: str) -> Optional[GcodeAnalysis]: else: return None + if "nozzle_diameter" in opts: + kwargs["nozzle"] = float(opts["nozzle_diameter"]) + else: + return None + return GcodeAnalysis(**kwargs) diff --git a/projects/tentacles/src/python/tentacles/sql/files.sql b/projects/tentacles/src/python/tentacles/sql/files.sql index 389d096..9a53828 100644 --- a/projects/tentacles/src/python/tentacles/sql/files.sql +++ b/projects/tentacles/src/python/tentacles/sql/files.sql @@ -16,6 +16,7 @@ CREATE TABLE IF NOT EXISTS file_analysis ( , max_z INTEGER , max_end INTEGER , max_bed INTEGER + , nozzle_diameter FLOAT , filament_id INTEGER REFERENCES filament(id) , file_id INTEGER REFERENCES file(id) ); @@ -60,11 +61,12 @@ WHERE -- name: create-analysis^ INSERT INTO file_analysis ( - , max_x + max_x , max_y , max_z , max_end , max_bed + , nozzle_diameter , filament_id , file_id ) @@ -74,6 +76,7 @@ VALUES ( , :max_z , :max_end , :max_bed + , :nozzle , :filament_id , :file_id ) @@ -84,7 +87,9 @@ RETURNING -- name: list-unanalyzed-files SELECT f.id + , f.path , f.filename + , f.user_id FROM files f LEFT JOIN file_analysis fa ON f.id = fa.file_id diff --git a/projects/tentacles/src/python/tentacles/sql/jobs.sql b/projects/tentacles/src/python/tentacles/sql/jobs.sql index 3d8ded8..7c9ef2b 100644 --- a/projects/tentacles/src/python/tentacles/sql/jobs.sql +++ b/projects/tentacles/src/python/tentacles/sql/jobs.sql @@ -68,17 +68,25 @@ WHERE -- name: list-job-queue SELECT - * + j.id as id + , j.file_id + , fa.id as analysis_id + , fa.max_x + , fa.max_y + , fa.max_z + , fa.max_bed + , fa.max_end + , fa.nozzle_diameter + , fa.filament_id FROM jobs j INNER JOIN files f ON j.file_id = f.id -INNER JOIN file_analysis fa +LEFT JOIN file_analysis fa ON fa.file_id = f.id WHERE finished_at IS NULL AND (:uid IS NULL OR j.user_id = :uid) AND f.id IS NOT NULL - AND fa.id IS NOT NULL ; -- name: poll-job-queue^ diff --git a/projects/tentacles/src/python/tentacles/sql/printers.sql b/projects/tentacles/src/python/tentacles/sql/printers.sql index 16eb881..3901f46 100644 --- a/projects/tentacles/src/python/tentacles/sql/printers.sql +++ b/projects/tentacles/src/python/tentacles/sql/printers.sql @@ -76,7 +76,7 @@ ALTER TABLE printers ADD filament_id INTEGER REFERENCES filament(id) DEFAULT 1; ALTER TABLE printers ADD enabled BOOLEAN DEFAULT TRUE; -- name: migration-0005-create-printer-nozzle# -ALTER TABLE printers ADD nozzle_diameter INTEGER default 4; +ALTER TABLE printers ADD nozzle_diameter FLOAT DEFAULT 0.4; -- name: try-create-printer^ INSERT INTO printers ( @@ -116,8 +116,19 @@ SELECT , p.api_key , p.last_poll_date , s.name as status + , p.enabled + , f.name as filament_name + , c.name as machine_name + , c.limit_x + , c.limit_y + , c.limit_z + , c.limit_bed + , c.limit_hotend + , p.nozzle_diameter FROM printers p INNER JOIN printer_statuses s ON p.status_id = s.id +INNER JOIN filament f on p.filament_id = f.id +INNER JOIN printer_chassis c on p.chassis_id = c.id ; -- name: list-idle-printers @@ -126,9 +137,8 @@ SELECT , c.limit_x , c.limit_y , c.limit_z - , c.limit_hotend , c.limit_bed - , c.limit_tools + , c.limit_hotend , p.nozzle_diameter FROM printers p LEFT JOIN (SELECT id, printer_id FROM jobs WHERE finished_at IS NULL) j diff --git a/projects/tentacles/src/python/tentacles/templates/streams.html.j2 b/projects/tentacles/src/python/tentacles/templates/streams.html.j2 index 16d8713..450ca89 100644 --- a/projects/tentacles/src/python/tentacles/templates/streams.html.j2 +++ b/projects/tentacles/src/python/tentacles/templates/streams.html.j2 @@ -6,6 +6,10 @@