|
@@ -33,39 +33,43 @@
|
|
|
: /^(T1|FU1|VD10|VD11|C2)$/.test(id) ? 'power'
|
|
: /^(T1|FU1|VD10|VD11|C2)$/.test(id) ? 'power'
|
|
|
: /^(VT[25]|R9|R10|R11|YA1|VD9|HL1|R20|S2)$/.test(id) ? 'output' : 'timer';
|
|
: /^(VT[25]|R9|R10|R11|YA1|VD9|HL1|R20|S2)$/.test(id) ? 'output' : 'timer';
|
|
|
let selected = 'memory', selectedPart = '', currentState = 'idle', currentEntered = [], currentCode = '1234', currentExit = false;
|
|
let selected = 'memory', selectedPart = '', currentState = 'idle', currentEntered = [], currentCode = '1234', currentExit = false;
|
|
|
- function inspect(group, id = '') {
|
|
|
|
|
|
|
+ function showComponentTooltip(group, id) {
|
|
|
|
|
+ if (!id) return;
|
|
|
|
|
+ const tooltip = document.querySelector('#componentTooltip');
|
|
|
|
|
+ const info = groups[group];
|
|
|
|
|
+ document.querySelector('#tooltipTitle').textContent = `${id} · ${names[id] || (/^VD[5-8]$/.test(id) ? `Тиристор ${Number(id.slice(2))-4}-й ступени` : /^R/.test(id) ? 'Резистор цепи' : /^C/.test(id) ? 'Конденсатор цепи' : info.title.split(' · ')[1])}`;
|
|
|
|
|
+ document.querySelector('#tooltipText').textContent = names[id] ? `${names[id]}. ${info.text}` : info.text;
|
|
|
|
|
+ tooltip.hidden = false;
|
|
|
|
|
+ }
|
|
|
|
|
+ function inspect(group, id = '', showHint = false) {
|
|
|
selected = group; selectedPart = id;
|
|
selected = group; selectedPart = id;
|
|
|
const info = groups[group];
|
|
const info = groups[group];
|
|
|
- document.querySelector('#detailTitle').textContent = id ? `${id} · ${names[id] || (/^VD[5-8]$/.test(id) ? `Тиристор ${Number(id.slice(2))-4}-й ступени` : /^R/.test(id) ? 'Резистор цепи' : 'Межступенчатый конденсатор')}` : info.title;
|
|
|
|
|
|
|
+ document.querySelectorAll('[data-part]').forEach(p => p.classList.toggle('is-selected', id ? p.dataset.part === id : groupFor(p.dataset.part) === group));
|
|
|
|
|
+ if (showHint) showComponentTooltip(group, id);
|
|
|
|
|
+ }
|
|
|
|
|
+ host.addEventListener('click', e => { const p = e.target.closest('[data-part]'); if (p) inspect(groupFor(p.dataset.part), p.dataset.part, true); });
|
|
|
|
|
+ host.addEventListener('keydown', e => { if ((e.key === 'Enter' || e.key === ' ') && e.target.matches('[data-part]')) { e.preventDefault(); inspect(groupFor(e.target.dataset.part), e.target.dataset.part, true); } });
|
|
|
|
|
+ function renderNodeInfo(group) {
|
|
|
|
|
+ const info = groups[group];
|
|
|
|
|
+ document.querySelector('#detailTitle').textContent = info.title;
|
|
|
document.querySelector('#detailRefs').textContent = info.refs;
|
|
document.querySelector('#detailRefs').textContent = info.refs;
|
|
|
document.querySelector('#detailText').textContent = info.text;
|
|
document.querySelector('#detailText').textContent = info.text;
|
|
|
document.querySelector('#detailRoute').textContent = info.route;
|
|
document.querySelector('#detailRoute').textContent = info.route;
|
|
|
- const deviceStates = {
|
|
|
|
|
- VT1: currentState === 'error' ? 'VT1 закрыт: ток удержания тиристоров прерван.' : 'VT1 открыт: цепочка тиристоров готова принимать управляющие импульсы.',
|
|
|
|
|
- VT2: currentState === 'open' && !currentExit ? 'VT2 проводит ток нагрузки.' : 'VT2 закрыт.' + (currentExit ? ' Нагрузка включена через S2.' : ''),
|
|
|
|
|
- VT5: currentState === 'open' && !currentExit ? 'VT5 проводит и управляет базой VT2.' : 'VT5 закрыт.' + (currentExit ? ' Нагрузка включена через S2.' : ''),
|
|
|
|
|
- VT3: 'VT3 переключается при достижении порога выдержки C1 и завершает цикл открытия.',
|
|
|
|
|
- VT4: 'VT4 поддерживает разрешающий режим VT1; после выдержки его состояние изменяется.',
|
|
|
|
|
- S2: currentExit ? 'S2 удерживается: контакт замкнут, питание нагрузки проходит в обход VT5 / VT2.' : 'S2 отпущена: контакт разомкнут.',
|
|
|
|
|
- C1: currentExit ? 'C1 не задаёт время выхода через S2: нагрузка включена непосредственно кнопкой.' : currentState === 'open' ? 'В реальном устройстве C1 задаёт выдержку. В этом стенде автоматическое закрытие отключено: состояние удерживается до закрытия кнопкой или сброса.' : 'Выдержка открытия не запущена.'
|
|
|
|
|
- };
|
|
|
|
|
- const thyristorIndex = /^VD[5-8]$/.test(id) ? Number(id.slice(2))-4 : 0;
|
|
|
|
|
- document.querySelector('#detailState').textContent = thyristorIndex
|
|
|
|
|
- ? `${id}: ${thyristorIndex <= currentEntered.length ? 'проводит' : 'закрыт'}. Управляющая цифра этой ступени — ${currentCode[thyristorIndex-1]}.`
|
|
|
|
|
- : deviceStates[id] || (group === 'timer' && currentExit ? 'Открытие через S2: таймер не ограничивает удержание кнопки.' : info.state());
|
|
|
|
|
|
|
+ document.querySelector('#detailState').textContent = info.state();
|
|
|
document.querySelectorAll('[data-node]').forEach(b => b.setAttribute('aria-pressed', String(b.dataset.node === group)));
|
|
document.querySelectorAll('[data-node]').forEach(b => b.setAttribute('aria-pressed', String(b.dataset.node === group)));
|
|
|
- document.querySelectorAll('[data-part]').forEach(p => p.classList.toggle('is-selected', id ? p.dataset.part === id : groupFor(p.dataset.part) === group));
|
|
|
|
|
|
|
+ document.querySelector('.component-detail-disclosure').open = true;
|
|
|
}
|
|
}
|
|
|
- host.addEventListener('click', e => { const p = e.target.closest('[data-part]'); if (p) inspect(groupFor(p.dataset.part), p.dataset.part); });
|
|
|
|
|
- host.addEventListener('keydown', e => { if ((e.key === 'Enter' || e.key === ' ') && e.target.matches('[data-part]')) { e.preventDefault(); inspect(groupFor(e.target.dataset.part), e.target.dataset.part); } });
|
|
|
|
|
- document.querySelectorAll('[data-node]').forEach(b => b.onclick = () => inspect(b.dataset.node));
|
|
|
|
|
|
|
+ document.querySelectorAll('[data-node]').forEach(b => b.onclick = () => renderNodeInfo(b.dataset.node));
|
|
|
const componentIds = ['S1','XP/XS',...Array.from({length:20},(_,i)=>'R'+(i+1)),...Array.from({length:6},(_,i)=>'C'+(i+1)),...Array.from({length:11},(_,i)=>'VD'+(i+1)),...Array.from({length:5},(_,i)=>'VT'+(i+1)),'YA1','HL1','S2','T1','FU1'];
|
|
const componentIds = ['S1','XP/XS',...Array.from({length:20},(_,i)=>'R'+(i+1)),...Array.from({length:6},(_,i)=>'C'+(i+1)),...Array.from({length:11},(_,i)=>'VD'+(i+1)),...Array.from({length:5},(_,i)=>'VT'+(i+1)),'YA1','HL1','S2','T1','FU1'];
|
|
|
document.querySelector('#componentList').innerHTML = componentIds.map(id => `<tr><th scope="row"><button type="button" data-inspect="${id}">${id}</button></th><td>${names[id] || (/^VD[5-8]$/.test(id) ? 'Тиристор памяти кода' : /^VD/.test(id) ? 'Диод развязки сигналов' : /^C/.test(id) ? 'Межступенчатый конденсатор' : groups[groupFor(id)].title.split(' · ')[1])}</td><td>${groupFor(id) === 'memory' ? 'Память' : groups[groupFor(id)].title.split(' · ')[1]}</td></tr>`).join('');
|
|
document.querySelector('#componentList').innerHTML = componentIds.map(id => `<tr><th scope="row"><button type="button" data-inspect="${id}">${id}</button></th><td>${names[id] || (/^VD[5-8]$/.test(id) ? 'Тиристор памяти кода' : /^VD/.test(id) ? 'Диод развязки сигналов' : /^C/.test(id) ? 'Межступенчатый конденсатор' : groups[groupFor(id)].title.split(' · ')[1])}</td><td>${groupFor(id) === 'memory' ? 'Память' : groups[groupFor(id)].title.split(' · ')[1]}</td></tr>`).join('');
|
|
|
- document.querySelector('#componentList').onclick = e => { const b = e.target.closest('[data-inspect]'); if (b) { inspect(groupFor(b.dataset.inspect),b.dataset.inspect); document.querySelector('#componentDetail').scrollIntoView({behavior:'smooth',block:'center'}); } };
|
|
|
|
|
|
|
+ document.querySelector('#componentList').onclick = e => { const b = e.target.closest('[data-inspect]'); if (b) inspect(groupFor(b.dataset.inspect),b.dataset.inspect, true); };
|
|
|
|
|
+ document.querySelector('#componentTooltip .component-tooltip__close').onclick = () => { document.querySelector('#componentTooltip').hidden = true; };
|
|
|
|
|
+ document.addEventListener('keydown', e => { if (e.key === 'Escape') document.querySelector('#componentTooltip').hidden = true; });
|
|
|
let zoom = 100;
|
|
let zoom = 100;
|
|
|
const setZoom = value => { zoom = Math.max(75,Math.min(200,value)); host.style.minWidth = '0'; host.style.width = `${Math.max(host.parentElement.clientWidth,1050)*zoom/100}px`; document.querySelector('#zoomValue').textContent = `${zoom}%`; document.querySelector('#zoomOut').disabled = zoom === 75; document.querySelector('#zoomIn').disabled = zoom === 200; };
|
|
const setZoom = value => { zoom = Math.max(75,Math.min(200,value)); host.style.minWidth = '0'; host.style.width = `${Math.max(host.parentElement.clientWidth,1050)*zoom/100}px`; document.querySelector('#zoomValue').textContent = `${zoom}%`; document.querySelector('#zoomOut').disabled = zoom === 75; document.querySelector('#zoomIn').disabled = zoom === 200; };
|
|
|
window.addEventListener('resize', () => setZoom(zoom));
|
|
window.addEventListener('resize', () => setZoom(zoom));
|
|
|
setZoom(100);
|
|
setZoom(100);
|
|
|
|
|
+ renderNodeInfo('memory');
|
|
|
document.querySelector('#zoomIn').onclick = () => setZoom(zoom+25);
|
|
document.querySelector('#zoomIn').onclick = () => setZoom(zoom+25);
|
|
|
document.querySelector('#zoomOut').onclick = () => setZoom(zoom-25);
|
|
document.querySelector('#zoomOut').onclick = () => setZoom(zoom-25);
|
|
|
document.querySelector('#zoomFit').onclick = () => setZoom(100);
|
|
document.querySelector('#zoomFit').onclick = () => setZoom(100);
|