usbmgmt/usbmgrtest/t_charging_emu/inc/tbatterycharging.h
changeset 0 c9bc50fca66e
child 15 f92a4f87e424
equal deleted inserted replaced
-1:000000000000 0:c9bc50fca66e
       
     1 /**
       
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 * Usb Battery Charging test code
       
    16 * 
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 #ifndef __CDUMMYUSBDEVICE_H__
       
    23 #define __CDUMMYUSBDEVICE_H__
       
    24 
       
    25 #include <usb/chargingtest/cusbbatterychargingtestplugin.h>
       
    26 #include <usbstates.h>
       
    27 #include <ecom/ecom.h>
       
    28 #include <e32std.h>
       
    29 #include "musbmanextensionpluginobserver.h"
       
    30 #include "cusbmanextensionplugin.h"
       
    31 #include <e32test.h>
       
    32 #include <e32property.h> //Publish & Subscribe header
       
    33 
       
    34 class MUsbDeviceNotify;
       
    35 
       
    36 _LIT(KUsbChargingTestPanic, "UsbChargingTestPanic");
       
    37 enum TUsbChargingTestPanic
       
    38 	{
       
    39 	EUsbChargingTestPanicIncorrectPlugin = 0,
       
    40 	EUsbChargingTestPanicBadInputData	 = 1,
       
    41 	EUsbChargingTestPanicBadCommand		 = 2,
       
    42 	EUsbChargingTestPanicBadAsyncOp		 = 3,
       
    43 	EUsbChargingTestPanicBadCheck		 = 4,
       
    44 	};
       
    45 
       
    46 enum TUsbChargingTestCommand
       
    47 	{
       
    48 	EUsbChargingTestCommandNone		    = 0, // "none"
       
    49 	EUsbChargingTestCommandDeviceState  = 1, // "devicestate"
       
    50 	EUsbChargingTestCommandUserSetting  = 2, // "usersetting"
       
    51 	};
       
    52 
       
    53 enum TUsbChargingTestCheck
       
    54 	{
       
    55 	EUsbChargingTestCheckNone			= 0, // "none"
       
    56 	EUsbChargingTestCheckPluginState	= 1, // "pluginstate"
       
    57 	EUsbChargingTestCheckMilliAmps		= 2, // "milliamps" - requested current
       
    58 	EUsbChargingTestCheckCharging		= 3, // "charging" - available current
       
    59 	};
       
    60 
       
    61 enum TUsbChargingTestAsyncOp
       
    62 	{
       
    63 	EUsbChargingTestAsyncOpNone			= 0, // "none"
       
    64 	EUsbChargingTestAsyncOpDelay		= 1, // "delay" - microseconds
       
    65 	};
       
    66 
       
    67 class CDummyUsbDevice : public CActive, public MUsbmanExtensionPluginObserver
       
    68 	{
       
    69 public:
       
    70 	static CDummyUsbDevice* NewL();
       
    71 	virtual ~CDummyUsbDevice();
       
    72 
       
    73 	void RegisterObserverL(MUsbDeviceNotify& aObserver);
       
    74 	void DeRegisterObserver(MUsbDeviceNotify& aObserver);
       
    75 	
       
    76 	void DefinePropertyL(const TInt32 aCategory, TUint aKey,RProperty::TType eType);
       
    77 	TInt GetChargingCurrentFromProperty(TInt &aCurrent);
       
    78 	TInt WriteToRepositoryProperty(TInt iCommandValue);
       
    79 	
       
    80 	TInt StartPropertyBatteryCharging();
       
    81 
       
    82 	void DoTestsL();
       
    83 
       
    84 public: // From CActive
       
    85 	void RunL();
       
    86 	void DoCancel();
       
    87 	TInt RunError(TInt aError);
       
    88 
       
    89 protected:
       
    90 	CDummyUsbDevice();
       
    91 	void ConstructL();
       
    92 
       
    93 private:
       
    94 	void InstantiateExtensionPluginsL();
       
    95 	void UpdatePluginInfo();
       
    96 	void OpenFileL();
       
    97 	TInt GetNextLine();
       
    98 	void InterpretLine();
       
    99 	TInt GetCommand(const TDesC8& aDes);
       
   100 	TInt GetAsyncOp(const TDesC8& aDes);
       
   101 	TInt GetCheck(const TDesC8& aDes);
       
   102 	void DoCommand();
       
   103 	void DoAsyncOp();
       
   104 	void DoCheck();
       
   105 
       
   106 private: // from MUsbmanExtensionPluginObserver
       
   107 	RDevUsbcClient& MuepoDoDevUsbcClient();
       
   108 	void MuepoDoRegisterStateObserverL(MUsbDeviceNotify& aObserver);
       
   109 
       
   110 private:
       
   111 	RPointerArray<MUsbDeviceNotify> iObservers;
       
   112 	RPointerArray<CUsbmanExtensionPlugin> iExtensionPlugins;
       
   113 	// we know there'll only be one plugin, so keep a single pointer to it...
       
   114 	CUsbmanExtensionPlugin* iPlugin;
       
   115 	TUsbDeviceState  iDeviceState;
       
   116 	RDevUsbcClient iDummyLdd;
       
   117 	REComSession* iEcom;	//	Not to be deleted, only closed!
       
   118 
       
   119 	TPluginTestInfo iInfo;
       
   120 
       
   121 	RTest iTest;
       
   122 	RTimer iTimer;
       
   123 	//CRepository* iRepository;
       
   124 
       
   125 	TPtr8 iPtr; // data file
       
   126 	TPtr8 iLine; // current line
       
   127 	TInt  iLineNumber;
       
   128 	TInt iFileOffset;
       
   129 	TText8* iText;
       
   130 
       
   131 	TInt	iCommand;
       
   132 	TInt					iCommandValue;
       
   133 	TInt	iAsyncOp;
       
   134 	TInt					iAsyncOpValue;
       
   135 	TInt	iCheck;
       
   136 	TInt					iCheckValue;
       
   137 	
       
   138 	RProperty iPropertyWriteToRepositoryAck;
       
   139 	RProperty iPropertyReadChargingCurrentAck;
       
   140 	RProperty iProperty;
       
   141 	};
       
   142 
       
   143 #endif // __CDUMMYUSBDEVICE_H__
       
   144