scanning
This commit is contained in:
@@ -23,7 +23,7 @@ class ScannerManager {
|
||||
this.area_px = options.area_px;
|
||||
this.frame_count = options.frame_count;
|
||||
this.scan_state = options.scan_state;
|
||||
this.sim_bt = options.simulate;
|
||||
this.sim_bt = options.simulate || null;
|
||||
this.well_btn = options.well_btn;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,9 @@ class ScannerManager {
|
||||
this.crop.addEventListener('click', (e) => { this._send({ type: 'calibrate', topic: "crop" }); });
|
||||
this.scan_bt.addEventListener('click', (e) => { this.scan(); });
|
||||
this.halt_bt.addEventListener('click', (e) => { this.halt(); });
|
||||
this.sim_bt.addEventListener('click', (e) => { this.simulate(); });
|
||||
|
||||
if (this.sim_bt)
|
||||
this.sim_bt.addEventListener('click', (e) => { this.simulate(); });
|
||||
}
|
||||
|
||||
registerSocket(socket) {
|
||||
@@ -44,18 +46,29 @@ class ScannerManager {
|
||||
try {
|
||||
if (payload.jpeg) { this.container.src = `data:image/jpeg;base64,${payload.jpeg}`; }
|
||||
if (payload.xy) { this.x.textContent=payload.x.toFixed(2); this.y.textContent=payload.y.toFixed(2); }
|
||||
if (payload.state) { this.debug.insertAdjacentHTML('afterbegin', `<li>[ ${++this.debug_count} - ${payload.state} ]: ${payload.msg}</li>`); }
|
||||
if (payload.state) {
|
||||
if (payload.state == 'median') {
|
||||
const span = this.median.querySelector("span.median"); span.style.color = payload.value ? '#f0f' : '#fff';
|
||||
} else if (payload.state == 'crop') {
|
||||
const span = this.crop.querySelector("span.crop"); span.style.color = payload.value ? '#f0f' : '#fff';
|
||||
}
|
||||
this.debug.insertAdjacentHTML('afterbegin', `<li>[ ${++this.debug_count} - ${payload.state} ]: ${payload.msg}</li>`);
|
||||
}
|
||||
if (payload.ts) { this.ts.textContent = timestampToLocalISOString(payload.ts); }
|
||||
if (payload.scan_state) { this.scan_state.textContent=payload.scan_state;}
|
||||
|
||||
if (payload.buttons) { this.well_btn.innerHTML = payload.buttons; }
|
||||
if (payload.buttons) {
|
||||
this.well_btn.innerHTML = payload.buttons;
|
||||
const span = this.crop.querySelector("span.crop"); span.style.color = '#f0f';
|
||||
}
|
||||
if (payload.current >= 0) {
|
||||
document.querySelectorAll('button.w3-button.well').forEach(btn => {
|
||||
document.querySelectorAll('button.w3-btn.well').forEach(btn => {
|
||||
if (btn.value==payload.current) { btn.classList.add('w3-green'); return; }
|
||||
btn.classList.remove('w3-green');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch(e) { console.log(e); }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user