Beispiel #1
0
int BaseApp::InternalSetup()
{
	try
	{
		Setup();
	}
	catch(const std::exception & e)
	{
		Log::Error("Failed to setup application ({})", e.what());
		system("pause");
		return EXIT_FAILURE;
	}

	try
	{
		Time::Update();
		InternalOnStart();
		if(!_internal_started)
			throw Exception("InternalOnStart() was not called on BaseApp!");

		OnStart();
	}
	catch(const std::exception & e)
	{
		Log::Error("Exception: {}", e.what());
		InternalOnForceQuit();
		OnForceQuit();
		system("pause");
		return EXIT_FAILURE;
	}

	return EXIT_SUCCESS;
}
Beispiel #2
0
tResult cJuryModule::Init()
{
    // connect the widgets and methods
    connect(m_pWidget->m_btnFileSelection, SIGNAL(released()), this, SLOT(OnManeuverListButton()));
    connect(m_pWidget->m_btnFileSelectionDescr, SIGNAL(released()), this, SLOT(OnDescriptionFileButton()));
    connect(m_pWidget->m_edtManeuverFile, SIGNAL(returnPressed()), this, SLOT(OnManeuverListSelected()));
    connect(m_pWidget->m_edtManeuverFile, SIGNAL(editingFinished()), this, SLOT(OnManeuverListSelected()));
    connect(m_pWidget->m_btnEmergencyStop, SIGNAL(released()), this, SLOT(OnEmergencyStop()));
    connect(m_pWidget->m_btnStart, SIGNAL(released()), this, SLOT(OnStart()));
    connect(m_pWidget->m_btnStop, SIGNAL(released()), this, SLOT(OnStop()));
    connect(m_pWidget->m_btnRequest, SIGNAL(released()), this, SLOT(OnRequestReady()));
    connect(m_pWidget->m_btnConnectDisconnect, SIGNAL(released()), this, SLOT(OnConnectDisconnect()));
    connect(m_pWidget->m_btnManeuverlist, SIGNAL(released()), this, SLOT(SendManeuverList()));
    connect(this, SIGNAL(SetDriverState(int, int)), this, SLOT(OnDriverState(int, int)));    
    connect(this, SIGNAL(SetLogText(QString)), this, SLOT(OnAppendText(QString)));
    connect(this, SIGNAL(SetConnectionState()), this, SLOT(OnConnectionStateChange()));
    connect(this, SIGNAL(SetControlState()), this, SLOT(OnControlState()));
    connect(m_pWidget->m_comboSector, SIGNAL(currentIndexChanged(int)), this, SLOT(OnComboSectionBoxChanged(int)));
    connect(m_pWidget->m_comboManeuver, SIGNAL(currentIndexChanged(int)), this, SLOT(OnComboActionBoxChanged(int)));
    connect(m_pWidget->m_cbxLocalHost, SIGNAL(stateChanged(int)), this, SLOT(OnLocalhostCheckChanged(int)));
    connect(m_pWidget->m_btnOpenTerminal, SIGNAL(released()), this, SLOT(OnOpenTerminalProcess()));
    connect(&m_oTerminalProcess, SIGNAL(started()), this, SLOT(OnProcessStarted()));
    connect(&m_oTerminalProcess, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(OnProcessFinished(int,QProcess::ExitStatus)));
    connect(&m_oTerminalProcess, SIGNAL(error(QProcess::ProcessError)), this, SLOT(OnProcessError(QProcess::ProcessError)));

    // set the connection and control state
    SetConnectionState();
    SetControlState();
    
    RETURN_NOERROR;
}
Beispiel #3
0
//
//   FUNCTION: Start(DWORD, PWSTR *)
//
//   PURPOSE: The function starts the service. It calls the OnStart virtual 
//   function in which you can specify the actions to take when the service 
//   starts. If an error occurs during the startup, the error will be logged 
//   in the Application event log, and the service will be stopped.
//
//   PARAMETERS:
//   * dwArgc   - number of command line arguments
//   * lpszArgv - array of command line arguments
//
void Start(DWORD dwArgc, PSTR *pszArgv)
{
	DBGPrint("Called\n");
    try
    {
        // Tell SCM that the service is starting.
        BaseSetServiceStatus(SERVICE_START_PENDING,NO_ERROR,0);

        // Perform service-specific initialization.
        OnStart(dwArgc, pszArgv);

        // Tell SCM that the service is started.
        BaseSetServiceStatus(SERVICE_RUNNING,NO_ERROR,0);
    }
    catch (DWORD dwError)
    {
        // Log the error.
        DBGPrint("Service Start");

        // Set the service status to be stopped.
        SetServiceStatus((SERVICE_STATUS_HANDLE)SERVICE_STOPPED, (LPSERVICE_STATUS) dwError);
    }
    catch (...)
    {
        // Log the error.
        DBGPrint("Service failed to start.");

        // Set the service status to be stopped.
        BaseSetServiceStatus(SERVICE_STOPPED,NO_ERROR,0);
    }

	DBGPrint("Returning\n");
}
void CWplayView::OnEasy() 
{
	// TODO: Add your command handler code here
	OnStart();
	startflag=1;
	MessageBox("人人模式已开启");
}
Beispiel #5
0
void Animation::Start(int _groupId)
{
//#ifdef ANIMATIONS_DEBUG
//	if(AnimationManager::Instance()->IsAnimationLoggerEnabled())
//	{
//		Logger::Debug("ANIMATION LOGGER: Animation::Start 0x%x    for owner 0x%x", (int)this, (int)owner);
//	}
//#endif
	//Logger::Debug("Animation started: %d", _groupId);
	Reset();
	groupId = _groupId;
	
	Animation * prevAnimation = AnimationManager::Instance()->FindLastAnimation(owner, groupId);
	
	if (!prevAnimation || (prevAnimation == this))
	{
		//Logger::Debug("real anim start");
		state |= STATE_IN_PROGRESS;
		OnStart();
	}
	else
	{	
		//Logger::Debug("add to queue");
//#ifdef ANIMATIONS_DEBUG
//		if(AnimationManager::Instance()->IsAnimationLoggerEnabled())
//		{
//			Logger::Debug("ANIMATION LOGGER: Animation::Set animation 0x%x as next for 0x%x   for owner 0x%x", (int)this, (int)prevAnimation, (int)owner);
//		}
//#endif
		prevAnimation->next = this;
	}
}
//
//   FUNCTION: CServiceBase::Start(DWORD, PWSTR *)
//
//   PURPOSE: The function starts the service. It calls the OnStart virtual 
//   function in which you can specify the actions to take when the service 
//   starts. If an error occurs during the startup, the error will be logged 
//   in the Application event log, and the service will be stopped.
//
//   PARAMETERS:
//   * dwArgc   - number of command line arguments
//   * lpszArgv - array of command line arguments
//
void CServiceBase::Start(DWORD dwArgc, PWSTR *pszArgv)
{
    WriteEventLogEntry(L"Service starting.", TRACE_LEVEL_ERROR);
    try
    {
        // Tell SCM that the service is starting.
        SetServiceStatus(SERVICE_START_PENDING);

        // Perform service-specific initialization.
        OnStart(dwArgc, pszArgv);

        // Tell SCM that the service is started.
        SetServiceStatus(SERVICE_RUNNING);
    }
    catch (DWORD dwError)
    {
        // Log the error.
        WriteErrorLogEntry(L"Service failed to start.", dwError);

        // Set the service status to be stopped.
        SetServiceStatus(SERVICE_STOPPED, dwError);
    }
    catch (...)
    {
        // Log the error.
        WriteEventLogEntry(L"Service failed to start.", TRACE_LEVEL_ERROR);

        // Set the service status to be stopped.
        SetServiceStatus(SERVICE_STOPPED);
    }
}
Beispiel #7
0
HRESULT Filter::Run(REFERENCE_TIME start)
{
    Lock lock;

    HRESULT hr = lock.Seize(this);

    if (FAILED(hr))
        return hr;

    //odbgstream os;
    //os << "mkvsplit::Filter::Run" << endl;

    switch (m_state)
    {
        case State_Stopped:
            OnStart();
            break;

        case State_Paused:
        case State_Running:
        default:
            break;
    }

    m_start = start;
    m_state = State_Running;

    return S_OK;
}
Beispiel #8
0
////////////////////////////////////////////////////////////
/// Start playing the audio stream
////////////////////////////////////////////////////////////
void SoundStream::Play()
{
    // Check if the sound parameters have been set
    if (myFormat == 0)
    {
        std::cerr << "Failed to play audio stream : sound parameters have not been initialized (call Initialize first)" << std::endl;
        return;
    }

    // If the sound is already playing (probably paused), just resume it
    if (myIsStreaming)
    {
        Sound::Play();
        return;
    }

    // Notify the derived class
    if (OnStart())
    {
        // Start updating the stream in a separate thread to avoid blocking the application
        mySamplesProcessed = 0;
        myIsStreaming = true;
        Launch();
    }
}
Beispiel #9
0
int main()
{
	OnStart( "" );
	OnStop();

	return 0;
}
Beispiel #10
0
void UGame::Start()
{
	Init();
	SimulationDateTime = InitialSimulationDateTime;
	OnStart();
	BPF_OnStart();
}
Beispiel #11
0
Controller::Controller(string ConfFile) {

	auto start = chrono::steady_clock::now();

	try {

		OnStart(ConfFile);
		DispatchWs();

	} catch (int e) {

		XaLibError Error;
		string ErrorDesc=Error.GetError(e);

		SendHtmlHeaders();
		SendError(e,ErrorDesc);

		//cout<<"<WsData><error><number>"+FromIntToString(e)+"</number><description>"+ErrorDesc+"</description></error></WsData>"<<endl;

	} catch (...) {

		SendHtmlHeaders();
		cout<<"Generic not handled Error"<<endl;

	}

	auto diff = chrono::steady_clock::now() - start;
	string duration=to_string(chrono::duration <double, std::milli> (diff).count());

	LOG.Write("INF", __FILE__, __FUNCTION__,__LINE__,"Action Execution Time In Ms -> "+duration);

	//////VERIFICARE QUESTO CLOSE
	LOG.Close();
};
Beispiel #12
0
////////////////////////////////////////////////////////////
/// /see SoundStream::OnGetData
////////////////////////////////////////////////////////////
bool Music::OnGetData(SoundStream::Chunk& Data)
{
    // Fill the chunk parameters
    Data.Samples   = &mySamples[0];
    Data.NbSamples = myFile->Read(&mySamples[0], mySamples.size());

    // Check if we have reached the end of the audio file
    if (Data.NbSamples < mySamples.size())
    {
        // Check if we must loop
        if (myLoop)
        {
            if (OnStart())
            {
                // We succeeded to restart the audio playback
                Data.NbSamples += myFile->Read(&mySamples[Data.NbSamples], mySamples.size() - Data.NbSamples);
                return true;
            }
        }

        // No more audio samples to read : we stop the playback
        return false;
    }

    // End of audio file has not been reached, continue playback
    return true;
}
Beispiel #13
0
void StateMachine::Update( float dt )
{
	//状态机自生的更新状态回调
	if (m_bIsFirstUpdate)
	{
		OnStart();
		OnUpdate(dt);
		m_bIsFirstUpdate = false;

		if (m_pCurState != nullptr)
			m_pCurState->OnEnter();
	}
	else
	{
		OnUpdate(dt);
	}
	
	//检查状态的改变,并回调相应的函数
	if (m_pCurState != nullptr)
	{
		int nStateIdOfChange = m_pCurState->OnCheckTranslation(m_oParameter);
		//状态需要改变
		if (nStateIdOfChange != m_pCurState->GetStateId())
		{
			MapStateList::const_iterator iterFinder = m_mapStateList.find(nStateIdOfChange);
			if ( iterFinder != m_mapStateList.end() )
			{
				m_pCurState->OnExit();
				m_pCurState = iterFinder->second;
				m_pCurState->OnEnter();
			}
		}
		m_pCurState->OnUpdate(dt);
	}
}
HRESULT Filter::Run(REFERENCE_TIME start)
{
    Lock lock;

    HRESULT hr = lock.Seize(this);

    if (FAILED(hr))
        return hr;

#ifdef _DEBUG
    odbgstream os;
    os << "webmvorbisencoder::Filter::Run" << endl;
#endif

    switch (m_state)
    {
        case State_Stopped:
            OnStart();
            break;

        case State_Paused:
        case State_Running:
        default:
            break;
    }

    m_start = start;
    m_state = State_Running;

    return S_OK;
}
void ribi::pylos::QtPylosMenuDialog::mousePressEvent(QMouseEvent *)
{
  if (ui->label_theme->underMouse())
  {
    m_theme_bw = !m_theme_bw;
    if (m_theme_bw)
      ui->label_theme->setText("Theme: black & white");
    else
      ui->label_theme->setText("Theme: red & blue");
    return;
  }

  if (ui->label_type->underMouse())
  {
    m_type_basic = !m_type_basic;
    if (m_type_basic)
      ui->label_type->setText("Game type: basic");
    else
      ui->label_type->setText("Game type: advanced");
    return;
  }

  switch (m_selected)
  {
    case 0: OnStart(); return;
    case 1: OnInstructions(); return;
    case 2: OnAbout(); return;
    case 3: this->close(); return;
  }
}
Beispiel #16
0
//启动函数
bool CBaseMainManageForZ::Start()
{
	if ((this==NULL)||(m_bRun==true)||(m_bInit==false)) return false;

	//建立事件
	CEvent StartEvent(FALSE,TRUE,NULL,NULL);
	if (StartEvent==NULL) throw new CAFCException(TEXT("CBaseMainManageForZ::Start 事件建立失败"),0x41C);

	//建立完成端口
	m_hCompletePort=::CreateIoCompletionPort(INVALID_HANDLE_VALUE,NULL,NULL,0);
	if (m_hCompletePort==NULL) throw new CAFCException(TEXT("CBaseMainManageForZ::Start m_hCompletePort 建立失败"),0x41D);
	m_DataLine.SetCompletionHandle(m_hCompletePort);

	//启动处理线程
	UINT uThreadID=0;
	HandleThreadStartStruct	ThreadStartData;
	ThreadStartData.pMainManage=this;
	ThreadStartData.hCompletionPort=m_hCompletePort;
	ThreadStartData.hEvent=StartEvent;
	m_hHandleThread=(HANDLE)_beginthreadex(NULL,0,LineDataHandleThread,&ThreadStartData,0,&uThreadID);
	if (m_hHandleThread==NULL) throw new CAFCException(TEXT("CBaseMainManageForZ::Start LineDataHandleThread 线程启动失败"),0x41E);
	WaitForSingleObject(StartEvent,INFINITE);

	//启动组件
	AFCKernelStart();
	if (m_KernelData.bStartSQLDataBase)	m_SQLDataManage.Start();
	if (m_KernelData.bStartTCPSocket) m_TCPSocket.Start(m_KernelData.uAcceptThreadCount,m_KernelData.uSocketThreadCount);

	//调用接口
	if (OnStart()==false) throw new CAFCException(TEXT("CBaseMainManageForZ::Start OnStart 函数错误"),0x41F);

	//设置数据
	m_bRun=true;
	return true;
}
void ArdunityController::start()
{
    started = true;
	updated = false;
	dirty = true;
	OnStart();
}
Beispiel #18
0
HRESULT Filter::Pause()
{
    //Unlike Stop(), Pause() can be asynchronous (that's why you have
    //GetState()).

    Lock lock;

    HRESULT hr = lock.Seize(this);

    if (FAILED(hr))
        return hr;

    //odbgstream os;
    //os << "mkvsplit::Filter::Pause" << endl;

    switch (m_state)
    {
        case State_Stopped:
            OnStart();  //commit outpin's allocator
            break;

        case State_Running:
        case State_Paused:
        default:
            break;
    }

    m_state = State_Paused;
    return S_OK;
}
void ribi::maziak::QtMaziakMenuDialog2::keyPressEvent(QKeyEvent * event)
{
    switch (event->key())
    {
    case Qt::Key_Up:
    case Qt::Key_Left:
    {
        switch (m_difficulty)
        {
        case Difficulty::easy:
            return;
        case Difficulty::medium:
            m_difficulty = Difficulty::easy;
            repaint();
            return;
        case Difficulty::hard:
            m_difficulty = Difficulty::medium;
            repaint();
            return;
        default:
            assert(!"Should not get here");
        }
    }
    case Qt::Key_Down:
    case Qt::Key_Right:
    {
        switch (m_difficulty)
        {
        case Difficulty::easy:
            m_difficulty = Difficulty::medium;
            repaint();
            return;
        case Difficulty::medium:
            m_difficulty = Difficulty::hard;
            repaint();
            return;
        case Difficulty::hard:
            return;
        default:
            assert(!"Should not get here");
        }
    }
    case Qt::Key_S:
        OnStart();
        break;
    case Qt::Key_I:
        OnInstructions();
        break;
    case Qt::Key_A:
        OnAbout();
        break;
    case Qt::Key_Q:
    case Qt::Key_Escape:
        close();
        return;
    default:
        break;
    }
}
//---------------------------------------------------------------------
void BaseTween::OnStart(TweenManager* _manager)
{
	if(_manager)
	{
		_manager->Register(this);
		OnStart();
	}
}
//---------------------------------------------------------------------
void BaseTween::OnStart(TweenManager* _manager, uint8 _groupID)
{
	if(_manager)
	{
		_manager->Register(this, _groupID);
		OnStart();
	}
}
Beispiel #22
0
void QTE::Start () {
	if (mIsStarted)
		return;

	mIsStarted = true;
	mIsPaused = false;

	OnStart ();
}
Beispiel #23
0
extern "C" void __cdecl mainCRTStartup()
{
    // TODO: set argc/argv
    //int argc = _ConvertCommandLineToArgcArgv( );

    OnStart();
    int ret = main(0, NULL, 0);
    OnExit();
    ExitProcess(ret);
}
Beispiel #24
0
	DWORD CWin32Svr::Run()
	{
		ReportStatusToSCM(SERVICE_START_PENDING);
		OnStart();
		ReportStatusToSCM(SERVICE_RUNNING);
		WaitForSingleObject(m_hExited, INFINITE);		
		ReportStatusToSCM(SERVICE_STOPPED);		
		
		return ERROR_SUCCESS;
	}
STDMETHODIMP WBPassthru::Start(LPCWSTR szUrl, IInternetProtocolSink *pOIProtSink,
    IInternetBindInfo *pOIBindInfo, DWORD grfPI, HANDLE_PTR dwReserved)
{
  ATLASSERT(m_spInternetProtocol != 0);
  if (!m_spInternetProtocol)
  {
    return E_UNEXPECTED;
  }

  return OnStart(szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved, m_spInternetProtocol);
}
Beispiel #26
0
	bool ResourceImpl::Start()
	{
		if (!OnStart())
		{
			return false;
		}

		m_state = ResourceState::Started;

		return true;
	}
int main()
{
	CHAR MyDocumentsPath[MAX_PATH];
	HRESULT result = SHGetFolderPath( NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, MyDocumentsPath );

	g_ExternalStorage = std::string( MyDocumentsPath ) + "\\ndkcookbook\\App6";

	OnStart();

	return 0;
}
Beispiel #28
0
void LifeFrame::OnSlider(wxScrollEvent& event)
{
    m_interval = event.GetPosition() * 100;

    if (m_running)
    {
        OnStop();
        OnStart();
    }

    UpdateInfoText();
}
int32 GTBehaviour::OnUpdate(void)
{
	// The first frame of update is OnStart
	if(m_bFirstUpdate)
	{
		m_bFirstUpdate = false;
		OnStart();
		return 1;
	}

	return 1;
}
void ribi::maziak::QtMaziakMenuDialog2::mousePressEvent(QMouseEvent * event)
{
    if (ui->widget_easy->geometry().contains(
                event->x(), event->y()))
    {
        m_difficulty = Difficulty::easy;
        repaint();
        return;
    }
    if (ui->widget_medium->geometry().contains(
                event->x(), event->y()))
    {
        m_difficulty = Difficulty::medium;
        repaint();
        return;
    }
    if (ui->widget_hard->geometry().contains(
                event->x(), event->y()))
    {
        m_difficulty = Difficulty::hard;
        repaint();
        return;
    }
    if (ui->widget_start->geometry().contains(
                event->x(), event->y()))
    {
        OnStart();
        return;
    }
    if (ui->widget_start_retro->geometry().contains(
                event->x(), event->y()))
    {
        OnStartRetro();
        return;
    }
    if (ui->widget_instructions->geometry().contains(
                event->x(), event->y()))
    {
        OnInstructions();
        return;
    }
    if (ui->widget_about->geometry().contains(
                event->x(), event->y()))
    {
        OnAbout();
        return;
    }
    if (ui->widget_quit->geometry().contains(
                event->x(), event->y()))
    {
        close();
    }
}