lbs/common/src/ctlbsstepconfighybridmodule.cpp
branchSymbian2
changeset 1 8758140453c0
child 6 c108117318cb
equal deleted inserted replaced
0:e8c1ea2c6496 1:8758140453c0
       
     1 // Copyright (c) 2007-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 the License "Symbian Foundation License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // This is the class implementation for the configuration of the AGPS Hybrid Module
       
    15 // The main purpose of this test step is to allow flexible configurability of the AGps Hybrid Module
       
    16 // from the Test Harness.
       
    17 // Various configuration options are read from the ini files and sent to the AGps Hybrid Module through the TH channel.
       
    18 // The AGps Hybrid Module always acknowledges each configuration message (see ProcessAGpsResponseMessage() method below).
       
    19 // This test step has been written to understand '.ini' files containing sections such as [Config2] below:
       
    20 // [Config2]
       
    21 // agps_module_update_file = c:\testdata\configs\lbs_molr.ini
       
    22 // agps_module_multi_updates_opt = on
       
    23 // agps_module_assistance_data_opt= on
       
    24 // $update,1,2,49.2,NAN,NAN,2,3*
       
    25 // $update,1,2,49.2,NAN,NAN,2,3*
       
    26 // $update,1,2,49.2,3.5,50,2,3*
       
    27 // => Current module possible options are:
       
    28 // agps_module_multi_updates_opt = [ on | off ]
       
    29 // It sets the module to send multiple updates after Target Time.
       
    30 // - When this mode is "off" only one update is sent just after 'Target time' (that is, the next update item available 
       
    31 // from the module's update array).
       
    32 // - When this mode is "on", the module sends N + 1 updates between 'Target time' and 'Max fix time'
       
    33 // (currently hardcoded -> N = 2).
       
    34 // The final update is the next update item available from the module's update array.
       
    35 // The module calculates the first N updates from the final update, these updates contain incomplete
       
    36 // positions (NAN longitude and latitude, ...). 
       
    37 // Note:'Target time' specifies the time when the location update should be provided by the AGPS module.
       
    38 // 'Max fix time' specifies the time maximum time the module should spend calculating the current location.
       
    39 // agps_module_assistance_data_opt = [ on | off ]
       
    40 // Only applicable when in Preferred Terminal Mode. 
       
    41 // - When this mode is "on", for each new location request the AGps Module may Request new Assistance Data
       
    42 // (if it has not been delivered already, sometimes assistance data is delivered to the module before it is requested).
       
    43 // - When this mode is off, the default RequestAssistanceData(EAssistanceDataNone) call will always be made.		
       
    44 // agps_module_dynamic_ass_data_opt = [ on | off ] (off by default)
       
    45 // Switches between different assistance data delivery methods:
       
    46 // -> OFF - On the first RequestAssistanceData requests the assistance data aDataMask is always set to
       
    47 // the assistance data that it needs.  However for all subsequent assistance data requests the
       
    48 // aDataMask will always be set to 0.  This is the method used in all the hybrid tests.
       
    49 // -> ON - Here the module will always request any assistance data that it has not yet received. So on
       
    50 // the first assistanceData request the aDataMask is set to the assistance data it requires.  On
       
    51 // subsequent assistance data requests it will re-request the assistance data that has not yet
       
    52 // been delivered.  This is the method that should be used in SUPL tests.
       
    53 // agps_module_clear_all_opt = [ on | off ]
       
    54 // Sets all the possible module options to on.
       
    55 // agps_module_set_all_opt = [ on | off ]
       
    56 // Sets all the possible module options to off.
       
    57 // => $update command: 
       
    58 // The $update entries in the ini files are used to populate the AGps Hybrid Module update array.
       
    59 // Note: The Module's update array contains the update items used to generate the updates sent to the AGps Manager.
       
    60 // The $update command syntax should be as follows:
       
    61 // $update,num_of_updates,[num_of_measurements],[latitude],[longitude],[altitude],[horz_accuracy],[vert_accuracy],[update_err]*
       
    62 // - where num_of_updates is the number of updates to add to the update array. For values greater than 1, each update
       
    63 // will contain the same data position and measurement data as defined by the reminder of the sentence.
       
    64 // - where num_of_measurements is the number of satellite measurements to define (see TPositionGpsMeasurementData). 
       
    65 // If this value is 0 no measurement data is defined and only the position data is defined. 
       
    66 // Values for the actual measurement data will be generated automatically.
       
    67 // - where latitude, longitude, altitude, horz_accuracy, vert_accuracy are used to define the values for the 
       
    68 // TPositionInfo part of the TPositionSatelliteInfo.
       
    69 // - where update_err, is the error code to return to the manager for the update. If NOT defined the value will be KErrNone.
       
    70 // => Possible Enhancements: This test step might be enhanced later on to also additional functionality such as:
       
    71 // agps_module_update_error = -1
       
    72 // agps_module_update_timeout = 5000000
       
    73 // agps_module_multi_updates_opt = 2	// where 2 is the number of multi updates sent before  
       
    74 // // the final update is sent prior to 'Max fix time'
       
    75 // 
       
    76 //
       
    77 
       
    78 
       
    79  
       
    80 #include "ctlbsstepconfighybridmodule.h"
       
    81 
       
    82 #include "tlbsutils.h"
       
    83 
       
    84 
       
    85 _LIT(KUpdateFile, "agps_module_update_file");
       
    86 _LIT(KClearAllOpt, "agps_module_clear_all_opt");
       
    87 _LIT(KAssistanceDataOpt, "agps_module_assistance_data_opt");
       
    88 _LIT(KMultiUpdateOpt, "agps_module_multi_updates_opt");
       
    89 _LIT(KReqAssDatReqOpt, "agps_module_req_ass_data_req_opt");
       
    90 _LIT(KSetAllOpt, "agps_module_set_all_opt");
       
    91 _LIT(KSuplAssDataOpt, "agps_module_dynamic_ass_data_opt");
       
    92 _LIT(KUpdateTimeout, "agps_module_update_timeout");
       
    93 _LIT(KOption_OFF, "off");
       
    94 _LIT(KOption_ON, "on");
       
    95 _LIT(KNoFileName, "");
       
    96 
       
    97 
       
    98 /**
       
    99  * Constructor
       
   100  */
       
   101 CT_LbsStep_ConfigHybridModule::CT_LbsStep_ConfigHybridModule(CT_LbsServer& aParent) : CT_LbsStep(aParent)
       
   102 	{
       
   103 	SetTestStepName(KLbsStep_ConfigHybridModule);
       
   104 	}
       
   105 
       
   106 
       
   107 /**
       
   108 Static Constructor
       
   109 */
       
   110 CT_LbsStep_ConfigHybridModule* CT_LbsStep_ConfigHybridModule::New(CT_LbsServer& aParent)
       
   111 	{
       
   112 	return new CT_LbsStep_ConfigHybridModule(aParent);
       
   113 	// Note the lack of ELeave.
       
   114 	// This means that having insufficient memory will return NULL;
       
   115 	}
       
   116 
       
   117 /**
       
   118  * @return - TVerdict code
       
   119  * Override of base class virtual
       
   120  */
       
   121 TVerdict CT_LbsStep_ConfigHybridModule::doTestStepPreambleL()
       
   122 	{
       
   123 	INFO_PRINTF1(_L("Test Preamble. CT_LbsStep_ConfigHybridModule"));
       
   124 
       
   125 	// create the test channel handler
       
   126 	iAGpsHandler = CT_LbsAGpsHandler::NewL(this);
       
   127 	
       
   128 	SetTestStepResult(EPass);
       
   129 	return TestStepResult();
       
   130 	}
       
   131 
       
   132 /**
       
   133  * @return - TVerdict code
       
   134  * Override of base class virtual
       
   135  */
       
   136 TVerdict CT_LbsStep_ConfigHybridModule::doTestStepPostambleL()
       
   137 	{
       
   138 	INFO_PRINTF1(_L("Test Postamble. CT_LbsStep_ConfigHybridModule"));
       
   139 
       
   140 	delete iAGpsHandler;
       
   141 	iAGpsHandler = NULL;
       
   142 		
       
   143 	return TestStepResult();
       
   144 	}
       
   145 	
       
   146 /**
       
   147  * @return - TVerdict code
       
   148  * Override of base class pure virtual
       
   149  * Our implementation only gets called if the base class doTestStepPreambleL() did
       
   150  * not leave. That being the case, the current test result value will be EPass.
       
   151  */
       
   152 TVerdict CT_LbsStep_ConfigHybridModule::doTestStepL()
       
   153 	{
       
   154 	INFO_PRINTF1(_L(">>CT_LbsStep_ConfigHybridModule::doTestStepL()")); // ??
       
   155 
       
   156 	if (TestStepResult() == EPass)
       
   157 		{
       
   158 		TPtrC configFileName;
       
   159 		GetStringFromConfig(ConfigSection(), KUpdateFile, configFileName);
       
   160 		if (configFileName != KNoFileName)
       
   161 			{
       
   162 			iConfigCtr++;
       
   163 			iAGpsHandler->SendRequestUpdateInitMsg(configFileName, ConfigSection());		
       
   164 			}
       
   165 						
       
   166 		TPtrC clearAllOpt;
       
   167 		GetStringFromConfig(ConfigSection(), KClearAllOpt, clearAllOpt);
       
   168 		if (clearAllOpt == KOption_ON)
       
   169 			{
       
   170 			iConfigCtr++;
       
   171 			iAGpsHandler->SendRequestClearAllModuleOptions();
       
   172 			}
       
   173 
       
   174 		TPtrC updateOpt;
       
   175 		GetStringFromConfig(ConfigSection(), KMultiUpdateOpt, updateOpt);
       
   176 		if (updateOpt == KOption_OFF)
       
   177 			{
       
   178 			iConfigCtr++;
       
   179 			iAGpsHandler->SendRequestModuleOption(ELbsHybridModuleOptions_MultiUpdatesOn, EFalse);
       
   180 			}
       
   181 		else if (updateOpt == KOption_ON)
       
   182 			{
       
   183 			iConfigCtr++;
       
   184 			iAGpsHandler->SendRequestModuleOption(ELbsHybridModuleOptions_MultiUpdatesOn, ETrue);
       
   185 			}
       
   186 			
       
   187 		TPtrC assDataOpt;
       
   188 		GetStringFromConfig(ConfigSection(), KAssistanceDataOpt, assDataOpt);
       
   189 		if (assDataOpt == KOption_OFF)
       
   190 			{
       
   191 			iConfigCtr++;
       
   192 			iAGpsHandler->SendRequestModuleOption(ELbsHybridModuleOptions_AssistanceDataOn, EFalse);
       
   193 			}
       
   194 		else if (assDataOpt == KOption_ON)
       
   195 			{
       
   196 			iConfigCtr++;
       
   197 			iAGpsHandler->SendRequestModuleOption(ELbsHybridModuleOptions_AssistanceDataOn, ETrue);
       
   198 			}
       
   199 
       
   200 
       
   201 		TPtrC reqAssDataOpt;
       
   202 		GetStringFromConfig(ConfigSection(), KReqAssDatReqOpt, reqAssDataOpt);
       
   203 		if (reqAssDataOpt == KOption_OFF)
       
   204 			{
       
   205 			iConfigCtr++;
       
   206 			iAGpsHandler->SendRequestModuleOption(ELbsHybridModuleOptions_DisableReqAssistData, EFalse);
       
   207 			}
       
   208 		else if (reqAssDataOpt == KOption_ON)
       
   209 			{
       
   210 			iConfigCtr++;
       
   211 			iAGpsHandler->SendRequestModuleOption(ELbsHybridModuleOptions_DisableReqAssistData, ETrue);
       
   212 			}
       
   213 		
       
   214 		
       
   215 		TPtrC suplAssDataOpt;
       
   216 		GetStringFromConfig(ConfigSection(), KSuplAssDataOpt, suplAssDataOpt);
       
   217 		if (suplAssDataOpt == KOption_OFF)
       
   218 			{
       
   219 			iConfigCtr++;
       
   220 			iAGpsHandler->SendRequestModuleOption(ELbsHybridModuleOptions_DynamicAssistanceData, EFalse);
       
   221 			}
       
   222 		else if (suplAssDataOpt == KOption_ON)
       
   223 			{
       
   224 			iConfigCtr++;
       
   225 			iAGpsHandler->SendRequestModuleOption(ELbsHybridModuleOptions_DynamicAssistanceData, ETrue);
       
   226 			}
       
   227 
       
   228 
       
   229 
       
   230 		TPtrC setAllOpt;
       
   231 		GetStringFromConfig(ConfigSection(), KSetAllOpt, setAllOpt);
       
   232 		if (setAllOpt == KOption_ON)
       
   233 			{
       
   234 			iConfigCtr++;
       
   235 			iAGpsHandler->SendRequestSetAllModuleOptions();
       
   236 			}
       
   237 		TInt updateTimeout;
       
   238 		if (GetIntFromConfig(ConfigSection(), KUpdateTimeout, updateTimeout))
       
   239 			{
       
   240 			TTimeIntervalMicroSeconds timeoutVal(updateTimeout);
       
   241 			
       
   242 			iConfigCtr++;
       
   243 			iAGpsHandler->SendRequestTimeOutMsg(timeoutVal); 
       
   244 			}		
       
   245 
       
   246 		// All the configuration requests sent, now start the active scheduler
       
   247 		if (iConfigCtr)
       
   248 			{
       
   249 			CActiveScheduler::Start();
       
   250 			}
       
   251 		}
       
   252 	
       
   253 	
       
   254 	INFO_PRINTF1(_L("<<CT_LbsStep_ConfigHybridModule::doTestStepL()"));	//??
       
   255 
       
   256 	return TestStepResult();
       
   257 	}
       
   258 
       
   259 
       
   260 void CT_LbsStep_ConfigHybridModule::ProcessAGpsResponseMessage(const TT_LbsAGpsResponseMsg::TModuleResponseType aResponse)
       
   261 	{
       
   262 	iConfigCtr--;
       
   263 
       
   264 	if (TT_LbsAGpsResponseMsg::EModuleResponseOk == aResponse)
       
   265 		{
       
   266 		// If any of the previous responses has failed do not override the verdict
       
   267 		if (iVerdict != EFail)
       
   268 			{
       
   269 			iVerdict = EPass;
       
   270 			}
       
   271 		}
       
   272 	else
       
   273 		{
       
   274 		iVerdict = EFail;
       
   275 		}
       
   276 	
       
   277 	if (!iConfigCtr)
       
   278 		{
       
   279 		SetTestStepResult(iVerdict);
       
   280 		CActiveScheduler::Stop();
       
   281 		}
       
   282 	}