35 managerState(eConstructed),
37 managerStateMutex(10000,
"managerStateMutex")
39 setTag(
"StatechartManager");
49 StringVariantContainerBaseMap startParameters)
56 toplevelState = newToplevelState;
57 this->startParameters = startParameters;
75 if (!runningTask && managerState !=
eShutDown)
87 if (enterToplevelState)
89 toplevelState->enter(startParameters);
96 throw LocalException(
"No toplevel state was set in StatechartManager!");
118 toplevelState->disableRunFunction();
121 toplevelState =
nullptr;
126 std::unique_lock lock(eventQueueMutex);
130 runningTask->stop(
false);
133 idleCondition.notify_one();
138 runningTask->waitForFinished();
181 idleCondition.notify_all();
191 if (!runningTask || !runningTask->isRunning())
196 if (!newEvent || !receivingState)
201 EventProcessingData
data;
202 data.event = newEvent;
203 data.receivingState = receivingState;
210 std::unique_lock lock(eventQueueMutex);
211 eventQueue.push_back(
data);
213 idleCondition.notify_one();
221 while (!runningTask->isStopped())
223 EventProcessingData nextEvent;
226 std::unique_lock lock(eventQueueMutex);
228 if (eventQueue.size() > 0)
230 nextEvent = eventQueue.front();
231 eventQueue.pop_front();
237 if (nextEvent.receivingState)
243 nextEvent.receivingState->__processEvent(nextEvent.event);
251 std::unique_lock lock(eventQueueMutex);
254 if (runningTask->isStopped())
259 while (eventQueue.size() == 0 && !runningTask->isStopped())
263 idleCondition.wait(lock);
269 StatechartManager::checkEvent(
const StatechartManager::EventProcessingData& eventData)
const
271 std::unique_lock lock(eventQueueMutex);
272 std::list<EventProcessingData>::const_iterator it = eventQueue.begin();
274 for (; it != eventQueue.end(); it++)
276 if (eventData.receivingState == it->receivingState)