add work/pool url options in engine constructor

This commit is contained in:
Stewart Allen 2025-07-13 14:20:16 -04:00
commit cb98a056f8
2 changed files with 13 additions and 8 deletions

View file

@ -10,7 +10,7 @@ import { load } from '../../load/file.js';
import { newWidget } from '../core/widget.js'; import { newWidget } from '../core/widget.js';
class Engine { class Engine {
constructor() { constructor({ workURL, poolURL } = {}) {
this.widget = newWidget(); this.widget = newWidget();
this.settings = { this.settings = {
mode: "FDM", mode: "FDM",
@ -22,7 +22,13 @@ class Engine {
widget: { [this.widget.id]: {} } widget: { [this.widget.id]: {} }
}; };
this.listener = () => { }; this.listener = () => { };
client.start(); try {
client.setWorkPath(workURL);
client.setPoolPath(poolURL);
client.restart();
} catch (error) {
console.log({ error });
}
} }
load(url) { load(url) {
@ -190,7 +196,7 @@ class Engine {
} }
export function newEngine() { export function newEngine() {
return new Engine(); return new Engine(...arguments);
} }
export { Engine }; export { Engine };

View file

@ -88,8 +88,7 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.12/ace.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.12/ace.js"></script>
<!-- <script src="/lib/kiri-run/engine.js" type="module"></script> --> <!-- <script src="/lib/kiri-run/engine.js" type="module"></script> -->
<script type="module"> <script type="module">
import { Engine } from '/lib/kiri-run/engine.js'; import { Engine } from '/lib/kiri/run/engine.js';
const engine = new Engine();
let edit, saveit = ""; let edit, saveit = "";
function $(id) { return document.getElementById(id) } function $(id) { return document.getElementById(id) }
function onload() { function onload() {
@ -127,7 +126,7 @@
eval(`(function(){${code}})()`); eval(`(function(){${code}})()`);
} }
function demoFDM() { function demoFDM() {
engine new Engine()
.setListener(display_message) .setListener(display_message)
.load("/obj/cube.stl") .load("/obj/cube.stl")
.then(eng => eng.setProcess({ .then(eng => eng.setProcess({
@ -144,7 +143,7 @@
} }
function demoCAM(){ function demoCAM(){
engine new Engine()
.setListener(display_message) .setListener(display_message)
.load("/obj/cube.stl") .load("/obj/cube.stl")
// should to call widget.setTopZ here ideally // should to call widget.setTopZ here ideally
@ -244,7 +243,7 @@
} }
function demoLASER(){ function demoLASER(){
engine new Engine()
.setListener(display_message) .setListener(display_message)
.load("/obj/cube.stl") .load("/obj/cube.stl")
// should to call widget.setTopZ here ideally // should to call widget.setTopZ here ideally