# TODO - PLC Client Web Project ## Objectives - [x] Implement a Flask web server to display PLC data. - [x] Replicate `plc_client.py` output in the web interface. - [x] Improve S7 connection management (robust connection, clean exit). - [x] Use external HTML/CSS/JS files. ## Tasks ### 1. Infrastructure & Setup - [x] Create `todo.md` (Done) - [x] Create folder structure: - `templates/` (for HTML) - `static/css/` (for CSS) - `static/js/` (for JS) - [x] Initialize Flask app in `plc_client_web.py`. ### 2. Backend Logic (Migration from `plc_client.py`) - [x] Analyze `plc_client.py` to identify core logic (polling, parsing, S7 connection). - [x] Refactor S7 communication into a separate class or thread-safe module. - [x] Implement robust connection handling (reconnect on failure, clean exit). - [x] Implement data polling loop that updates a shared state (e.g., a global variable or a thread-safe object). ### 3. Frontend & Integration - [x] Create `templates/index.html`. - [x] Create `static/css/style.css`. - [x] Create `static/js/script.js` to fetch data from the Flask server via AJAX/Fetch API. - [x] Create Flask routes to serve the page and provide data as JSON. ### 4. Refinement - [x] Match `plc_client.py` output exactly (initial phase). - [x] Optimize polling frequency and UI updates. - [x] Error handling and logging for the web version. ## Next Steps - [ ] Transition from hardcoded DB names (DB900, DB901, etc.) to a configurable array of memory objects. - [ ] Implement a persistent data logging system to save sessions to JSON/Database. - [ ] Add advanced chart types (e.g. Histograms, multi-axis charts).