同步五轴仿真文档和验证证据
This commit is contained in:
@@ -14,6 +14,7 @@ enum {
|
||||
LCMOT_CMD_CIRCULAR_MOVE,
|
||||
LCMOT_CMD_JOG_INCR,
|
||||
LCMOT_CMD_PAUSE,
|
||||
LCMOT_CMD_STEP,
|
||||
LCMOT_CMD_RESUME,
|
||||
LCMOT_CMD_ABORT,
|
||||
LCMOT_CMD_SET_AOUT,
|
||||
@@ -265,6 +266,9 @@ static void apply_command(const LcmotCommand *command)
|
||||
state->motion_type = 0;
|
||||
state->in_position = 0;
|
||||
break;
|
||||
case LCMOT_CMD_STEP:
|
||||
state->paused = 0;
|
||||
break;
|
||||
case LCMOT_CMD_RESUME:
|
||||
state->paused = 0;
|
||||
break;
|
||||
@@ -366,6 +370,8 @@ int lcmot_write_command_json(const char *json)
|
||||
command.type = LCMOT_CMD_JOG_INCR;
|
||||
} else if (contains_token(json, "EMC_TRAJ_PAUSE") || contains_token(json, "EMCMOT_PAUSE")) {
|
||||
command.type = LCMOT_CMD_PAUSE;
|
||||
} else if (contains_token(json, "EMC_TRAJ_STEP") || contains_token(json, "EMCMOT_STEP")) {
|
||||
command.type = LCMOT_CMD_STEP;
|
||||
} else if (contains_token(json, "EMC_TRAJ_RESUME") || contains_token(json, "EMCMOT_RESUME")) {
|
||||
command.type = LCMOT_CMD_RESUME;
|
||||
} else if (contains_token(json, "EMC_TRAJ_ABORT") || contains_token(json, "EMCMOT_ABORT")) {
|
||||
@@ -390,6 +396,7 @@ int lcmot_step_servo(long period_ns, int cycles)
|
||||
if (!lcmot_state.aborted && lcmot_state.queue_count > 0) {
|
||||
command = lcmot_state.queue[lcmot_state.queue_head];
|
||||
if (!lcmot_state.paused ||
|
||||
command.type == LCMOT_CMD_STEP ||
|
||||
command.type == LCMOT_CMD_RESUME ||
|
||||
command.type == LCMOT_CMD_ABORT) {
|
||||
queue_pop(&command);
|
||||
|
||||
@@ -32,6 +32,8 @@ struct TaskRuntime {
|
||||
std::string mode = "MANUAL";
|
||||
std::string interp_state = "IDLE";
|
||||
std::string exec_state = "DONE";
|
||||
bool task_paused = false;
|
||||
bool single_stepping = false;
|
||||
std::string open_program;
|
||||
int opened_line_count = 0;
|
||||
int opened_source_line_count = 0;
|
||||
@@ -478,6 +480,8 @@ std::string status_json()
|
||||
out << ",\"mode\":\"" << json_escape(state.mode) << "\"";
|
||||
out << ",\"interpState\":\"" << json_escape(state.interp_state) << "\"";
|
||||
out << ",\"execState\":\"" << json_escape(state.exec_state) << "\"";
|
||||
out << ",\"taskPaused\":" << (state.task_paused ? "true" : "false");
|
||||
out << ",\"singleStepping\":" << (state.single_stepping ? "true" : "false");
|
||||
out << ",\"cycle\":" << state.task_cycle;
|
||||
out << ",\"openProgram\":\"" << json_escape(state.open_program) << "\"";
|
||||
out << ",\"openedLineCount\":" << state.opened_line_count;
|
||||
@@ -614,24 +618,42 @@ int lctask_send_command_json(const char *command_json)
|
||||
state.run_elapsed_seconds = 0.0;
|
||||
state.interp_state = "READING";
|
||||
state.exec_state = "WAITING_FOR_MOTION";
|
||||
state.task_paused = false;
|
||||
state.single_stepping = false;
|
||||
state.events.push_back("task_plan_run");
|
||||
return 0;
|
||||
}
|
||||
if (contains_token(command_json, "EMC_TASK_PLAN_PAUSE")) {
|
||||
state.interp_state = "PAUSED";
|
||||
state.exec_state = "PAUSED";
|
||||
state.task_paused = true;
|
||||
state.events.push_back("task_plan_pause");
|
||||
return forward_motion_command("{\"type\":\"EMC_TRAJ_PAUSE\"}");
|
||||
}
|
||||
if (contains_token(command_json, "EMC_TASK_PLAN_STEP")) {
|
||||
state.single_stepping = true;
|
||||
state.task_paused = true;
|
||||
if (state.interp_state == "PAUSED") {
|
||||
state.interp_state = "READING";
|
||||
}
|
||||
state.exec_state = "WAITING_FOR_MOTION";
|
||||
state.events.push_back("task_plan_step");
|
||||
forward_motion_command("{\"type\":\"EMC_TRAJ_STEP\"}");
|
||||
return 0;
|
||||
}
|
||||
if (contains_token(command_json, "EMC_TASK_PLAN_RESUME")) {
|
||||
state.interp_state = "READING";
|
||||
state.exec_state = "WAITING_FOR_MOTION";
|
||||
state.task_paused = false;
|
||||
state.single_stepping = false;
|
||||
state.events.push_back("task_plan_resume");
|
||||
return forward_motion_command("{\"type\":\"EMC_TRAJ_RESUME\"}");
|
||||
}
|
||||
if (contains_token(command_json, "EMC_TASK_ABORT")) {
|
||||
state.interp_state = "IDLE";
|
||||
state.exec_state = "DONE";
|
||||
state.task_paused = false;
|
||||
state.single_stepping = false;
|
||||
state.run_elapsed_seconds = 0.0;
|
||||
state.events.push_back("task_abort");
|
||||
return forward_motion_command("{\"type\":\"EMC_TRAJ_ABORT\"}");
|
||||
@@ -640,6 +662,7 @@ int lctask_send_command_json(const char *command_json)
|
||||
state.mode = "MDI";
|
||||
state.interp_state = "READING";
|
||||
state.exec_state = "WAITING_FOR_MOTION";
|
||||
state.task_paused = false;
|
||||
enqueue_mdi(state, command_json);
|
||||
return 0;
|
||||
}
|
||||
@@ -647,6 +670,7 @@ int lctask_send_command_json(const char *command_json)
|
||||
state.mode = "MANUAL";
|
||||
state.interp_state = "IDLE";
|
||||
state.exec_state = "WAITING_FOR_MOTION";
|
||||
state.task_paused = false;
|
||||
state.events.push_back("task_jog_incr");
|
||||
return forward_motion_command(command_json);
|
||||
}
|
||||
@@ -654,6 +678,8 @@ int lctask_send_command_json(const char *command_json)
|
||||
state.mode = "MANUAL";
|
||||
state.interp_state = "IDLE";
|
||||
state.exec_state = "DONE";
|
||||
state.task_paused = false;
|
||||
state.single_stepping = false;
|
||||
state.next_program_line = 0;
|
||||
state.active_segment_index = 0;
|
||||
state.run_elapsed_seconds = 0.0;
|
||||
@@ -693,8 +719,15 @@ int lctask_run_cycles(long task_period_ns, long servo_period_ns, int task_cycles
|
||||
if (!state.motion_plan_loaded && state.next_program_line >= state.executable_line_count) {
|
||||
state.interp_state = "IDLE";
|
||||
state.exec_state = "DONE";
|
||||
state.task_paused = false;
|
||||
state.single_stepping = false;
|
||||
state.events.push_back("task_plan_complete");
|
||||
}
|
||||
if (state.single_stepping) {
|
||||
state.interp_state = "PAUSED";
|
||||
state.exec_state = "PAUSED";
|
||||
state.task_paused = true;
|
||||
}
|
||||
}
|
||||
if (lcmot_step_servo(servo_period_ns, servo_per_task) != 0) {
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user