-
+
+
+ |
+
+
+
Events that the card monitors (SET UP EVENT LIST):
Fetched proactive commands:
@@ -2634,6 +2639,8 @@ async function pysimConnect() {
await pysimRefresh();
pysimLoadCommands();
pysimFsRefresh();
+ pysimPollStatusInit();
+ pysimStartBackendPoll();
btn.textContent = t('Connected');
stkCheckMenu();
} catch (e) {
@@ -2645,6 +2652,7 @@ async function pysimConnect() {
}
function pysimDisconnect() {
+ if (_pysimPollTimer) { clearInterval(_pysimPollTimer); _pysimPollTimer = null; }
pysimShowConnected(false);
document.getElementById('pysim-status').textContent = '';
pysimSetConnected(false);
@@ -3096,7 +3104,7 @@ function pysimSwitchSubtab(name) {
document.getElementById('pysim-sub-' + s).classList.toggle('hidden', s !== name);
});
if (name === 'custom') pysimCustomRender();
- if (name === 'proactive') { pysimEventsRender(); pysimProactiveLogRender(); pysimPliRender(); }
+ if (name === 'proactive') { pysimEventsRender(); pysimProactiveLogRender(); pysimPliRender(); pysimPollStatusInit(); }
}
function pysimCmdKeydown(e) {
@@ -3758,7 +3766,7 @@ async function pysimEventsRender() {
html += '
'
+ e.toString(16).padStart(2, '0').toUpperCase()
+ ' ' + esc(name)
- + '
';
+ + '
';
});
el.innerHTML = html;
} catch (e) {
@@ -3910,6 +3918,63 @@ async function pysimStatusPoll() {
}
}
+let _pysimPollTimer = null;
+
+async function pysimPollToggle() {
+ const btn = document.getElementById('pli-pause-btn');
+ if (!btn) return;
+ try {
+ const status = await pysimFetch('/api/poll-status');
+ const newEnabled = !status.enabled;
+ const resp = await pysimFetch('/api/poll-toggle', { enabled: newEnabled });
+ pysimUpdatePollUI(resp.enabled, resp.interval);
+ } catch (e) { /* ignore */ }
+}
+
+function pysimUpdatePollUI(enabled, interval) {
+ const btn = document.getElementById('pli-pause-btn');
+ const stat = document.getElementById('pli-poll-stat');
+ if (!btn) return;
+ if (enabled) {
+ btn.textContent = 'ON';
+ btn.classList.remove('bg-gray-200', 'dark:bg-slate-700', 'text-gray-700', 'dark:text-slate-300');
+ btn.classList.add('bg-emerald-600', 'text-white');
+ } else {
+ btn.textContent = 'OFF';
+ btn.classList.remove('bg-emerald-600', 'text-white');
+ btn.classList.add('bg-gray-200', 'dark:bg-slate-700', 'text-gray-700', 'dark:text-slate-300');
+ }
+ if (stat) stat.textContent = enabled ? '(' + interval + 's)' : '';
+}
+
+async function pysimPollStatusInit() {
+ try {
+ const status = await pysimFetch('/api/poll-status');
+ pysimUpdatePollUI(status.enabled, status.interval);
+ } catch (e) { /* ignore */ }
+}
+
+function pysimStartBackendPoll() {
+ if (_pysimPollTimer) clearInterval(_pysimPollTimer);
+ _pysimPollTimer = setInterval(async () => {
+ try {
+ const [log, stk, ps] = await Promise.all([
+ pysimFetch('/api/proactive-log'),
+ pysimFetch('/api/stk-status'),
+ pysimFetch('/api/poll-status'),
+ ]);
+ const elLog = document.getElementById('pysim-proactive-log');
+ if (elLog && elLog.parentElement && !elLog.parentElement.closest('.hidden')) {
+ pysimProactiveLogRender();
+ }
+ pysimUpdatePollUI(ps.enabled, ps.interval);
+ if (!ps.enabled && !stk.active && !stk.pending) {
+ // card disconnected — clear stale event list
+ }
+ } catch (e) { /* ignore */ }
+ }, 5000);
+}
+
// ===== proactive command log =====
const CMD_NAMES = {
'03': 'POLL INTERVAL', '05': 'SET UP EVENT LIST',