Update documentation: enhance component overview and key functions for clarity and completeness
This commit is contained in:
+45
-32
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
LightTAM (Lightweight Time And Attendance Manager) is a terminal-based application for managing employee or student attendance using RFID cards. The system is modular, with each component responsible for a specific aspect of the program's functionality. Below is a detailed overview of how the program works, referencing the component UML diagram (`component_uml.png`).
|
LightTAM (Lightweight Time And Attendance Manager) is a terminal-based application for managing employee or student attendance using RFID cards. The system is modular, with each component responsible for a specific aspect of the program's functionality. Below is a detailed overview of how the program works, referencing the component UML diagram (`component_uml.png`).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Component Overview
|
## Component Overview
|
||||||
|
|
||||||
@@ -10,53 +10,66 @@ LightTAM (Lightweight Time And Attendance Manager) is a terminal-based applicati
|
|||||||
|
|
||||||
### 1. **Main Application (`main.c`)**
|
### 1. **Main Application (`main.c`)**
|
||||||
- **Role:** Entry point of the program. Initializes all subsystems, parses command-line arguments, loads the user database, and starts the main event loop.
|
- **Role:** Entry point of the program. Initializes all subsystems, parses command-line arguments, loads the user database, and starts the main event loop.
|
||||||
- **Responsibilities:**
|
- **Key Functions:**
|
||||||
- Initializes the logger, file/database handlers, and TUI.
|
- `main` – program entry, initialization, TUI start, graceful shutdown.
|
||||||
- Loads user data from the specified file.
|
- `handle_sigint` – signal handler for program termination.
|
||||||
- Handles program shutdown and resource cleanup.
|
- Calls to initialize logger (`initLogger`), load users (`loadListFromCSV`), start RFID thread (`uartListener`).
|
||||||
|
|
||||||
### 2. **Terminal User Interface (TUI) (`tui.c`, `tui.h`)**
|
### 2. **Terminal User Interface (TUI) (`tui.c`, `tui.h`)**
|
||||||
- **Role:** Provides all user interaction via a terminal-based UI using ncurses.
|
- **Role:** Provides all user interaction via a terminal-based UI using ncurses.
|
||||||
- **Responsibilities:**
|
- **Key Functions:**
|
||||||
- Displays menus (main, edit, search, user details, etc.).
|
- `mainMenu` – main menu display and navigation.
|
||||||
- Handles keyboard input and navigation.
|
- `personListing` – list all users.
|
||||||
- Calls business logic functions based on user actions.
|
- `personSearch` – search users by name or UUID.
|
||||||
- Shows dialogs for success, warnings, and errors.
|
- `personInfo` – show detailed user info.
|
||||||
- Manages forms for adding/removing users and logging time events.
|
- `editDatabaseMenu` – add, remove, or edit users.
|
||||||
|
- `dialogWindow` – show dialogs (errors, warnings, confirmations).
|
||||||
|
- `exportDialog` – export user or database data.
|
||||||
|
- Keyboard input handling, navigation, and forms.
|
||||||
|
|
||||||
### 3. **User Management (`users.c`, `users.h`)**
|
### 3. **User Management (`users.c`, `users.h`)**
|
||||||
- **Role:** Manages the in-memory linked list of users.
|
- **Role:** Manages the in-memory linked list of users.
|
||||||
- **Responsibilities:**
|
- **Key Functions and Structures:**
|
||||||
- Defines the `person_t`, `node_t`, and `list_t` structures.
|
- `person_t`, `node_t`, `list_t` – data structures for users and the list.
|
||||||
- Provides functions to add, remove, search, and update users.
|
- `addPersonToList` – add a user.
|
||||||
- Handles synchronization (mutex) for thread safety.
|
- `removePersonFromList` – remove a user.
|
||||||
- Calculates presence times and manages user states.
|
- `findPersonByUUID`, `findPersonByName` – search for users.
|
||||||
|
- `updatePerson` – update user data.
|
||||||
|
- `calculatePresenceTime` – compute attendance.
|
||||||
|
- Synchronization using mutex (`pthread_mutex_t`).
|
||||||
|
|
||||||
### 4. **File Handler (`file_handler.c`, `file_handler.h`)**
|
### 4. **File Handler (`file_handler.c`, `file_handler.h`)**
|
||||||
- **Role:** Handles reading and writing user data to CSV files.
|
- **Role:** Handles reading and writing user data to CSV files.
|
||||||
- **Responsibilities:**
|
- **Key Functions:**
|
||||||
- Loads the user list from a CSV file at startup.
|
- `loadListFromCSV` – load user list from file.
|
||||||
- Saves the user list to a CSV file on demand.
|
- `saveListToCSV` – save user list to file.
|
||||||
- Exports user or database information to external files.
|
- `exportPersonInfo` – export a user's data to an external file.
|
||||||
|
|
||||||
### 5. **RFID Handler (`rfid_handler.c`, `rfid_handler.h`)**
|
### 5. **RFID Handler (`rfid_handler.c`, `rfid_handler.h`)**
|
||||||
- **Role:** Interfaces with the RFID reader hardware via a serial port.
|
- **Role:** Interfaces with the RFID reader hardware via a serial port.
|
||||||
- **Responsibilities:**
|
- **Key Functions:**
|
||||||
- Opens and manages the serial port connection.
|
- `uartListener` – thread for reading data from the serial port.
|
||||||
- Reads RFID card data and matches it to users.
|
- `processRFIDEvent` – process a detected RFID card.
|
||||||
- Triggers time event logging when a card is detected.
|
- `sendPacketToDevice` – send data to the device.
|
||||||
|
- CRC check, card-to-user matching, attendance event logging.
|
||||||
|
|
||||||
### 6. **Logger (`logger.c`, `logger.h`)**
|
### 6. **Logger (`logger.c`, `logger.h`)**
|
||||||
- **Role:** Logs all actions, errors, and system events to a journal file.
|
- **Role:** Logs all actions, errors, and system events to a journal file.
|
||||||
- **Responsibilities:**
|
- **Key Functions:**
|
||||||
- Provides logging functions for other modules.
|
- `initLogger` – initialize the logger.
|
||||||
- Records user actions, errors, and system messages for auditing.
|
- `logErrorEvent` – log errors.
|
||||||
|
- `logWarningEvent` – log warnings.
|
||||||
|
- `logHardwareEvent` – log hardware events (e.g., RFID).
|
||||||
|
- `logInfoEvent` – log general information.
|
||||||
|
- `endLogger` – close the log file.
|
||||||
|
|
||||||
### 7. **Utilities (`utils.h`)**
|
### 7. **Utilities (`utils.c`,`utils.h`)**
|
||||||
- **Role:** Provides helper functions used throughout the program.
|
- **Role:** Provides helper functions used throughout the program.
|
||||||
- **Responsibilities:**
|
- **Key Functions:**
|
||||||
- String manipulation, time formatting, and other common tasks.
|
- `printDateAndTimeInString` – time formatting.
|
||||||
|
- String manipulation, input validation, type conversions.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Component Interactions
|
## Component Interactions
|
||||||
|
|
||||||
@@ -66,14 +79,14 @@ LightTAM (Lightweight Time And Attendance Manager) is a terminal-based applicati
|
|||||||
- **RFID Handler ↔ User Management:** When a card is read, the handler updates the user list.
|
- **RFID Handler ↔ User Management:** When a card is read, the handler updates the user list.
|
||||||
- **All Components ↔ Logger:** All modules log actions and errors via the logger.
|
- **All Components ↔ Logger:** All modules log actions and errors via the logger.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Error Handling & Logging
|
## Error Handling & Logging
|
||||||
|
|
||||||
- All errors (file I/O, serial port, invalid input) are reported to the user via TUI dialogs and logged in the journal file.
|
- All errors (file I/O, serial port, invalid input) are reported to the user via TUI dialogs and logged in the journal file.
|
||||||
- The logger ensures traceability for all critical operations.
|
- The logger ensures traceability for all critical operations.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Extensibility
|
## Extensibility
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user