kerneltest/e32test/usbho/t_usbdi/src/SoftwareConnectTimer.cpp
changeset 259 57b9594f5772
parent 0 a41df078684a
child 257 3e88ff8f41d5
equal deleted inserted replaced
247:d8d70de2bd36 259:57b9594f5772
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2007-2010 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
    20 
    24 
    21 namespace NUnitTesting_USBDI
    25 namespace NUnitTesting_USBDI
    22 	{
    26 	{
    23 	
    27 	
    24 const TInt KOneSecond(1000000);
    28 const TInt KOneSecond(1000000);
    25 	
    29 	
    26 CSoftwareConnectTimer* CSoftwareConnectTimer::NewL(RUsbTestDevice& aTestDevice)
    30 CSoftwareConnectTimer* CSoftwareConnectTimer::NewL(RUsbTestDevice& aTestDevice)
    27 	{
    31 	{
       
    32 	OstTraceFunctionEntry1( CSOFTWARECONNECTTIMER_NEWL_ENTRY, ( TUint )&( aTestDevice ) );
    28 	CSoftwareConnectTimer* self = new (ELeave) CSoftwareConnectTimer(aTestDevice);
    33 	CSoftwareConnectTimer* self = new (ELeave) CSoftwareConnectTimer(aTestDevice);
    29 	CleanupStack::PushL(self);
    34 	CleanupStack::PushL(self);
    30 	self->ConstructL();
    35 	self->ConstructL();
    31 	CleanupStack::Pop(self);
    36 	CleanupStack::Pop(self);
       
    37 	OstTraceFunctionExit1( CSOFTWARECONNECTTIMER_NEWL_EXIT, ( TUint )( self ) );
    32 	return self;
    38 	return self;
    33 	}
    39 	}
    34 	
    40 	
    35 	
    41 	
    36 CSoftwareConnectTimer::CSoftwareConnectTimer(RUsbTestDevice& aTestDevice)
    42 CSoftwareConnectTimer::CSoftwareConnectTimer(RUsbTestDevice& aTestDevice)
    37 :	CTimer(EPriorityStandard),
    43 :	CTimer(EPriorityStandard),
    38 	iTestDevice(aTestDevice),
    44 	iTestDevice(aTestDevice),
    39 	iConnectType(EUnknown)
    45 	iConnectType(EUnknown)
    40 	{
    46 	{
       
    47 	OstTraceFunctionEntryExt( CSOFTWARECONNECTTIMER_CSOFTWARECONNECTTIMER_ENTRY, this );
    41 	CActiveScheduler::Add(this);
    48 	CActiveScheduler::Add(this);
       
    49 	OstTraceFunctionExit1( CSOFTWARECONNECTTIMER_CSOFTWARECONNECTTIMER_EXIT, this );
    42 	}
    50 	}
    43 	
    51 	
    44 	
    52 	
    45 CSoftwareConnectTimer::~CSoftwareConnectTimer()
    53 CSoftwareConnectTimer::~CSoftwareConnectTimer()
    46 	{
    54 	{
    47 	LOG_FUNC
    55 	OstTraceFunctionEntry1( CSOFTWARECONNECTTIMER_CSOFTWARECONNECTTIMER_ENTRY_DUP01, this );
       
    56 	OstTraceFunctionExit1( CSOFTWARECONNECTTIMER_CSOFTWARECONNECTTIMER_EXIT_DUP01, this );
    48 	}
    57 	}
    49 	
    58 	
    50 	
    59 	
    51 void CSoftwareConnectTimer::SoftwareConnect(TInt aInterval)
    60 void CSoftwareConnectTimer::SoftwareConnect(TInt aInterval)
    52 	{
    61 	{
    53 	LOG_FUNC
    62 	OstTraceFunctionEntryExt( CSOFTWARECONNECTTIMER_SOFTWARECONNECT_ENTRY, this );
    54 	iConnectType = EConnect;
    63 	iConnectType = EConnect;
    55 	After(aInterval*KOneSecond);
    64 	After(aInterval*KOneSecond);
       
    65 	OstTraceFunctionExit1( CSOFTWARECONNECTTIMER_SOFTWARECONNECT_EXIT, this );
    56 	}
    66 	}
    57 	
    67 	
    58 
    68 
    59 void CSoftwareConnectTimer::SoftwareDisconnect(TInt aInterval)
    69 void CSoftwareConnectTimer::SoftwareDisconnect(TInt aInterval)
    60 	{
    70 	{
    61 	LOG_FUNC
    71 	OstTraceFunctionEntryExt( CSOFTWARECONNECTTIMER_SOFTWAREDISCONNECT_ENTRY, this );
    62 	iConnectType = EDisconnect;
    72 	iConnectType = EDisconnect;
    63 	After(aInterval*KOneSecond);
    73 	After(aInterval*KOneSecond);
       
    74 	OstTraceFunctionExit1( CSOFTWARECONNECTTIMER_SOFTWAREDISCONNECT_EXIT, this );
    64 	}
    75 	}
    65 	
    76 	
    66 	
    77 	
    67 void CSoftwareConnectTimer::SoftwareReConnect(TInt aInterval)
    78 void CSoftwareConnectTimer::SoftwareReConnect(TInt aInterval)
    68 	{
    79 	{
    69 	LOG_FUNC
    80 	OstTraceFunctionEntryExt( CSOFTWARECONNECTTIMER_SOFTWARERECONNECT_ENTRY, this );
    70 	iTestDevice.SoftwareDisconnect();
    81 	iTestDevice.SoftwareDisconnect();
    71 	SoftwareConnect(aInterval);
    82 	SoftwareConnect(aInterval);
       
    83 	OstTraceFunctionExit1( CSOFTWARECONNECTTIMER_SOFTWARERECONNECT_EXIT, this );
    72 	}
    84 	}
    73 
    85 
    74 
    86 
    75 void CSoftwareConnectTimer::RunL()
    87 void CSoftwareConnectTimer::RunL()
    76 	{
    88 	{
    77 	LOG_FUNC
    89 	OstTraceFunctionEntry1( CSOFTWARECONNECTTIMER_RUNL_ENTRY, this );
    78 	TInt completionCode(iStatus.Int());
    90 	TInt completionCode(iStatus.Int());
    79 	
    91 	
    80 	if(completionCode != KErrNone)
    92 	if(completionCode != KErrNone)
    81 		{
    93 		{
    82 		RDebug::Printf("<Error %d> software connect/disconnect timer error",completionCode);
    94 		OstTrace1(TRACE_NORMAL, CSOFTWARECONNECTTIMER_RUNL, "<Error %d> software connect/disconnect timer error",completionCode);
    83 		iTestDevice.ReportError(completionCode);
    95 		iTestDevice.ReportError(completionCode);
    84 		}
    96 		}
    85 	else
    97 	else
    86 		{
    98 		{
    87 		switch(iConnectType)
    99 		switch(iConnectType)
    93 			case EDisconnect:
   105 			case EDisconnect:
    94 				iTestDevice.SoftwareDisconnect();
   106 				iTestDevice.SoftwareDisconnect();
    95 				break;
   107 				break;
    96 				
   108 				
    97 			case EUnknown:
   109 			case EUnknown:
    98 				RDebug::Printf("<Error> Unknown state for software connect timer");
   110 				OstTrace0(TRACE_NORMAL, CSOFTWARECONNECTTIMER_RUNL_DUP01, "<Error> Unknown state for software connect timer");
    99 				break;
   111 				break;
   100 			
   112 			
   101 			default:
   113 			default:
   102 				break;
   114 				break;
   103 			}			
   115 			}			
   104 		}	
   116 		}	
       
   117 	OstTraceFunctionExit1( CSOFTWARECONNECTTIMER_RUNL_EXIT, this );
   105 	}
   118 	}
   106 
   119 
   107 
   120 
   108 	}
   121 	}
   109 	
   122