mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-12-23 03:23:48 +01:00
concat doodle3d printer and the doodle3d wifi box into one target
This commit is contained in:
parent
de2acfe6be
commit
56929c6af7
@ -152,7 +152,6 @@ export async function slice(target, name, mesh, settings, updateProgress) {
|
|||||||
steps = 1;
|
steps = 1;
|
||||||
break;
|
break;
|
||||||
case 'WIFI':
|
case 'WIFI':
|
||||||
case 'DOODLE3D-WIFI-BOX':
|
|
||||||
if (settings.printer === 'doodle3d_printer') {
|
if (settings.printer === 'doodle3d_printer') {
|
||||||
const { state } = await getMalyanStatus(settings.ip);
|
const { state } = await getMalyanStatus(settings.ip);
|
||||||
if (state !== 'idle') throw { message: 'printer must be idle before starting a print', code: 1 };
|
if (state !== 'idle') throw { message: 'printer must be idle before starting a print', code: 1 };
|
||||||
@ -187,54 +186,54 @@ export async function slice(target, name, mesh, settings, updateProgress) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case 'WIFI': {
|
case 'WIFI': {
|
||||||
const body = new FormData();
|
if (settings.printer === 'doodle3d_printer') {
|
||||||
const file = new File([gcode], 'doodle.gcode', { type: 'plain/text' });
|
const body = new FormData();
|
||||||
body.append('file', file);
|
const file = new File([gcode], 'doodle.gcode', { type: 'plain/text' });
|
||||||
|
body.append('file', file);
|
||||||
|
|
||||||
// await fetchProgress(`http://${settings.ip}/set?code=M563 S4`, { method: 'GET' });
|
// await fetchProgress(`http://${settings.ip}/set?code=M563 S4`, { method: 'GET' });
|
||||||
await fetchProgress(`http://${settings.ip}/upload`, { method: 'POST', body }, (progress) => {
|
await fetchProgress(`http://${settings.ip}/upload`, { method: 'POST', body }, (progress) => {
|
||||||
updateProgress({
|
updateProgress({
|
||||||
action: 'Uploading',
|
action: 'Uploading',
|
||||||
percentage: currentStep / steps + progress.loaded / progress.total / steps
|
percentage: currentStep / steps + progress.loaded / progress.total / steps
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
await fetchProgress(`http://${settings.ip}/set?code=M566 ${name}.gcode`, { method: 'GET' });
|
||||||
currentStep ++;
|
await fetchProgress(`http://${settings.ip}/set?code=M565`, { method: 'GET' });
|
||||||
await fetchProgress(`http://${settings.ip}/set?code=M566 ${name}.gcode`, { method: 'GET' });
|
|
||||||
await fetchProgress(`http://${settings.ip}/set?code=M565`, { method: 'GET' });
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'DOODLE3D-WIFI-BOX': {
|
currentStep ++;
|
||||||
// upload G-code file to AWS S3
|
} else {
|
||||||
const { data: { reservation, id } } = await fetch(`${GCODE_SERVER_URL}/upload`, { method: 'POST' })
|
// upload G-code file to AWS S3
|
||||||
.then(response => response.json());
|
const { data: { reservation, id } } = await fetch(`${GCODE_SERVER_URL}/upload`, { method: 'POST' })
|
||||||
|
.then(response => response.json());
|
||||||
|
|
||||||
const body = new FormData();
|
const body = new FormData();
|
||||||
const { fields } = reservation;
|
const { fields } = reservation;
|
||||||
for (const key in fields) {
|
for (const key in fields) {
|
||||||
body.append(key, fields[key]);
|
body.append(key, fields[key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const file = `;${JSON.stringify({
|
||||||
|
...settings,
|
||||||
|
name: `${name}.gcode`,
|
||||||
|
printer: { type: settings.printers, title: printerSettings[settings.printer].title },
|
||||||
|
material: { type: settings.material, title: materialSettings[settings.material].title },
|
||||||
|
quality: { type: settings.quality, title: qualitySettings[settings.quality].title }
|
||||||
|
}).trim()}\n${gcode}`;
|
||||||
|
body.append('file', file);
|
||||||
|
|
||||||
|
await fetchProgress(reservation.url, { method: 'POST', body }, (progress) => {
|
||||||
|
updateProgress({
|
||||||
|
action: 'Uploading',
|
||||||
|
percentage: currentStep / steps + progress.loaded / progress.total / steps
|
||||||
|
});
|
||||||
|
});
|
||||||
|
currentStep ++;
|
||||||
|
|
||||||
|
const url = `${CONNECT_URL}?uuid=${id}`;
|
||||||
|
const popup = window.open(url, '_blank');
|
||||||
|
if (!popup) throw { message: 'popup was blocked by browser', code: 3, url };
|
||||||
}
|
}
|
||||||
|
|
||||||
const file = `;${JSON.stringify({
|
|
||||||
...settings,
|
|
||||||
name: `${name}.gcode`,
|
|
||||||
printer: { type: settings.printers, title: printerSettings[settings.printer].title },
|
|
||||||
material: { type: settings.material, title: materialSettings[settings.material].title },
|
|
||||||
quality: { type: settings.quality, title: qualitySettings[settings.quality].title }
|
|
||||||
}).trim()}\n${gcode}`;
|
|
||||||
body.append('file', file);
|
|
||||||
|
|
||||||
await fetchProgress(reservation.url, { method: 'POST', body }, (progress) => {
|
|
||||||
updateProgress({
|
|
||||||
action: 'Uploading',
|
|
||||||
percentage: currentStep / steps + progress.loaded / progress.total / steps
|
|
||||||
});
|
|
||||||
});
|
|
||||||
currentStep ++;
|
|
||||||
|
|
||||||
const url = `${CONNECT_URL}?uuid=${id}`;
|
|
||||||
const popup = window.open(url, '_blank');
|
|
||||||
if (!popup) throw { message: 'popup was blocked by browser', code: 3, url };
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user