00001 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). 00002 // All rights reserved. 00003 // This component and the accompanying materials are made available 00004 // under the terms of "Eclipse Public License v1.0" 00005 // which accompanies this distribution, and is available 00006 // at the URL "http://www.eclipse.org/legal/epl-v10.html". 00007 // 00008 // Initial Contributors: 00009 // Nokia Corporation - initial contribution. 00010 // 00011 // Contributors: 00012 // 00013 // Description: 00014 // The following class opens the InverterOutQ message Queue and displays 00015 // recieved data in console. 00016 // 00017 00018 00019 00025 #include "CMsgQActive.h" 00026 #include "e32cons.h" 00027 00028 _LIT(KCommonFormat2,"%S"); 00029 _LIT(KTitle , "OutputMessage"); 00030 00034 CMsgQActive::CMsgQActive(TInt aPriority):CActive(aPriority) 00035 { 00036 CActiveScheduler::Add( this ); 00037 } 00038 00039 00040 CMsgQActive* CMsgQActive::NewL(TInt aPriority) 00041 { 00042 CMsgQActive* self=new(ELeave)CMsgQActive(aPriority); 00043 CleanupStack::PushL(self); 00044 self->ConstructL(); 00045 CleanupStack::Pop(self); 00046 return self; 00047 } 00048 00052 void CMsgQActive::ConstructL() 00053 { 00054 iConsole = Console::NewL(KTitle, TSize(KConsFullScreen, KConsFullScreen)); 00055 _LIT(KWelcomeScreen,".......Words recieved from the inverter......\n"); 00056 iConsole->Printf(KWelcomeScreen); 00057 00058 //Open the InverterOutQ Message Queue. 00059 _LIT(KGlobalInverterOutQ, "InverterOutQ"); 00060 User::LeaveIfError(iInverterOutQ.OpenGlobal(KGlobalInverterOutQ)); 00061 } 00062 00067 void CMsgQActive::StartRecieving() 00068 { 00069 iInverterOutQ.NotifyDataAvailable(iStatus); 00070 SetActive(); 00071 } 00072 00073 CMsgQActive::~CMsgQActive() 00074 { 00075 } 00076 00080 void CMsgQActive::DoCancel() 00081 { 00082 //Cancel any data which is present in the message Queue. 00083 iInverterOutQ.CancelDataAvailable(); 00084 delete iConsole; 00085 } 00086 00091 void CMsgQActive::RunL() 00092 { 00093 // Recieve all available messages from the message queue. 00094 iInverterOutQ.ReceiveBlocking(imsgQData); 00095 00096 //Print the recieved message in the output message console. 00097 iConsole->Printf(KCommonFormat2,&imsgQData); 00098 00099 _LIT(KNextLine , "\n"); 00100 iConsole->Printf(KNextLine); 00101 00102 // Make asynchronous request to be notified when data is available 00103 iInverterOutQ.NotifyDataAvailable(iStatus); 00104 SetActive(); 00105 }
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.