gx
chenyc
2026-09-24 ebb8329b667a3ab8b6ce3cd9f765142a6fd0efcc
gx
5个文件已修改
20 ■■■■■ 已修改文件
cache/latest-device-cache.json 4 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
gateway.config.json 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
gateway.js 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
package.json 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
sim_server.js 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cache/latest-device-cache.json
@@ -383,9 +383,9 @@
  "FX034856": {
    "deviceKey": "FX034856",
    "deviceName": "FX034856",
    "receivedAt": "2026-03-19T09:37:51.077Z",
    "receivedAt": "2026-03-30T03:57:41.675Z",
    "source": {
      "host": "127.0.0.1",
      "host": "192.168.33.1",
      "port": 3021
    },
    "params": [
gateway.config.json
@@ -23,7 +23,7 @@
  "devices": [
    {
      "name": "FX034856",
      "host": "127.0.0.1",
      "host": "192.168.33.1",
      "port": 3021
    }
  ],
gateway.js
@@ -503,12 +503,18 @@
            return p != null ? p.value : undefined;
        };
        // 将 YYYYMMDDHHmmss 格式化为 yyyy-MM-dd HH:mm:ss
        const rawTs = frameData.timestamp || '';
        const formattedTime = rawTs.length >= 14
            ? `${rawTs.slice(0,4)}-${rawTs.slice(4,6)}-${rawTs.slice(6,8)} ${rawTs.slice(8,10)}:${rawTs.slice(10,12)}:${rawTs.slice(12,14)}`
            : (rawTs || null);
        // 构造与物模型一致的扁平 payload,所有字段在同一层
        const mqttPayload = {
            ts: Date.now(),                                      // 毫秒时间戳
            suedtime: frameData.timestamp || null,               // 帧原始时间(YYYYMMDDHHmmss)
            deviceId: frameData.deviceName || null,              // 设备唯一标识(用name)
            suedtime: formattedTime,                             // 帧时间(yyyy-MM-dd HH:mm:ss)
            deviceNo: frameData.device || null,                  // 机器序列号
            n: frameData.deviceName || null,                      // 设备名称 (作为 deviceKey 使用) 配置在 gateway.config.json 中device.name字段
            deviceType: this.config.deviceType || 'Artis',      // 设备型号
            IPAddress: frameData.source?.host || null,           // 设备 IP
            zljd: pick(0),    // 治疗阶段
package.json
@@ -6,7 +6,7 @@
    "parse:raw": "node parse_raw.js",
    "hex:bin": "node hex_to_bin.js",
    "sim:server": "node sim_server.js",
    "gateway": "node gateway.js",
    "dev": "node gateway.js",
    "build:ncc": "ncc build gateway.js -o dist --minify --no-source-map-register",
    "build:win": "pkg dist/index.js --target node18-win-x64 --output build/gateway-win.exe --compress GZip",
    "build:linux": "pkg dist/index.js --target node18-linux-x64 --output build/gateway-linux --compress GZip",
sim_server.js
@@ -10,7 +10,7 @@
function parseArgs(argv) {
  const args = {
    host: '127.0.0.1',
    host: '192.168.33.1',
    port: 3021,
    interval: 1000,
    once: false,