コード例 #1
0
ITCPServerConnHandler::Command  HttpReqImpl::processHandlerResponse(natural res) {
	//stDetach causes waiting for user wakeup.
	if (res == IHttpHandler::stSleep) {
		return ITCPServerConnHandler::cmdWaitUserWakeup;
	}
	//depend on whether headers has been sent
	if (bHeaderSent) {
		//in case of 100 response, keep connection on-line
		if (res == 100) {
			if (!isInputAvailable()) {
				evType = evEndOfStream;
				res = curHandler->onData(*this);
				if (res == 100) res =500;
				return processHandlerResponse(res);
			}
			return ITCPServerConnHandler::cmdWaitRead;
		}
		else if (res == IHttpHandler::stWaitForWrite) {
			return ITCPServerConnHandler::cmdWaitWrite;
		} else {
			finish();
			//keep conection depend on keep-alive
			return keepAlive()?ITCPServerConnHandler::cmdWaitRead:ITCPServerConnHandler::cmdRemove;
		}
	} else {
		//in case of 100 response
		if (res == 100) {

			if (bNeedContinue) {
				send100continue();
			}

			if (!isInputAvailable()) {
				res = curHandler->onData(*this);
				if (res == 100) res =500;
				return processHandlerResponse(res);
			}
						//keep connection alive
			return ITCPServerConnHandler::cmdWaitRead;
		} else if (res == IHttpHandler::stWaitForWrite) {

			sendHeaders();
			return ITCPServerConnHandler::cmdWaitWrite;

		}
		//otherwise response with status page
		return errorPageKA(res);
	}
}
コード例 #2
0
ファイル: menus.cpp プロジェクト: nigelsheffield/opentx
bool isSourceAvailable(int source)
{
#if defined(PCBTARANIS)
    if (source>=MIXSRC_FIRST_INPUT && source<=MIXSRC_LAST_INPUT) {
        return isInputAvailable(source - MIXSRC_FIRST_INPUT);
    }
#endif

#if defined(LUA_MODEL_SCRIPTS)
    if (source>=MIXSRC_FIRST_LUA && source<=MIXSRC_LAST_LUA) {
        div_t qr = div(source-MIXSRC_FIRST_LUA, MAX_SCRIPT_OUTPUTS);
        return (qr.rem<scriptInputsOutputs[qr.quot].outputsCount);
    }
#elif defined(PCBTARANIS)
    if (source>=MIXSRC_FIRST_LUA && source<=MIXSRC_LAST_LUA)
        return false;
#endif

#if defined(PCBTARANIS)
    if (source>=MIXSRC_FIRST_POT && source<=MIXSRC_LAST_POT) {
        return IS_POT_AVAILABLE(POT1+source-MIXSRC_FIRST_POT);
    }
#endif

#if !defined(HELI)
    if (source>=MIXSRC_CYC1 && source<=MIXSRC_CYC3)
        return false;
#endif

    if (source>=MIXSRC_CH1 && source<=MIXSRC_LAST_CH) {
        uint8_t destCh = source-MIXSRC_CH1;
        for (uint8_t i = 0; i < MAX_MIXERS; i++) {
            MixData *md = mixAddress(i);
            if (md->srcRaw == 0) return false;
            if (md->destCh==destCh) return true;
        }
        return false;
    }

    if (source>=MIXSRC_SW1 && source<=MIXSRC_LAST_LOGICAL_SWITCH) {
        LogicalSwitchData * cs = lswAddress(source-MIXSRC_SW1);
        return (cs->func != LS_FUNC_NONE);
    }

#if !defined(GVARS)
    if (source>=MIXSRC_GVAR1 && source<=MIXSRC_LAST_GVAR)
        return false;
#endif

    if (source>=MIXSRC_FIRST_TELEM && source<=MIXSRC_LAST_TELEM)
        return isTelemetrySourceAvailable(source-MIXSRC_FIRST_TELEM+1);

    return true;
}
コード例 #3
0
void deleteExpoMix(uint8_t expo, uint8_t idx)
{
  pauseMixerCalculations();
  if (expo) {
    ExpoData *expo = expoAddress(idx);
    int input = expo->chn;
    memmove(expo, expo+1, (MAX_EXPOS-(idx+1))*sizeof(ExpoData));
    memclear(&g_model.expoData[MAX_EXPOS-1], sizeof(ExpoData));
    if (!isInputAvailable(input)) {
      memclear(&g_model.inputNames[input], LEN_INPUT_NAME);
    }
  }
  else {
    MixData *mix = mixAddress(idx);
    memmove(mix, mix+1, (MAX_MIXERS-(idx+1))*sizeof(MixData));
    memclear(&g_model.mixData[MAX_MIXERS-1], sizeof(MixData));
  }
  resumeMixerCalculations();
  eeDirty(EE_MODEL);
}