Verify XYZAC panel button parity
This commit is contained in:
@@ -303,6 +303,7 @@ if(EMSCRIPTEN)
|
||||
string(REPLACE "_sim_hal_set_param" "_sim_hal_set_param_scalar','_sim_hal_set_param" _sim_module_link_flags "${_sim_module_link_flags}")
|
||||
string(REPLACE "_sim_io_init" "_sim_io_size','_sim_io_init" _sim_module_link_flags "${_sim_module_link_flags}")
|
||||
string(REPLACE "_sim_io_set_estop','_sim_io_recover" "_sim_io_set_estop','_sim_io_set_power','_sim_io_recover" _sim_module_link_flags "${_sim_module_link_flags}")
|
||||
string(REPLACE "_sim_io_spindle_command','_sim_io_spindle_set_inhibit" "_sim_io_spindle_command','_sim_io_spindle_adjust','_sim_io_spindle_brake','_sim_io_spindle_set_inhibit" _sim_module_link_flags "${_sim_module_link_flags}")
|
||||
string(REPLACE "_sim_device_init" "_sim_device_io_size','_sim_device_init" _sim_module_link_flags "${_sim_module_link_flags}")
|
||||
string(REPLACE "_sim_motion_step','_sim_motion_read_state" "_sim_motion_step','_sim_motion_set_profile','_sim_motion_set_lookahead','_sim_motion_set_feed_override','_sim_motion_peek','_sim_motion_read_state" _sim_module_link_flags "${_sim_module_link_flags}")
|
||||
string(REPLACE "_sim_motion_state_hash','_sim_motion_canonical" "_sim_motion_state_hash','_sim_motion_plan_hash','_sim_motion_canonical" _sim_module_link_flags "${_sim_module_link_flags}")
|
||||
|
||||
@@ -120,6 +120,8 @@ int sim_io_reset(sim_io *io);
|
||||
int sim_io_register_pins(sim_io *io);
|
||||
int sim_io_spindle_command(sim_io *io, uint32_t spindle, double rpm,
|
||||
uint32_t enabled);
|
||||
int sim_io_spindle_adjust(sim_io *io, uint32_t spindle, double delta);
|
||||
int sim_io_spindle_brake(sim_io *io, uint32_t spindle, uint32_t engaged);
|
||||
int sim_io_spindle_set_inhibit(sim_io *io, uint32_t spindle, uint32_t inhibit);
|
||||
int sim_io_spindle_set_fault(sim_io *io, uint32_t spindle, uint32_t fault);
|
||||
int sim_io_spindle_set_index_enable(sim_io *io, uint32_t spindle, uint32_t enable);
|
||||
|
||||
@@ -263,6 +263,38 @@ int sim_io_spindle_command(sim_io *io, uint32_t spindle, double rpm, uint32_t en
|
||||
return SIM_IO_OK;
|
||||
}
|
||||
|
||||
int sim_io_spindle_adjust(sim_io *io, uint32_t spindle, double delta) {
|
||||
sim_io_spindle_state *state;
|
||||
double target;
|
||||
if (!valid_spindle(io, spindle)) return SIM_IO_ERR_ARGUMENT;
|
||||
if (!isfinite(delta)) { set_last(io, SIM_IO_ERR_NONFINITE); return SIM_IO_ERR_NONFINITE; }
|
||||
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];
|
||||
// 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 = state->command_rpm + delta;
|
||||
else if (state->command_rpm < 0.0) target = state->command_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;
|
||||
set_last(io, SIM_IO_OK);
|
||||
mirror_pins(io);
|
||||
return SIM_IO_OK;
|
||||
}
|
||||
|
||||
int sim_io_spindle_brake(sim_io *io, uint32_t spindle, uint32_t engaged) {
|
||||
sim_io_spindle_state *state;
|
||||
if (!valid_spindle(io, spindle) || engaged > 1U) return SIM_IO_ERR_ARGUMENT;
|
||||
if (io->state.estop) { set_last(io, SIM_IO_ERR_ESTOP); return SIM_IO_ERR_ESTOP; }
|
||||
state = &io->state.spindles[spindle];
|
||||
state->brake = engaged;
|
||||
if (engaged) { state->command_rpm = 0.0; state->enabled = 0; state->speed_rpm = 0.0; state->forward = 0; state->reverse = 0; state->at_speed = 1; }
|
||||
set_last(io, SIM_IO_OK);
|
||||
mirror_pins(io);
|
||||
return SIM_IO_OK;
|
||||
}
|
||||
|
||||
int sim_io_spindle_set_inhibit(sim_io *io, uint32_t spindle, uint32_t inhibit) {
|
||||
if (!valid_spindle(io, spindle) || inhibit > 1U) return SIM_IO_ERR_ARGUMENT;
|
||||
io->state.spindles[spindle].inhibit = inhibit;
|
||||
|
||||
@@ -38,6 +38,8 @@ int main(void) {
|
||||
limit_status = sim_io_spindle_command(&io, 0, 100001.0, 1);
|
||||
assert(limit_status == SIM_IO_ERR_LIMIT);
|
||||
assert(sim_io_spindle_command(&io, 0, 1200.0, 1) == SIM_IO_OK);
|
||||
assert(sim_io_spindle_adjust(&io, 0, -100.0) == SIM_IO_OK && io.state.spindles[0].command_rpm == 1100.0);
|
||||
assert(sim_io_spindle_adjust(&io, 0, 100.0) == SIM_IO_OK && io.state.spindles[0].command_rpm == 1200.0);
|
||||
spindle_step_status = sim_io_step(&io, 10);
|
||||
assert(spindle_step_status == SIM_IO_OK && io.state.spindles[0].speed_rpm == 600.0);
|
||||
assert(sim_io_step(&io, 10) == SIM_IO_OK && io.state.spindles[0].at_speed == 1);
|
||||
@@ -51,6 +53,8 @@ int main(void) {
|
||||
assert(sim_io_tool_change(&io) == SIM_IO_OK);
|
||||
assert(sim_io_tool_set_changed(&io, 1) == SIM_IO_OK && io.state.current_tool == 7);
|
||||
|
||||
assert(sim_io_probe_arm(&io, 0) == SIM_IO_OK);
|
||||
assert(sim_io_probe_disarm(&io) == SIM_IO_OK && io.state.probe.state == SIM_IO_PROBE_IDLE);
|
||||
assert(sim_io_probe_arm(&io, 0) == SIM_IO_OK);
|
||||
probe_status = sim_io_probe_update(&io, &(sim_posemath_pose){{1.0, 2.0, 3.0}, 0, 0, 0, 0, 0, 0}, 1);
|
||||
assert(probe_status == SIM_IO_OK && io.state.probe.state == SIM_IO_PROBE_TRIPPED);
|
||||
@@ -66,6 +70,9 @@ int main(void) {
|
||||
assert(sim_io_set_power(&io, 0) == SIM_IO_OK && io.state.ready == 0);
|
||||
assert(sim_io_spindle_command(&io, 0, 100.0, 1) == SIM_IO_ERR_NOT_READY);
|
||||
assert(sim_io_set_power(&io, 1) == SIM_IO_OK && io.state.ready == 1 && io.state.recovery_epoch == 2);
|
||||
assert(sim_io_spindle_brake(&io, 0, 0) == SIM_IO_OK);
|
||||
assert(sim_io_spindle_command(&io, 0, 600.0, 1) == SIM_IO_OK);
|
||||
assert(sim_io_spindle_brake(&io, 0, 1) == SIM_IO_OK && io.state.spindles[0].brake == 1 && io.state.spindles[0].command_rpm == 0.0);
|
||||
|
||||
assert(sim_io_tool_set_fault(&io, 1, 42) == SIM_IO_OK);
|
||||
fault_clear_status = sim_io_tool_clear_fault(&io);
|
||||
|
||||
Reference in New Issue
Block a user