Update application event logging, refine plot session management, and enhance configuration handling. Removed obsolete session_id fields, added new application start events, and improved session creation logic for better user experience.

This commit is contained in:
Miguel 2025-08-14 11:36:22 +02:00
parent 9618984a2b
commit 09263d39f8
8 changed files with 66 additions and 77 deletions

View File

@ -1,59 +1,5 @@
{
"events": [
{
"timestamp": "2025-07-17T17:57:48.115971",
"level": "info",
"event_type": "dataset_activated",
"message": "Dataset activated: DAR",
"details": {
"dataset_id": "dar",
"variables_count": 4,
"streaming_count": 4,
"prefix": "dar"
}
},
{
"timestamp": "2025-07-17T17:59:20.355788",
"level": "info",
"event_type": "dataset_activated",
"message": "Dataset activated: DAR",
"details": {
"dataset_id": "dar",
"variables_count": 4,
"streaming_count": 4,
"prefix": "dar"
}
},
{
"timestamp": "2025-07-17T17:59:20.358047",
"level": "info",
"event_type": "streaming_started",
"message": "Multi-dataset streaming started: 1 datasets activated",
"details": {
"activated_datasets": 1,
"total_datasets": 2,
"udp_host": "127.0.0.1",
"udp_port": 9870
}
},
{
"timestamp": "2025-07-17T18:00:01.148713",
"level": "info",
"event_type": "Application started",
"message": "Application initialization completed successfully",
"details": {}
},
{
"timestamp": "2025-07-17T18:00:01.174850",
"level": "info",
"event_type": "plc_connection",
"message": "Successfully connected to PLC 10.1.33.11",
"details": {
"ip": "10.1.33.11",
"rack": 0,
"slot": 2
}
},
{
"timestamp": "2025-07-17T18:00:01.179115",
"level": "info",
@ -10416,8 +10362,60 @@
"event_type": "csv_cleanup_failed",
"message": "CSV cleanup failed: 'max_hours'",
"details": {}
},
{
"timestamp": "2025-08-14T11:34:34.684516",
"level": "info",
"event_type": "application_started",
"message": "Application initialization completed successfully",
"details": {}
},
{
"timestamp": "2025-08-14T11:34:34.733822",
"level": "info",
"event_type": "dataset_activated",
"message": "Dataset activated: DAR",
"details": {
"dataset_id": "DAR",
"variables_count": 3,
"streaming_count": 3,
"prefix": "gateway_phoenix"
}
},
{
"timestamp": "2025-08-14T11:34:34.751250",
"level": "info",
"event_type": "csv_recording_started",
"message": "CSV recording started: 1 datasets activated",
"details": {
"activated_datasets": 1,
"total_datasets": 3
}
},
{
"timestamp": "2025-08-14T11:34:34.780016",
"level": "error",
"event_type": "csv_cleanup_failed",
"message": "CSV cleanup failed: 'max_hours'",
"details": {}
},
{
"timestamp": "2025-08-14T11:34:45.734619",
"level": "info",
"event_type": "plot_session_created",
"message": "Plot session 'UR29' created and started",
"details": {
"session_id": "plot_1",
"variables": [
"UR29_Brix",
"UR29_ma"
],
"time_window": 25,
"trigger_variable": null,
"auto_started": true
}
}
],
"last_updated": "2025-08-14T11:26:02.293765",
"last_updated": "2025-08-14T11:34:45.734619",
"total_entries": 1000
}

View File

@ -3,7 +3,6 @@
{
"id": "plot_1",
"name": "UR29",
"session_id": "plot_1",
"time_window": 25,
"trigger_enabled": false,
"trigger_on_true": true,
@ -14,7 +13,6 @@
{
"id": "Brix",
"name": "Brix",
"session_id": "Brix",
"time_window": 60,
"trigger_enabled": false,
"trigger_on_true": true

View File

@ -16,18 +16,13 @@
"id": {
"type": "string",
"title": "Plot ID",
"description": "Unique identifier for the plot"
"description": "Unique identifier for the plot session"
},
"name": {
"type": "string",
"title": "Plot Name",
"description": "Human-readable name of the plot session"
},
"session_id": {
"type": "string",
"title": "Session ID",
"description": "Session identifier for this plot"
},
"time_window": {
"type": "integer",
"title": "Time window (s)",

View File

@ -10,7 +10,6 @@
"ui:order": [
"id",
"name",
"session_id",
"time_window",
"y_min",
"y_max",
@ -22,15 +21,11 @@
[
{
"name": "id",
"width": 3
},
{
"name": "name",
"width": 4
},
{
"name": "session_id",
"width": 3
"name": "name",
"width": 6
},
{
"name": "time_window",

View File

@ -284,8 +284,10 @@ class PlotManager:
def create_session(self, config: Dict[str, Any]) -> str:
"""Crear una nueva sesión de plotting"""
with self.lock:
session_id = f"plot_{self.session_counter}"
self.session_counter += 1
# Use the ID from config if available, otherwise generate one
session_id = config.get("id") or f"plot_{self.session_counter}"
if not config.get("id"):
self.session_counter += 1
session = PlotSession(session_id, config)
# 🔑 CAMBIO: Crear sesiones en modo activo por defecto para mejor UX

View File

@ -122,7 +122,7 @@ export default function PlotRealtimeSession({
const variableNames = plotVariables.map(v => v.variable_name)
const plotConfig = {
session_id: plotDefinition.id,
id: plotDefinition.id, // Use id instead of session_id
name: plotDefinition.name,
variables: variableNames,
time_window: plotDefinition.time_window || 60,
@ -151,7 +151,7 @@ export default function PlotRealtimeSession({
try {
// Try to create the plot session with current configuration
await api.createPlot({
session_id: plotDefinition.id,
id: plotDefinition.id, // Use id instead of session_id
name: plotDefinition.name,
variables: plotVariables.map(v => v.variable_name), // Simplified format
time_window: localConfig.time_window,

View File

@ -1542,6 +1542,7 @@ def create_plot():
# Crear configuración de la sesión
config = {
"id": data.get("id"), # Use the plot ID from the definition
"name": data.get(
"name", f"Plot {len(streamer.data_streamer.plot_manager.sessions) + 1}"
),

View File

@ -3,11 +3,11 @@
"should_connect": true,
"should_stream": false,
"active_datasets": [
"Fast",
"DAR",
"Test",
"Fast"
"Test"
]
},
"auto_recovery_enabled": true,
"last_update": "2025-08-14T11:26:02.237589"
"last_update": "2025-08-14T11:34:34.761474"
}