Align AXIS Web control lifecycle with LinuxCNC
This commit is contained in:
@@ -295,7 +295,7 @@ if(EMSCRIPTEN)
|
||||
)
|
||||
get_target_property(_sim_module_link_flags sim_core_module LINK_FLAGS)
|
||||
string(REPLACE "_sim_task_recover','_sim_task_restore" "_sim_task_recover','_sim_task_command_gate','_sim_task_restore" _sim_module_link_flags "${_sim_module_link_flags}")
|
||||
string(REPLACE "_sim_interpreter_size" "_sim_program_size','_sim_program_requires_subroutines','_sim_program_init','_sim_program_reset','_sim_program_destroy','_sim_program_load','_sim_program_add_subroutine','_sim_program_set_rapid_velocity','_sim_program_start','_sim_program_pause','_sim_program_resume','_sim_program_abort','_sim_program_step','_sim_program_execute_block','_sim_program_seek','_sim_program_read_motion','_sim_program_clear_motion','_sim_program_canonical','_sim_program_state_hash','_sim_interpreter_size" _sim_module_link_flags "${_sim_module_link_flags}")
|
||||
string(REPLACE "_sim_interpreter_size" "_sim_program_size','_sim_program_requires_subroutines','_sim_program_init','_sim_program_reset','_sim_program_destroy','_sim_program_load','_sim_program_add_subroutine','_sim_program_set_rapid_velocity','_sim_program_set_position','_sim_program_start','_sim_program_pause','_sim_program_resume','_sim_program_abort','_sim_program_step','_sim_program_execute_block','_sim_program_seek','_sim_program_read_motion','_sim_program_clear_motion','_sim_program_canonical','_sim_program_state_hash','_sim_interpreter_size" _sim_module_link_flags "${_sim_module_link_flags}")
|
||||
string(REPLACE "_sim_kinematics_switch_select','_sim_kinematics_switch_forward" "_sim_kinematics_switch_select','_sim_kinematics_switch_select_physical','_sim_kinematics_switch_forward" _sim_module_link_flags "${_sim_module_link_flags}")
|
||||
string(REPLACE "_sim_kinematics_switch_inverse','_sim_kinematics_switch_active" "_sim_kinematics_switch_inverse','_sim_kinematics_switch_inverse_mode','_sim_kinematics_switch_active" _sim_module_link_flags "${_sim_module_link_flags}")
|
||||
string(REPLACE "_sim_motion_init" "_sim_motion_set_profile','_sim_motion_set_lookahead','_sim_motion_set_dynamics','_sim_motion_set_feed_override','_sim_motion_set_paused','_sim_motion_peek','_sim_motion_init" _sim_module_link_flags "${_sim_module_link_flags}")
|
||||
|
||||
@@ -89,6 +89,7 @@ void sim_program_destroy(sim_program *program);
|
||||
int32_t sim_program_load(sim_program *program, const char *source, uint32_t length);
|
||||
int32_t sim_program_add_subroutine(sim_program *program, const char *source, uint32_t length);
|
||||
int32_t sim_program_set_rapid_velocity(sim_program *program, double velocity);
|
||||
int32_t sim_program_set_position(sim_program *program, const sim_posemath_pose *position);
|
||||
int32_t sim_program_start(sim_program *program);
|
||||
int32_t sim_program_pause(sim_program *program);
|
||||
int32_t sim_program_resume(sim_program *program);
|
||||
|
||||
@@ -367,9 +367,46 @@ int32_t sim_program_set_rapid_velocity(sim_program *program, double velocity) {
|
||||
return SIM_PROGRAM_OK;
|
||||
}
|
||||
|
||||
int32_t sim_program_set_position(sim_program *program, const sim_posemath_pose *position) {
|
||||
const double *values;
|
||||
size_t index;
|
||||
if (program == NULL || position == NULL || program->status == SIM_PROGRAM_IDLE) return SIM_PROGRAM_ERR_ARGUMENT;
|
||||
values = &position->tran.x;
|
||||
for (index = 0; index < 9; ++index) if (!isfinite(values[index])) return SIM_PROGRAM_ERR_RANGE;
|
||||
program->interpreter.state.x = position->tran.x;
|
||||
program->interpreter.state.y = position->tran.y;
|
||||
program->interpreter.state.z = position->tran.z;
|
||||
program->interpreter.state.a = position->a;
|
||||
program->interpreter.state.b = position->b;
|
||||
program->interpreter.state.c = position->c;
|
||||
program->interpreter.state.u = position->u;
|
||||
program->interpreter.state.v = position->v;
|
||||
program->interpreter.state.w = position->w;
|
||||
program->interpreter.state.status = SIM_INTERP_OK;
|
||||
return SIM_PROGRAM_OK;
|
||||
}
|
||||
|
||||
int32_t sim_program_start(sim_program *program) {
|
||||
if (program == NULL || program->status == SIM_PROGRAM_IDLE) return SIM_PROGRAM_ERR_STATE;
|
||||
if (program->status == SIM_PROGRAM_COMPLETED || program->status == SIM_PROGRAM_ABORTED) return SIM_PROGRAM_ERR_STATE;
|
||||
/* LinuxCNC EMC_TASK_PLAN_RUN reopens the current task file after an M2/
|
||||
end-of-file or task abort, then starts again at the requested line
|
||||
(AXIS uses line zero for the normal Run button). Preserve the current
|
||||
interpreter position/offset state as the task-plan synchronization
|
||||
point, but rewind file/control execution before accepting AUTO_RUN. */
|
||||
if (program->status == SIM_PROGRAM_COMPLETED || program->status == SIM_PROGRAM_ABORTED) {
|
||||
program->current_line = 0;
|
||||
program->last_error = 0;
|
||||
program->error_line = 0;
|
||||
program->has_motion = 0;
|
||||
program->call_depth = 0;
|
||||
program->has_control = 0;
|
||||
program->control_code = 0;
|
||||
program->interpreter.state.line = 0;
|
||||
program->interpreter.state.program_end = 0;
|
||||
program->interpreter.state.status = SIM_INTERP_OK;
|
||||
memset(&program->motion, 0, sizeof(program->motion));
|
||||
memset(program->call_stack, 0, sizeof(program->call_stack));
|
||||
}
|
||||
program->status = SIM_PROGRAM_RUNNING;
|
||||
return SIM_PROGRAM_OK;
|
||||
}
|
||||
|
||||
@@ -95,6 +95,14 @@ int main(void) {
|
||||
}
|
||||
}
|
||||
assert(have_arc && arc.turn == -3);
|
||||
assert(program.status == SIM_PROGRAM_COMPLETED);
|
||||
assert(sim_program_start(&program) == SIM_PROGRAM_OK);
|
||||
assert(program.status == SIM_PROGRAM_RUNNING && program.current_line == 0);
|
||||
assert(program.interpreter.state.program_end == 0);
|
||||
assert(sim_program_step(&program) == SIM_PROGRAM_OK);
|
||||
assert(sim_program_abort(&program) == SIM_PROGRAM_OK);
|
||||
assert(sim_program_start(&program) == SIM_PROGRAM_OK);
|
||||
assert(program.status == SIM_PROGRAM_RUNNING && program.current_line == 0);
|
||||
|
||||
saved_switcher = switcher;
|
||||
saved_pose = pose;
|
||||
|
||||
Reference in New Issue
Block a user