kerneltest/e32test/usbho/t_usbdi/src/SoftwareConnectTimer.cpp
branchRCL_3
changeset 44 3e88ff8f41d5
parent 43 c1f20ce4abcf
equal deleted inserted replaced
43:c1f20ce4abcf 44:3e88ff8f41d5
     1 // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    15 // @internalComponent
    15 // @internalComponent
    16 // 
    16 // 
    17 //
    17 //
    18 
    18 
    19 #include "softwareconnecttimer.h"
    19 #include "softwareconnecttimer.h"
    20 #include "OstTraceDefinitions.h"
       
    21 #ifdef OST_TRACE_COMPILER_IN_USE
       
    22 #include "SoftwareConnectTimerTraces.h"
       
    23 #endif
       
    24 
    20 
    25 namespace NUnitTesting_USBDI
    21 namespace NUnitTesting_USBDI
    26 	{
    22 	{
    27 	
    23 	
    28 const TInt KOneSecond(1000000);
    24 const TInt KOneSecond(1000000);
    29 	
    25 	
    30 CSoftwareConnectTimer* CSoftwareConnectTimer::NewL(RUsbTestDevice& aTestDevice)
    26 CSoftwareConnectTimer* CSoftwareConnectTimer::NewL(RUsbTestDevice& aTestDevice)
    31 	{
    27 	{
    32 	OstTraceFunctionEntry1( CSOFTWARECONNECTTIMER_NEWL_ENTRY, ( TUint )&( aTestDevice ) );
       
    33 	CSoftwareConnectTimer* self = new (ELeave) CSoftwareConnectTimer(aTestDevice);
    28 	CSoftwareConnectTimer* self = new (ELeave) CSoftwareConnectTimer(aTestDevice);
    34 	CleanupStack::PushL(self);
    29 	CleanupStack::PushL(self);
    35 	self->ConstructL();
    30 	self->ConstructL();
    36 	CleanupStack::Pop(self);
    31 	CleanupStack::Pop(self);
    37 	OstTraceFunctionExit1( CSOFTWARECONNECTTIMER_NEWL_EXIT, ( TUint )( self ) );
       
    38 	return self;
    32 	return self;
    39 	}
    33 	}
    40 	
    34 	
    41 	
    35 	
    42 CSoftwareConnectTimer::CSoftwareConnectTimer(RUsbTestDevice& aTestDevice)
    36 CSoftwareConnectTimer::CSoftwareConnectTimer(RUsbTestDevice& aTestDevice)
    43 :	CTimer(EPriorityStandard),
    37 :	CTimer(EPriorityStandard),
    44 	iTestDevice(aTestDevice),
    38 	iTestDevice(aTestDevice),
    45 	iConnectType(EUnknown)
    39 	iConnectType(EUnknown)
    46 	{
    40 	{
    47 	OstTraceFunctionEntryExt( CSOFTWARECONNECTTIMER_CSOFTWARECONNECTTIMER_ENTRY, this );
       
    48 	CActiveScheduler::Add(this);
    41 	CActiveScheduler::Add(this);
    49 	OstTraceFunctionExit1( CSOFTWARECONNECTTIMER_CSOFTWARECONNECTTIMER_EXIT, this );
       
    50 	}
    42 	}
    51 	
    43 	
    52 	
    44 	
    53 CSoftwareConnectTimer::~CSoftwareConnectTimer()
    45 CSoftwareConnectTimer::~CSoftwareConnectTimer()
    54 	{
    46 	{
    55 	OstTraceFunctionEntry1( CSOFTWARECONNECTTIMER_CSOFTWARECONNECTTIMER_ENTRY_DUP01, this );
    47 	LOG_FUNC
    56 	OstTraceFunctionExit1( CSOFTWARECONNECTTIMER_CSOFTWARECONNECTTIMER_EXIT_DUP01, this );
       
    57 	}
    48 	}
    58 	
    49 	
    59 	
    50 	
    60 void CSoftwareConnectTimer::SoftwareConnect(TInt aInterval)
    51 void CSoftwareConnectTimer::SoftwareConnect(TInt aInterval)
    61 	{
    52 	{
    62 	OstTraceFunctionEntryExt( CSOFTWARECONNECTTIMER_SOFTWARECONNECT_ENTRY, this );
    53 	LOG_FUNC
    63 	iConnectType = EConnect;
    54 	iConnectType = EConnect;
    64 	After(aInterval*KOneSecond);
    55 	After(aInterval*KOneSecond);
    65 	OstTraceFunctionExit1( CSOFTWARECONNECTTIMER_SOFTWARECONNECT_EXIT, this );
       
    66 	}
    56 	}
    67 	
    57 	
    68 
    58 
    69 void CSoftwareConnectTimer::SoftwareDisconnect(TInt aInterval)
    59 void CSoftwareConnectTimer::SoftwareDisconnect(TInt aInterval)
    70 	{
    60 	{
    71 	OstTraceFunctionEntryExt( CSOFTWARECONNECTTIMER_SOFTWAREDISCONNECT_ENTRY, this );
    61 	LOG_FUNC
    72 	iConnectType = EDisconnect;
    62 	iConnectType = EDisconnect;
    73 	After(aInterval*KOneSecond);
    63 	After(aInterval*KOneSecond);
    74 	OstTraceFunctionExit1( CSOFTWARECONNECTTIMER_SOFTWAREDISCONNECT_EXIT, this );
       
    75 	}
    64 	}
    76 	
    65 	
    77 	
    66 	
    78 void CSoftwareConnectTimer::SoftwareReConnect(TInt aInterval)
    67 void CSoftwareConnectTimer::SoftwareReConnect(TInt aInterval)
    79 	{
    68 	{
    80 	OstTraceFunctionEntryExt( CSOFTWARECONNECTTIMER_SOFTWARERECONNECT_ENTRY, this );
    69 	LOG_FUNC
    81 	iTestDevice.SoftwareDisconnect();
    70 	iTestDevice.SoftwareDisconnect();
    82 	SoftwareConnect(aInterval);
    71 	SoftwareConnect(aInterval);
    83 	OstTraceFunctionExit1( CSOFTWARECONNECTTIMER_SOFTWARERECONNECT_EXIT, this );
       
    84 	}
    72 	}
    85 
    73 
    86 
    74 
    87 void CSoftwareConnectTimer::RunL()
    75 void CSoftwareConnectTimer::RunL()
    88 	{
    76 	{
    89 	OstTraceFunctionEntry1( CSOFTWARECONNECTTIMER_RUNL_ENTRY, this );
    77 	LOG_FUNC
    90 	TInt completionCode(iStatus.Int());
    78 	TInt completionCode(iStatus.Int());
    91 	
    79 	
    92 	if(completionCode != KErrNone)
    80 	if(completionCode != KErrNone)
    93 		{
    81 		{
    94 		OstTrace1(TRACE_NORMAL, CSOFTWARECONNECTTIMER_RUNL, "<Error %d> software connect/disconnect timer error",completionCode);
    82 		RDebug::Printf("<Error %d> software connect/disconnect timer error",completionCode);
    95 		iTestDevice.ReportError(completionCode);
    83 		iTestDevice.ReportError(completionCode);
    96 		}
    84 		}
    97 	else
    85 	else
    98 		{
    86 		{
    99 		switch(iConnectType)
    87 		switch(iConnectType)
   105 			case EDisconnect:
    93 			case EDisconnect:
   106 				iTestDevice.SoftwareDisconnect();
    94 				iTestDevice.SoftwareDisconnect();
   107 				break;
    95 				break;
   108 				
    96 				
   109 			case EUnknown:
    97 			case EUnknown:
   110 				OstTrace0(TRACE_NORMAL, CSOFTWARECONNECTTIMER_RUNL_DUP01, "<Error> Unknown state for software connect timer");
    98 				RDebug::Printf("<Error> Unknown state for software connect timer");
   111 				break;
    99 				break;
   112 			
   100 			
   113 			default:
   101 			default:
   114 				break;
   102 				break;
   115 			}			
   103 			}			
   116 		}	
   104 		}	
   117 	OstTraceFunctionExit1( CSOFTWARECONNECTTIMER_RUNL_EXIT, this );
       
   118 	}
   105 	}
   119 
   106 
   120 
   107 
   121 	}
   108 	}
   122 	
   109