接入L4-TOOL-DB节点运行时
结论:ToolDbProcessPort 已可通过 Node/native adapter 真实执行 LinuxCNC DB_PROGRAM 协议,浏览器端仍保持锁定直到 Python/WASM Worker 接入。
This commit is contained in:
@@ -35,6 +35,17 @@ assert.equal(jsonWorkflow.report.reportVersion, 1);
|
||||
assert.equal(jsonWorkflow.report.ready, true);
|
||||
assert.equal(jsonWorkflow.report.capabilityMatrix.ready, true);
|
||||
assert.deepEqual(jsonWorkflow.report.capabilityMatrix.capabilityTypes, ["workflow", "api", "gate"]);
|
||||
assert.equal(jsonWorkflow.report.capabilityMatrix.capabilityCount, 5);
|
||||
assert.equal(jsonWorkflow.report.capabilityMatrix.acceptedCount, 5);
|
||||
assert.equal(
|
||||
jsonWorkflow.report.capabilityMatrix.capabilities.some(
|
||||
(capability) =>
|
||||
capability.id === "tool-db-node-runtime-adapter" &&
|
||||
capability.evidence === "tool_db_node_runtime_adapter=ok" &&
|
||||
capability.command === "wasm-port/tests/sdk/node/verify_tool_db_node_runtime_adapter.sh",
|
||||
),
|
||||
true,
|
||||
);
|
||||
assert.equal(jsonWorkflow.report.workflow.ready, true);
|
||||
assert.equal(jsonWorkflow.report.workflow.virtualHalSimConfigSourceCoverageReady, true);
|
||||
assert.equal(jsonWorkflow.report.workflow.virtualHalMotionControllerMatrixReady, true);
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { resolve } from "node:path";
|
||||
|
||||
import {
|
||||
createLinuxCncToolDbProcessPort,
|
||||
createToolDbProcessDiagnostics,
|
||||
validateToolDbTranscript,
|
||||
} from "../../../runtime/sdk/src/tool-db-process-port.js";
|
||||
import {
|
||||
createLinuxCncToolDbNodeRuntimeAdapter,
|
||||
} from "../../../runtime/sdk/src/tool-db-node-runtime-adapter.js";
|
||||
|
||||
const adapter = createLinuxCncToolDbNodeRuntimeAdapter({
|
||||
dbSavefile: resolve("wasm-port/build/native/tool-db-runtime/sdk-node-runtime-adapter-db-nonran"),
|
||||
stdoutLog: resolve("wasm-port/build/native/tool-db-runtime/sdk-node-runtime-adapter.stdout.log"),
|
||||
stderrLog: resolve("wasm-port/build/native/tool-db-runtime/sdk-node-runtime-adapter.stderr.log"),
|
||||
});
|
||||
|
||||
const port = createLinuxCncToolDbProcessPort({
|
||||
dbProgramPath: "./db_nonran.py",
|
||||
sourceFiles: [
|
||||
"configs/sim/axis/db_demo/db_nonran.py",
|
||||
"configs/sim/axis/db_demo/db.py",
|
||||
"lib/python/tooldb.py",
|
||||
],
|
||||
runtimeMode: adapter.runtimeMode,
|
||||
runtimeAdapter: adapter,
|
||||
});
|
||||
|
||||
const startResult = await port.start();
|
||||
assert.equal(startResult.runtimeMode, "node-linuxcnc-db-program");
|
||||
assert.equal(startResult.runtimeExecutionReady, true);
|
||||
assert.equal(startResult.executionEnabled, false);
|
||||
assert.equal(startResult.promotionAllowed, false);
|
||||
|
||||
const planResult = await port.runTransactionPlan();
|
||||
assert.equal(planResult.status, "runtime_adapter_transaction_plan_executed");
|
||||
assert.equal(planResult.runtimeExecutionReady, true);
|
||||
assert.equal(planResult.executionEnabled, false);
|
||||
assert.equal(planResult.promotionAllowed, false);
|
||||
assert.equal(planResult.tblFallbackSufficient, false);
|
||||
|
||||
await port.writeLine("t 14");
|
||||
const t14AfterUnload = await port.readLine();
|
||||
assert.match(t14AfterUnload, /^T14 /);
|
||||
assert.match(t14AfterUnload, /P114\b/);
|
||||
|
||||
const transcript = port.exportTranscript();
|
||||
const validation = validateToolDbTranscript(transcript);
|
||||
assert.equal(validation.ready, true);
|
||||
assert.equal(transcript.some((entry) => entry.line === "v2.1"), true);
|
||||
assert.equal(transcript.some((entry) => entry.line.startsWith("T10 ") && entry.line.includes("P110")), true);
|
||||
assert.equal(transcript.some((entry) => entry.line.startsWith("FINI")), true);
|
||||
|
||||
await port.close();
|
||||
|
||||
const dbFileText = readFileSync(adapter.dbSavefile, "utf8");
|
||||
assert.match(dbFileText, /T11 P111 D0.33 Z0.11/);
|
||||
assert.match(dbFileText, /T14 P114\b/);
|
||||
|
||||
const diagnostics = createToolDbProcessDiagnostics({
|
||||
dbProgramPath: "./db_nonran.py",
|
||||
opfsDbPath: "/machines/db-demo/tool-db/db_nonran_file",
|
||||
transcript,
|
||||
dbFileText,
|
||||
startupToolCount: 10,
|
||||
mutationCount: 3,
|
||||
runtimeMode: adapter.runtimeMode,
|
||||
runtimeExecutionReady: true,
|
||||
});
|
||||
assert.equal(diagnostics.runtimeMode, "node-linuxcnc-db-program");
|
||||
assert.equal(diagnostics.runtimeExecutionReady, true);
|
||||
assert.equal(diagnostics.protocolTranscriptReady, true);
|
||||
assert.equal(diagnostics.opfsPersistenceReady, true);
|
||||
assert.equal(diagnostics.tblFallbackSufficient, false);
|
||||
assert.equal(diagnostics.executionEnabled, false);
|
||||
assert.equal(diagnostics.promotionAllowed, false);
|
||||
|
||||
console.log("tool_db_node_runtime_adapter=ok");
|
||||
6
wasm-port/tests/sdk/node/verify_tool_db_node_runtime_adapter.sh
Executable file
6
wasm-port/tests/sdk/node/verify_tool_db_node_runtime_adapter.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "$0")/../../.." && pwd)"
|
||||
|
||||
node "$ROOT_DIR/tests/sdk/node/verify_tool_db_node_runtime_adapter.mjs"
|
||||
@@ -91,6 +91,6 @@ assert.equal(diagnostics.promotionAllowed, false);
|
||||
assert.match(diagnostics.transcriptHash, /^[0-9a-f]{8}$/);
|
||||
assert.match(diagnostics.dbFileHash, /^[0-9a-f]{8}$/);
|
||||
|
||||
assert.equal(port.close().promotionAllowed, false);
|
||||
assert.equal((await port.close()).promotionAllowed, false);
|
||||
|
||||
console.log("tool_db_process_port_sdk=ok");
|
||||
|
||||
@@ -44,8 +44,18 @@ const report = createProjectBatchAcceptanceReport({
|
||||
evidence: "project_batch_acceptance_workflow_node_smoke=ok",
|
||||
command: "wasm-port/tests/sdk/node/verify_project_batch_acceptance_workflow.sh",
|
||||
},
|
||||
{
|
||||
id: "tool-db-node-runtime-adapter",
|
||||
type: "gate",
|
||||
label: "L4-TOOL-DB Node/native DB_PROGRAM runtime",
|
||||
evidence: "tool_db_node_runtime_adapter=ok",
|
||||
command: "wasm-port/tests/sdk/node/verify_tool_db_node_runtime_adapter.sh",
|
||||
},
|
||||
],
|
||||
observedOutputs: [
|
||||
"project_batch_acceptance_workflow_node_smoke=ok",
|
||||
"tool_db_node_runtime_adapter=ok",
|
||||
],
|
||||
observedOutputs: ["project_batch_acceptance_workflow_node_smoke=ok"],
|
||||
virtualHalSimConfigSourceCoverage: createVirtualHalSimConfigSourceCoverageReport({
|
||||
manifestText: sourceManifestText,
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user