diff --git a/src/routes/controller.svelte b/src/routes/controller.svelte
index b336fca..7482018 100644
--- a/src/routes/controller.svelte
+++ b/src/routes/controller.svelte
@@ -1,6 +1,12 @@
+
+ {#each [{ label: '点火测试', value: '1' }, { label: '放电测试', value: '2' }, { label: '系统功能', value: '3' }] as item}
+
+ {/each}
+
-
-
-
-
-
-
系统功能
-
-
波形数据
-
-
-
-
-
- 测试接口
-
-
-
-
-
-
+
+ {#if ctrlPanelMode == '1'}
+
+ {/if}
+ {#if ctrlPanelMode == '2'}
+
+ {/if}
+ {#if ctrlPanelMode == '3'}
+
+ {/if}
diff --git a/src/routes/controllers/discharge.svelte b/src/routes/controllers/discharge.svelte
new file mode 100644
index 0000000..05a8cef
--- /dev/null
+++ b/src/routes/controllers/discharge.svelte
@@ -0,0 +1,56 @@
+
+
+
diff --git a/src/routes/controllers/system.svelte b/src/routes/controllers/system.svelte
new file mode 100644
index 0000000..e14e9b4
--- /dev/null
+++ b/src/routes/controllers/system.svelte
@@ -0,0 +1,100 @@
+
+
+
+
信号引脚设置
+
+
+
信号引脚模式
+
+ {#each [{ name: '无效', value: 0 }, { name: '输入', value: 1 }, { name: '输出', value: 2 }] as item}
+
+ {/each}
+
+
+
+
+
有效电平
+
+ {#each [{ name: '低电平', value: 0 }, { name: '高电平', value: 1 }] as item}
+
+ {/each}
+
+
+
+
+
+
+
+
系统功能
+
+
波形数据
+
+
+
+
+
+ 测试接口
+
+
+
+
diff --git a/src/routes/controllers/work.svelte b/src/routes/controllers/work.svelte
new file mode 100644
index 0000000..1928e28
--- /dev/null
+++ b/src/routes/controllers/work.svelte
@@ -0,0 +1,113 @@
+
+
+
+
+
+
diff --git a/src/routes/dataHandler.js b/src/routes/dataHandler.js
index 35ab024..fdef20c 100644
--- a/src/routes/dataHandler.js
+++ b/src/routes/dataHandler.js
@@ -36,14 +36,14 @@ let voltPostProc = (adc) => {
return mv / 1000
}
let currentPostProc = (adc) => {
- let mA = -4.07 * adc + 12610
- if (mA < 50 && mA > -50) {
+ let mA = 4.07 * adc - 12610
+ if (mA < 140 && mA > -80) {
mA = 0
}
return mA / 1000
}
-let peakDataSet = {
- name: "输出峰值",
+let voltOutDataSet = {
+ name: "输出电压",
head: 0x11,
postfix: "V",
v: 0,
@@ -52,8 +52,8 @@ let peakDataSet = {
return self.v.toFixed(2) + self.postfix
},
}
-let currentDataSet = {
- name: "输出电流",
+let currentInDataSet = {
+ name: "输入电流",
head: 0x12,
postfix: "A",
v: 0,
@@ -62,8 +62,8 @@ let currentDataSet = {
return self.v.toFixed(2) + self.postfix
},
}
-let battDataSet = {
- name: "电池电压",
+let voltInDataSet = {
+ name: "输入电压",
head: 0x13,
postfix: "V",
v: 0,
@@ -72,6 +72,16 @@ let battDataSet = {
return self.v.toFixed(2) + self.postfix
},
}
+let currentOutDataSet = {
+ name: "输出电流",
+ head: 0x14,
+ postfix: "A",
+ v: 0,
+ postProc: currentPostProc,
+ print: (self) => {
+ return self.v.toFixed(2) + self.postfix
+ },
+}
let ratioDataSet = {
name: "输出占空比",
head: 0x18,
@@ -85,7 +95,7 @@ let ratioDataSet = {
},
}
let powerDataSet = {
- name: "输出功率",
+ name: "峰值功率",
head: 0xf0,
postfix: "W",
v: 0,
@@ -93,23 +103,56 @@ let powerDataSet = {
return self.v.toFixed(1) + self.postfix
},
}
+let delayDataSet = {
+ name: "点火延迟",
+ head: 0x72,
+ postfix: "ms",
+ v: 0,
+ print: (self) => {
+ return (self.v / 1000).toFixed(1) + self.postfix
+ },
+}
+let worktimeDataSet = {
+ name: "燃烧时间",
+ head: 0x74,
+ postfix: "ms",
+ v: 0,
+ print: (self) => {
+ return (self.v / 1000).toFixed(0) + self.postfix
+ },
+}
+let timestampDataSet = {
+ name: "时间戳",
+ head: 0x7f,
+ postfix: "us",
+ v: 0,
+}
+
export let dataTypesArray = new Array(
temperatureDataSet,
- battDataSet,
- currentDataSet,
- peakDataSet,
+ voltInDataSet,
+ currentInDataSet,
+ voltOutDataSet,
+ currentOutDataSet,
powerDataSet,
freqDataSet,
- ratioDataSet
+ ratioDataSet,
+ delayDataSet,
+ worktimeDataSet,
+ timestampDataSet
)
export const dataTypes = new Map([
[0x00, temperatureDataSet],
[0x10, freqDataSet],
- [0x11, peakDataSet],
- [0x12, currentDataSet],
- [0x13, battDataSet],
+ [0x11, voltOutDataSet],
+ [0x12, currentInDataSet],
+ [0x13, voltInDataSet],
+ [0x14, currentOutDataSet],
[0x18, ratioDataSet],
[0xf0, powerDataSet],
+ [0x72, delayDataSet],
+ [0x74, worktimeDataSet],
+ [0x7f, timestampDataSet],
])
export function dataUpdate(datas) {
datas.forEach((element) => {
@@ -117,7 +160,7 @@ export function dataUpdate(datas) {
dataTypes.get(element.head).v = element.v
}
})
- powerDataSet.v = peakDataSet.v * currentDataSet.v
+ powerDataSet.v = voltOutDataSet.v * currentInDataSet.v
if (freqDataSet.v > 0.0 && freqDataSet.v < 100.0) {
powerDataSet.v = (powerDataSet.v * freqDataSet.v) / 100
}
diff --git a/src/routes/info.svelte b/src/routes/info.svelte
new file mode 100644
index 0000000..da5ea93
--- /dev/null
+++ b/src/routes/info.svelte
@@ -0,0 +1,88 @@
+
+
+
+
+ {state}
+
+
+
+
+ {#each datas as item}
+
+ {item.name}
+ {item.value}
+ {item.unit}
+
+ {/each}
+
+
+
diff --git a/src/routes/nav.svelte b/src/routes/nav.svelte
index 649b16c..dd53687 100644
--- a/src/routes/nav.svelte
+++ b/src/routes/nav.svelte
@@ -9,24 +9,8 @@
export let device;
export let dataTypesArrayU;
- const temperature_badge_themes = ['badge-info', 'badge-success', 'badge-warning', 'badge-error'];
- const temperature_badge_levels_high = [24, 45, 60, 100];
- const temperature_badge_levels_low = [0, 22, 42, 58];
- let temperature_badge_level = 1;
- $: temperature_badge_theme = temperature_badge_themes[temperature_badge_level];
-
function onHidNewDataMsg(event) {
dispatch('message', event.detail);
- event.detail.forEach((data) => {
- if (data.head == 0x00) {
- if (data.v > temperature_badge_levels_high[temperature_badge_level]) {
- temperature_badge_level += 1;
- }
- if (data.v < temperature_badge_levels_low[temperature_badge_level]) {
- temperature_badge_level -= 1;
- }
- }
- });
}
@@ -40,15 +24,6 @@
{#if device && device.opened}
已连接
- {#if dataTypesArrayU}
- {#each dataTypesArrayU as item}
- {#if item.head == 0x00}
-
- {#if item.print}{item.print(item)}{:else}{item.v}{/if}
-
- {/if}
- {/each}
- {/if}
{:else}
未连接
{/if}
diff --git a/src/routes/realtimeData.svelte b/src/routes/realtimeData.svelte
index c0a99a5..de0dc5f 100644
--- a/src/routes/realtimeData.svelte
+++ b/src/routes/realtimeData.svelte
@@ -1,13 +1,17 @@
-
+
{#if dataTypesArrayU}
{#each dataTypesArrayU as item}
- {#if item.head != 0x00}
+ {#if filter.includes(item.head)}
- {item.name}
- d.vendorId === vid);
- if (!dev) {
+ let hidDevice = device_list.find((d) => d.vendorId === vid);
+ if (!hidDevice) {
console.log('ERROR: No valid devices found');
return -2;
}
- if (!dev.opened) {
- await dev.open();
+ if (!hidDevice.opened) {
+ await hidDevice.open();
}
- dev.oninputreport = reportPaser;
- console.log('device opened:', dev);
- return dev;
+ hidDevice.oninputreport = reportPaser;
+ console.log('device opened:', hidDevice);
+ return hidDevice;
}
async function openDeviceListById(vendorId) {
let devs = await navigator.hid.requestDevice({
@@ -79,13 +79,13 @@
return -1;
}
console.log('valid devices:', devs);
- let dev = devs[0];
- if (!dev.opened) {
- await dev.open();
+ let hidDevice = devs[0];
+ if (!hidDevice.opened) {
+ await hidDevice.open();
}
- dev.oninputreport = reportPaser;
- console.log('device opened:', dev);
- return dev;
+ hidDevice.oninputreport = reportPaser;
+ console.log('device opened:', hidDevice);
+ return hidDevice;
}
function dataPaser(data) {
@@ -101,6 +101,10 @@
if (data[4] != (data[2] ^ data[3])) {
return;
}
+ // function buf2hex(buffer) {
+ // return [...new Uint8Array(buffer)].map((x) => x.toString(16).padStart(2, '0')).join(' ');
+ // }
+ // console.log("hid", buf2hex(data.buffer));
let validDataType = (dt) => {
if (dataTypes.has(dt)) {
return dataTypes.get(dt);
@@ -127,7 +131,6 @@
dataValue = dataType.postProc(dataValue);
}
dataType.v = dataValue;
-
return { name: dataType.name, head: dataType.head, v: dataType.v };
};
let output = [];