nur wenn xyz genaendert, dann senden
This commit is contained in:
@@ -55,7 +55,7 @@ describe("Robot G92", () => {
|
||||
});
|
||||
|
||||
// G92 y2.8 z131.0
|
||||
test("ReadPosition -> G92()", () => {
|
||||
test("ReadPosition -> G92() test ob nur bestimmte Achsen gesendet werden", () => {
|
||||
|
||||
// === Instanz A: Vorwärts-Kinematik (XYZ -> Motorwinkel) ===
|
||||
const L1 = 300;
|
||||
@@ -75,14 +75,43 @@ describe("Robot G92", () => {
|
||||
|
||||
GCode.receiveGCode(robot,"M92 y0.049 z2.286");
|
||||
|
||||
const strExpect1 = 'G92 x0.00 y2.81 z128.17\r\n';
|
||||
//const strExpect1 = 'G92 x0.00 y2.81 z128.17\r\n';
|
||||
const strExpect1 = 'G92 y2.81 z128.17\r\n'; // x soll eben nicht gesendet werden.
|
||||
const strExpect2 = 'G92 y2.81 z128.17\r\n';
|
||||
|
||||
allowedValues = [strExpect1, strExpect2];
|
||||
expect(allowedValues).toContain(telnetSender1.tSocket.written);
|
||||
expect(telnetSender2.tSocket.written.length).toBe(0); // kein GCode für Ellbow
|
||||
|
||||
// ("Wenn nur G92 x3 gegeben wird, dann wird trotzdem auch y und z gesendet. schlecht." );
|
||||
});
|
||||
// G92 y2.8 z131.0
|
||||
test("ReadPosition -> G92() test ob nur bestimmte Achsen gesendet werden", () => {
|
||||
|
||||
// === Instanz A: Vorwärts-Kinematik (XYZ -> Motorwinkel) ===
|
||||
const L1 = 300;
|
||||
const L2 = 300;
|
||||
const L3 = 20;
|
||||
|
||||
const robot = new Robot(L1, L2, L3)
|
||||
|
||||
var telnetSender1 = new TenetSender(urlGRBL = "test.test", maxSpeedF = 2300, xAxisGrbl = "x", yAxisGrbl = "y", zAxisGrbl = "z");
|
||||
var telnetSender2 = new TenetSender(urlGRBL = "test.test", maxSpeedF = 5000, xAxisGrbl = "a", yAxisGrbl = null, zAxisGrbl = null);
|
||||
var telnetSender3 = new TenetSender(urlGRBL = "test.test", maxSpeedF = 5000, xAxisGrbl = "c", yAxisGrbl = "e", zAxisGrbl = "b");
|
||||
|
||||
robot.cmdReceivers.push(telnetSender1);
|
||||
robot.cmdReceivers.push(telnetSender2);
|
||||
robot.cmdReceivers.push(telnetSender3);
|
||||
|
||||
|
||||
GCode.receiveGCode(robot,"M92 a0.20");
|
||||
|
||||
|
||||
expect(telnetSender1.tSocket.written.length).toBe(0); // kein GCode für XYZ
|
||||
expect(telnetSender2.tSocket.written).toBe('G92 x11.46\r\n');
|
||||
expect(telnetSender3.tSocket.written.length).toBe(0); // kein GCode für XYZ
|
||||
|
||||
// ("Wenn nur G92 x3 gegeben wird, dann wird trotzdem auch y und z gesendet. schlecht." );
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const GCode = require('../robot/GCode.js');
|
||||
|
||||
const Robot = require('../robot/Robot.js');
|
||||
var TenetSender = require('../robot/TelnetSenderGRBL.js')
|
||||
|
||||
test('G91 ist ein GCode Command', () => {
|
||||
var x = GCode.containsCommand("G91") ;
|
||||
@@ -12,4 +13,37 @@ test('G28 ist ein GCode Command', () => {
|
||||
});
|
||||
|
||||
|
||||
beforeAll(() => {
|
||||
jest.spyOn(console, 'log').mockImplementation(() => {})
|
||||
})
|
||||
|
||||
afterAll(() => {
|
||||
jest.restoreAllMocks()
|
||||
})
|
||||
|
||||
|
||||
test("ReadPosition -> G1", () => {
|
||||
|
||||
const L1 = 300;
|
||||
const L2 = 300;
|
||||
const L3 = 20;
|
||||
|
||||
const robot = new Robot(L1, L2, L3)
|
||||
|
||||
var telnetSender1 = new TenetSender(urlGRBL = "test.test", maxSpeedF = 2300, xAxisGrbl = "x", yAxisGrbl = "y", zAxisGrbl = "z");
|
||||
var telnetSender2 = new TenetSender(urlGRBL = "test.test", maxSpeedF = 5000, xAxisGrbl = "a", yAxisGrbl = null, zAxisGrbl = null);
|
||||
var telnetSender3 = new TenetSender(urlGRBL = "test.test", maxSpeedF = 5000, xAxisGrbl = "c", yAxisGrbl = "e", zAxisGrbl = "b");
|
||||
|
||||
robot.cmdReceivers.push(telnetSender1);
|
||||
robot.cmdReceivers.push(telnetSender2);
|
||||
robot.cmdReceivers.push(telnetSender3);
|
||||
|
||||
|
||||
GCode.receiveGCode(robot,"G1 x120");
|
||||
|
||||
|
||||
expect(telnetSender1.tSocket.written).toContain('G1 x1')
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -98,8 +98,8 @@ describe('Robot.sendCommand & cmdReceivers', () => {
|
||||
test('Receiver-Reihenfolge bleibt erhalten', () => {
|
||||
const order = []
|
||||
|
||||
const r1 = { moveTo: () => order.push('r1') }
|
||||
const r2 = { moveTo: () => order.push('r2') }
|
||||
const r1 = { execCommand: () => order.push('r1') }
|
||||
const r2 = { execCommand: () => order.push('r2') }
|
||||
|
||||
robot.cmdReceivers.push(r1, r2)
|
||||
robot.sendCommand()
|
||||
|
||||
@@ -19,6 +19,9 @@ describe("TelnetSenderGRBL.execCommand", () => {
|
||||
// Provide some sample motion data
|
||||
const mOld = { x: 0, y: 0, z: 0, a:0, b:0, c:0, e:0 }; // not used in your code
|
||||
const mNew = { x: 12.34, y: Math.PI/2, z: 0, a:0, b:0, c:0, e:0 };
|
||||
mNew.xMotorChanged = true;
|
||||
mNew.yMotorChanged = true;
|
||||
mNew.zMotorChanged = true;
|
||||
|
||||
sender.execCommand("G1", mOld, mNew);
|
||||
|
||||
@@ -44,6 +47,11 @@ describe("TelnetSenderGRBL.execCommand", () => {
|
||||
const mOld = { x: 0, y: 0, z: 0, a:Math.PI, b:0, c:0, e:0 }; // not used in your code
|
||||
const mNew = { x: 12.34, y: Math.PI/2, z: 0, a:Math.PI/8, b:0, c:0, e:0 };
|
||||
|
||||
mNew.xMotorChanged = true;
|
||||
mNew.yMotorChanged = true;
|
||||
mNew.zMotorChanged = true;
|
||||
mNew.aMotorChanged = true;
|
||||
|
||||
sender.execCommand("G1", mOld, mNew);
|
||||
|
||||
// ✅ verify output
|
||||
@@ -66,6 +74,9 @@ describe("TelnetSenderGRBL.execCommand", () => {
|
||||
// Provide some sample motion data
|
||||
const mOld = { x: 0, y: 0, z: 0, a:0, b:0, c:0, e:0 }; // not used in your code
|
||||
const mNew = { x: 12.34, y: 1.0, z: 2.0, a:0, b:0, c:0, e:0 };
|
||||
mNew.xMotorChanged = true;
|
||||
mNew.yMotorChanged = true;
|
||||
mNew.zMotorChanged = true;
|
||||
|
||||
sender.execCommand("G92", mOld, mNew);
|
||||
|
||||
|
||||
@@ -11,6 +11,16 @@ class MockCmdReceiver {
|
||||
})
|
||||
}
|
||||
|
||||
execCommand(cmd, oldPos, newPos) {
|
||||
this.calls.push({
|
||||
cmd,
|
||||
oldPos,
|
||||
newPos
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
get callCount() {
|
||||
return this.calls.length
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user