Align AXIS Web control lifecycle with LinuxCNC
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user