Make machine configuration authoritative and restore native checkpoints exactly
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { fnv1a64 } from "./replay.mjs";
|
||||
import { WEB_SETTINGS } from "../workspace/web-settings.mjs";
|
||||
|
||||
const DEVICE_SCHEMA = "wasm_xyzac_device_io.v1";
|
||||
const DEVICE_ERROR_REASONS = Object.freeze({
|
||||
@@ -42,7 +43,7 @@ function operationNumber(value) {
|
||||
}
|
||||
|
||||
export class WasmXyzacDeviceIo {
|
||||
constructor(core, { encoderCount = 2 } = {}) {
|
||||
constructor(core, { encoderCount = WEB_SETTINGS.runtime.io.encoder_count, cycleTime = WEB_SETTINGS.runtime.io.cycle_time } = {}) {
|
||||
this.core = core;
|
||||
this.available = ["sim_device_io_size", "sim_device_init", "sim_device_canonical", "sim_device_state_hash"].every((name) => typeof core?.[`_${name}`] === "function" || typeof core?.[name] === "function");
|
||||
this.pointer = 0;
|
||||
@@ -50,7 +51,7 @@ export class WasmXyzacDeviceIo {
|
||||
const size = call(core, "sim_device_io_size", "number", [], []);
|
||||
this.pointer = core._malloc(size);
|
||||
if (!this.pointer) throw new Error("wasm_xyzac_device_io_allocation_failed");
|
||||
const result = call(core, "sim_device_init", "number", ["number", "number", "number"], [this.pointer, encoderCount, 0.01]);
|
||||
const result = call(core, "sim_device_init", "number", ["number", "number", "number"], [this.pointer, encoderCount, cycleTime]);
|
||||
if (result !== 0) throw new Error(`wasm_xyzac_device_io_init_${result}`);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user