Command handeling
This commit is contained in:
@@ -36,6 +36,14 @@ class FluidNCClient extends EventEmitter {
|
||||
this.ws.on("error", (err) => {
|
||||
console.log("[FluidNC] WS Error:", err.message);
|
||||
});
|
||||
|
||||
this.ws.on("unexpected-response", (req, res) => {
|
||||
console.log("[FluidNC] WS Unexpected Response:", res.statusCode, res.statusMessage);
|
||||
});
|
||||
|
||||
this.ws.on("disconnect", () => {
|
||||
console.log("[FluidNC] WS Disconnected");
|
||||
});
|
||||
}
|
||||
|
||||
sendLine(cmd) {
|
||||
@@ -48,8 +56,12 @@ class FluidNCClient extends EventEmitter {
|
||||
this.sendLine("?");
|
||||
}
|
||||
|
||||
jog(axis, value) {
|
||||
const cmd = `$J=G91 ${axis}${value} F2000`;
|
||||
jog(relative, axis, value) {
|
||||
// $J= um den Befehl als Jog zu kennzeichnen
|
||||
// G91 für relative Bewegungen (G90 für absolute)
|
||||
// G1 Linearbewegung
|
||||
const cmd = relative? `$J=G91 G1 ${axis}${value} F2000\r\n`: `$J=G90 G1 ${axis}${value} F2000\r\n`;
|
||||
console.log("[FluidNC] Jog Command:", cmd);
|
||||
this.sendLine(cmd);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ wss.on("connection", (ws) => {
|
||||
|
||||
console.log("Message from WSS: " + msg);
|
||||
if (data.type === "jog") {
|
||||
fluid.jog(data.axis, data.value);
|
||||
fluid.jog(data.relative, data.axis, data.value);
|
||||
}
|
||||
|
||||
if (data.type === "gcode") {
|
||||
|
||||
Reference in New Issue
Block a user