genericopenlibs/posixrealtimeextensions/test/testtimer/src/ttimerserver.cpp
changeset 0 e4d67989cc36
child 48 ab61c4cedc64
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "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 // Name        : ttimerserver.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <c32comm.h>
       
    19 
       
    20 #if defined (__WINS__)
       
    21 #define PDD_NAME		_L("ECDRV")
       
    22 #else
       
    23 #define PDD_NAME		_L("EUART1")
       
    24 #define PDD2_NAME		_L("EUART2")
       
    25 #define PDD3_NAME		_L("EUART3")
       
    26 #define PDD4_NAME		_L("EUART4")
       
    27 #endif
       
    28 
       
    29 #define LDD_NAME		_L("ECOMM")
       
    30 
       
    31 /**
       
    32  * @file
       
    33  *
       
    34  * Pipe test server implementation
       
    35  */
       
    36 #include "ttimerserver.h"
       
    37 #include "ttimer.h"
       
    38 
       
    39 
       
    40 _LIT(KServerName, "ttimer");
       
    41 
       
    42 CTimerTestServer* CTimerTestServer::NewL()
       
    43 	{
       
    44 	CTimerTestServer *server = new(ELeave) CTimerTestServer();
       
    45 	CleanupStack::PushL(server);
       
    46 	server->ConstructL(KServerName);
       
    47 	CleanupStack::Pop(server);
       
    48 	return server;
       
    49 	}
       
    50 
       
    51 static void InitCommsL()
       
    52     {
       
    53     TInt ret = User::LoadPhysicalDevice(PDD_NAME);
       
    54     User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
       
    55 
       
    56 #ifndef __WINS__
       
    57     ret = User::LoadPhysicalDevice(PDD2_NAME);
       
    58     ret = User::LoadPhysicalDevice(PDD3_NAME);
       
    59     ret = User::LoadPhysicalDevice(PDD4_NAME);
       
    60 #endif
       
    61 
       
    62     ret = User::LoadLogicalDevice(LDD_NAME);
       
    63     User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
       
    64     ret = StartC32();
       
    65     User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret);
       
    66     }
       
    67 
       
    68 LOCAL_C void MainL()
       
    69 	{
       
    70 	// Leave the hooks in for platform security
       
    71 #if (defined __DATA_CAGING__)
       
    72 	RProcess().DataCaging(RProcess::EDataCagingOn);
       
    73 	RProcess().SecureApi(RProcess::ESecureApiOn);
       
    74 #endif
       
    75 	InitCommsL();
       
    76 	
       
    77 	CActiveScheduler* sched=NULL;
       
    78 	sched=new(ELeave) CActiveScheduler;
       
    79 	CActiveScheduler::Install(sched);
       
    80 	CTimerTestServer* server = NULL;
       
    81 	// Create the CTestServer derived server
       
    82 	TRAPD(err, server = CTimerTestServer::NewL());
       
    83 	if(!err)
       
    84 		{
       
    85 		// Sync with the client and enter the active scheduler
       
    86 		RProcess::Rendezvous(KErrNone);
       
    87 		sched->Start();
       
    88 		}
       
    89 	delete server;
       
    90 	delete sched;
       
    91 	}
       
    92 
       
    93 /**
       
    94  * Server entry point
       
    95  * @return Standard Epoc error code on exit
       
    96  */
       
    97 TInt main()
       
    98 	{
       
    99 	__UHEAP_MARK;
       
   100 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
   101 	if(cleanup == NULL) 
       
   102 		{
       
   103 		return KErrNoMemory;  
       
   104 		}
       
   105 	TRAP_IGNORE(MainL());
       
   106 	delete cleanup;
       
   107 	__UHEAP_MARKEND;
       
   108 	
       
   109 	return KErrNone;
       
   110 	}
       
   111 
       
   112 CTestStep* CTimerTestServer::CreateTestStep(const TDesC& aStepName)
       
   113 	{
       
   114 	CTestStep* testStep = NULL;
       
   115 
       
   116 	if(aStepName == KTesttimerapi1)
       
   117 		{
       
   118 			testStep = new CTesttimer(aStepName);
       
   119 		}
       
   120 	if(aStepName == KTesttimerapi2)
       
   121 		{
       
   122 			testStep = new CTesttimer(aStepName);
       
   123 		}
       
   124 	if(aStepName == KTesttimerapi3)
       
   125 		{
       
   126 			testStep = new CTesttimer(aStepName);
       
   127 		}
       
   128 	if(aStepName == KTesttimerapi4)
       
   129 		{
       
   130 			testStep = new CTesttimer(aStepName);
       
   131 		}
       
   132 	if(aStepName == KTesttimerapi5)
       
   133 		{
       
   134 			testStep = new CTesttimer(aStepName);
       
   135 		}
       
   136 	if(aStepName == KTesttimerapi6)
       
   137 		{
       
   138 			testStep = new CTesttimer(aStepName);
       
   139 		}
       
   140 	if(aStepName == KTesttimerapi7)
       
   141 		{
       
   142 			testStep = new CTesttimer(aStepName);
       
   143 		}
       
   144 	if(aStepName == KTesttimerapi8)
       
   145 		{
       
   146 			testStep = new CTesttimer(aStepName);
       
   147 		}
       
   148 	if(aStepName == KTesttimerapi9)
       
   149 		{
       
   150 			testStep = new CTesttimer(aStepName);
       
   151 		}
       
   152 	if(aStepName == KTesttimerapi10)
       
   153 		{
       
   154 			testStep = new CTesttimer(aStepName);
       
   155 		}
       
   156 	if(aStepName == KTesttimerapi11)
       
   157 		{
       
   158 			testStep = new CTesttimer(aStepName);
       
   159 		}
       
   160 	if(aStepName == KTesttimerapi12)
       
   161 		{
       
   162 			testStep = new CTesttimer(aStepName);
       
   163 		}
       
   164 	if(aStepName == KTesttimerapi13)
       
   165 		{
       
   166 			testStep = new CTesttimer(aStepName);
       
   167 		}
       
   168 	if(aStepName == KTesttimerapi14)
       
   169 		{
       
   170 			testStep = new CTesttimer(aStepName);
       
   171 		}
       
   172 	if(aStepName == KTesttimerapi15)
       
   173 		{
       
   174 			testStep = new CTesttimer(aStepName);
       
   175 		}
       
   176 	if(aStepName == KTesttimerapi16)
       
   177 		{
       
   178 			testStep = new CTesttimer(aStepName);
       
   179 		}
       
   180 	if(aStepName == KTesttimerapi17)
       
   181 		{
       
   182 			testStep = new CTesttimer(aStepName);
       
   183 		}
       
   184 	if(aStepName == KTesttimerapi18)
       
   185 		{
       
   186 			testStep = new CTesttimer(aStepName);
       
   187 		}
       
   188 	if(aStepName == KTesttimerapi19)
       
   189 		{
       
   190 			testStep = new CTesttimer(aStepName);
       
   191 		}
       
   192 	if(aStepName == KTesttimerapi20)
       
   193 		{
       
   194 			testStep = new CTesttimer(aStepName);
       
   195 		}
       
   196 	if(aStepName == KTesttimerapi21)
       
   197 		{
       
   198 			testStep = new CTesttimer(aStepName);
       
   199 		}
       
   200 	if(aStepName == KTesttimerapi22)
       
   201 		{
       
   202 			testStep = new CTesttimer(aStepName);
       
   203 		}
       
   204 	if(aStepName == KTesttimerapi23)
       
   205 		{
       
   206 			testStep = new CTesttimer(aStepName);
       
   207 		}
       
   208 	if(aStepName == KTesttimerapi24)
       
   209 		{
       
   210 			testStep = new CTesttimer(aStepName);
       
   211 		}
       
   212 	if(aStepName == KTesttimerapi25)
       
   213 		{
       
   214 			testStep = new CTesttimer(aStepName);
       
   215 		}
       
   216 	if(aStepName == KTesttimerapi26)
       
   217 		{
       
   218 			testStep = new CTesttimer(aStepName);
       
   219 		}
       
   220 	if(aStepName == KTesttimerapi27)
       
   221 		{
       
   222 			testStep = new CTesttimer(aStepName);
       
   223 		}
       
   224 	if(aStepName == KTesttimerapi28)
       
   225         {
       
   226             testStep = new CTesttimer(aStepName);
       
   227         }
       
   228 	return testStep;
       
   229 	 }
       
   230