void SimulationServer::SimControlThread(shared_ptr<SimControlNode> controlNode)
{
    if (!mThreadBarrier)
        {
            GetLog()->Error()
                << "(SimulationServer) mThreadBarrier is not initialized.\n";
            return;
        }

    bool isInputControl = (controlNode->GetName() == "InputControl");
    bool isRenderControl = (controlNode->GetName() == "RenderControl");
    bool newCycle = false;

    while ( true )
        {
            mThreadBarrier->wait();
            // wait for PrePhysicsUpdate()
            mThreadBarrier->wait();
            newCycle = false;
            if ( controlNode->GetTime() - mSimTime <= 0.005f )
                {
                    newCycle = true;
                    controlNode->StartCycle();
                    controlNode->SenseAgent();
                    controlNode->ActAgent();
                    controlNode->SetSimTime(mSimTime);
                }
            if (isInputControl)
                {
                    while (int(mSumDeltaTime*100) < int(mSimStep*100))
                        controlNode->StartCycle(); // advance the time
                }
            mThreadBarrier->wait();
            if (mExit)
                break;
            // wait for physics update
            mThreadBarrier->wait();
            if (!isRenderControl && newCycle)
                controlNode->EndCycle();
        }
}