75 lines
1.8 KiB
C
75 lines
1.8 KiB
C
#ifndef LINUXCNC_WEB_WASM_SIM_INTERPRETER_H
|
|
#define LINUXCNC_WEB_WASM_SIM_INTERPRETER_H
|
|
|
|
#include <stdint.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
enum sim_interpreter_result {
|
|
SIM_INTERP_OK = 0,
|
|
SIM_INTERP_ERR_ARGUMENT = -500,
|
|
SIM_INTERP_ERR_NONFINITE = -501,
|
|
SIM_INTERP_ERR_SYNTAX = -502,
|
|
SIM_INTERP_ERR_RANGE = -503,
|
|
SIM_INTERP_ERR_UNKNOWN_CODE = -504,
|
|
SIM_INTERP_ERR_STATE = -505,
|
|
SIM_INTERP_ERR_BUFFER = -506,
|
|
};
|
|
|
|
enum sim_interpreter_units {
|
|
SIM_INTERP_UNITS_INCH = 20,
|
|
SIM_INTERP_UNITS_MM = 21,
|
|
};
|
|
|
|
enum sim_interpreter_distance_mode {
|
|
SIM_INTERP_ABSOLUTE = 90,
|
|
SIM_INTERP_INCREMENTAL = 91,
|
|
};
|
|
|
|
typedef struct sim_interpreter_state {
|
|
double x;
|
|
double y;
|
|
double z;
|
|
double a;
|
|
double b;
|
|
double c;
|
|
double u;
|
|
double v;
|
|
double w;
|
|
double feed;
|
|
double speed;
|
|
uint32_t line;
|
|
int units;
|
|
int distance_mode;
|
|
int plane;
|
|
int motion_mode;
|
|
int spindle_mode;
|
|
int program_end;
|
|
int status;
|
|
} sim_interpreter_state;
|
|
|
|
#define SIM_INTERPRETER_CANONICAL_CAPACITY 512u
|
|
|
|
typedef struct sim_interpreter {
|
|
sim_interpreter_state state;
|
|
uint64_t block_hash;
|
|
uint32_t canonical_length;
|
|
char canonical[SIM_INTERPRETER_CANONICAL_CAPACITY];
|
|
} sim_interpreter;
|
|
|
|
int sim_interpreter_init(sim_interpreter *interpreter);
|
|
int sim_interpreter_reset(sim_interpreter *interpreter);
|
|
int sim_interpreter_execute(sim_interpreter *interpreter, const char *block, uint32_t length);
|
|
int sim_interpreter_read_state(const sim_interpreter *interpreter, sim_interpreter_state *state);
|
|
uint32_t sim_interpreter_canonical(const sim_interpreter *interpreter, char *output, uint32_t capacity);
|
|
uint64_t sim_interpreter_state_hash(const sim_interpreter *interpreter);
|
|
uint64_t sim_interpreter_block_hash(const sim_interpreter *interpreter);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|