35 managerState(eConstructed),
37 managerStateMutex(10000,
"managerStateMutex")
39 setTag(
"StatechartManager");
54 toplevelState = newToplevelState;
55 this->startParameters = startParameters;
71 if (!runningTask && managerState !=
eShutDown)
82 if (enterToplevelState)
84 toplevelState->enter(startParameters);
91 throw LocalException(
"No toplevel state was set in StatechartManager!");
114 toplevelState->disableRunFunction();
117 toplevelState =
nullptr;
122 std::unique_lock lock(eventQueueMutex);
126 runningTask->stop(
false);
129 idleCondition.notify_one();
134 runningTask->waitForFinished();
173 idleCondition.notify_all();
182 if (!runningTask || !runningTask->isRunning())
187 if (!newEvent || !receivingState)
193 EventProcessingData
data;
194 data.event = newEvent;
195 data.receivingState = receivingState;
202 std::unique_lock lock(eventQueueMutex);
203 eventQueue.push_back(
data);
205 idleCondition.notify_one();
213 while (!runningTask->isStopped())
215 EventProcessingData nextEvent;
218 std::unique_lock lock(eventQueueMutex);
220 if (eventQueue.size() > 0)
222 nextEvent = eventQueue.front();
223 eventQueue.pop_front();
229 if (nextEvent.receivingState)
235 nextEvent.receivingState->__processEvent(nextEvent.event);
243 std::unique_lock lock(eventQueueMutex);
246 if (runningTask->isStopped())
251 while (eventQueue.size() == 0 && !runningTask->isStopped())
255 idleCondition.wait(lock);
260 bool StatechartManager::checkEvent(
const StatechartManager::EventProcessingData& eventData)
const
262 std::unique_lock lock(eventQueueMutex);
263 std::list<EventProcessingData>::const_iterator it = eventQueue.begin();
265 for (; it != eventQueue.end(); it++)
267 if (eventData.receivingState == it->receivingState)