Skip to content

Refactor and enhance NeTrainSim core functionality#31

Closed
AhmedAredah wants to merge 103 commits intoVTTI-CSM:mainfrom
AhmedAredah:server
Closed

Refactor and enhance NeTrainSim core functionality#31
AhmedAredah wants to merge 103 commits intoVTTI-CSM:mainfrom
AhmedAredah:server

Conversation

@AhmedAredah
Copy link
Copy Markdown
Member

Introduce version configuration, switch to CMake, and build the core as a DLL. Enhance simulator capabilities with improved threading, API exposure, and RabbitMQ integration. Implement container management, emissions tracking, and comprehensive documentation. Update GUI elements and logging for better clarity and usability.

Introduces thread-safe data map for APIData management
Adds mutex locking for singleton instance access
Refactors train and network handling for improved clarity
Updates signal-slot connections for better error handling and logging

Improves overall stability and maintainability of the simulator API
Adds detailed documentation for SimulatorAPI, including overview, architecture, usage examples, and error handling.
Enhances signal handling with additional signals for simulation events and train operations.
Refactors internal data structures and methods for better clarity and maintainability.
Corrects the reference from ship list to train list in APIData.
Modifies the simulatorLoaded signal to include APIData for better context.
Modifies the simulatorLoaded signal to pass APIData reference.
Updates forward declaration for Train class.

This change ensures that the APIData is available when the simulatorLoaded signal is emitted, improving data handling and integration.
Introduces a thread-safe API data map to manage network-specific simulation components.
Includes methods for adding, updating, removing, and retrieving API data.
Ensures thread safety using read-write locks.
Refactors container loading and unloading signals for clarity.
Adds methods to count and request unloading of containers at ports.
Introduces method to request current train state as JSON.

Improves overall container management and state reporting.
Adds methods to request unloading containers at terminals and to request the current state as JSON.
Renames `containersAdded` to `containersLoaded` for clarity.
Introduces methods for handling container unloading and counting containers leaving at ports.

Relates to improving train container management and state tracking.
Updates signal connections to include network name checks
Ensures progress bar and results handling are network-specific
Increases pen width for better visibility in train plots
Changes all instances of "ShipNetSim" to "NeTrainSim" in the report widget.
Updates document name, header content, and title to reflect the new branding.
Updates the comment to correctly refer to NeTrainSim DLL instead of ShipNetSimCore DLL in the CMakeLists.txt file.
…d validation

Simplifies the connection setup for train destination events
Adds detailed logging for simulation commands
Introduces a reusable array validation function
Enhances error handling for time step values
Updates simulation progress and results handling
Renames signal parameter from shipID to trainID for clarity
Updates slot parameters to include networkName and containersCount
Adds new slot for simulation progress updates
Introduces m_progressConnection member variable for managing connections
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.
Adds bar length parameter to progress bar
Improves progress bar display with color coding
Ensures progress percentage is capped at 100%
Includes platform-specific enhancements for Windows and Unix-based systems
Enhances logging messages to include specific command names for better clarity
and debugging. Updates log entries for various commands to ensure consistency
and more detailed information.
Introduces carbon dioxide emission tracking for vehicles.
Updates fuel consumption calculations to consider fuel type.
Adds new attributes for emission data in relevant classes.
Includes emission data in JSON output and resets.
Adds functionality to handle the event when all trains in the simulator reach their destinations.
Updates connections and signal handling to emit and process this new event.

Relates to improved event handling and notification.
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.

1 participant