blob: 842a22a21e5d15197b82b0cb0999e46e317a90f4 [file] [log] [blame]
///////////////////////////////////////////////////////////////////////////////
// //
// Copyright (c) 2000-2019 Ericsson Telecom AB //
// //
// All rights reserved. This program and the accompanying materials //
// are made available under the terms of the Eclipse Public License v2.0 //
// which accompanies this distribution, and is available at //
// https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html //
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// Module: EPTF_CLL_ExecCtrlClient_Functions
//
// Purpose:
// This module contains the implementation of EPTF_CLL_ExecCtrlClient functions.
//
// Module depends on:
// <EPTF_CLL_Common_Definitions>
// <EPTF_CLL_Base_Functions>
// <EPTF_CLL_LGenBase_Definitions>
// <EPTF_CLL_LGenBase_ConfigDefinitions>
// <EPTF_CLL_LGenBase_Functions>
// <EPTF_CLL_LGenBase_ConfigFunctions>
// <EPTF_CLL_LGenBase_TrafficFunctions>
// <EPTF_CLL_LGenBase_PhaseDefinitions>
// <EPTF_CLL_LGenBase_PhaseConfigFunctions>
// <EPTF_CLL_LGenBaseStats_Definitions>
// <EPTF_CLL_LGenBaseStats_Functions>
// <EPTF_CLL_LGenBase_EventHandlingFunctions>
// <EPTF_CLL_StatHandlerClient_Functions>
// <EPTF_CLL_StatHandlerClient_Definitions>
// <EPTF_CLL_Variable_Definitions>
// <EPTF_CLL_Variable_Functions>
// <EPTF_CLL_Logging_Definitions>
// <EPTF_CLL_Logging_Functions>
// <EPTF_CLL_ExecCtrl_Definitions>
// <EPTF_CLL_ExecCtrl_PhaseFunctions>
// <EPTF_CLL_ExecCtrl_LoggingFunctions>
// <EPTF_CLL_ExecCtrl_ScenarioDefinitions>
// <EPTF_CLL_ExecCtrlTimeProfile_Definitions>
// <EPTF_CLL_ExecCtrl_PhaseDefinitions>
// <EPTF_CLL_HashMapStr2Int_Functions>
// <EPTF_CLL_HashMap_Functions>
//
// Module Parameters:
// tsp_debug_EPTF_ExecCtrlClient_Functions - boolean
//
// Current Owner:
// Jozsef Gyurusi (ETHJGI)
//
// Last Review Date:
// 2009-02-03
//
// Detailed Comments:
// This module contains the interface functions for the EPTF_CLL_ExecCtrlClient.
//
// Public functions:
// <f_EPTF_ExecCtrlClient_init_CT>
// <f_EPTF_ExecCtrlClient_loadConfig>
// <f_EPTF_ExecCtrlClient_set_scenarioInitialized_fcb>
// <f_EPTF_ExecCtrlClient_registerEndOfConfigCallback>
// <f_EPTF_ExecCtrlClient_registerGuiDoneCallback>
// <f_EPTF_ExecCtrlClient_checkGuiDone>
// <f_EPTF_ExecCtrlClient_checkGuiDoneReported>
// <f_EPTF_ExecCtrlClient_reportGUIDone>
// <f_EPTF_ExecCtrlClient_readyToStart>
// <f_EPTF_ExecCtrlClient_checkEndOfConfig>
// <f_EPTF_ExecCtrlClient_getFirstEntityGlobalOffset>
// <f_EPTF_ExecCtrlClient_getEntityGroupGlobalOffset>
// <f_EPTF_ExecCtrlClient_getFirstEntityOffsetInEGrp>
// <f_EPTF_ExecCtrlClient_getEntityGroupSize>
// <f_EPTF_ExecCtrlClient_registerFinalTestReportGeneratorFn>
// <f_EPTF_ExecCtrlClient_deregisterFinalTestReportGeneratorFn>
//
// All other functions in this module are private!
//
///////////////////////////////////////////////////////////////
module EPTF_CLL_ExecCtrlClient_Functions {
import from EPTF_CLL_ExecCtrl_Definitions all;
import from EPTF_CLL_ExecCtrl_LoggingFunctions all;
import from EPTF_CLL_ExecCtrl_PhaseFunctions all;
import from EPTF_CLL_ExecCtrl_ScenarioDefinitions all;
import from EPTF_CLL_ExecCtrlTimeProfile_Definitions all;
import from EPTF_CLL_ExecCtrl_PhaseDefinitions all;
import from EPTF_CLL_ExecCtrl_ScenarioFunctions all;
import from EPTF_CLL_ExecCtrl_Functions all;
import from EPTF_CLL_LGenBase_Definitions all;
import from EPTF_CLL_LGenBase_Functions all;
import from EPTF_CLL_LGenBase_ConfigDefinitions all;
import from EPTF_CLL_LGenBase_TrafficFunctions all;
import from EPTF_CLL_LGenBase_ConfigFunctions all;
import from EPTF_CLL_LGenBaseStats_Definitions all;
import from EPTF_CLL_LGenBaseStats_Functions all;
import from EPTF_CLL_LGenBase_PhaseDefinitions all;
import from EPTF_CLL_LGenBase_PhaseConfigFunctions all;
import from EPTF_CLL_LGenBase_EventHandlingFunctions all;
import from EPTF_CLL_Variable_Definitions all;
import from EPTF_CLL_Variable_Functions all;
import from EPTF_CLL_Base_Functions all;
import from EPTF_CLL_Logging_Definitions all;
import from EPTF_CLL_Logging_Functions all;
import from EPTF_CLL_Common_Definitions all;
import from EPTF_CLL_HashMapStr2Int_Functions all;
import from EPTF_CLL_HashMap_Functions all;
modulepar boolean tsp_debug_EPTF_ExecCtrlClient_Functions := false;
modulepar boolean tsp_EPTF_ExecCtrlClient_terminateIfExecCtrlTerminates := true;
friend module EPTF_CLL_ExecCtrlUIHandler_Functions;
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrlClient_init_CT
//
// Purpose:
// Init EPTF_ExecCtrlClient feature
//
// Parameters:
// - pl_selfName - *in charstring* - the name of the component
// - pl_execCtrlCompRef - *in* <EPTF_ExecCtrl_CT> - the component reference of EPTF_ExecCtrl component
// - pl_reportReady - *in boolean* - if true: the client automatically sends "I am ready to start" message to the ExecCtrl
// default: true. To send "I am ready to start" manually (false setting), call <f_EPTF_ExecCtrlClient_readyToStart>
// - pl_reportGUIDone - *in boolean* - if true, GUIDone is reported automatically to ExecCtrl when the ExecCtrl client GUI is ready
// To report GUIDone at custom time, set this parameter to false and call <f_EPTF_ExecCtrlClient_reportGUIDone> later
//
// Return Value:
// -
//
// Errors & assertions:
//
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrlClient_init_CT(in charstring pl_selfName, in EPTF_ExecCtrl_CT pl_execCtrlCompRef,
in boolean pl_reportReady := true,
in boolean pl_reportGUIDone := true
) runs on EPTF_ExecCtrlClient_CT {
// f_EPTF_ExecCtrlClient_debug(%definitionId&": started...");
if (v_ExecCtrlClient_initialized) {
return;
}
f_EPTF_HashMap_init_CT (pl_selfName);
f_EPTF_Logging_init_CT(pl_selfName);
v_ExecCtrlClient_loggingMaskId := f_EPTF_Logging_registerComponentMasks(
tsp_EPTF_ExecCtrlClient_loggingComponentMask,
c_EPTF_ExecCtrl_loggingEventClasses,
EPTF_Logging_CLL);
if(tsp_debug_EPTF_ExecCtrlClient_Functions) {
f_EPTF_Logging_enableLocalMask(v_ExecCtrlClient_loggingMaskId, c_EPTF_ExecCtrl_loggingClassIdx_Debug);
} else {
f_EPTF_Logging_disableLocalMask(v_ExecCtrlClient_loggingMaskId, c_EPTF_ExecCtrl_loggingClassIdx_Debug);
}
vl_EPTF_ExecCtrlClient_def := activate(as_EPTF_ExecCtrlClient_MgmtIf());
f_EPTF_Base_assert(%definitionId&": LGenBase should be initialized before ExecCtrlClient", f_EPTF_LGenBase_initialized() or not pl_reportReady);
v_ExecCtrl_execCtrlMasterCompRef := pl_execCtrlCompRef;
f_EPTF_LGenBase_init(pl_selfName, 0, "");
f_EPTF_LGenBaseStats_init(pl_selfName,"");
// add listener to detect test finished:
if (-1!=f_EPTF_LGenBase_addGeneralEventListener(
c_EPTF_LGenBase_bIdx,
c_EPTF_LGenBase_inputIdx_testMgmt_testFinished,
refers(f_EPTF_ExecCtrlClient_testFinishedListener), {}
)) {}
f_EPTF_ExecCtrlClient_debug(%definitionId&": fill resource DB...");
// f_EPTF_ExecCtrlClient_fillResourceDB(); obsolated
f_EPTF_ExecCtrlClient_debug(%definitionId&": connecting to ExecCtrl...");
connect(self:ExecCtrlClient_MgmtIf_CP, v_ExecCtrl_execCtrlMasterCompRef:ExecCtrl_MgmtIf_CP);
f_EPTF_ExecCtrlClient_debug(%definitionId&": sending initial resource availability msg to ExecCtrl");
v_ExecCtrlClient_semaphore_DeclareScenario := 0;
v_ExecCtrlClient_semaphore_EndOfConfig := false;
t_EPTF_ExecCtrlClient_semaphoreTimer.start(0.0);
v_EPTF_ExecCtrlClient_guiPresent := false;
v_EPTF_ExecCtrlClient_guiDone := false;
v_EPTF_ExecCtrlClient_autoReportGuiDone := pl_reportGUIDone;
v_EPTF_ExecCtrlClient_guiDoneReported := false;
f_EPTF_ExecCtrlClient_initEGrpDB();
// replace with my groupFinishedFn:
//v_ExecCtrlClient_LGenBase_groupFinishedFn := v_LGenBase_groupFinishedFn;
v_ExecCtrlClient_LGenBase_groupFinishedDetectedFn :=
f_EPTF_LGenBase_setGroupFinishedDetectedFn(refers(f_EPTF_ExecCtrlClient_groupFinishedDetectedFn))
v_ExecCtrlClient_abortNextGroupFinish := true;
v_ExecCtrlClient_pauseDataForTCs := {};
f_EPTF_ExecCtrlClient_registerEndOfConfigCallback(refers(f_EPTF_ExecCtrlClient_registerFSMStats));
f_EPTF_LGenBase_registerTcStateChangedCallback(refers(f_EPTF_ExecCtrlClient_tcStateChanged_handlePaused));
f_EPTF_Base_registerCleanup(refers(f_EPTF_ExecCtrlClient_cleanup_CT));
v_ExecCtrlClient_started := false;
v_ExecCtrlClient_byeAckReceived := false;
v_ExecCtrlClient_byeReceived := false;
v_ExecCtrlClient_initialized := true;
// Client is ready:
if (pl_reportReady) {
f_EPTF_ExecCtrlClient_readyToStart();
}
f_EPTF_ExecCtrlClient_debug(%definitionId&": finished");
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrlClient_cleanup_CT
//
// Purpose:
// Cleanup EPTF_ExecCtrlClient feature
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrlClient_cleanup_CT() runs on EPTF_ExecCtrlClient_CT {
if (not v_ExecCtrlClient_initialized) {
return;
}
v_ExecCtrlClient_initialized := false;
f_EPTF_ExecCtrlClient_debug(%definitionId&": started");
// send bye only if ExecCtrl did not sent bye to me before
if (not v_ExecCtrlClient_byeReceived) {
ExecCtrlClient_MgmtIf_CP.send(EPTF_ExecCtrl_Bye:{});
f_EPTF_ExecCtrlClient_waitForByeAck();
}
disconnect(self:ExecCtrlClient_MgmtIf_CP, v_ExecCtrl_execCtrlMasterCompRef:ExecCtrl_MgmtIf_CP);
v_ExecCtrlClient_started := false;
v_ExecCtrlClient_byeAckReceived := false;
v_ExecCtrlClient_byeReceived := false;
v_ExecCtrlClient_semaphore_DeclareScenario := 0;
v_ExecCtrlClient_semaphore_EndOfConfig := false;
v_EPTF_ExecCtrlClient_guiDone := false;
v_EPTF_ExecCtrlClient_autoReportGuiDone := true;
v_EPTF_ExecCtrlClient_guiDoneReported := false;
f_EPTF_ExecCtrlClient_cleanupEGrpDB();
v_ExecCtrlClient_EndOfConfigCallbackFns := {};
v_ExecCtrlClient_GuiDoneCallbackFns := {};
v_EPTF_ExecCtrlClient_GuiDoneCallbackFn := null;
v_EPTF_ExecCtrlClient_finalTestReportGeneratorFns := {};
deactivate(vl_EPTF_ExecCtrlClient_def)
f_EPTF_ExecCtrlClient_debug(%definitionId&": finished");
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrlClient_loadConfig
//
// Purpose:
// Loads additional config data and appends them to existing data
//
// Parameters:
// pl_EPTF_LGenBase_TcMgmt_EntityGrpDeclaratorList - *in* <EPTF_LGenBase_TcMgmt_EntityGrpDeclaratorList>
// pl_EPTF_LGenBase_TcMgmt_Scenarios2GrpList - *in* <EPTF_LGenBase_TcMgmt_Scenarios2GrpList>
//
// pl_EPTF_LGenBase_ScenarioDeclaratorList - *in* <EPTF_LGenBase_ScenarioDeclaratorList>
// pl_EPTF_LGenBase_tcTypeDeclaratorList - *in* <EPTF_LGenBase_tcTypeDeclaratorList>
//
// pl_EPTF_LGenBase_TcMgmt_tcTypeDeclaratorList - *in* <EPTF_LGenBase_TcMgmt_tcTypeDeclaratorList>
// pl_EPTF_LGenBase_TcMgmt_ScenarioDeclaratorList - *in* <EPTF_LGenBase_TcMgmt_ScenarioDeclaratorList>
//
// pl_EPTF_LGenBase_TcMgmt_WeightedScenarioDeclaratorList - *in* <EPTF_LGenBase_TcMgmt_WeightedScenarioDeclaratorList>
//
// pl_EPTF_ExecCtrl_TimeProfileDescrList - *in* <EPTF_ExecCtrl_TimeProfileDescrList>
// pl_EPTF_ExecCtrl_TimeProfileList - *in* <EPTF_ExecCtrl_TimeProfileList>
// pl_EPTF_ExecCtrl_TimeProfile2TcList - *in* <EPTF_ExecCtrl_TimeProfile2TcList>
//
// pl_EPTF_LGenBase_ScenarioTypeDeclaratorList - *in* <EPTF_LGenBase_ScenarioTypeDeclaratorList> *optional* - Scenario Declator appeared in R3
// pl_EPTF_ExecCtrl_ScenarioInstanceTypeList - *in* <EPTF_ExecCtrl_ScenarioInstanceTypeList> - scenario instance decl
//
// pl_EPTF_ExecCtrl_LGenPool_Declarators - *in* <EPTF_ExecCtrl_LGenPool_Declarators> - LGen Pool declarators
// pl_EPTF_ExecCtrl_EntityGroup2LGenPool_List - *in* <EPTF_ExecCtrl_EntityGroup2LGenPool_List> - Entity group to LGen Pool declarators
//
// pl_EPTF_ExecCtrl_LGenFunction_Entry_List - *in* <EPTF_ExecCtrl_LGenFunction_Entry_List> - the LGen creator functions to register
//
// pl_EPTF_ExecCtrl_PhaseList_Declarators - *in* <EPTF_LGenBase_PhaseList_Declarators> - list of phaseLists
// pl_EPTF_ExecCtrl_ScenarioGroup_Declarators - *in* <EPTF_ExecCtrl_ScenarioGroup_Declarators> - list of scenario groups
//
// pl_EPTF_ExecCtrl_RegulatorNames - *in* <EPTF_ExecCtrl_RegulatorNames> - list of regulator names
// pl_EPTF_ExecCtrl_RegulatedItems - *in* <EPTF_ExecCtrl_RegulatedItems> - list of regulated items
//
// pl_EPTF_ExecCtrl_EntityGroupDistributionTypeList - *in* <EPTF_ExecCtrl_EntityGroupDistributionTypeList> - list of entity group distributions
//
// Return Value:
// -
//
// Errors & assertions:
//
// Detailed Comments:
// This function forwards the specified configuration data to ExecCtrl and calls the <f_EPTF_ExecCtrl_loadConfig> function with them.
// All parameters are optional. If specified, the value of that parameter is appended to the corresponding data already loaded.
// This function can be called more than once with different arguments.
// If you have your own tsp-s, this function can be used to load them into the ExecCtrl database from the LGen. The ExecCtr
// should know about all declarators in the system before it is started.
// The configuration can be loaded on an LGen if the LGen is not in an LGen-pool, because LGens in LGen pool are
// created after configuration data is loaded and ExecCtrl was started. Only from LGens created 'manually' is possible
// to load configuration data to ExecCtrl.
// This function should be called before the <f_EPTF_ExecCtrl_start> function is called (after which the configuration data is
// processed) on the ExecCtrl component and before the <f_EPTF_ExecCtrlClient_readyToStart> function is called.
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrlClient_loadConfig(
in EPTF_LGenBase_TcMgmt_EntityGrpDeclaratorList pl_EPTF_LGenBase_TcMgmt_EntityGrpDeclaratorList :={},
in EPTF_LGenBase_TcMgmt_Scenarios2GrpList pl_EPTF_LGenBase_TcMgmt_Scenarios2GrpList :={},
in EPTF_LGenBase_ScenarioDeclaratorList pl_EPTF_LGenBase_ScenarioDeclaratorList :={},
in EPTF_LGenBase_tcTypeDeclaratorList pl_EPTF_LGenBase_tcTypeDeclaratorList :={},
in EPTF_LGenBase_TcMgmt_tcTypeDeclaratorList pl_EPTF_LGenBase_TcMgmt_tcTypeDeclaratorList :={},
in EPTF_LGenBase_TcMgmt_ScenarioDeclaratorList pl_EPTF_LGenBase_TcMgmt_ScenarioDeclaratorList :={},
in EPTF_LGenBase_TcMgmt_WeightedScenarioDeclaratorList pl_EPTF_LGenBase_TcMgmt_WeightedScenarioDeclaratorList :={},
in EPTF_ExecCtrl_TimeProfileDescrList pl_EPTF_ExecCtrl_TimeProfileDescrList := {},
in EPTF_ExecCtrl_TimeProfileList pl_EPTF_ExecCtrl_TimeProfileList := {},
in EPTF_ExecCtrl_TimeProfile2TcList pl_EPTF_ExecCtrl_TimeProfile2TcList := {},
in EPTF_LGenBase_ScenarioTypeDeclaratorList pl_EPTF_LGenBase_ScenarioTypeDeclaratorList := {},
in EPTF_ExecCtrl_ScenarioInstanceTypeList pl_EPTF_ExecCtrl_ScenarioInstanceTypeList := {},
in EPTF_ExecCtrl_LGenPool_Declarators pl_EPTF_ExecCtrl_LGenPool_Declarators := {},
in EPTF_ExecCtrl_EntityGroup2LGenPool_List pl_EPTF_ExecCtrl_EntityGroup2LGenPool_List := {},
//in EPTF_ExecCtrl_LGenFunction_Entry_List pl_EPTF_ExecCtrl_LGenFunction_Entry_List := {},
in EPTF_LGenBase_PhaseList_Declarators pl_EPTF_ExecCtrl_PhaseList_Declarators := {},
in EPTF_ExecCtrl_ScenarioGroup_Declarators pl_EPTF_ExecCtrl_ScenarioGroup_Declarators := {},
in EPTF_ExecCtrl_RegulatorNames pl_EPTF_ExecCtrl_RegulatorNames := {},
in EPTF_ExecCtrl_RegulatedItems pl_EPTF_ExecCtrl_RegulatedItems := {},
in EPTF_ExecCtrl_EntityGroupDistributionTypeList pl_EPTF_ExecCtrl_EntityGroupDistributionTypeList := {}
) runs on EPTF_ExecCtrlClient_CT {
f_EPTF_ExecCtrlClient_debug(%definitionId&": started...");
if (v_ExecCtrlClient_byeReceived) {
f_EPTF_ExecCtrlClient_debug(log2str(%definitionId&": Config not loaded: ExecCtrl terminated."));
return;
}
if (v_ExecCtrlClient_started) {
f_EPTF_ExecCtrlClient_warning(log2str(%definitionId&": Config not loaded: ExecCtrlClient was already started"));
return;
}
var EPTF_ExecCtrlClient_LoadConfig vl_EPTF_ExecCtrlClient_LoadConfig := c_EPTF_ExecCtrlClient_LoadConfig_default;
vl_EPTF_ExecCtrlClient_LoadConfig := {
pl_EPTF_LGenBase_TcMgmt_EntityGrpDeclaratorList,
pl_EPTF_LGenBase_TcMgmt_Scenarios2GrpList,
pl_EPTF_LGenBase_ScenarioDeclaratorList,
pl_EPTF_LGenBase_tcTypeDeclaratorList,
pl_EPTF_LGenBase_TcMgmt_tcTypeDeclaratorList,
pl_EPTF_LGenBase_TcMgmt_ScenarioDeclaratorList,
pl_EPTF_LGenBase_TcMgmt_WeightedScenarioDeclaratorList,
pl_EPTF_ExecCtrl_TimeProfileDescrList,
pl_EPTF_ExecCtrl_TimeProfileList,
pl_EPTF_ExecCtrl_TimeProfile2TcList,
pl_EPTF_LGenBase_ScenarioTypeDeclaratorList,
pl_EPTF_ExecCtrl_ScenarioInstanceTypeList,
pl_EPTF_ExecCtrl_LGenPool_Declarators,
pl_EPTF_ExecCtrl_EntityGroup2LGenPool_List,
//pl_EPTF_ExecCtrl_LGenFunction_Entry_List,
pl_EPTF_ExecCtrl_PhaseList_Declarators,
pl_EPTF_ExecCtrl_ScenarioGroup_Declarators,
pl_EPTF_ExecCtrl_RegulatorNames,
pl_EPTF_ExecCtrl_RegulatedItems,
pl_EPTF_ExecCtrl_EntityGroupDistributionTypeList
}
ExecCtrlClient_MgmtIf_CP.send(EPTF_ExecCtrlClient_LoadConfig:vl_EPTF_ExecCtrlClient_LoadConfig);
f_EPTF_ExecCtrlClient_debug(%definitionId&": finished...");
}
friend function f_EPTF_ExecCtrlClient_execCtrlMasterCompRef() runs on EPTF_ExecCtrlClient_CT return EPTF_ExecCtrl_CT {
return v_ExecCtrl_execCtrlMasterCompRef;
}
// declares and registers FSM Stats into the StatHandler in ExecCtrl
private function f_EPTF_ExecCtrlClient_registerFSMStats() runs on EPTF_ExecCtrlClient_CT {
// get statList
var EPTF_LGenBase_StatisticListOfTCList vl_statList;
f_EPTF_LGenBase_getStatisticsOfTcs(vl_statList);
f_EPTF_ExecCtrlClient_debug(log2str(%definitionId&": vl_statList: ", vl_statList));
// notify ExecCtrl about the new stats
f_EPTF_ExecCtrlClient_createFSMStats(vl_statList);
}
// notifies ExecCtrl about the FSM stats in LGen
private function f_EPTF_ExecCtrlClient_createFSMStats(in EPTF_ExecCtrl_CreateFSMStats pl_createFSMStats) runs on EPTF_ExecCtrlClient_CT {
if (v_ExecCtrlClient_byeReceived) {
f_EPTF_ExecCtrlClient_debug(log2str("CreateFSMStats is not sent: ExecCtrl terminated."));
return;
}
ExecCtrlClient_MgmtIf_CP.send(EPTF_ExecCtrl_CreateFSMStats:pl_createFSMStats);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrlClient_set_scenarioInitialized_fcb
//
// Purpose:
// Function to set scenarioInitialized callback function
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrlClient_set_scenarioInitialized_fcb(in f_EPTF_ExecCtrlClient_scenarioInitialized_fcb_FT pl_scenarioInitialized_fcb) runs on EPTF_ExecCtrlClient_CT {
v_ExecCtrlClient_scenarioInitialized_fcb := pl_scenarioInitialized_fcb;
}
//====================================================
// f_EPTF_ExecCtrlClient_groupFinishedDetectedFn
// send groupFinish event to ExecCtrl:
//====================================================
private function f_EPTF_ExecCtrlClient_groupFinishedDetectedFn(
in integer pl_tcIdx,
in EPTF_LGenBase_ConditionTrue pl_condition,
out boolean pl_abortGroupFinished
) runs on EPTF_ExecCtrlClient_CT {
if (v_ExecCtrlClient_byeReceived) {
f_EPTF_ExecCtrlClient_debug(log2str("GroupFinished not sent: ExecCtrl terminated."));
pl_abortGroupFinished := true;
return;
}
pl_abortGroupFinished := v_ExecCtrlClient_abortNextGroupFinish;//(f_EPTF_LGenBase_getTrafficStartFinishConditionCounter(pl_tcIdx,nrOfExecStart) < 100);
if (v_ExecCtrlClient_abortNextGroupFinish) {
var charstring vl_eGrpName;
var charstring vl_scName;
var charstring vl_tcName;
f_EPTF_LGenBase_trafficCaseIdNames(pl_tcIdx,vl_eGrpName,vl_scName,vl_tcName);
var EPTF_ExecCtrl_GrpFinishConditionTypes vl_grpFinishConditionTypes := f_EPTF_ExecCtrl_condition2GrpFinishConditionType(pl_condition);
var EPTF_IntegerList vl_counters := {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
for(var integer i:=0; i<sizeof(vl_grpFinishConditionTypes); i:=i+1) {
vl_counters[vl_grpFinishConditionTypes[i]] := f_EPTF_ExecCtrlClient_getCounterForGroupFinishConditionType(pl_tcIdx,vl_grpFinishConditionTypes[i]);
}
f_EPTF_ExecCtrl_accumulateConditions(pl_condition,v_ExecCtrlClient_pauseDataForTCs[pl_tcIdx].groupFinishedDetected);
// always fill the counters:
vl_counters[c_EPTF_ExecCtrl_groupFinishNofExecStartIdx] := f_EPTF_ExecCtrlClient_getCounterForGroupFinishConditionType(pl_tcIdx,c_EPTF_ExecCtrl_groupFinishNofExecStartIdx);
vl_counters[c_EPTF_ExecCtrl_groupFinishNofSuccessIdx] := f_EPTF_ExecCtrlClient_getCounterForGroupFinishConditionType(pl_tcIdx,c_EPTF_ExecCtrl_groupFinishNofSuccessIdx);
vl_counters[c_EPTF_ExecCtrl_groupFinishNofFailIdx] := f_EPTF_ExecCtrlClient_getCounterForGroupFinishConditionType(pl_tcIdx,c_EPTF_ExecCtrl_groupFinishNofFailIdx);
vl_counters[c_EPTF_ExecCtrl_groupFinishNofTimeoutIdx] := f_EPTF_ExecCtrlClient_getCounterForGroupFinishConditionType(pl_tcIdx,c_EPTF_ExecCtrl_groupFinishNofTimeoutIdx);
vl_counters[c_EPTF_ExecCtrl_groupFinishNofErrorIdx] := f_EPTF_ExecCtrlClient_getCounterForGroupFinishConditionType(pl_tcIdx,c_EPTF_ExecCtrl_groupFinishNofErrorIdx);
vl_counters[c_EPTF_ExecCtrl_groupFinish_RangeLoops] := f_EPTF_ExecCtrlClient_getCounterForGroupFinishConditionType(pl_tcIdx,c_EPTF_ExecCtrl_groupFinish_RangeLoops);
ExecCtrlClient_MgmtIf_CP.send(EPTF_ExecCtrlClient_GroupFinished:{tcId := {vl_eGrpName,vl_scName,vl_tcName}, condition := pl_condition, thresholds := vl_counters});
f_EPTF_LGenBase_pauseTrafficCaseByIdx(pl_tcIdx);
} else {
v_ExecCtrlClient_abortNextGroupFinish := true; // next group finish will be aborted by default
}
}
//====================================================
// f_EPTF_ExecCtrlClient_processGroupFinished
// TR HL56376: fixed by ETHBAAT
//====================================================
private function f_EPTF_ExecCtrlClient_processGroupFinished(
in integer pl_tcIdx,
in EPTF_LGenBase_ConditionTrue pl_condition,
in EPTF_IntegerList pl_newConditionCounters
) runs on EPTF_ExecCtrlClient_CT {
if (not pl_condition.anythingFinished) {
//increase condition change condition:
f_EPTF_ExecCtrlClient_setNewConditionCounters(pl_tcIdx, pl_condition,pl_newConditionCounters);
f_EPTF_ExecCtrl_clearGroupFinishConditionFired(pl_condition,v_ExecCtrlClient_pauseDataForTCs[pl_tcIdx].groupFinishedDetected);
if (not f_EPTF_ExecCtrl_checkGroupFinishConditionFired(v_ExecCtrlClient_pauseDataForTCs[pl_tcIdx].groupFinishedDetected)) {
// all conditions are updated
// reset my flags:
v_ExecCtrlClient_pauseDataForTCs[pl_tcIdx].groupFinishedDetected := c_EPTF_LGenBase_emptyConditionTrue;
// reset LGenBase groupFinishedCondition flags so that it could detect them again
f_EPTF_LGenBase_resetTcGroupFinishConditionDetected(pl_tcIdx);
// only start if all conditions that had been fullfilled were updated:
// resume the traffic case:
f_EPTF_LGenBase_resumeTrafficCaseByIdx(pl_tcIdx);
}
} else {
f_EPTF_ExecCtrlClient_setNewConditionCounters(pl_tcIdx, pl_condition,pl_newConditionCounters); // set counters to final values
v_ExecCtrlClient_abortNextGroupFinish := false; // allow LGenBase to detect group finish:
f_EPTF_LGenBase_groupFinishedDetected(pl_tcIdx,pl_condition);
}
}//f_
private function f_EPTF_ExecCtrlClient_setNewConditionCounters(
in integer pl_tcIdx,
in EPTF_LGenBase_ConditionTrue pl_condition,
in EPTF_IntegerList pl_newConditionCounters
) runs on EPTF_ExecCtrlClient_CT {
if(pl_condition.nrOfExecStart
and isbound(pl_newConditionCounters[c_EPTF_ExecCtrl_groupFinishNofExecStartIdx])
and pl_newConditionCounters[c_EPTF_ExecCtrl_groupFinishNofExecStartIdx]>=0) {
f_EPTF_LGenBase_setTrafficStartFinishConditionCounter(pl_tcIdx,nrOfExecStart,pl_newConditionCounters[c_EPTF_ExecCtrl_groupFinishNofExecStartIdx]);
}
if(pl_condition.nrOfSuccesses
and isbound(pl_newConditionCounters[c_EPTF_ExecCtrl_groupFinishNofSuccessIdx])
and pl_newConditionCounters[c_EPTF_ExecCtrl_groupFinishNofSuccessIdx]>=0) {
f_EPTF_LGenBase_setTrafficStartFinishConditionCounter(pl_tcIdx,nrOfSuccesses,pl_newConditionCounters[c_EPTF_ExecCtrl_groupFinishNofSuccessIdx]);
}
if(pl_condition.nrOfFails
and isbound(pl_newConditionCounters[c_EPTF_ExecCtrl_groupFinishNofFailIdx])
and pl_newConditionCounters[c_EPTF_ExecCtrl_groupFinishNofFailIdx]>=0) {
f_EPTF_LGenBase_setTrafficStartFinishConditionCounter(pl_tcIdx,nrOfFails,pl_newConditionCounters[c_EPTF_ExecCtrl_groupFinishNofFailIdx]);
}
if(pl_condition.nrOfErrors
and isbound(pl_newConditionCounters[c_EPTF_ExecCtrl_groupFinishNofErrorIdx])
and pl_newConditionCounters[c_EPTF_ExecCtrl_groupFinishNofErrorIdx]>=0) {
f_EPTF_LGenBase_setTrafficStartFinishConditionCounter(pl_tcIdx,nrOfErrors,pl_newConditionCounters[c_EPTF_ExecCtrl_groupFinishNofErrorIdx]);
}
if(pl_condition.nrOfTimeouts
and isbound(pl_newConditionCounters[c_EPTF_ExecCtrl_groupFinishNofTimeoutIdx])
and pl_newConditionCounters[c_EPTF_ExecCtrl_groupFinishNofTimeoutIdx]>=0) {
f_EPTF_LGenBase_setTrafficStartFinishConditionCounter(pl_tcIdx,nrOfTimeouts,pl_newConditionCounters[c_EPTF_ExecCtrl_groupFinishNofTimeoutIdx]);
}
if(pl_condition.nrOfRangeLoop
and isbound(pl_newConditionCounters[c_EPTF_ExecCtrl_groupFinish_RangeLoops])
and pl_newConditionCounters[c_EPTF_ExecCtrl_groupFinish_RangeLoops]>=0) {
f_EPTF_LGenBase_setTrafficStartFinishConditionCounter(pl_tcIdx,nrOfRangeLoop,pl_newConditionCounters[c_EPTF_ExecCtrl_groupFinish_RangeLoops]);
}
}
// receive groupFinished from ExecCtrl:
private altstep as_EPTF_ExecCtrlClient_MgmtIf_groupFinished() runs on EPTF_ExecCtrlClient_CT {
var EPTF_ExecCtrlClient_GroupFinished vl_msg;
[] ExecCtrlClient_MgmtIf_CP.receive(EPTF_ExecCtrlClient_GroupFinished:?) -> value vl_msg {
f_EPTF_ExecCtrlClient_debug("EPTF_ExecCtrlClient_GroupFinished received...");
// calling original groupFinish handler:
var integer vl_tcIdx := f_EPTF_LGenBase_trafficCaseId(vl_msg.tcId.eGrpName,vl_msg.tcId.scName,vl_msg.tcId.tcName);
f_EPTF_ExecCtrlClient_processGroupFinished(vl_tcIdx,vl_msg.condition,vl_msg.thresholds);
repeat;
}
}
//====================================================
// f_EPTF_ExecCtrl_processPauseTC
//====================================================
private function f_EPTF_ExecCtrl_processPauseTC(
in integer pl_tcIdx,
in EPTF_ExecCtrl_GrpFinishConditionType pl_groupFinishConditionType
) runs on EPTF_ExecCtrlClient_CT {
v_ExecCtrlClient_pauseDataForTCs[pl_tcIdx].pausing := true;
v_ExecCtrlClient_pauseDataForTCs[pl_tcIdx].groupFinishConditionType := pl_groupFinishConditionType;
var EPTF_LGenBase_ConditionTrue vl_cause := f_EPTF_ExecCtrl_grpFinishConditionType2Condition(pl_groupFinishConditionType);
f_EPTF_ExecCtrl_accumulateConditions(vl_cause,v_ExecCtrlClient_pauseDataForTCs[pl_tcIdx].groupFinishedDetected);
if (f_EPTF_LGenBase_getTcState(pl_tcIdx)==c_EPTF_LGenBase_tcStatePaused) {
// call handler here:
f_EPTF_ExecCtrlClient_tcStateChanged_handlePaused(pl_tcIdx);
} else {
// pause the given traffic case:
f_EPTF_LGenBase_pauseTrafficCaseByIdx(pl_tcIdx);
//the registered handler <f_EPTF_ExecCtrlClient_tcStateChanged_handlePaused> will send pausedTC to ExecCtrl with the given counter when TC is paused
}
}//f_
// receive pauseTC from ExecCtrl:
private altstep as_EPTF_ExecCtrlClient_MgmtIf_pauseTC() runs on EPTF_ExecCtrlClient_CT {
var EPTF_ExecCtrlClient_PauseTC vl_msg;
[] ExecCtrlClient_MgmtIf_CP.receive(EPTF_ExecCtrlClient_PauseTC:?) -> value vl_msg {
f_EPTF_ExecCtrlClient_debug("EPTF_ExecCtrlClient_PauseTC received...");
// calling original groupFinish handler:
var integer vl_tcIdx := f_EPTF_LGenBase_trafficCaseId(vl_msg.tcId.eGrpName,vl_msg.tcId.scName,vl_msg.tcId.tcName);
f_EPTF_ExecCtrl_processPauseTC(vl_tcIdx,vl_msg.conditionType);
repeat;
}
}
function f_EPTF_ExecCtrlClient_tcStateChanged_handlePaused(in integer pl_tcIdx) runs on EPTF_ExecCtrlClient_CT {
// if tc gets paused
if (f_EPTF_LGenBase_getTcState(pl_tcIdx)==c_EPTF_LGenBase_tcStatePaused) {
// if pause was requested by ExecCtrl:
if (isbound(v_ExecCtrlClient_pauseDataForTCs[pl_tcIdx].pausing) and v_ExecCtrlClient_pauseDataForTCs[pl_tcIdx].pausing == true) {
// send paused to ExecCtrl
v_ExecCtrlClient_pauseDataForTCs[pl_tcIdx].pausing := false;
// get counter value for v_ExecCtrlClient_pauseDataForTCs[pl_tcIdx].onGroupFinishCounterId
var charstring vl_eGrpName;
var charstring vl_scName;
var charstring vl_tcName;
f_EPTF_LGenBase_trafficCaseIdNames(pl_tcIdx,vl_eGrpName,vl_scName,vl_tcName);
var EPTF_IntegerList vl_counters := {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
var integer vl_counter := f_EPTF_ExecCtrlClient_getCounterForGroupFinishConditionType(pl_tcIdx,v_ExecCtrlClient_pauseDataForTCs[pl_tcIdx].groupFinishConditionType);
vl_counters[v_ExecCtrlClient_pauseDataForTCs[pl_tcIdx].groupFinishConditionType] := vl_counter;
// always fill the counters:
vl_counters[c_EPTF_ExecCtrl_groupFinishNofExecStartIdx] := f_EPTF_ExecCtrlClient_getCounterForGroupFinishConditionType(pl_tcIdx,c_EPTF_ExecCtrl_groupFinishNofExecStartIdx);
vl_counters[c_EPTF_ExecCtrl_groupFinishNofSuccessIdx] := f_EPTF_ExecCtrlClient_getCounterForGroupFinishConditionType(pl_tcIdx,c_EPTF_ExecCtrl_groupFinishNofSuccessIdx);
vl_counters[c_EPTF_ExecCtrl_groupFinishNofFailIdx] := f_EPTF_ExecCtrlClient_getCounterForGroupFinishConditionType(pl_tcIdx,c_EPTF_ExecCtrl_groupFinishNofFailIdx);
vl_counters[c_EPTF_ExecCtrl_groupFinishNofTimeoutIdx] := f_EPTF_ExecCtrlClient_getCounterForGroupFinishConditionType(pl_tcIdx,c_EPTF_ExecCtrl_groupFinishNofTimeoutIdx);
vl_counters[c_EPTF_ExecCtrl_groupFinishNofErrorIdx] := f_EPTF_ExecCtrlClient_getCounterForGroupFinishConditionType(pl_tcIdx,c_EPTF_ExecCtrl_groupFinishNofErrorIdx);
vl_counters[c_EPTF_ExecCtrl_groupFinish_RangeLoops] := f_EPTF_ExecCtrlClient_getCounterForGroupFinishConditionType(pl_tcIdx,c_EPTF_ExecCtrl_groupFinish_RangeLoops);
// send current values for all conditions
ExecCtrlClient_MgmtIf_CP.send(EPTF_ExecCtrlClient_PauseTC:{
tcId := {
eGrpName := vl_eGrpName,
scName := vl_scName,
tcName := vl_tcName
},
conditionType := v_ExecCtrlClient_pauseDataForTCs[pl_tcIdx].groupFinishConditionType,
counters := vl_counters
});
}
}
}
private function f_EPTF_ExecCtrlClient_getCounterForGroupFinishConditionType(
in integer pl_tcIdx,
in EPTF_ExecCtrl_GrpFinishConditionType pl_groupFinishConditionType
) runs on EPTF_ExecCtrlClient_CT return integer {
var integer vl_counter;
if(pl_groupFinishConditionType==c_EPTF_ExecCtrl_groupFinishNofExecStartIdx) {
vl_counter := f_EPTF_LGenBase_getTcStarts(pl_tcIdx);
} else if(pl_groupFinishConditionType==c_EPTF_ExecCtrl_groupFinishNofSuccessIdx) {
vl_counter := f_EPTF_LGenBase_getTcSuccesses(pl_tcIdx);
} else if(pl_groupFinishConditionType==c_EPTF_ExecCtrl_groupFinishNofFailIdx) {
vl_counter := f_EPTF_LGenBase_getTcFails(pl_tcIdx);
} else if(pl_groupFinishConditionType==c_EPTF_ExecCtrl_groupFinishNofErrorIdx) {
vl_counter := f_EPTF_LGenBase_getTcErrors(pl_tcIdx);
} else if(pl_groupFinishConditionType==c_EPTF_ExecCtrl_groupFinishNofTimeoutIdx) {
vl_counter := f_EPTF_LGenBase_getTcTimeouts(pl_tcIdx);
} else if(pl_groupFinishConditionType==c_EPTF_ExecCtrl_groupFinish_RangeLoops) {
var charstring vl_eGrpName;
var charstring vl_scName;
var charstring vl_tcName;
f_EPTF_LGenBase_trafficCaseIdNames(pl_tcIdx,vl_eGrpName,vl_scName,vl_tcName);
var charstring vl_varNameBase := f_EPTF_LGenBase_getNamePrefix(vl_eGrpName,vl_scName,vl_tcName);
vl_counter := f_EPTF_Var_getIntValue(f_EPTF_Var_getId(vl_varNameBase&c_EPTF_LGenBaseStats_nameOfTcRangeLoops));
} else if(pl_groupFinishConditionType==c_EPTF_ExecCtrl_groupFinish_ExecTime) {
vl_counter := 1;
} else if(pl_groupFinishConditionType==c_EPTF_ExecCtrl_groupFinish_EntitiesFinished) {
vl_counter := 1;//f_EPTF_LGenBase_getTcAllEntities(pl_tcIdx) - f_EPTF_LGenBase_getTcNotFinishedEntities(pl_tcIdx);
} else if(pl_groupFinishConditionType==c_EPTF_ExecCtrl_groupFinish_AvailableEntitiesFinished) {
vl_counter := 1;//f_EPTF_LGenBase_getTcAvailable(pl_tcIdx);
} else if(pl_groupFinishConditionType==c_EPTF_ExecCtrl_groupFinish_Custom) {
vl_counter := 1;
} else if(pl_groupFinishConditionType==c_EPTF_ExecCtrl_groupFinishConditionUnknown) {
vl_counter := -1;
} else {
vl_counter := -1;
}
return vl_counter;
}
///////////////////////////////////////////////////////////
// Altstep: as_EPTF_ExecCtrlClient_MgmtIf_UpdateActiveEntities
//
// Purpose:
// Handles EPTF_ExecCtrl_UpdateCps messages from ExecCtrl
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private altstep as_EPTF_ExecCtrlClient_MgmtIf_UpdateActiveEntities() runs on EPTF_ExecCtrlClient_CT
{
var EPTF_ExecCtrl_UpdateActiveEntities vl_updateActiveEntities_msg;
[] ExecCtrlClient_MgmtIf_CP.receive(EPTF_ExecCtrl_UpdateActiveEntities:?) -> value vl_updateActiveEntities_msg
{
//Note: Don't change the log string! There is a regression test based on it!
f_EPTF_ExecCtrlClient_debug("EPTF_ExecCtrl_UpdateActiveEntities received...");
var integer vl_eGrpIdx := f_EPTF_LGenBase_entityGrpNameIndex(vl_updateActiveEntities_msg.eGrpName);
var integer vl_activeEntities := vl_updateActiveEntities_msg.activeEntities;
f_EPTF_LGenBase_limitExecution(vl_eGrpIdx,vl_activeEntities);
repeat;
}
}
///////////////////////////////////////////////////////////
// Altstep: as_EPTF_ExecCtrlClient_MgmtIf_UpdateCps
//
// Purpose:
// Handles EPTF_ExecCtrl_UpdateCps messages from ExecCtrl
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private altstep as_EPTF_ExecCtrlClient_MgmtIf_UpdateCps() runs on EPTF_ExecCtrlClient_CT
{
var EPTF_ExecCtrl_UpdateCps vl_updateCps_msg;
[] ExecCtrlClient_MgmtIf_CP.receive(EPTF_ExecCtrl_UpdateCps:?) -> value vl_updateCps_msg
{
f_EPTF_ExecCtrlClient_debug("EPTF_ExecCtrl_UpdateCps received...");
/* f_EPTF_LGenBase_setCpsOrWeightOfTcByNames(
vl_updateCps_msg.eGrpName,
vl_updateCps_msg.scenName,
vl_updateCps_msg.cpsList[tcidx].tcName,
vl_updateCps_msg.cpsList[tcidx].cpsToReach);*/
// new code performs the update via the variable feature, resulting in proper GUI refresh:
// // this code does not update the GUI:
// f_EPTF_LGenBase_setCPSByNames(
// vl_updateCps_msg.eGrpName,
// vl_updateCps_msg.scenName,
// vl_updateCps_msg.tcName,
// vl_updateCps_msg.cps
// );
var integer vl_eGrpIdx := f_EPTF_LGenBase_entityGrpNameIndex(vl_updateCps_msg.eGrpName);
var integer vl_scInGrpIdx := f_EPTF_LGenBase_scNameIndexInEG(vl_eGrpIdx, vl_updateCps_msg.scenName);
var integer vl_varIdx := -1;
var charstring vl_varNameBase := f_EPTF_LGenBaseStats_getNamePrefix(
vl_updateCps_msg.eGrpName,
vl_updateCps_msg.scenName,
vl_updateCps_msg.tcName
);
if (f_EPTF_LGenBase_isWeightedScenario(vl_eGrpIdx,vl_scInGrpIdx)) {
// update traffic weight:
vl_varIdx := f_EPTF_Var_getId(vl_varNameBase&c_EPTF_LGenBaseStats_nameOfTcWeight);
} else {
// update cpsToReach
vl_varIdx := f_EPTF_Var_getId(vl_varNameBase&c_EPTF_LGenBaseStats_nameOfTcCpsToReach);
}
if(vl_varIdx >= 0) {
f_EPTF_Var_adjustContent(vl_varIdx, {floatVal := vl_updateCps_msg.cps});
}
repeat;
}
}
///////////////////////////////////////////////////////////
// Altstep: as_EPTF_ExecCtrlClient_MgmtIf_UpdateStartDelay
//
// Purpose:
// Handles EPTF_ExecCtrl_UpdateStartDelay messages from ExecCtrl
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private altstep as_EPTF_ExecCtrlClient_MgmtIf_UpdateStartDelay() runs on EPTF_ExecCtrlClient_CT
{
var EPTF_ExecCtrl_UpdateStartDelay vl_msg;
[] ExecCtrlClient_MgmtIf_CP.receive(EPTF_ExecCtrl_UpdateStartDelay:?) -> value vl_msg
{
f_EPTF_ExecCtrlClient_debug("EPTF_ExecCtrl_UpdateStartDelay received...");
f_EPTF_LGenBase_setTCStartDelay(f_EPTF_LGenBase_trafficCaseId(vl_msg.eGrpName, vl_msg.scenName, vl_msg.tcName),vl_msg.startDelay);
repeat;
}
}
///////////////////////////////////////////////////////////
// Altstep: as_EPTF_ExecCtrlClient_MgmtIf_UpdateScenarioCps
//
// Purpose:
// Handles EPTF_ExecCtrl_UpdateScenarioCps messages from ExecCtrl
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private altstep as_EPTF_ExecCtrlClient_MgmtIf_UpdateScenarioCps() runs on EPTF_ExecCtrlClient_CT
{
var EPTF_ExecCtrl_UpdateScenarioCps vl_updateCps_msg;
[] ExecCtrlClient_MgmtIf_CP.receive(EPTF_ExecCtrl_UpdateScenarioCps:?) -> value vl_updateCps_msg
{
f_EPTF_ExecCtrlClient_debug("EPTF_ExecCtrl_UpdateScenarioCps received...");
var integer vl_eGrpIdx := f_EPTF_LGenBase_entityGrpNameIndex(vl_updateCps_msg.eGrpName);
var integer vl_scInGrpIdx := f_EPTF_LGenBase_scNameIndexInEG(vl_eGrpIdx, vl_updateCps_msg.scenName);
f_EPTF_LGenBase_setScenarioCPSByIdx(
vl_eGrpIdx,
vl_scInGrpIdx,
vl_updateCps_msg.cps);
var integer vl_varIdx := -1;
var charstring vl_varNameBase;
if (f_EPTF_LGenBase_isWeightedScenario(vl_eGrpIdx,vl_scInGrpIdx)) {
vl_varNameBase := f_EPTF_LGenBaseStats_getScNamePrefix(vl_updateCps_msg.eGrpName,vl_updateCps_msg.scenName);
} else {
f_EPTF_Base_assert(log2str("Cannot set CPS of the scenario ",vl_updateCps_msg.scenName,
": The scenario is not weighted! EGrpName:",vl_updateCps_msg.eGrpName," scenName: ",vl_updateCps_msg.scenName),
false);
}
vl_varIdx := f_EPTF_Var_getId(vl_varNameBase&c_EPTF_LGenBaseStats_nameOfTcCpsToReach);
if(vl_varIdx >= 0) {
f_EPTF_Var_refreshContent(vl_varIdx);
}
repeat;
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrlClient_registerEndOfConfigCallback
//
// Purpose:
// Register an EndOfConfig callback function, that is called when all of the scenarios in the current LGEn are created
// and the configuration of the client is finished
//
// Parameters:
// - pl_EndOfConfigCallback - *in* <EPTF_ExecCtrlClient_EndOfConfigCallbackFn> - reference to the callback function
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrlClient_registerEndOfConfigCallback(in EPTF_ExecCtrlClient_EndOfConfigCallbackFn pl_EndOfConfigCallback) runs on EPTF_ExecCtrlClient_CT {
v_ExecCtrlClient_EndOfConfigCallbackFns[sizeof(v_ExecCtrlClient_EndOfConfigCallbackFns)] := pl_EndOfConfigCallback;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrlClient_callEndOfConfigCallbacks
//
// Purpose:
// Calls all EndOfConfig callback functions
//
// Parameters:
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrlClient_callEndOfConfigCallbacks() runs on EPTF_ExecCtrlClient_CT {
for(var integer i:=0; i<sizeof(v_ExecCtrlClient_EndOfConfigCallbackFns);i:=i+1) {
f_EPTF_ExecCtrlClient_debug(log2str("ExeCtrlClient: EndOfConfigCallback: ", v_ExecCtrlClient_EndOfConfigCallbackFns[i], " called"));
if (v_ExecCtrlClient_EndOfConfigCallbackFns[i]!=null) {
v_ExecCtrlClient_EndOfConfigCallbackFns[i].apply();
}
f_EPTF_ExecCtrlClient_debug(log2str("ExeCtrlClient: EndOfConfigCallback: ", v_ExecCtrlClient_EndOfConfigCallbackFns[i], " done"));
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrlClient_registerGuiDoneCallback
//
// Purpose:
// Register a GuiDone callback function, that is called when the ExecCtrl gui is ready
//
// Parameters:
// - pl_guiDoneCallback - *in* <EPTF_ExecCtrlClient_GuiDoneCallbackFn> - reference to the callback function
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrlClient_registerGuiDoneCallback(in EPTF_ExecCtrlClient_GuiDoneCallbackFn pl_guiDoneCallback) runs on EPTF_ExecCtrlClient_CT {
v_ExecCtrlClient_GuiDoneCallbackFns[sizeof(v_ExecCtrlClient_GuiDoneCallbackFns)] := pl_guiDoneCallback;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrlClient_callGuiDoneCallbacks
//
// Purpose:
// Calls all GuiDone callback functions
//
// Parameters:
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrlClient_callGuiDoneCallbacks() runs on EPTF_ExecCtrlClient_CT {
for(var integer i:=0; i<sizeof(v_ExecCtrlClient_GuiDoneCallbackFns);i:=i+1) {
f_EPTF_ExecCtrlClient_debug(log2str("ExeCtrlClient: GuiDoneCallback: ", v_ExecCtrlClient_GuiDoneCallbackFns[i], " called"));
if (v_ExecCtrlClient_GuiDoneCallbackFns[i]!=null) {
v_ExecCtrlClient_GuiDoneCallbackFns[i].apply();
}
f_EPTF_ExecCtrlClient_debug(log2str("ExeCtrlClient: GuiDoneCallback: ", v_ExecCtrlClient_GuiDoneCallbackFns[i], " done"));
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrlClient_registerGuiDoneCallbackForFSMStats
//
// Purpose:
// used by ExecCtrlClient_UIHandler to register the f_ExecCtrlClient_UIHandler_bindFSMStatsToWidget callback function, that is called when the ExecCtrl gui is ready
//
// Parameters:
// - pl_guiDoneCallback - *in* <EPTF_ExecCtrlClient_GuiDoneCallbackFn> - reference to the callback function
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrlClient_registerGuiDoneCallbackForFSMStats(in EPTF_ExecCtrlClient_GuiDoneCallbackFn pl_guiDoneCallback) runs on EPTF_ExecCtrlClient_CT {
v_EPTF_ExecCtrlClient_GuiDoneCallbackFn := pl_guiDoneCallback;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrlClient_callGuiDoneCallbackForFSMStats
//
// Purpose:
// Calls all GuiDone callback function for FSMStats
//
// Parameters:
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrlClient_callGuiDoneCallbackForFSMStats() runs on EPTF_ExecCtrlClient_CT {
f_EPTF_ExecCtrlClient_debug(log2str("ExeCtrlClient: GuiDoneCallbackForFSMStats: ", v_EPTF_ExecCtrlClient_GuiDoneCallbackFn, " called"));
if (v_EPTF_ExecCtrlClient_GuiDoneCallbackFn!=null) {
v_EPTF_ExecCtrlClient_GuiDoneCallbackFn.apply();
}
f_EPTF_ExecCtrlClient_debug(log2str("ExeCtrlClient: GuiDoneCallbackForFSMStats: ", v_EPTF_ExecCtrlClient_GuiDoneCallbackFn, " done"));
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrlClient_scenarioStateCalcFn
//
// Purpose:
// CalcFn function to copy the scenario state from LGBaseStats to this variable
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// pl_argList[0] : vl_lgenBaseVarIdx to copy the state from
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrlClient_scenarioStateCalcFn(
in integer pl_idx,
in EPTF_IntegerList pl_argList,
in EPTF_IntegerList pl_nonVarArgList,
inout EPTF_Var_DirectContent pl_retVal
) runs on EPTF_ExecCtrlClient_CT {
f_EPTF_Var_getContent(pl_argList[0],pl_retVal);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrlClient_startScenario
//
// Purpose:
// Enables a scenario on an Entity Group and restores and starts
//
// Detailed Comments:
// Wrapper to f_EPTF_LGenBase_enableScenarioOnEntityGroup
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrlClient_startScenario(
in integer pl_eGrpIdx, //entity group
in integer pl_scIdxInGrp, //scenario index in group
in boolean pl_autoStart := true)
runs on EPTF_ExecCtrlClient_CT{
var EPTF_LGenBase_tcState vl_scStatePrev := f_EPTF_LGenBase_getScState(pl_eGrpIdx,pl_scIdxInGrp)
if(c_EPTF_LGenBase_tcStateStopped == vl_scStatePrev or
c_EPTF_LGenBase_tcStateAborted == vl_scStatePrev or
c_EPTF_LGenBase_tcStateTerminated == vl_scStatePrev) {
if(not f_EPTF_LGenBase_restoreScenarioByIdx(pl_eGrpIdx, pl_scIdxInGrp, false)) {
f_EPTF_ExecCtrlClient_debug(log2str("Restoring scenario with state ", vl_scStatePrev, " failed."));
}
}
f_EPTF_LGenBase_enableScenarioOnEntityGroup(pl_eGrpIdx,pl_scIdxInGrp,pl_autoStart);
}
private function f_EPTF_ExecCtrlClient_restoreScenarioData(
in integer pl_eGrpIdx, //entity group
in integer pl_scIdxInGrp //scenario index in group
) runs on EPTF_ExecCtrlClient_CT {
// reset v_ExecCtrlClient_pauseDataForTCs for all TCs in the scenario:
var EPTF_IntegerList vl_tcIdxList;
f_EPTF_LGenBase_tcIdxListOfScenario(pl_eGrpIdx,pl_scIdxInGrp,vl_tcIdxList);
for(var integer i:=0; i<sizeof(vl_tcIdxList); i:=i+1) {
f_EPTF_ExecCtrlClient_restoreTCData(vl_tcIdxList[i]);
}
}
private function f_EPTF_ExecCtrlClient_restoreTCData(
in integer pl_tcIdx //traffic case abs index in LGenBase
) runs on EPTF_ExecCtrlClient_CT {
v_ExecCtrlClient_pauseDataForTCs[pl_tcIdx] := c_EPTF_ExecCtrlClient_PauseData_default;
}
///////////////////////////////////////////////////////////
// Altstep: as_EPTF_ExecCtrlClient_MgmtIf_StartScenario
//
// Purpose:
// Handles <EPTF_ExecCtrl_StartScenario> messages from ExecCtrl
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private altstep as_EPTF_ExecCtrlClient_MgmtIf_StartScenario() runs on EPTF_ExecCtrlClient_CT
{
var EPTF_ExecCtrl_StartScenario vl_StartScenario_msg;
[] ExecCtrlClient_MgmtIf_CP.receive(EPTF_ExecCtrl_StartScenario:?) -> value vl_StartScenario_msg
{
f_EPTF_ExecCtrlClient_debug("EPTF_ExecCtrl_StartScenario received...");
if (not f_EPTF_LGenBase_restoreScenario(vl_StartScenario_msg.eGrpName, vl_StartScenario_msg.scenarioName, false)) {/*to remove the warning*/};
var integer vl_eGrpIdx := f_EPTF_LGenBase_entityGrpNameIndex(vl_StartScenario_msg.eGrpName);
var integer vl_scIdx := f_EPTF_LGenBase_scNameIndexInEG(vl_eGrpIdx,vl_StartScenario_msg.scenarioName)
f_EPTF_ExecCtrlClient_restoreScenarioData(vl_eGrpIdx, vl_scIdx);
f_EPTF_ExecCtrlClient_startScenario(vl_eGrpIdx, vl_scIdx,true);
repeat;
}
}
///////////////////////////////////////////////////////////
// Altstep: as_EPTF_ExecCtrlClient_MgmtIf_StopScenario
//
// Purpose:
// Handles <EPTF_ExecCtrl_StopScenario> messages from ExecCtrl
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private altstep as_EPTF_ExecCtrlClient_MgmtIf_StopScenario() runs on EPTF_ExecCtrlClient_CT
{
var EPTF_ExecCtrl_StopScenario vl_StopScenario_msg;
[] ExecCtrlClient_MgmtIf_CP.receive(EPTF_ExecCtrl_StopScenario:?) -> value vl_StopScenario_msg
{
f_EPTF_ExecCtrlClient_debug("EPTF_ExecCtrl_StopScenario received...");
var integer vl_eGrpIdx := f_EPTF_LGenBase_entityGrpNameIndex(vl_StopScenario_msg.eGrpName)
var integer vl_scIdx := f_EPTF_LGenBase_scNameIndexInEG(vl_eGrpIdx, vl_StopScenario_msg.scenarioName);
if(f_EPTF_LGenBase_isWeightedScenario(vl_eGrpIdx, vl_scIdx)) {
f_EPTF_LGenBase_stopWeightedScenarioByIdx(vl_eGrpIdx, vl_scIdx);
} else {
f_EPTF_LGenBase_stopScenarioByIdx(vl_eGrpIdx, vl_scIdx);
}
/*var integer vl_scenidx := f_EPTF_LGenBase_scenarioNameIndex(vl_StopScenario_msg.scenarioName);
for (var integer tcidx:=0;tcidx<sizeof(v_LGenBase_scenarioTypes[vl_scenidx].trafficCases);tcidx:=tcidx+1) {
f_EPTF_LGenBase_stopTrafficCase(
vl_StopScenario_msg.eGrpName,
vl_StopScenario_msg.scenarioName,
v_LGenBase_trafficCaseTypes[v_LGenBase_scenarioTypes[vl_scenidx].trafficCases[tcidx].tcTypeIdx].name // tcname
);
}*/
var EPTF_LGenBase_Scenario2Grp vl_scenario2Grp := {
eGrpName := vl_StopScenario_msg.eGrpName,
scenarioName := vl_StopScenario_msg.scenarioName
}
repeat;
}
}
///////////////////////////////////////////////////////////
// Altstep: as_EPTF_ExecCtrlClient_MgmtIf_ResetScenario
//
// Purpose:
// Handles <EPTF_ExecCtrl_ResetScenario> messages from ExecCtrl
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private altstep as_EPTF_ExecCtrlClient_MgmtIf_ResetScenario() runs on EPTF_ExecCtrlClient_CT
{
var EPTF_ExecCtrl_ResetScenario vl_msg;
[] ExecCtrlClient_MgmtIf_CP.receive(EPTF_ExecCtrl_ResetScenario:?) -> value vl_msg
{
f_EPTF_ExecCtrlClient_debug("EPTF_ExecCtrl_ResetScenario received...");
if (not f_EPTF_LGenBase_restoreScenario(vl_msg.eGrpName, vl_msg.scenName, false)) {/*to remove the warning*/};
var integer vl_eGrpIdx := f_EPTF_LGenBase_entityGrpNameIndex(vl_msg.eGrpName)
var integer vl_scIdx := f_EPTF_LGenBase_scNameIndexInEG(vl_eGrpIdx, vl_msg.scenName);
f_EPTF_ExecCtrlClient_restoreScenarioData(vl_eGrpIdx, vl_scIdx);
repeat;
}
}
///////////////////////////////////////////////////////////
// Altstep: as_EPTF_ExecCtrlClient_MgmtIf_ResetStats
//
// Purpose:
// Handles <EPTF_ExecCtrl_ResetStats> messages from ExecCtrl
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private altstep as_EPTF_ExecCtrlClient_MgmtIf_ResetStats() runs on EPTF_ExecCtrlClient_CT
{
var EPTF_ExecCtrl_ResetStats vl_msg;
[] ExecCtrlClient_MgmtIf_CP.receive(EPTF_ExecCtrl_ResetStats:?) -> value vl_msg
{
f_EPTF_ExecCtrlClient_debug("EPTF_ExecCtrl_ResetStats received...");
f_EPTF_LGenBase_resetStats();
repeat;
}
}
///////////////////////////////////////////////////////////
// Altstep: as_EPTF_ExecCtrlClient_MgmtIf_StartTrafficCase
//
// Purpose:
// Handles <EPTF_ExecCtrl_StartTrafficCase> messages from ExecCtrl
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private altstep as_EPTF_ExecCtrlClient_MgmtIf_StartTrafficCase() runs on EPTF_ExecCtrlClient_CT
{
var EPTF_ExecCtrl_StartTrafficCase vl_StartTC_msg;
[] ExecCtrlClient_MgmtIf_CP.receive(EPTF_ExecCtrl_StartTrafficCase:?) -> value vl_StartTC_msg
{
f_EPTF_ExecCtrlClient_debug("EPTF_ExecCtrl_StartTrafficCase received...");
if (f_EPTF_LGenBase_get_restoreTCAtStartTC(
vl_StartTC_msg.eGrpName,
vl_StartTC_msg.scenName,
vl_StartTC_msg.tcName
)) {
if (not f_EPTF_LGenBase_restoreTC(
vl_StartTC_msg.eGrpName,
vl_StartTC_msg.scenName,
vl_StartTC_msg.tcName
)) {/*to remove the warning*/};
}
var integer vl_tcAbsIdx := f_EPTF_LGenBase_trafficCaseId(vl_StartTC_msg.eGrpName, vl_StartTC_msg.scenName, vl_StartTC_msg.tcName);
f_EPTF_ExecCtrlClient_restoreTCData(vl_tcAbsIdx);
f_EPTF_LGenBase_startTrafficCase(
vl_StartTC_msg.eGrpName,
vl_StartTC_msg.scenName,
vl_StartTC_msg.tcName
);
repeat;
}
}
///////////////////////////////////////////////////////////
// Altstep: as_EPTF_ExecCtrlClient_MgmtIf_StopTrafficCase
//
// Purpose:
// Handles <EPTF_ExecCtrl_StopTrafficCase> messages from ExecCtrl
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private altstep as_EPTF_ExecCtrlClient_MgmtIf_StopTrafficCase() runs on EPTF_ExecCtrlClient_CT
{
var EPTF_ExecCtrl_StopTrafficCase vl_StopTC_msg;
[] ExecCtrlClient_MgmtIf_CP.receive(EPTF_ExecCtrl_StopTrafficCase:?) -> value vl_StopTC_msg
{
f_EPTF_ExecCtrlClient_debug("EPTF_ExecCtrl_StopTrafficCase received...");
f_EPTF_LGenBase_stopTrafficCase(
vl_StopTC_msg.eGrpName,
vl_StopTC_msg.scenName,
vl_StopTC_msg.tcName
);
repeat;
}
}
///////////////////////////////////////////////////////////
// Altstep: as_EPTF_ExecCtrlClient_MgmtIf_SingleShotTc
//
// Purpose:
// Handles <EPTF_ExecCtrl_SingleShotTc> messages from ExecCtrl
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private altstep as_EPTF_ExecCtrlClient_MgmtIf_SingleShotTc() runs on EPTF_ExecCtrlClient_CT
{
var EPTF_ExecCtrl_SingleShotTc vl_msg;
[] ExecCtrlClient_MgmtIf_CP.receive(EPTF_ExecCtrl_SingleShotTc:?) -> value vl_msg
{
f_EPTF_ExecCtrlClient_debug("EPTF_ExecCtrl_SingleShotTc received...");
f_EPTF_LGenBase_singleShotTc(
vl_msg.eGrpName,
vl_msg.scName,
vl_msg.tcName,
vl_msg.eIdx//,
//vl_msg.enableLog
);
repeat;
}
}
///////////////////////////////////////////////////////////
// Altstep: as_EPTF_ExecCtrlClient_MgmtIf_Bye
//
// Purpose:
// Handles <EPTF_ExecCtrl_Bye> messages from ExecCtrl
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private altstep as_EPTF_ExecCtrlClient_MgmtIf_Bye() runs on EPTF_ExecCtrlClient_CT
{
[] ExecCtrlClient_MgmtIf_CP.receive(EPTF_ExecCtrl_Bye:?)
{
f_EPTF_ExecCtrlClient_debug("EPTF_ExecCtrl_Bye received...");
ExecCtrlClient_MgmtIf_CP.send(EPTF_ExecCtrl_ByeAck:{});
v_ExecCtrlClient_byeReceived := true;
// if cleanup is not in progress and termination enabled:
if (v_ExecCtrlClient_initialized and tsp_EPTF_ExecCtrlClient_terminateIfExecCtrlTerminates) {
f_EPTF_Base_stop(none);
}
repeat;
}
}
///////////////////////////////////////////////////////////
// Altstep: as_EPTF_ExecCtrlClient_MgmtIf_ByeAck
//
// Purpose:
// Handles <EPTF_ExecCtrl_ByeAck> messages from ExecCtrl
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private altstep as_EPTF_ExecCtrlClient_MgmtIf_ByeAck() runs on EPTF_ExecCtrlClient_CT
{
[] ExecCtrlClient_MgmtIf_CP.receive(EPTF_ExecCtrl_ByeAck:?)
{
f_EPTF_ExecCtrlClient_debug("EPTF_ExecCtrl_ByeAck received...");
v_ExecCtrlClient_byeAckReceived := true;
repeat;
}
}
private function f_EPTF_ExecCtrlClient_waitForByeAck() runs on EPTF_ExecCtrlClient_CT {
timer t_wait := 0.0;
t_wait.start;
alt {
[v_ExecCtrlClient_byeAckReceived] t_wait.timeout;
}
}
///////////////////////////////////////////////////////////
// Altstep: as_EPTF_ExecCtrlClient_MgmtIf_unhandledMsg
//
// Purpose:
// Catch unhandled messages of <EPTF_ExecCtrl_Mgmt_PT>
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private altstep as_EPTF_ExecCtrlClient_MgmtIf_unhandledMsg() runs on EPTF_ExecCtrlClient_CT
{
[] ExecCtrlClient_MgmtIf_CP.receive
{
f_EPTF_ExecCtrlClient_error("************* Unhandled ExecCtrl message received *************");
//f_EPTF_Base_stopAll();
}
}
///////////////////////////////////////////////////////////
// Altstep: as_EPTF_ExecCtrlClient_MgmtIf
//
// Purpose:
// Management interface handler of EPTF_ExecCtrlClient feature
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private altstep as_EPTF_ExecCtrlClient_MgmtIf() runs on EPTF_ExecCtrlClient_CT
{
[] as_EPTF_ExecCtrlClient_MgmtIf_UpdateActiveEntities() {};
[] as_EPTF_ExecCtrlClient_MgmtIf_UpdateCps() {}
[] as_EPTF_ExecCtrlClient_MgmtIf_UpdateScenarioCps();
[] as_EPTF_ExecCtrlClient_MgmtIf_UpdateStartDelay();
[] as_EPTF_ExecCtrlClient_MgmtIf_StartScenario() {}
[] as_EPTF_ExecCtrlClient_MgmtIf_StopScenario() {}
[] as_EPTF_ExecCtrlClient_MgmtIf_ResetScenario();
[] as_EPTF_ExecCtrlClient_MgmtIf_ResetStats();
[] as_EPTF_ExecCtrlClient_MgmtIf_StartTrafficCase();
[] as_EPTF_ExecCtrlClient_MgmtIf_StopTrafficCase();
[] as_EPTF_ExecCtrlClient_MgmtIf_SingleShotTc();
[] as_EPTF_ExecCtrlClient_MgmtIf_groupFinished();
[] as_EPTF_ExecCtrlClient_MgmtIf_pauseTC();
// R3 handlers:
[] as_EPTF_ExecCtrlClient_MgmtIf_CreateEntityGrp();
[] as_EPTF_ExecCtrlClient_MgmtIf_CreateEntityGrpList();
[] as_EPTF_ExecCtrlClient_MgmtIf_DeclarePhaseLists();
[] as_EPTF_ExecCtrlClient_MgmtIf_DeclareTcs();
[] as_EPTF_ExecCtrlClient_MgmtIf_CreateScenario();
[] as_EPTF_ExecCtrlClient_MgmtIf_handlePhaseMsgs(); // R3 phase handling
[] as_EPTF_ExecCtrlClient_MgmtIf_handleEndOfConfig();
[] as_EPTF_ExecCtrlClient_MgmtIf_handleGuiDone();
[] as_EPTF_ExecCtrlClient_MgmtIf_Bye();
[] as_EPTF_ExecCtrlClient_MgmtIf_ByeAck();
[] as_EPTF_ExecCtrlClient_MgmtIf_EofTest();
[] as_EPTF_ExecCtrlClient_MgmtIf_unhandledMsg() {}
}
// Functions using the R3 database
group R3 {
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrlClient_readyToStart
//
// Purpose:
// sends "I am ready to start" message to ExecCtrl.
// The ExecCtrl will configure the clients if all LGens are ready to start
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrlClient_readyToStart() runs on EPTF_ExecCtrlClient_CT {
f_EPTF_ExecCtrlClient_sendEntityResourceInfo();
v_ExecCtrlClient_started := true;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrlClient_sendEntityResourceInfo
//
// Purpose:
// Function for sending the LGen's resource availability
// list <EPTF_ExecCtrl_LGenResourceList> to EPTF_ExecCtrl
// component
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
// Replaces f_EPTF_ExecCtrlClient_sendAvailableResourceList
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrlClient_sendEntityResourceInfo() runs on EPTF_ExecCtrlClient_CT
{
f_EPTF_ExecCtrlClient_debug(%definitionId&": started...");
if (v_ExecCtrlClient_byeReceived) {
f_EPTF_ExecCtrlClient_debug(log2str("ResourceInfo not sent: ExecCtrl terminated."));
return;
}
//FIXME Is it required?
//f_EPTF_ExecCtrlClient_debug(log2str("v_LGenBase_entityTypes = ", v_LGenBase_entityTypes));
//f_EPTF_ExecCtrlClient_debug(log2str("v_LGenBase_behaviorTypes = ", v_LGenBase_behaviorTypes));
// FIXME: replace the code below to an LGenBase function call
var EPTF_ExecCtrl_LGenResourceInfoList tmp_rList := {};
var integer minOf_availCount := 0;
// var integer maxOf_usageCount := 0;
var integer minOf_maxCount := 0;
var integer availCount := 0;
// var integer usageCount := 0;
var integer maxCount := 0;
for (var integer i:=0;i<f_EPTF_LGenBase_getETypeCount();i:=i+1) {
tmp_rList[i].eType := f_EPTF_LGenBase_getETypeName(i);
tmp_rList[i].eAvail := f_EPTF_LGenBase_getETypeAvailableByIdx(i);//minOf_availCount;
tmp_rList[i].eMaxCount := f_EPTF_LGenBase_getETypeMaxCountByIdx(i);//minOf_maxCount;
}
f_EPTF_ExecCtrlClient_debug(log2str("tmp_rList = ", tmp_rList));
if (sizeof(tmp_rList)>0) {
f_EPTF_ExecCtrlClient_debug(log2str("Sending resource list: ", tmp_rList));
} else {
f_EPTF_ExecCtrlClient_debug("empty resource list");
}
ExecCtrlClient_MgmtIf_CP.send(EPTF_ExecCtrl_EntityResourceInfo:{
lgenName := f_EPTF_Base_selfName(),
available := tmp_rList
});
f_EPTF_ExecCtrlClient_debug(%definitionId&": finished...");
}
private altstep as_EPTF_ExecCtrlClient_MgmtIf_CreateEntityGrp() runs on EPTF_ExecCtrlClient_CT
{
var EPTF_ExecCtrl_CreateEntityGrp vl_msg;
[] ExecCtrlClient_MgmtIf_CP.receive(EPTF_ExecCtrl_CreateEntityGrp:?) -> value vl_msg
{
f_EPTF_ExecCtrlClient_debug("EPTF_ExecCtrl_CreateEntityGrp received...");
// create Entity Group
var integer myETypeIdx;
myETypeIdx := f_EPTF_LGenBase_entityTypeNameIndex(vl_msg.eType);
if (myETypeIdx<0) {
f_EPTF_ExecCtrlClient_error(log2str("ERROR: unknown entityType in create entity group ",vl_msg,": ", vl_msg.eType));
//f_EPTF_Base_stopAll();
} else {
f_EPTF_ExecCtrlClient_debug(log2str("creating entityGroup: ", vl_msg));
// store entity group data:
f_EPTF_ExecCtrlClient_storeEGrpData(vl_msg);
var integer vl_grpSize := f_EPTF_LGenBase_createEntityGroup(
{
vl_msg.name,
vl_msg.eType,
vl_msg.eCount
}
);
f_EPTF_LGenBase_setTrafficCorrigationForEGrp(vl_msg.name,vl_msg.trafficCorrigation);
f_EPTF_ExecCtrlClient_debug(log2str("size of created entity group ", vl_msg.name, ": ", vl_grpSize));
}
f_EPTF_ExecCtrlClient_sendEntityResourceInfo();
//FIXME
//f_EPTF_ExecCtrlClient_debug(log2str("v_LGenBase_entityGroups = ", v_LGenBase_entityGroups));
repeat;
}
}
// initializes eGrp database
private function f_EPTF_ExecCtrlClient_initEGrpDB()
runs on EPTF_ExecCtrlClient_CT {
v_EPTF_ExecCtrlClient_eGrpHash := f_EPTF_str2int_HashMap_New(c_ExecCtrlClient_eGrpHashMapName);
}
// cleans up eGrp database
private function f_EPTF_ExecCtrlClient_cleanupEGrpDB()
runs on EPTF_ExecCtrlClient_CT {
f_EPTF_str2int_HashMap_Delete(c_ExecCtrlClient_eGrpHashMapName);
v_EPTF_ExecCtrlClient_eGrpHash := c_ExecCtrl_invalidIdx;
}
// stores the offsets of the entityGroup
private function f_EPTF_ExecCtrlClient_storeEGrpData(in EPTF_ExecCtrl_CreateEntityGrp pl_eGrpData) runs on EPTF_ExecCtrlClient_CT {
f_EPTF_str2int_HashMap_Insert(v_EPTF_ExecCtrlClient_eGrpHash, pl_eGrpData.name&".gOffset", pl_eGrpData.gOffset);
f_EPTF_str2int_HashMap_Insert(v_EPTF_ExecCtrlClient_eGrpHash, pl_eGrpData.name&".gCount", pl_eGrpData.gCount);
f_EPTF_str2int_HashMap_Insert(v_EPTF_ExecCtrlClient_eGrpHash, pl_eGrpData.name&".eOffset", pl_eGrpData.eOffset);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrlClient_getFirstEntityGlobalOffset
//
// Purpose:
// returns the global offset of the first entity of the entity group deployed on this LGen
//
// Parameters:
// -
//
// Return Value:
// integer - the global offset of the first entity of the entity group deployed on this LGen, -1 if not found
//
// Errors:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrlClient_getFirstEntityGlobalOffset(in charstring pl_eGrpName)
runs on EPTF_ExecCtrlClient_CT
return integer {
var integer vl_idx := -1;
if (not f_EPTF_str2int_HashMap_Find(
v_EPTF_ExecCtrlClient_eGrpHash,
pl_eGrpName&".eOffset",
vl_idx)) {
f_EPTF_ExecCtrlClient_warning(%definitionId&": Cannot find first entity global offset for entity group "&pl_eGrpName&" in database.");
return -1;
}
return vl_idx;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrlClient_getEntityGroupGlobalOffset
//
// Purpose:
// returns the global offset of the first entity of the entity group
//
// Parameters:
// -
//
// Return Value:
// integer - the global offset of the first entity of the entity group, -1 if not found
//
// Errors:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrlClient_getEntityGroupGlobalOffset(in charstring pl_eGrpName)
runs on EPTF_ExecCtrlClient_CT
return integer {
var integer vl_idx := -1;
if (not f_EPTF_str2int_HashMap_Find(
v_EPTF_ExecCtrlClient_eGrpHash,
pl_eGrpName&".gOffset",
vl_idx)) {
f_EPTF_ExecCtrlClient_warning(%definitionId&": Cannot find global offset for entity group "&pl_eGrpName&" in database.");
return -1;
}
return vl_idx;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrlClient_getFirstEntityOffsetInEGrp
//
// Purpose:
// returns the relative offset of the first entity of the entity group deployed on this LGen in the entity group
//
// Parameters:
// -
//
// Return Value:
// integer - the relative offset of the first entity of the entity group deployed on this LGen in the entity group, -1 if not found
//
// Errors:
// -
//
// Detailed Comments:
// The returned index will be in the range: 0-eGrpSize, or -1 if not found
//
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrlClient_getFirstEntityOffsetInEGrp(in charstring pl_eGrpName)
runs on EPTF_ExecCtrlClient_CT
return integer {
var integer vl_idx := -1;
var integer gOffset := f_EPTF_ExecCtrlClient_getEntityGroupGlobalOffset(pl_eGrpName);
var integer eOffset := f_EPTF_ExecCtrlClient_getFirstEntityGlobalOffset(pl_eGrpName);
if (gOffset==-1 or eOffset==-1) {
f_EPTF_ExecCtrlClient_warning(%definitionId&": Cannot find relative offset of the first entity in the entity group "&pl_eGrpName&" in database.");
return -1;
}
return eOffset-gOffset;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrlClient_getEntityGroupSize
//
// Purpose:
// returns the size of the of the entity group
//
// Parameters:
// -
//
// Return Value:
// integer - the size of the of the entity group, -1 if not found
//
// Errors:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrlClient_getEntityGroupSize(in charstring pl_eGrpName)
runs on EPTF_ExecCtrlClient_CT
return integer {
var integer vl_idx := -1;
if (not f_EPTF_str2int_HashMap_Find(
v_EPTF_ExecCtrlClient_eGrpHash,
pl_eGrpName&".gCount",
vl_idx)) {
f_EPTF_ExecCtrlClient_warning(%definitionId&": Cannot find size for entity group "&pl_eGrpName&" in database.");
return -1;
}
return vl_idx;
}
private altstep as_EPTF_ExecCtrlClient_MgmtIf_CreateEntityGrpList() runs on EPTF_ExecCtrlClient_CT
{
var EPTF_ExecCtrl_CreateEntityGrpList vl_msg;
[] ExecCtrlClient_MgmtIf_CP.receive(EPTF_ExecCtrl_CreateEntityGrpList:?) -> value vl_msg
{
f_EPTF_ExecCtrlClient_debug("EPTF_ExecCtrl_CreateEntityGrpList received...");
for(var integer i:=0; i<sizeof(vl_msg); i:=i+1) {
// create Entity Group
var integer myETypeIdx;
myETypeIdx := f_EPTF_LGenBase_entityTypeNameIndex(vl_msg[i].eType);
if (myETypeIdx<0) {
f_EPTF_ExecCtrlClient_error(log2str("ERROR: unknown entityType in create entity group ",vl_msg[i],": ", vl_msg[i].eType));
//f_EPTF_Base_stopAll();
} else {
f_EPTF_ExecCtrlClient_debug(log2str("creating entityGroup: ", vl_msg[i]));
// store entity group data:
f_EPTF_ExecCtrlClient_storeEGrpData(vl_msg[i]);
var integer vl_grpSize := f_EPTF_LGenBase_createEntityGroup(
{
vl_msg[i].name,
vl_msg[i].eType,
vl_msg[i].eCount
}
);
f_EPTF_LGenBase_setTrafficCorrigationForEGrp(vl_msg[i].name,vl_msg[i].trafficCorrigation);
f_EPTF_ExecCtrlClient_debug(log2str("size of created entity group ", vl_msg[i].name, ": ", vl_grpSize));
}
}
f_EPTF_ExecCtrlClient_sendEntityResourceInfo();
//FIXME
//f_EPTF_ExecCtrlClient_debug(log2str("v_LGenBase_entityGroups = ", v_LGenBase_entityGroups));
repeat;
}
}
private altstep as_EPTF_ExecCtrlClient_MgmtIf_DeclarePhaseLists() runs on EPTF_ExecCtrlClient_CT
{
var EPTF_ExecCtrl_DeclarePhaseLists vl_msg;
[] ExecCtrlClient_MgmtIf_CP.receive(EPTF_ExecCtrl_DeclarePhaseLists:?) -> value vl_msg
{
f_EPTF_ExecCtrlClient_debug("EPTF_ExecCtrl_DeclarePhaseLists received...");
f_EPTF_LGenBase_PhaseList_Declarators_store(vl_msg);
f_EPTF_ExecCtrlClient_debug(log2str("PhaseLists declared ", vl_msg));
repeat;
}
}
private altstep as_EPTF_ExecCtrlClient_MgmtIf_DeclareTcs() runs on EPTF_ExecCtrlClient_CT
{
var EPTF_ExecCtrl_DeclareTcs vl_msg;
[] ExecCtrlClient_MgmtIf_CP.receive(EPTF_ExecCtrl_DeclareTcs:?) -> value vl_msg
{
f_EPTF_ExecCtrlClient_debug("EPTF_ExecCtrl_DeclareTcs received...");
for(var integer i:=0; i<sizeof(vl_msg); i:=i+1) {
// declare traffic case
if (-1==f_EPTF_LGenBase_declareTrafficCaseTypeInternal(vl_msg[i])) {/*to remove the warning*/};
f_EPTF_ExecCtrlClient_debug(log2str("Traffic case declared ", vl_msg[i]));
}
repeat;
}
}
// notifies ExecCtrl that I am ready to run
private function f_EPTF_ExecCtrlClient_readyToRun() runs on EPTF_ExecCtrlClient_CT {
if (v_ExecCtrlClient_byeReceived) {
f_EPTF_ExecCtrlClient_debug(log2str("ReadyToRun not sent: ExecCtrl terminated."));
return;
}
ExecCtrlClient_MgmtIf_CP.send(EPTF_ExecCtrl_ReadyToRun:{});
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrlClient_checkEndOfConfig
//
// Purpose:
// Returns true when the configuration of the ExecCtrlClient is finished,
// and all scenarioInitializedCallback function registered by <f_EPTF_ExecCtrlClient_set_scenarioInitialized_fcb>
// finished its operation
//
// Parameters:
// -
//
// Return Value:
// boolean - true when the configuration of the ExecCtrlClient is finished
//
// Errors:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrlClient_checkEndOfConfig() runs on EPTF_ExecCtrlClient_CT return boolean {
return (v_ExecCtrlClient_semaphore_EndOfConfig and v_ExecCtrlClient_semaphore_DeclareScenario==0);
}
private altstep as_EPTF_ExecCtrlClient_MgmtIf_handleEndOfConfig() runs on EPTF_ExecCtrlClient_CT {
var EPTF_ExecCtrl_EndOfConfig vl_msg;
[] ExecCtrlClient_MgmtIf_CP.receive(EPTF_ExecCtrl_EndOfConfig:?) -> value vl_msg {
if(f_EPTF_Base_cleanupIsInProgress()){
// cleanup is not in progress.
f_EPTF_ExecCtrlClient_debug("EPTF_ExecCtrl_EndOfConfig received...");
v_ExecCtrlClient_semaphore_EndOfConfig := true;
f_EPTF_LGenBase_setDataSource(vl_msg.dataSourceCompRef);
} else {
// cleanup is in progress.
f_EPTF_ExecCtrlClient_debug("EPTF_ExecCtrl_EndOfConfig received, but cleanup is already running...");
}
repeat;
}
// wait until all scenarios are created and EPTF_ExecCtrl_EndOfConfig is received:
[f_EPTF_ExecCtrlClient_checkEndOfConfig()] t_EPTF_ExecCtrlClient_semaphoreTimer.timeout {
f_EPTF_ExecCtrlClient_debug("All scenarios are declared, configuration ended.");
// all scenarios are ready.
f_EPTF_ExecCtrlClient_callEndOfConfigCallbacks();
f_EPTF_ExecCtrlClient_readyToRun();
repeat;
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrlClient_checkGuiDone
//
// Purpose:
// Returns true when the creation of the GUI is finished
//
// Parameters:
// -
//
// Return Value:
// boolean - true when the creation of the GUI is finished
//
// Errors:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrlClient_checkGuiDone()
runs on EPTF_ExecCtrlClient_CT
return boolean {
return v_EPTF_ExecCtrlClient_guiDone;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrlClient_checkGuiDoneReported
//
// Purpose:
// Returns true when the GUIDone was reported to ExecCtrl by <f_EPTF_ExecCtrlClient_reportGUIDone>
//
// Parameters:
// -
//
// Return Value:
// boolean - true when the creation of the GUI is finished
//
// Errors:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrlClient_checkGuiDoneReported()
runs on EPTF_ExecCtrlClient_CT
return boolean {
return v_EPTF_ExecCtrlClient_guiDoneReported;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrlClient_reportGUIDone
//
// Purpose:
// Reports GUIDone to ExecCtrl
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrlClient_reportGUIDone() runs on EPTF_ExecCtrlClient_CT {
if (v_EPTF_ExecCtrlClient_guiDoneReported or not v_EPTF_ExecCtrlClient_guiDone) {
return; // prevent reporting multiple times or before ExecCtrl GUI is ready
}
if (not v_ExecCtrlClient_byeReceived) {
ExecCtrlClient_MgmtIf_CP.send(EPTF_ExecCtrl_GuiDone:{v_EPTF_ExecCtrlClient_guiPresent});
} else {
f_EPTF_ExecCtrlClient_debug(log2str("GUIDone not sent: ExecCtrl terminated."));
}
v_EPTF_ExecCtrlClient_guiDoneReported := true;
}
private altstep as_EPTF_ExecCtrlClient_MgmtIf_handleGuiDone() runs on EPTF_ExecCtrlClient_CT {
var EPTF_ExecCtrl_GuiDone vl_guiDone;
[] ExecCtrlClient_MgmtIf_CP.receive(EPTF_ExecCtrl_GuiDone:?) -> value vl_guiDone {
v_EPTF_ExecCtrlClient_guiPresent := vl_guiDone.guiPresent;
f_EPTF_ExecCtrlClient_debug("EPTF_ExecCtrl_GuiDone received...");
f_EPTF_ExecCtrlClient_callGuiDoneCallbackForFSMStats();
// call user callbacks:
f_EPTF_ExecCtrlClient_callGuiDoneCallbacks();
v_EPTF_ExecCtrlClient_guiDone := true;
// send gui done to execCtrl to synchronize:
if (v_EPTF_ExecCtrlClient_autoReportGuiDone) {
f_EPTF_ExecCtrlClient_reportGUIDone(); // GUIDone is reported automatically
}
repeat;
}
}
friend function f_EPTF_ExecCtrlClient_guiPresent() runs on EPTF_ExecCtrlClient_CT return boolean {
return v_EPTF_ExecCtrlClient_guiPresent
}
private function f_EPTF_ExecCtrlClient_createScenarioStatusVar(in charstring pl_eGrpName, in charstring pl_scName) runs on EPTF_ExecCtrlClient_CT {
// create new alias variable for scenario status:
var charstring vl_varName := "ExecCtrlClient.scenarioStatus."&pl_eGrpName&"."&pl_scName;
var integer vl_idx;
vl_idx := f_EPTF_Var_getId(vl_varName);
if (vl_idx != -1) {
return; // already exists
}
f_EPTF_Var_newCharstring(vl_varName,"",vl_idx);
// connect it to the LGenBaseStats scenario state:
var charstring vl_varNameBase := f_EPTF_LGenBaseStats_getScNamePrefix(pl_eGrpName,pl_scName);
vl_varName := vl_varNameBase&c_EPTF_LGenBaseStats_nameOfScStateName;
var integer vl_lgenBaseVarIdx := f_EPTF_Var_getId(vl_varName);
// this is never true, but kept for safety:
if (vl_lgenBaseVarIdx==-1) {
f_EPTF_ExecCtrlClient_debug(log2str("You should not see this: ", vl_varName, "!"));
f_EPTF_Var_adjustContent(vl_idx,{charstringVal := "StateUpdateError"});
return;
}
f_EPTF_Var_subscribeLocal(
vl_idx,
{
calcFn := {
funcRef := refers(f_EPTF_ExecCtrlClient_scenarioStateCalcFn),
argList := {vl_lgenBaseVarIdx},
nonVarArgList := {}
}
}
);
}
private function f_EPTF_ExecCtrlClient_createTrafficCaseStatusVar(in charstring pl_eGrpName, in charstring pl_scName, in charstring pl_tcName) runs on EPTF_ExecCtrlClient_CT {
// create new alias variable for scenario status:
var charstring vl_varName := "ExecCtrlClient.trafficCaseStatus."&pl_eGrpName&"."&pl_scName&"."&pl_tcName;
var integer vl_idx;
vl_idx := f_EPTF_Var_getId(vl_varName);
if (vl_idx != -1) {
return; // already exists
}
f_EPTF_Var_newCharstring(vl_varName,"",vl_idx);
// connect it to the LGenBaseStats scenario state:
var charstring vl_varNameBase := f_EPTF_LGenBaseStats_getNamePrefix(pl_eGrpName,pl_scName,pl_tcName);
vl_varName := vl_varNameBase&c_EPTF_LGenBaseStats_nameOfTcStateName;
var integer vl_lgenBaseVarIdx := f_EPTF_Var_getId(vl_varName);
// this is never true, but kept for safety:
if (vl_lgenBaseVarIdx==-1) {
f_EPTF_ExecCtrlClient_debug(log2str("You should not see this: ", vl_varName, "!"));
f_EPTF_Var_adjustContent(vl_idx,{charstringVal := "StateUpdateError"});
return;
}
f_EPTF_Var_subscribeLocal(
vl_idx,
{
calcFn := {
funcRef := refers(f_EPTF_ExecCtrlClient_scenarioStateCalcFn),
argList := {vl_lgenBaseVarIdx},
nonVarArgList := {}
}
}
);
}
private function f_EPTF_ExecCtrlClient_declareScenario(in EPTF_LGenBase_ScenarioTypeInternalDeclarator vl_scType, in EPTF_ExecCtrl_NamesInScenario pl_scNames) runs on EPTF_ExecCtrlClient_CT {
/*
// convert universal declarator to decl2 or weighted decl:
if (ispresent(vl_scType.weightedScData)) {
var EPTF_ExecCtrl_DeclareScenario3 vl_declareScenario3 := {
name := vl_scType.name,
enabled := vl_scType.enabled,
cpsToReach := vl_scType.weightedScData.cpsToReach,
lockCPS := false,
weightedScData := {
deterministicMix := vl_scType.weightedScData.deterministicMix
},
tcList := {}
};
for(var integer tc:=0; tc<sizeof(vl_scType.tcList);tc:=tc+1) {
vl_declareScenario3.tcList[tc] := {
tcName := pl_scNames.tcNames[tc],
//float startDelay,
tcWeight := vl_scType.tcList[tc].target.trafficWeight,
enableEntities := vl_scType.tcList[tc].enableEntities,
enable := vl_scType.tcList[tc].enable,
ranges := vl_scType.tcList[tc].ranges,
params := vl_scType.tcList[tc].params,
//finishConditions
groupFinishConditions := vl_scType.tcList[tc].groupFinishConditions,
entityFinishConditions := vl_scType.tcList[tc].entityFinishConditions,
//actionLists
entityFinishActions := vl_scType.tcList[tc].entityFinishActions,
tcFinishActions := vl_scType.tcList[tc].tcFinishActions
}
}
f_EPTF_LGenBase_declareWeightedScenarioType(vl_declareScenario3);
} else {
var EPTF_ExecCtrl_DeclareScenario2 vl_declareScenario2 := {
name := vl_scType.name,
tcList := {}
};
for(var integer tc:=0; tc<sizeof(vl_scType.tcList);tc:=tc+1) {
vl_declareScenario2.tcList[tc] := {
tcName := pl_scNames.tcNames[tc],
startDelay := vl_scType.tcList[tc].startDelay,
cpsToReach := vl_scType.tcList[tc].target.cpsToReach,
enableEntities := vl_scType.tcList[tc].enableEntities,
enable := vl_scType.tcList[tc].enable,
ranges := vl_scType.tcList[tc].ranges,
params := vl_scType.tcList[tc].params,
//finishConditions
groupFinishConditions := vl_scType.tcList[tc].groupFinishConditions,
entityFinishConditions := vl_scType.tcList[tc].entityFinishConditions,
//actionLists
entityFinishActions := vl_scType.tcList[tc].entityFinishActions,
tcFinishActions := vl_scType.tcList[tc].tcFinishActions
}
}
f_EPTF_LGenBase_declareScenarioType2(vl_declareScenario2);
}
*/
// declare scenario using the latest declararor type:
f_EPTF_ExecCtrlClient_debug(log2str("Declaring Scenario ", vl_scType, " names: ", pl_scNames));
v_ExecCtrlClient_semaphore_DeclareScenario := v_ExecCtrlClient_semaphore_DeclareScenario + 1;
if (-1==f_EPTF_LGenBase_declareScenarioTypeInternal(vl_scType)) {
/*to remove the warning*/
}
f_EPTF_LGenBase_createScenario2EntityGroup(
{pl_scNames.eGrpName,pl_scNames.scTypeName},
false
);
if (v_ExecCtrlClient_scenarioInitialized_fcb!=null) {
f_EPTF_ExecCtrlClient_debug(log2str("Calling callback fn: ", v_ExecCtrlClient_scenarioInitialized_fcb));
v_ExecCtrlClient_scenarioInitialized_fcb.apply({pl_scNames.eGrpName,pl_scNames.scTypeName});
}
v_ExecCtrlClient_semaphore_DeclareScenario := v_ExecCtrlClient_semaphore_DeclareScenario - 1;
f_EPTF_ExecCtrlClient_debug(log2str("Scenario ", pl_scNames.scTypeName, " added to eGrp: ", pl_scNames.eGrpName));
}
private altstep as_EPTF_ExecCtrlClient_MgmtIf_CreateScenario() runs on EPTF_ExecCtrlClient_CT
{
var EPTF_ExecCtrl_CreateScenario vl_msg;
[] ExecCtrlClient_MgmtIf_CP.receive(EPTF_ExecCtrl_CreateScenario:?) -> value vl_msg
{
f_EPTF_ExecCtrlClient_debug("EPTF_ExecCtrl_CreateScenario received...");
for(var integer sc:=0; sc<sizeof(vl_msg.scList); sc:=sc+1) {
f_EPTF_ExecCtrlClient_declareScenario(vl_msg.scList[sc],vl_msg.scNames[sc]);
f_EPTF_ExecCtrlClient_createScenarioStatusVar(vl_msg.scNames[sc].eGrpName,vl_msg.scNames[sc].scTypeName);
for(var integer tc:=0; tc<sizeof(vl_msg.scNames[sc].tcNames);tc:=tc+1) {
f_EPTF_ExecCtrlClient_createTrafficCaseStatusVar(vl_msg.scNames[sc].eGrpName,vl_msg.scNames[sc].scTypeName,vl_msg.scNames[sc].tcNames[tc]);
}
}
repeat;
}
}
// R3: final test report generation
group EPTF_ExecCtrlClient_FinalTestReport {
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrlClient_registerFinalTestReportGeneratorFn
//
// Purpose:
// registers callback function to generate final test report
//
// Parameters:
// pl_reportGeneratorFn - in <EPTF_ExecCtrl_FinalTestReportGenerator_FT> - the report generator fn to register
//
// Return Value:
//
// Errors:
//
// Detailed Comments:
// called when the end of test execution detected:
// exit event detected in any of the LGens, or the Exit button pressed
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrlClient_registerFinalTestReportGeneratorFn(in EPTF_ExecCtrl_FinalTestReportGenerator_FT pl_reportGeneratorFn)
runs on EPTF_ExecCtrlClient_CT {
v_EPTF_ExecCtrlClient_finalTestReportGeneratorFns[sizeof(v_EPTF_ExecCtrlClient_finalTestReportGeneratorFns)] := pl_reportGeneratorFn;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrlClient_deregisterFinalTestReportGeneratorFn
//
// Purpose:
// removes the callback function registered earlier by <f_EPTF_ExecCtrl_registerFinalTestReportGeneratorFn>
//
// Parameters:
// pl_reportGeneratorFn - in <EPTF_ExecCtrl_FinalTestReportGenerator_FT> - the report generator fn to deregister
//
// Return Value:
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrlClient_deregisterFinalTestReportGeneratorFn(in EPTF_ExecCtrl_FinalTestReportGenerator_FT pl_reportGeneratorFn)
runs on EPTF_ExecCtrlClient_CT {
for(var integer i:=0; i<sizeof(v_EPTF_ExecCtrlClient_finalTestReportGeneratorFns); i:=i+1) {
if(v_EPTF_ExecCtrlClient_finalTestReportGeneratorFns[i]==pl_reportGeneratorFn) {
v_EPTF_ExecCtrlClient_finalTestReportGeneratorFns[i] := null;
}
}
}
// calls all F.T.R. generator functions
private function f_EPTF_ExecCtrlClient_callFinalTestReportGeneratorFns(inout charstring pl_report)
runs on EPTF_ExecCtrlClient_CT {
for(var integer i:=0; i<sizeof(v_EPTF_ExecCtrlClient_finalTestReportGeneratorFns); i:=i+1) {
if(v_EPTF_ExecCtrlClient_finalTestReportGeneratorFns[i]!=null) {
f_EPTF_ExecCtrlClient_debug(log2str(%definitionId&": Calling final test report generator function: ",v_EPTF_ExecCtrlClient_finalTestReportGeneratorFns[i]));
v_EPTF_ExecCtrlClient_finalTestReportGeneratorFns[i].apply(pl_report);
f_EPTF_ExecCtrlClient_debug(log2str(%definitionId&": Final test report generator function finished: ",v_EPTF_ExecCtrlClient_finalTestReportGeneratorFns[i]));
}
}
}
// sends EofTest request to ExecCtrl
private function f_EPTF_ExecCtrlClient_sendEofTest()
runs on EPTF_ExecCtrlClient_CT {
if (v_ExecCtrlClient_byeReceived) {
f_EPTF_ExecCtrlClient_debug(log2str("EofTest not sent: ExecCtrl terminated."));
return;
}
ExecCtrlClient_MgmtIf_CP.send(EPTF_ExecCtrl_EofTest:{});
}
// sends EofTestDone to ExecCtrl
private function f_EPTF_ExecCtrlClient_sendEofTestDone(in charstring pl_reportMsg)
runs on EPTF_ExecCtrlClient_CT {
if (v_ExecCtrlClient_byeReceived) {
f_EPTF_ExecCtrlClient_debug(log2str("EofTestDone not sent: ExecCtrl terminated."));
return;
}
ExecCtrlClient_MgmtIf_CP.send(EPTF_ExecCtrl_EofTestDone:{pl_reportMsg});
}
private function f_EPTF_ExecCtrlClient_testFinishedListener(
EPTF_LGenBase_ReportedEventDescriptor pl_event,
EPTF_IntegerList pl_listenerArgs)
runs on EPTF_ExecCtrlClient_CT{
//v_ExecCtrlClient_testFinished := true;
f_EPTF_ExecCtrlClient_debug(log2str("Test finished in ",f_EPTF_Base_selfName()));
// send EofTest to ExecCtrl
f_EPTF_ExecCtrlClient_sendEofTest();
}
// handles EofTest/EofTestDone messages coming from the ExecCtrl
private altstep as_EPTF_ExecCtrlClient_MgmtIf_EofTest() runs on EPTF_ExecCtrlClient_CT
{
var EPTF_ExecCtrl_EofTest vl_msg;
[] ExecCtrlClient_MgmtIf_CP.receive(EPTF_ExecCtrl_EofTest:?) -> value vl_msg {
var charstring vl_reportMsg := "";
f_EPTF_ExecCtrlClient_callFinalTestReportGeneratorFns(vl_reportMsg);
f_EPTF_ExecCtrlClient_sendEofTestDone(vl_reportMsg);
repeat;
}
}
}
} // group R3
} // module