From 3b1aa988dec1dd0f668ecee5ec3af8f3314fb9a4 Mon Sep 17 00:00:00 2001 From: Ayzen Date: Mon, 29 Sep 2025 16:02:06 +0300 Subject: [PATCH] some fixes --- vna_system/binary_input/current_input.bin | 2 +- vna_system/calibration/current_calibration | 2 +- .../processors/configs/magnitude_config.json | 14 +++++++------- .../core/visualization/magnitude_chart.py | 3 ++- .../web_ui/static/js/modules/acquisition.js | 18 +++++++++--------- .../web_ui/static/js/modules/notifications.js | 15 ++++++++++++++- .../web_ui/static/js/modules/settings.js | 6 +++--- .../web_ui/static/js/modules/websocket.js | 9 +++++++-- 8 files changed, 44 insertions(+), 25 deletions(-) diff --git a/vna_system/binary_input/current_input.bin b/vna_system/binary_input/current_input.bin index 7f4ad93..e701777 120000 --- a/vna_system/binary_input/current_input.bin +++ b/vna_system/binary_input/current_input.bin @@ -1 +1 @@ -config_inputs/s11_start100_stop8800_points1000_bw1khz.bin \ No newline at end of file +config_inputs/s21_start100_stop8800_points1000_bw1khz.bin \ No newline at end of file diff --git a/vna_system/calibration/current_calibration b/vna_system/calibration/current_calibration index ef3d690..635f973 120000 --- a/vna_system/calibration/current_calibration +++ b/vna_system/calibration/current_calibration @@ -1 +1 @@ -s11_start100_stop8800_points1000_bw1khz/lol \ No newline at end of file +s21_start100_stop8800_points1000_bw1khz/bambambum \ No newline at end of file diff --git a/vna_system/core/processors/configs/magnitude_config.json b/vna_system/core/processors/configs/magnitude_config.json index d749561..e45c548 100644 --- a/vna_system/core/processors/configs/magnitude_config.json +++ b/vna_system/core/processors/configs/magnitude_config.json @@ -1,10 +1,10 @@ { - "y_min": -30, - "y_max": 15, - "smoothing_enabled": false, - "smoothing_window": 11, - "marker_enabled": false, - "marker_frequency": 100000009.0, - "grid_enabled": false, + "y_min": -90, + "y_max": 20, + "smoothing_enabled": true, + "smoothing_window": 17, + "marker_enabled": true, + "marker_frequency": 300000009.0, + "grid_enabled": true, "reset_smoothing": false } \ No newline at end of file diff --git a/vna_system/core/visualization/magnitude_chart.py b/vna_system/core/visualization/magnitude_chart.py index e0a5033..03fd5d8 100644 --- a/vna_system/core/visualization/magnitude_chart.py +++ b/vna_system/core/visualization/magnitude_chart.py @@ -164,7 +164,8 @@ def generate_standards_magnitude_plots( for standard_file in Path(calibration_path).glob("*.json"): standard_name = standard_file.stem - if "metadata" in standard_name: + if "metadata" in standard_name or "calibration_info" in standard_name: + logger.debug(f"Skipping {standard_name=}") continue try: diff --git a/vna_system/web_ui/static/js/modules/acquisition.js b/vna_system/web_ui/static/js/modules/acquisition.js index 9109d9d..bba74cf 100644 --- a/vna_system/web_ui/static/js/modules/acquisition.js +++ b/vna_system/web_ui/static/js/modules/acquisition.js @@ -61,14 +61,14 @@ export class AcquisitionManager { const result = await response.json(); if (result.success) { - this.notifications.show(result.message, 'success'); + this.notifications.show({type: 'success', message: result.message}); await this.updateStatus(); } else { - this.notifications.show(result.error || 'Failed to start acquisition', 'error'); + this.notifications.show({type: 'error', message: result.error || 'Failed to start acquisition'}); } } catch (error) { console.error('Error starting acquisition:', error); - this.notifications.show('Failed to start acquisition', 'error'); + this.notifications.show({type: 'error', message: 'Failed to start acquisition'}); } finally { this.setButtonLoading(this.elements.startBtn, false); } @@ -86,14 +86,14 @@ export class AcquisitionManager { const result = await response.json(); if (result.success) { - this.notifications.show(result.message, 'success'); + this.notifications.show({type: 'success', message: result.message}); await this.updateStatus(); } else { - this.notifications.show(result.error || 'Failed to stop acquisition', 'error'); + this.notifications.show({type: 'error', message: result.error || 'Failed to stop acquisition'}); } } catch (error) { console.error('Error stopping acquisition:', error); - this.notifications.show('Failed to stop acquisition', 'error'); + this.notifications.show({type: 'error', message: 'Failed to stop acquisition'}); } finally { this.setButtonLoading(this.elements.stopBtn, false); } @@ -111,14 +111,14 @@ export class AcquisitionManager { const result = await response.json(); if (result.success) { - this.notifications.show(result.message, 'success'); + this.notifications.show({type: 'success', message: result.message}); await this.updateStatus(); } else { - this.notifications.show(result.error || 'Failed to trigger single sweep', 'error'); + this.notifications.show({type: 'error', message: result.error || 'Failed to trigger single sweep'}); } } catch (error) { console.error('Error triggering single sweep:', error); - this.notifications.show('Failed to trigger single sweep', 'error'); + this.notifications.show({type: 'error', message: 'Failed to trigger single sweep'}); } finally { this.setButtonLoading(this.elements.singleSweepBtn, false); } diff --git a/vna_system/web_ui/static/js/modules/notifications.js b/vna_system/web_ui/static/js/modules/notifications.js index 1f91e11..906c097 100644 --- a/vna_system/web_ui/static/js/modules/notifications.js +++ b/vna_system/web_ui/static/js/modules/notifications.js @@ -66,8 +66,21 @@ export class NotificationManager { * Show a notification */ show(options) { - // Check for duplicate notifications within the last 2 seconds + // Validate options + if (!options || typeof options !== 'object') { + console.warn('⚠️ Invalid notification options:', options); + return null; + } + const { type = 'info', title, message } = options; + + // Don't show notification if both title and message are empty + if (!title && !message) { + console.warn('⚠️ Skipping notification with empty title and message'); + return null; + } + + // Check for duplicate notifications within the last 2 seconds const notificationKey = `${type}:${title}:${message}`; const now = Date.now(); const lastShown = this.recentNotifications.get(notificationKey); diff --git a/vna_system/web_ui/static/js/modules/settings.js b/vna_system/web_ui/static/js/modules/settings.js index 7fd929c..6ddd947 100644 --- a/vna_system/web_ui/static/js/modules/settings.js +++ b/vna_system/web_ui/static/js/modules/settings.js @@ -578,12 +578,12 @@ export class SettingsManager { this.pendingStandard = standard; this.websocket?.on?.('processor_result', this._boundHandleSweepForCalibration); - // Таймаут ожидания (30с) + // Таймаут ожидания (5с) this._clearCalibrationTimeout(); this.calibrationTimeout = setTimeout(() => { - this._notify('warning', 'Calibration Timeout', `No sweep received within 30 seconds for ${standard.toUpperCase()}. Please try again.`); + this._notify('warning', 'Calibration Timeout', `No sweep received within 5 seconds for ${standard.toUpperCase()}. Please try again.`); this._resetCalibrationCaptureState(standard); - }, 30000); + }, 5000); } catch (e) { console.error('Start standard capture failed:', e); this._notify('error', 'Calibration Error', 'Failed to start calibration standard capture'); diff --git a/vna_system/web_ui/static/js/modules/websocket.js b/vna_system/web_ui/static/js/modules/websocket.js index c659770..6f4e2c4 100644 --- a/vna_system/web_ui/static/js/modules/websocket.js +++ b/vna_system/web_ui/static/js/modules/websocket.js @@ -148,8 +148,8 @@ export class WebSocketManager { console.error('JSON parse error:', jsonError); this.notifications?.show?.({ type: 'error', - title: 'WebSocket Error', - message: 'Received invalid JSON from server' + title: 'JSON Parse Error', + message: `Failed to parse JSON: ${data.substring(0, 200)}${data.length > 200 ? '...' : ''}` }); return; } @@ -176,6 +176,11 @@ export class WebSocketManager { } catch (e) { console.error('❌ Failed to parse WebSocket JSON:', e); console.log('📝 Raw message:', data); + this.notifications?.show?.({ + type: 'error', + title: 'Message Processing Error', + message: `Error processing message: ${data.substring(0, 200)}${data.length > 200 ? '...' : ''}` + }); } }