// Boot plans & Multi-Profile Test Queue (ICT + RMT + AMT + MT full profile library & batch runner) (() => { const $ = id => document.getElementById(id); const esc = v => String(v ?? '').replace(/[&<>"']/g, c => ({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c])); const stages = [ ['uip1','ICT Stage 1','自动应用 ICT Stage 1 内存/电压/时序/RMT 参数并发送 exit 继续'], ['amt','AMT 测试菜单','按 AMT 页配置执行 tp 测试序列或发送 exit 跳过'], ['uip2','ICT Stage 2','自动应用 ICT Stage 2 参数并发送 exit 进入 DXE / UEFI'], ['uefi','UEFI 阶段','等待或继续进入 MT 内存测试'], ['mt','MT 内存测试','通过标准 PXE 自动运行 118.efi (mt86.cfg) 或在 Shell 启动'], ]; document.querySelector('[data-page="testing"]').insertAdjacentHTML('afterend',''); document.querySelector('.phase-actions-panel').insertAdjacentHTML('beforebegin',`

测试 Profile 配置库 & 多计划循环测试队列

标准三步使用流程:① 在第 2/3/4 页配置好 ICT、AMT、MT 详细参数并保存 → ② 在下方将当前完整配置保存为一个命名 Profile → ③ 组合多个 Profile 与各自重复次数,一键启动多计划循环测试队列(每轮日志与 JSON 报告独立落盘)。

空闲
第一步:当前工位已保存的 ICT / AMT / MT 详细配置快照(将被打包进新 Profile)
快捷 15 参数任务创建器 & 跨工位批量指派(无需逐页跳转即可快速构建 Profile 并下发多工位)
指派目标工位:

第二步:工位已保存的 Profile 库(可查看详细 ICT/AMT/MT 参数、加载回编辑器或加入队列)

0 个已存 Profile

第三步:待执行的多计划组合队列(按顺序依次执行各 Profile 指定次数)

待下发队列:0 组 Profile

各轮测试执行进度与独立落盘归档记录

轮次编号执行 Profile循环进度启动 ID状态 / 结论独立归档路径 (sol.raw / sol.clean.log / summary.json)
尚无批次运行记录

单次启动计划控制(按当前激活配置单轮运行)

配置单次开机各阶段(ICT Stage 1 / AMT / ICT Stage 2 / UEFI / MT)自动或手动执行方式。

读取中
${stages.map(([key,name,note]) => `
${name}${note}
`).join('')}
单轮计划执行记录 0 条
  1. 无记录

6400 高温罩后端闭环自动联动策略(按工位持久化)

后端自动执行完整温控闭环:开测前校验高温罩在线状态(产线视图强制拦截,工程视图可勾选跳过)→ DDR Training 完成后自动发送 0x01 加热至目标温度 → 多轮中间轮次 PASS 发送 0x08 01 保温 → 最终完成、FAIL、卡死超时、掉电或手动停止时自动发送 0x08 00 吹扫降温。

待加载
配置实时写入后端工位设置。

防卡死超时检测与死机恢复策略(三种处理模式 · 按工位持久化)

超时触发后自动记录死机前日志并向高温罩发 0x08 00 吹扫降温,并按所选模式处理:
① stop(默认):停机并保留死机现场,不发 BMC 重启;
② retry_current_task:自动复位主板并重新执行当前未完成的完整任务/轮次(单轮计划与多计划队列均支持);
③ restart_full_plan:自动复位主板并从头重新执行整个测试计划(回到第 1 个 Profile 第 1 轮)。

保护已启用
waiting_user / paused / 停机换条 / 手动模式提示符下自动豁免防卡死超时计时。
`); let api, formStation = '', tbSeq = 1, wdDirty = false, wdFormStation = '', thPolDirty = false, thPolStation = ''; const drafts = new Map(), tbDrafts = new Map(); const getTbDraft = () => { const id = api ? api.stationId() : 'S1'; if (!tbDrafts.has(id)) tbDrafts.set(id, []); return tbDrafts.get(id); }; const clone = x => JSON.parse(JSON.stringify(x)); const defaults = () => ({preset:'manual',stages:Object.fromEntries(stages.map(([key]) => [key,'manual'])),mt_enabled:false,use_in_runs:false}); const control = () => window.stlFirmware.snapshot(api.stationId()); const current = () => drafts.get(api.stationId()); const stateNames = {idle:'尚未开始',queued:'已排队',running:'自动观察 / 执行',waiting_boot:'等待新启动',waiting_user:'等待人工操作',paused:'已暂停 / 人工接管',completed:'已完成',blocked:'流程被阻止',failed:'执行失败',stopped:'自动执行已停止'}; const stageNames = Object.fromEntries(stages.map(([key,name]) => [key,name])); function enable(id, yes, reason='') { const b=$(id); if(!b)return; b.disabled=!yes || b.dataset.busy==='1'; b.title=yes?'':reason; } async function awaitCommand(method,args,name) { let item=await api.command(method,args,name); const deadline=Date.now()+20000; while (!['succeeded','failed','interrupted'].includes(item.state)) { if(Date.now()>deadline) throw new Error('操作仍在后端队列中,请查看操作队列;没有重新发送。'); await new Promise(resolve=>setTimeout(resolve,180)); try { item=await api.callApi('GetQueueItem',{command_id:item.command_id}); } catch(error) { if(!/NOT_FOUND|not found/i.test(error.message))throw error; } } if(item.state!=='succeeded')throw new Error(item.detail || item.error_code || '操作未完成'); return item; } function summarizeProfile(p) { const uipOvs = (p.uip_overrides || []).filter(x => x.mode === 'override'); const uipRaws = p.uip_raw_commands || []; const ictText = uipOvs.map(x => `${x.id}=${x.value}`).concat(uipRaws).join(', ') || '全部默认'; const amt = p.amt || p.amt_settings || {}; const runAmt = p.run_amt !== undefined ? p.run_amt : amt.action === 'run'; const amtOvs = (amt.overrides || []).map(x => `${x.name} ${x.value}`.trim()).join('; '); const amtText = !runAmt ? '跳过 (exit)' : `${amt.test_command || 'amemdiag 1'}${amtOvs ? ' · ' + amtOvs : ' · 默认全量'}`; const mt = p.mt || p.mt_selection || {}; const runMt = p.run_mt !== undefined ? p.run_mt : true; const mtRange = mt.memory_range === 'custom' ? `${mt.addr_lim_lo || '0x0'}~${mt.addr_lim_hi || ''}` : '全内存'; const mtText = !runMt ? '跳过' : `TSTLIST=${mt.tstlist || (mt.only_tests ? mt.only_tests.join(',') : '0..25')} · ${mtRange}`; return { ictText, amtText, mtText, uipCount: uipOvs.length + uipRaws.length }; } function fill() { const d=current();if(!d)return; $('boot-plan-preset').value=d.plan.preset; for(const select of document.querySelectorAll('[data-plan-stage]'))select.value=d.plan.stages[select.dataset.planStage] || 'manual'; $('boot-plan-mt-enabled').checked=!!d.plan.mt_enabled; $('boot-plan-use-in-runs').checked=!!d.plan.use_in_runs; } function edit() { const d=current();if(!d)return; d.plan={preset:$('boot-plan-preset').value,stages:Object.fromEntries([...document.querySelectorAll('[data-plan-stage]')].map(s=>[s.dataset.planStage,s.value])),mt_enabled:$('boot-plan-mt-enabled').checked,use_in_runs:$('boot-plan-use-in-runs').checked}; d.dirty=true;render(); } function render() { if(!api)return; const c=control();if(!c.boot_plan)return; const id=api.stationId(), saved=JSON.stringify(c.boot_plan); if(!drafts.has(id))drafts.set(id,{plan:{...defaults(),...clone(c.boot_plan)},saved,dirty:false}); const d=current(); if(!d.dirty && d.saved!==saved){d.plan={...defaults(),...clone(c.boot_plan)};d.saved=saved;formStation='';} if(formStation!==id){formStation=id;fill();} const custom=d.plan.preset==='custom'; for(const select of document.querySelectorAll('[data-plan-stage]'))select.disabled=!custom || ['uefi','mt'].includes(select.dataset.planStage)&&!d.plan.mt_enabled; $('boot-plan-preset-note').textContent={auto:'自动执行每个可操作节点;测试开关和参数取各参数页已保存的设置。',custom:'只在选择“等待我操作”的节点停下,其余节点按已保存参数自动执行。',manual:'各输入节点由你手动操作,后端持续观察并保存输出。'}[d.plan.preset] || ''; $('boot-plan-save-state').textContent=d.dirty?'有未保存修改':'已保存配置'; $('boot-plan-edit-note').textContent=d.dirty?'此处修改尚未保存;执行仍以已保存配置为准。':'保存不会立即写固件;执行时复制一份配置快照。'; const x=c.boot_execution || {}, state=x.state || 'idle', live=['running','waiting_boot','waiting_user','paused'].includes(state); $('boot-execution-state').textContent=stateNames[state] || state; $('boot-execution-state').classList.toggle('error',['failed','blocked'].includes(state)); $('boot-execution-stage').textContent=stageNames[x.current_stage] || x.current_stage || '等待开始计划'; $('boot-execution-reason').textContent=x.waiting_reason || x.error || (state==='completed'?'本次启动计划已结束,后端继续采集状态。':state==='paused'?'可在参数页或控制台手动操作,完成后点“继续计划”。':state==='running'?'后端按实际固件输出推进,不需要保持页面打开。':'保存好配置后,选择重启执行或从当前节点开始。'); $('boot-execution-identity').textContent=[x.id&&'执行 '+x.id,c.firmware?.boot_id&&'启动 '+c.firmware.boot_id].filter(Boolean).join(' · '); const unsaved=[d.dirty&&'启动计划',window.stlFirmware.isDirty?.()&&'ICT / MT',window.stlAmt?.isDirty?.()&&'AMT'].filter(Boolean); const launch=api.connected()&&!live&&!unsaved.length&&!api.station()?.run_id; const reason=unsaved.length?'请先保存:'+unsaved.join('、'):api.station()?.run_id?'当前高温轮次正在使用服务器':'当前已有计划在执行'; enable('btn-restart-boot-plan',launch,reason);enable('btn-start-boot-plan',launch,reason); enable('btn-save-boot-plan',api.connected());enable('btn-reload-boot-plan',api.connected()); enable('btn-pause-boot-plan',api.connected()&&['running','waiting_boot','waiting_user'].includes(state)); enable('btn-resume-boot-plan',api.connected()&&state==='paused');enable('btn-stop-boot-plan',api.connected()&&live); $('boot-plan-launch-note').textContent=unsaved.length?'未保存:'+unsaved.join('、')+'。请先保存对应页面。':!c.capabilities?.bmc_power?'未启用 BMC 电源控制:开始计划后按后端提示人工开机 / 复位。停止自动执行不会关闭电源。':'停止自动执行只停止后续自动命令;不代替测试程序退出或主板关机。'; const fw=c.firmware_settings || {}, rmt=(fw.uip_overrides||[]).find(v=>v.id==='rmt'&&v.mode==='override'); $('boot-plan-dependencies').innerHTML=[['uip','ICT / RMT',`${(fw.uip_overrides||[]).filter(v=>v.mode==='override').length} 项覆盖 · RMT ${rmt?.value || '默认 / 不覆盖'}`],['amt','AMT',`${c.amt_settings?.action==='run'?'执行测试':'退出菜单'} · ${(c.amt_settings?.overrides||[]).length} 项配置`],['testing','PXE / 外部 MT',d.plan.mt_enabled?(fw.mt_selection?.efi_path || '118.efi'):'未启用 · 到 UEFI 结束']].map(([page,title,text])=>``).join(''); for(const button of document.querySelectorAll('[data-plan-nav]'))button.onclick=()=>window.stlNavigation.show(button.dataset.planNav); const history=Array.isArray(x.history)?x.history:[]; $('boot-execution-count').textContent=history.length+' 条'; $('boot-execution-history').innerHTML=history.slice(-40).reverse().map(row=>`
  • ${esc(row.stage || row.action || row.kind || '')}${esc(row.message || row.detail || JSON.stringify(row))}
  • `).join('') || '
  • 尚无本次计划记录
  • '; renderTaskBatch(c); } function renderTaskBatch(c) { const fw = c.firmware_settings || {}, amtSaved = c.amt_settings || {}, pxeCfg = c.pxe_control?.mt86_cfg || {}; const curSummary = summarizeProfile({ uip_overrides: fw.uip_overrides || [], uip_raw_commands: fw.uip_raw_commands || [], amt: amtSaved, mt: { ...pxeCfg, ...(fw.mt_selection || {}) }, }); if ($('tb-current-config-preview')) { $('tb-current-config-preview').innerHTML = `
    ICT 阶段配置 (${curSummary.uipCount} 项)
    ${esc(curSummary.ictText)}
    AMT 阶段配置
    ${esc(curSummary.amtText)}
    PXE / MT 阶段配置
    ${esc(curSummary.mtText)}
    `; } const savedProfiles = Array.isArray(c.saved_profiles) ? c.saved_profiles : []; if ($('tb-library-count')) $('tb-library-count').textContent = `${savedProfiles.length} 个已存 Profile`; if ($('tb-saved-profiles-list')) { $('tb-saved-profiles-list').innerHTML = savedProfiles.map((p, idx) => { const s = summarizeProfile(p); return `
    ${esc(p.name || 'Profile-' + (idx + 1))} 默认 ${Number(p.repeat) === 0 ? '无限循环' : '×' + esc(p.repeat || 1) + ' 次'}${p.target_temp_c ? ` ${esc(p.target_temp_c)}℃` : ''}
    ICT: ${esc(s.ictText)} · AMT: ${esc(s.amtText)} · MT: ${esc(s.mtText)}
    `; }).join('') || '

    当前工位尚未保存命名 Profile。在上方输入名称并点“保存到后端 Profile 库”即可永久保存。

    '; document.querySelectorAll('[data-prof-enqueue]').forEach(btn => { btn.onclick = () => { const p = savedProfiles[Number(btn.dataset.profEnqueue)]; if (p) { getTbDraft().push(clone(p)); renderTaskBatch(control()); } }; }); document.querySelectorAll('[data-prof-load]').forEach(btn => { btn.onclick = async () => { const pid = btn.dataset.profLoad; await awaitCommand('LoadProfileToWorkspace', { station_id: api.stationId(), profile_id: pid }, `加载 Profile ${pid}`); window.stlFirmware?.resetDrafts?.(); window.stlAmt?.resetDrafts?.(); await window.stlFirmware.refresh(); api.status(`已将 Profile ${pid} 加载为当前工位激活配置。`); }; }); document.querySelectorAll('[data-prof-del]').forEach(btn => { btn.onclick = async () => { const pid = btn.dataset.profDel; const ok = window.stlUi ? await window.stlUi.confirm('删除 Profile', `确认永久删除工位 ${api.stationId()} 的测试配置 "${pid}" 吗?`, '确认删除', true) : true; if (!ok) return; await awaitCommand('DeleteProfile', { station_id: api.stationId(), profile_id: pid, name: pid }, `删除 Profile ${pid}`); await window.stlFirmware.refresh(); }; }); } const list = getTbDraft(); const hasInfinite = list.some(p => Number(p.repeat) === 0); const totalDraftRuns = list.reduce((acc, p) => acc + (Number(p.repeat) === 0 ? 0 : Number(p.repeat || 1)), 0); if ($('tb-draft-summary')) $('tb-draft-summary').textContent = hasInfinite ? `待下发队列:${list.length} 组 Profile · 含无限连续压测项` : `待下发队列:${list.length} 组 Profile · 合计将连续执行 ${totalDraftRuns} 轮测试`; if ($('tb-draft-list')) { $('tb-draft-list').innerHTML = list.map((p, idx) => { const s = summarizeProfile(p); return `
    步骤 #${idx + 1}:${esc(p.name)}
    ICT: ${esc(s.ictText)} | AMT: ${esc(s.amtText)} | MT: ${esc(s.mtText)}
    `; }).join('') || '

    队列为空:可从上方 Profile 库点“+ 加入待执行队列”,或点“直接加入右侧待执行测试队列”。

    '; document.querySelectorAll('[data-tb-del]').forEach(btn => { btn.onclick = () => { list.splice(Number(btn.dataset.tbDel), 1); renderTaskBatch(control()); }; }); document.querySelectorAll('[data-tb-rep]').forEach(inp => { inp.onchange = () => { const i = Number(inp.dataset.tbRep); if (list[i]) list[i].repeat = Math.max(0, Number(inp.value ?? 1)); renderTaskBatch(control()); }; }); } // Sync cross-station assign checkboxes dynamically const qtBox = $('qt-target-stations'); if (qtBox) { const allSt = window.stlStore?.get('stations') || []; const sig = JSON.stringify(allSt.map(x => x.station_id)); if (qtBox.dataset.sig !== sig) { const checkedPrev = new Set([...qtBox.querySelectorAll('input:checked')].map(i => i.value)); qtBox.dataset.sig = sig; qtBox.innerHTML = allSt.map(st => { const chk = checkedPrev.size ? checkedPrev.has(st.station_id) : st.station_id === api.stationId(); return ``; }).join(''); } } const tb = c.task_batch || {}, tbState = tb.state || 'idle'; const done = Number(tb.total_runs_completed || 0), planned = Number(tb.total_runs_planned || 0); if ($('task-batch-state-badge')) { $('task-batch-state-badge').textContent = stateNames[tbState] || tbState; $('task-batch-state-badge').classList.toggle('error', ['failed', 'blocked'].includes(tbState)); } if ($('tb-live-progress')) $('tb-live-progress').textContent = `${done} / ${planned} 轮`; if ($('tb-live-title')) { $('tb-live-title').textContent = tb.batch_id ? `${tb.current_profile_name || 'Profile'} (第 ${tb.current_repeat || 1}/${tb.current_profile_repeats || 1} 次)` : '尚无活动批次队列'; } if ($('tb-live-detail')) { const fmtElapsed = api.formatElapsed ? api.formatElapsed(c.elapsed_ms || 0) : `${Math.floor((Number(c.elapsed_ms || 0)) / 1000)}s`; $('tb-live-detail').textContent = tb.batch_id ? `批次编号 ${tb.batch_id} · 状态 ${stateNames[tbState] || tbState} · 已完成 ${done}/${planned} 轮 · 总用时 ${fmtElapsed}` : '添加 1 组或多组 Profile 后,点击下方按钮立即按序自动重启并执行。'; } const tbRuns = Array.isArray(tb.runs) ? tb.runs : []; const histRuns = Array.isArray(c.task_history) ? c.task_history : []; const seenIds = new Set(tbRuns.map(r => r.run_id).filter(Boolean)); const runs = tbRuns.length ? histRuns.filter(r => r.run_id && !seenIds.has(r.run_id)).concat(tbRuns).slice(-20) : histRuns.slice(-20); if ($('tb-runs-tbody')) { $('tb-runs-tbody').innerHTML = runs.slice().reverse().map(r => { const fTag = r.fault_code ? ` ${esc(r.fault_code)}${r.hang_scene_preserved ? '·保现场' : ''}` : ''; const gTag = r.serial_gap_detected ? ` serial_gap` : ''; return ` ${esc(r.run_id || '-')} ${esc(r.profile_name || '-')} 第 ${esc(r.repeat_index || 1)} / ${esc(r.repeat_total || 1)} 次 ${esc(r.boot_id || '-')} ${esc(r.verdict || r.state || '-')}${fTag}${gTag} ${esc(r.log_path || r.log_raw_path || r.summary_path || '运行中 (完成后自动归档 sol.raw & summary.json)')} `; }).join('') || '尚无批次运行记录'; } const curSid = api.stationId(); const thPol = c.thermal_policy || {}; if ($('th-policy-badge')) { const en = thPol.auto_enabled !== false; $('th-policy-badge').textContent = en ? `自动控温 ${thPol.target_temp_c ?? 70}℃ · ${thPol.require_online !== false ? '开测校验在线' : '允许离线开测'}` : '自动联动已关闭'; $('th-policy-badge').classList.toggle('connected', en); } if (thPolStation !== curSid) { thPolStation = curSid; thPolDirty = false; } if ($('th-policy-auto') && !thPolDirty) { $('th-policy-auto').checked = thPol.auto_enabled !== false; if ($('th-policy-target')) $('th-policy-target').value = Number(thPol.target_temp_c ?? 70); if ($('th-policy-require-online')) $('th-policy-require-online').checked = thPol.require_online !== false; } const wd = c.watchdog || {}; if ($('wd-live-badge')) { const en = wd.enabled !== false; $('wd-live-badge').textContent = !en ? '已关闭' : wd.fault_code ? `已触发: ${wd.fault_code}` : `启用中 · 双断 ${Math.round((wd.link_lost_timeout_ms || 240000)/1000)}s / 密集阶段 ${Math.round((wd.dense_stage_silence_timeout_ms || 150000)/1000)}s`; $('wd-live-badge').classList.toggle('connected', en && !wd.fault_code); $('wd-live-badge').classList.toggle('error', !!wd.fault_code); } if (wdFormStation !== curSid) { wdFormStation = curSid; wdDirty = false; } if ($('wd-enabled') && !wdDirty) { $('wd-enabled').checked = wd.enabled !== false; if ($('wd-link-lost-s')) $('wd-link-lost-s').value = Math.round(Number(wd.link_lost_timeout_ms || 240000) / 1000); if ($('wd-dense-silence-s')) $('wd-dense-silence-s').value = Math.round(Number(wd.dense_stage_silence_timeout_ms || 150000) / 1000); if ($('wd-amt-silence-s')) $('wd-amt-silence-s').value = Math.round(Number(wd.amt_silence_timeout_ms || 420000) / 1000); if ($('wd-mt-silence-s')) $('wd-mt-silence-s').value = Math.round(Number(wd.mt_silence_timeout_ms || 480000) / 1000); if ($('wd-mt-max-dur-s')) $('wd-mt-max-dur-s').value = Math.round(Number(wd.mt_max_duration_ms || 3600000) / 1000); const act = wd.hang_action || (wd.reboot_on_hang ? 'retry_current_task' : 'stop'); if ($('wd-hang-action')) $('wd-hang-action').value = act; if ($('tb-hang-action')) $('tb-hang-action').value = act; if ($('wd-max-hangs')) $('wd-max-hangs').value = Number(wd.max_consecutive_hangs ?? 2); if ($('tb-max-consecutive-hangs')) $('tb-max-consecutive-hangs').value = Number(wd.max_consecutive_hangs ?? 2); } } async function runWithThermalCheck(method, args, label) { try { return await awaitCommand(method, args, label); } catch (err) { const isThOffline = err?.code === 'THERMAL_OFFLINE' || /THERMAL_OFFLINE|高温罩未连接/.test(err?.message || ''); if (isThOffline && window.stlUi?.getMode?.() === 'engineering' && !args.skip_thermal_check) { const ok = await window.stlUi.confirm('高温罩未连接(工程模式可选跳过)', `${err.message}\n\n当前处于工程视图,是否跳过高温罩在线校验并继续启动测试?`, '跳过校验并启动', false); if (ok) { return await awaitCommand(method, { ...args, skip_thermal_check: true }, `${label} (跳过温控校验)`); } } throw err; } } function init(services) { api=services; $('boot-plan-preset').onchange=()=>{const value=$('boot-plan-preset').value;if(value!=='custom')for(const s of document.querySelectorAll('[data-plan-stage]'))s.value=value==='auto'?'auto':'manual';edit();}; for(const input of document.querySelectorAll('[data-plan-stage],#boot-plan-mt-enabled,#boot-plan-use-in-runs'))input.onchange=edit; for(const wid of ['wd-enabled','wd-link-lost-s','wd-dense-silence-s','wd-amt-silence-s','wd-mt-silence-s','wd-mt-max-dur-s','wd-hang-action','wd-max-hangs']) { if ($(wid)) for (const evt of ['input','change']) $(wid).addEventListener(evt, () => { wdDirty = true; }); } for(const tid of ['th-policy-auto','th-policy-target','th-policy-require-online']) { if ($(tid)) for (const evt of ['input','change']) $(tid).addEventListener(evt, () => { thPolDirty = true; }); } api.bind('btn-save-boot-plan',async()=>{const id=api.stationId(), d=current();if(!d)throw new Error('等待配置加载');const plan=clone(d.plan);await awaitCommand('SaveBootPlan',{station_id:id,plan},'保存启动计划');d.dirty=false;formStation='';await window.stlFirmware.refresh();api.status('启动计划已保存,尚未开始执行。');}); api.bind('btn-reload-boot-plan',async()=>{const id=api.stationId();await window.stlFirmware.refresh();drafts.delete(id);formStation='';render();}); for(const [id,action,name] of [['btn-restart-boot-plan','restart','重启并执行已保存计划'],['btn-start-boot-plan','start','从当前阶段执行计划'],['btn-pause-boot-plan','pause','暂停计划并人工接管'],['btn-resume-boot-plan','resume','继续启动计划'],['btn-stop-boot-plan','stop','停止自动执行']]) { api.bind(id, async () => { if (['start','restart'].includes(action)) { api.useLiveConsole?.(); const skipCheck = window.stlUi?.getMode?.() === 'engineering' && !!$('tb-skip-thermal-check')?.checked; return runWithThermalCheck('ControlBootPlan', { station_id: api.stationId(), action, skip_thermal_check: skipCheck }, name); } return api.command('ControlBootPlan', { action }, name); }); } $('btn-plan-open-input').onclick=()=>{api.useLiveConsole?.();const x=control(),p=x.firmware?.console_prompt?.kind || x.boot_execution?.current_stage;window.stlNavigation.show(p==='amt'?'amt':['uip','uip1','uip2'].includes(p)?'uip':'testing');}; const buildProfileFromForm = () => { const c = control(), fw = c.firmware_settings || {}, amtSaved = clone(c.amt_settings || {}), pxeCfg = c.pxe_control?.mt86_cfg || {}; const name = ($('tb-profile-name')?.value || '').trim() || `Profile-${tbSeq++}`; const repeat = Math.max(0, Number($('tb-profile-repeat')?.value ?? 1)); const targetTempC = Math.max(0, Math.min(254, Number($('tb-profile-temp')?.value ?? 70))); const amtMode = $('tb-profile-amt-mode')?.value || 'current'; const mtMode = $('tb-profile-mt-mode')?.value || 'current'; const runRmt = $('tb-profile-rmt') ? $('tb-profile-rmt').checked : true; let runAmt = true; const amt = { ...amtSaved, test_command: amtSaved.test_command || 'amemdiag 1', exit_after: true }; if (amtMode === 'skip') { runAmt = false; amt.action = 'skip'; } else if (amtMode === 'fast24') { runAmt = true; amt.action = 'run'; amt.tp_end_step = 0; amt.only_tests = Array.from({ length: 24 }, (_, i) => i + 1); amt.overrides = (amt.overrides || []).filter(x => x.name !== 'tp'); } else if (amtMode === 'tp0') { runAmt = true; amt.action = 'run'; amt.tp_end_step = 0; amt.only_tests = [1]; amt.overrides = [{ name: 'tp', value: '0,1,0,0,0,255' }]; } else if (amtMode === 'all24') { runAmt = true; amt.action = 'run'; amt.overrides = (amt.overrides || []).filter(x => x.name !== 'tp'); } else { runAmt = amt.action === 'run'; } let runMt = true; const mt = { ...pxeCfg, ...(fw.mt_selection || {}), efi_path: 'FS0:\\EFI\\118.efi', exit_mode: 2 }; if (mtMode === 'skip') { runMt = false; } else if (mtMode === 'fast64m') { mt.tstlist = '0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25'; mt.memory_range = 'custom'; mt.addr_lim_lo = '0x10000000'; mt.addr_lim_hi = '0x14000000'; } else if (mtMode === 'test0_64m') { mt.tstlist = '0'; mt.memory_range = 'custom'; mt.addr_lim_lo = '0x10000000'; mt.addr_lim_hi = '0x14000000'; } else if (mtMode === 'test0_all') { mt.tstlist = '0'; mt.memory_range = 'all'; } return { profile_id: `PRF-${Date.now()}`, name, repeat, target_temp_c: targetTempC, thermal_auto_enabled: targetTempC > 0, require_thermal_online: targetTempC > 0, run_rmt: runRmt, run_amt: runAmt, run_mt: runMt, uip_overrides: clone(fw.uip_overrides || []), uip_raw_commands: clone(fw.uip_raw_commands || []), amt, mt, }; }; const buildQuickProfile = () => { const name = ($('qt-name')?.value || '').trim() || `Quick-${Date.now()}`; const targetTempC = Math.max(0, Math.min(254, Number($('qt-temp')?.value ?? 70))); const repeat = Math.max(0, Number($('qt-repeat')?.value ?? 1)); const rmtVal = $('qt-rmt')?.value || 'enable'; const uip_overrides = []; if ($('qt-errhandle')?.checked) uip_overrides.push({ id: 'errhandle', mode: 'override', value: 'disable' }); if (rmtVal !== 'disable') uip_overrides.push({ id: 'rmt', mode: 'override', value: rmtVal }); const dr = ($('qt-datarate')?.value || '').trim(); if (dr) uip_overrides.push({ id: 'datarate', mode: 'override', value: dr }); const vdd = ($('qt-vdd')?.value || '').trim(); if (vdd) uip_overrides.push({ id: 'vol.mem.vdd', mode: 'override', value: vdd }); const vddq = ($('qt-vddq')?.value || '').trim(); if (vddq) uip_overrides.push({ id: 'vol.mem.vddq', mode: 'override', value: vddq }); const vpp = ($('qt-vpp')?.value || '').trim(); if (vpp) uip_overrides.push({ id: 'vol.mem.vpp', mode: 'override', value: vpp }); const amtMode = $('qt-amt')?.value || 'all24'; const amt = { action: amtMode === 'skip' ? 'skip' : 'run', test_command: 'amemdiag 1', exit_after: true, overrides: [] }; if (amtMode === 'fast24') { amt.tp_end_step = 0; amt.only_tests = Array.from({ length: 24 }, (_, i) => i + 1); } else if (amtMode === 'tp0') { amt.tp_end_step = 0; amt.only_tests = [1]; amt.overrides = [{ name: 'tp', value: '0,1,0,0,0,255' }]; } const mtRange = $('qt-mt-range')?.value || 'all'; const mt = { efi_path: 'FS0:\\EFI\\118.efi', exit_mode: 2, tstlist: ($('qt-mt-tstlist')?.value || '0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25').trim(), numpass: Math.max(1, Number($('qt-mt-numpass')?.value || 1)), memory_range: mtRange === 'custom' ? 'custom' : 'all', ...(mtRange === 'custom' ? { addr_lim_lo: '0x10000000', addr_lim_hi: '0x14000000' } : {}), }; return { profile_id: `QPRF-${Date.now()}`, name, repeat, target_temp_c: targetTempC, thermal_auto_enabled: targetTempC > 0, require_thermal_online: targetTempC > 0, run_rmt: rmtVal !== 'disable', run_amt: amtMode !== 'skip', run_mt: mtRange !== 'skip', uip_overrides, uip_raw_commands: [], amt, mt, }; }; if ($('btn-qt-save-only')) { api.bind('btn-qt-save-only', async () => { const profile = buildQuickProfile(); await awaitCommand('SaveProfile', { station_id: api.stationId(), profile }, `快捷保存 Profile ${profile.name}`); await window.stlFirmware.refresh(); render(); api.status(`快捷任务配置「${profile.name}」已存入 ${api.stationId()} Profile 库。`); }); } if ($('btn-qt-dispatch-stations')) { api.bind('btn-qt-dispatch-stations', async () => { const targets = [...document.querySelectorAll('.qt-station-cb:checked')].map(c => c.value); if (!targets.length) throw new Error('请至少勾选 1 个目标工位'); const profile = buildQuickProfile(); const stopOnFail = $('qt-stop-fail') ? $('qt-stop-fail').checked : true; const hangAction = $('qt-hang-action')?.value || 'stop'; const skipCheck = window.stlUi?.getMode?.() === 'engineering' && !!$('tb-skip-thermal-check')?.checked; const errs = []; for (const sid of targets) { try { await awaitCommand('SaveProfile', { station_id: sid, profile }, `保存 Profile 至 ${sid}`); await awaitCommand('ConfigureThermalPolicy', { station_id: sid, thermal_policy: { auto_enabled: profile.target_temp_c > 0, target_temp_c: profile.target_temp_c, require_online: profile.target_temp_c > 0 }, }, profile.target_temp_c > 0 ? `配置 ${sid} 目标温度` : `关闭 ${sid} 自动温控`); await runWithThermalCheck('SubmitTaskBatch', { station_id: sid, profiles: [profile], stop_on_fail: stopOnFail, hang_action: hangAction, reboot_on_hang: hangAction !== 'stop', auto_start: true, skip_thermal_check: skipCheck }, `下发并启动 ${sid}`); } catch (e) { errs.push(`${sid}: ${e.message}`); } } await window.stlFirmware.refresh(); render(); if (errs.length) throw new Error(`部分工位下发失败:${errs.join(';')}`); api.status(`已将「${profile.name}」成功下发并启动至 ${targets.join(', ')}。`); }); } if ($('btn-save-thermal-policy')) { api.bind('btn-save-thermal-policy', async () => { const thermal_policy = { auto_enabled: $('th-policy-auto') ? $('th-policy-auto').checked : true, target_temp_c: Math.max(0, Math.min(254, Number($('th-policy-target')?.value ?? 70))), require_online: $('th-policy-require-online') ? $('th-policy-require-online').checked : true, }; await awaitCommand('ConfigureThermalPolicy', { station_id: api.stationId(), thermal_policy }, '保存高温罩闭环联动策略'); thPolDirty = false; await window.stlFirmware.refresh(); render(); api.status(`高温罩闭环联动策略已保存(自动=${thermal_policy.auto_enabled ? '开' : '关'},目标=${thermal_policy.target_temp_c}℃)。`); }); } if ($('btn-tb-save-library')) { api.bind('btn-tb-save-library', async () => { const profile = buildProfileFromForm(); await awaitCommand('SaveProfile', { station_id: api.stationId(), profile }, `保存 Profile ${profile.name}`); await window.stlFirmware.refresh(); if ($('tb-library-status')) $('tb-library-status').textContent = `已存入后端 Profile 库:${profile.name}`; render(); }); } if ($('btn-tb-add-profile')) { $('btn-tb-add-profile').onclick = () => { const p = buildProfileFromForm(); getTbDraft().push(p); tbSeq += 1; if ($('tb-profile-name')) $('tb-profile-name').value = `Profile-${tbSeq}`; renderTaskBatch(control()); }; } if ($('btn-tb-clear-draft')) { $('btn-tb-clear-draft').onclick = () => { tbDrafts.set(api.stationId(), []); renderTaskBatch(control()); }; } if ($('btn-save-watchdog')) { api.bind('btn-save-watchdog', async () => { const hangAction = $('wd-hang-action')?.value || 'stop'; const maxHangs = Math.max(0, Number($('wd-max-hangs')?.value ?? 2)); const watchdog = { enabled: $('wd-enabled') ? $('wd-enabled').checked : true, link_lost_timeout_s: Math.max(6, Number($('wd-link-lost-s')?.value || 240)), dense_stage_silence_timeout_s: Math.max(5, Number($('wd-dense-silence-s')?.value || 150)), amt_silence_timeout_s: Math.max(5, Number($('wd-amt-silence-s')?.value || 420)), mt_silence_timeout_s: Math.max(5, Number($('wd-mt-silence-s')?.value || 480)), mt_max_duration_s: Math.max(0, Number($('wd-mt-max-dur-s')?.value || 3600)), hang_action: hangAction, reboot_on_hang: hangAction !== 'stop', max_consecutive_hangs: maxHangs, reset_consecutive_hangs: true, }; if ($('tb-hang-action')) $('tb-hang-action').value = hangAction; if ($('tb-max-consecutive-hangs')) $('tb-max-consecutive-hangs').value = maxHangs; await awaitCommand('ConfigureWatchdog', { station_id: api.stationId(), watchdog, reset_consecutive_hangs: true }, '保存防卡死与死机恢复参数'); wdDirty = false; await window.stlFirmware.refresh(); render(); api.status('防卡死超时检测与死机恢复模式已保存并持久化。'); }); } if ($('btn-tb-submit-start')) { api.bind('btn-tb-submit-start', async () => { const list = getTbDraft(); const profiles = list.length ? clone(list) : [buildProfileFromForm()]; const stopOnFail = $('tb-stop-on-fail') ? $('tb-stop-on-fail').checked : true; const hangAction = $('tb-hang-action')?.value || 'stop'; const maxConsecutiveHangs = Math.max(0, Number($('tb-max-consecutive-hangs')?.value ?? 2)); const skipCheck = window.stlUi?.getMode?.() === 'engineering' && !!$('tb-skip-thermal-check')?.checked; api.useLiveConsole?.(); await runWithThermalCheck('SubmitTaskBatch', { station_id: api.stationId(), profiles, stop_on_fail: stopOnFail, hang_action: hangAction, reboot_on_hang: hangAction !== 'stop', max_consecutive_hangs: maxConsecutiveHangs, auto_start: true, skip_thermal_check: skipCheck }, '提交并启动多计划测试队列'); await window.stlFirmware.refresh(); render(); }); } for (const [btnId, act, label] of [['btn-tb-pause', 'pause', '暂停任务队列'], ['btn-tb-resume', 'resume', '继续任务队列'], ['btn-tb-stop', 'stop', '停止任务队列']]) { if ($(btnId)) api.bind(btnId, async () => { await api.command('ControlTaskBatch', { station_id: api.stationId(), action: act }, label); await window.stlFirmware.refresh(); render(); }); } } window.stlBootPlan={init,render,awaitCommand,runWithThermalCheck,isDirty:()=>!!current()?.dirty}; })();