Document source UI gates, explicit native live-plot clearing, and remaining parity boundaries. Fix pause/resume transport continuity, repeated stepping, coordinate previews, and spindle override state. Optimize large program snapshots and rendering, and cover the control flows with native Tcl, WASM, and browser checks. Validation: 22 native tests and source/browser checks pass. Worker/App regression: 113 of 123 pass; 10 pre-existing failures remain documented with no new failures.
47 lines
2.8 KiB
C
47 lines
2.8 KiB
C
#include "sim_protocol.h"
|
|
|
|
#include <assert.h>
|
|
#include <stddef.h>
|
|
|
|
int main(void) {
|
|
sim_protocol_reset();
|
|
assert(sim_protocol_state_value() == SIM_PROTOCOL_NEW);
|
|
assert(sim_protocol_accept(1, 1, "HELLO", NULL, 0) == SIM_PROTOCOL_OK);
|
|
assert(sim_protocol_accept(1, 3, "SESSION_ATTACH", NULL, 0) == SIM_PROTOCOL_ERR_SEQUENCE);
|
|
assert(sim_protocol_accept(1, 2, "SESSION_ATTACH", NULL, 0) == SIM_PROTOCOL_OK);
|
|
assert(sim_protocol_state_value() == SIM_PROTOCOL_READY);
|
|
assert(sim_protocol_accept(1, 3, "MDI_EXECUTE", NULL, 0) == SIM_PROTOCOL_ERR_OPERATION_ID);
|
|
assert(sim_protocol_accept(1, 3, "MDI_EXECUTE", "op-3", 2) == SIM_PROTOCOL_OK);
|
|
assert(sim_protocol_accept(1, 4, "RESET", "reset-machine", 2) == SIM_PROTOCOL_OK);
|
|
assert(sim_protocol_last_seq() == 4);
|
|
assert(sim_protocol_accept(1, 5, "PROGRAM_PAUSE", "op-4", 2) == SIM_PROTOCOL_OK);
|
|
assert(sim_protocol_accept(1, 6, "SIM_STEP", "op-5-step", 2) == SIM_PROTOCOL_OK);
|
|
/* These are connected-channel frames. MDI can still be rejected by
|
|
the task; the transport must not poison subsequent command IDs. */
|
|
const char *paused_commands[] = {"VISUAL_CLEAR", "SET_SPINDLE_OVERRIDE", "SET_MAX_VELOCITY", "PROGRAM_STEP", "MDI_EXECUTE", "PROGRAM_PAUSE"};
|
|
uint32_t seq = 7;
|
|
for (unsigned int i = 0; i < sizeof(paused_commands) / sizeof(paused_commands[0]); ++i) {
|
|
assert(sim_protocol_accept(1, seq, paused_commands[i], "paused-op", 2) == SIM_PROTOCOL_OK);
|
|
assert(sim_protocol_last_seq() == seq++);
|
|
assert(sim_protocol_state_value() == SIM_PROTOCOL_PAUSED);
|
|
}
|
|
assert(sim_protocol_accept(1, seq + 1, "PROGRAM_RESUME", "resume-gap", 2) == SIM_PROTOCOL_ERR_SEQUENCE);
|
|
assert(sim_protocol_last_seq() == seq - 1);
|
|
assert(sim_protocol_accept(1, seq, "MDI_EXECUTE", NULL, 2) == SIM_PROTOCOL_ERR_OPERATION_ID);
|
|
assert(sim_protocol_accept(1, seq++, "PROGRAM_RESUME", "resume", 2) == SIM_PROTOCOL_OK);
|
|
assert(sim_protocol_state_value() == SIM_PROTOCOL_READY);
|
|
assert(sim_protocol_accept(1, seq++, "PROGRAM_PAUSE", "pause-again", 2) == SIM_PROTOCOL_OK);
|
|
assert(sim_protocol_accept(1, seq++, "PROGRAM_ABORT", "abort", 2) == SIM_PROTOCOL_OK);
|
|
assert(sim_protocol_state_value() == SIM_PROTOCOL_READY);
|
|
assert(sim_protocol_accept(2, seq, "PING", NULL, 2) == SIM_PROTOCOL_ERR_SCHEMA);
|
|
assert(sim_protocol_accept(1, seq, "PING", NULL, 1) == SIM_PROTOCOL_ERR_TICK);
|
|
assert(sim_protocol_accept(1, seq++, "DESTROY", NULL, 2) == SIM_PROTOCOL_OK);
|
|
assert(sim_protocol_accept(1, seq, "PING", NULL, 2) == SIM_PROTOCOL_ERR_STATE);
|
|
assert(sim_protocol_accept(1, seq, "RESET", "reset-1", 2) == SIM_PROTOCOL_OK);
|
|
assert(sim_protocol_state_value() == SIM_PROTOCOL_NEW);
|
|
assert(sim_protocol_last_seq() == 0);
|
|
assert(sim_protocol_set_tick(4) == SIM_PROTOCOL_OK);
|
|
assert(sim_protocol_set_tick(3) == SIM_PROTOCOL_ERR_TICK);
|
|
return 0;
|
|
}
|