132 lines
6.5 KiB
Markdown
132 lines
6.5 KiB
Markdown
# Product Requirements Document: B24SiemensEmulator
|
|
|
|
## Introduction/Overview
|
|
|
|
The B24SiemensEmulator is a Windows Forms application that serves as a PLC simulator for testing the B24SiemensPlugin server. The emulator connects to the existing B24SiemensPlugin (which listens on TCP port 42010) and sends PLCPacket data every second, while displaying the response data received from the plugin. This tool enables developers and testers to simulate PLC behavior without requiring actual hardware.
|
|
|
|
**Goal:** Create a user-friendly PLC emulator that allows manual configuration of packet data and real-time monitoring of server responses for testing B24SiemensPlugin functionality.
|
|
|
|
## Goals
|
|
|
|
1. Enable testing of B24SiemensPlugin without physical PLC hardware
|
|
2. Provide intuitive UI for configuring PLCPacket field values
|
|
3. Display real-time responses from the B24SiemensPlugin server
|
|
4. Support saving and loading of packet configurations
|
|
5. Maintain continuous communication with automatic reconnection handling
|
|
|
|
## User Stories
|
|
|
|
1. **As a developer**, I want to input custom PLCPacket field values through a Windows Forms interface so that I can test different scenarios with the B24SiemensPlugin.
|
|
|
|
2. **As a tester**, I want to see the latest response from the server displayed in real-time so that I can verify the plugin is processing packets correctly.
|
|
|
|
3. **As a developer**, I want to save my current packet configuration to a JSON file so that I can reuse test scenarios without re-entering data.
|
|
|
|
4. **As a tester**, I want the emulator to automatically reconnect when connection is lost so that testing can continue without manual intervention.
|
|
|
|
5. **As a developer**, I want to start and stop packet transmission manually so that I can control when testing occurs.
|
|
|
|
## Functional Requirements
|
|
|
|
### Core Communication
|
|
1. The system must establish TCP connection to B24SiemensPlugin on port 42010
|
|
2. The system must send PLCPacket data every 1 second when transmission is active
|
|
3. The system must receive and display the echo response from the server
|
|
4. The system must handle connection failures gracefully with automatic retry every 1 second
|
|
|
|
### User Interface - Input Fields (Editable)
|
|
5. The system must provide input controls for all PLCPacket fields:
|
|
- **Lifebit** (checkbox) - Connection status bit
|
|
- **KameraStart** (checkbox) - Camera start command bit
|
|
- **Materialnummer** (numeric input) - Material number (integer)
|
|
- **ArtikelnummerBall** (numeric input) - Ball article number (integer)
|
|
- **MaterialnummerFoil** (numeric input) - Foil material number (integer)
|
|
- **Chargennummer** (text input, 5 characters max) - Charge number string
|
|
|
|
### User Interface - Response Display (Read-only)
|
|
6. The system must display received response packet fields in read-only format:
|
|
- All PLCPacket fields showing the latest response values
|
|
- Fields must be clearly labeled and visually distinct from input fields
|
|
|
|
### Control Functions
|
|
7. The system must provide a Start/Stop button to control packet transmission
|
|
8. The system must provide Save Configuration button to export current field values to JSON
|
|
9. The system must provide Load Configuration button to import field values from JSON file
|
|
|
|
### Error Handling & Status
|
|
10. The system must display connection errors in red text on the form when connection fails
|
|
11. The system must hide error messages when connection is successfully established
|
|
12. The system must show connection status (Connected/Disconnected) clearly on the form
|
|
|
|
### Configuration Management
|
|
13. The system must save packet field values to JSON file format
|
|
14. The system must load packet field values from JSON file format
|
|
15. The system must validate loaded JSON data and show error if invalid
|
|
|
|
## Non-Goals (Out of Scope)
|
|
|
|
1. **No modifications to B24SiemensPlugin** - The existing plugin must remain unchanged
|
|
2. **No support for multiple simultaneous connections** - Single connection only
|
|
3. **No logging or history of responses** - Only latest response is displayed
|
|
4. **No advanced network configuration** - Uses hardcoded IP (localhost) and port (42010)
|
|
5. **No custom packet intervals** - Fixed 1-second transmission rate
|
|
6. **No protocol validation** - Assumes B24SiemensPlugin handles malformed packets
|
|
7. **No visual connection status indicators** - Simple text-based status only
|
|
|
|
## Design Considerations
|
|
|
|
### Windows Forms Layout
|
|
- **Left Panel:** Input controls for PLCPacket fields with clear labels
|
|
- **Right Panel:** Read-only display of response packet fields
|
|
- **Top Section:** Connection status and Start/Stop controls
|
|
- **Bottom Section:** Save/Load configuration buttons and error message area
|
|
|
|
### Data Validation
|
|
- Numeric fields should accept valid integer ranges
|
|
- Chargennummer field should limit input to 5 ASCII characters
|
|
- JSON file operations should include basic error handling
|
|
|
|
### Visual Design
|
|
- Group related fields using GroupBox controls
|
|
- Use consistent spacing and alignment
|
|
- Error messages displayed in red text
|
|
- Clear visual separation between input and response sections
|
|
|
|
## Technical Considerations
|
|
|
|
### Framework & Dependencies
|
|
- Target same .NET Framework version as B24SiemensPlugin project
|
|
- Use Windows Forms for UI (System.Windows.Forms)
|
|
- JSON serialization using Newtonsoft.Json or System.Text.Json
|
|
- Async TCP client implementation for network communication
|
|
|
|
### PLCPacket Integration
|
|
- Reference or copy PLCPacket class structure from B24SiemensPlugin
|
|
- Implement same serialization/deserialization logic (19-byte binary format)
|
|
- Handle big-endian byte order for integer fields
|
|
|
|
### Network Implementation
|
|
- TCP client connecting to localhost:42010
|
|
- Asynchronous send/receive operations
|
|
- Timer-based packet transmission (1-second interval)
|
|
- Proper connection cleanup and resource disposal
|
|
|
|
## Success Metrics
|
|
|
|
1. **Functional Success:** Emulator successfully connects to B24SiemensPlugin and exchanges packets
|
|
2. **Usability Success:** Developer can configure and save test scenarios in under 2 minutes
|
|
3. **Reliability Success:** Automatic reconnection works within 5 seconds of connection loss
|
|
4. **Data Integrity Success:** All PLCPacket fields are correctly transmitted and received
|
|
|
|
## Open Questions
|
|
|
|
1. Should the application remember the last used configuration file path?
|
|
2. Do we need input validation ranges for numeric fields (min/max values)?
|
|
3. Should there be a manual "Send Now" button in addition to automatic transmission?
|
|
4. Is there a preferred location for saving configuration files (default directory)?
|
|
|
|
---
|
|
|
|
**Document Version:** 1.0
|
|
**Created:** 2025-07-25
|
|
**Target Implementation:** B24SiemensEmulator Windows Forms Application |