Exemple #1
0
LOCAL_C TInt CalcArcsinArccos(TReal& aTrg, TRealX& x, TBool aCos)
	{
	//	Calculate arcsin (if aCos false) or arccos (if aCos true) of x
	//	and write result to aTrg.
	//	Algorithm (arcsin):
	//		If x>0.5, replace x with Sqrt((1-x)/2)
	//			( use identity cos(x)=2(cos(x/2))^2-1 )
	//		Use polynomial approximation for arcsin(x), 0<=x<=0.5
	//		If original x>0.5, replace result y with pi/2-2y

	const TRealX One = *(const TRealX*)Onedata;
	const TRealX Half = *(const TRealX*)Halfdata;
	const TRealX Pi = *(const TRealX*)Pidata;
	const TRealX PiBy2 = *(const TRealX*)PiBy2data;

	TInt sign=x.iSign&1;
	x.iSign=0;
	if (x<=One)
		{
		TBool big=(x>Half);
		if (big)
			{
			x=One-x;
			if (x.iExp>1)
				x.iExp--;
			TReal temp;
			Math::Sqrt(temp, (TReal)x);
			x=temp;
			}
		TRealX y;
		Math::PolyX(y,x*x,12,(const TRealX*)ArcsinCoeffs);
		y*=x;
		if (big)
			{
			if (y.iExp)
				y.iExp++;
			if (aCos)
				{
				if (sign)
					y=Pi-y;
				}
			else
				{
				y=PiBy2-y;
				y.iSign=TInt8(sign);
				}
			}
		else
			{
			y.iSign=TInt8(sign);
			if (aCos)
				y=PiBy2-y;
			}
		return y.GetTReal(aTrg);
		}
	return KErrArgument;
	}
Exemple #2
0
AnimDll::AnimDll(RWsSession* aWs, QString aName,QObject *parent) :
    QObject(parent), iClientDll(*aWs), iClientCommander(iClientDll),MPropertyCallBack()
{
    qDebug()<<"connecting dll";
    TPtrC name (static_cast<const TUint16*>(aName.utf16()),aName.length());
    iClientDll.Load(name);
    qDebug()<<RProperty::Define(TUid::Uid(KPropertyUid),0x100,RProperty::EInt);
    qDebug()<<RProperty::Set(TUid::Uid(KPropertyUid),0x100,0);
    qDebug()<<RProperty::Define(TUid::Uid(KPropertyUid),0x101,RProperty::EInt);
    qDebug()<<RProperty::Set(TUid::Uid(KPropertyUid),0x101,0);
    qDebug()<<RProperty::Define(TUid::Uid(KPropertyUid),0x102,RProperty::EInt);
    qDebug()<<RProperty::Set(TUid::Uid(KPropertyUid),0x102,50000);
    qDebug()<<RProperty::Define(TUid::Uid(KPropertyUid),0x200,RProperty::EInt);
    qDebug()<<RProperty::Set(TUid::Uid(KPropertyUid),0x200,0);

    iObserver=CPropertyObserver::NewL(TUid::Uid(KPropertyUid),0x100,this);

    iWinGroup=new (ELeave) RWindowGroup(*aWs);
    iWinGroup->Construct((TUint32)&iWinGroup, EFalse);
    iWinGroup->SetOrdinalPosition(-1);
    iWinGroup->EnableReceiptOfFocus(ETrue);
    CApaWindowGroupName* wn=CApaWindowGroupName::NewL(*aWs);
    wn->SetHidden(ETrue);
    wn->SetWindowGroupName(*iWinGroup);
    delete wn;

    TBuf8<1> params( TInt8( 0 ) );
    RWindow wnd(*aWs);
    User::LeaveIfError(wnd.Construct(*iWinGroup,TUint32(&wnd)));
    wnd.SetOrdinalPosition(0,1000000);
    iClientCommander.ImageConstruct(wnd,1,params );
    qDebug()<<"dll connected";
    qDebug()<<"animdll thread"<<RThread().Id().Id();
}
// -----------------------------------------------------------------------------
// CG711PayloadFormatRead::ConfigurePayloadFormatL
// Configure payload decoding parameters.
// -----------------------------------------------------------------------------
//
void CG711PayloadFormatRead::ConfigurePayloadFormatL( const TDesC8& aConfigParams )
{
    DP_G711_READ( "CG711PayloadFormatRead::ConfigurePayloadFormatL" );

    __ASSERT_ALWAYS( aConfigParams.Size() == sizeof( TMccCodecInfo ),
                     User::Leave( KErrArgument ) );

    TMccCodecInfoBuffer infoBuffer;
    infoBuffer.Copy( aConfigParams );

    if ( !infoBuffer() .iIsUpdate )
    {
        iCInfo = infoBuffer();
        // Calculates frames/packet, frame size and frame time interval
        iFramesPerPacket = TInt8( iCInfo.iMaxPtime / iCInfo.iHwFrameTime );
        iCInfo.iFrameSize =
            static_cast<TUint>( KDefaultSampleRateInkHz * iCInfo.iHwFrameTime );
        iFrameTimeInterval = TInt64( iCInfo.iHwFrameTime );

        // Create two frame buffers used in data transfer with datapath.
        // Space for two byte additional header needed by HW codec is reserved.
        iFrameBufferOne =
            CMMFDataBuffer::NewL( iCInfo.iFrameSize + KVoIPHeaderLength );
        iFrameBufferTwo =
            CMMFDataBuffer::NewL( iCInfo.iFrameSize + KVoIPHeaderLength );

        // PayloadBuffer contains data received from network
        TInt plSize = iCInfo.iFrameSize * iFramesPerPacket;
        DP_G711_READ3( "CG711PayloadFormatRead::ConfigurePayloadFormatL \
FramesPerPacket: %d, FrameSize: %d" , iFramesPerPacket, iCInfo.iFrameSize );

        if ( EGenRedUsed == iCInfo.iAlgoUsed )
        {
            DP_G711_READ2( "CG711PayloadFormatRead::ConfigurePayloadFormatL, RED LEVEL: %d",
                           iCInfo.iRedundancyCount );

            if ( iCInfo.iRedundancyCount )
            {
                plSize *= iCInfo.iRedundancyCount;
            }

            CPayloadFormatRead* redDecoder
                = static_cast<CPayloadFormatRead*>( iClip );

            TMccRedPayloadReadConfig config;
            config.iRedBlockCount = iCInfo.iRedundancyCount;
            config.iMaxPayloadSize = iCInfo.iFrameSize * iFramesPerPacket;
            config.iNumOfEncodings = 1;
            config.iRedPayloadType = iCInfo.iRedundantPayload;
            config.InitPayloadTypes();
            config.iEncPayloadTypes[0] = iCInfo.iPayloadType;
            TMccRedPayloadReadPckg pckg( config );
            redDecoder->ConfigurePayloadFormatL( pckg );
        }

        iSourceBuffer = CreateClipBufferL( plSize, iSourceBufOwnership );
    }
/** Gets all days in the month on which this rule is repeated.

@param aDays On return this array contains all days in the month that are to be set. 
This function will do nothing if this is not a monthly or yearly repeat rule. 
@publishedAll
@released 
@capability None
*/
EXPORT_C void TCalRRule::GetByDayL(RArray<TDayOfMonth>& aDays) const
	{
	if (iType == EMonthly)
		{
		aDays.Reset();
		if (GetNthBit(KMonthlyByWeek))
			{
			// if i == 35, then weekNum = 5 below which is too high
			for (TUint i = 0; i < 35; ++i)
				{
				if (GetNthBit(i))
					{
					// This is the reverse of the algorithm in TCalRRule::SetByDay(const RArray<TDayOfMonth>& aDays)
					TDay day = static_cast<TDay>(i % 7);
					TInt weekNum = i / 7;
					if (weekNum == 0)
						{
						weekNum = -1;
						}
					TDayOfMonth dayOfMonth(day, weekNum);
					aDays.AppendL(dayOfMonth);
					}
				}
			}
		}
	else if (iType == EYearly)
		{
		aDays.Reset();
		if (GetNthBit(KYearlyByWeek))
			{
			TUint8* bufferPtr = (TUint8*)&iBuffer; // convert the iBuffer store to three TUint8s
			TDay theDay = TDay(bufferPtr[0]-1); // -1 because EMonday is stored as +1
			TInt8 theWeek = TInt8(bufferPtr[1]);
			
			if (theDay >= EMonday && theDay <= ESunday)
				{
				TDayOfMonth dayOfMonth(theDay, theWeek);
				aDays.AppendL(dayOfMonth);
				}
			}
		}
	}
void CBtmcSignal::ConvertToHFPScale(TInt8 &aSignal)
    {
    TReal result;
    Math::Round( result, TReal(TReal(KMaxHFPSignal)/TReal(KMaxPhoneSignal) *TReal(aSignal)),0);
    aSignal = TInt8(result);
    }
void CNetworkPsy2::TimerCompleted()
    {
    TPsyConfig& config(iPsyConfigArray[iCurrentIndex]);
    if(config.iType==TPsyConfig::EConfigLRResponse)
        {
        //If no pending LR, then just return
        if(!iRequestStatus)
            {
            return;
            }
            
        TInt err = config.iData.iLRConfig.iErr;
        //complete location request
        if(iPositionInfoBase->PositionClassType() & EPositionInfoClass)
            {
            //Set TPositionInfo
            TPosition pos;
            pos.SetCoordinate(
                config.iData.iLRConfig.iLat,
                config.iData.iLRConfig.iLon,
                config.iData.iLRConfig.iAlt);
                
            TPositionInfo* posInfo = reinterpret_cast<TPositionInfo*>(iPositionInfoBase);
            posInfo->SetPosition(pos);
            }
        if(iPositionInfoBase->PositionClassType() & EPositionGenericInfoClass)
            {
            //Set HGeneric Info
            HPositionGenericInfo* genInfo =
                static_cast<HPositionGenericInfo*>(iPositionInfoBase);
            if(genInfo->IsRequestedField(EPositionFieldNMEASentences))
                {
                genInfo->SetValue(EPositionFieldNMEASentences, TInt8(1));
                HBufC8* nmea = NULL;
                TRAP(err, nmea = HBufC8::NewL(config.iData.iLRConfig.iNmeaDataSize));
                if(KErrNone == err)
                	{
	                TPtr8 nmeaPtr(nmea->Des());
	                nmeaPtr.Fill('H', config.iData.iLRConfig.iNmeaDataSize);
	                err = genInfo->SetValue(EPositionFieldNMEASentences+1, *nmea);
                	}
                delete nmea;
                }
            }
        CompleteRequest(err);
        if(config.iData.iLRConfig.iNumOfResponse>1)
            {
            config.iData.iLRConfig.iNumOfResponse--;
            }
        else if(config.iData.iLRConfig.iNumOfResponse>0)
            {
            iCurrentIndex++;
            }
        else
            {
            //0 means forever response with this
            }
        }
    else //ECinfigModuleStatus
        {
        //Change module status
        TPositionModuleStatus modStatus;
        modStatus.SetDataQualityStatus(config.iData.iStatusConfig.iDataQuality);
        modStatus.SetDeviceStatus(config.iData.iStatusConfig.iDeviceStatus);
        MPositionerStatus* observer = PositionerStatus();
        observer->ReportStatus(modStatus);
        iCurrentIndex++;
        }
    iTimer->Cancel();
    
    if(iCurrentIndex>=iPsyConfigArray.Count())
        {
        //When all items are used, then clean the config items
        iPsyConfigArray.Reset();
        iCurrentIndex = 0;
        }
        
    StartTimerIfNeeded();
    }
EXPORT_C TInt8 CWriteInquiryResponseTransmitPowerLevelCommand::TxPowerLevel() const
	{
	return TInt8(iTxPowerLevel);
	}