void Drive::escape(){
  RunR(-1000);
  RunL(-1000);
  delay(3000);
  RunR(1000);
  RunL(1000);
  delay(10000);
  RunR(-1000);
  RunL(-1000);
  delay(3000);
  RunR(1000);
  RunL(-1000);
  delay(1000);
  RunR(1000);
  RunL(1000);
  delay(2000);
  RunR(-1000);
  RunL(1000);
  delay(1000);
  RunR(1000);
  RunL(1000);
  delay(5000);
  RunR(0);
  RunL(0);
}
void CPropertyWatch::ConstructL(TUsbMsDriveState_Subkey aSubkey)
	{
	User::LeaveIfError(iProperty.Attach(KUsbMsDriveState_Category, aSubkey));
	CActiveScheduler::Add(this);
	// initial subscription and process current property value
	RunL();
	}
// ---------------------------------------------------------
// CUniSmilList::CreateSmilAttachmentL
//
// Create SMIL from DOM
// ---------------------------------------------------------
//
EXPORT_C void CUniSmilList::CreateSmilAttachmentL(
        MUniSmilComposeObserver& aObserver,
        CMsvStore& aEditStore,
        CMDXMLDocument* aDom )
    {
    iDom = aDom;
    iObserver = &aObserver;
    //iSmilAttaId = KMsvNullIndexEntryId;
    //iSmilAttaFullpath.Zero();

    iManager = &( aEditStore.AttachmentManagerL() );
    CMsvAttachment* attachment = CMsvAttachment::NewL( CMsvAttachment::EMsvFile );
    CleanupStack::PushL( attachment );

    //TODO: Set size(?) & complete flag(?)
    //attachment->SetSize()
    //attachment->SetComplete( EFalse );

    iEditFile = new ( ELeave ) RFile;
    CMuiuOperationWait* wait = CMuiuOperationWait::NewLC();
    iManager->CreateAttachmentL( KPresentationFileName, *iEditFile, attachment, wait->iStatus );
    wait->Start();
    //manager.AddAttachmentL( aPath, attachment, iStatus );
    CleanupStack::PopAndDestroy( wait );	

    CleanupStack::Pop( attachment );
    iAttachment = attachment;

    //Do self complete to trigger runL 
    RunL();
    }
// -----------------------------------------------------------------------------
// ConstructL()
// -----------------------------------------------------------------------------
//
void CCCEPluginManager::ConstructL()
    {
#if 0
// capabilities still todo here

    static _LIT_SECURITY_POLICY_PASS( KAllowAllPolicy );
    static _LIT_SECURITY_POLICY_C2( KICMPolicy, 
                                    ECapabilityNetworkControl,
                                    ECapabilityWriteDeviceData);    

        
    // define first property to be integer type
    TInt err = RProperty::Define( KPSUidICMIncomingCall, 
        KPropertyKeyICMPluginUID, RProperty::EInt, KAllowAllPolicy, KICMPolicy );
#else
    // define first property to be integer type
    TInt err = RProperty::Define( KPSUidICMIncomingCall, 
        KPropertyKeyICMPluginUID, RProperty::EInt );
#endif
        
    if ( err != KErrAlreadyExists )
        {
        User::LeaveIfError( err );
        }
        
    User::LeaveIfError( iProperty.Attach( KPSUidICMIncomingCall,
        KPropertyKeyICMPluginUID ) );
    CActiveScheduler::Add(this);
    RunL();

    iIdle = CIdle::NewL( EPriorityIdle );
    iIdle->Start( TCallBack(DoAfterBoot,this) );
    
    iSPSettings = CCCESPSettingsHandler::NewL( *this );
    }
/**
The 2nd phase constructor. Attaches to the property, completes the async 
request to cause the RunL method to be called for the first time and check
if there has already been an update to the property.

@leave If a error happens, it leaves with one of the system error codes.
*/
void CLbsInternalPosStatusWatcher::ConstructL()
	{
    // Get the CategoryUid from the cenrep file owned by LbsRoot.
    TInt category;
    CRepository* rep = CRepository::NewLC(KLbsCenRepUid);

    // attach to the property
	if (iType == ELbsPositioningStatusMO)
		{
		// Mobile Originated Status P&S Property
        User::LeaveIfError(rep->Get(KMoPositioningStatusAPIKey, category));
        TSecureId propOwnerSecureId(category);
		User::LeaveIfError(iProperty.Attach(propOwnerSecureId, KLbsMoPositioningStatusKey, EOwnerThread));
		}
	else if (iType == ELbsPositioningStatusNI)
		{
		// Network Initiated Status P&S Property
        User::LeaveIfError(rep->Get(KNiPositioningStatusAPIKey, category));
        TSecureId propOwnerSecureId(category);
		User::LeaveIfError(iProperty.Attach(propOwnerSecureId, KLbsNiPositioningStatusKey, EOwnerThread));
		}
	else
		{
		// Any other value indicates a programming error
		User::Leave(KErrArgument);
		}

    CleanupStack::PopAndDestroy(rep);

    CActiveScheduler::Add(this);
    // initial subscription and process current property value
    RunL();
	}
Beispiel #6
0
void TFail::Test(const THeapFail& aHeap,const TContext* aContext)
	{
	TInt ii;
	TInt errCode;
	for (ii=1;;++ii)
		{
		if (aContext)
			{
			TRAP(errCode, aContext->OpenDbL());
			if(errCode != KErrNone)
				return;
			}
		aHeap.Fail(ii);
		aHeap.Mark();
		TRAPD(r,RunL());
		aHeap.Reset();
		if (r==KErrNone)
			break;
		test(r==KErrNoMemory);
		if (aContext)
			TheDatabase.Close();
		aHeap.Check();
		}
	End();
	if (aContext)
		TheDatabase.Close();
	aHeap.Check();
	}
void CTestCaseTimerWatch::ConstructL()
	{	
	iTimer.After(iStatus, 61000000); // 61s timer
	
	CActiveScheduler::Add(this);
	// initial subscription and process current property value
	RunL();
	}
void CPropertyObserver::ConstructL()
        {
        RThread t;
        RDebug::Print(_L("Property init, thread %d"),t.Id().Id());
        User::LeaveIfError( iProperty.Attach( iUid, iKey ) );
        CActiveScheduler::Add(this);
        // initial subscription and process current property value
        RunL();
        }
// -----------------------------------------------------------------------------
// CSensorDataCompensatorInitializer::ConstructL
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CSensorDataCompensatorInitializer::ConstructL()
    {
    FUNC_LOG;

    CActiveScheduler::Add( this );
	User::LeaveIfError( iProperty.Attach( KPSUidStartup,
	                    KPSIdlePhase1Ok ) );
    RunL(); // Start listening
    }
// ---------------------------------------------------------------------------
// CAknMemorySelectionDialogMultiDrive::RunDlgLD
// A wrapper for RunL.
// ---------------------------------------------------------------------------
//
EXPORT_C TBool CAknMemorySelectionDialogMultiDrive::RunDlgLD(
    TDriveNumber& aSelectedDrive,
    TInt aResourceId,
    TDes* aRootPath,
    TDes* aDefaultFolder )
    {
    return RunL(
        aResourceId, aSelectedDrive, aRootPath, aDefaultFolder, KNullDesC );
    }
void CRequestSessionWatcher::ConstructL()
    {
    __MSFNLOG
    User::LeaveIfError(iProperty.Define(KUidUsbManCategory, KUsbRequestSessionProperty, RProperty::EInt));
    User::LeaveIfError(iProperty.Attach(KUidUsbManCategory, KUsbRequestSessionProperty));
    CActiveScheduler::Add(this);

    // initial subscription and process current property value
	RunL();
    }
	void CSender::StartPassive(TInt aPort, TRequestStatus* aStatus, RConnection& aConn, TAction aAction)
		{
		iAction = aAction;
		iSavedStatus = aStatus;
		if (!iSavedStatus) User::Invariant();
		
		// Open a sock for listening on a connection
		TInt nRet = iListener.Open(iSS, KAfInet, KSockStream, KProtocolInetTcp, aConn);
		if (nRet != KErrNone)
			{
			iLogger.Log(_L("Failed to open socket on Iap %d on Network %d, : return value = %d"),
				nRet, iPref.IapId(), iPref.NetId());
			User::Leave(nRet);
			}

		// bind the socket
		iLocal.SetPort(aPort);
		nRet = iListener.Bind(iLocal);
		if (nRet != KErrNone)
			{
			iLogger.Log(_L("Failed to bind socketon Iap %d on Network %d, : return value = %d"),
				nRet, iPref.IapId(), iPref.NetId());
			User::Leave(nRet);
			}

		// listen on the socket
		nRet = iListener.Listen(1);
		if (nRet != KErrNone)
			{
			iLogger.Log(_L("Failed to listen on socketon Iap %d on Network %d, : return value = %d"),
				nRet, iPref.IapId(), iPref.NetId());
			User::Leave(nRet);
			}

		// open a blank socket
		nRet = iSock.Open(iSS);
		if (nRet != KErrNone)
			{
			iLogger.Log(_L("Failed to open Receiver socketon Iap %d on Network %d, : return value = %d"),
				nRet, iPref.IapId(), iPref.NetId());
			User::Leave(nRet);
			}

		// Mark the saved state as pending
		if (iSavedStatus)
			*iSavedStatus = KRequestPending;
		
		iLogger.Log(_L("Trying to Accept on Iap %d on Network %d"), iPref.IapId(), iPref.NetId());
		iListener.Accept(iSock, iStatus);
		// Wait for async incoming connction
		iState = EConnecting;
		//SetActive();
		User::WaitForRequest(iStatus);
		RunL();
		}
void CTestCasePropertyWatch::ConstructL()
	{
	//User::LeaveIfError(iProperty.Attach(KMyHWRMTestPpoperty,EHWRMNextTestToRun));
	User::LeaveIfError(iProperty.Attach(KMyHWRMTestPpoperty,EHWRMStepResult));
	
	//iTimer.After(iStatus, 61000000); // 61s timer
	
	CActiveScheduler::Add(this);
	// initial subscription and process current property value
	RunL();
	}
void CCamcTestClient_9::MvruoPrepareComplete( TInt aError )
    {    
    if (aError)
        {
         SomethingInActiveObjectIsLeaving(aError);
        }
    else
        {
        iPrepareReady = ETrue;
        RunL();
        }
    }
void CCamcTestClient_3::MvruoRecordComplete( TInt aError )
    {
    if (aError)
        {
         SomethingInActiveObjectIsLeaving(aError);
        }
    else
        {
        iRecordingReady = ETrue;
        RunL(); // RunL is trapped, cannot actually leave.
        }
    }
void CCamcTestClient_visualcheck::MvruoPrepareComplete( TInt aError )
    {    
    if (aError)
        {
        SomethingInActiveObjectIsLeaving(aError);
        }
    else
        {
        iPrepareReady = ETrue;
        RunL(); // RunL is trapped, cannot actually leave.
        }
    }
// -----------------------------------------------------------------------------
// CHWRMExtendedLightStatusObserver::ConstructL
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CHWRMExtendedLightStatusObserver::ConstructL()
    {
    COMPONENT_TRACE1(_L( "HWRM ExtendedLightClient - CHWRMExtendedLightStatusObserver::ConstructL()" ));

    User::LeaveIfError( InitializeStatusArray( iLastStatusValue ) );
    User::LeaveIfError( InitializeStatusArray( iStatusUnknownList ) );
    User::LeaveIfError(iProperty.Attach(KPSUidHWResourceNotification, KHWRMLightStatus));
    
    // Call RunL to order notification and do the initial notifying of the client
    RunL();

    COMPONENT_TRACE1(_L( "HWRM ExtendedLightClient - CHWRMExtendedLightStatusObserver::ConstructL - return" ) );
    }
void CUnifiedCertStore::DoCancel()
	{
	// If the current state is the last state involved in handling a request, we
	// check to see if we have already been completed - in this case we can
	// simply complete the client with iStatus (this may be KErrNone).  If we
	// have not we cancel the outstanding request and pass the resulting iStatus
	// back to the client - this too may indicate a successful completion if the
	// cancel arrived after the request was executed.
	//
	// For more complex cases, where there are more states to go through before
	// we finish servicing the client request, we cancel any outstanding
	// request, and return KErrCancel to the client.

	switch (iState)
		{
		case EInitializeFinished:
		case ERetrieve:
		case EGetCert:
		case EApplications:
		case EIsApplicable:
		case ETrusted:
		case ERetrieveData:
		case ERemove:
		case ESetApplicability:
		case ESetTrust:		
			if (iStatus == KRequestPending)
				{
				// Attempt to cancel outstanding request and pass status back to
				// client
				CancelOutstandingRequest();
				Complete(iStatus.Int());
				}
			else
				{
				// We've already been completed - call RunL() to process results
				// and complete client
				TRAPD(err, RunL());
				if (err != KErrNone)
					{
					RunError(err);
					}
				}
			break;
			
		default:
			CancelOutstandingRequest();
			Complete(KErrCancel);
			break;
		}
	}
Beispiel #19
0
void CSymTtkImageDecoder::decode(const char* filename,
				 TtkBitmapInterface*& bitmap, TtkImage& image)
{
	_LIT8(KGifMimeType, "image/gif");
	CActiveScheduler::Add(this);
	TPtrC8 ptr(reinterpret_cast<const unsigned char*>(filename));
	HBufC* buffer = CnvUtfConverter::ConvertToUnicodeFromUtf8L(ptr);
	CleanupStack::PushL(buffer);
	iDecoder = CImageDecoder::FileNewL(CCoeEnv::Static()->FsSession(),
			*buffer, KGifMimeType);
	CleanupStack::PopAndDestroy(buffer);
	iTimer.CreateLocal();
	iImage = &image;
	RunL();
}
TInt E32Main()
	{
	__UHEAP_MARK;

	CTrapCleanup* cleanup=CTrapCleanup::New();
	TInt r=KErrNoMemory;
	if (cleanup)
		{
		TRAP(r,RunL());
		delete cleanup;
		}

	__UHEAP_MARKEND;
	return r;
	}
TInt E32Main()
	{
	__UHEAP_MARK;

	CTrapCleanup* cleanup=CTrapCleanup::New();
	TInt r=KErrNoMemory;
	if (cleanup)
		{
		TRAP(r,RunL());
		delete cleanup;
		}

	__UHEAP_MARKEND;
	return r;
	} //lint -e714 Suppress 'not referenced'
void CCamcTestClient_visualcheck::MvruoRecordComplete( TInt aError )
    {
#ifdef _DEBUG
    RDebug::Print(_L("CamCTestClient VisualCheck:Record Complete"));
#endif
    if ((aError) && (aError != KErrCompletion))
        {
        SomethingInActiveObjectIsLeaving(aError);
        }
    else
        {
        iRecordingReady = ETrue;
        RunL(); // RunL is trapped, cannot actually leave.
        }
    }
// -----------------------------------------------------------------------------
// CHttpFilterConnHandlerObserver::ConstructL
// ------------------------------------------------------------------------------
void CHttpFilterConnHandlerObserver::ConstructL()
{
    // Note: the CHttpFilterConnHandlerObserver object s.b. created after connection is set for particular bearer
    User::LeaveIfError(iGPRSStateProperty.Attach(KUidSystemCategory, KPSUidGprsStatusValue));
    User::LeaveIfError(iWCDMAStateProperty.Attach(KUidSystemCategory, KPSUidWcdmaStatusValue)); 

    CActiveScheduler::Add(this);
    iSuspendTimer = CPeriodic::NewL(CActive::EPriorityLow );
    if( !iTelServer.Handle() )	
        {
        // this initialization needed for identifying 3G networks
        //
        User::LeaveIfError( iTelServer.Connect() );
        User::LeaveIfError( iTelServer.LoadPhoneModule( KMmTsyModuleName ) );

        TInt numPhones;
        User::LeaveIfError( iTelServer.EnumeratePhones( numPhones ) );
        if( numPhones <= 0 )
            {
            // Huh???
            User::Leave( KErrCorrupt );
            }

        RTelServer::TPhoneInfo phoneInfo;
        User::LeaveIfError( iTelServer.GetPhoneInfo( 0, phoneInfo ) );
        User::LeaveIfError( iMobilePhone.Open( iTelServer, phoneInfo.iName ) );
        User::LeaveIfError( iMobilePhone.Initialise() );

		RMobilePhone::TMobilePhoneNetworkMode networkMode;
		User::LeaveIfError( iMobilePhone.GetCurrentMode( networkMode ) );

		if( networkMode == RMobilePhone::ENetworkModeWcdma ||
			networkMode == RMobilePhone::ENetworkModeTdcdma )
			{ // 3G/WCDMA mode
			iUidValue = KPSUidWcdmaStatusValue;
			}
		else if ( networkMode == RMobilePhone::ENetworkModeGsm ||
				  networkMode == RMobilePhone::ENetworkModeUnknown ||	
				  networkMode == RMobilePhone::ENetworkModeUnregistered )
			{
			iUidValue = KPSUidGprsStatusValue;
			}
		}

    // initial subscription and process current property value
    RunL();
}
void Drive::initiate(double Lat, double Lng){
  //Serial.println("Motor Initiating");
  escR.attach(RightMotor);
  escL.attach(LeftMotor);
  delay(4000);
  
  RunR(RGain*200);
  RunL(LGain*200);
  delay(4000);
  //Serial.println("Ready to Drive");
  goalLat = Lat;
  goalLng = Lng;
  //Serial.print("Destination Lat = ");
  //Serial.println(goalLat);
  //Serial.print("            Lng = ");
  //Serial.println(goalLng);
}
void CCamcTestClient_9::MvruoRecordComplete( TInt aError )
    {
    switch( iAction)
        {
        case K_Tc9_SetMaxClipSizeLWhenControllerReadySize0 :
        case K_Tc9_SetMaxClipSizeLWhenControllerReadyKMMFNoMaxClipSize :
            {
            if ( (aError ==  KErrDiskFull) || (aError == KErrCompletion ) )
                {
                // KErrCompletion if there is more space than needed for 60 min recording.
                // Otherwise KErrDiskFull
                aError = KErrNone;
                }
            else
                {
                aError = KErrGeneral;
                }
            break;
            }
        case K_TC9_NewFileNameWhenInternalStop :
            {
            if (aError == KErrCompletion)
                {
                // That's expected case.
                aError = KErrNone;
                }
            else
                {
                aError = KErrGeneral;
                }
            break;
            }
        }

    if (aError)
        {
         SomethingInActiveObjectIsLeaving(aError);
        }
    else
        {
        iRecordingReady = ETrue;
        RunL();
        }
    }
GLDEF_C TInt E32Main()
	{
	__UHEAP_MARK;
	TInt err = KErrNoMemory;
	CActiveScheduler* sheduler = new CActiveScheduler;
	if (sheduler)
		{
		CActiveScheduler::Install(sheduler);
		CTrapCleanup* cleanup = CTrapCleanup::New();
		if (cleanup)
			{
			TRAP(err, RunL());
			delete cleanup;
			}
		delete sheduler;
		}
	__UHEAP_MARKEND;
	return err;
	}
void Drive::gotoGoal(){
  double vel;
  double str;
  vel = Velcoeff*sqrt((((myLat-goalLat)*1000000)*((myLat-goalLat)*1000000))+(((myLng-goalLng)*1000000)*((myLng-goalLng)*1000000)));
  str = Strcoeff1*calSteer(myLat, myLng, goalLat, goalLng, yaw) + Strcoeff2*angV;
  if(str > Maxstr){
    str = Maxstr;
  }
  else if(str < -Maxstr){
    str = -Maxstr;
  }
  if(vel > Maxvel){
    vel = Maxvel;
  }
  else if(vel < -Maxvel){
    vel = -Maxvel;
  }
  RunR(vel - str);
  RunL(vel + str);
}
void CTcSerialConnection::ConnectL()
    {
    LOG( _L("CTcSerialConnection::ConnectL() start") );
	if( iState != EIdle )
		{
		User::Leave( KErrNotReady );
		}

	iState = EConnecting;

	// Open serial port
	SetupPortL();
	
    // Serial port can be used immediately after port opening, do some nasty
    // RunL call to get in connected state
    iStatus = KErrNone;
	RunL();

	LOG( _L("CTcSerialConnection::ConnectL() end") );
    }
	void CSender::StartActive(TRequestStatus* aStatus, TAction aAction)
		{
		iAction = aAction;
		iSavedStatus = aStatus;

		// Mark the saved state as pending
		if (iSavedStatus) 
			*iSavedStatus = KRequestPending;

		TBuf<39> AddrBuf;
		iRemote.OutputWithScope(AddrBuf);
		
		iLogger.Log(_L("Trying to connect socket to %S on Iap %d on Network %d"), 
			&AddrBuf, iPref.IapId(), iPref.NetId());
		
		iSock.Connect(iRemote, iStatus);
		iState = EConnecting;
		// this is commented so that the first socket gets connected first
		//SetActive();
		User::WaitForRequest(iStatus);
		RunL();
		}
void Drive::gotoDes(){
	double vel;
  double str;
  vel = Velcoeff*sqrt((((myLat-desLat)*1000000)*((myLat-desLat)*1000000))+(((myLng-desLng)*1000000)*((myLng-desLng)*1000000)));
  str = Strcoeff1*calSteer(myLat, myLng, desLat, desLng, yaw) + Strcoeff2*angV;
  if(str > Maxstr){
    str = Maxstr;
  }
  else if(str < -Maxstr){
    str = -Maxstr;
  }
  if(vel > Maxvel){
    vel = Maxvel;
  }
  else if(vel < -Maxvel){
    vel = -Maxvel;
  }
  RunR(vel - str);
  RunL(vel + str);
        /*double myLngdeg = transDeg(myLng);
        double myLatdeg = transDeg(myLat);
        double goalLngdeg = transDeg(goalLng);
        double goalLatdeg = transDeg(goalLat);
	double A = (PI/180)*abs(myLngdeg - goalLngdeg);
//Serial.println(A*180/PI);
	double b = (PI/180)*abs(90 - myLatdeg);
//Serial.println(b*180/PI);
	double c = (PI/180)*abs(90 - goalLatdeg);
//Serial.println(c*180/PI);
        double Distance = 64000*acos(cos(b)*cos(c) + sin(b)*sin(c)*cos(A));
        //Serial.print("Distance = ");
        //Serial.print(Distance, 6);
        //Serial.println("m");
	vel = 50000*acos(cos(b)*cos(c) + sin(b)*sin(c)*cos(A));
*/
  //drive = 0(Stop), drive = 1(go to goal point), drive = 2(go to a point)
}