Complete XYZAC LinuxCNC WASM parity and smooth 3D preview

This commit is contained in:
2026-08-28 06:24:50 +08:00
parent e8fe323aab
commit 1a7995fa9b
181 changed files with 36854 additions and 215 deletions

View File

@@ -93,6 +93,8 @@ typedef struct sim_device_io {
double phase_accumulator[SIM_DEVICE_MAX_ENCODERS];
} sim_device_io;
uint32_t sim_device_io_size(void);
int sim_device_init(sim_device_io *device, uint32_t encoder_count, double cycle_time);
int sim_device_reset(sim_device_io *device);
int sim_device_encoder_set_speed(sim_device_io *device, uint32_t channel, double speed_rps);

View File

@@ -8,7 +8,7 @@ extern "C" {
#endif
#define SIM_EVENT_KIND_CAPACITY 32U
#define SIM_EVENT_CAPACITY 256U
#define SIM_EVENT_CAPACITY 16384U
enum sim_event_result {
SIM_EVENT_OK = 0,

View File

@@ -47,6 +47,7 @@ typedef struct sim_hal_value {
void sim_hal_reset(void);
int32_t sim_hal_register_pin(const char *name, uint32_t type);
int32_t sim_hal_set_pin(const char *name, sim_hal_value value);
int32_t sim_hal_set_pin_scalar(const char *name, uint32_t type, double value);
int32_t sim_hal_get_pin(const char *name, sim_hal_value *out);
int32_t sim_hal_connect(const char *source, const char *target);
int32_t sim_hal_register_thread(const char *name, uint32_t period_ticks);
@@ -54,6 +55,7 @@ int32_t sim_hal_register_function(const char *thread, const char *name);
/* Register a statically linked .comp component instance on a HAL thread. */
int32_t sim_hal_register_component(const char *instance, const char *type, const char *thread);
int32_t sim_hal_set_param(const char *name, sim_hal_value value);
int32_t sim_hal_set_param_scalar(const char *name, uint32_t type, double value);
int32_t sim_hal_get_param(const char *name, sim_hal_value *out);
uint32_t sim_hal_component_count(void);
uint32_t sim_hal_param_count(void);

View File

@@ -111,6 +111,8 @@ typedef struct sim_io {
uint32_t pins_registered;
} sim_io;
uint32_t sim_io_size(void);
int sim_io_init(sim_io *io, uint32_t spindle_count, uint32_t tool_capacity,
double cycle_time, double spindle_accel_rpm_s,
double spindle_tolerance_rpm);

View File

@@ -0,0 +1,94 @@
#ifndef LINUXCNC_WEB_WASM_SIM_PROGRAM_H
#define LINUXCNC_WEB_WASM_SIM_PROGRAM_H
#include "sim_interpreter.h"
#ifdef __cplusplus
extern "C" {
#endif
#define SIM_PROGRAM_SOURCE_CAPACITY 131072u
#define SIM_PROGRAM_LINE_CAPACITY 4096u
#define SIM_PROGRAM_CANONICAL_CAPACITY 4096u
#define SIM_PROGRAM_SUBROUTINE_CAPACITY 16u
#define SIM_PROGRAM_SUBROUTINE_NAME_CAPACITY 48u
#define SIM_PROGRAM_CALL_DEPTH 8u
#define SIM_PROGRAM_CALL_PARAMETER_CAPACITY 30u
enum sim_program_result {
SIM_PROGRAM_OK = 0,
SIM_PROGRAM_ERR_ARGUMENT = -1100,
SIM_PROGRAM_ERR_RANGE = -1101,
SIM_PROGRAM_ERR_STATE = -1102,
SIM_PROGRAM_ERR_CONTROL = -1103,
SIM_PROGRAM_ERR_BUFFER = -1104,
SIM_PROGRAM_ERR_INTERPRETER = -1105,
};
enum sim_program_status {
SIM_PROGRAM_IDLE = 0,
SIM_PROGRAM_LOADED = 1,
SIM_PROGRAM_RUNNING = 2,
SIM_PROGRAM_PAUSED = 3,
SIM_PROGRAM_COMPLETED = 4,
SIM_PROGRAM_ABORTED = 5,
SIM_PROGRAM_ERROR = 6,
};
typedef struct sim_program_subroutine {
char name[SIM_PROGRAM_SUBROUTINE_NAME_CAPACITY];
uint32_t body_line;
uint32_t end_line;
} sim_program_subroutine;
typedef struct sim_program_call_frame {
uint32_t return_line;
double parameters[SIM_PROGRAM_CALL_PARAMETER_CAPACITY];
} sim_program_call_frame;
typedef struct sim_program {
sim_interpreter interpreter;
char source[SIM_PROGRAM_SOURCE_CAPACITY];
uint32_t line_offsets[SIM_PROGRAM_LINE_CAPACITY + 1u];
uint32_t source_length;
uint32_t line_count;
uint32_t main_line_count;
uint32_t current_line;
uint32_t status;
int32_t last_error;
uint32_t error_line;
sim_posemath_segment motion;
uint32_t has_motion;
sim_program_subroutine subroutines[SIM_PROGRAM_SUBROUTINE_CAPACITY];
uint32_t subroutine_count;
sim_program_call_frame call_stack[SIM_PROGRAM_CALL_DEPTH];
uint32_t call_depth;
uint32_t has_control;
int32_t control_code;
double rapid_velocity;
} sim_program;
uint32_t sim_program_size(void);
int32_t sim_program_requires_subroutines(const char *source, uint32_t length);
int32_t sim_program_init(sim_program *program);
int32_t sim_program_reset(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_start(sim_program *program);
int32_t sim_program_pause(sim_program *program);
int32_t sim_program_resume(sim_program *program);
int32_t sim_program_abort(sim_program *program);
int32_t sim_program_step(sim_program *program);
int32_t sim_program_execute_block(sim_program *program, const char *block, uint32_t length);
int32_t sim_program_seek(sim_program *program, uint32_t line);
int32_t sim_program_read_motion(const sim_program *program, sim_posemath_segment *segment);
int32_t sim_program_clear_motion(sim_program *program);
uint32_t sim_program_canonical(const sim_program *program, char *output, uint32_t capacity);
uint64_t sim_program_state_hash(const sim_program *program);
#ifdef __cplusplus
}
#endif
#endif