MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / startDemo

Method startDemo

app/src/Misc/DemoLauncher.cpp:64–109  ·  view source on GitHub ↗

* @brief Stage a writable copy, open it under a demo session (never persisted as the last * project), gate the Pro 3D group, then connect so the simulation runs. A failed load * restores the prior mode and session; when the demo is already loaded it re-arms the * session, re-applies mode and gating, and reconnects instead of re-staging. */

Source from the content-addressed store, hash-verified

62 * session, re-applies mode and gating, and reconnects instead of re-staging.
63 */
64bool Misc::DemoLauncher::startDemo()
65{
66 auto& state = AppState::instance();
67 if (state.ephemeralSession())
68 return false;
69
70 auto& io = IO::ConnectionManager::instance();
71 const auto& model = DataModel::ProjectModel::instance();
72
73 if (model.jsonFilePath() == demoProjectPath()) {
74 state.setDemoSession(demoDirectory());
75 state.setOperationMode(SerialStudio::ProjectFile);
76 applyProGating();
77
78 if (io.isConnected())
79 io.disconnectDevice();
80
81 io.connectDevice();
82 return true;
83 }
84
85 QString projectPath;
86 if (!stageDemoProject(projectPath)) {
87 showStartFailure();
88 return false;
89 }
90
91 const auto previousMode = state.operationMode();
92 state.setDemoSession(demoDirectory());
93
94 if (!DataModel::ProjectModel::instance().openJsonFile(projectPath)) {
95 state.setDemoSession(QString());
96 state.setOperationMode(previousMode);
97 qWarning() << "[Demo] Failed to open staged demo project:" << projectPath;
98 showStartFailure();
99 return false;
100 }
101
102 applyProGating();
103
104 if (io.isConnected())
105 io.disconnectDevice();
106
107 io.connectDevice();
108 return true;
109}
110
111//--------------------------------------------------------------------------------------------------
112// Private helpers

Callers

nothing calls this directly

Calls 8

ephemeralSessionMethod · 0.80
setDemoSessionMethod · 0.80
disconnectDeviceMethod · 0.80
connectDeviceMethod · 0.80
operationModeMethod · 0.80
openJsonFileMethod · 0.80
setOperationModeMethod · 0.45
isConnectedMethod · 0.45

Tested by

no test coverage detected