# Node-RED Node Configuration Reference Quick reference for configuring nodes when implementing data persistence. --- ## Modified Existing Nodes ### 1. Machine Cycles Function Node ``` Name: Machine cycles Type: function Outputs: 3 (changed from 2) Code: See modified_machine_cycles.js Wiring: Output 1 → [Scrap prompt handler] (existing) Output 2 → [Production state handler] (existing) Output 3 → [Session State DB] (NEW - MySQL node) ``` ### 2. Work Order Buttons Function Node ``` Name: Work Order buttons Type: function Outputs: 5 (changed from 4) Code: See modified_work_order_buttons.js Wiring: Output 1 → [Upload handler] (existing) Output 2 → [Select query handler] (existing) Output 3 → [Start/scrap handler] (existing) Output 4 → [Complete handler] (existing) Output 5 → [Session State DB] (NEW - MySQL node) ``` --- ## New Recovery Flow Nodes ### 3. Startup Inject Node ``` Name: Startup Trigger Type: inject Payload: timestamp Topic: (empty) Repeat: none Once after: 0.1 seconds On start: checked ✓ Wiring: Output → [Query Previous Session] ``` ### 4. Query Previous Session Function ``` Name: Query Previous Session Type: function Outputs: 1 Code: See startup_recovery_query.js Wiring: Output → [Session State DB] ``` ### 5. Process Recovery Response Function ``` Name: Process Recovery Response Type: function Outputs: 2 Code: See process_recovery_response.js Wiring: Output 1 → [Session State DB] (deactivate stale) Output 2 → [Recovery Prompt UI] ``` ### 6. Restore Session Function ``` Name: Restore Session Type: function Outputs: 2 Code: See restore_session.js Triggered by: User clicking "Restore Session" button Wiring: Output 1 → [Session State DB] (update work order status) Output 2 → [Success notification UI] ``` ### 7. Start Fresh Function ``` Name: Start Fresh Type: function Outputs: 2 Code: See start_fresh.js Triggered by: User clicking "Start Fresh" button Wiring: Output 1 → [Session State DB] (deactivate old session) Output 2 → [Success notification UI] ``` ### 8. Session State DB MySQL Node ``` Name: Session State DB Type: mysql Database: [Select your database config - same as work_orders] This node receives inputs from: - Machine cycles (output 3) - Work Order buttons (output 5) - Query Previous Session - Process Recovery Response (output 1) - Restore Session (output 1) - Start Fresh (output 1) ``` --- ## UI Notification Nodes ### Option A: Simple Toast Notifications ``` Node: notification Type: ui_toast Position: top right Duration: 5 seconds Highlight: (varies by message type) Receives from: - Process Recovery Response (output 2) - Restore Session (output 2) - Start Fresh (output 2) ``` ### Option B: Custom Dashboard Modal (Recommended) Create a custom UI template for recovery prompts: ``` Node: Recovery Prompt Modal Type: ui_template Template HTML: (see below) Receives from: - Process Recovery Response (output 2) Sends to: - Restore Session (when "Restore" clicked) - Start Fresh (when "Start Fresh" clicked) ``` **Modal Template Example:** ```html
{{msg.payload.message}}
Work Order: {{msg.payload.details.workOrderId}}
Cycles Completed: {{msg.payload.details.cyclesCompleted}}
Operating Time: {{msg.payload.details.operatingTime}}
Status: {{msg.payload.details.trackingWas}}
Last Update: {{msg.payload.details.lastUpdate}}