Commit 0e340286 authored by lyong's avatar lyong

refactor(factoryTest): 优化系统

parent 3dd90d38
...@@ -3,6 +3,7 @@ var _userdata = require("userdata.js"); ...@@ -3,6 +3,7 @@ var _userdata = require("userdata.js");
var userData = _userdata.userData; var userData = _userdata.userData;
const fs = require("@system.fs"); const fs = require("@system.fs");
var systemCtrl = require("systemCtrl.js"); var systemCtrl = require("systemCtrl.js");
var process = require("@system.process");
var that; var that;
var systemInfoTimer = null; var systemInfoTimer = null;
var systemInfo = {}; var systemInfo = {};
...@@ -29,7 +30,7 @@ const textValueKeys = [ ...@@ -29,7 +30,7 @@ const textValueKeys = [
// "crtsystemId3_TextValue2", // "crtsystemId3_TextValue2",
// "crtsystemId3_TextValue3", // "crtsystemId3_TextValue3",
// "crtsystemId3_TextValue4", // "crtsystemId3_TextValue4",
// "crtsystemId3_TextValue5" // "crtsystemId3_TextValue5"
]; ];
...@@ -43,12 +44,12 @@ const textValueKeys = [ ...@@ -43,12 +44,12 @@ const textValueKeys = [
let checkedCount = 0; let checkedCount = 0;
let ngCount = 0; let ngCount = 0;
function setTextColorByValue(that, fullKey, value) { function setTextColorByValue(that, fullKey, value) {
// 1. 设置颜色 // 1. 设置颜色
const color = (value === "NG") ? "#ff0000" : "#00ff00"; const color = (value === "NG") ? "#ff0000" : "#00ff00";
const key = fullKey.replace(/^crt/, ""); const key = fullKey.replace(/^crt/, "");
that.$setTextColor(key, color); that.$setTextColor(key, color);
// 2. 更新计数 // 2. 更新计数
...@@ -56,14 +57,14 @@ function setTextColorByValue(that, fullKey, value) { ...@@ -56,14 +57,14 @@ function setTextColorByValue(that, fullKey, value) {
if (value === "NG") ngCount++; if (value === "NG") ngCount++;
// 3. 等所有项都检测完再写全局变量 // 3. 等所有项都检测完再写全局变量
console.log("textValueKeys.length: " + textValueKeys.length +", checkedCount: " + checkedCount + ", ngCount: " + ngCount) console.log("textValueKeys.length: " + textValueKeys.length + ", checkedCount: " + checkedCount + ", ngCount: " + ngCount)
console.log("factoryTestSystemCheck: " + that.factoryTestSystemCheck) console.log("factoryTestSystemCheck: " + that.factoryTestSystemCheck)
if (checkedCount === textValueKeys.length) { if (checkedCount === textValueKeys.length) {
that.factoryTestSystemCheck = (ngCount === 0) ? 1 : 2; that.factoryTestSystemCheck = (ngCount === 0) ? 1 : 2;
// 重置计数器,方便下次调用 // 重置计数器,方便下次调用
checkedCount = 0; checkedCount = 0;
ngCount = 0; ngCount = 0;
} }
} }
...@@ -81,16 +82,32 @@ function updateSystemInfo() { ...@@ -81,16 +82,32 @@ function updateSystemInfo() {
systemInfo.softwareVersion = userData.softwareVersion; systemInfo.softwareVersion = userData.softwareVersion;
systemInfo.hardwareVersion = userData.hardwareVersion; systemInfo.hardwareVersion = userData.hardwareVersion;
systemInfo.factorywareVersion = userData.factorywareVersion; systemInfo.factorywareVersion = userData.factorywareVersion;
systemInfo.cpuTemperature = getCPUTemperature();
systemInfo.cpuFrequency = getCPUFrequency(); if (process.platform == "win32") {
systemInfo.storageInfo = getTotalStorageInfo();
systemInfo.wifiMac = getWifiInfo("address"); systemInfo.cpuTemperature = "NG";
systemInfo.cpuFrequency = "NG";
systemInfo.storageInfo = {
totalSizeMB: "NG",
totalAvailableMB: "NG"
}
systemInfo.wifiMac = "NG";
systemInfo.licenseRegistered = "NG";
systemInfo.wifiIp = "NG";
} else {
systemInfo.cpuTemperature = getCPUTemperature();
systemInfo.cpuFrequency = getCPUFrequency();
systemInfo.storageInfo = getTotalStorageInfo();
systemInfo.wifiMac = getWifiInfo("address");
systemInfo.licenseRegistered = (checkLicense() == 1 ? "Pass" : "NG"); // 需根据实际实现
systemInfo.wifiIp = getWifiInfo("ip_address"); //前提wifi要连接
}
systemInfo.sn = userData.aboutSNValue || "NG"; systemInfo.sn = userData.aboutSNValue || "NG";
systemInfo.tpVersion = "V5A"; // 示例值 systemInfo.tpVersion = "V5A"; // 示例值
systemInfo.screenVendor = getScreenVendor(); // 需根据实际实现 systemInfo.screenVendor = getScreenVendor(); // 需根据实际实现
systemInfo.wifiModel = "AP62212"; // 示例值 systemInfo.wifiModel = "AP62212"; // 示例值
systemInfo.licenseRegistered = (checkLicense() == 1 ? "Pass" : "NG"); // 需根据实际实现
systemInfo.wifiIp = getWifiInfo("ip_address"); //前提wifi要连接
...@@ -104,18 +121,18 @@ function updateSystemInfo() { ...@@ -104,18 +121,18 @@ function updateSystemInfo() {
that.crtsystemId1_TextValue2 = systemInfo.softwareVersion; that.crtsystemId1_TextValue2 = systemInfo.softwareVersion;
that.crtsystemId1_TextValue3 = systemInfo.hardwareVersion; that.crtsystemId1_TextValue3 = systemInfo.hardwareVersion;
that.crtsystemId1_TextValue4 = "NG", that.crtsystemId1_TextValue4 = "NG",
that.crtsystemId1_TextValue5 = "792 MHZ", that.crtsystemId1_TextValue5 = "792 MHZ",
// that.crtsystemId2_TextHeader1: "WiFi MAC:", // that.crtsystemId2_TextHeader1: "WiFi MAC:",
// that.crtsystemId2_TextHeader2: "蓝牙MAC:", // that.crtsystemId2_TextHeader2: "蓝牙MAC:",
// that.crtsystemId2_TextHeader3: "语音license:", // that.crtsystemId2_TextHeader3: "语音license:",
// that.crtsystemId2_TextHeader4: "CPU温度:", // that.crtsystemId2_TextHeader4: "CPU温度:",
// that.crtsystemId2_TextHeader5: "存储空间:", // that.crtsystemId2_TextHeader5: "存储空间:",
that.crtsystemId2_TextValue1 = systemInfo.wifiMac; that.crtsystemId2_TextValue1 = systemInfo.wifiMac;
// that.crtsystemId2_TextValue2: "NG", // that.crtsystemId2_TextValue2: "NG",
that.crtsystemId2_TextValue3 = systemInfo.licenseRegistered; that.crtsystemId2_TextValue3 = systemInfo.licenseRegistered;
that.crtsystemId2_TextValue4 = (systemInfo.cpuTemperature != "NG") ? systemInfo.cpuTemperature + "" : systemInfo.cpuTemperature; that.crtsystemId2_TextValue4 = (systemInfo.cpuTemperature != "NG") ? systemInfo.cpuTemperature + "" : systemInfo.cpuTemperature;
that.crtsystemId2_TextValue5 =(systemInfo.storageInfo.totalAvailableMB != "NG" && systemInfo.storageInfo.totalSizeMB != "NG") ? systemInfo.storageInfo.totalAvailableMB + "MB" + "/" + systemInfo.storageInfo.totalSizeMB + "MB" : "NG"; that.crtsystemId2_TextValue5 = (systemInfo.storageInfo.totalAvailableMB != "NG" && systemInfo.storageInfo.totalSizeMB != "NG") ? systemInfo.storageInfo.totalAvailableMB + "MB" + "/" + systemInfo.storageInfo.totalSizeMB + "MB" : "NG";
// that.crtsystemId3_TextHeader1: "产测版本:", // that.crtsystemId3_TextHeader1: "产测版本:",
// that.crtsystemId3_TextHeader2: "屏模组信息:", // that.crtsystemId3_TextHeader2: "屏模组信息:",
...@@ -124,7 +141,7 @@ function updateSystemInfo() { ...@@ -124,7 +141,7 @@ function updateSystemInfo() {
// that.crtsystemId3_TextHeader5: "IP地址:", // that.crtsystemId3_TextHeader5: "IP地址:",
that.crtsystemId3_TextValue1 = systemInfo.factorywareVersion; that.crtsystemId3_TextValue1 = systemInfo.factorywareVersion;
that.crtsystemId3_TextValue2 = systemInfo.screenVendor; that.crtsystemId3_TextValue2 = systemInfo.screenVendor;
that.crtsystemId3_TextValue3 = (systemInfo.cpuFrequency != "NG") ? systemInfo.cpuFrequency +"MHz" : systemInfo.cpuFrequency; that.crtsystemId3_TextValue3 = (systemInfo.cpuFrequency != "NG") ? systemInfo.cpuFrequency + "MHz" : systemInfo.cpuFrequency;
that.crtsystemId3_TextValue4 = systemInfo.wifiIp; that.crtsystemId3_TextValue4 = systemInfo.wifiIp;
// that.crtsystemId3_TextValue5: "NG", // that.crtsystemId3_TextValue5: "NG",
...@@ -162,8 +179,8 @@ function startSystemInfoTimer(obj) { ...@@ -162,8 +179,8 @@ function startSystemInfoTimer(obj) {
} }
systemInfoTimer = setInterval(() => { systemInfoTimer = setInterval(() => {
updateSystemInfo(); updateSystemInfo();
}, 2000); }, 5000);
console.log("系统信息定时器已启动(500ms)"); console.log("系统信息定时器已启动(5000ms)");
} }
// 停止定时器 // 停止定时器
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment