S7_snap7_Stremer_n_Recorder/GEMINI.md

2.0 KiB

Project Overview

This project is a web-based application for monitoring and logging data from a Siemens S7 PLC. It consists of a Python backend and a React frontend.

Backend:

  • Framework: Flask
  • PLC Communication: python-snap7
  • Data Processing: pandas, numpy
  • Functionality:
    • Provides a REST API for interacting with the PLC.
    • Streams data from the PLC in real-time.
    • Logs data to CSV files with rotation and cleanup.
    • Manages PLC and application configurations.
    • Serves the React frontend.

Frontend:

  • Framework: React
  • Build Tool: Vite
  • UI Library: Chakra UI
  • Charting: Chart.js
  • Internationalization: i18next
  • Functionality:
    • Provides a user interface for configuring the PLC connection and data logging.
    • Displays real-time data from the PLC in charts.
    • Allows browsing and visualizing historical data.

Building and Running

1. Install Dependencies:

  • Backend: pip install -r requirements.txt
  • Frontend: cd frontend && npm install

2. Build the Frontend:

cd frontend && npm run build

3. Run the Application:

  • Development:
    1. Start the backend: python main.py
    2. Start the frontend dev server: cd frontend && npm run dev
  • Production (standalone executable):
    1. Build the frontend as described above.
    2. Clean previous builds: rmdir /s /q build dist
    3. Run PyInstaller: conda activate snap7v12; pyinstaller main.spec --clean

The production build will create a single executable file in the dist directory.

Development Conventions

  • The backend follows a modular structure with a core directory containing the main application logic.
  • The frontend is located in the frontend directory and follows standard React project conventions.
  • Configuration is managed through JSON files in the config/data directory.
  • The application uses a rotating logger system for the backend, with logs stored in the .logs directory.