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:
@@ -257,6 +257,8 @@ int sim_io_spindle_command(sim_io *io, uint32_t spindle, double rpm, uint32_t en
|
||||
if (io->state.estop) { set_last(io, SIM_IO_ERR_ESTOP); return SIM_IO_ERR_ESTOP; }
|
||||
if (!io->state.ready) { set_last(io, SIM_IO_ERR_NOT_READY); return SIM_IO_ERR_NOT_READY; }
|
||||
state = &io->state.spindles[spindle];
|
||||
state->requested_rpm = enabled ? rpm : 0.0;
|
||||
state->direction = enabled ? (rpm > 0 ? 1 : rpm < 0 ? -1 : 0) : 0;
|
||||
state->command_rpm = enabled && !state->inhibit && !state->amp_fault ? rpm * state->override_scale : 0.0;
|
||||
state->enabled = enabled ? 1U : 0U;
|
||||
set_last(io, SIM_IO_OK);
|
||||
@@ -274,11 +276,12 @@ int sim_io_spindle_adjust(sim_io *io, uint32_t spindle, double delta) {
|
||||
state = &io->state.spindles[spindle];
|
||||
// Match LinuxCNC EMCMOT_SPINDLE_INCREASE/DECREASE: change the signed
|
||||
// speed only while the spindle is running and keep its direction.
|
||||
if (state->command_rpm > 0.0) target = fmax(0.0, state->command_rpm + delta);
|
||||
else if (state->command_rpm < 0.0) target = fmin(0.0, state->command_rpm - delta);
|
||||
if (state->requested_rpm > 0.0) target = fmax(0.0, state->requested_rpm + delta);
|
||||
else if (state->requested_rpm < 0.0) target = fmin(0.0, state->requested_rpm - delta);
|
||||
else target = 0.0;
|
||||
target = fmax(-state->max_rpm, fmin(state->max_rpm, target));
|
||||
state->command_rpm = state->enabled && !state->inhibit && !state->amp_fault ? target : 0.0;
|
||||
state->requested_rpm = target;
|
||||
state->command_rpm = state->enabled && !state->inhibit && !state->amp_fault ? target * state->override_scale : 0.0;
|
||||
set_last(io, SIM_IO_OK);
|
||||
mirror_pins(io);
|
||||
return SIM_IO_OK;
|
||||
@@ -300,12 +303,11 @@ int sim_io_spindle_set_override(sim_io *io, uint32_t spindle, double scale) {
|
||||
sim_io_spindle_state *state;
|
||||
double base;
|
||||
if (!valid_spindle(io, spindle) || !isfinite(scale) || scale < 0.0 || scale > 2.0) return SIM_IO_ERR_RANGE;
|
||||
if (io->state.estop) { set_last(io, SIM_IO_ERR_ESTOP); return SIM_IO_ERR_ESTOP; }
|
||||
if (!io->state.ready) { set_last(io, SIM_IO_ERR_NOT_READY); return SIM_IO_ERR_NOT_READY; }
|
||||
/* EMC_TRAJ_SET_SPINDLE_SCALE remains accepted while OFF/ESTOP. */
|
||||
state = &io->state.spindles[spindle];
|
||||
base = state->override_scale > 0.0 ? state->command_rpm / state->override_scale : 0.0;
|
||||
base = state->requested_rpm;
|
||||
state->override_scale = scale;
|
||||
state->command_rpm = state->enabled && !state->inhibit && !state->amp_fault ? base * scale : 0.0;
|
||||
state->command_rpm = scale > 0 && state->enabled && !state->inhibit && !state->amp_fault ? base * scale : 0.0;
|
||||
set_last(io, SIM_IO_OK);
|
||||
mirror_pins(io);
|
||||
return SIM_IO_OK;
|
||||
@@ -623,9 +625,9 @@ uint32_t sim_io_canonical(const sim_io *io, char *output, uint32_t capacity) {
|
||||
const sim_io_spindle_state *spindle = &io->state.spindles[index];
|
||||
int part = snprintf(destination + (output && (uint32_t)written < capacity ? written : 0),
|
||||
output && (uint32_t)written < capacity ? capacity - (uint32_t)written : 0,
|
||||
"%s{\"at_speed\":%u,\"brake\":%u,\"command_rpm\":%.9g,\"enabled\":%u,\"forward\":%u,\"inhibit\":%u,\"override\":%.9g,\"reverse\":%u,\"speed_rpm\":%.9g,\"tick\":%u}",
|
||||
"%s{\"at_speed\":%u,\"brake\":%u,\"command_rpm\":%.9g,\"enabled\":%u,\"forward\":%u,\"inhibit\":%u,\"override\":%.9g,\"reverse\":%u,\"speed_rpm\":%.9g,\"tick\":%u,\"requested_rpm\":%.9g,\"direction\":%d}",
|
||||
index ? "," : "", spindle->at_speed, spindle->brake, spindle->command_rpm,
|
||||
spindle->enabled, spindle->forward, spindle->inhibit, spindle->override_scale, spindle->reverse, spindle->speed_rpm, spindle->tick);
|
||||
spindle->enabled, spindle->forward, spindle->inhibit, spindle->override_scale, spindle->reverse, spindle->speed_rpm, spindle->tick, spindle->requested_rpm, spindle->enabled ? spindle->direction : 0);
|
||||
if (part < 0) return 0; written += part;
|
||||
}
|
||||
{ int part = snprintf(destination + (output && (uint32_t)written < capacity ? written : 0),
|
||||
|
||||
Reference in New Issue
Block a user