CAM: Simulator - Drilling - RetractMode G98/G99

This commit is contained in:
tarman3
2025-05-30 08:52:54 +03:00
parent bc5616dbf6
commit 2db1a734e7
3 changed files with 19 additions and 4 deletions

View File

@@ -41,7 +41,7 @@ GCodeParser::~GCodeParser()
bool GCodeParser::Parse(const char* filename)
{
Operations.clear();
lastState = {eNop, -1, 0, 0, 0, 0, 0, 0, 0};
lastState = {eNop, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0};
lastTool = -1;
FILE* fl;
@@ -163,6 +163,13 @@ bool GCodeParser::ParseLine(const char* ptr)
}
else if (cmd == 73 || cmd == 81 || cmd == 82 || cmd == 83) {
lastState.cmd = eDril;
lastState.retract_z = lastState.z;
}
else if (cmd == 98 || cmd == 99) {
lastState.retract_mode = cmd;
}
else if (cmd == 80) {
lastState.retract_mode = 0;
}
break;
@@ -212,7 +219,13 @@ bool GCodeParser::AddLine(const char* ptr)
if (lastState.cmd == eDril) {
// split to several motions
lastState.cmd = eMoveLiner;
float rPlane = lastState.r;
float rPlane;
if (lastState.retract_mode == 99) {
rPlane = lastState.r;
}
else {
rPlane = lastState.retract_z;
}
float finalDepth = lastState.z;
lastState.z = rPlane;
Operations.push_back(lastState);

View File

@@ -45,8 +45,8 @@ public:
public:
std::vector<MillMotion> Operations;
MillMotion lastState = {eNop, 0, 0, 0, 0, 0, 0, 0, 0};
MillMotion lastLastState = {eNop, 0, 0, 0, 0, 0, 0, 0, 0};
MillMotion lastState = {eNop, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
MillMotion lastLastState = {eNop, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
protected:
const char* GetNextToken(const char* ptr, GCToken* token);

View File

@@ -53,6 +53,8 @@ struct MillMotion
float x, y, z;
float i, j, k;
float r;
char retract_mode;
float retract_z;
};
static inline void MotionPosToVec(vec3 vec, const MillMotion* motion)