|
SILICON
|
Manages simulation lifecycle and waveform tracing for DiagramScene. More...
#include <diagramSceneSimulationController.hpp>
Classes | |
| struct | TraceConfiguration |
| Ordered buses and group metadata used by waveform tracing. More... | |
Public Member Functions | |
| DiagramSceneSimulationController (DiagramScene &scene) | |
| Constructs a simulation controller bound to a scene. | |
| ~DiagramSceneSimulationController () | |
| Destroys the controller and releases any simulator resources. | |
| bool | enterSimulationMode () |
| Enters interactive simulation mode for the scene. | |
| void | exitSimulationMode () |
| Leaves interactive simulation mode and clears runtime state. | |
| void | handleInputToggled (Bus targetBus, const BusValue &value, Component_weakPtr source) |
| Applies a user input toggle to the running simulator. | |
| void | setFstTraceFile (std::optional< std::string > fileName) |
| Enables or disables FST tracing for the active simulation session. | |
| void | refreshGraphicalOutputs () |
| Refreshes the visual state of all graphical outputs from bus values. | |
| void | clearWaveformTrace () |
| Clears waveform state after the scene has been fully emptied. | |
| void | simulateEditedWaveform (qulonglong duration, std::vector< Sample > inputSnapshots) |
| Runs the circuit from an edited input waveform and publishes output trace. | |
| bool | isFstTracingEnabled () const |
| Returns whether FST tracing is currently enabled. | |
Private Member Functions | |
| void | refreshTraceConfiguration () |
| Refreshes waveform, simulator, and FST tracing from one scene snapshot. | |
| TraceConfiguration | collectTraceConfiguration () const |
| Collects ordered trace buses and their input count. | |
| void | startJob (std::function< Simulator::RunResult()> job) |
| Starts one cancellable simulation operation and its progress UI. | |
| void | setupJobUI () |
| Configures progress dialog, timers, and locks the views before a job. | |
| void | finishJob () |
| Finalizes a completed job on the GUI thread. | |
| void | cancelAndWait () |
| Requests cancellation and waits for the active job before teardown. | |
| bool | isJobFinished () const |
| Returns whether the active job has completed. | |
| void | setJobFinished (bool finished) |
| Publishes whether the active job has completed. | |
| bool | isJobCancellationRequested () const |
| Returns whether cancellation has been requested for the active job. | |
| void | requestJobCancellation () |
| Publishes a cancellation request for the active job. | |
| void | resetJobCancellation () |
| Clears cancellation state before starting a job. | |
| void | resetTrace (const TraceConfiguration &trace) |
| Rebuilds the waveform viewer's signal-name configuration. | |
| void | configureSimulatorTrace (const TraceConfiguration &trace, const std::optional< std::string > &traceFile) |
| Applies trace buses, snapshot collection, and optional FST output. | |
Private Attributes | |
| DiagramScene & | scene |
| Host scene that owns the graphical items and Qt signals. | |
| std::unique_ptr< SILICON::simulation::Session > | simulator |
| Runtime simulation session active only during simulation mode. | |
| std::optional< std::string > | fstTraceFile |
| Optional output file used for live FST tracing. | |
| std::jthread | worker |
| Native worker synchronization. | |
| std::atomic_bool | jobCancellationRequested = false |
| Platform-agnostic thread-safe job state. | |
| std::atomic_bool | jobFinished = true |
| Simulator::RunResult | jobResult = Simulator::RunResult::Completed |
| Result produced by the latest simulation operation. | |
| std::exception_ptr | jobException |
| Exception captured during a job and reported on the GUI thread. | |
| QProgressDialog * | progressDialog = nullptr |
| Delayed cancellation dialog for long-running jobs. | |
| QTimer * | completionTimer = nullptr |
| GUI timer that detects job completion without blocking the event loop. | |
| QTimer * | dialogTimer = nullptr |
| GUI timer that prevents the progress dialog flashing for short jobs. | |
| QList< QPair< qulonglong, std::vector< BusValue > > > | pendingWaveformSnapshots |
| Worker-produced snapshots delivered to the viewer as one GUI batch. | |
Manages simulation lifecycle and waveform tracing for DiagramScene.
This helper owns the temporary runtime-only simulation state used by the editor, including the Simulator instance and optional FST trace output. It keeps DiagramScene focused on interaction and scene management while centralizing simulation entry/exit, live input toggles, output refreshes, and waveform updates.
Definition at line 62 of file diagramSceneSimulationController.hpp.
|
explicit |
Constructs a simulation controller bound to a scene.
| scene | Host scene that provides items, signals, and repaint hooks |
Definition at line 91 of file diagramSceneSimulationController.cpp.
Destroys the controller and releases any simulator resources.
Definition at line 96 of file diagramSceneSimulationController.cpp.
|
private |
Requests cancellation and waits for the active job before teardown.
Definition at line 510 of file diagramSceneSimulationController.cpp.
| void clearWaveformTrace | ( | ) |
Clears waveform state after the scene has been fully emptied.
Definition at line 259 of file diagramSceneSimulationController.cpp.
|
nodiscardprivate |
Collects ordered trace buses and their input count.
Definition at line 552 of file diagramSceneSimulationController.cpp.
|
private |
Applies trace buses, snapshot collection, and optional FST output.
| trace | Trace buses collected from the scene |
| traceFile | Optional destination for FST output |
Definition at line 365 of file diagramSceneSimulationController.cpp.
| bool enterSimulationMode | ( | ) |
Enters interactive simulation mode for the scene.
Recalculates wire-to-component assignments before creating runtime simulation state. If that recalculation fails while assigning an input, startup is aborted and the caller should leave the scene in normal mode.
Definition at line 101 of file diagramSceneSimulationController.cpp.
| void exitSimulationMode | ( | ) |
Leaves interactive simulation mode and clears runtime state.
Definition at line 167 of file diagramSceneSimulationController.cpp.
|
private |
Finalizes a completed job on the GUI thread.
Definition at line 455 of file diagramSceneSimulationController.cpp.
| void handleInputToggled | ( | Bus | targetBus, |
| const BusValue & | value, | ||
| Component_weakPtr | source ) |
Applies a user input toggle to the running simulator.
| targetBus | Logic bus driven by the input widget |
| value | New value to inject |
| source | Component that originated the change |
Definition at line 189 of file diagramSceneSimulationController.cpp.
|
inlinenodiscard |
Returns whether FST tracing is currently enabled.
Definition at line 126 of file diagramSceneSimulationController.hpp.
|
nodiscardprivate |
Returns whether cancellation has been requested for the active job.
Definition at line 536 of file diagramSceneSimulationController.cpp.
|
nodiscardprivate |
Returns whether the active job has completed.
Definition at line 526 of file diagramSceneSimulationController.cpp.
| void refreshGraphicalOutputs | ( | ) |
Refreshes the visual state of all graphical outputs from bus values.
Definition at line 227 of file diagramSceneSimulationController.cpp.
|
private |
Refreshes waveform, simulator, and FST tracing from one scene snapshot.
Definition at line 339 of file diagramSceneSimulationController.cpp.
|
private |
Publishes a cancellation request for the active job.
Definition at line 541 of file diagramSceneSimulationController.cpp.
|
private |
Clears cancellation state before starting a job.
Definition at line 546 of file diagramSceneSimulationController.cpp.
|
private |
Rebuilds the waveform viewer's signal-name configuration.
Definition at line 354 of file diagramSceneSimulationController.cpp.
| void setFstTraceFile | ( | std::optional< std::string > | fileName | ) |
Enables or disables FST tracing for the active simulation session.
| fileName | Destination file or std::nullopt to disable tracing |
Definition at line 213 of file diagramSceneSimulationController.cpp.
|
private |
Publishes whether the active job has completed.
Definition at line 531 of file diagramSceneSimulationController.cpp.
|
private |
Configures progress dialog, timers, and locks the views before a job.
Definition at line 420 of file diagramSceneSimulationController.cpp.
| void simulateEditedWaveform | ( | qulonglong | duration, |
| std::vector< Sample > | inputSnapshots ) |
Runs the circuit from an edited input waveform and publishes output trace.
| duration | Total waveform duration to simulate |
| inputSnapshots | Input-only timestamped values ordered like waveform inputs |
Definition at line 264 of file diagramSceneSimulationController.cpp.
|
private |
Starts one cancellable simulation operation and its progress UI.
| job | Operation that checks jobCancellationRequested cooperatively |
Definition at line 384 of file diagramSceneSimulationController.cpp.
|
private |
GUI timer that detects job completion without blocking the event loop.
Definition at line 217 of file diagramSceneSimulationController.hpp.
|
private |
GUI timer that prevents the progress dialog flashing for short jobs.
Definition at line 220 of file diagramSceneSimulationController.hpp.
|
private |
Optional output file used for live FST tracing.
Definition at line 196 of file diagramSceneSimulationController.hpp.
|
private |
Platform-agnostic thread-safe job state.
Definition at line 204 of file diagramSceneSimulationController.hpp.
|
private |
Exception captured during a job and reported on the GUI thread.
Definition at line 211 of file diagramSceneSimulationController.hpp.
|
private |
Definition at line 205 of file diagramSceneSimulationController.hpp.
|
private |
Result produced by the latest simulation operation.
Definition at line 208 of file diagramSceneSimulationController.hpp.
|
private |
Worker-produced snapshots delivered to the viewer as one GUI batch.
Definition at line 223 of file diagramSceneSimulationController.hpp.
|
private |
Delayed cancellation dialog for long-running jobs.
Definition at line 214 of file diagramSceneSimulationController.hpp.
|
private |
Host scene that owns the graphical items and Qt signals.
Definition at line 190 of file diagramSceneSimulationController.hpp.
|
private |
Runtime simulation session active only during simulation mode.
Definition at line 193 of file diagramSceneSimulationController.hpp.
|
private |
Native worker synchronization.
Definition at line 200 of file diagramSceneSimulationController.hpp.