Fix: recover filament IDs correctly; edit nozzle size; nozzle as a schedule constraint
This commit is contained in:
parent
5ceb2d1488
commit
5b39d9e653
8 changed files with 46 additions and 14 deletions
|
@ -123,7 +123,7 @@ def handle_edit_printers():
|
||||||
args["enabled"] = int(args["enabled"])
|
args["enabled"] = int(args["enabled"])
|
||||||
args["filament_id"] = int(args["filament_id"])
|
args["filament_id"] = int(args["filament_id"])
|
||||||
args["chassis_id"] = int(args["chassis_id"])
|
args["chassis_id"] = int(args["chassis_id"])
|
||||||
print(args)
|
args["nozzle_diameter"] = float(args["nozzle_diameter"])
|
||||||
ctx.db.edit_printer(**args)
|
ctx.db.edit_printer(**args)
|
||||||
return redirect("/admin")
|
return redirect("/admin")
|
||||||
|
|
||||||
|
|
|
@ -213,3 +213,7 @@ class Db(Queries):
|
||||||
|
|
||||||
def finish_job(self, *, jid: int, state: str, message: Optional[str] = None):
|
def finish_job(self, *, jid: int, state: str, message: Optional[str] = None):
|
||||||
super().finish_job(jid=jid, state=state, message=message)
|
super().finish_job(jid=jid, state=state, message=message)
|
||||||
|
|
||||||
|
def create_filament(self, *, name: str):
|
||||||
|
super().create_filament(name=name)
|
||||||
|
return super().fetch_filament(name=name)
|
||||||
|
|
|
@ -78,6 +78,7 @@ SELECT
|
||||||
, fa.max_end
|
, fa.max_end
|
||||||
, fa.nozzle_diameter
|
, fa.nozzle_diameter
|
||||||
, fa.filament_id
|
, fa.filament_id
|
||||||
|
, (SELECT name FROM filament WHERE id = fa.filament_id) AS filament_name
|
||||||
FROM jobs j
|
FROM jobs j
|
||||||
INNER JOIN files f
|
INNER JOIN files f
|
||||||
ON j.file_id = f.id
|
ON j.file_id = f.id
|
||||||
|
|
|
@ -102,6 +102,7 @@ SELECT
|
||||||
, p.chassis_id
|
, p.chassis_id
|
||||||
, p.enabled
|
, p.enabled
|
||||||
, s.name as status
|
, s.name as status
|
||||||
|
, p.nozzle_diameter
|
||||||
FROM printers p
|
FROM printers p
|
||||||
INNER JOIN printer_statuses s ON p.status_id = s.id
|
INNER JOIN printer_statuses s ON p.status_id = s.id
|
||||||
WHERE p.id = :pid
|
WHERE p.id = :pid
|
||||||
|
@ -140,6 +141,7 @@ SELECT
|
||||||
, c.limit_bed
|
, c.limit_bed
|
||||||
, c.limit_hotend
|
, c.limit_hotend
|
||||||
, p.nozzle_diameter
|
, p.nozzle_diameter
|
||||||
|
, p.filament_id
|
||||||
FROM printers p
|
FROM printers p
|
||||||
LEFT JOIN (SELECT id, printer_id FROM jobs WHERE finished_at IS NULL) j
|
LEFT JOIN (SELECT id, printer_id FROM jobs WHERE finished_at IS NULL) j
|
||||||
ON p.id = j.printer_id
|
ON p.id = j.printer_id
|
||||||
|
@ -174,6 +176,7 @@ SET
|
||||||
, filament_id = :filament_id
|
, filament_id = :filament_id
|
||||||
, chassis_id = :chassis_id
|
, chassis_id = :chassis_id
|
||||||
, enabled = :enabled
|
, enabled = :enabled
|
||||||
|
, nozzle_diameter = :nozzle_diameter
|
||||||
WHERE
|
WHERE
|
||||||
id = :id
|
id = :id
|
||||||
;
|
;
|
||||||
|
@ -202,3 +205,9 @@ VALUES (
|
||||||
RETURNING
|
RETURNING
|
||||||
id
|
id
|
||||||
;
|
;
|
||||||
|
|
||||||
|
-- name: fetch-filament^
|
||||||
|
SELECT *
|
||||||
|
FROM filament
|
||||||
|
WHERE name = :name
|
||||||
|
;
|
||||||
|
|
|
@ -4,10 +4,18 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<form method="post">
|
<form method="post">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="twelve columns">
|
<div class="six columns">
|
||||||
<label for="name">Printer name</label>
|
<label for="name">Printer name</label>
|
||||||
<input type="text" name="name" value="{{ printer.name }}" />
|
<input type="text" name="name" value="{{ printer.name }}" />
|
||||||
</div>
|
</div>
|
||||||
|
<div class="six columns">
|
||||||
|
<label for="chassis">Chassis</label>
|
||||||
|
<select name="chassis_id">
|
||||||
|
{% for c in ctx.db.list_chassis() %}
|
||||||
|
<option value="{{c.id}}" {% if printer.chassis_id == c.id %}selected{%endif%}>{{c.name}}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="twelve columns">
|
<div class="twelve columns">
|
||||||
|
@ -27,15 +35,7 @@
|
||||||
<input type="text" name="api_key" value="{{ printer.api_key }}" />
|
<input type="text" name="api_key" value="{{ printer.api_key }}" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class"row">
|
<div class="row">
|
||||||
<div class="four columns">
|
|
||||||
<label for="chassis">Chassis</label>
|
|
||||||
<select name="chassis_id">
|
|
||||||
{% for c in ctx.db.list_chassis() %}
|
|
||||||
<option value="{{c.id}}" {% if printer.chassis_id == c.id %}selected{%endif%}>{{c.name}}</option>
|
|
||||||
{% endfor %}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="four columns">
|
<div class="four columns">
|
||||||
<label for="filament">Filament load</label>
|
<label for="filament">Filament load</label>
|
||||||
<select name="filament_id">
|
<select name="filament_id">
|
||||||
|
@ -44,6 +44,10 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="four columns">
|
||||||
|
<label for="nozzle_diameter">Nozzle diameter (mm)</label>
|
||||||
|
<input type="text" name="nozzle_diameter" value="{{ printer.nozzle_diameter}}" />
|
||||||
|
</div>
|
||||||
<div class="four columns">
|
<div class="four columns">
|
||||||
<label for="enabled">Printing enabled</label>
|
<label for="enabled">Printing enabled</label>
|
||||||
<select name="enabled">
|
<select name="enabled">
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
{% if jobs %}
|
{% if jobs %}
|
||||||
{% for job in jobs %}
|
{% for job in jobs %}
|
||||||
<div class="job row u-flex">
|
<div class="job row u-flex">
|
||||||
<div class="details six columns u-flex">
|
<div class="details six columns u-flex u-flex-wrap">
|
||||||
<div class="job-filename u-flex">
|
<div class="job-filename u-flex">
|
||||||
<label for="filename">File</label>
|
<label for="filename">File</label>
|
||||||
<span name="filename">{{ctx.db.fetch_file(ctx.uid, job.file_id).filename or "it's a secret"}}</span>
|
<span name="filename">{{ctx.db.fetch_file(ctx.uid, job.file_id).filename or "it's a secret"}}</span>
|
||||||
|
@ -20,6 +20,15 @@
|
||||||
<label for="runtime">Runtime</label>
|
<label for="runtime">Runtime</label>
|
||||||
<span name="Runtime">{{ (datetime.now() - datetime.fromisoformat(job.started_at)) }}</span>
|
<span name="Runtime">{{ (datetime.now() - datetime.fromisoformat(job.started_at)) }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<div class="job-constraint u-flex">
|
||||||
|
<label>Material</label>
|
||||||
|
{{ job.filament_name }}
|
||||||
|
</div>
|
||||||
|
<div class="job-constraint u-flex">
|
||||||
|
<label>Limits</label>
|
||||||
|
{{ job.max_x }}mm x{{ job.max_y }}mm x{{ job.max_z }}mm, bed {{ job.max_bed }}c, end {{ job.max_end }}c, nozzle {{ "%.2f"|format(job.nozzle_diameter) }}mm
|
||||||
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="two columns">
|
<div class="two columns">
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
<span><label>Status</label>{{printer.status}}, {% if printer.enabled %}accepting jobs{%else%}not scheduling{%endif%}</span>
|
<span><label>Status</label>{{printer.status}}, {% if printer.enabled %}accepting jobs{%else%}not scheduling{%endif%}</span>
|
||||||
<span><label>Loaded material</label>{{printer.filament_name}}</span>
|
<span><label>Loaded material</label>{{printer.filament_name}}</span>
|
||||||
<span><label>Machine</label>{{printer.machine_name}}</span>
|
<span><label>Machine</label>{{printer.machine_name}}</span>
|
||||||
|
<span><label>Nozzle</label>{{ "%.2f"|format(printer.nozzle_diameter) }}mm</span>
|
||||||
<span><label>Limits</label>{{printer.limit_x}}mm x{{printer.limit_y}}mm x{{printer.limit_z}}mm, bed {{printer.limit_bed}}c, end {{printer.limit_hotend}}c</span>
|
<span><label>Limits</label>{{printer.limit_x}}mm x{{printer.limit_y}}mm x{{printer.limit_z}}mm, bed {{printer.limit_bed}}c, end {{printer.limit_hotend}}c</span>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -152,7 +152,8 @@ def assign_jobs(app: App, db: Db) -> None:
|
||||||
for job in db.list_job_queue(uid=None):
|
for job in db.list_job_queue(uid=None):
|
||||||
for printer in db.list_idle_printers():
|
for printer in db.list_idle_printers():
|
||||||
if (
|
if (
|
||||||
printer.limit_x >= job.max_x
|
job.analysis_id is not None
|
||||||
|
and printer.limit_x >= job.max_x
|
||||||
and printer.limit_y >= job.max_y
|
and printer.limit_y >= job.max_y
|
||||||
and printer.limit_z >= job.max_z
|
and printer.limit_z >= job.max_z
|
||||||
and printer.limit_hotend >= job.max_end
|
and printer.limit_hotend >= job.max_end
|
||||||
|
@ -163,6 +164,8 @@ def assign_jobs(app: App, db: Db) -> None:
|
||||||
db.assign_job(jid=job.id, pid=printer.id)
|
db.assign_job(jid=job.id, pid=printer.id)
|
||||||
log.info(f"Mapped job {job.id} to printer {printer.id}")
|
log.info(f"Mapped job {job.id} to printer {printer.id}")
|
||||||
break
|
break
|
||||||
|
else:
|
||||||
|
print("Could not map\n", job, "\n", printer)
|
||||||
|
|
||||||
|
|
||||||
def push_jobs(app: App, db: Db) -> None:
|
def push_jobs(app: App, db: Db) -> None:
|
||||||
|
@ -336,6 +339,7 @@ def analyze_files(app: App, db: Db):
|
||||||
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
log.info(f"Analyzed {file}")
|
||||||
db.create_analysis(
|
db.create_analysis(
|
||||||
file_id=file.id,
|
file_id=file.id,
|
||||||
max_x=record.max_x,
|
max_x=record.max_x,
|
||||||
|
@ -344,7 +348,7 @@ def analyze_files(app: App, db: Db):
|
||||||
max_end=record.max_end,
|
max_end=record.max_end,
|
||||||
max_bed=record.max_bed,
|
max_bed=record.max_bed,
|
||||||
nozzle=record.nozzle,
|
nozzle=record.nozzle,
|
||||||
filament_id=db.create_filament(record.filament),
|
filament_id=db.create_filament(name=record.filament).id,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue