88 lines
3.9 KiB
HTML
88 lines
3.9 KiB
HTML
<!doctype html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>星元智灵异常场景测试</title>
|
|
<link rel="stylesheet" href="../../app/src/main/assets/www/styles.css" />
|
|
</head>
|
|
<body>
|
|
<main id="app" class="app-shell" aria-live="polite"></main>
|
|
<div id="toast" class="toast" role="status"></div>
|
|
<script>
|
|
(function () {
|
|
var params = new URLSearchParams(location.search);
|
|
var scenario = params.get("scenario") || "pass";
|
|
var baselineDelay = Number(params.get("baselineDelay") || 30);
|
|
var weightQueryCounts = {};
|
|
if (params.get("clear") === "1") localStorage.clear();
|
|
window.__nativeCalls = [];
|
|
|
|
function record(method, json) {
|
|
var payload = {};
|
|
try { payload = JSON.parse(json || "{}"); } catch (error) {}
|
|
window.__nativeCalls.push({ method: method, payload: payload, at: Date.now() });
|
|
document.documentElement.setAttribute("data-native-calls", JSON.stringify(window.__nativeCalls));
|
|
return payload;
|
|
}
|
|
|
|
function emitConnection(payload, delay) {
|
|
window.setTimeout(function () {
|
|
if (window.ZhitouSerial) window.ZhitouSerial.onConnectionCheck(payload);
|
|
}, delay || 20);
|
|
}
|
|
|
|
window.XingyuanNative = {
|
|
configure: function (json) { record("configure", json); },
|
|
startHeartbeat: function (json) { record("startHeartbeat", json); },
|
|
scanMediaFiles: function () { return "[]"; },
|
|
loadLocalBackups: function () { return "[]"; },
|
|
fetchWorkContext: function () {
|
|
return JSON.stringify([{ machineNo: "TEST-01", persons: ["测试员"], batches: ["BATCH-01"] }]);
|
|
},
|
|
requestConnectionCheck: function (json) {
|
|
var request = record("requestConnectionCheck", json);
|
|
var serialOnline = scenario !== "serial-fail" && scenario !== "all-fail";
|
|
var networkOnline = scenario !== "network-fail" && scenario !== "all-fail";
|
|
emitConnection({
|
|
requestId: request.requestId,
|
|
mode: request.mode,
|
|
serialOnline: serialOnline,
|
|
networkOnline: networkOnline,
|
|
tcpConnected: networkOnline,
|
|
httpReachable: networkOnline,
|
|
pingOk: networkOnline
|
|
}, scenario === "slow-check" ? 4300 : 20);
|
|
},
|
|
queryWeight: function (json) {
|
|
var request = record("queryWeight", json);
|
|
var port = Number(request.port || 1);
|
|
weightQueryCounts[port] = Number(weightQueryCounts[port] || 0) + 1;
|
|
if (scenario !== "weight-missing" && !(scenario === "baseline-missing" && weightQueryCounts[port] === 1)) {
|
|
window.setTimeout(function () {
|
|
if (window.ZhitouSerial) {
|
|
window.ZhitouSerial.onThrowWeight({
|
|
port: port,
|
|
weight: 5,
|
|
beforeWeight: 5,
|
|
afterWeight: 5,
|
|
queryResponse: true
|
|
});
|
|
}
|
|
}, baselineDelay);
|
|
}
|
|
return true;
|
|
},
|
|
queryFill: function (json) { record("queryFill", json); return true; },
|
|
queryTemperature: function (json) { record("queryTemperature", json); return true; },
|
|
openThrowDoor: function (json) { record("openThrowDoor", json); return scenario !== "open-fail"; },
|
|
closeThrowDoor: function (json) { record("closeThrowDoor", json); return scenario !== "close-fail"; },
|
|
reportXingyuanDelivery: function (json) { record("reportXingyuanDelivery", json); return true; },
|
|
saveLocalBackup: function (json) { record("saveLocalBackup", json); return "/tmp/test-backup.json"; }
|
|
};
|
|
})();
|
|
</script>
|
|
<script src="../../app/src/main/assets/www/app.js"></script>
|
|
</body>
|
|
</html>
|