serialserver/packetloopbackcsy/inc/LoopbackConfig.h
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 2004-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 // LoopbackConfig.cpp
       
    15 // This file handles retrieving settings from the config file for the loopback test driver
       
    16 // 
       
    17 //
       
    18 
       
    19 /**
       
    20  @file
       
    21 */
       
    22 
       
    23 #ifndef __LOOPBACK_CONFIG_H__
       
    24 #define __LOOPBACK_CONFIG_H__
       
    25 
       
    26 #include <e32def.h>
       
    27 
       
    28 #include <testconfigfileparser.h>
       
    29 
       
    30 #include "FlowControlChange.h"
       
    31 
       
    32 const TUint KDefaultDelay = 100;	// in milliseconds
       
    33 const TUint KDefaultPacketLength = 1024;
       
    34 const TUint KDefaultQueueLength = 30;
       
    35 const TUint KDefaultBufferSize = 10000;
       
    36 
       
    37 enum TPortType
       
    38 	{
       
    39 	EPacketLoopbackPortType,
       
    40 	ESerialLoopbackPortType
       
    41 	};
       
    42 
       
    43 class TLoopbackConfigItem
       
    44 /**
       
    45  Each of the elements in this file match to a port entry in the loopback.ini file
       
    46  */
       
    47  	{
       
    48 public:
       
    49 	/** The port connected to iPortB via loopback connection */
       
    50 	TUint iPortA;
       
    51 	/** The port connected to iPortA via loopback connection */
       
    52 	TUint iPortB;
       
    53 	/** The delay, in milliseconds for each write for these 2 ports */
       
    54 	TUint iDelay;
       
    55 	/** packet length gives the size of the buffer to be allocated for each read and write */
       
    56  	TUint iPacketLength;
       
    57  	/** The number of entries in the Read and Write queues */
       
    58 	TUint iQueueLength;
       
    59 	/** The total buffer size (in bytes) for serial mode */
       
    60 	TUint iBufferSize;
       
    61 	/** Default values for a loopback config item */
       
    62 	TLoopbackConfigItem()
       
    63 		{
       
    64 		iPortA = 0;
       
    65 		iPortB = 1;
       
    66 		iDelay = KDefaultDelay;
       
    67 		iPacketLength = KDefaultPacketLength;
       
    68 		iQueueLength = KDefaultQueueLength;
       
    69 		iBufferSize = KDefaultBufferSize;
       
    70 		}
       
    71 	};
       
    72 	
       
    73 NONSHARABLE_CLASS(CLoopbackConfig) : CBase
       
    74 /**
       
    75  * This class is used to get settings from the loopback.ini file
       
    76  */
       
    77 	{
       
    78 public:
       
    79 	~CLoopbackConfig();
       
    80 	static CLoopbackConfig* NewL();
       
    81 	TUint Count() const;
       
    82 	TInt GetPortSettings(TUint aUnit, TLoopbackConfigItem& aPortSettings) const;
       
    83 	static TInt GetTestNumber(TInt& aTestNumber);
       
    84 	static TInt GetFlowControl(TBool& aFlowControlOn);
       
    85 	TPortType PortType() const;
       
    86 private:
       
    87 	CLoopbackConfig();
       
    88 	void ConstructL();
       
    89 	
       
    90 	/** Array of all of the items in the loopback config file */
       
    91 	CArrayFixFlat<TLoopbackConfigItem> *iConfigItems;
       
    92 	/** The port type (either packet or serial) */
       
    93 	TPortType iPortType;
       
    94 	};
       
    95 
       
    96 _LIT(KLoopbackConfigFilename,"c:\\loopback.ini");
       
    97 _LIT(KConfigFileDir,"loopback");
       
    98 _LIT8(KSectionNameFormat,"test%d");
       
    99 _LIT8(KPort,"Port");
       
   100 _LIT8(KSerialLoopbackPortType, "SerialLoopbackPort");
       
   101 _LIT8(KPacketLoopbackPortType, "PacketLoopbackPort");
       
   102 const TUint KMaxPortTypeNameLength = 64;
       
   103 
       
   104 
       
   105 // Loopback CSY UIDs
       
   106 
       
   107 static const TUid KUidLoopbackCSYMin = {0x10206864};
       
   108 static const TUid KUidLoopbackCSYMax = {0x1020686F};
       
   109 
       
   110 static const TUid KUidLoopbackCsyDll = {0x10206864}; // KUidLoopbackCSYMin
       
   111 static const TUid KUidTestLoopbackCsyDll = {0x10206865}; // KUidLoopbackCSYMin + 1
       
   112 static const TUid KUidPSPacketLoopbackCsyCategory = {0x10206866}; // KUidLoopbackCSYMin + 2
       
   113 static const TUid KUidPSCsyFlowControlCategory = {0x10206867}; // KUidLoopbackCSYMin + 3
       
   114 static const TUid KUidPSCsyReadResultCategory = {0x10206868}; // KUidLoopbackCSYMin + 4
       
   115 static const TUid KUidPSCsyWriteResultCategory = {0x10206869}; //KUidLoopbackCSYMin + 5
       
   116 
       
   117 // KUidPSPacketLoopbackCsyCategory constants
       
   118 const TInt KPSLoopbackCsyTestNumber = 0;
       
   119 const RProperty::TType KPSLoopbackCsyTestNumberKeyType = RProperty::EInt;
       
   120 
       
   121 // KUidPSCsyFlowControlCategory constants
       
   122 const RProperty::TType KPSLoopbackCsyFlowControlOnKeyType = RProperty::EInt;
       
   123 
       
   124 // KUidPSCsyReadResultCategory constants
       
   125 const RProperty::TType KUidPSCsyReadResultCategoryKeyType = RProperty::EInt;
       
   126 
       
   127 // KUidPSCsyWriteResultCategory constants
       
   128 const RProperty::TType KUidPSCsyWriteResultCategoryKeyType = RProperty::EInt;
       
   129 
       
   130 #endif
       
   131