Drone::Drone(int txPin, int rxPin) {
  _serialIO = SerialIO(txPin, rxPin);
  _callback = Callback();
  _incomingPacketReader = IncomingPacketReader(&_serialIO);
  _vitals = Vitals(&_serialIO, &_incomingPacketReader, &_callback);
  _responseHandler = ResponseHandler(&_serialIO, &_incomingPacketReader, &_callback, &_vitals);
  _rc = RC(&_serialIO, &_callback, &_incomingPacketReader);
  _gpio = GPIO(&_serialIO, &_callback, &_incomingPacketReader);
  _i2c = I2C(&_serialIO, &_callback, &_incomingPacketReader);
  _pose = Pose(&_serialIO, &_callback, &_incomingPacketReader);
  _autopilot = Autopilot(&_serialIO, &_callback, &_incomingPacketReader);
  _transmitterSupport = TransmitterSupport(&_serialIO, &_callback, &_incomingPacketReader);
}
示例#2
0
文件: Gainer.cpp 项目: arton/GainerX
HRESULT STDMETHODCALLTYPE CGainer::Wait( 
            /* [in] */ long Timeout)
{
    MSG msg;
    for (;;)
    {
        UINT_PTR timer = ::SetTimer(NULL, 0, Timeout, NULL);
        int ret = GetMessage(&msg, m_hWndCD, 0, 0);  // m_hWndCD may be null
        ::KillTimer(m_hWndCD, timer);
        if (!ret) break;
        if (ret < 0) return Error(IDS_E_BADWINDOW);
        switch (msg.message)
        {
        case WM_TIMER:
            return S_OK;
        case WM_COM_READRESULT:
        case WM_COM_REBOOT:
        case WM_COM_RESPONSE:
            if (!m_hWndCD)
            {
                BOOL bHandled;
                switch (msg.message)
                {
                case WM_COM_READRESULT:
                    ResponseTextHandler(msg.message, msg.wParam, msg.lParam, bHandled);
                    break;
                case WM_COM_REBOOT:
                    RebootHandler(msg.message, msg.wParam, msg.lParam, bHandled);
                    break;
                default:
                    ResponseHandler(msg.message, msg.wParam, msg.lParam, bHandled);
                    break;   
                }
                continue;
            }
            // fall through
        default:
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }

    return S_OK;
}
示例#3
0
 // if an embedder of this class calls close() on AsyncClient in it's
 // destructor (for more rigorous cleanup) then it's possible that the
 // onError handler will still be called as a result of the socket close.
 // the callback might then be interacting with a C++ object that has
 // already been deleted. for this case (which does occur in the
 // desktop::NetworkReply class) we provide a method that disables
 // any pending handlers
 void disableHandlers()
 {
    responseHandler_ = ResponseHandler();
    errorHandler_ = ErrorHandler();
 }