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