14 * Description: This class implements the dps state machine. |
14 * Description: This class implements the dps state machine. |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 |
18 |
19 #include <e32debug.h> |
|
20 #include "dpsstatemachine.h" |
19 #include "dpsstatemachine.h" |
21 #include "dpsscriptreceiver.h" |
20 #include "dpsscriptreceiver.h" |
22 #include "dpsscriptsender.h" |
21 #include "dpsscriptsender.h" |
23 #include "dpstransaction.h" |
22 #include "dpstransaction.h" |
24 #include "dpsconst.h" |
23 #include "dpsconst.h" |
25 #include "pictbridge.h" |
24 #include "pictbridge.h" |
26 #include "dpsparam.h" |
25 #include "dpsparam.h" |
27 #include "dpsoperation.h" |
26 #include "dpsoperation.h" |
28 |
27 #include "OstTraceDefinitions.h" |
29 #ifdef _DEBUG |
28 #ifdef OST_TRACE_COMPILER_IN_USE |
30 # define IF_DEBUG(t) {RDebug::t;} |
29 #include "dpsstatemachineTraces.h" |
31 #else |
|
32 # define IF_DEBUG(t) |
|
33 #endif |
30 #endif |
34 |
31 |
35 // --------------------------------------------------------------------------- |
32 // --------------------------------------------------------------------------- |
36 // |
33 // |
37 // --------------------------------------------------------------------------- |
34 // --------------------------------------------------------------------------- |
38 // |
35 // |
39 CDpsStateMachine* CDpsStateMachine::NewL(CDpsEngine* aEngine) |
36 CDpsStateMachine* CDpsStateMachine::NewL(CDpsEngine* aEngine) |
40 { |
37 { |
41 IF_DEBUG(Print(_L("CDpsStateMachine::NewL"))); |
|
42 CDpsStateMachine* self = new(ELeave) CDpsStateMachine(aEngine); |
38 CDpsStateMachine* self = new(ELeave) CDpsStateMachine(aEngine); |
43 CleanupStack::PushL(self); |
39 CleanupStack::PushL(self); |
44 self->ConstructL(); |
40 self->ConstructL(); |
45 CleanupStack::Pop(); |
41 CleanupStack::Pop(); |
46 return self; |
42 return self; |
62 |
58 |
63 delete iIdleState; iIdleState = NULL; |
59 delete iIdleState; iIdleState = NULL; |
64 delete iSendingReqState; iSendingReqState = NULL; |
60 delete iSendingReqState; iSendingReqState = NULL; |
65 delete iWaitingRepState; iWaitingRepState = NULL; |
61 delete iWaitingRepState; iWaitingRepState = NULL; |
66 delete iSendingRepState; iSendingRepState = NULL; |
62 delete iSendingRepState; iSendingRepState = NULL; |
67 IF_DEBUG(Print(_L("<<<~CDpsStateMachine"))); |
63 OstTraceFunctionExit0( CDPSSTATEMACHINE_CDPSSTATEMACHINE_DES_EXIT ); |
68 } |
64 } |
69 |
65 |
70 // --------------------------------------------------------------------------- |
66 // --------------------------------------------------------------------------- |
71 // |
67 // |
72 // --------------------------------------------------------------------------- |
68 // --------------------------------------------------------------------------- |
73 // |
69 // |
74 CDpsStateMachine::CDpsStateMachine(CDpsEngine* aEngine) : |
70 CDpsStateMachine::CDpsStateMachine(CDpsEngine* aEngine) : |
75 iEngine(aEngine),iOperation(EDpsOpEmpty), iEvent(EDpsEvtEmpty), |
71 iEngine(aEngine),iOperation(EDpsOpEmpty), iEvent(EDpsEvtEmpty), |
76 iCurError(KErrNone) |
72 iCurError(KErrNone) |
77 { |
73 { |
78 IF_DEBUG(Print(_L(">>>CDpsStateMachine::Ctor"))); |
74 OstTraceFunctionEntry0( DUP1_CDPSSTATEMACHINE_CDPSSTATEMACHINE_CONS_ENTRY ); |
79 |
75 |
80 IF_DEBUG(Print(_L("<<<CDpsStateMachine::Ctor"))); |
76 OstTraceFunctionExit0( DUP1_CDPSSTATEMACHINE_CDPSSTATEMACHINE_CONS_EXIT ); |
81 } |
77 } |
82 |
78 |
83 // --------------------------------------------------------------------------- |
79 // --------------------------------------------------------------------------- |
84 // |
80 // |
85 // --------------------------------------------------------------------------- |
81 // --------------------------------------------------------------------------- |
86 // |
82 // |
87 void CDpsStateMachine::ConstructL() |
83 void CDpsStateMachine::ConstructL() |
88 { |
84 { |
89 IF_DEBUG(Print(_L(">>>CDpsStateMachine::ConstructL"))); |
85 OstTraceFunctionEntry0( CDPSSTATEMACHINE_CONSTRUCTL_ENTRY ); |
90 iIdleState = new(ELeave) TDpsIdleState(this); |
86 iIdleState = new(ELeave) TDpsIdleState(this); |
91 iSendingReqState = new(ELeave) TDpsSendingReqState(this); |
87 iSendingReqState = new(ELeave) TDpsSendingReqState(this); |
92 iWaitingRepState = new(ELeave) TDpsWaitingRepState(this); |
88 iWaitingRepState = new(ELeave) TDpsWaitingRepState(this); |
93 iSendingRepState = new(ELeave) TDpsSendingRepState(this); |
89 iSendingRepState = new(ELeave) TDpsSendingRepState(this); |
94 iCurState = iIdleState; |
90 iCurState = iIdleState; |
95 iTrader = CDpsTransaction::NewL(this); |
91 iTrader = CDpsTransaction::NewL(this); |
96 iScriptReceiver = CDpsScriptReceiver::NewL(this); |
92 iScriptReceiver = CDpsScriptReceiver::NewL(this); |
97 iScriptSender = CDpsScriptSender::NewL(this); |
93 iScriptSender = CDpsScriptSender::NewL(this); |
98 IF_DEBUG(Print(_L("<<<CDpsOperator::ConstructL"))); |
94 OstTraceFunctionExit0( CDPSSTATEMACHINE_CONSTRUCTL_EXIT ); |
99 } |
95 } |
100 |
96 |
101 // --------------------------------------------------------------------------- |
97 // --------------------------------------------------------------------------- |
102 // |
98 // |
103 // --------------------------------------------------------------------------- |
99 // --------------------------------------------------------------------------- |
104 // |
100 // |
105 void CDpsStateMachine::StartTransactionL(TMDpsOperation* aRequest) |
101 void CDpsStateMachine::StartTransactionL(TMDpsOperation* aRequest) |
106 { |
102 { |
107 IF_DEBUG(Print(_L(">>>CDpsStateMachine::StartTransaction"))); |
103 OstTraceFunctionEntry0( CDPSSTATEMACHINE_STARTTRANSACTIONL_ENTRY ); |
108 iMOperation = aRequest; |
104 iMOperation = aRequest; |
109 iOperation = (TDpsOperation)iMOperation->iOperation; |
105 iOperation = (TDpsOperation)iMOperation->iOperation; |
110 iTrader->CreateRequestL(aRequest); |
106 iTrader->CreateRequestL(aRequest); |
111 iCurState = iSendingReqState; |
107 iCurState = iSendingReqState; |
112 IF_DEBUG(Print(_L("<<<CDpsStateMachine::StartTransaction"))); |
108 OstTraceFunctionExit0( CDPSSTATEMACHINE_STARTTRANSACTIONL_EXIT ); |
113 } |
109 } |
114 |
110 |
115 // --------------------------------------------------------------------------- |
111 // --------------------------------------------------------------------------- |
116 // |
112 // |
117 // --------------------------------------------------------------------------- |
113 // --------------------------------------------------------------------------- |
118 // |
114 // |
119 void CDpsStateMachine::Initialize() |
115 void CDpsStateMachine::Initialize() |
120 { |
116 { |
121 IF_DEBUG(Print(_L(">>>CDpsStateMachine::Initialize"))); |
117 OstTraceFunctionEntry0( CDPSSTATEMACHINE_INITIALIZE_ENTRY ); |
122 iOperation = EDpsOpEmpty; |
118 iOperation = EDpsOpEmpty; |
123 iEvent = EDpsEvtEmpty; |
119 iEvent = EDpsEvtEmpty; |
124 iCurError = KErrNone; |
120 iCurError = KErrNone; |
125 if (CurState() != IdleState()) |
121 if (CurState() != IdleState()) |
126 { |
122 { |
127 SetState(IdleState()); |
123 SetState(IdleState()); |
128 } |
124 } |
129 IF_DEBUG(Print(_L("<<<CDpsStateMachine::Initialize"))); |
125 OstTraceFunctionExit0( CDPSSTATEMACHINE_INITIALIZE_EXIT ); |
130 } |
126 } |