143 lines
4.4 KiB
C
143 lines
4.4 KiB
C
#ifndef LINUXCNC_WEB_WASM_SIM_TASK_H
|
|
#define LINUXCNC_WEB_WASM_SIM_TASK_H
|
|
|
|
#include <stdint.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define SIM_TASK_SCHEMA_VERSION 1U
|
|
#define SIM_TASK_CONTEXT_CAPACITY 128U
|
|
#define SIM_TASK_SESSION_CAPACITY 128U
|
|
#define SIM_TASK_CANONICAL_CAPACITY 512U
|
|
#define SIM_TASK_NO_LINE UINT32_MAX
|
|
|
|
enum sim_task_result {
|
|
SIM_TASK_OK = 0,
|
|
SIM_TASK_ERR_ARGUMENT = -1000,
|
|
SIM_TASK_ERR_STATE = -1001,
|
|
SIM_TASK_ERR_TRANSITION = -1002,
|
|
SIM_TASK_ERR_SEQUENCE = -1003,
|
|
SIM_TASK_ERR_TICK = -1004,
|
|
SIM_TASK_ERR_RANGE = -1005,
|
|
SIM_TASK_ERR_NONFINITE = -1006,
|
|
SIM_TASK_ERR_BUFFER = -1007,
|
|
SIM_TASK_ERR_DESTROYED = -1008,
|
|
};
|
|
|
|
enum sim_task_state_value {
|
|
SIM_TASK_NEW = 0,
|
|
SIM_TASK_READY = 1,
|
|
SIM_TASK_RUNNING = 2,
|
|
SIM_TASK_PAUSED = 3,
|
|
SIM_TASK_ESTOP = 4,
|
|
SIM_TASK_FAULT = 5,
|
|
SIM_TASK_STOPPED = 6,
|
|
SIM_TASK_DESTROYED = 7,
|
|
};
|
|
|
|
enum sim_task_mode_value {
|
|
SIM_TASK_MODE_MANUAL = 0,
|
|
SIM_TASK_MODE_MDI = 1,
|
|
SIM_TASK_MODE_AUTO = 2,
|
|
};
|
|
|
|
enum sim_task_program_value {
|
|
SIM_TASK_PROGRAM_IDLE = 0,
|
|
SIM_TASK_PROGRAM_LOADED = 1,
|
|
SIM_TASK_PROGRAM_RUNNING = 2,
|
|
SIM_TASK_PROGRAM_PAUSED = 3,
|
|
SIM_TASK_PROGRAM_COMPLETED = 4,
|
|
SIM_TASK_PROGRAM_ABORTED = 5,
|
|
SIM_TASK_PROGRAM_FAULT = 6,
|
|
};
|
|
|
|
/* LinuxCNC emctaskmain command classes used by the Web XYZAC surface. */
|
|
enum sim_task_gate_command {
|
|
SIM_TASK_GATE_ESTOP = 1,
|
|
SIM_TASK_GATE_RESET = 2,
|
|
SIM_TASK_GATE_POWER = 3,
|
|
SIM_TASK_GATE_HOME = 4,
|
|
SIM_TASK_GATE_JOG = 5,
|
|
SIM_TASK_GATE_MDI = 6,
|
|
SIM_TASK_GATE_RUN = 7,
|
|
SIM_TASK_GATE_PAUSE = 8,
|
|
SIM_TASK_GATE_RESUME = 9,
|
|
SIM_TASK_GATE_ABORT = 10,
|
|
SIM_TASK_GATE_RESTART = 11,
|
|
SIM_TASK_GATE_KINEMATICS = 12,
|
|
SIM_TASK_GATE_SET_MODE = 13,
|
|
SIM_TASK_GATE_PROGRAM_LOAD = 14,
|
|
SIM_TASK_GATE_STEP = 15,
|
|
};
|
|
|
|
enum sim_task_gate_result {
|
|
SIM_TASK_GATE_ALLOWED = 0,
|
|
SIM_TASK_GATE_ESTOP_ACTIVE = 1,
|
|
SIM_TASK_GATE_MACHINE_OFF = 2,
|
|
SIM_TASK_GATE_MACHINE_ON = 3,
|
|
SIM_TASK_GATE_INTERP_ACTIVE = 4,
|
|
SIM_TASK_GATE_TASKFILE_MISSING = 5,
|
|
SIM_TASK_GATE_ESTOPOFF_REQUIRED = 6,
|
|
SIM_TASK_GATE_PAUSE_STATE = 7,
|
|
SIM_TASK_GATE_RESUME_STATE = 8,
|
|
SIM_TASK_GATE_ABORT_STATE = 9,
|
|
SIM_TASK_GATE_RESTART_STATE = 10,
|
|
SIM_TASK_GATE_KINEMATICS_INVALID = 11,
|
|
SIM_TASK_GATE_MODE_STATE = 12,
|
|
SIM_TASK_GATE_MODE_AUTO_ACTIVE = 13,
|
|
SIM_TASK_GATE_JOG_STATE = 14,
|
|
SIM_TASK_GATE_MDI_STATE = 15,
|
|
SIM_TASK_GATE_RESET_STATE = 16,
|
|
SIM_TASK_GATE_UNKNOWN_COMMAND = 17,
|
|
SIM_TASK_GATE_UNHOMED = 18,
|
|
};
|
|
|
|
typedef struct sim_task_state {
|
|
char context_id[SIM_TASK_CONTEXT_CAPACITY];
|
|
char session_id[SIM_TASK_SESSION_CAPACITY];
|
|
uint32_t state;
|
|
uint32_t mode;
|
|
uint32_t program_status;
|
|
uint32_t seq;
|
|
uint32_t simulation_tick;
|
|
uint32_t current_line;
|
|
int32_t last_error;
|
|
} sim_task_state;
|
|
|
|
typedef struct sim_task {
|
|
sim_task_state state;
|
|
} sim_task;
|
|
|
|
uint32_t sim_task_size(void);
|
|
int32_t sim_task_init(sim_task *task, const char *context_id, const char *session_id);
|
|
int32_t sim_task_reset(sim_task *task);
|
|
int32_t sim_task_attach(sim_task *task);
|
|
int32_t sim_task_set_command(sim_task *task, uint32_t seq, uint32_t simulation_tick);
|
|
int32_t sim_task_set_tick(sim_task *task, uint32_t simulation_tick);
|
|
int32_t sim_task_set_mode(sim_task *task, uint32_t mode);
|
|
int32_t sim_task_set_program(sim_task *task, uint32_t program_status, uint32_t current_line);
|
|
int32_t sim_task_transition(sim_task *task, uint32_t state);
|
|
int32_t sim_task_fault(sim_task *task, int32_t error_code);
|
|
int32_t sim_task_estop(sim_task *task, int32_t error_code);
|
|
int32_t sim_task_recover(sim_task *task);
|
|
int32_t sim_task_command_gate(const sim_task *task, uint32_t command,
|
|
uint32_t requested, uint32_t io_ready,
|
|
uint32_t io_estop, uint32_t homed,
|
|
uint32_t queue_depth,
|
|
uint32_t queue_limit);
|
|
int32_t sim_task_restore(sim_task *task, uint32_t state, uint32_t mode,
|
|
uint32_t program_status, uint32_t seq,
|
|
uint32_t simulation_tick, uint32_t current_line,
|
|
int32_t error_code);
|
|
int32_t sim_task_read_state(const sim_task *task, sim_task_state *out);
|
|
uint32_t sim_task_canonical(const sim_task *task, char *output, uint32_t capacity);
|
|
uint64_t sim_task_state_hash(const sim_task *task);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|