Skip to content

Enhancements & Fixes: Simulator, Network, and Train Improvements#29

Merged
AhmedAredah merged 13 commits intoVTTI-CSM:serverfrom
AhmedAredah:server
Mar 9, 2025
Merged

Enhancements & Fixes: Simulator, Network, and Train Improvements#29
AhmedAredah merged 13 commits intoVTTI-CSM:serverfrom
AhmedAredah:server

Conversation

@AhmedAredah
Copy link
Copy Markdown
Member

This pull request consolidates a range of improvements and bug fixes aimed at enhancing the simulator environment, network JSON support, and train handling functionalities. The main changes include:

  • CMake & Environment:

    • Container Library Path: Updated CMake configuration for improved container library path handling.
    • Simulator Setup: Enhanced the simulator environment setup using QJsonObject for better configuration management.
  • Simulator Enhancements:

    • Pause Handling: Improved pause handling and fixed atomicity issues for more reliable simulation control.
    • Simulator API: Refined error handling and data structures in the simulator API.
  • Network Upgrades:

    • Shared Pointer Support: Added shared_ptr type declaration for the Network module.
    • JSON Integration: Implemented JSON support for reading network nodes and links.
  • Train & Simulation Fixes:

    • Container Management: Updated container location on train addition and added container unloading event handling.
    • Data Consistency: Removed unnecessary parameters and incorporated container count into the JSON state.
    • Trip Time Tracking: Added trip time information to the train JSON state.
    • Trainslist Fix: Corrected string format handling for train path IDs.
    • Logging: Adjusted log messages in SimulationServer for improved clarity.
  • Metatype Enhancements:

    • Declarations: Introduced metatype declarations for pointers and shared pointers to improve type management.

Consolidates platform-specific container library paths into a single variable.
Removes redundant platform-specific bin directory settings and replaces them with a generic check for library directory existence.

Addresses potential configuration inconsistencies across different platforms.
Replaces the use of raw boolean with atomic boolean for pauseFlag to ensure thread safety.
Modifies pause logic to avoid blocking the event loop by processing events during pause.
Removes unnecessary move operation for networkTrains initialization.

Improves overall thread safety and responsiveness of the simulator.
… and add debug checks

- Change `createNewSimulationEnvironment` parameters from `QString` to `QJsonObject` for nodes and links file content.
- Add `CHECK_TRUE` macro for enhanced debug assertion.
- Improve error handling and resource cleanup on setup failure.
- Register `Train*` and `APIData*` meta types.
- Ensure simulator setup success tracking and conditional subsequent actions.
- Use `CHECK_TRUE` for robust QObject connections.
Adds Q_DECLARE_METATYPE for std::shared_ptr<Network> to enable
use of shared pointers with QVariant in the Qt framework.
Implements functionality to read nodes and links from JSON files.
Adds validation and error handling for JSON structure and content.
Enhances flexibility by supporting both file and JSON object inputs.
Ensures containers are assigned a location when added to a train.
Updates container location setting in both addContainer and addContainers methods.
Includes necessary header file adjustment and type declarations.
…nters

Adds Q_DECLARE_METATYPE declarations for pointers and std::shared_ptr for TrainNetworkDefinition and TrainsResults classes to support QVariant usage with these types.
Ensures that train path IDs in JSON can be parsed from both string and number formats. Adds validation and logging for invalid string formats to prevent potential errors during parsing.
Adds a new slot `onContainersUnloaded` to handle container unloading events.
Integrates the new slot with the `SimulatorAPI`.
Improves message consumption logic to avoid busy-loops and CPU hogging.
Enhances error handling in the `processCommand` function.
Introduces retry logic for publishing RabbitMQ messages.
Refines train state storage by replacing QJsonArray with QJsonObject.
Adds null check for train existence before adding containers.
Ensures method exits early if containers are unloaded successfully.

Fixes potential crash due to null pointer reference.
Removes the unused 'this' parameter from the `loadContainersFromJson` call.
Adds the container count to the JSON output when the server build is enabled.
Improves clarity of log messages by fixing typos and formatting.
Corrects the message when unloading containers and when adding containers to a train.
Includes trip time information in the JSON representation of the train's current state for better tracking of trip duration.
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 9, 2025

CLA assistant check
All committers have signed the CLA.

@AhmedAredah AhmedAredah merged commit f596ad4 into VTTI-CSM:server Mar 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants