Align AXIS control flow and fix pause and program rendering
Document source UI gates, explicit native live-plot clearing, and remaining parity boundaries. Fix pause/resume transport continuity, repeated stepping, coordinate previews, and spindle override state. Optimize large program snapshots and rendering, and cover the control flows with native Tcl, WASM, and browser checks. Validation: 22 native tests and source/browser checks pass. Worker/App regression: 113 of 123 pass; 10 pre-existing failures remain documented with no new failures.
This commit is contained in:
@@ -64,6 +64,9 @@ int main(void) {
|
||||
assert(fabs(interpreter.state.x - 11.0) < 1e-12);
|
||||
assert(fabs(interpreter.state.y - 22.0) < 1e-12);
|
||||
assert(fabs(interpreter.state.z - 33.0) < 1e-12);
|
||||
assert(sim_interpreter_read_motion(&interpreter, &motion) == SIM_INTERP_OK);
|
||||
assert(fabs(motion.end.tran.x - 11.0) < 1e-12);
|
||||
assert(fabs(motion.end.tran.y - 22.0) < 1e-12);
|
||||
assert(sim_interpreter_execute(&interpreter, "G53 G0 X0 Y0 Z10", (uint32_t)(sizeof("G53 G0 X0 Y0 Z10") - 1)) == SIM_INTERP_OK);
|
||||
assert(fabs(interpreter.state.x) < 1e-12 && fabs(interpreter.state.y) < 1e-12 && fabs(interpreter.state.z - 10.0) < 1e-12);
|
||||
assert(sim_interpreter_execute(&interpreter, "G10 L20 P0 X0 Y0 Z10", (uint32_t)(sizeof("G10 L20 P0 X0 Y0 Z10") - 1)) == SIM_INTERP_OK);
|
||||
@@ -78,5 +81,17 @@ int main(void) {
|
||||
assert(sim_interpreter_execute(&interpreter, "G80 M7", (uint32_t)(sizeof("G80 M7") - 1)) == SIM_INTERP_OK);
|
||||
assert(sim_interpreter_execute(&interpreter, "M8", 2) == SIM_INTERP_OK);
|
||||
assert(sim_interpreter_execute(&interpreter, "M9", 2) == SIM_INTERP_OK);
|
||||
assert(sim_interpreter_reset(&interpreter) == SIM_INTERP_OK);
|
||||
assert(sim_interpreter_execute(&interpreter, "G0 X30 A20 C40", sizeof("G0 X30 A20 C40") - 1) == SIM_INTERP_OK);
|
||||
assert(sim_interpreter_execute(&interpreter, "G10 L20 P1 X5", 13) == SIM_INTERP_OK);
|
||||
assert(interpreter.state.x == 30.0);
|
||||
assert(sim_interpreter_execute(&interpreter, "G0 X6", 5) == SIM_INTERP_OK);
|
||||
assert(sim_interpreter_read_motion(&interpreter, &motion) == SIM_INTERP_OK);
|
||||
assert(motion.start.tran.x == 30.0 && motion.end.tran.x == 31.0);
|
||||
assert(sim_interpreter_execute(&interpreter, "G10 L20 P9 A5 C10", 17) == SIM_INTERP_OK);
|
||||
assert(interpreter.state.a == 20.0 && interpreter.state.c == 40.0);
|
||||
assert(sim_interpreter_execute(&interpreter, "G59.3 G0 A6 C11", 15) == SIM_INTERP_OK);
|
||||
assert(sim_interpreter_read_motion(&interpreter, &motion) == SIM_INTERP_OK);
|
||||
assert(motion.end.a == 21.0 && motion.end.c == 41.0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "sim_linuxcnc_tp.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -43,6 +44,44 @@ int main(void) {
|
||||
assert(sim_linuxcnc_tp_step(planner) == 0);
|
||||
assert(sim_linuxcnc_tp_read_state(planner, &state) == 0);
|
||||
assert(state.position.tran.x > 0.0 && sim_linuxcnc_tp_jog(planner, 0, 1, 100.0, 22) != 0);
|
||||
assert(sim_linuxcnc_tp_abort(planner) == 0);
|
||||
assert(sim_linuxcnc_tp_set_position(planner, &origin) == 0);
|
||||
assert(sim_linuxcnc_tp_jog(planner, 0, 1, -1.0, 23) != 0);
|
||||
assert(sim_linuxcnc_tp_jog(planner, 0, 1, NAN, 23) != 0);
|
||||
assert(sim_linuxcnc_tp_jog(planner, 0, 1, 0.0, 23) == 0);
|
||||
for (int index = 0; index < 3000; ++index) {
|
||||
assert(sim_linuxcnc_tp_step(planner) == 0);
|
||||
assert(sim_linuxcnc_tp_read_state(planner, &state) == 0);
|
||||
assert(state.position.tran.x <= 5.0);
|
||||
if (state.queue_depth == 0) break;
|
||||
}
|
||||
assert(state.queue_depth == 0 && fabs(state.position.tran.x - 5.0) < 1e-9);
|
||||
assert(sim_linuxcnc_tp_jog(planner, 0, 1, 0.0, 24) != 0);
|
||||
assert(sim_linuxcnc_tp_jog(planner, 0, -1, 0.0, 25) == 0);
|
||||
for (int index = 0; index < 50; ++index) assert(sim_linuxcnc_tp_step(planner) == 0);
|
||||
assert(sim_linuxcnc_tp_read_state(planner, &state) == 0);
|
||||
assert(state.position.tran.x < 5.0 && state.position.tran.x > -5.0);
|
||||
assert(sim_linuxcnc_tp_abort(planner) == 0);
|
||||
assert(sim_linuxcnc_tp_read_state(planner, &state) == 0 && state.queue_depth == 0);
|
||||
assert(sim_linuxcnc_tp_set_position(planner, &origin) == 0);
|
||||
first = pose(1, 0, 0); second = pose(2, 0, 0);
|
||||
assert(sim_linuxcnc_tp_add_line(planner, &first, 10, 300, 101, 1) == 0);
|
||||
assert(sim_linuxcnc_tp_add_line(planner, &second, 10, 300, 102, 1) == 0);
|
||||
assert(sim_linuxcnc_tp_set_paused(planner, 1) == 0);
|
||||
assert(sim_linuxcnc_tp_step_line(planner) == 0);
|
||||
for (int tick = 0; tick < 3000 && sim_linuxcnc_tp_is_stepping(planner); ++tick) assert(sim_linuxcnc_tp_step(planner) == 0);
|
||||
assert(!sim_linuxcnc_tp_is_stepping(planner));
|
||||
assert(sim_linuxcnc_tp_read_state(planner, &state) == 0);
|
||||
/* motion/control.c detects an ID transition after the servo sample;
|
||||
a transition may advance less than one cycle into the following TC. */
|
||||
assert(state.position.tran.x >= 1.0 && state.position.tran.x < 1.0 + 10.0 * 0.001);
|
||||
assert(sim_linuxcnc_tp_queue_depth(planner) == 1);
|
||||
assert(sim_linuxcnc_tp_step_line(planner) == 0);
|
||||
for (int tick = 0; tick < 3000 && sim_linuxcnc_tp_is_stepping(planner); ++tick) assert(sim_linuxcnc_tp_step(planner) == 0);
|
||||
assert(sim_linuxcnc_tp_read_state(planner, &state) == 0);
|
||||
assert(fabs(state.position.tran.x - 2.0) < 1e-9);
|
||||
assert(sim_linuxcnc_tp_axis_limit(planner, 0, 0) == -5.0);
|
||||
assert(sim_linuxcnc_tp_axis_limit(planner, 0, 1) == 5.0);
|
||||
puts(canonical);
|
||||
free(planner);
|
||||
return 0;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "sim_protocol.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
|
||||
int main(void) {
|
||||
sim_protocol_reset();
|
||||
@@ -15,17 +16,31 @@ int main(void) {
|
||||
assert(sim_protocol_last_seq() == 4);
|
||||
assert(sim_protocol_accept(1, 5, "PROGRAM_PAUSE", "op-4", 2) == SIM_PROTOCOL_OK);
|
||||
assert(sim_protocol_accept(1, 6, "SIM_STEP", "op-5-step", 2) == SIM_PROTOCOL_OK);
|
||||
assert(sim_protocol_accept(1, 7, "MDI_EXECUTE", "op-5", 2) == SIM_PROTOCOL_ERR_STATE);
|
||||
assert(sim_protocol_accept(1, 7, "PROGRAM_ABORT", "op-5", 2) == SIM_PROTOCOL_OK);
|
||||
/* These are connected-channel frames. MDI can still be rejected by
|
||||
the task; the transport must not poison subsequent command IDs. */
|
||||
const char *paused_commands[] = {"VISUAL_CLEAR", "SET_SPINDLE_OVERRIDE", "SET_MAX_VELOCITY", "PROGRAM_STEP", "MDI_EXECUTE", "PROGRAM_PAUSE"};
|
||||
uint32_t seq = 7;
|
||||
for (unsigned int i = 0; i < sizeof(paused_commands) / sizeof(paused_commands[0]); ++i) {
|
||||
assert(sim_protocol_accept(1, seq, paused_commands[i], "paused-op", 2) == SIM_PROTOCOL_OK);
|
||||
assert(sim_protocol_last_seq() == seq++);
|
||||
assert(sim_protocol_state_value() == SIM_PROTOCOL_PAUSED);
|
||||
}
|
||||
assert(sim_protocol_accept(1, seq + 1, "PROGRAM_RESUME", "resume-gap", 2) == SIM_PROTOCOL_ERR_SEQUENCE);
|
||||
assert(sim_protocol_last_seq() == seq - 1);
|
||||
assert(sim_protocol_accept(1, seq, "MDI_EXECUTE", NULL, 2) == SIM_PROTOCOL_ERR_OPERATION_ID);
|
||||
assert(sim_protocol_accept(1, seq++, "PROGRAM_RESUME", "resume", 2) == SIM_PROTOCOL_OK);
|
||||
assert(sim_protocol_state_value() == SIM_PROTOCOL_READY);
|
||||
assert(sim_protocol_accept(1, 8, "PROGRAM_PAUSE", "op-6", 2) == SIM_PROTOCOL_OK);
|
||||
assert(sim_protocol_accept(1, 9, "PROGRAM_RESUME", "op-7", 2) == SIM_PROTOCOL_OK);
|
||||
assert(sim_protocol_accept(2, 10, "PING", NULL, 2) == SIM_PROTOCOL_ERR_SCHEMA);
|
||||
assert(sim_protocol_accept(1, 10, "PING", NULL, 1) == SIM_PROTOCOL_ERR_TICK);
|
||||
assert(sim_protocol_accept(1, 10, "DESTROY", NULL, 2) == SIM_PROTOCOL_OK);
|
||||
assert(sim_protocol_accept(1, 11, "PING", NULL, 2) == SIM_PROTOCOL_ERR_STATE);
|
||||
assert(sim_protocol_accept(1, 12, "RESET", "reset-1", 0) == SIM_PROTOCOL_OK);
|
||||
assert(sim_protocol_accept(1, seq++, "PROGRAM_PAUSE", "pause-again", 2) == SIM_PROTOCOL_OK);
|
||||
assert(sim_protocol_accept(1, seq++, "PROGRAM_ABORT", "abort", 2) == SIM_PROTOCOL_OK);
|
||||
assert(sim_protocol_state_value() == SIM_PROTOCOL_READY);
|
||||
assert(sim_protocol_accept(2, seq, "PING", NULL, 2) == SIM_PROTOCOL_ERR_SCHEMA);
|
||||
assert(sim_protocol_accept(1, seq, "PING", NULL, 1) == SIM_PROTOCOL_ERR_TICK);
|
||||
assert(sim_protocol_accept(1, seq++, "DESTROY", NULL, 2) == SIM_PROTOCOL_OK);
|
||||
assert(sim_protocol_accept(1, seq, "PING", NULL, 2) == SIM_PROTOCOL_ERR_STATE);
|
||||
assert(sim_protocol_accept(1, seq, "RESET", "reset-1", 2) == SIM_PROTOCOL_OK);
|
||||
assert(sim_protocol_state_value() == SIM_PROTOCOL_NEW);
|
||||
assert(sim_protocol_set_tick(4) == SIM_PROTOCOL_ERR_TICK);
|
||||
assert(sim_protocol_last_seq() == 0);
|
||||
assert(sim_protocol_set_tick(4) == SIM_PROTOCOL_OK);
|
||||
assert(sim_protocol_set_tick(3) == SIM_PROTOCOL_ERR_TICK);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -29,8 +29,9 @@ int main(void) {
|
||||
assert(sim_task_set_mode(&task, SIM_TASK_MODE_AUTO) == SIM_TASK_OK);
|
||||
assert(sim_task_command_gate(&task, SIM_TASK_GATE_PAUSE, 0, 1, 0, 1, 0, 10) == SIM_TASK_GATE_ALLOWED);
|
||||
assert(sim_task_command_gate(&task, SIM_TASK_GATE_OVERRIDE, 0, 1, 0, 1, 0, 10) == SIM_TASK_GATE_ALLOWED);
|
||||
assert(sim_task_command_gate(&task, SIM_TASK_GATE_OVERRIDE, 0, 0, 0, 1, 0, 10) == SIM_TASK_GATE_MACHINE_OFF);
|
||||
assert(sim_task_command_gate(&task, SIM_TASK_GATE_OVERRIDE, 0, 1, 1, 1, 0, 10) == SIM_TASK_GATE_ESTOP_ACTIVE);
|
||||
/* axis.tcl sliders are available in OFF and ESTOP as well as AUTO. */
|
||||
assert(sim_task_command_gate(&task, SIM_TASK_GATE_OVERRIDE, 0, 0, 0, 1, 0, 10) == SIM_TASK_GATE_ALLOWED);
|
||||
assert(sim_task_command_gate(&task, SIM_TASK_GATE_OVERRIDE, 0, 1, 1, 1, 0, 10) == SIM_TASK_GATE_ALLOWED);
|
||||
assert(sim_task_command_gate(&task, SIM_TASK_GATE_POWER, 0, 1, 0, 1, 0, 10) == SIM_TASK_GATE_ALLOWED);
|
||||
assert(sim_task_command_gate(&task, SIM_TASK_GATE_SET_MODE, SIM_TASK_MODE_MANUAL, 1, 0, 1, 0, 10) == SIM_TASK_GATE_MODE_AUTO_ACTIVE);
|
||||
assert(sim_task_command_gate(&task, SIM_TASK_GATE_ESTOP, 1, 1, 0, 1, 0, 10) == SIM_TASK_GATE_ALLOWED);
|
||||
|
||||
Reference in New Issue
Block a user