提示词:
对标 LinuxCNC,分阶段完善 Web 版数控系统仿真的 WASM 程序,继续补齐 G 代码语法并严格测试。 总结: 对齐 LinuxCNC read_g 的 G80 特例:同一行 G80 与另一个运动模态 G 码共存时不触发同组冲突;新增 G80 G1 与 G1 G80 用例。已通过 ./test-native.sh 和 ./test-linuxcnc-source-link.sh。
This commit is contained in:
@@ -644,21 +644,26 @@ int supported_linuxcnc_m_modal_group(int value) {
|
||||
}
|
||||
|
||||
bool check_linuxcnc_modal_group_conflicts(const std::vector<Word> &word_list, std::string *error) {
|
||||
std::array<bool, 17> g_modes{};
|
||||
std::array<int, 17> g_modes{};
|
||||
std::array<bool, 11> m_modes{};
|
||||
g_modes.fill(-1);
|
||||
for (const Word &word : word_list) {
|
||||
if (word.letter == 'G') {
|
||||
const int mode = supported_linuxcnc_g_modal_group(word.value);
|
||||
if (mode < 0) {
|
||||
continue;
|
||||
}
|
||||
if (g_modes[static_cast<size_t>(mode)]) {
|
||||
const int code = linuxcnc_g_code_number(word.value);
|
||||
const int previous_code = g_modes[static_cast<size_t>(mode)];
|
||||
if (previous_code != -1 && previous_code != 800 && code != 800) {
|
||||
if (error) {
|
||||
*error = "Two G codes used from same modal group";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
g_modes[static_cast<size_t>(mode)] = true;
|
||||
if (previous_code == -1 || previous_code == 800) {
|
||||
g_modes[static_cast<size_t>(mode)] = code;
|
||||
}
|
||||
} else if (word.letter == 'M') {
|
||||
const int mode = supported_linuxcnc_m_modal_group(rounded_value(word.value));
|
||||
if (mode < 0) {
|
||||
|
||||
@@ -3582,6 +3582,26 @@ int main() {
|
||||
sizeof(same_modal_group_g_program) - 1) != 0,
|
||||
"expected LinuxCNC to reject two G codes from the same modal group");
|
||||
|
||||
const char g80_before_motion_program[] =
|
||||
"G21 G90\n"
|
||||
"F100\n"
|
||||
"G80 G1 X1\n";
|
||||
events.clear();
|
||||
ok &= expect(cnc_sim_parse_program(sim,
|
||||
g80_before_motion_program,
|
||||
sizeof(g80_before_motion_program) - 1) == 0,
|
||||
"expected LinuxCNC to allow G80 before another motion G code");
|
||||
|
||||
const char g80_after_motion_program[] =
|
||||
"G21 G90\n"
|
||||
"F100\n"
|
||||
"G1 G80 X1\n";
|
||||
events.clear();
|
||||
ok &= expect(cnc_sim_parse_program(sim,
|
||||
g80_after_motion_program,
|
||||
sizeof(g80_after_motion_program) - 1) == 0,
|
||||
"expected LinuxCNC to allow G80 after another motion G code");
|
||||
|
||||
const char same_modal_group_m_program[] =
|
||||
"G21 G90\n"
|
||||
"M3 M4\n";
|
||||
|
||||
Reference in New Issue
Block a user