Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
voxelias committed Jul 24, 2023
1 parent c60e2a5 commit b933533
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 42 deletions.
1 change: 1 addition & 0 deletions config.sl1.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = (env, args) => {
WITH_START_PRINT_AFTER_UPLOAD: true,
WITH_LOGS: false,
WITH_FONT: false,
WITH_V1_API: true,
...env,
};
return webpackConfig(config, args);
Expand Down
1 change: 0 additions & 1 deletion src/printer/components/cameras.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,6 @@ const createCameraSettingsModal = (cameraId, resolve) => {
inputTriggerScheme.value = translateTriggerScheme(data.trigger_scheme);

setVisible(inputFocus.parentNode, hasFocus);
console.log(`DEBUG: has focus (${hasFocus})`, data)
if (hasFocus) {
inputFocus.value = Math.round(data.focus * 100);
}
Expand Down
3 changes: 3 additions & 0 deletions src/printer/components/dataFormat.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@ const str_false = translate("prop.false");
* @param {any} value
*/
const formatData = (format, value) => {
return fdmFormatData(format, value);
/*
if (process.env.PRINTER_TYPE === "sla") {
return slaFormatData(format, value);
} else {
return fdmFormatData(format, value);
}
*/
};

/**
Expand Down
3 changes: 3 additions & 0 deletions src/printer/components/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ const updateFiles = (opts = {}) => {
headers: { "If-None-Match": lastETag },
})
.then((result) => {
if (result.code === 304) {
return
}
if (url !== getCurrentApiPath()) {
// user navigated to other folder
return;
Expand Down
38 changes: 16 additions & 22 deletions src/printer/components/job.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,13 @@ function updateComponent(context, isFilePreview) {
function setupRefill(stateText) {
const preview = document.getElementById("preview-wrapper")
const refill = document.getElementById("refill-wrapper")
if (stateText == "Feed me" || stateText == "Pour in resin") {
if (stateText == "Pour in resin") {
if ([LinkState.REFILL, LinkState.POUR_IN_RESIN].includes(stateText)) {
if (stateText == LinkState.POUR_IN_RESIN) {
translate("msg.sla-pour-resin", { query: "#sla-refill-text" });
}
setHidden(preview);
setVisible(refill);
}
else {
} else {
setHidden(refill);
setVisible(preview);
}
Expand Down Expand Up @@ -173,18 +172,13 @@ function setupButtons(state, dataSource, jobId) {
setupDownloadButton(state, file, jobId);

if (!!jobId) {
if (process.env.PRINTER_TYPE === "fdm") {
setupPauseButton(state, jobId, "#job #pause");
setupResumeButton(state, jobId);
}
setupPauseButton(state, jobId, "#job #pause");
setupResumeButton(state, jobId);

if (process.env.PRINTER_TYPE === "sla") {
const jobFile = jobResult?.job?.file;
if (jobFile)
setupExposureButton(state, jobFile, changeExposureTimesQuestion);
setupPauseButton(state, jobId, "#job #refill");
setupSlaResumeButton(state, "#job #continue");
setupSlaResumeButton(state, "#job #back");
setupExposureButton(state, file, changeExposureTimesQuestion);
// setupSlaResumeButton(state, "#job #resume");
//setupSlaResumeButton(state, "#job #back");
}
}
}
Expand Down Expand Up @@ -252,30 +246,30 @@ function setupPauseButton(state, jobId, selector) {

function setupResumeButton(state, jobId) {
const btn = document.querySelector("#job #resume");
const isPaused = state === LinkState.PAUSED;
const isPaused = [LinkState.PAUSED, LinkState.POUR_IN_RESIN].includes(state);
setVisible(btn, isPaused);
setEnabled(btn, !pendingCommand && isPaused);

if (btn) {
btn.onclick = () => {
setEnabled(btn, false);
pendingCommand = {code: "resume", state: state};
resumeJob(jobId)
.catch(() => pendingCommand = null);
const command = (state !== LinkState.REFILL) ? resumeJob(jobId) : resinRefill();
command.catch(() => pendingCommand = null);
}
}
}

function setupSlaResumeButton(state, selector) {
const btn = document.querySelector(selector);
if (selector.includes("#back"))
setVisible(btn, state.flags.paused && state.text === "Feed me");
setVisible(btn, state === LinkState.REFILL);
else
setVisible(btn, state.flags.paused);
setVisible(btn, state === LinkState.PAUSED);


if (btn) {
if (state.text == "Feed me" && !selector.includes("#back")) {
if (state == LinkState.REFILL && !selector.includes("#back")) {
btn.onclick = resinRefill;
} else {
btn.onclick = resumeJob;
Expand Down Expand Up @@ -324,8 +318,8 @@ function setupDownloadButton(state, file, jobId) {
function setupExposureButton(state, jobFile, changeExposureTimesQuestion) {
const btn = document.querySelector("#job #exposure");
if (btn) {
setVisible(btn, state.text === "Pour in resin" || state.text === "Printing");
setEnabled(btn, state.flags.operational);
setVisible(btn, [LinkState.POUR_IN_RESIN, LinkState.PRINTING].includes(state));
setEnabled(btn, [...OperationalStates, LinkState.POUR_IN_RESIN].includes(state));
btn.onclick = () => changeExposureTimesQuestion(jobFile);
}
}
Expand Down
34 changes: 28 additions & 6 deletions src/printer/fdm/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ export class Context {
return getJson("/api/connection", { method: "GET" })
.then(res => {
this.link.connect.settings = {
hostname: res.data.connect.hostname,
port: res.data.connect.port,
tls: res.data.connect.tls,
hostname: res.data.connect?.hostname,
port: res.data.connect?.port,
tls: res.data.connect?.tls,
};
this.link.connect.registration = res.data.connect.registration;
this.link.connect.registration = res.data.connect?.registration;
this.link.printer.settings = {
port: res.data.current.port,
baudrate: res.data.current.baudrate,
port: res.data.current?.port,
baudrate: res.data.current?.baudrate,
};
});
}
Expand Down Expand Up @@ -105,12 +105,14 @@ export class Context {
hostname: printer.hostname,
port: printer.port,
};
this.fileExtensions = printer.project_extensions ?? process.env["FILE_EXTENSIONS"].split(",")
}

updateTelemetry(printer) {
this.state = LinkState.fromApi(printer.state.toUpperCase());
this.telemetry = {
temperature: {
// fdm
nozzle: {
current: printer.temp_nozzle,
target: printer.target_nozzle,
Expand All @@ -119,6 +121,16 @@ export class Context {
current: printer.temp_bed,
target: printer.target_bed,
},
// sla
ambient: {
current: printer.temp_ambient,
},
cpu: {
current: printer.temp_cpu,
},
uvLED: {
current: printer.temp_uv_led,
},
},
axis: {
x: printer.axis_x,
Expand All @@ -128,9 +140,15 @@ export class Context {
flow: printer.flow,
speed: printer.speed,
fan: {
// fdm
hotend: printer.fan_hotend,
print: printer.fan_print,
// sla
blower: printer.fan_blower,
rear: printer.fan_rear,
uvLED: printer.fan_uv_led,
},
coverClosed: printer.cover_closed,
};
// hide status if connect is not supported
this.link.connect.message = printer.status_connect?.message ?? "";
Expand Down Expand Up @@ -344,6 +362,10 @@ const mapFile = (data) => ({
filamentType: data.meta?.filament_type,
layerHeight: data.meta?.layer_height,
estimatedPrintTime: data.meta?.estimated_print_time,
exposureTime: data.meta?.exposure_time,
exposureTimeCalibration: data.meta?.exposure_time_calibration,
exposureTimeFirst: data.meta?.exposure_time_first,
exposureUserProfile: data.meta?.exposure_user_profile,
},
readOnly: data.read_only || data.ro
});
7 changes: 5 additions & 2 deletions src/printer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
// SPDX-License-Identifier: GPL-3.0-or-later

const printer = (() => {
if (process.env.PRINTER_TYPE === "sla") return require("./sla");
if (process.env.PRINTER_TYPE === "fdm") return require("./fdm");
/*
if (process.env.PRINTER_TYPE === "sla") return require("./sla");
if (process.env.PRINTER_TYPE === "fdm") return require("./fdm");
*/
return require("./fdm")
})().default;

export default printer;
8 changes: 4 additions & 4 deletions src/printer/sla/exposure.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ const setUpElements = (file, elements, div) => {
const template = document.getElementById("exposure-item").content;
div.className = "modal-exposure";
for (let expo in config) {
if (expo in file) {
if (expo in file.meta && file.meta[expo] !== undefined) {
const elm = document.importNode(template, true);
var minus = elm.getElementById("minus");
var plus = elm.getElementById("plus");
elm.getElementById("desc").innerHTML = config[expo].text;
const value = elm.getElementById("value");
value.dataset.value = file[expo].toFixed(0);
value.dataset.value = file.meta[expo].toFixed(0);
if (expo == "exposureUserProfile") {
switch(parseInt(file[expo])) {
switch(parseInt(file.meta[expo])) {
case 0:
value.innerHTML = translate("exp-times.faster");
break;
Expand All @@ -109,7 +109,7 @@ const setUpElements = (file, elements, div) => {
plus = elm.getElementById("next");
minus.style.display = "block";
plus.style.display = "block";
} else value.innerHTML = (file[expo] / 1000).toFixed(1);
} else value.innerHTML = (file.meta[expo] / 1000).toFixed(1);
const [min, max] = config[expo].limit;
const setMinus = setValue(expo, value, min, max, -config[expo].step);
minus.onclick = setMinus;
Expand Down
10 changes: 9 additions & 1 deletion src/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export const LinkState = {
IDLE: "IDLE",
READY: "READY",
BUSY: "BUSY",
POUR_IN_RESIN: "POUR IN RESIN",
REFILL: "FEED ME",
PRINTING: "PRINTING",
PAUSED: "PAUSED",
FINISHED: "FINISHED",
Expand All @@ -23,6 +25,9 @@ export const LinkState = {
case "STOPPED": return LinkState.STOPPED;
case "ERROR": return LinkState.ERROR;
case "ATTENTION": return LinkState.ATTENTION;
// sla specific
case "POUR IN RESIN": return LinkState.POUR_IN_RESIN;
case "FEED ME": return LinkState.REFILL;
default:
console.error(`Unsupported state: ${linkState}`);
return LinkState.UNKNOWN;
Expand All @@ -33,12 +38,13 @@ export const LinkState = {
export const OperationalStates = [
LinkState.IDLE,
LinkState.READY,
LinkState.FINISHED
LinkState.FINISHED,
];

export const JobPendingStates = [
LinkState.PRINTING,
LinkState.PAUSED,
LinkState.POUR_IN_RESIN,
];

export const translateState = (state) => {
Expand All @@ -52,6 +58,8 @@ export const translateState = (state) => {
case LinkState.STOPPED: return translate("prop.st-stopped");
case LinkState.ERROR: return translate("prop.st-error");
case LinkState.ATTENTION: return translate("prop.st-attention");
case LinkState.POUR_IN_RESIN: return translate("prop.st-pour-resin");
case LinkState.REFILL: return translate("prop.st-feedme");
default:
console.error(`Unsupported state: ${state}`);
return translate("prop.st-unknown");
Expand Down
12 changes: 6 additions & 6 deletions templates/components/telemetry.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
{% if env.PRINTER_TYPE == "sla" %}
{%
set telemetry_list = [
{'text': 'CPU temperature', label: 'prop.temp-cpu', 'icon': 'temperature_color.svg', 'format': 'temp', "locations": ["temperature.bed.actual"], enabled: true },
{'text': 'UV LED temperature', label: 'prop.temp-led', 'icon': 'temperature_color.svg', 'format': 'temp', "locations": ["temperature.tool0.actual"], enabled: true },
{'text': 'ambient temperature', label: 'prop.temp-amb', 'icon': 'temperature_color.svg', 'format': 'temp', "locations": ["temperature.chamber.actual"], enabled: true },
{'text': 'UV LED fan', label: 'prop.fan-led', 'icon': 'fan_color.svg', 'format': 'fan', "location": "telemetry.fanUvLed", enabled: true },
{'text': 'blower fan', label: 'prop.fan-blower', 'icon': 'fan_color.svg', 'format': 'fan', "location": "telemetry.fanBlower", enabled: true },
{'text': 'rear fan', label: 'prop.fan-rear', 'icon': 'fan_color.svg', 'format': 'fan', "location": "telemetry.fanRear", enabled: true },
{'text': 'CPU temperature', label: 'prop.temp-cpu', 'icon': 'temperature_color.svg', 'format': 'temp', "locations": ["telemetry.temperature.cpu.current"], enabled: true },
{'text': 'UV LED temperature', label: 'prop.temp-led', 'icon': 'temperature_color.svg', 'format': 'temp', "locations": ["telemetry.temperature.uvLED.current"], enabled: true },
{'text': 'ambient temperature', label: 'prop.temp-amb', 'icon': 'temperature_color.svg', 'format': 'temp', "locations": ["telemetry.temperature.ambient.current"], enabled: true },
{'text': 'UV LED fan', label: 'prop.fan-led', 'icon': 'fan_color.svg', 'format': 'fan', "location": "telemetry.fan.uvLED", enabled: true },
{'text': 'blower fan', label: 'prop.fan-blower', 'icon': 'fan_color.svg', 'format': 'fan', "location": "telemetry.fan.blower", enabled: true },
{'text': 'rear fan', label: 'prop.fan-rear', 'icon': 'fan_color.svg', 'format': 'fan', "location": "telemetry.fan.rear", enabled: true },
{'text': 'cover state', label: 'prop.cover', 'icon': 'cover_color.svg', 'format': 'cover', "location": "telemetry.coverClosed", enabled: true }
]
%}
Expand Down

0 comments on commit b933533

Please sign in to comment.