2012-01-19 7 views
0

현재 두 대의 XBee 중 하나를 내 컴퓨터에 연결하고 다른 하나는 수제 UAV를 사용하고 있습니다. 비행기의 Xbee는 지속적으로 비행기에 대한 데이터를 보내고 있으며 C++ 인터페이스 (양식 (WinForms)라고도합니다)를 사용하여 해당 데이터를 가져오고 싶습니다. 내 양식에는 Google Earth가 내장 된 webBrowser가 있으며 GE지도에서 비행기의 위치를 ​​업데이트하려고합니다. 데이터를 XBee에서 가져 오는 방법을 알고 있지만 데이터를 수집하여 입력없이 끊임없이 실행하는 코드를 얻는 방법을 알지 못합니다.형식으로 함수를 계속 실행하십시오 (C++)

이 프로젝트는 다른 사람이 프로젝트를 삭제 한 프로젝트입니다. 나는이 코드를 "상속 받았으며", 코멘트가 없어서 약간 혼란 스럽다.

+0

일반적으로 이러한 데이터 수집을 처리하지 못합니다. –

답변

1

GetMessage() 대신 PeekMessage()을 사용하도록 메시지 펌프를 변경할 수 있습니다. 이렇게하면 메시지 루프가 유휴 상태 일 때 사용할 수있는 메시지가 있으면 처리하거나 다른 작업을 수행 할 수 있습니다.

for (bool running = true; running;) 
{ 
    // check for any window messages. this operation does not block 
    // if no messages are available. 
    ::MSG message; 
    const ::BOOL fetched = ::PeekMessage(&message, 0, 0, 0, PM_REMOVE); 
    if (fetched) 
    { 
     // process window message. 
     TranslateMessage(&message); 
     DispatchMessage(&message); 

     // need to check explicitly for WM_QUIT message, since the "false" 
     // return value is already used to mean "there were no messages". 
     running = (message.message != WM_QUIT); 
    } 
    else 
    { 
     // no messages available, thread is idle. take time to check 
     // auxiliary input source. if no auxiliary input is available 
     // and checking (and processing) the auxiliary inputs is very 
     // fast, consider adding an extra ::Sleep() call to avoid hogging 
     // up the CPU. 
    } 
} 

.NET 기반 응용 프로그램의 경우,이 Application.Idle 이벤트를 살펴 할 수 있습니다 :

는 Win32 API를 사용하여

, 그것은 같이 보입니다.

관련 문제