Horrible G91 G90 mistake

This commit is contained in:
ChK
2026-04-23 20:22:10 +02:00
parent d801e19ad0
commit a16eb53aeb
7 changed files with 1678 additions and 322 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -12648,3 +12648,237 @@
2026-04-21T19:36:02.211Z ::ffff:172.21.0.5: Ping
2026-04-21T19:36:07.208Z ::ffff:172.21.0.5: Ping
2026-04-21T19:36:12.051Z ::ffff:172.21.0.5: Ping
2026-04-23T17:25:21.535Z ::ffff:172.21.0.6: Ping
2026-04-23T17:25:26.653Z ::ffff:172.21.0.6: Ping
2026-04-23T17:25:31.536Z ::ffff:172.21.0.6: Ping
2026-04-23T17:25:36.534Z ::ffff:172.21.0.6: Ping
2026-04-23T17:25:41.545Z ::ffff:172.21.0.6: Ping
2026-04-23T17:25:46.534Z ::ffff:172.21.0.6: Ping
2026-04-23T17:25:52.065Z ::ffff:172.21.0.6: Ping
2026-04-23T17:25:57.073Z ::ffff:172.21.0.6: Ping
2026-04-23T17:26:01.535Z ::ffff:172.21.0.6: Ping
2026-04-23T17:28:33.538Z ::ffff:172.21.0.6: Ping
2026-04-23T17:28:38.550Z ::ffff:172.21.0.6: Ping
2026-04-23T17:28:43.466Z ::ffff:172.21.0.6: Ping
2026-04-23T17:28:48.456Z ::ffff:172.21.0.6: Ping
2026-04-23T17:28:53.501Z ::ffff:172.21.0.6: Ping
2026-04-23T17:28:58.519Z ::ffff:172.21.0.6: Ping
2026-04-23T17:29:04.053Z ::ffff:172.21.0.6: Ping
2026-04-23T17:29:11.818Z ::ffff:172.21.0.6: Ping
2026-04-23T17:30:15.932Z ::ffff:172.21.0.6: Ping
2026-04-23T17:30:20.951Z ::ffff:172.21.0.6: Ping
2026-04-23T17:30:25.969Z ::ffff:172.21.0.6: Ping
2026-04-23T17:30:30.883Z ::ffff:172.21.0.6: Ping
2026-04-23T17:30:35.901Z ::ffff:172.21.0.6: Ping
2026-04-23T17:30:40.919Z ::ffff:172.21.0.6: Ping
2026-04-23T17:30:45.860Z ::ffff:172.21.0.6: Ping
2026-04-23T17:34:42.993Z ::ffff:172.21.0.6: Ping
2026-04-23T17:34:48.011Z ::ffff:172.21.0.6: Ping
2026-04-23T17:34:53.035Z ::ffff:172.21.0.6: Ping
2026-04-23T17:34:58.051Z ::ffff:172.21.0.6: Ping
2026-04-23T17:35:03.053Z ::ffff:172.21.0.6: Ping
2026-04-23T17:35:08.043Z ::ffff:172.21.0.6: Ping
2026-04-23T17:35:13.051Z ::ffff:172.21.0.6: Ping
2026-04-23T17:35:17.955Z ::ffff:172.21.0.6: Ping
2026-04-23T17:35:22.955Z ::ffff:172.21.0.6: Ping
2026-04-23T17:35:27.954Z ::ffff:172.21.0.6: Ping
2026-04-23T17:35:33.048Z ::ffff:172.21.0.6: Ping
2026-04-23T17:38:33.916Z ::ffff:172.21.0.6: Ping
2026-04-23T17:38:33.916Z ::ffff:172.21.0.6: Ping
2026-04-23T17:38:33.916Z ::ffff:172.21.0.6: Ping
2026-04-23T17:38:33.916Z ::ffff:172.21.0.6: Ping
2026-04-23T17:38:33.916Z ::ffff:172.21.0.6: Ping
2026-04-23T17:38:33.916Z ::ffff:172.21.0.6: Ping
2026-04-23T17:38:33.917Z ::ffff:172.21.0.6: Ping
2026-04-23T17:38:33.917Z ::ffff:172.21.0.6: Ping
2026-04-23T17:38:33.917Z ::ffff:172.21.0.6: Ping
2026-04-23T17:38:33.917Z ::ffff:172.21.0.6: Ping
2026-04-23T17:38:33.917Z ::ffff:172.21.0.6: Ping
2026-04-23T17:38:33.917Z ::ffff:172.21.0.6: Ping
2026-04-23T17:38:33.917Z ::ffff:172.21.0.6: Ping
2026-04-23T17:38:33.917Z ::ffff:172.21.0.6: Ping
2026-04-23T17:38:33.917Z ::ffff:172.21.0.6: Ping
2026-04-23T17:38:33.917Z ::ffff:172.21.0.6: Ping
2026-04-23T17:38:33.918Z ::ffff:172.21.0.6: Ping
2026-04-23T17:38:36.120Z ::ffff:172.21.0.6: Ping
2026-04-23T17:38:41.060Z ::ffff:172.21.0.6: Ping
2026-04-23T17:38:46.073Z ::ffff:172.21.0.6: Ping
2026-04-23T17:38:56.070Z ::ffff:172.21.0.6: Ping
2026-04-23T17:39:21.810Z ::ffff:172.21.0.6: Ping
2026-04-23T17:39:32.771Z ::ffff:172.21.0.6: Ping
2026-04-23T17:39:37.742Z ::ffff:172.21.0.6: Ping
2026-04-23T17:39:45.369Z ::ffff:172.21.0.6: Ping
2026-04-23T17:41:02.095Z ::ffff:172.21.0.6: Ping
2026-04-23T17:41:12.285Z ::ffff:172.21.0.6: Ping
2026-04-23T17:41:17.223Z ::ffff:172.21.0.6: Ping
2026-04-23T17:41:22.215Z ::ffff:172.21.0.6: Ping
2026-04-23T17:41:27.220Z ::ffff:172.21.0.6: Ping
2026-04-23T17:41:37.151Z ::ffff:172.21.0.6: Ping
2026-04-23T17:41:42.136Z ::ffff:172.21.0.6: Ping
2026-04-23T17:42:21.548Z ::ffff:172.21.0.6: Ping
2026-04-23T17:42:27.070Z ::ffff:172.21.0.6: Ping
2026-04-23T17:42:32.090Z ::ffff:172.21.0.6: Ping
2026-04-23T17:42:37.326Z ::ffff:172.21.0.6: Ping
2026-04-23T17:44:58.314Z ::ffff:172.21.0.6: Ping
2026-04-23T17:45:03.307Z ::ffff:172.21.0.6: Ping
2026-04-23T17:45:08.313Z ::ffff:172.21.0.6: Ping
2026-04-23T17:45:13.302Z ::ffff:172.21.0.6: Ping
2026-04-23T17:45:19.027Z ::ffff:172.21.0.6: Ping
2026-04-23T17:57:21.908Z ::ffff:172.21.0.6: Ping
2026-04-23T17:57:21.999Z ::ffff:172.21.0.6: Ping
2026-04-23T17:57:31.992Z ::ffff:172.21.0.6: Ping
2026-04-23T17:57:37.004Z ::ffff:172.21.0.6: Ping
2026-04-23T17:57:46.011Z ::ffff:172.21.0.6: Ping
2026-04-23T17:57:51.897Z ::ffff:172.21.0.6: Ping
2026-04-23T17:58:01.027Z ::ffff:172.21.0.6: Ping
2026-04-23T17:58:06.015Z ::ffff:172.21.0.6: Ping
2026-04-23T17:58:11.058Z ::ffff:172.21.0.6: Ping
2026-04-23T17:58:15.998Z ::ffff:172.21.0.6: Ping
2026-04-23T17:58:19.561Z ::ffff:172.21.0.6: Ping
2026-04-23T17:58:20.995Z ::ffff:172.21.0.6: Ping
2026-04-23T17:58:24.573Z ::ffff:172.21.0.6: Ping
2026-04-23T17:58:25.993Z ::ffff:172.21.0.6: Ping
2026-04-23T17:58:29.585Z ::ffff:172.21.0.6: Ping
2026-04-23T17:58:34.563Z ::ffff:172.21.0.6: Ping
2026-04-23T17:58:39.625Z ::ffff:172.21.0.6: Ping
2026-04-23T17:58:44.643Z ::ffff:172.21.0.6: Ping
2026-04-23T17:58:49.660Z ::ffff:172.21.0.6: Ping
2026-04-23T17:58:54.560Z ::ffff:172.21.0.6: Ping
2026-04-23T17:59:00.006Z ::ffff:172.21.0.6: Ping
2026-04-23T17:59:05.019Z ::ffff:172.21.0.6: Ping
2026-04-23T17:59:06.047Z ::ffff:172.21.0.6: Ping
2026-04-23T17:59:10.037Z ::ffff:172.21.0.6: Ping
2026-04-23T17:59:15.051Z ::ffff:172.21.0.6: Ping
2026-04-23T17:59:20.021Z ::ffff:172.21.0.6: Ping
2026-04-23T17:59:24.994Z ::ffff:172.21.0.6: Ping
2026-04-23T18:02:26.003Z ::ffff:172.21.0.6: Ping
2026-04-23T18:02:31.045Z ::ffff:172.21.0.6: Ping
2026-04-23T18:02:35.998Z ::ffff:172.21.0.6: Ping
2026-04-23T18:02:38.942Z ::ffff:172.21.0.6: Ping
2026-04-23T18:02:40.998Z ::ffff:172.21.0.6: Ping
2026-04-23T18:02:44.050Z ::ffff:172.21.0.6: Ping
2026-04-23T18:02:45.987Z ::ffff:172.21.0.6: Ping
2026-04-23T18:02:49.082Z ::ffff:172.21.0.6: Ping
2026-04-23T18:02:51.015Z ::ffff:172.21.0.6: Ping
2026-04-23T18:02:53.945Z ::ffff:172.21.0.6: Ping
2026-04-23T18:02:56.030Z ::ffff:172.21.0.6: Ping
2026-04-23T18:02:58.947Z ::ffff:172.21.0.6: Ping
2026-04-23T18:03:05.989Z ::ffff:172.21.0.6: Ping
2026-04-23T18:03:39.036Z ::ffff:172.21.0.6: Ping
2026-04-23T18:03:44.055Z ::ffff:172.21.0.6: Ping
2026-04-23T18:03:49.076Z ::ffff:172.21.0.6: Ping
2026-04-23T18:03:54.091Z ::ffff:172.21.0.6: Ping
2026-04-23T18:03:58.999Z ::ffff:172.21.0.6: Ping
2026-04-23T18:04:03.981Z ::ffff:172.21.0.6: Ping
2026-04-23T18:04:05.982Z ::ffff:172.21.0.6: Ping
2026-04-23T18:04:09.039Z ::ffff:172.21.0.6: Ping
2026-04-23T18:04:19.001Z ::ffff:172.21.0.6: Ping
2026-04-23T18:04:24.093Z ::ffff:172.21.0.6: Ping
2026-04-23T18:04:28.985Z ::ffff:172.21.0.6: Ping
2026-04-23T18:04:34.027Z ::ffff:172.21.0.6: Ping
2026-04-23T18:05:05.985Z ::ffff:172.21.0.6: Ping
2026-04-23T18:05:05.986Z ::ffff:172.21.0.6: Ping
2026-04-23T18:05:31.023Z ::ffff:172.21.0.6: Ping
2026-04-23T18:05:53.056Z ::ffff:172.21.0.6: Ping
2026-04-23T18:05:54.901Z ::ffff:172.21.0.6: Ping
2026-04-23T18:05:55.125Z ::ffff:172.21.0.6: Ping
2026-04-23T18:05:59.978Z ::ffff:172.21.0.6: Ping
2026-04-23T18:06:00.993Z ::ffff:172.21.0.6: Ping
2026-04-23T18:06:05.020Z ::ffff:172.21.0.6: Ping
2026-04-23T18:06:05.034Z ::ffff:172.21.0.6: Ping
2026-04-23T18:06:10.067Z ::ffff:172.21.0.6: Ping
2026-04-23T18:06:10.074Z ::ffff:172.21.0.6: Ping
2026-04-23T18:06:15.094Z ::ffff:172.21.0.6: Ping
2026-04-23T18:06:16.016Z ::ffff:172.21.0.6: Ping
2026-04-23T18:06:20.008Z ::ffff:172.21.0.6: Ping
2026-04-23T18:06:20.988Z ::ffff:172.21.0.6: Ping
2026-04-23T18:06:25.026Z ::ffff:172.21.0.6: Ping
2026-04-23T18:06:26.051Z ::ffff:172.21.0.6: Ping
2026-04-23T18:06:30.043Z ::ffff:172.21.0.6: Ping
2026-04-23T18:06:31.067Z ::ffff:172.21.0.6: Ping
2026-04-23T18:06:35.060Z ::ffff:172.21.0.6: Ping
2026-04-23T18:06:35.988Z ::ffff:172.21.0.6: Ping
2026-04-23T18:06:39.989Z ::ffff:172.21.0.6: Ping
2026-04-23T18:06:40.977Z ::ffff:172.21.0.6: Ping
2026-04-23T18:06:45.097Z ::ffff:172.21.0.6: Ping
2026-04-23T18:06:45.982Z ::ffff:172.21.0.6: Ping
2026-04-23T18:06:50.010Z ::ffff:172.21.0.6: Ping
2026-04-23T18:06:50.982Z ::ffff:172.21.0.6: Ping
2026-04-23T18:06:54.978Z ::ffff:172.21.0.6: Ping
2026-04-23T18:06:55.983Z ::ffff:172.21.0.6: Ping
2026-04-23T18:07:00.982Z ::ffff:172.21.0.6: Ping
2026-04-23T18:07:05.984Z ::ffff:172.21.0.6: Ping
2026-04-23T18:07:05.988Z ::ffff:172.21.0.6: Ping
2026-04-23T18:08:06.060Z ::ffff:172.21.0.6: Ping
2026-04-23T18:08:06.061Z ::ffff:172.21.0.6: Ping
2026-04-23T18:09:05.983Z ::ffff:172.21.0.6: Ping
2026-04-23T18:09:05.983Z ::ffff:172.21.0.6: Ping
2026-04-23T18:10:05.983Z ::ffff:172.21.0.6: Ping
2026-04-23T18:10:05.984Z ::ffff:172.21.0.6: Ping
2026-04-23T18:11:05.976Z ::ffff:172.21.0.6: Ping
2026-04-23T18:11:05.978Z ::ffff:172.21.0.6: Ping
2026-04-23T18:12:05.975Z ::ffff:172.21.0.6: Ping
2026-04-23T18:12:05.976Z ::ffff:172.21.0.6: Ping
2026-04-23T18:13:05.985Z ::ffff:172.21.0.6: Ping
2026-04-23T18:13:05.986Z ::ffff:172.21.0.6: Ping
2026-04-23T18:14:05.971Z ::ffff:172.21.0.6: Ping
2026-04-23T18:14:05.972Z ::ffff:172.21.0.6: Ping
2026-04-23T18:15:05.971Z ::ffff:172.21.0.6: Ping
2026-04-23T18:15:05.972Z ::ffff:172.21.0.6: Ping
2026-04-23T18:15:32.713Z ::ffff:172.21.0.6: Ping
2026-04-23T18:15:49.046Z ::ffff:172.21.0.6: Ping
2026-04-23T18:15:54.057Z ::ffff:172.21.0.6: Ping
2026-04-23T18:15:59.066Z ::ffff:172.21.0.6: Ping
2026-04-23T18:16:03.991Z ::ffff:172.21.0.6: Ping
2026-04-23T18:16:08.972Z ::ffff:172.21.0.6: Ping
2026-04-23T18:16:13.979Z ::ffff:172.21.0.6: Ping
2026-04-23T18:17:05.978Z ::ffff:172.21.0.6: Ping
2026-04-23T18:18:05.973Z ::ffff:172.21.0.6: Ping
2026-04-23T18:18:20.390Z ::ffff:172.21.0.6: Ping
2026-04-23T18:18:24.029Z ::ffff:172.21.0.6: Ping
2026-04-23T18:18:28.977Z ::ffff:172.21.0.6: Ping
2026-04-23T18:18:34.004Z ::ffff:172.21.0.6: Ping
2026-04-23T18:18:36.080Z ::ffff:172.21.0.6: Ping
2026-04-23T18:18:39.024Z ::ffff:172.21.0.6: Ping
2026-04-23T18:18:41.076Z ::ffff:172.21.0.6: Ping
2026-04-23T18:18:43.981Z ::ffff:172.21.0.6: Ping
2026-04-23T18:18:46.074Z ::ffff:172.21.0.6: Ping
2026-04-23T18:18:48.963Z ::ffff:172.21.0.6: Ping
2026-04-23T18:18:51.075Z ::ffff:172.21.0.6: Ping
2026-04-23T18:18:53.973Z ::ffff:172.21.0.6: Ping
2026-04-23T18:18:56.074Z ::ffff:172.21.0.6: Ping
2026-04-23T18:18:58.991Z ::ffff:172.21.0.6: Ping
2026-04-23T18:19:01.083Z ::ffff:172.21.0.6: Ping
2026-04-23T18:19:04.009Z ::ffff:172.21.0.6: Ping
2026-04-23T18:19:06.071Z ::ffff:172.21.0.6: Ping
2026-04-23T18:19:08.974Z ::ffff:172.21.0.6: Ping
2026-04-23T18:19:11.071Z ::ffff:172.21.0.6: Ping
2026-04-23T18:19:13.988Z ::ffff:172.21.0.6: Ping
2026-04-23T18:19:16.982Z ::ffff:172.21.0.6: Ping
2026-04-23T18:19:18.984Z ::ffff:172.21.0.6: Ping
2026-04-23T18:19:21.978Z ::ffff:172.21.0.6: Ping
2026-04-23T18:19:23.977Z ::ffff:172.21.0.6: Ping
2026-04-23T18:19:27.041Z ::ffff:172.21.0.6: Ping
2026-04-23T18:19:28.994Z ::ffff:172.21.0.6: Ping
2026-04-23T18:19:31.987Z ::ffff:172.21.0.6: Ping
2026-04-23T18:19:34.012Z ::ffff:172.21.0.6: Ping
2026-04-23T18:19:36.970Z ::ffff:172.21.0.6: Ping
2026-04-23T18:19:38.993Z ::ffff:172.21.0.6: Ping
2026-04-23T18:19:42.001Z ::ffff:172.21.0.6: Ping
2026-04-23T18:19:43.983Z ::ffff:172.21.0.6: Ping
2026-04-23T18:19:46.981Z ::ffff:172.21.0.6: Ping
2026-04-23T18:19:49.066Z ::ffff:172.21.0.6: Ping
2026-04-23T18:19:52.032Z ::ffff:172.21.0.6: Ping
2026-04-23T18:19:53.972Z ::ffff:172.21.0.6: Ping
2026-04-23T18:19:56.980Z ::ffff:172.21.0.6: Ping
2026-04-23T18:19:58.975Z ::ffff:172.21.0.6: Ping
2026-04-23T18:20:01.970Z ::ffff:172.21.0.6: Ping
2026-04-23T18:20:04.015Z ::ffff:172.21.0.6: Ping
2026-04-23T18:20:06.985Z ::ffff:172.21.0.6: Ping
2026-04-23T18:20:09.033Z ::ffff:172.21.0.6: Ping
2026-04-23T18:20:12.003Z ::ffff:172.21.0.6: Ping
2026-04-23T18:20:13.971Z ::ffff:172.21.0.6: Ping
2026-04-23T18:20:18.982Z ::ffff:172.21.0.6: Ping
2026-04-23T18:20:23.981Z ::ffff:172.21.0.6: Ping
2026-04-23T18:21:06.070Z ::ffff:172.21.0.6: Ping
2026-04-23T18:21:06.071Z ::ffff:172.21.0.6: Ping

View File

@@ -337,7 +337,7 @@ class Robot{
this.calculateSpeeds(this.motorPositionOld, this.motorPosition);
this.motorPosition.speeds = {...this.motorSpeeds};
console.log("Robot.sendCommand: Motor-Pos: x=", this.motorPosition.x.toFixed(3), "yMotor=",this.motorPosition.y.toFixed(3), "zMotor=",this.motorPosition.z.toFixed(3), "aM=", this.motorPosition.a.toFixed(3), "bM=", this.motorPosition.b.toFixed(3), "cM=", this.motorPosition.c.toFixed(3), " e=", this.motorPosition.e.toFixed(3));
console.log("Robot.sendCommand: ", cmd.toString(), " Motor-Pos: x=", this.motorPosition.x.toFixed(3), "yMotor=",this.motorPosition.y.toFixed(3), "zMotor=",this.motorPosition.z.toFixed(3), "aM=", this.motorPosition.a.toFixed(3), "bM=", this.motorPosition.b.toFixed(3), "cM=", this.motorPosition.c.toFixed(3), " e=", this.motorPosition.e.toFixed(3));
this.cmdReceivers.forEach(receiver => {
receiver.execCommand(cmd,this.motorPositionOld, this.motorPosition);

View File

@@ -57,7 +57,7 @@ module.exports = class TelnetSenderGRBL{
});
}
console.log("🤖 TelnetSenderGRBL initialized with URL: " + urlGRBL);
console.log("🤖 TelnetSenderGRBL initialized: " + urlGRBL);
}
moveTo(mOld, mNew){
@@ -106,7 +106,7 @@ module.exports = class TelnetSenderGRBL{
if(this.yAxisGrbl == "x" && mNew.xMotorChanged && Number.isFinite(mNew.x)){
if(this.yAxisGrbl == "x" && mNew.xMotorChanged && Number.isFinite(mNew.x)){
data += " y" + (mNew.x ).toFixed(2).toString();
}
if(this.yAxisGrbl == "y" && mNew.yMotorChanged && Number.isFinite(mNew.y)){
@@ -203,7 +203,7 @@ if(this.yAxisGrbl == "x" && mNew.xMotorChanged && Number.isFinite(mNew.x)){
data += " b" + (mNew.e * 180 / Math.PI).toFixed(2).toString();
}
if(this.tSocket && data.toString("utf-8").length > 3){
if(this.tSocket && data.length > 3){
if(strCommand == "G1" && mNew){
const DEFAULT_FEEDRATE = process.env.ROBOT_DEFAULT_FEEDRATE ?
@@ -216,8 +216,14 @@ if(this.yAxisGrbl == "x" && mNew.xMotorChanged && Number.isFinite(mNew.x)){
// abhngig vom FluidNC und dessen speed interpretation ist.
}
if(!this.isTestMode){ console.log("" + this.urlGRBLstr + " gets the message: " + data.toString("utf-8"))}
this.tSocket.write( data.toString("utf-8") + "\r\n");
if(data.indexOf("G90") == -1){
data = "G90 " + data;
}
console.log("Driver send to 🤖 " + this.urlGRBLstr + " the message: " + data)
this.tSocket.write( data + "\r\n");
}
}
}

View File

@@ -331,11 +331,16 @@ module.exports = class TelnetSenderGRBL{
data += " f"+(maxSpeedF.toFixed(2).toString())
dataStr = data.toString("utf-8");
if(this.tSocket && dataStr.length > 3){
// Ensure that the command starts with G90 (absolute positioning) if it's not already included
if(dataStr.indexOf("G90") == -1){
dataStr = "G90 " + dataStr;
}
console.log("Driver send to 🤖 " + this.urlGRBLstr + " the message: " + data.toString("utf-8"))
if(this.tSocket && data.toString("utf-8").length > 3){
//if(!this.isTestMode){
console.log("" + this.urlGRBLstr + " gets the message: " + data.toString("utf-8"))
//}
this.tSocket.write( data.toString("utf-8") + "\r\n");
}
}

View File

@@ -1,241 +1,70 @@
const fs = require('fs');
const https = require('https');
const WebSocket = require('ws');
function getLastLines(filePath, numLines) {
try {
const data = fs.readFileSync(filePath, 'utf8');
const lines = data.split('\n').filter(line => line.trim());
return lines.slice(-numLines);
} catch (e) {
return [];
}
}
const Robot = require('./robot/Robot');
const GCode = require('./robot/GCode');
const initInputWS = require('./server/InputWS');
const createInfoServer = require('./server/InfoServer');
const Robot = require('./robot/Robot.js')
const GCode = require('./robot/GCode.js')
// 238 + 1 + 25 = 264
let robot = new Robot(250,264,100); //(300,290,10);
const TenetSender = require('./robot/TelnetSenderGRBL');
/* ---------- Robot ---------- */
const robot = new Robot(250, 264, 100);
let connectedClients = [];
let lastCommands = [];
let lastPings = [];
let sharedState = {
/* ---------- Shared State ---------- */
const sharedState = {
connectedClients: [],
lastCommands: [],
lastPings: []
};
/* ---------- HTTPS ---------- */
const httpsOptions = {
"enable": true,
'key': fs.readFileSync('https/localhost.key'),
'cert': fs.readFileSync('https/localhost.pem'),
"passphrase": "abcd"
}
server = https.createServer(httpsOptions, (req, res) => {;});
const wss = new WebSocket.Server({ server });
// Input Connection for WebService
wss.on('connection', function connection(ws)
{
console.log("WebServer for Input is connected");
const clientIP = ws._socket.remoteAddress || 'unknown';
connectedClients.push(clientIP);
ws.on('close', () => {
connectedClients = connectedClients.filter(client => client !== clientIP);
});
ws.on('message', function incoming(message)
{
if(message == "Ping"){
fs.appendFileSync('./logs/pings.log', `${new Date().toISOString()} ${clientIP}: ${message}\n`);
lastPings.push(new Date().toISOString() + ': ' + message);
if (lastPings.length > 10) lastPings.shift();
wss.clients.forEach(function (client)
{
if (client.readyState == WebSocket.OPEN)
{
client.send( message );
}
});
}
if(GCode.containsCommand(message)){
fs.appendFileSync('./logs/gcode_commands.log', `${new Date().toISOString()} ${clientIP}: ${message}\n`);
lastCommands.push(new Date().toISOString() + ': ' + message);
if (lastCommands.length > 10) lastCommands.shift();
GCode.receiveGCode(robot,message);
reply = GCode.getM114(robot);
wss.clients.forEach(function (client)
{
if (client.readyState == WebSocket.OPEN)
{
client.send( reply );
}
});
}
if(GCode.ContainsFilesCommand(message)){
fs.appendFileSync('./logs/gcode_commands.log', `${new Date().toISOString()} ${clientIP}: ${message}\n`);
lastCommands.push(new Date().toISOString() + ': ' + message);
if (lastCommands.length > 10) lastCommands.shift();
reply = GCode.receiveFC(robot, message);
wss.clients.forEach(function (client)
{
if (client.readyState == WebSocket.OPEN)
{
client.send( reply );
}
});
}
// Request for Status
if(message == "M114"){
fs.appendFileSync('./logs/gcode_commands.log', `${new Date().toISOString()} ${clientIP}: ${message}\n`);
lastCommands.push(new Date().toISOString() + ': ' + message);
if (lastCommands.length > 10) lastCommands.shift();
reply = GCode.getM114(robot);
wss.clients.forEach(function (client)
{
if (client.readyState == WebSocket.OPEN)
{
client.send( reply );
}
});
}
});
});
/*
const InputWS = require('./server/InputWS.js')
const wss = InputWS(server, robot, GCode, sharedState);
*/
var TenetSender = require('./robot/TelnetSenderGRBL.js')
enable: true,
key: fs.readFileSync('https/localhost.key'),
cert: fs.readFileSync('https/localhost.pem'),
passphrase: 'abcd'
};
const httpsServer = https.createServer(httpsOptions);
/* ---------- WebSocket Input ---------- */
initInputWS(httpsServer, robot, GCode, sharedState);
/* ---------- GRBL Sender ---------- */
const baseIP = process.env.GRBL_BASE_IP ?? "fluidNcBase.local";
const elbowIP = process.env.GRBL_ELLBOW_IP ?? "fluidNcEllbow.local";
const elbowIP= process.env.GRBL_ELLBOW_IP ?? "fluidNcEllbow.local";
const handIP = process.env.GRBL_HAND_IP ?? "fluidNcHand.local";
console.log(baseIP, elbowIP, handIP);
const telnetSender1 = new TenetSender(baseIP, 2300, "x", "y", "z");
const telnetSender2 = new TenetSender(elbowIP, 5000, "a", null, null);
const telnetSender3 = new TenetSender(handIP, 5000, "c", "e", "b");
var telnetSender1 = new TenetSender(urlGRBL = baseIP, maxSpeedF = 2300, xAxisGrbl = "x", yAxisGrbl = "y", zAxisGrbl = "z");
var telnetSender2 = new TenetSender(urlGRBL = elbowIP, maxSpeedF = 5000, xAxisGrbl = "a", yAxisGrbl = null, zAxisGrbl = null);
var telnetSender3 = new TenetSender(urlGRBL = handIP, maxSpeedF = 5000, xAxisGrbl = "c", yAxisGrbl = "e", zAxisGrbl = "b");
setTimeout(function() {
if(telnetSender1?.tSocket != null) { robot.cmdReceivers.push(telnetSender1); console.log("Socket 1 added");}
else{ console.log("Socket 1 is not connected"); console.log(telnetSender1?.tSocket);}
if(telnetSender2?.tSocket != null) { robot.cmdReceivers.push(telnetSender2); console.log("Socket 2 added");}
else{ console.log("Socket 2 is not connected"); console.log(telnetSender2?.tSocket);}
if(telnetSender3?.tSocket != null) { robot.cmdReceivers.push(telnetSender3); console.log("Socket 3 added");}
else{ console.log("Socket 3 is not connected"); console.log(telnetSender3?.tSocket);}
}, 8000);
setTimeout(function(){
if(robot.cmdReceivers.length == 0){
console.log("Kein GRBL Command-Receiver gefunden. Verwende reines Test-Setting.")
}
},8002)
console.log("Works with FluidNc Base");
const port = Number(process.env.PORT);
const listenPort = Number.isInteger(port) ? port : 2095;
console.log("Starting server on port: " + listenPort.toString());
server.listen(listenPort);
console.log("Listen on Port: https://localhost:" + listenPort.toString()+ "/")
// Info server on port 2098
const infoServer = https.createServer(httpsOptions, (req, res) => {
if (req.url === '/') {
fs.readFile('./public/index.html', (err, data) => {
if (err) {
res.writeHead(404);
res.end('Not found');
} else {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end(data);
}
setTimeout(() => {
[telnetSender1, telnetSender2, telnetSender3].forEach(s => {
if (s?.tSocket) robot.cmdReceivers.push(s);
});
} else if (req.url === '/app.js') {
fs.readFile('./public/app.js', (err, data) => {
if (err) {
res.writeHead(404);
res.end('Not found');
} else {
res.writeHead(200, {'Content-Type': 'application/javascript'});
res.end(data);
}
});
} else if (req.url === '/style.css') {
fs.readFile('./public/style.css', (err, data) => {
if (err) {
res.writeHead(404);
res.end('Not found');
} else {
res.writeHead(200, {'Content-Type': 'text/css'});
res.end(data);
}
}); } else if (req.url === '/allApps.css') {
fs.readFile('./public/allApps.css', (err, data) => {
if (err) {
res.writeHead(404);
res.end('Not found');
} else {
res.writeHead(200, {'Content-Type': 'text/css'});
res.end(data);
}
});
} else if (req.url === '/api/status') {
const status = {
clients: connectedClients,
senders: [
{name: 'Base', status: telnetSender1?.tSocket ? 'connected' : 'disconnected'},
{name: 'Elbow', status: telnetSender2?.tSocket ? 'connected' : 'disconnected'},
{name: 'Hand', status: telnetSender3?.tSocket ? 'connected' : 'disconnected'}
],
lastCommands: getLastLines('./logs/gcode_commands.log', 15),
lastPings: getLastLines('./logs/pings.log', 15)
};
res.writeHead(200, {'Content-Type': 'application/json'});
res.end(JSON.stringify(status));
} else if (req.url === '/api/position'){
res.writeHead(200, {'Content-Type': 'application/json'});
res.end(GCode.getM114(robot));
} else {
res.writeHead(404);
res.end('Not found');
}
});
}, 5000);
/* ---------- Start Input Server ---------- */
const port = Number(process.env.PORT) || 2095;
httpsServer.listen(port);
console.log(`Input HTTPS/WebSocket on https://localhost:${port}`);
const InfPort = Number(process.env.PORT);
const listenInfoPort = Number.isInteger(InfPort) ? InfPort : 2098;
/* ---------- Info Server ---------- */
const infoServer = createInfoServer(
httpsOptions,
sharedState,
robot,
GCode,
[
{ name: "Base", instance: telnetSender1 },
{ name: "Elbow", instance: telnetSender2 },
{ name: "Hand", instance: telnetSender3 }
]
);
console.log("Starting info server on port: " + listenInfoPort.toString());
infoServer.listen(listenInfoPort);
console.log("Info server listening on https://localhost:"+ listenInfoPort.toString() + "/");
const infoPort = 2098;
infoServer.listen(infoPort);
console.log(`Info server on https://localhost:${infoPort}`);

View File

@@ -1,70 +0,0 @@
const fs = require('fs');
const https = require('https');
const Robot = require('./robot/Robot');
const GCode = require('./robot/GCode');
const initInputWS = require('./server/InputWS');
const createInfoServer = require('./server/InfoServer');
const TenetSender = require('./robot/TelnetSenderGRBL');
/* ---------- Robot ---------- */
const robot = new Robot(250, 264, 100);
/* ---------- Shared State ---------- */
const sharedState = {
connectedClients: [],
lastCommands: [],
lastPings: []
};
/* ---------- HTTPS ---------- */
const httpsOptions = {
enable: true,
key: fs.readFileSync('https/localhost.key'),
cert: fs.readFileSync('https/localhost.pem'),
passphrase: 'abcd'
};
const httpsServer = https.createServer(httpsOptions);
/* ---------- WebSocket Input ---------- */
initInputWS(httpsServer, robot, GCode, sharedState);
/* ---------- GRBL Sender ---------- */
const baseIP = process.env.GRBL_BASE_IP ?? "fluidNcBase.local";
const elbowIP= process.env.GRBL_ELLBOW_IP ?? "fluidNcEllbow.local";
const handIP = process.env.GRBL_HAND_IP ?? "fluidNcHand.local";
const telnetSender1 = new TenetSender(baseIP, 2300, "x", "y", "z");
const telnetSender2 = new TenetSender(elbowIP, 5000, "a", null, null);
const telnetSender3 = new TenetSender(handIP, 5000, "c", "e", "b");
setTimeout(() => {
[telnetSender1, telnetSender2, telnetSender3].forEach(s => {
if (s?.tSocket) robot.cmdReceivers.push(s);
});
}, 8000);
/* ---------- Start Input Server ---------- */
const port = Number(process.env.PORT) || 2095;
httpsServer.listen(port);
console.log(`Input HTTPS/WebSocket on https://localhost:${port}`);
/* ---------- Info Server ---------- */
const infoServer = createInfoServer(
httpsOptions,
sharedState,
robot,
GCode,
[
{ name: "Base", instance: telnetSender1 },
{ name: "Elbow", instance: telnetSender2 },
{ name: "Hand", instance: telnetSender3 }
]
);
const infoPort = 2098;
infoServer.listen(infoPort);
console.log(`Info server on https://localhost:${infoPort}`);