fix: UI 标签优化、继电器着色、工装配置概览面板
- fixture.js: FarTol/NearTol/StepTol 容差字段去掉 ×10 换算 - test_data.js: relay_out 列增加 fmtRelay() 着色渲染 - test_op.js: 新增工装配置概览面板 (renderConfigOverview + toggleConfig);新增 fmtRelay();renderLatest 继电器着色 - fixture.html: 标签文本优化 — 触发距离/释放距离/mm/V 单位标注 - test_op.html: 新增配置概览面板 HTML,隐藏旧 test-mode-indicator - vehicle_base_test.html: 标签文本统一(触发/释放距离 + 单位) - .gitignore: 新增,排除 __pycache__/*.pyc/.venv
This commit is contained in:
@@ -217,9 +217,9 @@ function fillFormFromParam(param) {
|
||||
document.getElementById("param-fre-max").value = rawFreqToHz(param.FreMax || 0);
|
||||
document.getElementById("param-peak-min").value = rawPeakToV(param.PeakMin || 0);
|
||||
document.getElementById("param-peak-max").value = rawPeakToV(param.PeakMax || 0);
|
||||
document.getElementById("param-far-tol").value = (param.FarTol || 0) * 10;
|
||||
document.getElementById("param-near-tol").value = (param.NearTol || 0) * 10;
|
||||
document.getElementById("param-step-tol").value = (param.StepTol || 0) * 10;
|
||||
document.getElementById("param-far-tol").value = param.FarTol || 0;
|
||||
document.getElementById("param-near-tol").value = param.NearTol || 0;
|
||||
document.getElementById("param-step-tol").value = param.StepTol || 0;
|
||||
document.getElementById("param-back-forth").value = param.BackForth || 0;
|
||||
document.getElementById("param-near-stay").value = param.NearStay || 0;
|
||||
document.getElementById("param-far-stay").value = param.FarStay || 0;
|
||||
@@ -314,9 +314,9 @@ function getFormParams() {
|
||||
fre_max: hzToRawFreq(parseFloat(document.getElementById("param-fre-max").value) || 0),
|
||||
peak_min: vToRawPeak(parseFloat(document.getElementById("param-peak-min").value) || 0),
|
||||
peak_max: vToRawPeak(parseFloat(document.getElementById("param-peak-max").value) || 0),
|
||||
far_tol: Math.round((parseInt(document.getElementById("param-far-tol").value) || 0) / 10),
|
||||
near_tol: Math.round((parseInt(document.getElementById("param-near-tol").value) || 0) / 10),
|
||||
step_tol: Math.round((parseInt(document.getElementById("param-step-tol").value) || 0) / 10),
|
||||
far_tol: parseInt(document.getElementById("param-far-tol").value) || 0,
|
||||
near_tol: parseInt(document.getElementById("param-near-tol").value) || 0,
|
||||
step_tol: parseInt(document.getElementById("param-step-tol").value) || 0,
|
||||
back_forth: parseInt(document.getElementById("param-back-forth").value) || 0,
|
||||
near_stay: parseInt(document.getElementById("param-near-stay").value) || 0,
|
||||
far_stay: parseInt(document.getElementById("param-far-stay").value) || 0,
|
||||
|
||||
@@ -14,7 +14,7 @@ const VIEWS = {
|
||||
{ key: 'test_mode', title: '测试模式', render: r => r.test_mode === 1 ? '波动' : '灵敏度' },
|
||||
{ key: 'iffinish', title: '完成', render: r => r.data_source === 'B4' ? '-' : (r.iffinish === '1' ? '是' : '否') },
|
||||
{ key: 'fault_info', title: '故障信息', render: r => r.data_source === 'B4' ? '-' : `<span style="display:inline-block;max-width:12em;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;" title="${escHtml(r.fault_info || '')}">${escHtml(r.fault_info || '-')}</span>` },
|
||||
{ key: 'relay_out', title: '继电器' },
|
||||
{ key: 'relay_out', title: '继电器', render: r => fmtRelay(r.relay_out) },
|
||||
{ key: 'ppvalue', title: '峰峰值(V)', render: r => r.data_source === 'B4' ? '-' : (r.ppvalue != null ? r.ppvalue.toFixed(2) : '-') },
|
||||
{ key: 'idle_freq', title: '开始频率(Hz)', render: r => r.data_source === 'B4' ? '-' : (r.idle_freq || '-') },
|
||||
{ key: 'enter_freq', title: '进入频率(Hz)', render: r => r.data_source === 'B4' ? '-' : (r.enter_freq || '-') },
|
||||
@@ -49,7 +49,7 @@ const VIEWS = {
|
||||
{ key: 'test_mode', title: '测试模式', render: r => r.test_mode === 1 ? '波动' : '灵敏度' },
|
||||
{ key: 'iffinish', title: '完成', render: r => r.iffinish === '1' ? '是' : '否' },
|
||||
{ key: 'fault_info', title: '故障信息', render: r => `<span style="display:inline-block;max-width:12em;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;" title="${escHtml(r.fault_info || '')}">${escHtml(r.fault_info || '-')}</span>` },
|
||||
{ key: 'relay_out', title: '继电器' },
|
||||
{ key: 'relay_out', title: '继电器', render: r => fmtRelay(r.relay_out) },
|
||||
{ key: 'ppvalue', title: '峰峰值(V)', render: r => r.ppvalue?.toFixed(2) || '-' },
|
||||
{ key: 'idle_freq', title: '开始频率(Hz)' },
|
||||
{ key: 'enter_freq', title: '进入频率(Hz)' },
|
||||
@@ -76,7 +76,7 @@ const VIEWS = {
|
||||
{ key: 'far_dist', title: '最远距离(mm)' },
|
||||
{ key: 'b4_enter_dist', title: '触发距离(mm)' },
|
||||
{ key: 'b4_leave_dist', title: '释放高度(mm)' },
|
||||
{ key: 'relay_out', title: '继电器' },
|
||||
{ key: 'relay_out', title: '继电器', render: r => fmtRelay(r.relay_out) },
|
||||
{ key: 'env', title: '测试环境', render: r => envLabel(r) },
|
||||
{ key: 'create_time', title: '时间', render: r => fmtTime(r.create_time) },
|
||||
],
|
||||
@@ -137,6 +137,13 @@ function envLabel(r) {
|
||||
return parts.join(' ') || '-';
|
||||
}
|
||||
|
||||
function fmtRelay(s) {
|
||||
if (!s) return '-';
|
||||
return s
|
||||
.replace(/继电器有输出/g, '<span style="color:#22c55e;font-weight:600">✅有输出</span>')
|
||||
.replace(/继电器无输出/g, '<span style="color:#ef4444;font-weight:600">❌无输出</span>');
|
||||
}
|
||||
|
||||
// ─── 视图切换 ────────────────────────────────────
|
||||
|
||||
function switchView(view) {
|
||||
@@ -422,7 +429,7 @@ async function loadChart() {
|
||||
{ type: 'value', name: '距离(mm)', nameTextStyle: { fontSize: 11 } },
|
||||
{ type: 'value', name: '速度(dm/s)',nameTextStyle: { fontSize: 11 },
|
||||
offset: 80 },
|
||||
{ type: 'value', name: '继电器输出', nameTextStyle: { fontSize: 11 },
|
||||
{ type: 'value', name: '继电器', nameTextStyle: { fontSize: 11 },
|
||||
min: -0.5, max: 3.5, interval: 1,
|
||||
offset: 160,
|
||||
axisLabel: {
|
||||
|
||||
@@ -279,6 +279,7 @@ async function loadTestMode() {
|
||||
const param = await resp.json();
|
||||
if (param && param.dnt_id) {
|
||||
updateTestModeUI(param.TestMode);
|
||||
renderConfigOverview(param);
|
||||
} else {
|
||||
// 没有工装参数时,尝试从最新测试数据获取
|
||||
const r2 = await fetch(`/api/automation/${DNT_ID}/progress`);
|
||||
@@ -292,17 +293,81 @@ async function loadTestMode() {
|
||||
|
||||
function updateTestModeUI(mode) {
|
||||
currentTestMode = mode;
|
||||
const indicator = document.getElementById("test-mode-indicator");
|
||||
const waveSection = document.getElementById("wave-section");
|
||||
if (mode === 1) {
|
||||
indicator.innerHTML = '当前测试模式:<strong style="color:#e67e22;">波动测试</strong>';
|
||||
waveSection.style.display = '';
|
||||
} else {
|
||||
indicator.innerHTML = '当前测试模式:<strong style="color:#2980b9;">灵敏度测试</strong>';
|
||||
waveSection.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
function renderConfigOverview(param) {
|
||||
const panel = document.getElementById("config-overview");
|
||||
if (!panel) return;
|
||||
panel.style.display = '';
|
||||
|
||||
// 测试模式
|
||||
const modeEl = document.getElementById("cfg-test-mode");
|
||||
if (param.TestMode === 1) {
|
||||
modeEl.innerHTML = '<strong style="color:#e67e22;">波动测试</strong>';
|
||||
} else {
|
||||
modeEl.innerHTML = '<strong style="color:#2980b9;">灵敏度测试</strong>';
|
||||
}
|
||||
|
||||
// 型号
|
||||
const devTypeMap = {0: '未知', 1: 'PD132', 2: 'DLD110'};
|
||||
document.getElementById("cfg-dev-type").textContent = devTypeMap[param.DevType] || `0x${(param.DevType||0).toString(16)}`;
|
||||
|
||||
// 距离 (DB cm → 显示 mm)
|
||||
document.getElementById("cfg-reset-dis").textContent = param.RestDis != null ? param.RestDis * 10 : '-';
|
||||
document.getElementById("cfg-minus-dis").textContent = param.MinusDis != null ? param.MinusDis * 10 : '-';
|
||||
|
||||
// 触发和释放范围 (SensMin ~ SensMax)
|
||||
document.getElementById("cfg-sens-range").textContent =
|
||||
(param.SensMin != null && param.SensMax != null) ? `${param.SensMin} ~ ${param.SensMax}` : '-';
|
||||
|
||||
// 频率范围 (配置值 ×10 = 实际 Hz)
|
||||
if (param.FreMin != null && param.FreMax != null) {
|
||||
document.getElementById("cfg-fre-range").textContent = `${param.FreMin * 10} ~ ${param.FreMax * 10}`;
|
||||
} else {
|
||||
document.getElementById("cfg-fre-range").textContent = '-';
|
||||
}
|
||||
|
||||
// 线圈信息
|
||||
const coil = [param.coil_num, param.coil_name].filter(Boolean).join(' ');
|
||||
document.getElementById("cfg-coil").textContent = coil || '-';
|
||||
|
||||
// 模拟车辆信息
|
||||
const car = [param.simulate_num, param.car_name].filter(Boolean).join(' ');
|
||||
document.getElementById("cfg-car").textContent = car || '-';
|
||||
|
||||
// 波动参数
|
||||
const waveParams = document.getElementById("cfg-wave-params");
|
||||
if (param.TestMode === 1) {
|
||||
waveParams.style.display = '';
|
||||
document.getElementById("cfg-near-tol").textContent = param.NearTol ?? '-';
|
||||
document.getElementById("cfg-far-tol").textContent = param.FarTol ?? '-';
|
||||
document.getElementById("cfg-step-tol").textContent = param.StepTol ?? '-';
|
||||
document.getElementById("cfg-back-forth").textContent = param.BackForth ?? '-';
|
||||
document.getElementById("cfg-near-stay").textContent = param.NearStay ?? '-';
|
||||
document.getElementById("cfg-far-stay").textContent = param.FarStay ?? '-';
|
||||
} else {
|
||||
waveParams.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
function toggleConfig() {
|
||||
const body = document.getElementById("config-body");
|
||||
const toggle = document.getElementById("config-toggle");
|
||||
if (body.style.display === 'none') {
|
||||
body.style.display = '';
|
||||
toggle.textContent = '收起 ▲';
|
||||
} else {
|
||||
body.style.display = 'none';
|
||||
toggle.textContent = '展开 ▼';
|
||||
}
|
||||
}
|
||||
|
||||
async function loadInitialData() {
|
||||
await loadTestMode();
|
||||
refreshDeviceStatus();
|
||||
@@ -399,6 +464,13 @@ function decodeRelay(v) {
|
||||
return RELAY_MAP[parseInt(v)] || `0x${parseInt(v).toString(16).toUpperCase().padStart(2, '0')}`;
|
||||
}
|
||||
|
||||
function fmtRelay(s) {
|
||||
if (!s) return '-';
|
||||
return s
|
||||
.replace(/继电器有输出/g, '<span style="color:#22c55e;font-weight:600">✅有输出</span>')
|
||||
.replace(/继电器无输出/g, '<span style="color:#ef4444;font-weight:600">❌无输出</span>');
|
||||
}
|
||||
|
||||
// ─── 显示最新结果 ──────────────────────────────
|
||||
|
||||
function renderLatest(data) {
|
||||
@@ -416,7 +488,7 @@ function renderLatest(data) {
|
||||
<p>离开速度:${toSpeed(data.exit_speed)} m/s</p>
|
||||
<p>是否完成:${data.iffinish === '1' ? '是' : '否'}</p>
|
||||
<p>故障信息:${data.fault_info || '无'}</p>
|
||||
<p>继电器:${data.relay_out || decodeRelay(data.relay_code)}</p>
|
||||
<p>继电器:${fmtRelay(data.relay_out) || decodeRelay(data.relay_code)}</p>
|
||||
<p>时间:${fmtTime(data.create_time)}</p>
|
||||
`;
|
||||
}
|
||||
@@ -457,7 +529,7 @@ function renderLatestWave(data) {
|
||||
<p>最远距离:${data.far_dist || '-'} mm</p>
|
||||
<p>进入高度 (B4):${data.b4_enter_dist || '-'} mm</p>
|
||||
<p>离开高度 (B4):${data.b4_leave_dist || '-'} mm</p>
|
||||
<p>继电器:${data.relay_out || decodeRelay(data.relay_code)}</p>
|
||||
<p>继电器:${fmtRelay(data.relay_out) || decodeRelay(data.relay_code)}</p>
|
||||
<p>时间:${fmtTime(data.create_time)}</p>
|
||||
`;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>复位距离 (mm)</label>
|
||||
<label>复位距离 (包含了皮距,mm)</label>
|
||||
<input type="number" id="param-reset-dis" value="0" min="0">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -45,11 +45,11 @@
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>灵敏度最小值</label>
|
||||
<label>触发距离最小值(mm)</label>
|
||||
<input type="number" id="param-sens-min" value="0">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>灵敏度最大值</label>
|
||||
<label>释放距离最大值(mm)</label>
|
||||
<input type="number" id="param-sens-max" value="0">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -61,11 +61,11 @@
|
||||
<input type="number" id="param-fre-max" value="0">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>峰峰值最小值</label>
|
||||
<label>峰峰值最小值 (V)</label>
|
||||
<input type="number" id="param-peak-min" value="0">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>峰峰值最大值</label>
|
||||
<label>峰峰值最大值 (V)</label>
|
||||
<input type="number" id="param-peak-max" value="0">
|
||||
</div>
|
||||
<div class="form-group"><hr style="border-color:#eee; margin:2px 0;"></div>
|
||||
@@ -133,7 +133,7 @@
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>编码</th><th>名称</th><th>灵敏度</th><th>频率(Hz)</th><th>峰峰值</th>
|
||||
<th>编码</th><th>名称</th><th>触发和释放范围(mm)</th><th>频率(Hz)</th><th>峰峰值(V)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="ref-table-body"></tbody>
|
||||
|
||||
@@ -9,7 +9,39 @@
|
||||
<div id="device-status-bar" style="margin-top:4px;font-size:14px;">
|
||||
设备状态:<span id="device-status-text" class="{% if device.state == 1 %}status-online{% elif device.state == 2 %}status-poor{% else %}status-offline{% endif %}">加载中…</span>
|
||||
</div>
|
||||
<div id="test-mode-indicator" style="margin-top:4px;font-size:14px;color:#888;">加载中…</div>
|
||||
<div id="test-mode-indicator" style="margin-top:4px;font-size:14px;color:#888;display:none;">加载中…</div>
|
||||
<div id="config-overview" style="margin-top:8px;background:#f8f9fa;border:1px solid #e0e0e0;border-radius:6px;padding:10px 14px;font-size:13px;display:none;">
|
||||
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:6px;">
|
||||
<strong style="color:#555;">工装配置概览</strong>
|
||||
<span id="config-toggle" style="cursor:pointer;color:#888;font-size:12px;user-select:none;" onclick="toggleConfig()">收起 ▲</span>
|
||||
</div>
|
||||
<div id="config-body">
|
||||
<div style="display:grid;grid-template-columns:1fr 1fr;gap:4px 24px;">
|
||||
<div>测试模式:<span id="cfg-test-mode">-</span></div>
|
||||
<div>车检器型号:<span id="cfg-dev-type">-</span></div>
|
||||
<div>复位距离:<span id="cfg-reset-dis">-</span> mm</div>
|
||||
<div>皮距:<span id="cfg-minus-dis">-</span> mm</div>
|
||||
<div>触发和释放范围:<span id="cfg-sens-range">-</span> mm</div>
|
||||
<div>频率范围:<span id="cfg-fre-range">-</span> Hz</div>
|
||||
</div>
|
||||
<div style="margin-top:6px;padding-top:6px;border-top:1px dashed #ddd;">
|
||||
<div style="display:grid;grid-template-columns:1fr 1fr;gap:4px 24px;">
|
||||
<div>线圈:<span id="cfg-coil">-</span></div>
|
||||
<div>模拟车辆:<span id="cfg-car">-</span></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="cfg-wave-params" style="display:none;margin-top:6px;padding-top:6px;border-top:1px dashed #ddd;">
|
||||
<div style="display:grid;grid-template-columns:1fr 1fr 1fr;gap:4px 16px;">
|
||||
<div>最近容差:<span id="cfg-near-tol">-</span> mm</div>
|
||||
<div>最远容差:<span id="cfg-far-tol">-</span> mm</div>
|
||||
<div>步进容差:<span id="cfg-step-tol">-</span> mm</div>
|
||||
<div>来回次数:<span id="cfg-back-forth">-</span></div>
|
||||
<div>最近停留:<span id="cfg-near-stay">-</span> ms</div>
|
||||
<div>最远停留:<span id="cfg-far-stay">-</span> ms</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="test-layout">
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
<tr>
|
||||
<th>类型编码</th>
|
||||
<th>型号/名称</th>
|
||||
<th>灵敏度范围</th>
|
||||
<th>触发和释放距离范围(mm)</th>
|
||||
<th>频率范围 (Hz)</th>
|
||||
<th>峰峰值范围</th>
|
||||
<th>峰峰值范围(V)</th>
|
||||
<th>备注</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
@@ -47,11 +47,11 @@
|
||||
<input type="text" id="edit-dev-name">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>灵敏度最小值</label>
|
||||
<label>触发距离最小值(mm)</label>
|
||||
<input type="number" id="edit-sens-min" value="0">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>灵敏度最大值</label>
|
||||
<label>释放距离最大值(mm)</label>
|
||||
<input type="number" id="edit-sens-max" value="0">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -63,11 +63,11 @@
|
||||
<input type="number" id="edit-fre-max" value="0">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>峰峰值最小值</label>
|
||||
<label>峰峰值最小值(V)</label>
|
||||
<input type="number" id="edit-peak-min" value="0">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>峰峰值最大值</label>
|
||||
<label>峰峰值最大值(V)</label>
|
||||
<input type="number" id="edit-peak-max" value="0">
|
||||
</div>
|
||||
<div class="form-group full">
|
||||
|
||||
Reference in New Issue
Block a user