Milliseconds ReplSetConfig::getPriorityTakeoverDelay(int memberIdx) const { auto member = getMemberAt(memberIdx); int priorityRank = calculatePriorityRank(member.getPriority()); return (priorityRank + 1) * getElectionTimeoutPeriod(); }
void IncludeOrderPPCallbacks::EndOfMainFile() { LookForMainModule = true; if (IncludeDirectives.empty()) return; // TODO: find duplicated includes. // Form blocks of includes. We don't want to sort across blocks. This also // implicitly makes us never reorder over #defines or #if directives. // FIXME: We should be more careful about sorting below comments as we don't // know if the comment refers to the next include or the whole block that // follows. for (auto &Bucket : IncludeDirectives) { auto &FileDirectives = Bucket.second; std::vector<unsigned> Blocks(1, 0); for (unsigned I = 1, E = FileDirectives.size(); I != E; ++I) if (SM.getExpansionLineNumber(FileDirectives[I].Loc) != SM.getExpansionLineNumber(FileDirectives[I - 1].Loc) + 1) Blocks.push_back(I); Blocks.push_back(FileDirectives.size()); // Sentinel value. // Get a vector of indices. std::vector<unsigned> IncludeIndices; for (unsigned I = 0, E = FileDirectives.size(); I != E; ++I) IncludeIndices.push_back(I); // Sort the includes. We first sort by priority, then lexicographically. for (unsigned BI = 0, BE = Blocks.size() - 1; BI != BE; ++BI) std::sort(IncludeIndices.begin() + Blocks[BI], IncludeIndices.begin() + Blocks[BI + 1], [&FileDirectives](unsigned LHSI, unsigned RHSI) { IncludeDirective &LHS = FileDirectives[LHSI]; IncludeDirective &RHS = FileDirectives[RHSI]; int PriorityLHS = getPriority(LHS.Filename, LHS.IsAngled, LHS.IsMainModule); int PriorityRHS = getPriority(RHS.Filename, RHS.IsAngled, RHS.IsMainModule); return std::tie(PriorityLHS, LHS.Filename) < std::tie(PriorityRHS, RHS.Filename); }); // Emit a warning for each block and fixits for all changes within that // block. for (unsigned BI = 0, BE = Blocks.size() - 1; BI != BE; ++BI) { // Find the first include that's not in the right position. unsigned I, E; for (I = Blocks[BI], E = Blocks[BI + 1]; I != E; ++I) if (IncludeIndices[I] != I) break; if (I == E) continue; // Emit a warning. auto D = Check.diag(FileDirectives[I].Loc, "#includes are not sorted properly"); // Emit fix-its for all following includes in this block. for (; I != E; ++I) { if (IncludeIndices[I] == I) continue; const IncludeDirective &CopyFrom = FileDirectives[IncludeIndices[I]]; SourceLocation FromLoc = CopyFrom.Range.getBegin(); const char *FromData = SM.getCharacterData(FromLoc); unsigned FromLen = std::strcspn(FromData, "\n"); StringRef FixedName(FromData, FromLen); SourceLocation ToLoc = FileDirectives[I].Range.getBegin(); const char *ToData = SM.getCharacterData(ToLoc); unsigned ToLen = std::strcspn(ToData, "\n"); auto ToRange = CharSourceRange::getCharRange(ToLoc, ToLoc.getLocWithOffset(ToLen)); D << FixItHint::CreateReplacement(ToRange, FixedName); } } } IncludeDirectives.clear(); }
TVerdict CT_LbsHybridUEAssistedX3PAccurateGPS::doTestStepL() { // Generic test step used to test the LBS Client Notify position update API. INFO_PRINTF1(_L("CT_LbsHybridUEAssistedX3PAccurateGPS::doTestStepL()")); // Stop the test if the preamble failed TESTL(TestStepResult() == EPass); const TInt KTimeOut = 30*1000*1000; const TInt KAdviceSystemStatusTimeout = 40*1000*1000; const TInt KSmallTimeOut = 3*1000*1000; // >> AdviceSystemStatus(0) TESTL(iProxy->WaitForResponse(KAdviceSystemStatusTimeout) == ENetMsgGetCurrentCapabilitiesResponse); CLbsNetworkProtocolBase::TLbsSystemStatus status; TInt cleanupCnt; cleanupCnt = iProxy->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status); TESTL(status == CLbsNetworkProtocolBase::ESystemStatusNone); CleanupStack::PopAndDestroy(cleanupCnt); //Initiate X3P start // TransmitPosition() _LIT(KThirdParty,"+4407463842101"); const TInt KPriority= 6; TLbsTransmitPositionOptions options(TTimeIntervalMicroSeconds(50*1000*1000)); TRequestStatus refPosStatus=KRequestPending; TRequestStatus transPosStatus=KRequestPending; TPositionInfo refPosInfo; TPositionInfo transPosInfo; iTransmitter.SetTransmitOptions(options); iTransmitter.TransmitPosition(KThirdParty, KPriority, refPosStatus, refPosInfo, transPosStatus, transPosInfo); // RequestTransmitLocation() TESTL(iProxy->WaitForResponse(KTimeOut) == ENetMsgRequestTransmitLocation); TBufC16<14> thirdParty(KThirdParty); TPtr16 ptr = thirdParty.Des(); HBufC16* getThirdParty = NULL; TLbsNetSessionId* getSessionId = NULL; TInt getPriority(0); cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestTransmitLocation, &getSessionId, &getThirdParty, &getPriority); TESTL(ptr.Compare(*getThirdParty)==KErrNone); TESTL(getPriority == KPriority); iSessionId = *getSessionId; //session ID is initialised by LBS CleanupStack::PopAndDestroy(cleanupCnt); // ProcessStatusUpdate() MLbsNetworkProtocolObserver::TLbsNetProtocolService service = MLbsNetworkProtocolObserver::EServiceTransmitThirdParty; iProxy->CallL(ENetMsgProcessStatusUpdate, &service); //End Initiate //Reference Position Notification Start // ProcessLocationUpdate() refPosInfo = ArgUtils::ReferencePositionInfo(); iProxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &refPosInfo); //Reference Position Notification End //Assistance Data Notification Start // ProcessAssistanceData() TLbsAsistanceDataGroup dataRequestMask = EAssistanceDataReferenceTime; RLbsAssistanceDataBuilderSet assistanceData; ArgUtils::PopulateLC(assistanceData); TInt reason = KErrNone; iProxy->CallL(ENetMsgProcessAssistanceData, &dataRequestMask, &assistanceData, &reason); CleanupStack::PopAndDestroy(1); //assistanceData // Assistance Data Notification End // Network Location Request Start // ProcessLocationRequest() const TBool emergency(EFalse); TLbsNetPosRequestQuality quality = ArgUtils::QualityAlpha2(); TLbsNetPosRequestMethod method = ArgUtils::RequestHybridMethod(); iProxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method); // Network Location Request Stop //Start the timer TTime timerStart; timerStart.HomeTime(); // RequestAssistanceData(0) TESTL(iProxy->WaitForResponse(KSmallTimeOut) == ENetMsgRequestAssistanceData); TLbsAsistanceDataGroup dataGroup; cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataGroup); TESTL(dataGroup == EAssistanceDataNone); CleanupStack::PopAndDestroy(cleanupCnt); // now wait for either to complete - but we will expect only the asynchrous request // waiting for the REF position to complete with KErrNone User::WaitForRequest(refPosStatus, transPosStatus); TESTL(refPosStatus==KErrNone); TESTL(transPosStatus.Int() == KRequestPending); //Find the time elapsed from timer TTimeIntervalMicroSeconds microseconds; TTime timerStop; timerStop.HomeTime(); microseconds = timerStop.MicroSecondsFrom(timerStart); TInt64 timeElapsed = microseconds.Int64(); /*** NRH's Alpha2 timer expires. We enter Hybrid mode.***/ //Test that we do not get response before alpha2 has expired TESTL(iProxy->WaitForResponse(KAlpha2Timeout-timeElapsed-KDelta) == ENetMsgTimeoutExpired); TESTL(iProxy->WaitForResponse(2*KDelta) == ENetMsgRespondLocationRequest); getSessionId = NULL; TInt getReason = KErrNone; TPositionSatelliteInfo* getPositionInfo = NULL; cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &getSessionId, &getReason, &getPositionInfo); TESTL(getSessionId->SessionNum() == iSessionId.SessionNum()); TESTL(getReason==KErrNone); CleanupStack::PopAndDestroy(cleanupCnt); // no need for looping, we assume that the next update location from GPS will give accurate fix quality = ArgUtils::Quality(); iProxy->CallL(ENetMsgProcessLocationRequest, &iSessionId, &emergency, &service, &quality, &method); // RequestAssistanceData(0) TESTL(iProxy->WaitForResponse(KSmallTimeOut) == ENetMsgRequestAssistanceData); cleanupCnt = iProxy->GetArgsLC(ENetMsgRequestAssistanceData, &dataGroup); TESTL(dataGroup == EAssistanceDataNone); CleanupStack::PopAndDestroy(cleanupCnt); // GPS positions meets required accuracy. This is sent immediately to protocol module // The ini file should contain accurate gps fix for this test case to work TESTL(iProxy->WaitForResponse(KTTimeout) == ENetMsgRespondLocationRequest); getSessionId = NULL; getReason = KErrNone; getPositionInfo = NULL; cleanupCnt = iProxy->GetArgsLC(ENetMsgRespondLocationRequest, &getSessionId, &getReason, &getPositionInfo); TESTL(getSessionId->SessionNum() == iSessionId.SessionNum()); TESTL(getReason == KErrNone); // Test position is the same as in the ini file data fed to the GPS module // $update,1,2,51.5015,-0.105,50,2,3* TPosition gpsPos; getPositionInfo->GetPosition(gpsPos); TESTL(gpsPos.Latitude()==51.5015 && gpsPos.Longitude()==-0.105 && gpsPos.Altitude()==50 && gpsPos.HorizontalAccuracy()==2 && gpsPos.VerticalAccuracy()==3); CleanupStack::PopAndDestroy(cleanupCnt); // Network Result Notification Start // ProcessLocationUpdate() //Final Network Position is the GPS position TPositionInfo gpsPosInfo; gpsPosInfo.SetPosition(gpsPos); gpsPosInfo.SetUpdateType(EPositionUpdateGeneral); gpsPosInfo.SetPositionMode(TPositionModuleInfo::ETechnologyNetwork | TPositionModuleInfo::ETechnologyAssisted); gpsPosInfo.SetPositionModeReason(EPositionModeReasonNone); iProxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &gpsPosInfo); // Network Result Notification Stop // Session Complete Start reason = KErrNone; iProxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason); MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask activeServiceMask = MLbsNetworkProtocolObserver::EServiceNone; iProxy->CallL(ENetMsgProcessStatusUpdate, &activeServiceMask); // Session Complete Stop // the REF position request has completed, so now, after injecting the FNP and Session Complete // we expect that the other request to complete with KErrNone User::WaitForRequest(transPosStatus); TESTL(transPosStatus==KErrNone); return TestStepResult(); }
/* Called when one of the stub PM's receives a message from the NG * * @param aPmId The ID of the PM that received this message * @param aMessageType The ID of the message type received from the PM */ void CT_LbsHybridMultipleTest::OnHandleNGMessage(TUint aPmId, TInt aMessageType) { //Get the correct proxy CLbsTestNgMessageHandler* proxy = LookupProtocolModuleProxy(aPmId); if (!proxy) { INFO_PRINTF2(_L("ERROR: No NG proxy setup for PM%d"), aPmId); User::Leave(KErrNotFound); } TInt cleanupCnt; TInt sequenceId = KErrNotFound; //For each of the different message types, find out whether the message type was expected by the // sequence (if a session Id is sent with the message) or by any sequence (if the session Id is not // present). Then confirm the message parameters are expected and then move the correct sequence // onto the next message. switch(aMessageType) { // >> AdviceSystemStatus() [2009] case ENetMsgGetCurrentCapabilitiesResponse: { sequenceId = WasMessageExpectedPmId(aPmId, ENetMsgGetCurrentCapabilitiesResponse); INFO_PRINTF2(_L("-> AdviceSystemStatus() [2009] Sq: %d"), sequenceId); if(sequenceId != KErrNotFound) { CLbsNetworkProtocolBase::TLbsSystemStatus status; cleanupCnt = proxy->ProtocolProxy()->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status); TESTL(status == CLbsNetworkProtocolBase::ESystemStatusNone); CleanupStack::PopAndDestroy(cleanupCnt); } break; } // >> RespondPrivacyRequest() [2000] case ENetMsgRespondPrivacyRequest: { TLbsNetSessionId* getSessionId = NULL; CLbsNetworkProtocolBase::TLbsPrivacyResponse getPrivacy; cleanupCnt = proxy->ProtocolProxy()->GetArgsLC(ENetMsgRespondPrivacyRequest, &getSessionId, &getPrivacy); sequenceId = WasMessageExpectedSessionId(getSessionId->SessionNum(), ENetMsgRespondPrivacyRequest); INFO_PRINTF3(_L("-> RespondPrivacyRequest(%d) [2000] Sq: %d"), getPrivacy, sequenceId); if(sequenceId != KErrNotFound) { iSequences[sequenceId]->CheckRespondPrivacyRequest(getPrivacy); } CleanupStack::PopAndDestroy(cleanupCnt);//getSessionId break; } // >> RequestAssistanceData() [2004] case ENetMsgRequestAssistanceData: { sequenceId = WasMessageExpectedPmId(aPmId, ENetMsgRequestAssistanceData); //Request Assistance Data is a special case. Depending upon the timing of when the messages // will be sent/received, it is not possible to predict in advance whether this message will // always arrive in some of the later sequences. As such, a RequestAssistanceData message can // arrive and even if it is not expected by any of the sequences, it will not fail the test. if(sequenceId != KErrNotFound) { INFO_PRINTF2(_L("-> RequestAssistanceData() [2004] Sq: %d"), sequenceId); TLbsAsistanceDataGroup dataGroup; cleanupCnt = proxy->ProtocolProxy()->GetArgsLC(ENetMsgRequestAssistanceData, &dataGroup); CleanupStack::PopAndDestroy(cleanupCnt); } else { //Message was not expected by any sequence. Manually set the Net Proxy off listening // again, so the sequence can receive the message it expected. INFO_PRINTF2(_L("-> RequestAssistanceData() [2004] Sq: unknown, PM: %d"), aPmId); proxy->WaitForResponseL(80 * 1000 * 1000); //Break out of the function now return; } break; } // >> ResponsdLocationRequest() [2001] case ENetMsgRespondLocationRequest: { TLbsNetSessionId* getSessionId = NULL; getSessionId = NULL; TInt getReason = KErrNone; TPositionSatelliteInfo* getPositionInfo = NULL; cleanupCnt = proxy->ProtocolProxy()->GetArgsLC(ENetMsgRespondLocationRequest, &getSessionId, &getReason, &getPositionInfo); sequenceId = WasMessageExpectedSessionId(getSessionId->SessionNum(), ENetMsgRespondLocationRequest); INFO_PRINTF3(_L("-> RespondLocationRequest(%d) [2001] Sq: %d"), getReason, sequenceId); CleanupStack::PopAndDestroy(cleanupCnt); break; } // >> RequestSelfLocation() [2005] case ENetMsgRequestSelfLocation: { TLbsNetSessionId* sessionId = NULL; TLbsNetPosRequestOptionsAssistance* opts = NULL; cleanupCnt = proxy->ProtocolProxy()->GetArgsLC(ENetMsgRequestSelfLocation, &sessionId, &opts); sequenceId = WasMessageExpectedPmId(aPmId, ENetMsgRequestSelfLocation); INFO_PRINTF2(_L("-> RequestSelfLocation() [2005] Sq: %d"), sequenceId); if(sequenceId != KErrNotFound) { iSequences[sequenceId]->CheckSelfLocationRequest(sessionId); } CleanupStack::PopAndDestroy(cleanupCnt); break; } // >> CancelSelfLocation() [2006] case ENetMsgCancelSelfLocation: { TLbsNetSessionId* sessionId = NULL; TInt reason = 0; cleanupCnt = proxy->ProtocolProxy()->GetArgsLC(ENetMsgCancelSelfLocation, &sessionId, &reason); sequenceId = WasMessageExpectedSessionId(sessionId->SessionNum(), ENetMsgRequestSelfLocation); INFO_PRINTF2(_L("-> CancelSelfLocation() [2006] Sq: %d"), sequenceId); CleanupStack::PopAndDestroy(cleanupCnt); break; } // >> RequestTransmitLocation() [2002] case ENetMsgRequestTransmitLocation: { HBufC16* getThirdParty = NULL; TLbsNetSessionId* getSessionId = NULL; TInt getPriority(0); TInt cleanupCnt; cleanupCnt = proxy->ProtocolProxy()->GetArgsLC(ENetMsgRequestTransmitLocation, &getSessionId, &getThirdParty, &getPriority); sequenceId = WasMessageExpectedPmId(aPmId, ENetMsgRequestTransmitLocation); INFO_PRINTF2(_L("-> RequestTransmitLocation() [2002] Sq: %d"), sequenceId); if(sequenceId != KErrNotFound) { iSequences[sequenceId]->CheckRequestTransmitLocation(getSessionId, getPriority, *getThirdParty); } CleanupStack::PopAndDestroy(cleanupCnt); break; } // >> CancelTransmitLocation() [2003] case ENetMsgCancelTransmitLocation: { TLbsNetSessionId* sessionId = NULL; TInt reason = 0; cleanupCnt = proxy->ProtocolProxy()->GetArgsLC(ENetMsgCancelTransmitLocation, &sessionId, &reason); sequenceId = WasMessageExpectedSessionId(sessionId->SessionNum(), ENetMsgCancelTransmitLocation); INFO_PRINTF2(_L("-> CancelTransmitLocation() [2003] Sq: %d"), sequenceId); CleanupStack::PopAndDestroy(cleanupCnt); break; } // >> RequestNetworkLocation() [2007] case ENetMsgRequestNetworkLocation: { TLbsNetSessionId* sessionId = NULL; TLbsNetPosRequestOptionsAssistance* opts = NULL; cleanupCnt = proxy->ProtocolProxy()->GetArgsLC(ENetMsgRequestNetworkLocation, &sessionId, &opts); sequenceId = WasMessageExpectedPmId(aPmId, ENetMsgRequestNetworkLocation); INFO_PRINTF2(_L("-> RequestNetworkLocation() [2007] Sq: %d"), sequenceId); if(sequenceId != KErrNotFound) { iSequences[sequenceId]->CheckNetworkLocationRequest(sessionId); } break; } // >> CancelNetworkLocation [2008] case ENetMsgCancelNetworkLocation: { sequenceId = WasMessageExpectedPmId(aPmId, ENetMsgCancelNetworkLocation); INFO_PRINTF2(_L("-> CancelNetworkLocation() [2008] Sq: %d"), sequenceId); //NOTE: Currently no handling implemented for this message type break; } // Timeout occurred waiting for a NG Message case -1000: { INFO_PRINTF2(_L("Error - Timeout occurred waiting for NG message on PM: %d"), aPmId); break; } //Error occurred, not a recognised message. Fail the test. default: { INFO_PRINTF3(_L("Error - Received invalid NG message: %d on PM: %d"), aMessageType, aPmId); return StopTest(KErrArgument); } } //If the message was expected, continue the test if(sequenceId != KErrNotFound) { iSequences[sequenceId]->SignalCallbackIdleStart(); } else { // when an unexpected message arrives merley ignore and wait for next one! proxy->WaitForResponseL(80 * 1000 * 1000); } }
void CTR::execRP_RSCT() { BUS::glbl_READ_BUS = 034 + getPriority(); }
void CTR::execWP_WPCTR() { register_PSEQ.write(getSubseq()); register_PCELL.write(getPriority()); }
Token exprEvaluate(vector<Token> tokens) { vector<Token> round1; /* round 1: check which tokens are unary add or unary sub */ for(int i = 0; i < tokens.size(); ++i) { if(tokens[i].getIndex() == sub) { if(round1.size() == 0 || (round1.back().getIndex() != num && round1.back().getIndex() != bracket_r)) { round1.push_back(Token(unary_sub, "-")); } else { round1.push_back(tokens[i]); } } else if(tokens[i].getIndex() == add) { if(round1.size() == 0 || (round1.back().getIndex() != num && round1.back().getIndex() != bracket_r)) { round1.push_back(Token(unary_add, "+")); } else { round1.push_back(tokens[i]); } } else { round1.push_back(tokens[i]); } } vector<Token> postfixExpr; stack<Token> temp; /* transform the expression to postfix form */ for(int i = 0; i < round1.size(); ++i) { if(round1[i].getIndex() == num) { postfixExpr.push_back(round1[i]); } else if(round1[i].getIndex() == bracket_l || temp.empty()) { temp.push(round1[i]); } else if(round1[i].getIndex() == bracket_r) { while(!temp.empty()) { if(temp.top().getIndex() == bracket_l) { temp.pop(); break; } postfixExpr.push_back(temp.top()); temp.pop(); } } else { bool flag = false; while(!temp.empty()) { if(temp.top().getIndex() == bracket_l || getPriority(round1[i].getIndex()) > getPriority(temp.top().getIndex())) { temp.push(round1[i]); flag = true; break; } else { postfixExpr.push_back(temp.top()); temp.pop(); } } if(!flag) { temp.push(round1[i]); } } } while(!temp.empty()) { postfixExpr.push_back(temp.top()); temp.pop(); } Token num1, num2, result; /* evaluate the postfix expression using a stack */ for(int i = 0; i < postfixExpr.size(); ++i) { if(postfixExpr[i].getIndex() == num || postfixExpr[i].getIndex() == _bool) { temp.push(postfixExpr[i]); } else if(isLogicToken(postfixExpr[i].getIndex())) { num1 = temp.top(); temp.pop(); if(postfixExpr[i].getIndex() == _not) { result = evaluate(Token(dollar, ""), num1, _not); } else { num2 = temp.top(); temp.pop(); result = evaluate(num1, num2, postfixExpr[i].getIndex()); } temp.push(result); } else if(postfixExpr[i].getIndex() == unary_add || postfixExpr[i].getIndex() == unary_sub) { num1 = temp.top(); temp.pop(); result = evaluate(Token(dollar, ""), num1, postfixExpr[i].getIndex()); temp.push(result); } else { num1 = temp.top(); temp.pop(); num2 = temp.top(); temp.pop(); result = evaluate(num1, num2, postfixExpr[i].getIndex()); if(result.getIndex() == dollar) { return result; } temp.push(result); } } return temp.top(); }