blob: c45e396ef2865dd9ef021d66a0c464bc6d3d3579 [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_ExecCtrl_Functions
//
// Purpose:
// This module contains the implementation of EPTF_CLL_ExecCtrl functions.
//
// Module depends on:
// <EPTF_CLL_Common_Definitions>
// <EPTF_CLL_Base_Functions>
// <EPTF_CLL_FBQ_Definitions>
// <EPTF_CLL_LGenBase_Definitions>
// <EPTF_CLL_LGenBase_ConfigDefinitions>
// <EPTF_CLL_LGenBase_ConfigFunctions>
// <EPTF_CLL_LGenBase_PhaseDefinitions>
// <EPTF_CLL_ExecCtrl_Definitions>
// <EPTF_CLL_ExecCtrlTimeProfile_Definitions>
// <EPTF_CLL_ExecCtrl_ScenarioFunctions>
// <EPTF_CLL_ExecCtrl_LoggingFunctions>
// <EPTF_CLL_HashMapStr2Int_Functions>
// <EPTF_CLL_HashMapInt2Int_Functions>
// <EPTF_CLL_Scheduler_Definitions>
// <EPTF_CLL_RBTScheduler_Functions>
// <EPTF_CLL_Variable_Definitions>
// <EPTF_CLL_Variable_Functions>
// <EPTF_CLL_LGenBaseStats_Definitions>
// <EPTF_CLL_LGenBaseStats_Functions>
// <EPTF_CLL_Logging_Definitions>
// <EPTF_CLL_Logging_Functions>
// <EPTF_CLL_ExecCtrl_ScenarioDefinitions>
// <EPTF_CLL_ExecCtrlClient_Functions>
// <EPTF_CLL_ExecCtrl_PhaseFunctions>
// <EPTF_CLL_StatMeasure_Functions>
// <EPTF_CLL_StatHandler_Functions>
// <EPTF_CLL_StatHandlerClient_Functions>
// <EPTF_CLL_StatHandlerClient_Definitions>
// <TCCFileIO_Functions>
// <TCCDateTime_Functions>
// <EPTF_CLL_HashMap_Functions>
//
// Module Parameters:
// tsp_debug_EPTF_ExecCtrl_Functions - boolean - enable/disable debug logs
// tsp_EPTF_ExecCtrl_maxKillTime - float - max time to wait for all LGens to stop
// tsp_EPTF_ExecCtrl_finalTestReportFile - charstring - name of the file where the final test report is saved. Default: EPTF_ExecCtrl_FinalTestReport_%Y-%m-%d_%H.%M.%S.txt
// tsp_EPTF_ExecCtrl_UIHandler_disableAutoEnablingOfManualControlModeWhenStopButtonIsPressed - *boolean* - Disable to return to manual control mode when stop button is pressed
//
// Current Owner:
// Jozsef Gyurusi (ethjgi)
//
// Last Review Date:
// 2009-02-03
//
// Detailed Comments:
// This module contains the interface functions for the EPTF_CLL_ExecCtrl.
//
// Public functions:
// <f_EPTF_ExecCtrl_init_CT>
// <f_EPTF_ExecCtrl_checkManualLGenStarted> *new
// <f_EPTF_ExecCtrl_start>
// <f_EPTF_ExecCtrl_getManualControl>
// <f_EPTF_ExecCtrl_setManualControl>
// <f_EPTF_ExecCtrl_getTimePeriodForTcDeltaStats>
// <f_EPTF_ExecCtrl_setTimePeriodForTcDeltaStats>
// <f_EPTF_ExecCtrl_loadConfig>
// <f_EPTF_ExecCtrl_checkReadyToRun>
// <f_EPTF_ExecCtrl_waitForCondition>
// <f_EPTF_ExecCtrl_setTimeFormat>
// <f_EPTF_ExecCtrl_startTimeProfiles>
// <f_EPTF_ExecCtrl_stopTimeProfiles>
// <f_EPTF_ExecCtrl_startAllScenarios>
// <f_EPTF_ExecCtrl_startAllScenarioGroups>
// <f_EPTF_ExecCtrl_stopAllScenarioGroups>
// <f_EPTF_ExecCtrl_terminateAllScenarioGroups> *new
// <f_EPTF_ExecCtrl_stopCurrentPhaseForAllScenarioGroups>
// <f_EPTF_ExecCtrl_stopAllScenarios>
// <f_EPTF_ExecCtrl_terminateAllScenarios> *new
// <f_EPTF_ExecCtrl_checkAllScenarios> *new
// <f_EPTF_ExecCtrl_setCps_TC>
// <f_EPTF_ExecCtrl_setCps_SC>
// <f_EPTF_ExecCtrl_getCPSToReach_TC>
// <f_EPTF_ExecCtrl_setCPSToReach_TC>
// <f_EPTF_ExecCtrl_getCPSToReach_SC>
// <f_EPTF_ExecCtrl_setCPSToReach_SC>
// <f_EPTF_ExecCtrl_getTCWeight>
// <f_EPTF_ExecCtrl_setTCWeight>
// <f_EPTF_ExecCtrl_Regulator_addRegulator>
// <f_EPTF_ExecCtrl_Regulator_getRegulatorId>
// <f_EPTF_ExecCtrl_Regulator_setTotalCps>
// <f_EPTF_ExecCtrl_Regulator_getTotalCps>
// <f_EPTF_ExecCtrl_Regulator_getRegulatedItemId>
// <f_EPTF_ExecCtrl_Regulator_getRegulatorName>
// <f_EPTF_ExecCtrl_Regulator_setRegulatorName>
// <f_EPTF_ExecCtrl_Regulator_logAll>
// <f_EPTF_ExecCtrl_registerScenarioStateChangedCallback>
// <f_EPTF_ExecCtrl_registerTrafficCaseStateChangedCallback>
// <f_EPTF_ExecCtrl_enableStartStopScenario>
// <f_EPTF_ExecCtrl_disableStartStopScenario>
// <f_EPTF_ExecCtrl_scenarioIsNotInScenarioGroup>
// <f_EPTF_ExecCtrl_isDisabledStartStopScenario>
// <f_EPTF_ExecCtrl_getStartStopScenarioIdx>
// <f_EPTF_ExecCtrl_enableStartStopTC>
// <f_EPTF_ExecCtrl_disableStartStopTC>
// <f_EPTF_ExecCtrl_isDisabledStartStopTC>
// <f_EPTF_ExecCtrl_getStartStopTCIdx>
// <f_EPTF_ExecCtrl_startScenarioOnLGens>
// <f_EPTF_ExecCtrl_stopScenarioOnLGens>
// <f_EPTF_ExecCtrl_resetScenarioOnLGens>
// <f_EPTF_ExecCtrl_stopScenarioGroupOnLGens>
// <f_EPTF_ExecCtrl_startTCOnLGens>
// <f_EPTF_ExecCtrl_stopTCOnLGens>
// <f_EPTF_ExecCtrl_singleShotTc>
// <f_EPTF_ExecCtrl_scenarioEnabled>
// <f_EPTF_ExecCtrl_behavior>
// <f_EPTF_ExecCtrl_exit>
// <f_EPTF_ExeCtrl_enableUIHandlerProgress>
// <f_EPTF_ExecCtrl_resetFSMStat>
// <f_EPTF_ExecCtrl_LGenPool_createLGens>
// <f_EPTF_ExecCtrl_nrOfClients>
// <f_EPTF_ExecCtrl_LGenPool_dumpInstanceDB>
// <f_EPTF_ExecCtrl_addLGenFunctionsFromDeclarators>
// <f_EPTF_ExecCtrl_getLGenCompRefsOfPool>
// <f_EPTF_ExecCtrl_checkCreatorFnNameOfPool>
// <f_EPTF_ExecCtrl_registerFinalTestReportGeneratorFn>
// <f_EPTF_ExecCtrl_deregisterFinalTestReportGeneratorFn>
// <f_EPTF_ExecCtrl_generateFinalTestReport>
// <f_EPTF_ExecCtrl_registerFSMStatsCreatedCallback>
// <f_EPTF_ExecCtrl_deregisterFSMStatsCreatedCallback>
// <f_EPTF_ExecCtrl_getFSMStatisticsOfTcs>
// <f_EPTF_ExecCtrl_setStartDelay_TC>
// <f_EPTF_ExecCtrl_startScenarioOnLGensByName>
// <f_EPTF_ExecCtrl_stopScenarioOnLGensByName>
// <f_EPTF_ExecCtrl_Regulator_findRegulatorsForScenario>
// <f_EPTF_ExecCtrl_StatHandler_getVarIdx>
// <f_EPTF_ExecCtrl_StatHandler_getVarNameByStatName>
// <f_EPTF_ExecCtrl_StatHandler_getAuxVars>
//
// All other functions in this module are private!
//
///////////////////////////////////////////////////////////////
module EPTF_CLL_ExecCtrl_Functions {
//=========================================================================
// Import Part
//=========================================================================
import from EPTF_CLL_Common_Definitions all;
import from EPTF_CLL_Base_Functions all;
import from EPTF_CLL_LGenBase_Definitions all;
import from EPTF_CLL_LGenBase_ConfigDefinitions all;
import from EPTF_CLL_LGenBase_ConfigFunctions all;
import from EPTF_CLL_LGenBase_PhaseDefinitions all;
import from EPTF_CLL_ExecCtrl_Definitions all;
import from EPTF_CLL_ExecCtrlTimeProfile_Definitions all;
import from EPTF_CLL_ExecCtrl_ScenarioFunctions all;
import from EPTF_CLL_ExecCtrl_LoggingFunctions all;
import from EPTF_CLL_HashMapStr2Int_Functions all;
import from EPTF_CLL_HashMapInt2Int_Functions all;
import from EPTF_CLL_Scheduler_Definitions all;
import from EPTF_CLL_RBTScheduler_Functions all;
import from EPTF_CLL_Variable_Definitions all;
import from EPTF_CLL_Variable_Functions all;
import from EPTF_CLL_LGenBaseStats_Definitions all;
import from EPTF_CLL_LGenBaseStats_Functions all;
import from EPTF_CLL_Logging_Definitions all;
import from EPTF_CLL_Logging_Functions all;
import from EPTF_CLL_ExecCtrl_ScenarioDefinitions all;
import from EPTF_CLL_ExecCtrl_PhaseDefinitions all;
import from EPTF_CLL_ExecCtrl_PhaseFunctions all;
import from EPTF_CLL_ExecCtrl_DSFunctions all;
import from EPTF_CLL_StatMeasure_Functions all;
import from EPTF_CLL_StatHandler_Definitions all;
import from EPTF_CLL_StatHandler_Functions all;
import from EPTF_CLL_StatHandlerClient_Functions all;
import from EPTF_CLL_StatHandlerClient_Definitions all;
import from EPTF_CLL_StatManager_Functions all;
import from TCCFileIO_Functions all;
import from TCCDateTime_Functions all;
import from EPTF_CLL_DataSource_Definitions all;
import from EPTF_CLL_DataSourceClient_Functions all;
import from EPTF_CLL_HashMap_Functions all;
import from EPTF_CLL_FBQ_Functions all;
friend module EPTF_CLL_ExecCtrlUIHandler_Functions, EPTF_CLL_ExecCtrl_DSFunctions;
friend module EPTF_CLL_ExecCtrlClient_Functions;
//modulepar boolean tsp_EPTF_ExecCtrl_StatHandler_wait4response := true; // sets the StatHandler Wait4Resp flag
//=========================================================================
// Functions
//========================================================================
///////////////////////////////////////////////////////////
// Group: EPTF_ExecCtrl
//
// Purpose:
// Functions related to EPTF_ExecCtrl feature
//
///////////////////////////////////////////////////////////
group EPTF_ExecCtrl {
modulepar boolean tsp_debug_EPTF_ExecCtrl_Functions := false;
modulepar float tsp_EPTF_ExecCtrl_maxKillTime := 30.0; // max time to wait for all LGens to stop
modulepar charstring tsp_EPTF_ExecCtrl_finalTestReportFile := "EPTF_ExecCtrl_FinalTestReport_%Y-%m-%d_%H.%M.%S.txt"; // name of the file where the final test report is saved. Default: EPTF_ExecCtrl_FinalTestReport_%Y-%m-%d_%H.%M.%S.txt
// Set it to empty string to disable final test report generation
modulepar boolean tsp_EPTF_ExecCtrl_generateOwnReport := true; // If enabled ExecCtrl will write the traffic case statistics into the final test report. Default: true
const charstring c_EPTF_ExecCtrl_Regulator_totalValue := "Regulator.totalValue"; // name of the variable that indicates the regulator targetLoad
const charstring c_EPTF_ExecCtrl_Regulator_targetLoad := "Regulator.targetLoad"; // name of the variable that indicates the regulator targetLoad
const charstring c_EPTF_ExecCtrl_Regulator_currentLoad := "Regulator.currentLoad"; // name of the variable that indicates the regulator currentLoad
const charstring c_EPTF_ExecCtrl_Regulator_status := "Regulator.status"; // name of the variable that indicates the regulator status
const charstring c_EPTF_ExecCtrl_Regulator_enable := "Regulator.enable"; // name of the variable that indicates the regulator enable flag
modulepar boolean tsp_EPTF_ExecCtrl_UIHandler_disableAutoEnablingOfManualControlModeWhenStopButtonIsPressed := false;
const EPTF_StatusLED c_EPTF_ExecCtrl_UIVars_StatusLED_init := { color := led_black, text := "NA" };
const EPTF_StatusLED c_EPTF_ExecCtrl_UIVars_GroupFinishCondStatusLED_init := { color := led_black, text := " -- " };
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_init_CT
//
// Purpose:
// Init EPTF_ExecCtrl feature
//
// Parameters:
// - pl_selfName - *in charstring* - the name of the component
// - pl_nrOfClients - *in integer* - the number of the <EPTF_ExecCtrlClient_CT> components created by the user
// (this is the size of the default pool)
// - pl_createLGenPools - *in boolean - if true, LGens in LGens pools are created automatically during init, otherwise
// the function <f_EPTF_ExecCtrl_LGenPool_createLGens> has to be called after the init function. Default: true
// - pl_loadModulepars - *in boolean - if true, module parameters are automatically loaded. Default: true
// - pl_autoStart - *in boolean - if true, ExecCtrl is started automatically by calling <f_EPTF_ExecCtrl_start>. Default: true
// - pl_dataSource_compRef - *in* <EPTF_DataSource_CT> - DataSource component reference. Optional, if given, ExecCtrl will be able to behave
// as a DataSource Client. It means that datas can be requested from it and it will provide them in variables. This component can
// be for example the UIHandler component.
// - pl_nofExternalStatHandlers - *in integer* - if >0: ExecCtrl TC and FSM statistics will be calculated on a separate StatHandler component,
// for 0: ExecCtrl will calculate the stats
// Note, that using external StatHandler component increases the internal traffic on the Variable interface (between ExecCtrl and StatHandler)
// Default: 0, which means that ExecCtrl will use its internal StatHandler (No extra internal traffic)
// - pl_usePullModeForStats - *in* *boolean* - If true pull mode is used for StatHandler statistics (default: false)
//
// Return Value:
// -
//
// Errors & assertions:
// - pl_nrOfClients shall be non-negative.
//
// Detailed Comments:
// The pl_nrOfClients parameter shall specify the number of LGens in the default LGen pool.
// The default LGen pool is the collection of LGens created by the user.
// All other LGens are created automatically by the LGenPool functionality, and
// the number of those LGens should not be added to this parameter.
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_init_CT
(
in charstring pl_selfName,
in integer pl_nrOfClients,
in boolean pl_createLGenPools := true,
in boolean pl_loadModulepars := true,
in boolean pl_autoStart := true,
in EPTF_DataSource_CT pl_dataSource_compRef := null,
in integer pl_nofExternalStatHandlers := 0,
in boolean pl_usePullModeForStats := false
) runs on EPTF_ExecCtrl_CT {
if (v_ExecCtrl_initialized) {
return; // already initialized
}
v_ExecCtrl_initialized := true; // should be here to prevent cleanup from not being called
v_ExecCtrl_readyToRun := false;
v_ExecCtrl_allLGensCreated := false;
v_EPTF_ExecCtrl_startTime := -1.0;
v_EPTF_ExecCtrl_timeFormat := tsp_EPTF_ExecCtrl_timeFormat;
v_EPTF_ExecCtrl_ScenarioGroupPhaseChangedCallbackFns := {};
v_EPTF_ExecCtrl_ScenarioStateChangedCallbackFns := {};
v_EPTF_ExecCtrl_TrafficCaseStateChangedCallbackFns := {};
v_EPTF_ExecCtrl_onGroupFinishCallbackFns := {};
v_EPTF_ExecCtrl_finalTestReportGeneratorFns := {};
v_EPTF_ExecCtrl_finalTestReport := "";
if (tsp_EPTF_ExecCtrl_generateOwnReport) {
f_EPTF_ExecCtrl_setGenerateOwnReport(true);
}
v_ExecCtrl_endOfTest := false;
v_ExecCtrl_pendingMsgCounter := 0;
v_ExecCtrl_pendingByeCounter := 0;
v_ExecCtrl_FSMStats := {};
v_EPTF_ExecCtrl_fsmStatsCreatedCallbackFns := {};
v_ExecCtrl_processingCreateFSMStats := false;
v_ExecCtrl_progressBarUIHandler_Idx := -1;
v_ExecCtrl_progressEnabled := true;
v_ExecCtrl_progressBarUIHandler_updateSent := false;
f_EPTF_Base_init_CT(pl_selfName);
f_EPTF_FBQ_init_CT(pl_selfName);
f_EPTF_Var_init_CT(pl_selfName);
f_EPTF_StatMeasure_init_CT(pl_selfName);
v_ExecCtrl_dataSourceCompRef := pl_dataSource_compRef;
v_EPTF_ExecCtrl_nofExternalStatHandlers := pl_nofExternalStatHandlers;
v_EPTF_ExecCtrl_statHandler_comprefList := {};
v_EPTF_ExecCtrl_statHandler_autoSelector := 0;
v_ExecCtrl_statHandlerHash := f_EPTF_str2int_HashMap_New(c_ExecCtrl_statHandlerHashMapName);
v_ExecCtrl_usePullModeForStats := pl_usePullModeForStats;
f_ExecCtrl_ExternalStatHandler_startNew();
f_EPTF_StatHandlerClient_init_CT(pl_selfName);
f_EPTF_Scheduler_init_CT(pl_selfName);
f_EPTF_Logging_init_CT(pl_selfName);
f_EPTF_HashMap_init_CT (pl_selfName);
f_EPTF_DataSourceClient_init_CT(pl_selfName, pl_dataSource_compRef);
v_ExecCtrl_regulatedItemsHash := f_EPTF_str2int_HashMap_New(c_ExecCtrl_regulatedItemsHashMapName);
if(pl_dataSource_compRef != null){
v_ExecCtrl_dataSourceCompRef := pl_dataSource_compRef;
f_EPTF_DataSourceClient_registerSetDataValue(c_ExecCtrl_DataSource_sourceId, f_EPTF_Base_selfName(), refers(f_EPTF_ExecCtrl_DSProcessSetDataValue));
f_EPTF_DataSourceClient_registerData(c_ExecCtrl_DataSource_sourceId, f_EPTF_Base_selfName(), refers(f_EPTF_ExecCtrl_DSProcessData));
f_EPTF_DataSourceClient_registerDataValue(c_ExecCtrl_DataSource_sourceId, f_EPTF_Base_selfName(), refers(f_EPTF_ExecCtrl_DSProcessDataValue), pl_dataSource_compRef);
f_EPTF_DataSourceClient_registerCondition(c_ExecCtrl_DataSource_sourceId, f_EPTF_Base_selfName(), refers(f_EPTF_ExecCtrl_conditionHandler_isWeightedSc),c_ExecCtrl_conditionIsWeightedSc);
f_EPTF_DataSourceClient_registerCondition(c_ExecCtrl_DataSource_sourceId, f_EPTF_Base_selfName(), refers(f_EPTF_ExecCtrl_conditionHandler_isInScGroup), c_ExecCtrl_conditionIsInScGroup);
}
v_ExecCtrl_loggingMaskId := f_EPTF_Logging_registerComponentMasks(tsp_EPTF_ExecCtrl_loggingComponentMask, c_EPTF_ExecCtrl_loggingEventClasses, EPTF_Logging_CLL);
if(tsp_debug_EPTF_ExecCtrl_Functions) {
f_EPTF_Logging_enableLocalMask(v_ExecCtrl_loggingMaskId, c_EPTF_ExecCtrl_loggingClassIdx_Debug);
} else {
f_EPTF_Logging_disableLocalMask(v_ExecCtrl_loggingMaskId, c_EPTF_ExecCtrl_loggingClassIdx_Debug);
}
if (pl_loadModulepars) {
f_EPTF_ExecCtrl_loadConfigFromModulepars();
}
// add vars for automated GUI elements
f_EPTF_ExecCtrl_UIVars_InitGUILayout_vars();
f_EPTF_ExecCtrl_initEventStatus();
f_EPTF_Base_assert(%definitionId&": Checking number of ExecCtrlClients", pl_nrOfClients>=0);
v_ExecCtrl_nrOfClients := pl_nrOfClients;
v_ExecCtrl_started := false;
v_EPTF_ExecCtrl_EntityResourceInfo_Buffer := {};
f_EPTF_Base_registerCleanup(refers(f_EPTF_ExecCtrl_cleanup_CT));
f_EPTF_ExecCtrl_registerOnGroupFinishCallbackFn(refers(f_EPTF_ExecCtrl_setLEDForOnGroupFinishCallBack));
v_EPTF_ExecCtrl_defaultAltstep := activate(as_EPTF_ExecCtrl_MgmtIf());
if (pl_autoStart) {
f_EPTF_ExecCtrl_start(pl_createLGenPools);
} else {
if (pl_createLGenPools) {
f_EPTF_ExecCtrl_warning(%definitionId& ": LGen pools are not created: Auto-start is disabled!");
}
}
f_EPTF_ExecCtrl_Subscribe2ExitButton_vars();
v_EPTF_ExecCtrl_SampledAtSync_vars := {}; // TR HQ88308 - Sampled & sync variables on old GUI for refresh
// TR HR20548 - Reset All statistics button
f_EPTF_StatHandler_registerStatisticsResetFunction(refers(f_EPTF_ExecCtrl_resetStatFunctions));
f_EPTF_StatHandlerClient_registerResetFunction(refers(f_EPTF_ExecCtrl_resetStatFunctions));
}
// this StatHandlert will process all ExecCtrl statistics (TC, FSM)
// Using External StatHandler will increase internal traffic on Variable interface
private function f_ExecCtrl_ExternalStatHandler_behaviour(
in EPTF_DataSource_CT pl_dataSource_compRef,
in integer pl_statHandlerId
) runs on EPTF_ExecCtrl_StatHandler_CT {
f_EPTF_StatHandler_init_CT("ExecCtrl_ExternalStatHandler_Comp_"&log2str(pl_statHandlerId),pl_dataSource_compRef);
f_EPTF_StatManager_init_CT(f_EPTF_Base_selfName(),pl_dataSource_compRef);
f_EPTF_Base_wait4Shutdown();
}
// starts new StatHandlera or initializes the local
private function f_ExecCtrl_ExternalStatHandler_startNew() runs on EPTF_ExecCtrl_CT {
if (v_EPTF_ExecCtrl_nofExternalStatHandlers==0) {
// use local
f_EPTF_StatHandler_init_CT(f_EPTF_Base_selfName(), v_ExecCtrl_dataSourceCompRef); // Set pl_dataSource_compRef
f_EPTF_StatManager_init_CT(f_EPTF_Base_selfName(), v_ExecCtrl_dataSourceCompRef);
v_EPTF_ExecCtrl_statHandler_comprefList := {self};
return;
}
for(var integer i:=0; i<v_EPTF_ExecCtrl_nofExternalStatHandlers; i:=i+1) {
var EPTF_ExecCtrl_StatHandler_CT vl_externalStatHandler := EPTF_ExecCtrl_StatHandler_CT.create;
vl_externalStatHandler.start(f_ExecCtrl_ExternalStatHandler_behaviour(v_ExecCtrl_dataSourceCompRef,i));
v_EPTF_ExecCtrl_statHandler_comprefList[i] := vl_externalStatHandler;
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_StatHandler_getVarIdx
//
// Purpose:
// Function for getting the id/index of the variable of a statistic.
//
// Parameters:
// pl_statName - *in* *charstring* - name of the stat
//
// Return Value:
// *integer* - index of variable for the stat
//
// Errors & assertions:
// -
//
// Detailed Comments:
// override function <f_EPTF_StatHandler_getVarIdx>
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_StatHandler_getVarIdx(
in charstring pl_statName
) runs on EPTF_ExecCtrl_CT return integer {
var integer vl_statVarIdx;
var EPTF_StatHandler_CT vl_statHandler := f_EPTF_ExecCtrl_findStatHandler(pl_statName);
if (vl_statHandler==self) {
var integer vl_statId := f_EPTF_StatHandler_getId(pl_statName);
vl_statVarIdx := f_EPTF_StatHandler_getVarIdx(vl_statId);
} else {
// get var idx from remote statHandler
// the stat variable name and the stat name is the same;
var EPTF_Var_SubscriptionMode vl_subscriptionModeForVars := sampled;
if (v_ExecCtrl_usePullModeForStats) {
vl_subscriptionModeForVars := pull;
}
f_EPTF_Var_subscribeRemote(
pl_remoteCompRef := vl_statHandler,
pl_remoteProviderVarName := pl_statName,
pl_subscriptionMode := vl_subscriptionModeForVars,
pl_idx := vl_statVarIdx,
pl_localName := pl_statName&"_Local"
);
}
return vl_statVarIdx;
}
/////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_StatHandler_getVarNameByStatName
//
// Purpose:
// Function for getting the variable name for a statistic name.
//
// Parameters:
// pl_statName - *in* *charstring* - name of statistic
// pl_varName - *out* *charstring* - the variable name for a statistic name
//
// Return Value:
// *boolean* - true if success
//
// Errors & assertions:
// -
//
// Detailed Comments:
// override function <f_EPTF_StatHandler_getVarNameByStatName>
//
/////////////////////////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_StatHandler_getVarNameByStatName(
in charstring pl_statName,
out charstring pl_varName)
runs on EPTF_ExecCtrl_CT
return boolean
{
var integer vl_varIdx := f_EPTF_ExecCtrl_StatHandler_getVarIdx(pl_statName);
if(vl_varIdx < 0) { return false; }
pl_varName := f_EPTF_Var_getName(vl_varIdx);
return true;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_StatHandler_getAuxVars
//
// Purpose:
// Function for getting the auxiliary Variable indices of a statistic.
//
// Parameters:
// pl_statName - *in* *charstring* - name of the stat
//
// Return Value:
// <EPTF_IntegerList> - list of auxiliary Var indices
//
// Errors & assertions:
// -
//
// Detailed Comments:
// override function f_EPTF_StatHandler_getAuxVars
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_StatHandler_getAuxVars(
in charstring pl_statName
) runs on EPTF_ExecCtrl_CT return EPTF_IntegerList {
var EPTF_IntegerList vl_auxVars;
var EPTF_StatHandler_CT vl_statHandler := f_EPTF_ExecCtrl_findStatHandler(pl_statName);
if (vl_statHandler==self) {
var integer vl_statId := f_EPTF_StatHandler_getId(pl_statName);
vl_auxVars := f_EPTF_StatHandler_getAuxVars(vl_statId);
} else {
// get aux var idxs from remote statHandler and subscribe to them
var EPTF_CharstringList vl_auxVarNames := f_EPTF_StatHandlerClient_getAuxVariables(pl_statName,vl_statHandler);
var EPTF_Var_SubscriptionMode vl_subscriptionModeForVars := sampled;
if (v_ExecCtrl_usePullModeForStats) {
vl_subscriptionModeForVars := pull;
}
for(var integer i:=0, size:=sizeof(vl_auxVarNames); i<size; i:=i+1) {
f_EPTF_Var_subscribeRemote(
pl_remoteCompRef := vl_statHandler,
pl_remoteProviderVarName := vl_auxVarNames[i],
pl_subscriptionMode := vl_subscriptionModeForVars,
pl_idx := vl_auxVars[i]
)
}
}
return vl_auxVars;
}
// override function f_EPTF_StatHandlerClient_declareStat
private function f_EPTF_ExecCtrl_StatHandlerClient_declareStat(
in charstring pl_statName,
in EPTF_StatHandler_StatMethod pl_statMethod,
in EPTF_Var_DirectContent pl_statResetValue
) runs on EPTF_ExecCtrl_CT return boolean {
var EPTF_StatHandler_CT vl_statHandler := f_EPTF_ExecCtrl_findStatHandler(pl_statName);
var integer vl_statHandlerCompIdx := -1;
if (vl_statHandler==null) {
if (v_EPTF_ExecCtrl_nofExternalStatHandlers==0) {
vl_statHandlerCompIdx := 0;
} else {
vl_statHandlerCompIdx := v_EPTF_ExecCtrl_statHandler_autoSelector mod v_EPTF_ExecCtrl_nofExternalStatHandlers;
}
vl_statHandler := v_EPTF_ExecCtrl_statHandler_comprefList[vl_statHandlerCompIdx];
} else {
// stat already declared
return true;
}
var boolean vl_success := f_EPTF_StatHandlerClient_declareStat(
pl_statName := pl_statName,
pl_statMethod := pl_statMethod,
pl_statResetValue := pl_statResetValue,
pl_statHandler := vl_statHandler,
pl_wait4response := true
);
if (vl_success) {
// subscribe statVar so that DS handler does not need f_EPTF_Var_subscribeRemote which would cause long call stack there
var EPTF_Var_SubscriptionMode vl_subscriptionModeForVars := sampled;
if (v_ExecCtrl_usePullModeForStats) {
vl_subscriptionModeForVars := pull;
}
var integer vl_idx;
f_EPTF_Var_subscribeRemote(
pl_remoteCompRef := vl_statHandler,
pl_remoteProviderVarName := pl_statName,
pl_subscriptionMode := vl_subscriptionModeForVars,
pl_idx := vl_idx,
pl_localName := pl_statName&"_Local"
);
// store statHandler compRef for the statName:
f_EPTF_str2int_HashMap_Insert(v_ExecCtrl_statHandlerHash, pl_statName, vl_statHandlerCompIdx);
if (v_EPTF_ExecCtrl_nofExternalStatHandlers>0) {
v_EPTF_ExecCtrl_statHandler_autoSelector := v_EPTF_ExecCtrl_statHandler_autoSelector + 1;
}
}
return vl_success;
}
// override function f_EPTF_StatHandlerClient_registerAggregatedStat
private function f_EPTF_ExecCtrl_StatHandlerClient_registerAggregatedStat(
in EPTF_StatHandler_CT pl_sourceStatHandler,
in charstring pl_sourceStatName,
in charstring pl_targetStatName,
in EPTF_Var_SubscriptionMode pl_subscriptionMode := sampledAtSync,
in boolean pl_wait4response := true//tsp_EPTF_ExecCtrl_StatHandler_wait4response
) runs on EPTF_ExecCtrl_CT return boolean {
var EPTF_StatHandler_CT vl_statHandler := self;
if (v_EPTF_ExecCtrl_nofExternalStatHandlers>0) {
vl_statHandler := f_EPTF_ExecCtrl_findStatHandler(pl_targetStatName);
if (vl_statHandler==null) {
return false;
}
}
return f_EPTF_StatHandlerClient_registerAggregatedStat(
pl_sourceStatHandler := pl_sourceStatHandler,
pl_sourceStatName := pl_sourceStatName,
pl_targetStatName := pl_targetStatName,
pl_subscriptionMode := pl_subscriptionMode,
pl_wait4response := pl_wait4response,
pl_statHandler := vl_statHandler
);
}
// override function f_EPTF_StatHandlerClient_getStatVariableRef
private function f_EPTF_ExecCtrl_StatHandlerClient_getStatVariableRef(
in charstring pl_statName
) runs on EPTF_ExecCtrl_CT return charstring {
var EPTF_StatHandler_CT vl_statHandler := self;
if (v_EPTF_ExecCtrl_nofExternalStatHandlers>0) {
vl_statHandler := f_EPTF_ExecCtrl_findStatHandler(pl_statName);
if (vl_statHandler==null) {
return "";
}
}
return f_EPTF_StatHandlerClient_getStatVariableRef(
pl_statName := pl_statName,
pl_statHandler := vl_statHandler
);
}
//override function f_EPTF_StatHandlerClient_registerStat
private function f_EPTF_ExecCtrl_StatHandlerClient_registerStat(
in EPTF_CharstringList pl_providerVarList,
in charstring pl_statName,
in EPTF_Var_SubscriptionMode pl_subscriptionMode := sampledAtSync,
in boolean pl_wait4response := true,//tsp_EPTF_ExecCtrl_StatHandler_wait4response,
in EPTF_Var_CT pl_sourceCompRef := null,
in integer pl_refreshRate := 0
) runs on EPTF_ExecCtrl_CT return boolean {
var EPTF_StatHandler_CT vl_statHandler := self;
if (v_EPTF_ExecCtrl_nofExternalStatHandlers>0) {
vl_statHandler := f_EPTF_ExecCtrl_findStatHandler(pl_statName);
if (vl_statHandler==null) {
return false;
}
}
return f_EPTF_StatHandlerClient_registerStat(
pl_providerVarList := pl_providerVarList,
pl_statName := pl_statName,
pl_subscriptionMode := pl_subscriptionMode,
pl_wait4response := pl_wait4response,
pl_sourceCompRef := pl_sourceCompRef,
pl_statHandler := vl_statHandler,
pl_refreshRate := pl_refreshRate
);
}
friend function f_EPTF_ExecCtrl_findStatHandler(
in charstring pl_statName
) runs on EPTF_ExecCtrl_CT return EPTF_StatHandler_CT {
var integer vl_idx;
if (not f_EPTF_str2int_HashMap_Find(
v_ExecCtrl_statHandlerHash,
pl_statName,
vl_idx
)) {
return null;
}
return v_EPTF_ExecCtrl_statHandler_comprefList[vl_idx];
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_checkManualLGenStarted
//
// Purpose:
// Checks if LGens that are created manually (not in LGenPool) have started
//
// Parameters:
// -
//
// Return Value:
// boolean - true if all manual LGens have started, false if not
//
// Errors & assertions:
//
// Detailed Comments:
// After this function is called, no more user created LGen will start.
// If LGen pools are created before user created LGens i.e. when start was called
// before the manual LGens are created, this function will return true when all
// LGens have been created.
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_checkManualLGenStarted() runs on EPTF_ExecCtrl_CT return boolean {
return ((not v_ExecCtrl_started) and sizeof(v_EPTF_ExecCtrl_EntityResourceInfo_Buffer) == v_ExecCtrl_nrOfClients) or v_ExecCtrl_allLGensCreated;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_start
//
// Purpose:
// Start the ExecCtrl operation
//
// Parameters:
// - pl_createLGenPools - *in boolean - if true, LGens in LGens pools are created automatically, otherwise
// the function <f_EPTF_ExecCtrl_LGenPool_createLGens> has to be called later. Default: true
//
// Return Value:
// -
//
// Errors & assertions:
//
// Detailed Comments:
// After this function is called, configuration data cannot be loaded i.e.
// config loaded by f_EPTF_ExecCtrl_loadConfig will be ignored.
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_start(in boolean pl_createLGenPools := true) runs on EPTF_ExecCtrl_CT {
// Init R3 DB:
f_EPTF_ExecCtrl_initTypeDB();
f_EPTF_ExecCtrl_loadTypeDB(
v_ExecCtrl_ScenarioDeclarators,
v_ExecCtrl_tcTypeDeclarators,
v_ExecCtrl_ScenarioDeclarators2,
v_ExecCtrl_tcTypeDeclarators2,
v_ExecCtrl_ScenarioDeclarators3,
v_ExecCtrl_ScenarioDeclaratorsR3
);
f_EPTF_ExecCtrl_initInstanceDB();
f_EPTF_ExecCtrl_loadInstanceDB(
v_ExecCtrl_EntityGrpDeclarators,
v_ExecCtrl_Scenarios2Grps,
v_ExecCtrl_scenario2EntityGroups
);
// R3 end
f_EPTF_ExecCtrl_initSc2grp();
f_EPTF_ExecCtrl_initScTimeProfileListDB();
f_EPTF_ExecCtrl_Phase_init();
//create scenario groups
f_EPTF_ExecCtrl_Phase_createScenarioGroups();
f_EPTF_ExecCtrl_Regulator_init(v_EPTF_ExecCtrl_RegulatorNames,v_EPTF_ExecCtrl_RegulatedItemsCFG); // this should be done at last
f_EPTF_ExecCtrl_EntityGroupDistribution_init(v_EPTF_ExecCtrl_entityGroupDistributionCFG);
f_EPTF_ExecCtrl_debug(log2str("value of v_ExecCtrl_tcTypeDeclarators = ", v_ExecCtrl_tcTypeDeclarators));
f_EPTF_ExecCtrl_LGenPool_initInstanceDB();
f_EPTF_ExecCtrl_LGenPool_loadInstanceDB(
v_EPTF_ExecCtrl_LGenPool_Declarators,
v_EPTF_ExecCtrl_EntityGroup2LGenPools
);
f_EPTF_ExecCtrl_LGenFunctions_initInstanceDB();
f_EPTF_ExecCtrl_addLGenFunctionsFromDeclarators(v_EPTF_ExecCtrl_lgenCreatorFn_list);
v_ExecCtrl_started := true;
f_EPTF_ExecCtrl_loadBuffered_EntityResourceInfo();
if (pl_createLGenPools) {
f_EPTF_ExecCtrl_LGenPool_createLGens();
}
if(v_ExecCtrl_nrOfClients==0 and v_ExecCtrl_allLGensCreated) {
if (pl_createLGenPools) {
t_ExecCtrl_allLGensCreated.stop;
}
f_EPTF_ExecCtrl_readyToRun();
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_getManualControl
//
// Purpose:
// Gets the manual control mode
//
// Parameters:
//
// Return Value:
// boolean - manual control mode
//
// Errors & assertions:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_getManualControl() runs on EPTF_ExecCtrl_CT return boolean
{
return v_ExecCtrl_manualControl;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_setManualControl
//
// Purpose:
// Sets the manual control mode (overwrites config setting)
//
// Parameters:
// pl_manualControl - *in boolean* - true to enable manual control mode, false to disable (automatic start of scenarios)
//
// Return Value:
// -
//
// Errors & assertions:
//
// Detailed Comments:
// It is not called in <f_EPTF_ExecCtrl_init_CT>.
// This function should be called before initializing the ExecCtrl component with its init function <f_EPTF_ExecCtrl_init_CT>.
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_setManualControl(in boolean pl_manualControl) runs on EPTF_ExecCtrl_CT
{
v_ExecCtrl_manualControl := pl_manualControl;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_getTimePeriodForTcDeltaStats
//
// Purpose:
// Gets The time period when delta stats are refreshed
//
// Parameters:
//
// Return Value:
// float - Time period when delta stats are refreshed.
//
// Errors & assertions:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_getTimePeriodForTcDeltaStats() runs on EPTF_ExecCtrl_CT return float
{
return v_EPTF_ExecCtrl_timePeriodForTcDeltaStats;
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_setTimePeriodForTcDeltaStats
//
// Purpose:
// Tells that the ExecCtrl's Time period when delta stats are refreshed.
//
// Parameters:
// pl_gtimePeriodForTcDeltaStats - *float* - Time period when delta stats are refreshed.
//
// Return Value:
// -
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_setTimePeriodForTcDeltaStats(in float pl_gtimePeriodForTcDeltaStats) runs on EPTF_ExecCtrl_CT
{
v_EPTF_ExecCtrl_timePeriodForTcDeltaStats := pl_gtimePeriodForTcDeltaStats;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_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:
// 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. It is not called in <f_EPTF_ExecCtrl_init_CT>.
// If you have your own tsp-s, this function can be used to load them into the ExecCtrl database. The ExecCtr
// should know about all declarators in the system.
// This function should be called before the <f_EPTF_ExecCtrl_start> function is called on the ExecCtrl component.
// This function can be called before the ExecCtrl is initialized with its init function <f_EPTF_ExecCtrl_init_CT>.
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_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_ExecCtrl_CT {
if (v_ExecCtrl_started) {
f_EPTF_ExecCtrl_warning(log2str(%definitionId&": Config not loaded: ExecCtrl was already started"));
return;
}
// load pl_EPTF_LGenBase_TcMgmt_EntityGrpDeclaratorList:
for(var integer i:=0, size := sizeof(pl_EPTF_LGenBase_TcMgmt_EntityGrpDeclaratorList); i<size; i:=i+1) {
var integer vl_currentSize := sizeof(v_ExecCtrl_EntityGrpDeclarators);
v_ExecCtrl_EntityGrpDeclarators[vl_currentSize] := pl_EPTF_LGenBase_TcMgmt_EntityGrpDeclaratorList[i];
}
// load pl_EPTF_LGenBase_TcMgmt_Scenarios2GrpList:
for(var integer i:=0, size := sizeof(pl_EPTF_LGenBase_TcMgmt_Scenarios2GrpList); i<size; i:=i+1) {
var integer vl_currentSize := sizeof(v_ExecCtrl_Scenarios2Grps);
v_ExecCtrl_Scenarios2Grps[vl_currentSize] := pl_EPTF_LGenBase_TcMgmt_Scenarios2GrpList[i];
}
// load pl_EPTF_LGenBase_ScenarioDeclaratorList:
for(var integer i:=0, size := sizeof(pl_EPTF_LGenBase_ScenarioDeclaratorList); i<size; i:=i+1) {
var integer vl_currentSize := sizeof(v_ExecCtrl_ScenarioDeclarators);
v_ExecCtrl_ScenarioDeclarators[vl_currentSize] := pl_EPTF_LGenBase_ScenarioDeclaratorList[i];
}
// load pl_EPTF_LGenBase_tcTypeDeclaratorList:
for(var integer i:=0, size := sizeof(pl_EPTF_LGenBase_tcTypeDeclaratorList); i<size; i:=i+1) {
var integer vl_currentSize := sizeof(v_ExecCtrl_tcTypeDeclarators);
v_ExecCtrl_tcTypeDeclarators[vl_currentSize] := pl_EPTF_LGenBase_tcTypeDeclaratorList[i];
}
// load pl_EPTF_LGenBase_TcMgmt_tcTypeDeclaratorList:
for(var integer i:=0, size := sizeof(pl_EPTF_LGenBase_TcMgmt_tcTypeDeclaratorList); i<size; i:=i+1) {
var integer vl_currentSize := sizeof(v_ExecCtrl_tcTypeDeclarators2);
v_ExecCtrl_tcTypeDeclarators2[vl_currentSize] := pl_EPTF_LGenBase_TcMgmt_tcTypeDeclaratorList[i];
}
// load pl_EPTF_LGenBase_TcMgmt_ScenarioDeclaratorList:
for(var integer i:=0, size := sizeof(pl_EPTF_LGenBase_TcMgmt_ScenarioDeclaratorList); i<size; i:=i+1) {
var integer vl_currentSize := sizeof(v_ExecCtrl_ScenarioDeclarators2);
v_ExecCtrl_ScenarioDeclarators2[vl_currentSize] := pl_EPTF_LGenBase_TcMgmt_ScenarioDeclaratorList[i];
}
// load pl_EPTF_LGenBase_TcMgmt_WeightedScenarioDeclaratorList:
for(var integer i:=0, size := sizeof(pl_EPTF_LGenBase_TcMgmt_WeightedScenarioDeclaratorList); i<size; i:=i+1) {
var integer vl_currentSize := sizeof(v_ExecCtrl_ScenarioDeclarators3);
v_ExecCtrl_ScenarioDeclarators3[vl_currentSize] := pl_EPTF_LGenBase_TcMgmt_WeightedScenarioDeclaratorList[i];
}
// load pl_EPTF_ExecCtrl_TimeProfileDescrList:
for(var integer i:=0, size := sizeof(pl_EPTF_ExecCtrl_TimeProfileDescrList); i<size; i:=i+1) {
var integer vl_currentSize := sizeof(v_EPTF_ExecCtrl_TimeProfileDescrList);
v_EPTF_ExecCtrl_TimeProfileDescrList[vl_currentSize] := pl_EPTF_ExecCtrl_TimeProfileDescrList[i];
}
// load pl_EPTF_ExecCtrl_TimeProfileList:
for(var integer i:=0, size := sizeof(pl_EPTF_ExecCtrl_TimeProfileList); i<size; i:=i+1) {
var integer vl_currentSize := sizeof(v_EPTF_ExecCtrl_TimeProfileList);
v_EPTF_ExecCtrl_TimeProfileList[vl_currentSize] := pl_EPTF_ExecCtrl_TimeProfileList[i];
}
// load pl_EPTF_ExecCtrl_TimeProfile2TcList:
for(var integer i:=0, size := sizeof(pl_EPTF_ExecCtrl_TimeProfile2TcList); i<size; i:=i+1) {
var integer vl_currentSize := sizeof(v_EPTF_ExecCtrl_TimeProfile2TcList);
v_EPTF_ExecCtrl_TimeProfile2TcList[vl_currentSize] := pl_EPTF_ExecCtrl_TimeProfile2TcList[i];
}
// load pl_EPTF_LGenBase_ScenarioTypeDeclaratorList:
for(var integer i:=0, size := sizeof(pl_EPTF_LGenBase_ScenarioTypeDeclaratorList); i<size; i:=i+1) {
var integer vl_currentSize := sizeof(v_ExecCtrl_ScenarioDeclaratorsR3);
v_ExecCtrl_ScenarioDeclaratorsR3[vl_currentSize] := pl_EPTF_LGenBase_ScenarioTypeDeclaratorList[i];
}
// load pl_EPTF_ExecCtrl_ScenarioInstanceTypeList:
for(var integer i:=0, size := sizeof(pl_EPTF_ExecCtrl_ScenarioInstanceTypeList); i<size; i:=i+1) {
var integer vl_currentSize := sizeof(v_ExecCtrl_scenario2EntityGroups);
v_ExecCtrl_scenario2EntityGroups[vl_currentSize] := pl_EPTF_ExecCtrl_ScenarioInstanceTypeList[i];
}
// load pl_EPTF_ExecCtrl_LGenPool_Declarators:
for(var integer i:=0, size := sizeof(pl_EPTF_ExecCtrl_LGenPool_Declarators); i<size; i:=i+1) {
var integer vl_currentSize := sizeof(v_EPTF_ExecCtrl_LGenPool_Declarators);
v_EPTF_ExecCtrl_LGenPool_Declarators[vl_currentSize] := pl_EPTF_ExecCtrl_LGenPool_Declarators[i];
}
// load pl_EPTF_ExecCtrl_EntityGroup2LGenPool_List:
for(var integer i:=0, size := sizeof(pl_EPTF_ExecCtrl_EntityGroup2LGenPool_List); i<size; i:=i+1) {
var integer vl_currentSize := sizeof(v_EPTF_ExecCtrl_EntityGroup2LGenPools);
v_EPTF_ExecCtrl_EntityGroup2LGenPools[vl_currentSize] := pl_EPTF_ExecCtrl_EntityGroup2LGenPool_List[i];
}
// load pl_EPTF_ExecCtrl_LGenFunction_Entry_List:
for(var integer i:=0, size := sizeof(pl_EPTF_ExecCtrl_LGenFunction_Entry_List); i<size; i:=i+1) {
var integer vl_currentSize := sizeof(v_EPTF_ExecCtrl_lgenCreatorFn_list);
v_EPTF_ExecCtrl_lgenCreatorFn_list[vl_currentSize] := pl_EPTF_ExecCtrl_LGenFunction_Entry_List[i];
}
// load pl_EPTF_ExecCtrl_PhaseList_Declarators:
for(var integer i:=0, size := sizeof(pl_EPTF_ExecCtrl_PhaseList_Declarators); i<size; i:=i+1) {
var integer vl_currentSize := sizeof(v_EPTF_ExecCtrl_PhaseList_Declarators);
v_EPTF_ExecCtrl_PhaseList_Declarators[vl_currentSize] := pl_EPTF_ExecCtrl_PhaseList_Declarators[i];
}
// load pl_EPTF_ExecCtrl_PhaseList_Declarators:
for(var integer i:=0, size := sizeof(pl_EPTF_ExecCtrl_ScenarioGroup_Declarators); i<size; i:=i+1) {
var integer vl_currentSize := sizeof(v_EPTF_ExecCtrl_ScenarioGroup_Declarators);
v_EPTF_ExecCtrl_ScenarioGroup_Declarators[vl_currentSize] := pl_EPTF_ExecCtrl_ScenarioGroup_Declarators[i];
}
// load pl_EPTF_ExecCtrl_RegulatorNames:
for(var integer i:=0, size := sizeof(pl_EPTF_ExecCtrl_RegulatorNames); i<size; i:=i+1) {
var integer vl_currentSize := sizeof(v_EPTF_ExecCtrl_RegulatorNames);
v_EPTF_ExecCtrl_RegulatorNames[vl_currentSize] := pl_EPTF_ExecCtrl_RegulatorNames[i];
}
// load pl_EPTF_ExecCtrl_RegulatedItems:
for(var integer i:=0, size := sizeof(pl_EPTF_ExecCtrl_RegulatedItems); i<size; i:=i+1) {
var integer vl_currentSize := sizeof(v_EPTF_ExecCtrl_RegulatedItemsCFG);
v_EPTF_ExecCtrl_RegulatedItemsCFG[vl_currentSize] := pl_EPTF_ExecCtrl_RegulatedItems[i];
}
// load pl_EPTF_ExecCtrl_EntityGroupDistributionTypeList:
for(var integer i:=0, size := sizeof(pl_EPTF_ExecCtrl_EntityGroupDistributionTypeList); i<size; i:=i+1) {
var integer vl_currentSize := sizeof(v_EPTF_ExecCtrl_entityGroupDistributionCFG);
v_EPTF_ExecCtrl_entityGroupDistributionCFG[vl_currentSize] := pl_EPTF_ExecCtrl_EntityGroupDistributionTypeList[i];
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_setTimeFormat
//
// Purpose:
// Sets the timeformat for the timeElapsed variable
//
// Parameters:
// in <EPTF_ExecCtrl_timeFormat> pl_timeFormat : the new timeformat to set
//
// Return Value:
//
// Errors & assertions:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_setTimeFormat(in EPTF_ExecCtrl_timeFormat pl_timeFormat) runs on EPTF_ExecCtrl_CT {
v_EPTF_ExecCtrl_timeFormat := pl_timeFormat;
}
private function f_EPTF_ExecCtrl_handleLoadConfig(in EPTF_ExecCtrlClient_CT pl_client, in EPTF_ExecCtrlClient_LoadConfig pl_config) runs on EPTF_ExecCtrl_CT {
if (v_ExecCtrl_started) {
f_EPTF_ExecCtrl_warning(log2str(%definitionId&": Config received from ",pl_client," not loaded: ExecCtrl was already started. Config ignored: ", pl_config));
return;
}
f_EPTF_ExecCtrl_loadConfig(
pl_config.pl_EPTF_LGenBase_TcMgmt_EntityGrpDeclaratorList,
pl_config.pl_EPTF_LGenBase_TcMgmt_Scenarios2GrpList,
pl_config.pl_EPTF_LGenBase_ScenarioDeclaratorList,
pl_config.pl_EPTF_LGenBase_tcTypeDeclaratorList,
pl_config.pl_EPTF_LGenBase_TcMgmt_tcTypeDeclaratorList,
pl_config.pl_EPTF_LGenBase_TcMgmt_ScenarioDeclaratorList,
pl_config.pl_EPTF_LGenBase_TcMgmt_WeightedScenarioDeclaratorList,
pl_config.pl_EPTF_ExecCtrl_TimeProfileDescrList,
pl_config.pl_EPTF_ExecCtrl_TimeProfileList,
pl_config.pl_EPTF_ExecCtrl_TimeProfile2TcList,
pl_config.pl_EPTF_LGenBase_ScenarioTypeDeclaratorList,
pl_config.pl_EPTF_ExecCtrl_ScenarioInstanceTypeList,
pl_config.pl_EPTF_ExecCtrl_LGenPool_Declarators,
pl_config.pl_EPTF_ExecCtrl_EntityGroup2LGenPool_List,
{},//pl_config.pl_EPTF_ExecCtrl_LGenFunction_Entry_List,
pl_config.pl_EPTF_ExecCtrl_PhaseList_Declarators,
pl_config.pl_EPTF_ExecCtrl_ScenarioGroup_Declarators,
pl_config.pl_EPTF_ExecCtrl_RegulatorNames,
pl_config.pl_EPTF_ExecCtrl_RegulatedItems,
pl_config.pl_EPTF_ExecCtrl_EntityGroupDistributionTypeList
);
}
private altstep as_EPTF_ExecCtrl_MgmtIf_handleLoadConfig() runs on EPTF_ExecCtrl_CT {
var EPTF_ExecCtrlClient_CT vl_client;
var EPTF_ExecCtrlClient_LoadConfig v_msg;
[] ExecCtrl_MgmtIf_CP.receive(EPTF_ExecCtrlClient_LoadConfig:?) -> value v_msg sender vl_client {
f_EPTF_ExecCtrl_debug("DEBUG: EPTF_ExecCtrlClient_LoadConfig received...");
f_EPTF_ExecCtrl_handleLoadConfig(vl_client,v_msg);
repeat;
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_initSc2grp
//
// Purpose:
// Preprocess <v_ExecCtrl_Scenarios2Grps> -> Only one scenario will be associated to each entityGrp
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_initSc2grp()runs on EPTF_ExecCtrl_CT {
var EPTF_LGenBase_TcMgmt_Scenarios2GrpList v_ExecCtrl_Scenarios2Grps_orig := v_ExecCtrl_Scenarios2Grps;
v_ExecCtrl_Scenarios2Grps := {};
var integer vl_grp := 0;
for(var integer i:=0, size := sizeof(v_ExecCtrl_Scenarios2Grps_orig); i<size; i:=i+1) {
for(var integer j:=0, sizej := sizeof(v_ExecCtrl_Scenarios2Grps_orig[i].scenarioNames); j<sizej; j:=j+1) {
v_ExecCtrl_Scenarios2Grps[vl_grp] := {
v_ExecCtrl_Scenarios2Grps_orig[i].eGrpName,
{ v_ExecCtrl_Scenarios2Grps_orig[i].scenarioNames[j] }
};
vl_grp := vl_grp + 1;
}
}
}
group TimeProfile {
// uses modulepar EPTF_ExecCtrl_TimeProfileDescrList tsp_EPTF_ExecCtrl_TimeProfileDescrList := {};
// and modulepar EPTF_ExecCtrl_TimeProfile2TcList tsp_EPTF_ExecCtrl_TimeProfile2TcList := {};
// to initialize the v_EPTF_ExecCtrl_ScTimeProfileListDB database
// only declarator2 is supported
private function f_EPTF_ExecCtrl_initScTimeProfileListDB() runs on EPTF_ExecCtrl_CT {
v_EPTF_ExecCtrl_ScTimeProfileDB := {};
// going through the scenario instances:
for (var integer sidx := 0, size := sizeof(v_ExecCtrl_scenarios); sidx < size; sidx := sidx + 1)
{
var integer vl_sizeTCs := sizeof(v_ExecCtrl_scenarios[sidx].scData.tcList);
if (f_EPTF_ExecCtrl_isWeightedScenario(sidx)) {
vl_sizeTCs := 1;
}
for (var integer tcidx := 0; tcidx < vl_sizeTCs; tcidx := tcidx + 1)
{
if (f_EPTF_ExecCtrl_isWeightedScenario(sidx)) {
f_EPTF_ExecCtrl_initProfileForSc(/*grp,*/sidx);
} else {
f_EPTF_ExecCtrl_initProfileForTc(/*grp,*/sidx,tcidx);
}
}
}
f_EPTF_ExecCtrl_debug(log2str("v_EPTF_ExecCtrl_TimeProfile2TcList: ", v_EPTF_ExecCtrl_TimeProfile2TcList));
f_EPTF_ExecCtrl_debug(log2str("v_EPTF_ExecCtrl_TimeProfileDescrList: ", v_EPTF_ExecCtrl_TimeProfileDescrList));
f_EPTF_ExecCtrl_debug(log2str("v_EPTF_ExecCtrl_ScTimeProfileDB: ", v_EPTF_ExecCtrl_ScTimeProfileDB));
}
// initializes the time profile database for a traffic case
private function f_EPTF_ExecCtrl_initProfileForTc(
// in integer grp,
in integer sidx,
in integer tcidx
) runs on EPTF_ExecCtrl_CT {
v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx] := {
timeProfileIdList := {},
timeProfileIdx := -1,
eventIdList := {}
}; // time prof not defined for this TC
var charstring vl_tcName := f_EPTF_LGenBase_tcNameOfTcOfSc(v_ExecCtrl_scenarios[sidx].scData,tcidx)
var EPTF_ExecCtrl_TCName tcId := {
eGrpName := v_ExecCtrl_entityGroups[v_ExecCtrl_scenarios[sidx].eGroupIdx].name,
scName := v_ExecCtrl_scenarios[sidx].scData.name,
tcName := vl_tcName
}
// find time profile for this tc:
for (var integer i:=0, size := sizeof(v_EPTF_ExecCtrl_TimeProfile2TcList); i<size; i:=i+1) {
// if (v_EPTF_ExecCtrl_TimeProfile2TcList[i].tcId == tcId) { // this is syntactically erroneous
if (v_EPTF_ExecCtrl_TimeProfile2TcList[i].tcId.eGrpName == tcId.eGrpName
and v_EPTF_ExecCtrl_TimeProfile2TcList[i].tcId.scName == tcId.scName
and v_EPTF_ExecCtrl_TimeProfile2TcList[i].tcId.tcName == tcId.tcName) {
// time prof found
// find the time profile data:
var integer vl_timeProfileIdx := -1;
for (var integer tpIdx := 0, sizet := sizeof(v_EPTF_ExecCtrl_TimeProfileList); tpIdx<sizet; tpIdx:=tpIdx+1) {
if (v_EPTF_ExecCtrl_TimeProfileList[tpIdx].name == v_EPTF_ExecCtrl_TimeProfile2TcList[i].timeProfileName) {
vl_timeProfileIdx := tpIdx;
break;
}
}
if(vl_timeProfileIdx == -1){
f_EPTF_ExecCtrl_error(%definitionId&": Unable to find the time profile " &v_EPTF_ExecCtrl_TimeProfile2TcList[i].timeProfileName&" in v_EPTF_ExecCtrl_TimeProfileList");
}
v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].timeProfileIdx := vl_timeProfileIdx;
// search time profile data for each profile in the list:
for(var integer k:=0, sizek := sizeof(v_EPTF_ExecCtrl_TimeProfileList[vl_timeProfileIdx].timeProfileList); k<sizek; k:=k+1) {
for(var integer j:=0, sizej := sizeof(v_EPTF_ExecCtrl_TimeProfileDescrList); j<sizej; j:=j+1) {
if (v_EPTF_ExecCtrl_TimeProfileDescrList[j].name == v_EPTF_ExecCtrl_TimeProfileList[vl_timeProfileIdx].timeProfileList[k].timeProfileDescrName) {
// time profile found:
// append data into DB:
var integer vl_currentSize := sizeof(v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].timeProfileIdList);
v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].timeProfileIdList[vl_currentSize] := j;
v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].eventIdList[vl_currentSize] := -1; // no event yet
break;
}
}
}
break;
}
}
}
// initializes the time profile database for a weighted scenario
private function f_EPTF_ExecCtrl_initProfileForSc(
// in integer grp,
in integer sidx
) runs on EPTF_ExecCtrl_CT {
var integer tcidx := 0; // tc 0 will contain the time profile data for the scenario CPS
v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx] := {
timeProfileIdList := {},
timeProfileIdx := -1,
eventIdList := {}
}; // time prof not defined for this TC
var EPTF_ExecCtrl_SCName tcId := {
eGrpName := v_ExecCtrl_entityGroups[v_ExecCtrl_scenarios[sidx].eGroupIdx].name,
scName := v_ExecCtrl_scenarios[sidx].scData.name
}
// find time profile for this tc:
for (var integer i:=0, size := sizeof(v_EPTF_ExecCtrl_TimeProfile2TcList); i<size; i:=i+1) {
// if (v_EPTF_ExecCtrl_TimeProfile2TcList[i].tcId == tcId) { // this is syntactically erroneous
// TCName ignored in timeProfile data, because it is a weighted scenario!
if (v_EPTF_ExecCtrl_TimeProfile2TcList[i].tcId.eGrpName == tcId.eGrpName
and v_EPTF_ExecCtrl_TimeProfile2TcList[i].tcId.scName == tcId.scName) {
// time prof found
// find the time profile data:
var integer vl_timeProfileIdx := -1;
for (var integer tpIdx :=0, sizet := sizeof(v_EPTF_ExecCtrl_TimeProfileList); tpIdx<sizet; tpIdx:=tpIdx+1) {
if (v_EPTF_ExecCtrl_TimeProfileList[tpIdx].name == v_EPTF_ExecCtrl_TimeProfile2TcList[i].timeProfileName) {
vl_timeProfileIdx := tpIdx;
break;
}
}
f_EPTF_Base_assert(%definitionId&": Unable to find the time profile " &v_EPTF_ExecCtrl_TimeProfile2TcList[i].timeProfileName&" in v_EPTF_ExecCtrl_TimeProfileList", vl_timeProfileIdx!=-1);
v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].timeProfileIdx := vl_timeProfileIdx;
// search time profile data for each profile in the list:
for(var integer k:=0, sizek := sizeof(v_EPTF_ExecCtrl_TimeProfileList[vl_timeProfileIdx].timeProfileList); k<sizek; k:=k+1) {
for(var integer j:=0, sizej := sizeof(v_EPTF_ExecCtrl_TimeProfileDescrList); j<sizej; j:=j+1) {
if (v_EPTF_ExecCtrl_TimeProfileDescrList[j].name == v_EPTF_ExecCtrl_TimeProfileList[vl_timeProfileIdx].timeProfileList[k].timeProfileDescrName) {
// time profile found:
// append data into DB:
var integer vl_currentSize := sizeof(v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].timeProfileIdList);
v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].timeProfileIdList[vl_currentSize] := j;
v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].eventIdList[vl_currentSize] := -1; // no event yet
break;
}
}
}
break;
}
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_getTimeProfileNameForTC
//
// Purpose:
// Returns the time profile name for a traffic case instance
//
// Parameters:
// pl_scIdx - *in integer* - the scenario instance idx
// pl_tcOfScIdx - *in integer* - the traffic case index in the scenario
//
// Return Value:
// charstring - name of the time profile ("" if no time profile is set)
//
// Errors & assertions:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_getTimeProfileNameForTC(
in integer pl_scIdx,
in integer pl_tcOfScIdx
) runs on EPTF_ExecCtrl_CT return charstring {
var charstring vl_timeProfileName := ""
if (v_EPTF_ExecCtrl_ScTimeProfileDB[pl_scIdx].tcTimeProfile[pl_tcOfScIdx].timeProfileIdx != -1) {
vl_timeProfileName := v_EPTF_ExecCtrl_TimeProfileList[v_EPTF_ExecCtrl_ScTimeProfileDB[pl_scIdx].tcTimeProfile[pl_tcOfScIdx].timeProfileIdx].name;
}
return vl_timeProfileName;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_startTimeProfiles
//
// Purpose:
// Starts all time profiles by scheduling their first event
//
// Parameters:
//
// Return Value:
//
// Errors & assertions:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_startTimeProfiles() runs on EPTF_ExecCtrl_CT {
v_EPTF_ExecCtrl_startTime := T_EPTF_componentClock.read; // read the scheduler clock to store the time of start
for (var integer sidx := 0, size := sizeof(v_EPTF_ExecCtrl_ScTimeProfileDB); sidx < size; sidx := sidx + 1)
{
for (var integer tcidx := 0, tsize := sizeof(v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile); tcidx < tsize; tcidx := tcidx + 1)
{
f_EPTF_ExecCtrl_startProfileForTc(/*grp,*/sidx,tcidx);
}
}
f_EPTF_ExecCtrl_debug("**********TIMEPROF STARTED*************");
f_EPTF_ExecCtrl_debug(log2str("v_EPTF_ExecCtrl_ScTimeProfileDB after start: ", v_EPTF_ExecCtrl_ScTimeProfileDB));
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_stopTimeProfiles
//
// Purpose:
// stops the time profile execution
//
// Parameters:
//
// Return Value:
//
// Errors & assertions:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_stopTimeProfiles() runs on EPTF_ExecCtrl_CT {
v_EPTF_ExecCtrl_startTime := -1.0; // this value is used to ignore additional time profile events
for (var integer sidx := 0, size := sizeof(v_EPTF_ExecCtrl_ScTimeProfileDB); sidx < size; sidx := sidx + 1)
{
for (var integer tcidx := 0, tsize := sizeof(v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile); tcidx < tsize; tcidx := tcidx + 1)
{
// here you should include your code:
for (var integer i:=0, lsize := sizeof(v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].timeProfileIdList); i<lsize; i:=i+1) {
var integer vl_eventIndex := v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].eventIdList[i];
// Cancel the event:
if (vl_eventIndex !=-1) {
if(not f_EPTF_SchedulerComp_CancelEvent(vl_eventIndex)) {
f_EPTF_ExecCtrl_warning(%definitionId& ": could not cancel event.");
}
v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].eventIdList[i] := -1;
}
} // end of for i
}
}
f_EPTF_ExecCtrl_debug("**********TIMEPROF STOPPED*************");
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_startTime
//
// Purpose:
// Returns the start time of the test execution
//
// Parameters:
//
// Return Value:
// float - the start time (-1.0 if not running)
//
// Errors & assertions:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_startTime() runs on EPTF_ExecCtrl_CT return float {
return v_EPTF_ExecCtrl_startTime;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_startAllScenarios
//
// Purpose:
// Starts all scenarios in ExecCtrl
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
// Starts all enabled scenarios. Also starts scenario groups
// and time profiles
//
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_startAllScenarios() runs on EPTF_ExecCtrl_CT
{
for(var integer sc:=0, size := sizeof(v_ExecCtrl_scenarios); sc<size; sc:=sc+1) {
f_EPTF_ExecCtrl_debug(%definitionId&": Checking scenario status");
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[sc].eGroupIdx;
var charstring eGrpName := v_ExecCtrl_entityGroups[vl_eGrpIdx].name;
var charstring scenName := v_ExecCtrl_scenarios[sc].scData.name;
if (f_EPTF_ExecCtrl_checkScenarioStatus({
eGrpName := eGrpName,
scName := scenName
},
t_ExecCtrl_scenarioReadyToStart))
{
f_EPTF_ExecCtrl_debug(log2str(
"Scenario: {", eGrpName,
", ", scenName,
" is ready to start"));
// Start scenario on LGens
if (f_EPTF_ExecCtrl_scenarioEnabled(sc)
and f_EPTF_ExecCtrl_scenarioIsNotInScenarioGroup(sc)) {
f_EPTF_ExecCtrl_startScenarioOnLGens(sc);
}
}
else {
f_EPTF_ExecCtrl_debug(log2str(
"Scenario: {", eGrpName,
", ", scenName,
" is NOT ready to start"));
//return
}
}
f_EPTF_ExecCtrl_startAllScenarioGroups();
// f_EPTF_Logging_debug(tsp_debug_EPTF_ExecCtrl_UIVars,
// "All scenarios are ready to run");
// start the time profiles:
f_EPTF_ExecCtrl_startTimeProfiles();
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_startAllScenarioGroups
//
// Purpose:
// Starts all scenarios in ExecCtrl that are in scenario groups
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_startAllScenarioGroups() runs on EPTF_ExecCtrl_CT {
for(var integer scGroupIdx :=0, size := sizeof(v_ExecCtrl_ScenarioGroupInstanceDB.data); scGroupIdx<size; scGroupIdx:=scGroupIdx+1) {
f_EPTF_ExecCtrl_ScenarioGroup_start(scGroupIdx);
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_stopCurrentPhaseForAllScenarioGroups
//
// Purpose:
// Starts all scenarios in ExecCtrl that are in scenario groups
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_stopCurrentPhaseForAllScenarioGroups() runs on EPTF_ExecCtrl_CT {
for(var integer scGroupIdx :=0, size := sizeof(v_ExecCtrl_ScenarioGroupInstanceDB.data); scGroupIdx<size; scGroupIdx:=scGroupIdx+1) {
f_EPTF_ExecCtrl_ScenarioGroup_stop(scGroupIdx);
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_stopAllScenarioGroups
//
// Purpose:
// Stops all scenario groups
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_stopAllScenarioGroups() runs on EPTF_ExecCtrl_CT {
for(var integer scGroupIdx :=0, size := sizeof(v_ExecCtrl_ScenarioGroupInstanceDB.data); scGroupIdx<size; scGroupIdx:=scGroupIdx+1) {
f_EPTF_ExecCtrl_ScenarioGroup_stop(scGroupIdx);
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_terminateAllScenarioGroups
//
// Purpose:
// Terminates all scenario groups
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
// Stops all scenario groups so that the phase actions
// are not executed, all scenarios in the scenario groups
// are stopped.
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_terminateAllScenarioGroups() runs on EPTF_ExecCtrl_CT {
for(var integer scGroupIdx :=0, size := sizeof(v_ExecCtrl_ScenarioGroupInstanceDB.data); scGroupIdx<size; scGroupIdx:=scGroupIdx+1) {
f_EPTF_ExecCtrl_stopScenarioGroupOnLGens(scGroupIdx);
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_stopAllScenarios
//
// Purpose:
// Stops all scenarios in ExecCtrl
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
// Also stops time profiles and scenario groups.
//
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_stopAllScenarios() runs on EPTF_ExecCtrl_CT {
// stop the time profiles:
f_EPTF_ExecCtrl_stopTimeProfiles();
// stop scenario groups
f_EPTF_ExecCtrl_stopAllScenarioGroups();
// Stop scenarios
for(var integer sc:=0, size := sizeof(v_ExecCtrl_scenarios); sc<size; sc:=sc+1) {
f_EPTF_ExecCtrl_debug(%definitionId&": Checking scenario status");
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[sc].eGroupIdx;
var charstring eGrpName := v_ExecCtrl_entityGroups[vl_eGrpIdx].name;
var charstring scenName := v_ExecCtrl_scenarios[sc].scData.name;
if (f_EPTF_ExecCtrl_checkScenarioStatus({
eGrpName := eGrpName,
scName := scenName
},
t_ExecCtrl_scenarioReadyToStop))
{
f_EPTF_ExecCtrl_debug(log2str(
"Scenario: {", eGrpName,
", ", scenName,
" is ready to stop"));
if (f_EPTF_ExecCtrl_scenarioIsNotInScenarioGroup(sc)) {
f_EPTF_ExecCtrl_stopScenarioOnLGens(sc);
}
}
else {
f_EPTF_ExecCtrl_debug(log2str(
"Scenario: {", eGrpName,
", ", scenName,
" is NOT ready to stop"));
//return
}
}
// f_EPTF_Logging_debug(tsp_debug_EPTF_ExecCtrl_UIVars,
// "DEBUG: all scenarios are ready to stop");
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_terminateAllScenarios
//
// Purpose:
// Terminates all scenarios in ExecCtrl
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
// Also stops time profiles and terminates scenario groups.
// Normal scenarios are stopped the same way as in
// <f_EPTF_ExecCtrl_stopAllScenarios>
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_terminateAllScenarios() runs on EPTF_ExecCtrl_CT {
// stop the time profiles:
f_EPTF_ExecCtrl_stopTimeProfiles();
// terminate scenario groups
f_EPTF_ExecCtrl_terminateAllScenarioGroups();
// Stop scenarios
for(var integer sc:=0, size := sizeof(v_ExecCtrl_scenarios); sc<size; sc:=sc+1) {
f_EPTF_ExecCtrl_debug(%definitionId&": Checking scenario status");
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[sc].eGroupIdx;
var charstring eGrpName := v_ExecCtrl_entityGroups[vl_eGrpIdx].name;
var charstring scenName := v_ExecCtrl_scenarios[sc].scData.name;
if (f_EPTF_ExecCtrl_checkScenarioStatus({
eGrpName := eGrpName,
scName := scenName
},
t_ExecCtrl_scenarioReadyToStop))
{
f_EPTF_ExecCtrl_debug(log2str(
"Scenario: {", eGrpName,
", ", scenName,
" is ready to stop"));
if (f_EPTF_ExecCtrl_scenarioIsNotInScenarioGroup(sc)) {
f_EPTF_ExecCtrl_stopScenarioOnLGens(sc);
}
}
else {
f_EPTF_ExecCtrl_debug(log2str(
"Scenario: {", eGrpName,
", ", scenName,
" is NOT ready to stop"));
//return
}
}
// f_EPTF_Logging_debug(tsp_debug_EPTF_ExecCtrl_UIVars,
// "DEBUG: all scenarios are ready to stop");
}
// starts a time profile by scheduling its first event
// only one event is running for each profile at a time. counters and data are passed in the eventId
private function f_EPTF_ExecCtrl_startProfileForTc(
// in integer grp,
in integer sidx,
in integer tcidx
) runs on EPTF_ExecCtrl_CT {
var integer timeProfileDataPos := 0; // current position in timeProfileData
var integer nofRepetition := 0; // current nofRepetition
// go through in the list of time profiles for this Tc:
for (var integer i:=0, size := sizeof(v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].timeProfileIdList); i<size; i:=i+1) {
// schedule the first event:
f_EPTF_ExecCtrl_TimeProfile_ScheduleEvent(sidx,tcidx,i,timeProfileDataPos,nofRepetition);
} // end of for i
}
// handles the time profile event
private function f_EPTF_ExecCtrl_TimeProfileEventHandler(
in EPTF_ScheduledAction pl_action, in integer pl_eventIndex
) runs on EPTF_ExecCtrl_CT return boolean {
f_EPTF_ExecCtrl_debug(log2str(%definitionId&": pl_action being handled: ", pl_action));
if (v_EPTF_ExecCtrl_startTime == -1.0) {
f_EPTF_ExecCtrl_debug("TimeProfile execution was stopped, event ignored.");
return true; // do not handle the event
}
var integer sidx := pl_action.actionId[0];
var integer tcidx := pl_action.actionId[1];
var integer i := pl_action.actionId[2];
var integer timeProfileDataPos := pl_action.actionId[3];
var integer nofRepetition := pl_action.actionId[4];
var integer vl_timeProfileIdx := v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].timeProfileIdx;
var integer vl_timeProfileId := v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].timeProfileIdList[i];
// set CPS:
var float targetValue := f_EPTF_ExecCtrl_getTimeProfileTargetValue(sidx,tcidx,i,timeProfileDataPos);
if (f_EPTF_ExecCtrl_isWeightedScenario(sidx)) {
f_EPTF_ExecCtrl_setCps_SC(sidx,targetValue);
} else {
f_EPTF_ExecCtrl_setCps_TC(sidx,tcidx,targetValue);
}
//reschedule event:
timeProfileDataPos := timeProfileDataPos + 1;
// end of time profile reached:
if (timeProfileDataPos==sizeof(v_EPTF_ExecCtrl_TimeProfileDescrList[vl_timeProfileId].timeProfileData)) {
// increase repetition:
nofRepetition := nofRepetition + 1;
// restore position to the beginning:
timeProfileDataPos := 0;
}
// max repetition reached (-1: will continue to infty):
// (repetition reaches maxRepetition+1: the profile executed maxRepetition times + the first execution)
if (v_EPTF_ExecCtrl_TimeProfileList[vl_timeProfileIdx].timeProfileList[i].nofRepetition != -1
and nofRepetition == v_EPTF_ExecCtrl_TimeProfileList[vl_timeProfileIdx].timeProfileList[i].nofRepetition + 1) {
v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].eventIdList[i] := -1; // reset the event id
return true; // no more event scheduled
}
// schedule the new event:
f_EPTF_ExecCtrl_TimeProfile_ScheduleEvent(sidx,tcidx,i,timeProfileDataPos,nofRepetition);
return true;
}
// schedules the time profile event
private function f_EPTF_ExecCtrl_TimeProfile_ScheduleEvent(
// in integer grp,
in integer sidx,
in integer tcidx,
in integer tpidx, // index in v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].timeProfileIdList
in integer timeProfileDataPos,
in integer nofRepetition
) runs on EPTF_ExecCtrl_CT {
var integer vl_timeProfileIdx := v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].timeProfileIdx;
var integer vl_timeProfileId := v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].timeProfileIdList[tpidx];
// f_EPTF_ExecCtrl_debug(log2str("vl_timeProfileIdx: ", vl_timeProfileIdx));
// f_EPTF_ExecCtrl_debug(log2str("v_EPTF_ExecCtrl_TimeProfileList[vl_timeProfileIdx]: ", v_EPTF_ExecCtrl_TimeProfileList[vl_timeProfileIdx]));
// f_EPTF_ExecCtrl_debug(log2str("vl_timeProfileId: ", vl_timeProfileId));
// f_EPTF_ExecCtrl_debug(log2str("v_EPTF_ExecCtrl_TimeProfileDescrList[vl_timeProfileId]: ", v_EPTF_ExecCtrl_TimeProfileDescrList[vl_timeProfileId]));
var float vl_when := v_EPTF_ExecCtrl_startTime +
v_EPTF_ExecCtrl_TimeProfileList[vl_timeProfileIdx].timeProfileList[tpidx].startTime
+ v_EPTF_ExecCtrl_TimeProfileDescrList[vl_timeProfileId].timeProfileData[timeProfileDataPos].time
+ int2float(nofRepetition)*v_EPTF_ExecCtrl_TimeProfileList[vl_timeProfileIdx].timeProfileList[tpidx].periodOfRepetition;
var EPTF_Scheduler_ActionHandler vl_actionHandler := refers(f_EPTF_ExecCtrl_TimeProfileEventHandler);
var EPTF_ActionId vl_action := {
//grp,
sidx,
tcidx,
tpidx, // index in v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].timeProfileIdList
timeProfileDataPos, // index in v_EPTF_ExecCtrl_TimeProfileDescrList[vl_timeProfileId].timeProfileData
nofRepetition // current nofRepetition
};
f_EPTF_ExecCtrl_debug(log2str("scheduling action: ", vl_action, " to: ", vl_when));
var integer vl_eventIndex;
if (f_EPTF_SchedulerComp_scheduleAction(
vl_when,
vl_actionHandler,
vl_action,
vl_eventIndex
)) {}; // to remove the warning
// store event idx:
v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].eventIdList[tpidx] := vl_eventIndex;
f_EPTF_ExecCtrl_debug(log2str("v_EPTF_ExecCtrl_ScTimeProfileDB[",sidx,"].tcTimeProfile[",tcidx,"] after schedule: ", v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx]));
}
// gets the target value from time profile data for a Traffic Case
private function f_EPTF_ExecCtrl_getTimeProfileTargetValue (
// in integer grp,
in integer sidx,
in integer tcidx,
in integer i,
in integer timeProfileDataPos
) runs on EPTF_ExecCtrl_CT return float {
var integer vl_timeProfileId := v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].timeProfileIdList[i];
return v_EPTF_ExecCtrl_TimeProfileDescrList[vl_timeProfileId].timeProfileData[timeProfileDataPos].targetValue;
}
} // group TimeProfile
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_setCps_TC
//
// Purpose:
// sets the Traffic case CPS in all related LGens
//
// Parameters:
// pl_scIdx - *in integer* - the scenario instace idx
// pl_tcOfScIdx - *in integer* - the tc of scenario idx
// cps - *in float* - CPS to set
//
// Return Value:
//
// Errors & assertions:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_setCps_TC (
// in integer grp,
in integer pl_scIdx,
in integer pl_tcOfScIdx,
in float cps
) runs on EPTF_ExecCtrl_CT {
f_EPTF_Base_assert(%definitionId&": Invalid SC index "&int2str(pl_scIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_scenarios))&").",
pl_scIdx >= 0 and pl_scIdx < sizeof(v_ExecCtrl_scenarios));
f_EPTF_Base_assert(%definitionId&": Invalid tcOfScenario index "&int2str(pl_tcOfScIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_scenarios[pl_scIdx].scData.tcList))&").",
pl_tcOfScIdx >= 0 and pl_tcOfScIdx < sizeof(v_ExecCtrl_scenarios[pl_scIdx].scData.tcList));
f_EPTF_Base_assert(%definitionId&": Cannot set traffic case CPS in the weighted scenario "&
v_ExecCtrl_scenarios[pl_scIdx].name,
not f_EPTF_ExecCtrl_isWeightedScenario(pl_scIdx));
var integer vl_tcIdx :=v_ExecCtrl_scenarios[pl_scIdx].tcIdxList[pl_tcOfScIdx];
f_EPTF_ExecCtrl_setCPSToReach_TC(vl_tcIdx,cps);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_setCps_SC
//
// Purpose:
// sets the Scenario CPS in all related LGens
//
// Parameters:
// pl_scIdx - *in integer* - the scenario instace idx
// cps - *in float* - CPS to set
//
// Return Value:
//
// Errors & assertions:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_setCps_SC (
// in integer grp,
in integer pl_scIdx,
in float cps
) runs on EPTF_ExecCtrl_CT {
f_EPTF_ExecCtrl_setCPSToReach_SC(pl_scIdx,cps);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_setStartDelay_TC
//
// Purpose:
// sets the Traffic case startDelay in all related LGens
//
// Parameters:
// pl_scIdx - *in integer* - the scenario instace idx
// pl_tcOfScIdx - *in integer* - the tc of scenario idx
// startDelay - *in float* - startDelay to set
//
// Return Value:
//
// Errors & assertions:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_setStartDelay_TC (
// in integer grp,
in integer pl_scIdx,
in integer pl_tcOfScIdx,
in float pl_startDelay
) runs on EPTF_ExecCtrl_CT {
f_EPTF_Base_assert(%definitionId&": Invalid SC index "&int2str(pl_scIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_scenarios))&").",
pl_scIdx >= 0 and pl_scIdx < sizeof(v_ExecCtrl_scenarios));
f_EPTF_Base_assert(%definitionId&": Invalid tcOfScenario index "&int2str(pl_tcOfScIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_scenarios[pl_scIdx].scData.tcList))&").",
pl_tcOfScIdx >= 0 and pl_tcOfScIdx < sizeof(v_ExecCtrl_scenarios[pl_scIdx].scData.tcList));
f_EPTF_Base_assert(%definitionId&": Cannot set traffic case StartDelay in the weighted scenario "&
v_ExecCtrl_scenarios[pl_scIdx].name,
not f_EPTF_ExecCtrl_isWeightedScenario(pl_scIdx));
v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].startDelay := pl_startDelay;
f_EPTF_ExecCtrl_debug(log2str("updated v_ExecCtrl_scenarios[",pl_scIdx,"].scData.tcList[",pl_tcOfScIdx,"].startDelay: ", pl_startDelay));
f_EPTF_ExecCtrl_sendUpdatedStartDelay(pl_scIdx,pl_tcOfScIdx);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_getCPSToReach_TC
//
// Purpose:
// returns the target CPS of a traffic case instance
//
// Parameters:
// pl_tcIdx - *in integer* - id of the traffic case instance
//
// Return Value:
// float - the targetCPS (i.e. the cpsToReach) of the traffic case
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_getCPSToReach_TC(
in integer pl_tcIdx
) runs on EPTF_ExecCtrl_CT return float {
f_EPTF_Base_assert(%definitionId&": Invalid TC index "&int2str(pl_tcIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_trafficCases))&").",
pl_tcIdx >= 0 and pl_tcIdx < sizeof(v_ExecCtrl_trafficCases));
var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioIdxForTc(pl_tcIdx);
f_EPTF_Base_assert(%definitionId&": cpsToReach is not available for the traffic case "&
f_EPTF_ExecCtrl_getTrafficCaseName(pl_tcIdx)&": traffic case is in a weighted scenario: "
&f_EPTF_ExecCtrl_getScenarioInstanceName(vl_scIdx),
not f_EPTF_ExecCtrl_isWeightedScenario(vl_scIdx));
var integer vl_tcOfScIdx := v_ExecCtrl_trafficCases[pl_tcIdx].tcOfScenarioIdx;
return v_ExecCtrl_scenarios[vl_scIdx].scData.tcList[vl_tcOfScIdx].target.cpsToReach;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_setCPSToReach_TC
//
// Purpose:
// Sets the target CPS of a traffic case instance
//
// Parameters:
// pl_tcIdx - *in integer* - id of the traffic case instance
// pl_cpsToReach - *in float* - the targetCPS (i.e. the cpsToReach) to set
//
// Return Value:
// -
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_setCPSToReach_TC(
in integer pl_tcIdx,
in float pl_cpsToReach
) runs on EPTF_ExecCtrl_CT {
f_EPTF_Base_assert(%definitionId&": Invalid TC index "&int2str(pl_tcIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_trafficCases))&").",
pl_tcIdx >= 0 and pl_tcIdx < sizeof(v_ExecCtrl_trafficCases));
var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioIdxForTc(pl_tcIdx);
f_EPTF_Base_assert(%definitionId&": Cannot set cpsToReach for the traffic case "&
f_EPTF_ExecCtrl_getTrafficCaseName(pl_tcIdx)&": traffic case is in a weighted scenario: "
&f_EPTF_ExecCtrl_getScenarioInstanceName(vl_scIdx),
not f_EPTF_ExecCtrl_isWeightedScenario(vl_scIdx));
var integer vl_tcOfScIdx := v_ExecCtrl_trafficCases[pl_tcIdx].tcOfScenarioIdx;
v_ExecCtrl_scenarios[vl_scIdx].scData.tcList[vl_tcOfScIdx].target.cpsToReach := pl_cpsToReach;
f_EPTF_ExecCtrl_debug(log2str("updated v_ExecCtrl_scenarios[",vl_scIdx,"].scData.tcList[",vl_tcOfScIdx,"].target.cpsToReach: ", v_ExecCtrl_scenarios[vl_scIdx].scData.tcList[vl_tcOfScIdx].target.cpsToReach));
f_EPTF_ExecCtrl_sendUpdatedCps(vl_scIdx,vl_tcOfScIdx);
f_EPTF_ExecCtrl_callCPSChangedCallbacks_TC(pl_cpsToReach,v_ExecCtrl_scenarios[vl_scIdx].tcIdxList[vl_tcOfScIdx]);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_getCPSToReach_SC
//
// Purpose:
// returns the target CPS of a scenario instance
//
// Parameters:
// pl_scIdx - *in integer* - id of the scenario instance
//
// Return Value:
// float - the targetCPS (i.e. the cpsToReach) of the scenario
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_getCPSToReach_SC(
in integer pl_scIdx
) runs on EPTF_ExecCtrl_CT return float {
f_EPTF_Base_assert(%definitionId&": Invalid SC index "&int2str(pl_scIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_scenarios))&").",
pl_scIdx >= 0 and pl_scIdx < sizeof(v_ExecCtrl_scenarios));
f_EPTF_Base_assert(%definitionId&": CPSToReach is not available for non-weighted scenario: "
&f_EPTF_ExecCtrl_getScenarioInstanceName(pl_scIdx),
f_EPTF_ExecCtrl_isWeightedScenario(pl_scIdx));
return v_ExecCtrl_scenarios[pl_scIdx].scData.weightedScData.cpsToReach;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_setCPSToReach_SC
//
// Purpose:
// Sets the target CPS of a scenario instance
//
// Parameters:
// pl_scIdx - *in integer* - id of the scenario instance
// pl_cpsToReach - *in float* - the targetCPS (i.e. the cpsToReach) to set
//
// Return Value:
// float - the targetCPS (i.e. the cpsToReach) of the scenario
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_setCPSToReach_SC(
in integer pl_scIdx,
in float pl_cpsToReach
) runs on EPTF_ExecCtrl_CT {
f_EPTF_Base_assert(%definitionId&": Invalid SC index "&int2str(pl_scIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_scenarios))&").",
pl_scIdx >= 0 and pl_scIdx < sizeof(v_ExecCtrl_scenarios));
f_EPTF_Base_assert(%definitionId&": Cannot set scenario CPS in the non-weighted scenario "&
v_ExecCtrl_scenarios[pl_scIdx].name,
f_EPTF_ExecCtrl_isWeightedScenario(pl_scIdx));
v_ExecCtrl_scenarios[pl_scIdx].scData.weightedScData.cpsToReach := pl_cpsToReach;
f_EPTF_ExecCtrl_debug(log2str("updated v_ExecCtrl_scenarios[",pl_scIdx,"].scData.weightedScData.cpsToReach: ", v_ExecCtrl_scenarios[pl_scIdx].scData.weightedScData.cpsToReach));
f_EPTF_ExecCtrl_sendUpdatedScenarioCps(pl_scIdx);
f_EPTF_ExecCtrl_callCPSChangedCallbacks_SC(pl_cpsToReach,pl_scIdx);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_getTCWeight
//
// Purpose:
// returns the weight of the traffic case instance in the weighted scenario
//
// Parameters:
// pl_tcIdx - *in integer* - id of the traffic case instance
//
// Return Value:
// float - the tcWeight of the traffic case
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_getTCWeight(
in integer pl_tcIdx
) runs on EPTF_ExecCtrl_CT return float {
f_EPTF_Base_assert(%definitionId&": Invalid index "&int2str(pl_tcIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_trafficCases))&").",
pl_tcIdx >= 0 and pl_tcIdx < sizeof(v_ExecCtrl_trafficCases));
var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioIdxForTc(pl_tcIdx);
f_EPTF_Base_assert(%definitionId&": Traffic case weight is not available for the traffic case "&
f_EPTF_ExecCtrl_getTrafficCaseName(pl_tcIdx)&": traffic case is not in a weighted scenario: "
&f_EPTF_ExecCtrl_getScenarioInstanceName(vl_scIdx),
f_EPTF_ExecCtrl_isWeightedScenario(vl_scIdx));
var integer vl_tcOfScIdx := v_ExecCtrl_trafficCases[pl_tcIdx].tcOfScenarioIdx;
return v_ExecCtrl_scenarios[vl_scIdx].scData.tcList[vl_tcOfScIdx].target.trafficWeight;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_setTCWeight
//
// Purpose:
// Sets the weight of the traffic case instance in the weighted scenario
//
// Parameters:
// pl_tcIdx - *in integer* - id of the traffic case instance
// pl_tcWeight - *in float* - the weight of the traffic case
//
// Return Value:
// -
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_setTCWeight(
in integer pl_tcIdx,
in float pl_tcWeight
) runs on EPTF_ExecCtrl_CT {
f_EPTF_Base_assert(%definitionId&": Invalid index "&int2str(pl_tcIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_trafficCases))&").",
pl_tcIdx >= 0 and pl_tcIdx < sizeof(v_ExecCtrl_trafficCases));
var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioIdxForTc(pl_tcIdx);
f_EPTF_Base_assert(%definitionId&": Traffic case weight is not available for the traffic case "&
f_EPTF_ExecCtrl_getTrafficCaseName(pl_tcIdx)&": traffic case is not in a weighted scenario: "
&f_EPTF_ExecCtrl_getScenarioInstanceName(vl_scIdx),
f_EPTF_ExecCtrl_isWeightedScenario(vl_scIdx));
var integer vl_tcOfScIdx := v_ExecCtrl_trafficCases[pl_tcIdx].tcOfScenarioIdx;
v_ExecCtrl_scenarios[vl_scIdx].scData.tcList[vl_tcOfScIdx].target.trafficWeight := pl_tcWeight;
f_EPTF_ExecCtrl_sendUpdatedCps(vl_scIdx,vl_tcOfScIdx);
}
group EPTF_ExecCtrl_Regulator {
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_getRegulatorNameVarName
//
// Purpose:
// Gives back the RegulatorName Variable Name from the idName and the regulatedItemData in hash.
//
// Parameters:
// pl_idName - *in* <EPTF_ExecCtrl_RegulatedItemName> - Regulated Item Name
// pl_regulatedItemDataIdInHash - *in* *integer* - regulatedItemData hash id
//
// Return Value:
// *charstring* - Variable name of RegulatorName
//
// Errors:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_getRegulatorNameVarName(in EPTF_ExecCtrl_RegulatedItemName pl_idName,
in integer pl_regulatedItemDataIdInHash)
runs on EPTF_ExecCtrl_CT
return charstring{
var EPTF_ExecCtrl_RegulatedItemId vl_regulatedItemData := f_EPTF_ExecCtrl_Regulator_getRegulatedItemDataById(pl_regulatedItemDataIdInHash);
// Regulator name
if (ischosen(pl_idName.cps_TC)) {
// "SC2." & "Traffic.Regulator." & grpName&"."& int2str(sidx) & "." & int2str(tcidx);
return "Traffic.Regulator." &
pl_idName.cps_TC.eGrpName
&"."&int2str(vl_regulatedItemData.cps_TC.scenidx)
&"."&int2str(vl_regulatedItemData.cps_TC.tcidx);
}
if (ischosen(pl_idName.cps_SC)) {
// "Traffic.Regulator." & grpName&"."& int2str(sidx);
return "Traffic.Regulator." &
pl_idName.cps_SC.eGrpName
&"."&int2str(vl_regulatedItemData.cps_SC.scenidx);
}
if (ischosen(pl_idName.cps_TCInPhase)) {
// "SC2." & "Traffic.Regulator." & grpName&"."& int2str(sidx) & "." & int2str(tcidx);
return "Traffic.Regulator." &
pl_idName.cps_TCInPhase.eGrpName
&"."&int2str(vl_regulatedItemData.cps_TCInPhase.scenidx)
&"."&int2str(vl_regulatedItemData.cps_TCInPhase.tcidx)
&".InPhase."&vl_regulatedItemData.cps_TCInPhase.phase;
}
if (ischosen(pl_idName.cps_SCInPhase)) {
// "Traffic.Regulator." & grpName&"."& int2str(sidx);
return "Traffic.Regulator." &
pl_idName.cps_SCInPhase.eGrpName
&"."&int2str(vl_regulatedItemData.cps_SCInPhase.scenidx)
&".InPhase."&vl_regulatedItemData.cps_SCInPhase.phase;
}
return "";
}
// initializes the EPTF_ExecCtrl_Regulator, this is the main init function
private function f_EPTF_ExecCtrl_Regulator_init(in EPTF_CharstringList pl_regulatorNames, in EPTF_ExecCtrl_RegulatedItems pl_EPTF_ExecCtrl_RegulatedItems) runs on EPTF_ExecCtrl_CT {
f_EPTF_ExecCtrl_Regulator_initRegulators(pl_regulatorNames);
f_EPTF_ExecCtrl_Regulator_initRegulateditems(pl_EPTF_ExecCtrl_RegulatedItems);
f_EPTF_ExecCtrl_registerScenarioStateChangedCallback(refers(f_EPTF_ExecCtrl_Regulator_scenarioStateChangedCallback));
f_EPTF_ExecCtrl_registerScenarioGroupPhaseChangedCallback(refers(f_EPTF_ExecCtrl_Regulator_scenarioGroupPhaseChangedCallback));
f_EPTF_ExecCtrl_registerTrafficCaseStateChangedCallback(refers(f_EPTF_ExecCtrl_Regulator_trafficCaseStateChangedCallback));
}
// initializes v_EPTF_ExecCtrl_Regulators
private function f_EPTF_ExecCtrl_Regulator_initRegulators(in EPTF_CharstringList pl_regulatorNames) runs on EPTF_ExecCtrl_CT {
v_EPTF_ExecCtrl_Regulators := {};
for(var integer i:=0, size := sizeof(pl_regulatorNames); i<size; i:=i+1) {
var integer vl_regulatorId := f_EPTF_ExecCtrl_Regulator_addRegulator(pl_regulatorNames[i]);
}
f_EPTF_ExecCtrl_debug(log2str("v_EPTF_ExecCtrl_Regulators: ", v_EPTF_ExecCtrl_Regulators));
}
// initializes the regulator database by adding the new regulated items
private function f_EPTF_ExecCtrl_Regulator_initRegulateditems(in EPTF_ExecCtrl_RegulatedItems pl_EPTF_ExecCtrl_RegulatedItems) runs on EPTF_ExecCtrl_CT {
v_EPTF_ExecCtrl_RegulatedItems := {};
v_EPTF_ExecCtrl_RegulatedItemIdsDB := {};
for(var integer i:=0, size := sizeof(pl_EPTF_ExecCtrl_RegulatedItems); i<size; i:=i+1) {
if (-1==f_EPTF_ExecCtrl_Regulator_addRegulatedItem(
pl_EPTF_ExecCtrl_RegulatedItems[i].idName,
pl_EPTF_ExecCtrl_RegulatedItems[i].regulatorName,
pl_EPTF_ExecCtrl_RegulatedItems[i].weight,
pl_EPTF_ExecCtrl_RegulatedItems[i].enabled
)) {/*to remove the warning*/};
}
var integer vl_sizeScen := f_EPTF_ExecCtrl_numScenarios();
var integer vl_sizeTCs;
for (var integer sidx := 0; sidx < vl_sizeScen; sidx := sidx + 1)
{
var integer vl_eGrpIdx := f_EPTF_ExecCtrl_getScenarioEGroupIdx(sidx);
var charstring grpName := f_EPTF_ExecCtrl_eGrp_name(vl_eGrpIdx);
var charstring scenName := f_EPTF_ExecCtrl_getScenarioName(sidx);
vl_sizeTCs := f_EPTF_ExecCtrl_numTcOfScenario(sidx);
for (var integer tcidx := 0; tcidx < vl_sizeTCs; tcidx := tcidx + 1)
{
var charstring tcName := f_EPTF_ExecCtrl_tcNameOfTcOfSc(sidx,tcidx)
var charstring vl_regulatorName := "";
var EPTF_ExecCtrl_RegulatedItemName vl_idName;
var integer vl_scGrpidx := f_EPTF_ExecCtrl_ScenarioGroup_get_byScIndex(sidx);
if (vl_scGrpidx==-1) {
if (f_EPTF_ExecCtrl_isWeightedScenario(sidx)) {
vl_idName := {cps_SC := {grpName,scenName}};
} else {
vl_idName := {cps_TC := {grpName,scenName,tcName}};
}
} else {
// for scenarios in scenario groups: it shows the regulator in the current phase
var EPTF_ExecCtrl_PhaseList_Instance phaseList := f_EPTF_ExecCtrl_getScenarioGroupInstanceGroupPhaseList(vl_scGrpidx);
// create variables for all phases:
for(var integer ph:=0; ph<f_EPTF_ExecCtrl_getScenarioGroupInstanceGroupPhaseListPhasesNum(vl_scGrpidx); ph:=ph+1) {
var charstring vl_phaseName := f_EPTF_ExecCtrl_getScenarioGroupInstanceGroupPhaseListPhaseName(vl_scGrpidx,ph);
if (f_EPTF_ExecCtrl_isWeightedScenario(sidx)) {
vl_idName := {cps_SCInPhase := {grpName,scenName, vl_phaseName}};
} else {
vl_idName := {cps_TCInPhase := {grpName,scenName,tcName, vl_phaseName}};
}
var integer vl_regulatedItemId := f_EPTF_ExecCtrl_Regulator_getRegulatedItemId(vl_idName);
if (vl_regulatedItemId==-1) {
// add new regulated item:
vl_regulatedItemId := f_EPTF_ExecCtrl_Regulator_addRegulatedItem(vl_idName,"");
}
}
// put regulator in CURRENT PHASE to the GUI:
var charstring vl_phaseName := f_EPTF_ExecCtrl_getScenarioGroupInstanceActualPhaseName(vl_scGrpidx);
if (f_EPTF_ExecCtrl_isWeightedScenario(sidx)) {
vl_idName := {cps_SCInPhase := {grpName,scenName, vl_phaseName}};
} else {
vl_idName := {cps_TCInPhase := {grpName,scenName,tcName, vl_phaseName}};
}
}
var integer vl_regulatedItemId := f_EPTF_ExecCtrl_Regulator_getRegulatedItemId(vl_idName);
if (vl_regulatedItemId==-1) {
// add new regulated item:
vl_regulatedItemId := f_EPTF_ExecCtrl_Regulator_addRegulatedItem(vl_idName,"");
}
}
}
if(c_EPTF_Common_debugSwitch and f_EPTF_ExecCtrl_debugEnabled()) {
f_EPTF_ExecCtrl_debug("Regulator database initialized.");
f_EPTF_ExecCtrl_Regulator_logAll();
}
}
// start/stop relevant regulators if phase of the scenario group changes
private function f_EPTF_ExecCtrl_Regulator_scenarioGroupPhaseChangedCallback(in charstring pl_sgName, in integer pl_actualPhaseIdx) runs on EPTF_ExecCtrl_CT {
var integer vl_sgIdx := f_EPTF_ExecCtrl_ScenarioGroup_getIdx(pl_sgName);
// start/stop regulators for all scenarios and traffic cases in the scenario group:
for (var integer i:=0, size := sizeof(v_ExecCtrl_ScenarioGroupInstanceDB.data[vl_sgIdx].scenarios); i<size; i:=i+1) {
var integer vl_scIdx := v_ExecCtrl_ScenarioGroupInstanceDB.data[vl_sgIdx].scenarios[i].idx;
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[vl_scIdx].eGroupIdx;
var charstring vl_eGrpName := v_ExecCtrl_entityGroups[vl_eGrpIdx].name;
var charstring vl_scenName := v_ExecCtrl_scenarios[vl_scIdx].scData.name;
f_EPTF_ExecCtrl_Regulator_scenarioStateChangedCallback(vl_eGrpName,vl_scenName, "");
// go through all traffic cases
for (var integer tcOfSc:=0; tcOfSc<f_EPTF_ExecCtrl_numTcOfScenario(vl_scIdx); tcOfSc:=tcOfSc+1) {
var charstring vl_tcName := f_EPTF_LGenBase_tcNameOfTcOfSc(v_ExecCtrl_scenarios[vl_scIdx].scData,tcOfSc);
f_EPTF_ExecCtrl_Regulator_trafficCaseStateChangedCallback(vl_eGrpName,vl_scenName,vl_tcName,"");
}
}
}
// check if the regulators belonging this scenario should be enabled/disabled and enable/disable them
private function f_EPTF_ExecCtrl_Regulator_scenarioStateChangedCallback(in charstring pl_eGrpName, in charstring pl_scName, in charstring pl_state) runs on EPTF_ExecCtrl_CT {
// find the regulators that regulate items in the current scenario:
var EPTF_IntegerList vl_regulatorIdxList := {};
f_EPTF_ExecCtrl_Regulator_findRegulatorsForScenario(pl_eGrpName,pl_scName,vl_regulatorIdxList);
for(var integer i:=0, size := sizeof(vl_regulatorIdxList); i<size; i:=i+1) {
f_EPTF_ExecCtrl_Regulator_startStop(vl_regulatorIdxList[i]);
}
}
// check if the regulators belonging this traffic case should be enabled/disabled and enable/disable them
private function f_EPTF_ExecCtrl_Regulator_trafficCaseStateChangedCallback(in charstring pl_eGrpName, in charstring pl_scName, in charstring pl_tcName, in charstring pl_state) runs on EPTF_ExecCtrl_CT {
// find the regulators that regulate items in the current scenario:
var EPTF_IntegerList vl_regulatorIdxList := {};
f_EPTF_ExecCtrl_Regulator_findRegulatorsForTrafficCase(pl_eGrpName,pl_scName,pl_tcName,vl_regulatorIdxList);
for(var integer i:=0, size := sizeof(vl_regulatorIdxList); i<size; i:=i+1) {
f_EPTF_ExecCtrl_Regulator_startStop(vl_regulatorIdxList[i]);
}
}
// if the status of the regulator changes to connected, check if the regulator should be enabled/disabled and enable/disable it
private function f_EPTF_ExecCtrl_Regulator_statusChangePostProc(
in integer pl_idx,
in EPTF_IntegerList pl_argList)
runs on EPTF_ExecCtrl_CT {
if (not v_ExecCtrl_initialized) {
return;
}
var integer vl_regulatorId := pl_argList[0];
var integer vl_regulatorStatusIdx := f_EPTF_ExecCtrl_Regulator_getRegulatorStatusIdxByRegulatorId(vl_regulatorId);
if (vl_regulatorStatusIdx!=-1) {
var EPTF_StatusLED vl_regulatorStatus := f_EPTF_Var_getStatusLEDValue(vl_regulatorStatusIdx);
if (vl_regulatorStatus == {led_yellow, "Registering..."}) {
var integer vl_regulatorCompRefInt := float2int(f_EPTF_Var_getFloatValue(v_EPTF_ExecCtrl_Regulators[vl_regulatorId].currentLoadIdx)+0.1);
if (vl_regulatorCompRefInt!=0) {
var charstring vl_regulatorName := f_EPTF_ExecCtrl_Regulator_getRegulatorNameByRegulatorId(vl_regulatorId);
var EPTF_Var_CT vl_regulatorCompRef := f_EPTF_Var_downcast(f_EPTF_Base_downcast(vl_regulatorCompRefInt));
f_EPTF_ExecCtrl_debug(%definitionId&"Regulator """&vl_regulatorName&""" is connected, initializing variables...");
f_EPTF_Var_setSubsCanAdjust(v_EPTF_ExecCtrl_Regulators[vl_regulatorId].totalValueIdx,false);
f_EPTF_Var_setSubsCanAdjust(v_EPTF_ExecCtrl_Regulators[vl_regulatorId].targetLoadIdx,true);
var charstring vl_currentName := "EPTF_LoadRegulator."&c_EPTF_ExecCtrl_Regulator_totalValue&"."&vl_regulatorName;
f_EPTF_Var_resubscribeRemote(vl_regulatorCompRef,vl_currentName,realtime,v_EPTF_ExecCtrl_Regulators[vl_regulatorId].totalValueIdx);
vl_currentName := "EPTF_LoadRegulator."&c_EPTF_ExecCtrl_Regulator_targetLoad&"."&vl_regulatorName;
f_EPTF_Var_resubscribeRemote(vl_regulatorCompRef,vl_currentName,realtime,v_EPTF_ExecCtrl_Regulators[vl_regulatorId].targetLoadIdx);
vl_currentName := "EPTF_LoadRegulator."&c_EPTF_ExecCtrl_Regulator_currentLoad&"."&vl_regulatorName;
f_EPTF_Var_resubscribeRemote(vl_regulatorCompRef,vl_currentName,realtime,v_EPTF_ExecCtrl_Regulators[vl_regulatorId].currentLoadIdx);
vl_currentName := "EPTF_LoadRegulator."&c_EPTF_ExecCtrl_Regulator_status&"."&vl_regulatorName;
f_EPTF_Var_resubscribeRemote(vl_regulatorCompRef,vl_currentName,realtime,v_EPTF_ExecCtrl_Regulators[vl_regulatorId].statusIdx);
vl_currentName := "EPTF_LoadRegulator."&c_EPTF_ExecCtrl_Regulator_enable&"."&vl_regulatorName;
f_EPTF_Var_resubscribeRemote(vl_regulatorCompRef,vl_currentName,realtime,v_EPTF_ExecCtrl_Regulators[vl_regulatorId].enableIdx);
}
}
else if (vl_regulatorStatus == {led_green, "Connected"}) {
f_EPTF_ExecCtrl_debug(%definitionId&"Regulator is connected, checking if it should be started");
f_EPTF_ExecCtrl_Regulator_startStop(vl_regulatorId);
} else if (vl_regulatorStatus == {led_red, "Disconnected"}) {
f_EPTF_ExecCtrl_debug(%definitionId&"Regulator is disconnected");
f_EPTF_Var_unsubscribe(v_EPTF_ExecCtrl_Regulators[vl_regulatorId].totalValueIdx);
f_EPTF_Var_unsubscribe(v_EPTF_ExecCtrl_Regulators[vl_regulatorId].targetLoadIdx);
f_EPTF_Var_unsubscribe(v_EPTF_ExecCtrl_Regulators[vl_regulatorId].currentLoadIdx);
f_EPTF_Var_unsubscribe(v_EPTF_ExecCtrl_Regulators[vl_regulatorId].statusIdx);
f_EPTF_Var_unsubscribe(v_EPTF_ExecCtrl_Regulators[vl_regulatorId].enableIdx);
f_EPTF_Var_setSubsCanAdjust(v_EPTF_ExecCtrl_Regulators[vl_regulatorId].totalValueIdx,true);
f_EPTF_Var_setSubsCanAdjust(v_EPTF_ExecCtrl_Regulators[vl_regulatorId].targetLoadIdx,false);
}
}
}
// the the regulated item to v_EPTF_ExecCtrl_RegulatedItemIdsDB for fast access
private function f_EPTF_ExecCtrl_Regulator_addToRegulatedItemIdsDB(in integer pl_regulatedItemId) runs on EPTF_ExecCtrl_CT {
// determinde egrpidx,scenidx,tcidx:
// currently egrpIdx is not used!!!
v_EPTF_ExecCtrl_RegulatedItemIdsDB[pl_regulatedItemId] := f_EPTF_ExecCtrl_Regulator_itemName2ItemId(v_EPTF_ExecCtrl_RegulatedItems[pl_regulatedItemId].idName);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_Regulator_addRegulator
//
// Purpose:
// creates a regulator and returns the id of the regulator,
// if the regulator exists already, it returns its idx
//
// Parameters:
// pl_regulatorName - *in charstring* - the name of the regulator
//
// Return Value:
// integer - id of the regulator
//
// Errors & assertions:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_Regulator_addRegulator(in charstring pl_regulatorName) runs on EPTF_ExecCtrl_CT return integer {
if (pl_regulatorName == "") {
return -1; // empty name is not allowed
}
var integer vl_regulatorId := f_EPTF_ExecCtrl_Regulator_getRegulatorId(pl_regulatorName);
if (vl_regulatorId != -1) {
return vl_regulatorId; // regulator already registered
}
// add to regulator database:
vl_regulatorId := sizeof(v_EPTF_ExecCtrl_Regulators);
v_EPTF_ExecCtrl_Regulators[vl_regulatorId] := {pl_regulatorName, {}, 0,0,0,0,0};
// create an EPTF Variable that holds the targetValue:
var charstring vl_currentName := "EPTF_ExecCtrl."&c_EPTF_ExecCtrl_Regulator_totalValue&"."&pl_regulatorName;
f_EPTF_Var_newFloat(
vl_currentName,
0.0,
v_EPTF_ExecCtrl_Regulators[vl_regulatorId].totalValueIdx
);
f_EPTF_Var_addPostProcFn(
v_EPTF_ExecCtrl_Regulators[vl_regulatorId].totalValueIdx, { refers(f_EPTF_ExecCtrl_Regulator_updateTotalValue), {vl_regulatorId}}
);
f_EPTF_ExecCtrl_debug(log2str("Variable created to set totalValue for regulator ",pl_regulatorName, " : ",vl_currentName));
// create an EPTF Variable that holds the targetLoad:
vl_currentName := "EPTF_ExecCtrl."&c_EPTF_ExecCtrl_Regulator_targetLoad&"."&pl_regulatorName;
f_EPTF_Var_newFloat(
vl_currentName,
0.0,
v_EPTF_ExecCtrl_Regulators[vl_regulatorId].targetLoadIdx
);
f_EPTF_Var_setSubsCanAdjust(v_EPTF_ExecCtrl_Regulators[vl_regulatorId].targetLoadIdx,false);
f_EPTF_ExecCtrl_debug(log2str("Variable created to set targetLoad for regulator ",pl_regulatorName, " : ",vl_currentName));
// create an EPTF Variable that holds the currentLoad:
vl_currentName := "EPTF_ExecCtrl."&c_EPTF_ExecCtrl_Regulator_currentLoad&"."&pl_regulatorName;
f_EPTF_Var_newFloat(
vl_currentName,
0.0,
v_EPTF_ExecCtrl_Regulators[vl_regulatorId].currentLoadIdx
);
f_EPTF_Var_setSubsCanAdjust(v_EPTF_ExecCtrl_Regulators[vl_regulatorId].currentLoadIdx,false);
f_EPTF_ExecCtrl_debug(log2str("Variable created to set currentLoad for regulator ",pl_regulatorName, " : ",vl_currentName));
// create an EPTF Variable that holds the status:
vl_currentName := "EPTF_ExecCtrl."&c_EPTF_ExecCtrl_Regulator_status&"."&pl_regulatorName;
f_EPTF_Var_newStatusLED(
vl_currentName,
{led_red, "Disconnected"},
v_EPTF_ExecCtrl_Regulators[vl_regulatorId].statusIdx
);
f_EPTF_Var_setSubsCanAdjust(v_EPTF_ExecCtrl_Regulators[vl_regulatorId].statusIdx,false);
f_EPTF_Var_addPostProcFn(
v_EPTF_ExecCtrl_Regulators[vl_regulatorId].statusIdx, { refers(f_EPTF_ExecCtrl_Regulator_statusChangePostProc), {vl_regulatorId}}
);
// FIXME: refactor needed to be able to disable var here
//f_EPTF_Var_setSubsCanAdjust(v_EPTF_ExecCtrl_Regulators[vl_regulatorId].statusIdx,false);
f_EPTF_ExecCtrl_debug(log2str("Variable created to set status for regulator ",pl_regulatorName, " : ",vl_currentName));
// create an EPTF Variable that holds the enable:
vl_currentName := "EPTF_ExecCtrl."&c_EPTF_ExecCtrl_Regulator_enable&"."&pl_regulatorName;
f_EPTF_Var_newBool(
vl_currentName,
false,
v_EPTF_ExecCtrl_Regulators[vl_regulatorId].enableIdx
);
f_EPTF_ExecCtrl_debug(log2str("Variable created to set the enable flag for regulator ",pl_regulatorName, " : ",vl_currentName));
return vl_regulatorId;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_Regulator_getRegulatorId
//
// Purpose:
// returns the id of the regulator in v_EPTF_ExecCtrl_Regulators (same as in v_EPTF_ExecCtrl_RegulatorNames)
//
// Parameters:
// pl_regulatorName - *in charstring* - the name of the regulator
//
// Return Value:
// integer - id of the regulator
//
// Errors & assertions:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_Regulator_getRegulatorId(in charstring pl_regulatorName) runs on EPTF_ExecCtrl_CT return integer {
for(var integer i:=0, size := sizeof(v_EPTF_ExecCtrl_Regulators); i<size; i:=i+1) {
if (v_EPTF_ExecCtrl_Regulators[i].name == pl_regulatorName) {
return i;
}
}
return -1; // not found
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_Regulator_regulatorName
//
// Purpose:
// returns the name of the regulator from the index in v_EPTF_ExecCtrl_Regulators (same as in v_EPTF_ExecCtrl_RegulatorNames)
//
// Parameters:
// pl_regulatorId - *in integer* - the id of the regulator
//
// Return Value:
// charstring - name of the regulator ("" if not available)
//
// Errors & assertions:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_Regulator_regulatorName(in integer pl_regulatorId) runs on EPTF_ExecCtrl_CT return charstring {
var charstring vl_regulatorName := "";
if (0<=pl_regulatorId and pl_regulatorId<sizeof(v_EPTF_ExecCtrl_RegulatorNames)) {
vl_regulatorName := v_EPTF_ExecCtrl_RegulatorNames[pl_regulatorId];
}
return vl_regulatorName;
}
friend function f_EPTF_ExecCtrl_Regulator_getNofRegulators() runs on EPTF_ExecCtrl_CT return integer {
return sizeof(v_EPTF_ExecCtrl_Regulators);
}
friend function f_EPTF_ExecCtrl_Regulator_getRegulatorNameByRegulatorId(in integer pl_regulatorId) runs on EPTF_ExecCtrl_CT return charstring {
return v_EPTF_ExecCtrl_Regulators[pl_regulatorId].name;
}
friend function f_EPTF_ExecCtrl_Regulator_getRegulatorTotalValueIdxByRegulatorId(in integer pl_regulatorId) runs on EPTF_ExecCtrl_CT return integer {
return v_EPTF_ExecCtrl_Regulators[pl_regulatorId].totalValueIdx;
}
friend function f_EPTF_ExecCtrl_Regulator_getRegulatorTargetLoadIdxByRegulatorId(in integer pl_regulatorId) runs on EPTF_ExecCtrl_CT return integer {
return v_EPTF_ExecCtrl_Regulators[pl_regulatorId].targetLoadIdx;
}
friend function f_EPTF_ExecCtrl_Regulator_getRegulatorCurrentLoadIdxByRegulatorId(in integer pl_regulatorId) runs on EPTF_ExecCtrl_CT return integer {
return v_EPTF_ExecCtrl_Regulators[pl_regulatorId].currentLoadIdx;
}
friend function f_EPTF_ExecCtrl_Regulator_getRegulatorStatusIdxByRegulatorId(in integer pl_regulatorId) runs on EPTF_ExecCtrl_CT return integer {
return v_EPTF_ExecCtrl_Regulators[pl_regulatorId].statusIdx;
}
// add a regulated item into the database,
// creates the regulator data if needed and registers the regulated item into the regulator,
// updates v_EPTF_ExecCtrl_RegulatedItemIdsDB also
friend function f_EPTF_ExecCtrl_Regulator_addRegulatedItem(
in EPTF_ExecCtrl_RegulatedItemName pl_idName,
in charstring pl_regulatorName, // name in EPTF_ExecCtrl_Regulators: this regulator regulates this item
in float pl_weight := 1.0, // used to determine part of the total value
in boolean pl_enabled := true // regulation enabled
) runs on EPTF_ExecCtrl_CT
return integer
{
// if (pl_idName == "") {
// return -1; // empty name is not allowed
// }
// check if the regulated item exists:
var boolean vl_regulatedItemIsWeighted := false;
var charstring vl_errorMsg := "Cannot regulate the CPS of the traffic case in a weighted scenario.";
var charstring vl_eGrpName, vl_scName, vl_tcName;
var boolean vl_inPhase := false; // all phases
var charstring vl_phase; // unbound for all phases!
if (ischosen(pl_idName.cps_TC)) {
vl_eGrpName := pl_idName.cps_TC.eGrpName;
vl_scName := pl_idName.cps_TC.scName;
vl_tcName := pl_idName.cps_TC.tcName;
} else if (ischosen(pl_idName.cps_SC)) {
vl_regulatedItemIsWeighted := true;
vl_errorMsg := "Cannot regulate the CPS of a non-weighted scenario.";
vl_eGrpName := pl_idName.cps_SC.eGrpName;
vl_scName := pl_idName.cps_SC.scName;
} else if (ischosen(pl_idName.cps_TCInPhase)) {
vl_eGrpName := pl_idName.cps_TCInPhase.eGrpName;
vl_scName := pl_idName.cps_TCInPhase.scName;
vl_tcName := pl_idName.cps_TCInPhase.tcName;
vl_phase := pl_idName.cps_TCInPhase.phase;
vl_inPhase := true;
if (vl_phase=="") {
f_EPTF_ExecCtrl_error(%definitionId&": Invalid configuration data: Regulated item "&log2str(pl_idName)&" has no phase.");
}
} else if (ischosen(pl_idName.cps_SCInPhase)) {
vl_regulatedItemIsWeighted := true;
vl_errorMsg := "Cannot regulate the CPS of a non-weighted scenario.";
vl_eGrpName := pl_idName.cps_SCInPhase.eGrpName;
vl_scName := pl_idName.cps_SCInPhase.scName;
vl_phase := pl_idName.cps_SCInPhase.phase;
vl_inPhase := true;
if (vl_phase=="") {
f_EPTF_ExecCtrl_error(%definitionId&": Invalid configuration data: Regulated item "&log2str(pl_idName)&" has no phases.");
}
}
var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioIdxForScOfEGrp(vl_eGrpName,vl_scName);
if (vl_scIdx==-1) {
f_EPTF_ExecCtrl_error(%definitionId&": Invalid configuration data: Regulated item "&log2str(pl_idName)&" is not found in database."
&" Check the entity group- and scenario names.");
}
if (f_EPTF_ExecCtrl_isWeightedScenario(vl_scIdx)!=vl_regulatedItemIsWeighted) {
f_EPTF_ExecCtrl_error(%definitionId&": Invalid configuration data for the regulated item "&log2str(pl_idName)&": "&vl_errorMsg);
}
// The scenario groups are initialized by f_EPTF_ExecCtrl_Phase_createScenarioGroups,
// check if the phase regulation is consistent with scenario groups:
if (f_EPTF_ExecCtrl_scenarioIsNotInScenarioGroup(vl_scIdx) == vl_inPhase) {
vl_errorMsg := "Phase setting is not consistent with scenario: The scenario is not in a scenario group but phase is specified or vice versa."
f_EPTF_ExecCtrl_error(%definitionId&": Invalid configuration data for the regulated item "&log2str(pl_idName)&": "&vl_errorMsg);
}
if (not vl_regulatedItemIsWeighted) {
var integer vl_tcIdx := f_EPTF_ExecCtrl_getTrafficCaseIdx(vl_eGrpName,vl_scName,vl_tcName);
if ( vl_tcIdx==-1) {
f_EPTF_ExecCtrl_error(%definitionId&": Invalid configuration data: Regulated item "&log2str(pl_idName)&" is not found in database."
&" Check the traffic case name.");
}
}
// check if it is already there:
var integer vl_regulatedItemId := f_EPTF_ExecCtrl_Regulator_getRegulatedItemId(pl_idName);
if (vl_regulatedItemId == -1) {
// if not found: append to regulatedItems database:
vl_regulatedItemId := sizeof(v_EPTF_ExecCtrl_RegulatedItems);
// set the values:
v_EPTF_ExecCtrl_RegulatedItems[vl_regulatedItemId] := {pl_idName,pl_weight,pl_enabled,pl_regulatorName};
} else {
f_EPTF_ExecCtrl_warning(%definitionId&": Cannot add regulated item to database: regulated item is already added: "&log2str(pl_idName));
// regulated item is already in the database
// do not overwrite the existing values
}
// also: add to the v_EPTF_ExecCtrl_RegulatedItemIdsDB:
f_EPTF_ExecCtrl_Regulator_addToRegulatedItemIdsDB(vl_regulatedItemId);
// also: add the regulator:
var integer vl_regulatorIdx := f_EPTF_ExecCtrl_Regulator_addRegulator(pl_regulatorName);
// register the regulated item into the regulator:
// if regulated, add to regulator data:
f_EPTF_ExecCtrl_Regulator_registerItem(vl_regulatorIdx,vl_regulatedItemId);
return vl_regulatedItemId;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_Regulator_getRegulatedItemId
//
// Purpose:
// returns the id of the regulatedItem
//
// Parameters:
// pl_idName - *in* <EPTF_ExecCtrl_RegulatedItemName> - the name of the regulated item
//
// Return Value:
// integer - the id of the regulated item
//
// Errors & assertions:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_Regulator_getRegulatedItemId(in EPTF_ExecCtrl_RegulatedItemName pl_idName) runs on EPTF_ExecCtrl_CT return integer {
for(var integer i:=0, size := sizeof(v_EPTF_ExecCtrl_RegulatedItems); i<size; i:=i+1) {
if (v_EPTF_ExecCtrl_RegulatedItems[i].idName == pl_idName) {
return i;
}
}
return -1; // not found
}
// returns the id of the regulatedItem
private function f_EPTF_ExecCtrl_Regulator_getRegulatedItemIdById(in EPTF_ExecCtrl_RegulatedItemId pl_id) runs on EPTF_ExecCtrl_CT return integer {
for(var integer i:=0, size := sizeof(v_EPTF_ExecCtrl_RegulatedItemIdsDB); i<size; i:=i+1) {
if (v_EPTF_ExecCtrl_RegulatedItemIdsDB[i] == pl_id) {
return i;
}
}
return -1; // not found
}
// returns the id of the regulatedItem
friend function f_EPTF_ExecCtrl_Regulator_getRegulatedItemDataById(in integer pl_id) runs on EPTF_ExecCtrl_CT return EPTF_ExecCtrl_RegulatedItemId {
return v_EPTF_ExecCtrl_RegulatedItemIdsDB[pl_id];
}
// append regulated item idx to regulatedItems of regulator pl_regulatorIdx
// checks also if the regulated item is regulated by some regulator
private function f_EPTF_ExecCtrl_Regulator_registerItem(in integer pl_regulatorIdx, in integer pl_itemIdx) runs on EPTF_ExecCtrl_CT {
if (pl_regulatorIdx==-1) {
return; // no regulator given
}
// check if it is already in a regulator or not:
if ( v_EPTF_ExecCtrl_RegulatedItems[pl_itemIdx].regulatorName != ""
and v_EPTF_ExecCtrl_RegulatedItems[pl_itemIdx].regulatorName != v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].name)
{
f_EPTF_ExecCtrl_error(%definitionId&": Cannot set regulator name "&v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].name&
" to the item "&log2str(v_EPTF_ExecCtrl_RegulatedItems[pl_itemIdx].idName)&
": it is already regulated by " & v_EPTF_ExecCtrl_RegulatedItems[pl_itemIdx].regulatorName);
}
// register it into regulated items:
v_EPTF_ExecCtrl_RegulatedItems[pl_itemIdx].regulatorName := v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].name;
// register it into the regulator:
f_EPTF_ExecCtrl_Regulator_addItem(pl_regulatorIdx,pl_itemIdx);
}
// remove regulated item idx from regulatedItems of regulator pl_regulatorIdx
// removes also the regulated item from the regulator
private function f_EPTF_ExecCtrl_Regulator_deregisterItem(in integer pl_regulatorIdx, in integer pl_itemIdx) runs on EPTF_ExecCtrl_CT {
// check if it is already in a regulator or not:
// deregister it from the regulated items:
v_EPTF_ExecCtrl_RegulatedItems[pl_itemIdx].regulatorName := "";
// deregister it from the regulator:
f_EPTF_ExecCtrl_Regulator_removeItem(pl_regulatorIdx,pl_itemIdx);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_Regulator_setTotalCps
//
// Purpose:
// sets the total CPS into the regulated items for this regulator. The total CPS is distributed according to the weights, only the enabled items are processed
//
// Parameters:
// pl_regulatorIdx - *in integer* - the id of the regulator
// pl_totalCps - *in float* - the total CPS to set
//
// Return Value:
//
// Errors & assertions:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_Regulator_setTotalCps(in integer pl_regulatorIdx, in float pl_totalCps) runs on EPTF_ExecCtrl_CT {
if (pl_regulatorIdx == -1) {
return; // no regulator
}
if (not v_ExecCtrl_initialized) {
return;
}
var float vl_sumWeight := 0.0;
// sum the CPS-es:
for(var integer i:=0, size := sizeof(v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].regulatedItemIds); i<size; i:=i+1) {
var integer vl_regulatedItemIdx := v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].regulatedItemIds[i];
// check if the regulator regulates in the current phase:
if (not f_EPTF_ExecCtrl_currentPhaseIsRegulated(vl_regulatedItemIdx)) {
continue;
}
// grpidx is not used currently!
//var integer grpidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_TC.grpidx;
if (v_EPTF_ExecCtrl_RegulatedItems[vl_regulatedItemIdx].enabled and f_EPTF_ExecCtrl_Regulator_itemIsRunning(vl_regulatedItemIdx)) {
vl_sumWeight := vl_sumWeight + v_EPTF_ExecCtrl_RegulatedItems[vl_regulatedItemIdx].weight;
}
}
// set the CPS-es:
for(var integer i:=0, size := sizeof(v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].regulatedItemIds); i<size; i:=i+1) {
var integer vl_regulatedItemIdx := v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].regulatedItemIds[i];
// check if the regulator regulates in the current phase:
if (not f_EPTF_ExecCtrl_currentPhaseIsRegulated(vl_regulatedItemIdx)) {
continue;
}
if (not v_EPTF_ExecCtrl_RegulatedItems[vl_regulatedItemIdx].enabled
or not f_EPTF_ExecCtrl_Regulator_itemIsRunning(vl_regulatedItemIdx)) {
continue;
}
if (ischosen(v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_TC)) {
var integer scenidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_TC.scenidx;
var integer tcidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_TC.tcidx;
// grpidx is not used currently!
var integer grpidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_TC.grpidx;
v_ExecCtrl_scenarios[scenidx].scData.tcList[tcidx].target.cpsToReach := pl_totalCps * v_EPTF_ExecCtrl_RegulatedItems[vl_regulatedItemIdx].weight/vl_sumWeight;
f_EPTF_ExecCtrl_setCps_TC(scenidx,tcidx, v_ExecCtrl_scenarios[scenidx].scData.tcList[tcidx].target.cpsToReach);
} else if (ischosen(v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_SC)) {
var integer scenidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_SC.scenidx;
// grpidx is not used currently!
var integer grpidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_SC.grpidx;
v_ExecCtrl_scenarios[scenidx].scData.weightedScData.cpsToReach := pl_totalCps * v_EPTF_ExecCtrl_RegulatedItems[vl_regulatedItemIdx].weight/vl_sumWeight;
f_EPTF_ExecCtrl_setCps_SC(scenidx,v_ExecCtrl_scenarios[scenidx].scData.weightedScData.cpsToReach);
} else if (ischosen(v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_TCInPhase)) {
var integer scenidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_TCInPhase.scenidx;
var integer tcidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_TCInPhase.tcidx;
// grpidx is not used currently!
var integer grpidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_TCInPhase.grpidx;
v_ExecCtrl_scenarios[scenidx].scData.tcList[tcidx].target.cpsToReach := pl_totalCps * v_EPTF_ExecCtrl_RegulatedItems[vl_regulatedItemIdx].weight/vl_sumWeight;
f_EPTF_ExecCtrl_setCps_TC(scenidx,tcidx, v_ExecCtrl_scenarios[scenidx].scData.tcList[tcidx].target.cpsToReach);
} else if (ischosen(v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_SCInPhase)) {
var integer scenidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_SCInPhase.scenidx;
// grpidx is not used currently!
var integer grpidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_SCInPhase.grpidx;
v_ExecCtrl_scenarios[scenidx].scData.weightedScData.cpsToReach := pl_totalCps * v_EPTF_ExecCtrl_RegulatedItems[vl_regulatedItemIdx].weight/vl_sumWeight;
f_EPTF_ExecCtrl_setCps_SC(scenidx,v_ExecCtrl_scenarios[scenidx].scData.weightedScData.cpsToReach);
}
}
}
private function f_EPTF_ExecCtrl_currentPhaseIsRegulated(in integer pl_regulatedItemIdx) runs on EPTF_ExecCtrl_CT return boolean {
if (ischosen(v_EPTF_ExecCtrl_RegulatedItemIdsDB[pl_regulatedItemIdx].cps_TC)) {
return true;// this item is regulated in all phases
} else if (ischosen(v_EPTF_ExecCtrl_RegulatedItemIdsDB[pl_regulatedItemIdx].cps_SC)) {
return true;// this item is regulated in all phases
}
var integer sidx;
var charstring vl_phase;
if (ischosen(v_EPTF_ExecCtrl_RegulatedItemIdsDB[pl_regulatedItemIdx].cps_TCInPhase)) {
sidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[pl_regulatedItemIdx].cps_TCInPhase.scenidx;
vl_phase := v_EPTF_ExecCtrl_RegulatedItemIdsDB[pl_regulatedItemIdx].cps_TCInPhase.phase;
} else if (ischosen(v_EPTF_ExecCtrl_RegulatedItemIdsDB[pl_regulatedItemIdx].cps_SCInPhase)) {
sidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[pl_regulatedItemIdx].cps_SCInPhase.scenidx;
vl_phase := v_EPTF_ExecCtrl_RegulatedItemIdsDB[pl_regulatedItemIdx].cps_SCInPhase.phase;
}
// check if current phase is the same as the regulated item's phase
var integer vl_scGrpidx := f_EPTF_ExecCtrl_ScenarioGroup_get_byScIndex(sidx);
if (vl_scGrpidx==-1) {
//f_EPTF_ExecCtrl_error(%definitionId&": Invalid configuration data for the regulated item "&log2str(v_EPTF_ExecCtrl_RegulatedItems[pl_regulatedItemIdx])&": "
// &"Phase setting is not consistent with scenario: The scenario is not in a scenario group but phase is specified or vice versa.");
return false; // this is not reached
}
var integer vl_currentPhaseIdx := v_ExecCtrl_ScenarioGroupInstanceDB.data[vl_scGrpidx].groupPhaseList.actualPhaseIndex;
var charstring vl_currentPhaseName := v_ExecCtrl_ScenarioGroupInstanceDB.data[vl_scGrpidx].groupPhaseList.phases[vl_currentPhaseIdx].name;
if (vl_phase == vl_currentPhaseName) {
return true;
}
return false;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_checkTrafficCaseStatus
//
// Purpose:
// Check if the execution state of a specified traffic case is consistent
// in all LGens
//
// Parameters:
// - pl_idName - *in* <EPTF_ExecCtrl_TCName> - the regulated item ID
// - pl_status - *in template charstring* - the desired state
//
// Return Value:
// *boolean* - true, if the execution state of a scenario matches the specifid state
//
// Errors & assertions:
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_checkTrafficCaseStatus(in EPTF_ExecCtrl_TCName pl_idName, in template charstring pl_status) runs on EPTF_ExecCtrl_CT return boolean
{
f_EPTF_ExecCtrl_debug(%definitionId&": started");
var charstring vl_currentName := "ExecCtrl.trafficCaseStatus."&pl_idName.eGrpName&"."&pl_idName.scName&"."&pl_idName.tcName;
var integer vl_idx := f_EPTF_Var_getId(vl_currentName);
if (vl_idx == -1) {
return false;
}
var EPTF_StatusLED vl_statusLED := f_EPTF_Var_getStatusLEDValue(vl_idx);
var charstring vl_status := vl_statusLED.text;
if (not match(vl_status, pl_status)) {
return false;
}
f_EPTF_ExecCtrl_debug(%definitionId&": finish");
return true;
}
private function f_EPTF_ExecCtrl_Regulator_itemIsRunning(in integer pl_regulatedItemIdx) runs on EPTF_ExecCtrl_CT return boolean {
var charstring vl_varName;
if (ischosen(v_EPTF_ExecCtrl_RegulatedItems[pl_regulatedItemIdx].idName.cps_TC)) {
return f_EPTF_ExecCtrl_checkTrafficCaseStatus(
v_EPTF_ExecCtrl_RegulatedItems[pl_regulatedItemIdx].idName.cps_TC,
c_EPTF_LGenBase_stateNames[c_EPTF_LGenBase_tcStateRunning]
);
} else if (ischosen(v_EPTF_ExecCtrl_RegulatedItems[pl_regulatedItemIdx].idName.cps_SC)) {
return f_EPTF_ExecCtrl_checkScenarioStatus(
v_EPTF_ExecCtrl_RegulatedItems[pl_regulatedItemIdx].idName.cps_SC,
c_EPTF_LGenBase_stateNames[c_EPTF_LGenBase_tcStateRunning]
);
}else if (ischosen(v_EPTF_ExecCtrl_RegulatedItems[pl_regulatedItemIdx].idName.cps_TCInPhase)) {
return f_EPTF_ExecCtrl_checkTrafficCaseStatus(
{
v_EPTF_ExecCtrl_RegulatedItems[pl_regulatedItemIdx].idName.cps_TCInPhase.eGrpName,
v_EPTF_ExecCtrl_RegulatedItems[pl_regulatedItemIdx].idName.cps_TCInPhase.scName,
v_EPTF_ExecCtrl_RegulatedItems[pl_regulatedItemIdx].idName.cps_TCInPhase.tcName
},
c_EPTF_LGenBase_stateNames[c_EPTF_LGenBase_tcStateRunning]
);
} else if (ischosen(v_EPTF_ExecCtrl_RegulatedItems[pl_regulatedItemIdx].idName.cps_SCInPhase)) {
return f_EPTF_ExecCtrl_checkScenarioStatus(
{v_EPTF_ExecCtrl_RegulatedItems[pl_regulatedItemIdx].idName.cps_SCInPhase.eGrpName,v_EPTF_ExecCtrl_RegulatedItems[pl_regulatedItemIdx].idName.cps_SCInPhase.scName},
c_EPTF_LGenBase_stateNames[c_EPTF_LGenBase_tcStateRunning]
);
}
return false;// never reached
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_Regulator_getTotalCps
//
// Purpose:
// returns the total CPS of the regulated items belonging to the given regulator, only the enabled items are processed
//
// Parameters:
// pl_regulatorIdx - *in integer* - the id of the regulator
//
// Return Value:
// float - the total CPS
//
// Errors & assertions:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_Regulator_getTotalCps(in integer pl_regulatorIdx) runs on EPTF_ExecCtrl_CT return float {
if (pl_regulatorIdx == -1) {
return 0.0; // no regulator
}
var float vl_sumCps := 0.0;
// sum the CPS-es:
for(var integer i:=0, size := sizeof(v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].regulatedItemIds); i<size; i:=i+1) {
var integer vl_regulatedItemIdx := v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].regulatedItemIds[i];
// check if the regulator regulates in the current phase:
if (not f_EPTF_ExecCtrl_currentPhaseIsRegulated(vl_regulatedItemIdx)) {
continue;
}
if (v_EPTF_ExecCtrl_RegulatedItems[vl_regulatedItemIdx].enabled
and f_EPTF_ExecCtrl_Regulator_itemIsRunning(vl_regulatedItemIdx)
) {
if (ischosen(v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_TC)) {
var integer scenidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_TC.scenidx;
var integer tcidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_TC.tcidx;
// grpidx is not used currently!
//var integer grpidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_TC.grpidx;
vl_sumCps := vl_sumCps + v_ExecCtrl_scenarios[scenidx].scData.tcList[tcidx].target.cpsToReach;
} else if (ischosen(v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_SC)) {
var integer scenidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_SC.scenidx;
// grpidx is not used currently!
//var integer grpidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_SC.grpidx;
vl_sumCps := vl_sumCps + v_ExecCtrl_scenarios[scenidx].scData.weightedScData.cpsToReach;
} else if (ischosen(v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_TCInPhase)) {
var integer scenidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_TCInPhase.scenidx;
var integer tcidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_TCInPhase.tcidx;
// grpidx is not used currently!
//var integer grpidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_TC.grpidx;
vl_sumCps := vl_sumCps + v_ExecCtrl_scenarios[scenidx].scData.tcList[tcidx].target.cpsToReach;
} else if (ischosen(v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_SCInPhase)) {
var integer scenidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_SCInPhase.scenidx;
// grpidx is not used currently!
//var integer grpidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_SC.grpidx;
vl_sumCps := vl_sumCps + v_ExecCtrl_scenarios[scenidx].scData.weightedScData.cpsToReach;
}
}
}
return vl_sumCps;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_Regulator_getRegulatorName
//
// Purpose:
// returns the name of the regulator for the given regulated item:
//
// Parameters:
// pl_regulatedItemIdx - *in integer* - the id of the regulated item
//
// Return Value:
// charstring - the name of the regulator the item is regulated by
// Empty string ("") is returned if no regulator found for this item
//
// Errors & assertions:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_Regulator_getRegulatorName(in integer pl_regulatedItemIdx) runs on EPTF_ExecCtrl_CT return charstring {
if (pl_regulatedItemIdx == -1) {
return "";
}
if (sizeof(v_EPTF_ExecCtrl_RegulatedItems)<=pl_regulatedItemIdx) {
return "";
}
return v_EPTF_ExecCtrl_RegulatedItems[pl_regulatedItemIdx].regulatorName;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_Regulator_setRegulatorName
//
// Purpose:
// sets the name of the regulator for the given regulated item:
//
// Parameters:
// pl_regulatedItemIdx - *in integer* - the id of the regulated item
// pl_regulatorName - *in charstring* - the name of the regulator
//
// Return Value:
//
// Errors & assertions:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_Regulator_setRegulatorName(in integer pl_regulatedItemIdx, in charstring pl_regulatorName) runs on EPTF_ExecCtrl_CT {
if (pl_regulatedItemIdx == -1) {
return;
}
var charstring vl_prevRegulatorName := v_EPTF_ExecCtrl_RegulatedItems[pl_regulatedItemIdx].regulatorName;
var integer vl_regulatorIdx := f_EPTF_ExecCtrl_Regulator_addRegulator(vl_prevRegulatorName);
var integer vl_prevRegulatorIdx := vl_regulatorIdx;
f_EPTF_ExecCtrl_Regulator_deregisterItem(vl_regulatorIdx,pl_regulatedItemIdx);
v_EPTF_ExecCtrl_RegulatedItems[pl_regulatedItemIdx].regulatorName := pl_regulatorName;
// also: add the regulator:
vl_regulatorIdx := f_EPTF_ExecCtrl_Regulator_addRegulator(pl_regulatorName);
// register the regulated item into the regulator:
// if regulated, add to regulator data:
f_EPTF_ExecCtrl_Regulator_registerItem(vl_regulatorIdx,pl_regulatedItemIdx);
if (vl_prevRegulatorIdx != -1) {
// try to stop the old regulator:
f_EPTF_ExecCtrl_Regulator_startStop(vl_prevRegulatorIdx);
}
if (vl_regulatorIdx!=-1) {
// start the new regulator if needed:
f_EPTF_ExecCtrl_Regulator_startStop(vl_regulatorIdx);
}
}
// private:
// append regulated item idx to regulatedItems of regulator pl_regulatorIdx
private function f_EPTF_ExecCtrl_Regulator_addItem(in integer pl_regulatorIdx, in integer pl_itemIdx) runs on EPTF_ExecCtrl_CT {
if (pl_regulatorIdx==-1) {
return; // no regulator given
}
// check if it is already there:
for (var integer i:=0, size := sizeof(v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].regulatedItemIds); i<size; i:=i+1) {
if (v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].regulatedItemIds[i] == pl_itemIdx) {
return; // already there
}
}
// register it into the regulator:
var integer vl_currentSize := sizeof(v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].regulatedItemIds);
v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].regulatedItemIds[vl_currentSize] := pl_itemIdx;
// update the totalValue:
f_EPTF_Var_adjustContent(v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].totalValueIdx,{floatVal := f_EPTF_ExecCtrl_Regulator_getTotalCps(pl_regulatorIdx)});
}
// remove regulated item idx from the regulatedItems of regulator pl_regulatorIdx
private function f_EPTF_ExecCtrl_Regulator_removeItem(in integer pl_regulatorIdx, in integer pl_itemIdx) runs on EPTF_ExecCtrl_CT {
if (pl_regulatorIdx==-1) {
return; // no regulator given
}
var EPTF_IntegerList vl_regulatedItemIds_old := v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].regulatedItemIds;
var integer vl_currentSize := 0;
v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].regulatedItemIds := {};
for (var integer i:=0, size := sizeof(vl_regulatedItemIds_old); i<size; i:=i+1) {
if (vl_regulatedItemIds_old[i] != pl_itemIdx) {
v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].regulatedItemIds[vl_currentSize] := vl_regulatedItemIds_old[i];
vl_currentSize := vl_currentSize + 1;
}
}
// update the totalValue:
f_EPTF_Var_adjustContent(v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].totalValueIdx,{floatVal := f_EPTF_ExecCtrl_Regulator_getTotalCps(pl_regulatorIdx)});
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_Regulator_createRefVarFromRegulatedItemWeight
//
// Purpose:
// creates a referenced EPTF Var from the weight of the regulated item
//
// Parameters:
// pl_varName - *in charstring* - name of the EPTF Var to create
// pl_regulatedItemIdx - *in integer* - the id of the regulated item in v_EPTF_ExecCtrl_RegulatedItems
// pl_idx - *out integer* - index of the created variable
//
// Return Value:
//
//
// Errors & assertions:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_Regulator_createRefVarFromRegulatedItemWeight(
in charstring pl_varName,
in integer pl_regulatedItemIdx,
out integer pl_idx
) runs on EPTF_ExecCtrl_CT {
f_EPTF_Var_newFloatRef(
pl_varName, v_EPTF_ExecCtrl_RegulatedItems[pl_regulatedItemIdx].weight, pl_idx);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_Regulator_createRefVarFromRegulatedItemEnabled
//
// Purpose:
// creates a referenced EPTF Var from the weight of the regulated item
//
// Parameters:
// pl_varName - *in charstring* - name of the EPTF Var to create
// pl_regulatedItemIdx - *in integer* - the id of the regulated item in v_EPTF_ExecCtrl_RegulatedItems
// pl_idx - *out integer* - index of the created variable
//
// Return Value:
//
//
// Errors & assertions:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_Regulator_createRefVarFromRegulatedItemEnabled(
in charstring pl_varName,
in integer pl_regulatedItemIdx,
out integer pl_idx
) runs on EPTF_ExecCtrl_CT {
f_EPTF_Var_newBoolRef(
pl_varName, v_EPTF_ExecCtrl_RegulatedItems[pl_regulatedItemIdx].enabled, pl_idx);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_Regulator_nofRegulatedItems
//
// Purpose:
// Returns the number of regulated items
//
// Parameters:
//
// Return Value:
// integer - number of regulated items
//
// Errors & assertions:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_Regulator_nofRegulatedItems() runs on EPTF_ExecCtrl_CT return integer {
return sizeof(v_EPTF_ExecCtrl_RegulatedItems);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_Regulator_itemId2ItemName
//
// Purpose:
// Converts the regulated item idx in v_EPTF_ExecCtrl_RegulatedItems to <EPTF_ExecCtrl_RegulatedItemName>
//
// Parameters:
// pl_regulatedItemIdx - *in integer* - the id of the regulated item in v_EPTF_ExecCtrl_RegulatedItems
//
// Return Value:
// EPTF_ExecCtrl_RegulatedItemName - the idName of the regulated item
//
// Errors & assertions:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_Regulator_itemId2ItemName(in integer pl_regulatedItemIdx) runs on EPTF_ExecCtrl_CT return EPTF_ExecCtrl_RegulatedItemName {
return v_EPTF_ExecCtrl_RegulatedItems[pl_regulatedItemIdx].idName;
}
private function f_EPTF_ExecCtrl_Regulator_itemName2ItemId(in EPTF_ExecCtrl_RegulatedItemName pl_idName) runs on EPTF_ExecCtrl_CT return EPTF_ExecCtrl_RegulatedItemId {
var EPTF_ExecCtrl_RegulatedItemId vl_itemId;
var integer scenidx := c_ExecCtrl_invalidIdx;
if (ischosen(pl_idName.cps_TC)) {
// search in ScenDescr2 (descr1 is not supported!!)
scenidx := f_EPTF_ExecCtrl_getScenarioIdxForScOfEGrp(pl_idName.cps_TC.eGrpName, pl_idName.cps_TC.scName);
f_EPTF_Base_assert(%definitionId&": Cannot find scenario type "&pl_idName.cps_TC.scName&" for entity group "&pl_idName.cps_TC.eGrpName&" in database.", scenidx!=-1);
vl_itemId.cps_TC.scenidx := scenidx;
for (var integer tcidx:=0, size := sizeof(v_ExecCtrl_scenarios[scenidx].scData.tcList);tcidx<size;tcidx:=tcidx+1)
{
var charstring vl_tcName := f_EPTF_LGenBase_tcNameOfTcOfSc(v_ExecCtrl_scenarios[scenidx].scData,tcidx)
if (vl_tcName == pl_idName.cps_TC.tcName) {
vl_itemId.cps_TC.tcidx := tcidx;
break;
}
}
var integer vl_eGrpIdx := f_EPTF_ExecCtrl_getEntityGroupIdx(pl_idName.cps_TC.eGrpName);
vl_itemId.cps_TC.grpidx := vl_eGrpIdx; // currently not used
} else if (ischosen(pl_idName.cps_SC)) {
// search in WeightedScenarios
scenidx := f_EPTF_ExecCtrl_getScenarioIdxForScOfEGrp(pl_idName.cps_SC.eGrpName, pl_idName.cps_SC.scName);
f_EPTF_Base_assert(%definitionId&": Cannot find scenario type "&pl_idName.cps_SC.scName&" for entity group "&pl_idName.cps_SC.eGrpName&" in database.", scenidx!=-1);
vl_itemId.cps_SC.scenidx := scenidx;
var integer vl_eGrpIdx := f_EPTF_ExecCtrl_getEntityGroupIdx(pl_idName.cps_SC.eGrpName);
vl_itemId.cps_SC.grpidx := vl_eGrpIdx; // currently not used
} else if (ischosen(pl_idName.cps_TCInPhase)) {
scenidx := f_EPTF_ExecCtrl_getScenarioIdxForScOfEGrp(pl_idName.cps_TCInPhase.eGrpName, pl_idName.cps_TCInPhase.scName);
f_EPTF_Base_assert(%definitionId&": Cannot find scenario type "&pl_idName.cps_TCInPhase.scName&" for entity group "&pl_idName.cps_TCInPhase.eGrpName&" in database.", scenidx!=-1);
vl_itemId.cps_TCInPhase.scenidx := scenidx;
for (var integer tcidx:=0, size := sizeof(v_ExecCtrl_scenarios[scenidx].scData.tcList);tcidx<size;tcidx:=tcidx+1)
{
var charstring vl_tcName := f_EPTF_LGenBase_tcNameOfTcOfSc(v_ExecCtrl_scenarios[scenidx].scData,tcidx)
if (vl_tcName == pl_idName.cps_TCInPhase.tcName) {
vl_itemId.cps_TCInPhase.tcidx := tcidx;
break;
}
}
var integer vl_eGrpIdx := f_EPTF_ExecCtrl_getEntityGroupIdx(pl_idName.cps_TCInPhase.eGrpName);
vl_itemId.cps_TCInPhase.grpidx := vl_eGrpIdx; // currently not used
vl_itemId.cps_TCInPhase.phase := pl_idName.cps_TCInPhase.phase;
} else if (ischosen(pl_idName.cps_SCInPhase)) {
// search in WeightedScenarios
scenidx := f_EPTF_ExecCtrl_getScenarioIdxForScOfEGrp(pl_idName.cps_SCInPhase.eGrpName, pl_idName.cps_SCInPhase.scName);
f_EPTF_Base_assert(%definitionId&": Cannot find scenario type "&pl_idName.cps_SCInPhase.scName&" for entity group "&pl_idName.cps_SCInPhase.eGrpName&" in database.", scenidx!=-1);
vl_itemId.cps_SCInPhase.scenidx := scenidx;
var integer vl_eGrpIdx := f_EPTF_ExecCtrl_getEntityGroupIdx(pl_idName.cps_SCInPhase.eGrpName);
vl_itemId.cps_SCInPhase.grpidx := vl_eGrpIdx; // currently not used
vl_itemId.cps_SCInPhase.phase := pl_idName.cps_SCInPhase.phase;
}
f_EPTF_ExecCtrl_debug(log2str(%definitionId&": pl_idName ",pl_idName, " converted to vl_itemId: ", vl_itemId));
return vl_itemId
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_Regulator_logAll
//
// Purpose:
// log the regulator database for debug purposes
//
// Parameters:
//
// Return Value:
//
// Errors & assertions:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_Regulator_logAll() runs on EPTF_ExecCtrl_CT {
if(c_EPTF_Common_debugSwitch) {
f_EPTF_ExecCtrl_debug("-----------Regulator database---------");
f_EPTF_ExecCtrl_debug(log2str("v_EPTF_ExecCtrl_RegulatorNames: ",v_EPTF_ExecCtrl_RegulatorNames));
f_EPTF_ExecCtrl_debug(log2str("v_EPTF_ExecCtrl_RegulatedItems: ",v_EPTF_ExecCtrl_RegulatedItems));
f_EPTF_ExecCtrl_debug(log2str("v_EPTF_ExecCtrl_RegulatedItemIdsDB: ",v_EPTF_ExecCtrl_RegulatedItemIdsDB));
f_EPTF_ExecCtrl_debug(log2str("v_EPTF_ExecCtrl_Regulators: ",v_EPTF_ExecCtrl_Regulators));
f_EPTF_ExecCtrl_debug("---------Regulator database END--------");
}
}
// postproc fn to update targetValue for an regulator (pl_args[0]: regulatorId)
private function f_EPTF_ExecCtrl_Regulator_updateTotalValue(
in integer pl_idx,
in EPTF_IntegerList pl_argList)
runs on EPTF_ExecCtrl_CT {
if (not v_ExecCtrl_initialized) {
return;
}
var integer vl_regulatorIdx := pl_argList[0];
// check if regulator is running:
var EPTF_StatusLED v_regulatorStatus := f_EPTF_Var_getStatusLEDValue(v_EPTF_ExecCtrl_Regulators[vl_regulatorIdx].statusIdx);
f_EPTF_ExecCtrl_debug(%definitionId&": Status of regulator "& v_EPTF_ExecCtrl_Regulators[vl_regulatorIdx].name&": "& log2str(v_regulatorStatus));
if (v_regulatorStatus.text == "Auto-off" or v_regulatorStatus.text == "Disabled") {
f_EPTF_ExecCtrl_debug(%definitionId&": TotalCps is not set for regulator "&v_EPTF_ExecCtrl_Regulators[vl_regulatorIdx].name&": Regulator is Disabled, or Auto-off");
return; // do not update target value if regulator is in "auto-off" or disabled state
}
f_EPTF_ExecCtrl_Regulator_setTotalCps(vl_regulatorIdx, f_EPTF_Var_getFloatValue(pl_idx));
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_Regulator_findRegulatorsForScenario
//
// Purpose:
// find the regulators that regulate items in the current scenario
//
// Parameters:
// pl_eGrpName - *in charstring* - entity group name
// pl_scenName - *in charstring* - scenario name
// pl_regulatorIdxList - *out* <EPTF_IntegerList> - the regulator indexes that regulate items in the given scenario
//
// Return Value:
//
// Errors & assertions:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_Regulator_findRegulatorsForScenario(in charstring pl_eGrpName,in charstring pl_scenName,out EPTF_IntegerList pl_regulatorIdxList) runs on EPTF_ExecCtrl_CT {
pl_regulatorIdxList := {};
// go through all regulators and check if they regulate an item for this scenario
for(var integer i:=0, size := sizeof(v_EPTF_ExecCtrl_Regulators); i<size; i:=i+1) {
if (f_EPTF_ExecCtrl_Regulator_isRegulatesScenario(i,pl_eGrpName,pl_scenName)) {
pl_regulatorIdxList[sizeof(pl_regulatorIdxList)] := i;
}
}
}
// check if the given regulator regulates an item for the given scenario
private function f_EPTF_ExecCtrl_Regulator_isRegulatesScenario(in integer pl_regulatorIdx,in charstring pl_eGrpName,in charstring pl_scenName) runs on EPTF_ExecCtrl_CT return boolean {
for(var integer i:=0, size := sizeof(v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].regulatedItemIds); i<size; i:=i+1) {
var integer vl_regulatedItemIdx := v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].regulatedItemIds[i];
var EPTF_ExecCtrl_RegulatedItemName vl_idName := v_EPTF_ExecCtrl_RegulatedItems[vl_regulatedItemIdx].idName;
// // check if the regulator regulates in the current phase:
// if (not f_EPTF_ExecCtrl_currentPhaseIsRegulated(vl_regulatedItemIdx)) {
// continue;
// }
var charstring vl_eGrpName := "";
var charstring vl_scenName := "";
if (ischosen(vl_idName.cps_SC)) {
vl_eGrpName := vl_idName.cps_SC.eGrpName;
vl_scenName := vl_idName.cps_SC.scName;
} else if (ischosen(vl_idName.cps_SCInPhase)) {
vl_eGrpName := vl_idName.cps_SCInPhase.eGrpName;
vl_scenName := vl_idName.cps_SCInPhase.scName;
}
if (vl_eGrpName == pl_eGrpName and vl_scenName == pl_scenName) {
return true; // regulated item found for the given scenario
}
}
return false;
}
// find the regulators that regulate items in the current scenario
private function f_EPTF_ExecCtrl_Regulator_findRegulatorsForTrafficCase(in charstring pl_eGrpName,in charstring pl_scenName,in charstring pl_tcName,out EPTF_IntegerList vl_regulatorIdxList) runs on EPTF_ExecCtrl_CT {
vl_regulatorIdxList := {};
// go through all regulators and check if they regulate an item for this scenario
for(var integer i:=0, size := sizeof(v_EPTF_ExecCtrl_Regulators); i<size; i:=i+1) {
if (f_EPTF_ExecCtrl_Regulator_isRegulatesTrafficCase(i,pl_eGrpName,pl_scenName,pl_tcName)) {
vl_regulatorIdxList[sizeof(vl_regulatorIdxList)] := i;
}
}
}
// check if the given regulator regulates an item for the given scenario
private function f_EPTF_ExecCtrl_Regulator_isRegulatesTrafficCase(in integer pl_regulatorIdx,in charstring pl_eGrpName,in charstring pl_scenName,in charstring pl_tcName) runs on EPTF_ExecCtrl_CT return boolean {
for(var integer i:=0, size := sizeof(v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].regulatedItemIds); i<size; i:=i+1) {
var integer vl_regulatedItemIdx := v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].regulatedItemIds[i];
var EPTF_ExecCtrl_RegulatedItemName vl_idName := v_EPTF_ExecCtrl_RegulatedItems[vl_regulatedItemIdx].idName;
// // check if the regulator regulates in the current phase:
// if (not f_EPTF_ExecCtrl_currentPhaseIsRegulated(vl_regulatedItemIdx)) {
// continue;
// }
var charstring vl_eGrpName := "";
var charstring vl_scenName := "";
var charstring vl_tcName := "";
if (ischosen(vl_idName.cps_TC)) {
vl_eGrpName := vl_idName.cps_TC.eGrpName;
vl_scenName := vl_idName.cps_TC.scName;
vl_tcName := vl_idName.cps_TC.tcName;
} else if (ischosen(vl_idName.cps_TCInPhase)) {
vl_eGrpName := vl_idName.cps_TCInPhase.eGrpName;
vl_scenName := vl_idName.cps_TCInPhase.scName;
vl_tcName := vl_idName.cps_TCInPhase.tcName;
}
if (vl_eGrpName == pl_eGrpName and vl_scenName == pl_scenName and vl_tcName == pl_tcName) {
return true; // regulated item found for the given scenario
}
}
return false;
}
// enables the regulator (scenarios for any item is running):
// disables the regulator if the scenarios for all items are not running:
friend function f_EPTF_ExecCtrl_Regulator_startStop(in integer pl_regulatorIdx) runs on EPTF_ExecCtrl_CT {
// if the regulator is disconnected, do nothing:
var integer vl_regulatorStatusIdx := f_EPTF_ExecCtrl_Regulator_getRegulatorStatusIdxByRegulatorId(pl_regulatorIdx);
if (vl_regulatorStatusIdx!=-1) {
var EPTF_StatusLED vl_regulatorStatus := f_EPTF_Var_getStatusLEDValue(vl_regulatorStatusIdx);
if (vl_regulatorStatus == {led_red, "Disconnected"}) {
f_EPTF_ExecCtrl_debug(%definitionId&": Regulator "&v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].name&" is Disconnected, not started");
return; // do not start/stop the regulator if it is disconnected
}
}
// check all regulated items for this regulator if any of their scenarios is running:
for(var integer i:=0, size := sizeof(v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].regulatedItemIds); i<size; i:=i+1) {
var integer vl_regulatedItemIdx := v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].regulatedItemIds[i];
// check if the regulator regulates in the current phase:
if (not f_EPTF_ExecCtrl_currentPhaseIsRegulated(vl_regulatedItemIdx)) {
continue;
}
if (v_EPTF_ExecCtrl_RegulatedItems[vl_regulatedItemIdx].enabled
and f_EPTF_ExecCtrl_Regulator_itemIsRunning(vl_regulatedItemIdx)) {
var EPTF_ExecCtrl_RegulatedItemName vl_idName := v_EPTF_ExecCtrl_RegulatedItems[vl_regulatedItemIdx].idName;
f_EPTF_ExecCtrl_debug(log2str("Regulator #",pl_regulatorIdx," is started, scenario/traffic case is running: ", vl_idName));
// update the totalValue if it was changed:
var float vl_newTotalCps := f_EPTF_ExecCtrl_Regulator_getTotalCps(pl_regulatorIdx);
if (f_EPTF_Var_getFloatValue(v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].totalValueIdx)!=vl_newTotalCps) {
f_EPTF_Var_adjustContent(v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].totalValueIdx,{floatVal := vl_newTotalCps});
}
var integer vl_idx := v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].enableIdx;
f_EPTF_Var_adjustContent(vl_idx,{boolVal := true});
return;
}
}
// no running scenario found, stop the regulator:
f_EPTF_ExecCtrl_debug(log2str("Regulator #",pl_regulatorIdx," is stopped, none of the scenarios/traffic cases are running"));
var integer vl_idx := v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].enableIdx;
f_EPTF_Var_adjustContent(vl_idx,{boolVal := false});
}
} // group EPTF_ExecCtrl_Regulator
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_loadConfigFromModulepars
//
// Purpose:
// Loads configuration data from the module parameters (appends existing config)
//
// Parameters:
// -
//
// Return Value:
// -
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_loadConfigFromModulepars() runs on EPTF_ExecCtrl_CT {
f_EPTF_ExecCtrl_debug(%definitionId&": Loading modulepars...");
f_EPTF_ExecCtrl_loadConfig(
pl_EPTF_LGenBase_TcMgmt_EntityGrpDeclaratorList :=tsp_LGenBase_EntityGrpDeclarators,
pl_EPTF_LGenBase_TcMgmt_Scenarios2GrpList :=tsp_LGenBase_Scenarios2Grps,
pl_EPTF_LGenBase_ScenarioDeclaratorList :=tsp_LGenBase_ScenarioDeclarators,
pl_EPTF_LGenBase_tcTypeDeclaratorList :=tsp_LGenBase_tcTypeDeclarators,
pl_EPTF_LGenBase_TcMgmt_tcTypeDeclaratorList :=tsp_LGenBase_TcMgmt_tcTypeDeclarators2,
pl_EPTF_LGenBase_TcMgmt_ScenarioDeclaratorList :=tsp_LGenBase_TcMgmt_ScenarioDeclarators2,
pl_EPTF_LGenBase_TcMgmt_WeightedScenarioDeclaratorList :=tsp_LGenBase_TcMgmt_WeightedScenarioDeclarators,
pl_EPTF_ExecCtrl_TimeProfileDescrList := tsp_EPTF_ExecCtrl_TimeProfileDescrList,
pl_EPTF_ExecCtrl_TimeProfileList := tsp_EPTF_ExecCtrl_TimeProfileList,
pl_EPTF_ExecCtrl_TimeProfile2TcList := tsp_EPTF_ExecCtrl_TimeProfile2TcList,
pl_EPTF_LGenBase_ScenarioTypeDeclaratorList := tsp_LGenBase_TcMgmt_ScenarioDeclarators3,
pl_EPTF_ExecCtrl_ScenarioInstanceTypeList := tsp_EPTF_ExecCtrl_Scenario2EntityGroupList,
pl_EPTF_ExecCtrl_LGenPool_Declarators := tsp_EPTF_ExecCtrl_LGenPool_Declarators,
pl_EPTF_ExecCtrl_EntityGroup2LGenPool_List := tsp_EPTF_ExecCtrl_EntityGroup2LGenPool_List,
pl_EPTF_ExecCtrl_LGenFunction_Entry_List := {},
pl_EPTF_ExecCtrl_PhaseList_Declarators := tsp_EPTF_ExecCtrl_PhaseList_Declarators,
pl_EPTF_ExecCtrl_ScenarioGroup_Declarators := tsp_EPTF_ExecCtrl_ScenarioGroup_Declarators,
pl_EPTF_ExecCtrl_RegulatorNames := tsp_EPTF_ExecCtrl_RegulatorNames,
pl_EPTF_ExecCtrl_RegulatedItems := tsp_EPTF_ExecCtrl_RegulatedItems,
pl_EPTF_ExecCtrl_EntityGroupDistributionTypeList := tsp_EPTF_ExecCtrl_EntityGroupDistributionDeclarators
);
//v_ExecCtrl_manualControl := tsp_ExecCtrl_manualControl;
v_EPTF_ExecCtrl_StartStopScenarioDisable := tsp_EPTF_ExecCtrl_StartStopScenarioDisable;
v_EPTF_ExecCtrl_StartStopTCDisable := tsp_EPTF_ExecCtrl_StartStopTCDisable;
f_EPTF_ExecCtrl_debug(%definitionId&": Modulepars loaded.");
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_clearConfig
//
// Purpose:
// Clears the variables that store configuration from module parameters
//
// Parameters:
// -
//
// Return Value:
// -
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_clearConfig() runs on EPTF_ExecCtrl_CT {
// declarators:
v_ExecCtrl_manualControl := tsp_ExecCtrl_manualControl;
v_ExecCtrl_EntityGrpDeclarators := {};//tsp_LGenBase_EntityGrpDeclarators;
v_ExecCtrl_ScenarioDeclarators := {};//tsp_LGenBase_ScenarioDeclarators;
v_ExecCtrl_tcTypeDeclarators := {};//tsp_LGenBase_tcTypeDeclarators;
v_ExecCtrl_Scenarios2Grps := {};//tsp_LGenBase_Scenarios2Grps;
v_ExecCtrl_scenario2EntityGroups:= {};//tsp_EPTF_ExecCtrl_Scenario2EntityGroupList;
v_ExecCtrl_tcTypeDeclarators2 := {};//tsp_LGenBase_TcMgmt_tcTypeDeclarators2;
v_ExecCtrl_ScenarioDeclarators2 := {};//tsp_LGenBase_TcMgmt_ScenarioDeclarators2;
v_ExecCtrl_ScenarioDeclarators3 := {};//tsp_LGenBase_TcMgmt_WeightedScenarioDeclarators;
v_ExecCtrl_ScenarioDeclaratorsR3 := {};//tsp_LGenBase_TcMgmt_ScenarioDeclarators3;
v_EPTF_ExecCtrl_TimeProfile2TcList := {};//tsp_EPTF_ExecCtrl_TimeProfile2TcList;
v_EPTF_ExecCtrl_TimeProfileList := {};//tsp_EPTF_ExecCtrl_TimeProfileList;
v_EPTF_ExecCtrl_TimeProfileDescrList := {};//tsp_EPTF_ExecCtrl_TimeProfileDescrList;
// LGenPool declarators:
v_EPTF_ExecCtrl_lgenCreatorFn_list := {};
v_EPTF_ExecCtrl_LGenPool_Declarators := {};//tsp_EPTF_ExecCtrl_LGenPool_Declarators;
v_EPTF_ExecCtrl_EntityGroup2LGenPools := {};//tsp_EPTF_ExecCtrl_EntityGroup2LGenPool_List;
// phases:
v_EPTF_ExecCtrl_PhaseList_Declarators := {};//tsp_EPTF_ExecCtrl_PhaseList_Declarators;
v_EPTF_ExecCtrl_ScenarioGroup_Declarators := {};//tsp_EPTF_ExecCtrl_ScenarioGroup_Declarators;
// FIXME: f_cleanupRegulators:
v_EPTF_ExecCtrl_RegulatorNames := {};//tsp_EPTF_ExecCtrl_RegulatorNames;
v_EPTF_ExecCtrl_RegulatedItemsCFG := {};//tsp_EPTF_ExecCtrl_RegulatedItems;
// entity group distribution:
v_EPTF_ExecCtrl_entityGroupDistributionCFG := {}; // tsp_EPTF_ExecCtrl_EntityGroupDistributionDeclarators
v_EPTF_ExecCtrl_StartStopScenarioDisable := {};//tsp_EPTF_ExecCtrl_StartStopScenarioDisable;
v_EPTF_ExecCtrl_StartStopTCDisable := {};//tsp_EPTF_ExecCtrl_StartStopTCDisable;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_cleanup_CT
//
// Purpose:
// Cleanup EPTF_ExecCtrl feature
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_cleanup_CT() runs on EPTF_ExecCtrl_CT {
f_EPTF_ExecCtrl_debug(%definitionId&": started");
if (not v_ExecCtrl_initialized) {
return;
}
f_EPTF_ExecCtrl_stopTimeProfiles();
f_EPTF_ExecCtrl_sendByeToAllClients();
v_EPTF_ExecCtrl_ScTimeProfileDB := {};
deactivate(v_EPTF_ExecCtrl_defaultAltstep);
v_EPTF_ExecCtrl_defaultAltstep := null;
// clear the configuration:
f_EPTF_ExecCtrl_clearConfig();
// entity group distribution DB:
v_EPTF_ExecCtrl_entityGroupDistribution := {};
// FIXME: f_cleanupRegulators:
v_EPTF_ExecCtrl_RegulatedItems := {};
v_EPTF_ExecCtrl_RegulatedItemIdsDB := {};
v_EPTF_ExecCtrl_Regulators := {};
v_EPTF_ExecCtrl_ScenarioGroupPhaseChangedCallbackFns := {};
v_EPTF_ExecCtrl_ScenarioStateChangedCallbackFns := {};
v_EPTF_ExecCtrl_TrafficCaseStateChangedCallbackFns := {};
v_EPTF_ExecCtrl_onGroupFinishCallbackFns := {};
v_EPTF_ExecCtrl_finalTestReportGeneratorFns := {};
v_EPTF_ExecCtrl_finalTestReport := "";
//v_ExecCtrl_endOfTest := false; // do not generate report after cleanup again
v_ExecCtrl_nrOfClients := 0;
v_EPTF_ExecCtrl_EntityResourceInfo_Buffer := {};
v_ExecCtrl_started := false;
v_ExecCtrl_readyToRun := false;
v_ExecCtrl_allLGensCreated := false;
v_EPTF_ExecCtrl_startTime := -1.0;
v_ExecCtrl_nrOfExpectedClients := -1;
// EPTF R3 InstanceDB
v_ExecCtrl_pendingMsgCounter := 0;
v_ExecCtrl_pendingByeCounter := 0;
v_ExecCtrl_cfgState := c_ExecCtrl_Cfg_WAITFOR_INIT;
f_EPTF_ExecCtrl_cleanupTypeDB();
f_EPTF_ExecCtrl_cleanupInstanceDB();
f_EPTF_ExecCtrl_Phase_cleanUp();
f_EPTF_ExecCtrl_LGenFunctions_cleanupInstanceDB();
f_EPTF_ExecCtrl_LGenPool_cleanupInstanceDB();
if (v_ExecCtrl_regulatedItemsHash != c_ExecCtrl_invalidIdx) {
f_EPTF_str2int_HashMap_Delete(c_ExecCtrl_regulatedItemsHashMapName);
v_ExecCtrl_regulatedItemsHash := c_ExecCtrl_invalidIdx;
}
if (v_ExecCtrl_statHandlerHash != c_ExecCtrl_invalidIdx) {
f_EPTF_str2int_HashMap_Delete(c_ExecCtrl_statHandlerHashMapName);
v_ExecCtrl_statHandlerHash := c_ExecCtrl_invalidIdx;
}
v_ExecCtrl_initialized := false;
f_EPTF_ExecCtrl_debug(%definitionId&": finished");
//v_ExecCtrl_loggingMaskId := c_EPTF_Logging_invalidMaskId; // to be able to log after cleanup
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_sendUpdatedActiveEntities
//
// Purpose:
// On-demand sending the Number of active entities of an entity group to LGens
//
// Parameters:
// - pl_eGrpIdx - *in integer* - index of the entity group in <v_ExecCtrl_entityGroups>
//
// Return Value:
// -
//
// Errors & assertions:
// - the specified indexes should point to valid group
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_sendUpdatedActiveEntities(
in integer pl_eGrpIdx)
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug(%definitionId&": started");
f_EPTF_Base_assert(%definitionId&": Invalid EntityGrp index "&int2str(pl_eGrpIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_entityGroups))&").",
pl_eGrpIdx >= 0 and pl_eGrpIdx < sizeof(v_ExecCtrl_entityGroups));
if (v_ExecCtrl_cfgState != c_ExecCtrl_Cfg_CONFIGURED) {
return; // lgens not signed in yet
}
var EPTF_IntegerList vl_entityDistributionDb := f_EPTF_ExecCtrl_splitActiveEntitiesOfEGrp(pl_eGrpIdx);
// Sending to LGens
var integer vl_eGrpIdx := pl_eGrpIdx;
for (var integer lgenidx:=0, size := sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList);lgenidx<size;lgenidx:=lgenidx+1) {
if (v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].eCount == 0) {
continue; // do not send packet to LGen if there is no entity on the LGen
}
var integer vl_lgenIdx := v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].lgenIdx;
v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].eCountActive := vl_entityDistributionDb[lgenidx];
ExecCtrl_MgmtIf_CP.send(EPTF_ExecCtrl_UpdateActiveEntities:{
eGrpName := v_ExecCtrl_entityGroups[vl_eGrpIdx].name,
activeEntities := vl_entityDistributionDb[lgenidx]
}) to f_EPTF_Base_downcast(v_ExecCtrl_lgens[vl_lgenIdx].lgenCompRef);
f_EPTF_ExecCtrl_debug(log2str("Active Entities of Entity Group ",v_ExecCtrl_entityGroups[vl_eGrpIdx].name,
" updated on LGen ",v_ExecCtrl_lgens[vl_lgenIdx].name," to: ", vl_entityDistributionDb[lgenidx]));
} // lgenidx
f_EPTF_ExecCtrl_debug(%definitionId&": finish");
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_sendUpdatedCps
//
// Purpose:
// On-demand sending the CPS of the traffic case to LGens
//
// Parameters:
// - pl_scIdx - *in integer* - index of the scenario in <EPTF_ExecCtrl_ScenarioList>
// - pl_tcOfScIdx - *in integer* - index of the traffic case in <EPTF_ExecCtrl_ScenarioList>[pl_scIdx].scData.tcList
//
// Return Value:
// -
//
// Errors & assertions:
// - the specified indexes should point to valid gropus and scenarios
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_sendUpdatedCps(
in integer pl_scIdx,
in integer pl_tcOfScIdx)
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug(%definitionId&": started");
f_EPTF_Base_assert(%definitionId&": Invalid SC index "&int2str(pl_scIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_scenarios))&").",
pl_scIdx >= 0 and pl_scIdx < sizeof(v_ExecCtrl_scenarios));
f_EPTF_Base_assert(%definitionId&": Invalid tcOfScenario index "&int2str(pl_tcOfScIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_scenarios[pl_scIdx].scData.tcList))&").",
pl_tcOfScIdx >= 0 and pl_tcOfScIdx < sizeof(v_ExecCtrl_scenarios[pl_scIdx].scData.tcList));
if (v_ExecCtrl_cfgState != c_ExecCtrl_Cfg_CONFIGURED) {
return; // lgens not signed in yet
}
var EPTF_FloatList vl_cpsDistributionDb := f_EPTF_ExecCtrl_splitCPSOfTc(pl_scIdx,pl_tcOfScIdx);
// Sending to LGens
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[pl_scIdx].eGroupIdx;
for (var integer lgenidx:=0, size := sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList);lgenidx<size;lgenidx:=lgenidx+1) {
if (v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].eCount == 0) {
continue; // do not send packet to LGen if there is no entity on the LGen
}
var integer vl_lgenIdx := v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].lgenIdx;
var charstring vl_tcName := f_EPTF_LGenBase_tcNameOfTcOfSc(v_ExecCtrl_scenarios[pl_scIdx].scData,pl_tcOfScIdx)
ExecCtrl_MgmtIf_CP.send(EPTF_ExecCtrl_UpdateCps:{
eGrpName := v_ExecCtrl_entityGroups[vl_eGrpIdx].name,
scenName := v_ExecCtrl_scenarios[pl_scIdx].scData.name, // Currently only for debug purposes
tcName:= vl_tcName,
cps := vl_cpsDistributionDb[lgenidx]
}) to f_EPTF_Base_downcast(v_ExecCtrl_lgens[vl_lgenIdx].lgenCompRef);
f_EPTF_ExecCtrl_debug(log2str("CPS of Tc #",pl_tcOfScIdx," of Scenario ", v_ExecCtrl_scenarios[pl_scIdx].name," updated on LGen ",v_ExecCtrl_lgens[vl_lgenIdx].name," to: ", vl_cpsDistributionDb[lgenidx]));
} // lgenidx
f_EPTF_ExecCtrl_debug(%definitionId&": finish");
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_sendUpdatedScenarioCps
//
// Purpose:
// On-demand sending the CPS of the scenario to LGens
//
// Parameters:
// - pl_scIdx - *in integer* - index of the scenario in <EPTF_ExecCtrl_ScenarioList>
//
// Return Value:
// -
//
// Errors & assertions:
// - the specified indexes should point to valid scenarios
//
// Detailed Comments:
// Only relevant for weighted scenario
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_sendUpdatedScenarioCps(
in integer pl_scIdx)
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug(%definitionId&": started");
f_EPTF_Base_assert(%definitionId&": Invalid SC index "&int2str(pl_scIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_scenarios))&").",
pl_scIdx >= 0 and pl_scIdx < sizeof(v_ExecCtrl_scenarios));
if (v_ExecCtrl_cfgState != c_ExecCtrl_Cfg_CONFIGURED) {
return; // lgens not signed in yet
}
var EPTF_FloatList vl_cpsDistributionOfScDb := f_EPTF_ExecCtrl_splitCPSOfSc(pl_scIdx);
// Sending to LGens
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[pl_scIdx].eGroupIdx;
for (var integer lgenidx:=0, size := sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList);lgenidx<size;lgenidx:=lgenidx+1) {
if (v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].eCount == 0) {
continue; // do not send packet to LGen if there is no entity on the LGen
}
var integer vl_lgenIdx := v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].lgenIdx;
f_EPTF_ExecCtrl_debug(log2str("CPS of Scenario ",v_ExecCtrl_scenarios[pl_scIdx].name," updated on LGen ",v_ExecCtrl_lgens[vl_lgenIdx].name," to: ", vl_cpsDistributionOfScDb[lgenidx]));
ExecCtrl_MgmtIf_CP.send(EPTF_ExecCtrl_UpdateScenarioCps:{
eGrpName := v_ExecCtrl_entityGroups[vl_eGrpIdx].name,
scenName := v_ExecCtrl_scenarios[pl_scIdx].scData.name, // Currently only for debug purposes
cps := vl_cpsDistributionOfScDb[lgenidx]
}) to f_EPTF_Base_downcast(v_ExecCtrl_lgens[vl_lgenIdx].lgenCompRef);
} // lgenidx
f_EPTF_ExecCtrl_debug(%definitionId&": finish");
}
// the CPS of all TCs and all SCs of the entity group is redistributed onto the LGens
private function f_EPTF_ExecCtrl_sendCurrentCPSForAllSCInEGrp(in integer pl_eGrpIdx) runs on EPTF_ExecCtrl_CT {
for(var integer sc:=0, size := sizeof(v_ExecCtrl_entityGroups[pl_eGrpIdx].scenarios); sc<size; sc:=sc+1) {
var integer vl_scIdx := v_ExecCtrl_entityGroups[pl_eGrpIdx].scenarios[sc];
if (f_EPTF_ExecCtrl_isWeightedScenario(vl_scIdx)) {
f_EPTF_ExecCtrl_sendUpdatedScenarioCps(vl_scIdx);
} else {
for(var integer tc:=0, sizet := sizeof(v_ExecCtrl_scenarios[vl_scIdx].tcIdxList); tc<sizet; tc:=tc+1) {
f_EPTF_ExecCtrl_sendUpdatedCps(vl_scIdx,tc);
}
}
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_sendUpdatedStartDelay
//
// Purpose:
// On-demand sending the StartDelay of the traffic case to LGens
//
// Parameters:
// - pl_scIdx - *in integer* - index of the scenario in <EPTF_ExecCtrl_ScenarioList>
// - pl_tcOfScIdx - *in integer* - index of the traffic case in <EPTF_ExecCtrl_ScenarioList>[pl_scIdx].scData.tcList
//
// Return Value:
// -
//
// Errors & assertions:
// - the specified indexes should point to valid gropus and scenarios
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_sendUpdatedStartDelay(
in integer pl_scIdx,
in integer pl_tcOfScIdx)
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug(%definitionId&": started");
f_EPTF_Base_assert(%definitionId&": Invalid SC index "&int2str(pl_scIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_scenarios))&").",
pl_scIdx >= 0 and pl_scIdx < sizeof(v_ExecCtrl_scenarios));
f_EPTF_Base_assert(%definitionId&": Invalid tcOfScenario index "&int2str(pl_tcOfScIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_scenarios[pl_scIdx].scData.tcList))&").",
pl_tcOfScIdx >= 0 and pl_tcOfScIdx < sizeof(v_ExecCtrl_scenarios[pl_scIdx].scData.tcList));
if (v_ExecCtrl_cfgState != c_ExecCtrl_Cfg_CONFIGURED) {
return; // lgens not signed in yet
}
// Sending to LGens
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[pl_scIdx].eGroupIdx;
for (var integer lgenidx:=0, size := sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList);lgenidx<size;lgenidx:=lgenidx+1) {
if (v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].eCount == 0) {
continue; // do not send packet to LGen if there is no entity on the LGen
}
var integer vl_lgenIdx := v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].lgenIdx;
var charstring vl_tcName := f_EPTF_LGenBase_tcNameOfTcOfSc(v_ExecCtrl_scenarios[pl_scIdx].scData,pl_tcOfScIdx);
ExecCtrl_MgmtIf_CP.send(EPTF_ExecCtrl_UpdateStartDelay:{
eGrpName := v_ExecCtrl_entityGroups[vl_eGrpIdx].name,
scenName := v_ExecCtrl_scenarios[pl_scIdx].scData.name, // Currently only for debug purposes
tcName:= vl_tcName,
startDelay := v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].startDelay
}) to f_EPTF_Base_downcast(v_ExecCtrl_lgens[vl_lgenIdx].lgenCompRef);
f_EPTF_ExecCtrl_debug(log2str("StartDalay of Tc #",pl_tcOfScIdx," of Scenario ", v_ExecCtrl_scenarios[pl_scIdx].name," updated on LGen ",v_ExecCtrl_lgens[vl_lgenIdx].name," to: ",
v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].startDelay));
} // lgenidx
f_EPTF_ExecCtrl_debug(%definitionId&": finish");
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_subscribeScenarioState
//
// Purpose:
// Subscribe for scenario state variable on all ExecCtrlClient/LGen, and create a local variable to calculate the overall scenario state
//
// Parameters:
// - pl_scIdx - *in integer* - the scenario index in <EPTF_ExecCtrl_ScenarioList>
//
// Return Value:
// -
//
// Errors & assertions:
// - the specified indexes should point to valid groups and scenarios
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_subscribeScenarioState(
in integer pl_scIdx
) runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug("### "& %definitionId&": start");
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[pl_scIdx].eGroupIdx;
var charstring vl_eType;
var charstring vl_varName := "";
var integer vl_idx;
vl_varName := "ExecCtrlClient.scenarioStatus."&v_ExecCtrl_entityGroups[vl_eGrpIdx].name&"."&v_ExecCtrl_scenarios[pl_scIdx].scData.name;
var EPTF_IntegerList vl_args := {};
for (var integer lgenidx:=0, size := sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList);lgenidx<size;lgenidx:=lgenidx+1)
{
var integer vl_lgenIdx := v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].lgenIdx;
// if no entities are allocated on the LGen
if (v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].eCount == 0 ) {
continue; // nothing to do
}
f_EPTF_ExecCtrl_debug(log2str("Subscribing on LGen (", v_ExecCtrl_lgens[vl_lgenIdx].lgenCompRef, "): ",
v_ExecCtrl_lgens[vl_lgenIdx].name, " to variable : ", vl_varName));
f_EPTF_ExecCtrl_debug(log2str("Subscribing for (grp / scenName): ",
v_ExecCtrl_entityGroups[vl_eGrpIdx].name, " / ",
v_ExecCtrl_scenarios[pl_scIdx].scData.name));
f_EPTF_Var_subscribeRemote(
f_EPTF_Var_downcast(f_EPTF_Base_downcast(v_ExecCtrl_lgens[vl_lgenIdx].lgenCompRef)),
vl_varName,
realtime,
vl_idx,
vl_varName&"."&v_ExecCtrl_lgens[vl_lgenIdx].name
);
// append variable index to the list:
vl_args[sizeof(vl_args)] := vl_idx;
f_EPTF_ExecCtrl_debug(log2str("New variable created: ", vl_varName&"."&v_ExecCtrl_lgens[vl_lgenIdx].name));
} // lgenidx
vl_varName := "ExecCtrl.scenarioStatus."&v_ExecCtrl_entityGroups[vl_eGrpIdx].name&"."&v_ExecCtrl_scenarios[pl_scIdx].scData.name;
f_EPTF_Var_newStatusLED(vl_varName,{led_black, "Timeout"},vl_idx);
f_EPTF_Var_subscribeLocal(
vl_idx,
{
calcFn := {
funcRef := refers(f_EPTF_ExecCtrl_scenarioStateCalcFn),
argList := vl_args,
nonVarArgList := {pl_scIdx}
}
}
);
// add postproc that will call scenarioStateChangedCallbacks
var integer vl_prevStatusIdx; // this var is needed to call callbacks only when state changes
f_EPTF_Var_newCharstring(vl_varName&".prevValue","",vl_prevStatusIdx);
f_EPTF_Var_addPostProcFn(
vl_idx, { refers(f_EPTF_ExecCtrl_scenarioStatePostProc), {pl_scIdx, vl_prevStatusIdx}}
);
// call the postproc now:
f_EPTF_ExecCtrl_scenarioStatePostProc(vl_idx,{pl_scIdx, vl_prevStatusIdx});
f_EPTF_ExecCtrl_debug(%definitionId&": finished");
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_createTrafficCaseVariablesOfSc
//
// Purpose:
// Creates all traffic case variables for a scenario
//
// Parameters:
// - pl_scIdx - *in integer* - the scenario index in <EPTF_ExecCtrl_ScenarioList>
//
// Return Value:
// -
//
// Errors & assertions:
// - the specified indexes should point to valid groups and scenarios
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_createTrafficCaseVariablesOfSc(
in integer pl_scIdx
) runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug("### "& %definitionId&": start");
// go through all traffic cases of the scenario:
for(var integer tc:=0, size := sizeof(v_ExecCtrl_scenarios[pl_scIdx].tcIdxList); tc<size; tc:=tc+1) {
var integer vl_tcIdx := v_ExecCtrl_scenarios[pl_scIdx].tcIdxList[tc];
f_EPTF_ExecCtrl_subscribeTrafficCaseState(vl_tcIdx);
f_EPTF_ExecCtrl_createExecTimeForTc(vl_tcIdx);
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_subscribeTrafficCaseState
//
// Purpose:
// Subscribe for traffic case state variable on all ExecCtrlClient/LGen, and create a local variable to calculate the overall traffic case state
//
// Parameters:
// - pl_tcIdx - *in integer* - the traffic case index in <EPTF_ExecCtrl_TrafficCaseList>
//
// Return Value:
// -
//
// Errors & assertions:
// - the specified indexes should point to valid groups and scenarios
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_subscribeTrafficCaseState(
in integer pl_tcIdx
) runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug("### "& %definitionId&": start");
var integer vl_scIdx := v_ExecCtrl_trafficCases[pl_tcIdx].scenarioIdx;
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[vl_scIdx].eGroupIdx;
var integer vl_tcOfScenarioIdx := v_ExecCtrl_trafficCases[pl_tcIdx].tcOfScenarioIdx;
var integer vl_idx;
var charstring vl_varName := "ExecCtrlClient.trafficCaseStatus."&
v_ExecCtrl_entityGroups[vl_eGrpIdx].name&"."&v_ExecCtrl_scenarios[vl_scIdx].scData.name&"."&f_EPTF_LGenBase_tcNameOfTcOfSc(v_ExecCtrl_scenarios[vl_scIdx].scData,vl_tcOfScenarioIdx);
var EPTF_IntegerList vl_args := {};
for (var integer lgenidx:=0, size := sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList);lgenidx<size;lgenidx:=lgenidx+1)
{
var integer vl_lgenIdx := v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].lgenIdx;
// if no entities are allocated on the LGen
if (v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].eCount == 0 ) {
continue; // nothing to do
}
f_EPTF_ExecCtrl_debug(log2str("Subscribing on LGen (", v_ExecCtrl_lgens[vl_lgenIdx].lgenCompRef, "): ",
v_ExecCtrl_lgens[vl_lgenIdx].name, " to variable : ", vl_varName));
f_EPTF_ExecCtrl_debug(log2str("Subscribing for (grp / scenName): ",
v_ExecCtrl_entityGroups[vl_eGrpIdx].name, " / ",
v_ExecCtrl_scenarios[vl_scIdx].scData.name));
f_EPTF_Var_subscribeRemote(
f_EPTF_Var_downcast(f_EPTF_Base_downcast(v_ExecCtrl_lgens[vl_lgenIdx].lgenCompRef)),
vl_varName,
realtime,
vl_idx,
vl_varName&"."&v_ExecCtrl_lgens[vl_lgenIdx].name
);
// append variable index to the list:
vl_args[sizeof(vl_args)] := vl_idx;
f_EPTF_ExecCtrl_debug(log2str("New variable created: ", vl_varName&"."&v_ExecCtrl_lgens[vl_lgenIdx].name));
} // lgenidx
vl_varName := "ExecCtrl.trafficCaseStatus."&v_ExecCtrl_entityGroups[vl_eGrpIdx].name&"."&v_ExecCtrl_scenarios[vl_scIdx].scData.name&"."&f_EPTF_LGenBase_tcNameOfTcOfSc(v_ExecCtrl_scenarios[vl_scIdx].scData,vl_tcOfScenarioIdx)
f_EPTF_Var_newStatusLED(vl_varName,{led_black, "Timeout"},vl_idx);
f_EPTF_Var_subscribeLocal(
vl_idx,
{
calcFn := {
funcRef := refers(f_EPTF_ExecCtrl_scenarioStateCalcFn),
argList := vl_args,
nonVarArgList := {vl_scIdx}
}
}
);
// add postproc that will call trafficCaseStateChangedCallbacks
var integer vl_prevStatusIdx; // this var is needed to call callbacks only when state changes
f_EPTF_Var_newCharstring(vl_varName&".prevValue","",vl_prevStatusIdx);
f_EPTF_Var_addPostProcFn(
vl_idx, { refers(f_EPTF_ExecCtrl_trafficCaseStatePostProc), {pl_tcIdx, vl_prevStatusIdx}}
);
// call the postproc now:
f_EPTF_ExecCtrl_trafficCaseStatePostProc(vl_idx,{pl_tcIdx, vl_prevStatusIdx});
f_EPTF_ExecCtrl_debug(%definitionId&": finished");
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_createExecTimeForTc
//
// Purpose:
// Create the variable that shows the execTime of a traffic case
//
// Parameters:
// - pl_tcIdx - *in integer* - the traffic case index in <EPTF_ExecCtrl_TrafficCaseList>
//
// Return Value:
// -
//
// Errors & assertions:
// - the specified indexes should point to valid groups and scenarios
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_createExecTimeForTc(
in integer pl_tcIdx
) runs on EPTF_ExecCtrl_CT {
f_EPTF_ExecCtrl_debug("### "& %definitionId&": start");
var integer vl_scIdx := v_ExecCtrl_trafficCases[pl_tcIdx].scenarioIdx;
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[vl_scIdx].eGroupIdx;
var integer vl_tcOfScenarioIdx := v_ExecCtrl_trafficCases[pl_tcIdx].tcOfScenarioIdx;
var integer vl_statId := f_EPTF_StatMeasure_newStat_chrono();
f_EPTF_StatMeasure_stop_chrono(vl_statId);
// save the id into the onGroupFinish database:
v_ExecCtrl_trafficCases[pl_tcIdx].groupFinishData.onGroupFinish.execTimeStatId := vl_statId;
// add a callback that updates the stat periodically:
f_EPTF_Var_addSyncCallBackFn(refers(f_EPTF_ExecCtrl_updateExecTimeForTcSyncCallBack), {vl_statId});
}
// the function that updates the execTime stats pl_argList[0] : the statId
private function f_EPTF_ExecCtrl_updateExecTimeForTcSyncCallBack(in EPTF_IntegerList pl_argList) runs on EPTF_ExecCtrl_CT {
f_EPTF_StatMeasure_update_chrono(pl_argList[0]);
}
// this function starts and stops the execTime statistics for the traffic case
private function f_EPTF_ExecCtrl_execTimeUpdate_TCStateChangedCallbackFn(
in charstring pl_eGrpName,
in charstring pl_scName,
in charstring pl_tcName,
in charstring pl_state
) runs on EPTF_ExecCtrl_CT {
var integer vl_tcIdx := f_EPTF_ExecCtrl_getTrafficCaseIdx(pl_eGrpName,pl_scName,pl_tcName);
var integer vl_statId := -1;
//HM85637
if(isbound(v_ExecCtrl_trafficCases[vl_tcIdx].groupFinishData.onGroupFinish.execTimeStatId)) {
vl_statId := v_ExecCtrl_trafficCases[vl_tcIdx].groupFinishData.onGroupFinish.execTimeStatId;
}
if (vl_statId==-1) {
return;
}
// start the chronometer when TC state changes to running:
if (pl_state==c_EPTF_LGenBase_stateNames[c_EPTF_LGenBase_tcStateRunning]) {
f_EPTF_StatMeasure_resetStat(vl_statId);
f_EPTF_StatMeasure_addData_chrono(vl_statId);
return;
}
// reset the chronometer to 0 when TC state changes to idle
if (pl_state==c_EPTF_LGenBase_stateNames[c_EPTF_LGenBase_tcStateIdle]) {
f_EPTF_StatMeasure_resetStat(vl_statId);
f_EPTF_StatMeasure_stop_chrono(vl_statId);
return;
}
// stop chrono in any other case:
f_EPTF_StatMeasure_stop_chrono(vl_statId);
}
// returns the execTime of the traffic case (does not refresh the stat)
private function f_EPTF_ExecCtrl_getExecTimeForTc(
in integer pl_tcIdx
) runs on EPTF_ExecCtrl_CT return float {
return f_EPTF_StatMeasure_getTime_chrono(v_ExecCtrl_trafficCases[pl_tcIdx].groupFinishData.onGroupFinish.execTimeStatId);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_scenarioStateCalcFn
//
// Purpose:
// CalcFn function to calculate the statusLED from the scenario states in LGens
//
// Parameters:
// - pl_idx - *in integer* - idx of the EPTF Variable containing the statusLED
// - pl_argList - *in* <EPTF_IntegerList> - list of scenario State variables for LGens
// - pl_nonVarArgList - *in* <EPTF_IntegerList> - entity group and scenario idx
// - pl_retVal - *inout* <EPTF_Var_DirectContent> - the new value of the statusLED
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
// If the states are the same for all LGens, the state is set to the one
// calculated by <f_EPTF_ExecCtrl_stateStrToEPTF_StatusLED>.
// If the states are different, the state is set to : {led_yellow,"Mixed"}
// If pl_argList is empty, the state is set to: {led_black,"Off"}
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_scenarioStateCalcFn(in integer pl_idx, in EPTF_IntegerList pl_argList, in EPTF_IntegerList pl_nonVarArgList, inout EPTF_Var_DirectContent pl_retVal) runs on EPTF_ExecCtrl_CT {
pl_retVal := {statusLEDVal := {led_yellow, "Mixed"} }; // invalid
if(c_EPTF_Common_debugSwitch) {
f_EPTF_ExecCtrl_debug("### "& %definitionId&"()");
f_EPTF_ExecCtrl_debug(log2str("pl_idx: ", pl_idx));
f_EPTF_ExecCtrl_debug(log2str("pl_argList: ", pl_argList));
}
var EPTF_Var_DirectContent vl_content1;
var boolean sync := true;
if (sizeof(pl_argList) == 0) {
// no LGens
sync := true;
vl_content1 := {charstringVal := "Off"};
} else {
// LGen list is not empty
var EPTF_Var_DirectContent vl_content2;
var integer vl_LGenScenarioStateVarIdx := pl_argList[0];
f_EPTF_Var_getContent(vl_LGenScenarioStateVarIdx, vl_content1);
for (var integer i:=1, size := sizeof(pl_argList); i<size; i:=i+1) {
vl_LGenScenarioStateVarIdx := pl_argList[i];
f_EPTF_Var_getContent(vl_LGenScenarioStateVarIdx, vl_content2);
if (vl_content1 != vl_content2) {
sync := false;
break;
}
}
}
if (sync) {
f_EPTF_ExecCtrl_debug(log2str("Scenario state is in sync for scenario ", f_EPTF_Var_getName(pl_idx), " : ", vl_content1));
pl_retVal := {
statusLEDVal := f_EPTF_ExecCtrl_stateStrToEPTF_StatusLED(vl_content1.charstringVal)
}
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_stateStrToEPTF_StatusLED
//
// Purpose:
// Converts c_EPTF_LGenBase_stateNames to statusLED
//
// Parameters:
// - pl_state - *in charstring* - stateName
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_stateStrToEPTF_StatusLED(in charstring pl_state) return EPTF_StatusLED {
var EPTF_StatusLED vl_led;
select (pl_state) {
case (c_EPTF_LGenBase_stateNames[c_EPTF_LGenBase_tcStateIdle]) {
vl_led := {
color := led_blue,
text := pl_state
}
}
case (c_EPTF_LGenBase_stateNames[c_EPTF_LGenBase_tcStateAborting]) {
vl_led := {
color := led_red,
text := pl_state
}
}
case (c_EPTF_LGenBase_stateNames[c_EPTF_LGenBase_tcStateRunning]) {
vl_led := {
color := led_green,
text := pl_state
}
}
case (c_EPTF_LGenBase_stateNames[c_EPTF_LGenBase_tcStateTerminated]) {
vl_led := {
color := led_blue,
text := pl_state
}
}
case (c_EPTF_LGenBase_stateNames[c_EPTF_LGenBase_tcStateFinished]) {
vl_led := {
color := led_yellow,
text := pl_state
}
}
case (c_EPTF_LGenBase_stateNames[c_EPTF_LGenBase_tcStateStopped]) {
vl_led := {
color := led_blue,
text := pl_state
}
}
case (c_EPTF_LGenBase_stateNames[c_EPTF_LGenBase_tcStateAborted]) {
vl_led := {
color := led_blue,
text := pl_state
}
}
case (c_EPTF_LGenBase_stateNames[c_EPTF_LGenBase_tcStatePaused]) {
vl_led := {
color := led_blue,
text := pl_state
}
}
case (c_EPTF_LGenBase_stateNames[c_EPTF_LGenBase_tcStateStopping]) {
vl_led := {
color := led_red,
text := pl_state
}
}
case else {
vl_led := {
color := led_black,
text := pl_state
}
}
}
return vl_led;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_scenarioStatePostProc
//
// Purpose:
// Postproc fn to call ScenarioStateChangedCallbacks
//
// Parameters:
// - pl_idx - *in integer* - idx of the EPTF Variable containing the statusLED
// - pl_argList - *in* <EPTF_IntegerList> - index of the scenario instance
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
// This postproc is used on the statusLED variable of the scenario (ExecCtrl.scenarioStatus)
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_scenarioStatePostProc(
in integer pl_idx,
in EPTF_IntegerList pl_argList)
runs on EPTF_ExecCtrl_CT {
if (not v_ExecCtrl_initialized) {
return;
}
var integer vl_scIdx := pl_argList[0];
var integer vl_prevStatusIdx := pl_argList[1];
var EPTF_StatusLED vl_status := f_EPTF_Var_getStatusLEDValue(pl_idx);
var charstring vl_prevStatus := f_EPTF_Var_getCharstringValue(vl_prevStatusIdx);
// do nothing if status not changed:
if (vl_prevStatus==vl_status.text) {
return;
}
// update prevStatus (no subscribers => adjustContent is not needed, setContent is faster):
f_EPTF_Var_setContent(vl_prevStatusIdx,{charstringVal:=vl_status.text});
// call callback functions (eGrpName,scenName,statusTxt)
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[vl_scIdx].eGroupIdx;
var charstring vl_eGrpName := v_ExecCtrl_entityGroups[vl_eGrpIdx].name;
var charstring vl_scenName := v_ExecCtrl_scenarios[vl_scIdx].scData.name;
f_EPTF_ExecCtrl_callScenarioStateChangedCallbacks(vl_eGrpName,vl_scenName,vl_status.text);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_registerScenarioStateChangedCallback
//
// Purpose:
// Register a scenario stateChange callback function, that is called when the states of the scenarios in all LGens reach the same state
//
// Parameters:
// - pl_scenarioStateChangedCallback - *in* <EPTF_ExecCtrl_ScenarioStateChangedCallbackFn> - reference to the callback function
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_registerScenarioStateChangedCallback(in EPTF_ExecCtrl_ScenarioStateChangedCallbackFn pl_scenarioStateChangedCallback) runs on EPTF_ExecCtrl_CT {
v_EPTF_ExecCtrl_ScenarioStateChangedCallbackFns[sizeof(v_EPTF_ExecCtrl_ScenarioStateChangedCallbackFns)] := pl_scenarioStateChangedCallback;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_callScenarioStateChangedCallbacks
//
// Purpose:
// Calls all scenarioStateChange callback functions
//
// Parameters:
// - pl_eGrpName - *in charstring* - name of the entity group
// - pl_scName - *in charstring* - name of the scenario
// - pl_state - *in charstring* - state of the scenario (see <c_EPTF_LGenBase_stateNames> in <EPTF_CLL_LGenBase_Definitions> for possible values)
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_callScenarioStateChangedCallbacks(in charstring pl_eGrpName, in charstring pl_scName, in charstring pl_state) runs on EPTF_ExecCtrl_CT {
for(var integer i:=0, size := sizeof(v_EPTF_ExecCtrl_ScenarioStateChangedCallbackFns); i<size; i:=i+1) {
if(c_EPTF_Common_debugSwitch) {
f_EPTF_ExecCtrl_debug(log2str("ExecCtrl: scenarioStateChangedCallback: ", v_EPTF_ExecCtrl_ScenarioStateChangedCallbackFns[i], " called"));
f_EPTF_ExecCtrl_debug(log2str("Args: pl_eGrpName: ", pl_eGrpName, " pl_scName: ", pl_scName, " pl_state: ",pl_state))
}
v_EPTF_ExecCtrl_ScenarioStateChangedCallbackFns[i].apply(pl_eGrpName,pl_scName,pl_state);
if(c_EPTF_Common_debugSwitch) {
f_EPTF_ExecCtrl_debug(log2str("ExecCtrl: scenarioStateChangedCallback: ", v_EPTF_ExecCtrl_ScenarioStateChangedCallbackFns[i], " done"));
}
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_trafficCaseStatePostProc
//
// Purpose:
// Postproc fn to call TrafficCaseStateChangedCallbacks
//
// Parameters:
// - pl_idx - *in integer* - idx of the EPTF Variable containing the statusLED
// - pl_argList - *in* <EPTF_IntegerList> - index of the trafficCase instance
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
// This postproc is used on the statusLED variable of the traffic case (ExecCtrl.trafficCaseStatus)
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_trafficCaseStatePostProc(
in integer pl_idx,
in EPTF_IntegerList pl_argList)
runs on EPTF_ExecCtrl_CT {
if (not v_ExecCtrl_initialized) {
return;
}
var integer vl_tcIdx := pl_argList[0];
var integer vl_prevStatusIdx := pl_argList[1];
var EPTF_StatusLED vl_status := f_EPTF_Var_getStatusLEDValue(pl_idx);
var charstring vl_prevStatus := f_EPTF_Var_getCharstringValue(vl_prevStatusIdx);
// do nothing if status not changed:
if (vl_prevStatus==vl_status.text) {
return;
}
// update prevStatus (no subscribers => adjustContent is not needed, setContent is faster):
f_EPTF_Var_setContent(vl_prevStatusIdx,{charstringVal:=vl_status.text});
// call callback functions (eGrpName,scenName,statusTxt)
var integer vl_scIdx := v_ExecCtrl_trafficCases[vl_tcIdx].scenarioIdx;
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[vl_scIdx].eGroupIdx;
var integer vl_tcOfScIdx := v_ExecCtrl_trafficCases[vl_tcIdx].tcOfScenarioIdx;
var charstring vl_eGrpName := v_ExecCtrl_entityGroups[vl_eGrpIdx].name;
var charstring vl_scenName := v_ExecCtrl_scenarios[vl_scIdx].scData.name;
var charstring vl_tcName := f_EPTF_LGenBase_tcNameOfTcOfSc(v_ExecCtrl_scenarios[vl_scIdx].scData,vl_tcOfScIdx);
f_EPTF_ExecCtrl_callTrafficCaseStateChangedCallbacks(vl_eGrpName,vl_scenName,vl_tcName,vl_status.text);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_registerTrafficCaseStateChangedCallback
//
// Purpose:
// Register a trafficCase stateChange callback function, that is called when the states of the trafficCases in all LGens reach the same state
//
// Parameters:
// - pl_trafficCaseStateChangedCallback - *in* <EPTF_ExecCtrl_TrafficCaseStateChangedCallbackFn> - reference to the callback function
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_registerTrafficCaseStateChangedCallback(in EPTF_ExecCtrl_TrafficCaseStateChangedCallbackFn pl_trafficCaseStateChangedCallback) runs on EPTF_ExecCtrl_CT {
v_EPTF_ExecCtrl_TrafficCaseStateChangedCallbackFns[sizeof(v_EPTF_ExecCtrl_TrafficCaseStateChangedCallbackFns)] := pl_trafficCaseStateChangedCallback;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_callTrafficCaseStateChangedCallbacks
//
// Purpose:
// Calls all trafficCaseStateChange callback functions
//
// Parameters:
// - pl_eGrpName - *in charstring* - name of the entity group
// - pl_scName - *in charstring* - name of the trafficCase
// - pl_tcName - *in charstring* - name of the trafficCase
// - pl_state - *in charstring* - state of the trafficCase (see <c_EPTF_LGenBase_stateNames> in <EPTF_CLL_LGenBase_Definitions> for possible values)
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_callTrafficCaseStateChangedCallbacks(in charstring pl_eGrpName, in charstring pl_scName, in charstring pl_tcName, in charstring pl_state) runs on EPTF_ExecCtrl_CT {
//f_EPTF_ExecCtrl_debug(%definitionId&": ", pl_eGrpName, " pl_scName: ", pl_scName, " pl_tcName: ", pl_tcName, " pl_state: ",pl_state);
for(var integer i:=0, size := sizeof(v_EPTF_ExecCtrl_TrafficCaseStateChangedCallbackFns); i<size;i:=i+1) {
if(c_EPTF_Common_debugSwitch) {
f_EPTF_ExecCtrl_debug(log2str("ExecCtrl: trafficCaseStateChangedCallback: ", v_EPTF_ExecCtrl_TrafficCaseStateChangedCallbackFns[i], " called"));
f_EPTF_ExecCtrl_debug(log2str("Args: pl_eGrpName: ", pl_eGrpName, " pl_scName: ", pl_scName, " pl_tcName: ", pl_tcName, " pl_state: ",pl_state))
}
v_EPTF_ExecCtrl_TrafficCaseStateChangedCallbackFns[i].apply(pl_eGrpName,pl_scName,pl_tcName,pl_state);
if(c_EPTF_Common_debugSwitch) {
f_EPTF_ExecCtrl_debug(log2str("ExecCtrl: trafficCaseStateChangedCallback: ", v_EPTF_ExecCtrl_TrafficCaseStateChangedCallbackFns[i], " done"));
}
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_createStartStopScenario
//
// Purpose:
// Creates a variable that can be used to start/stop the scenario
//
// Parameters:
// - pl_scIdx - *in integer* - the scenario index in <EPTF_ExecCtrl_ScenarioList>
//
// Return Value:
// -
//
// Errors & assertions:
// - the specified indexes should point to valid groups and scenarios
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_createStartStopScenario(
in integer pl_scIdx
) runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug("### "& %definitionId&": start");
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[pl_scIdx].eGroupIdx;
var charstring vl_eType;
var integer vl_startScenarioVarIdx;
var integer vl_stopScenarioVarIdx;
var charstring vl_varName := "ExecCtrl.scenarioStatus."&v_ExecCtrl_entityGroups[vl_eGrpIdx].name&"."&v_ExecCtrl_scenarios[pl_scIdx].scData.name;
var integer vl_scenarioStateVarIdx := f_EPTF_Var_getId(vl_varName);
// Start Scenario
vl_varName := "ExecCtrl.startScenario."&v_ExecCtrl_entityGroups[vl_eGrpIdx].name&"."&v_ExecCtrl_scenarios[pl_scIdx].scData.name;
f_EPTF_Var_newBool(vl_varName,false,vl_startScenarioVarIdx);
// Stop Scenario
vl_varName := "ExecCtrl.stopScenario."&v_ExecCtrl_entityGroups[vl_eGrpIdx].name&"."&v_ExecCtrl_scenarios[pl_scIdx].scData.name;
f_EPTF_Var_newBool(vl_varName,false,vl_stopScenarioVarIdx);
var EPTF_IntegerList vl_args := {};
// Start Scenario
f_EPTF_Var_addGuardFn(
vl_startScenarioVarIdx,
{
funcRef := refers(f_EPTF_ExecCtrl_startScenarioGuardFn),
argList := {pl_scIdx,vl_scenarioStateVarIdx,vl_stopScenarioVarIdx}
}
);
// Stop Scenario
f_EPTF_Var_addGuardFn(
vl_stopScenarioVarIdx,
{
funcRef := refers(f_EPTF_ExecCtrl_stopScenarioGuardFn),
argList := {pl_scIdx,vl_scenarioStateVarIdx,vl_startScenarioVarIdx}
}
);
f_EPTF_ExecCtrl_debug(%definitionId&": finished");
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_startScenarioGuardFn
//
// Purpose:
// GuardFn function to start/stop the scenario
//
// Parameters:
// - pl_idx - *in integer* - idx of the EPTF Variable containing the runScenario variable
// - pl_argList - *in* <EPTF_IntegerList> - not used
// - pl_newContent - *in* <EPTF_Var_DirectContent> - the new value of the runScenario
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
// if the scenario is not running: starts the scenario and sets it to true
// if the scenario is not stopped: stops the scenario and sets the value to false
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_startScenarioGuardFn(in integer pl_idx, in EPTF_IntegerList pl_argList, in EPTF_Var_DirectContent pl_newContent) runs on EPTF_ExecCtrl_CT return boolean {
var integer vl_scIdx := pl_argList[0];
var integer vl_scenarioStateVarIdx := pl_argList[1];
var integer vl_stopScenarioVarIdx := pl_argList[2];
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[vl_scIdx].eGroupIdx;
var charstring vl_eGrpName := v_ExecCtrl_entityGroups[vl_eGrpIdx].name;
var charstring vl_scenName := v_ExecCtrl_scenarios[vl_scIdx].scData.name;
// var EPTF_Var_DirectContent vl_scenarioState;
// f_EPTF_Var_getContent(vl_scenarioStateVarIdx,vl_scenarioState);
// if (vl_scenarioState.statusLEDVal.text=="Running") {
// if (pl_newContent.boolVal==true) {
// f_EPTF_Var_refreshContent(pl_idx); // update the gui with the previous value
// return false; // new value is not accepted
// }
// }// else {
if (pl_newContent.boolVal==true) {
// check if button is disabled:
if (f_EPTF_ExecCtrl_isDisabledStartStopScenario(
{vl_eGrpName, vl_scenName}
)) {
f_EPTF_Var_refreshContent(pl_idx); // update the gui with the previous value
return false;
}
// uncheck the other:
f_EPTF_Var_adjustContent(vl_stopScenarioVarIdx,{boolVal := false})
// start scenario:
f_EPTF_ExecCtrl_startScenarioOnLGens(vl_scIdx);
}
// }
return true;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_stopScenarioGuardFn
//
// Purpose:
// GuardFn function to start/stop the scenario
//
// Parameters:
// - pl_idx - *in integer* - idx of the EPTF Variable containing the runScenario variable
// - pl_argList - *in* <EPTF_IntegerList> - not used
// - pl_newContent - *in* <EPTF_Var_DirectContent> - the new value of the runScenario
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
// if the scenario is not running: starts the scenario and sets it to true
// if the scenario is not stopped: stops the scenario and sets the value to false
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_stopScenarioGuardFn(in integer pl_idx, in EPTF_IntegerList pl_argList, in EPTF_Var_DirectContent pl_newContent) runs on EPTF_ExecCtrl_CT return boolean {
var integer vl_scIdx := pl_argList[0];
var integer vl_scenarioStateVarIdx := pl_argList[1];
var integer vl_startScenarioVarIdx := pl_argList[2];
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[vl_scIdx].eGroupIdx;
var charstring vl_eGrpName := v_ExecCtrl_entityGroups[vl_eGrpIdx].name;
var charstring vl_scenName := v_ExecCtrl_scenarios[vl_scIdx].scData.name;
// var EPTF_Var_DirectContent vl_scenarioState;
// f_EPTF_Var_getContent(vl_scenarioStateVarIdx,vl_scenarioState);
// if (vl_scenarioState.statusLEDVal.text=="Idle"
// or vl_scenarioState.statusLEDVal.text=="Stopped"
// or vl_scenarioState.statusLEDVal.text=="Aborted"
// or vl_scenarioState.statusLEDVal.text=="Finished"
// or vl_scenarioState.statusLEDVal.text=="Paused"
// ) {
// if (pl_newContent.boolVal==true) {
// f_EPTF_Var_refreshContent(pl_idx); // update the gui with the previous value
// return false; // new value is not accepted
// }
// }// else {
if (pl_newContent.boolVal==true) {
// check if button is disabled:
if (f_EPTF_ExecCtrl_isDisabledStartStopScenario(
{vl_eGrpName, vl_scenName}
)) {
f_EPTF_Var_refreshContent(pl_idx); // update the gui with the previous value
return false;
}
// uncheck the other:
f_EPTF_Var_adjustContent(vl_startScenarioVarIdx,{boolVal := false})
// start scenario:
f_EPTF_ExecCtrl_stopScenarioOnLGens(vl_scIdx);
}
// }
return true;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_enableStartStopScenario
//
// Purpose:
// Adds or enables start/stop scenario button
//
// Parameters:
// - pl_scIdName - *in* <EPTF_ExecCtrl_SCName> - entity group and scenario name
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_enableStartStopScenario(in EPTF_ExecCtrl_SCName pl_scIdName) runs on EPTF_ExecCtrl_CT {
var integer vl_idx := f_EPTF_ExecCtrl_getStartStopScenarioIdx(pl_scIdName);
if (vl_idx!=-1) {
v_EPTF_ExecCtrl_StartStopScenarioDisable[vl_idx].disabled := false;
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_disableStartStopScenario
//
// Purpose:
// Adds or disables start/stop scenario button
//
// Parameters:
// - pl_scIdName - *in* <EPTF_ExecCtrl_SCName> - entity group and scenario name
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_disableStartStopScenario(in EPTF_ExecCtrl_SCName pl_scIdName) runs on EPTF_ExecCtrl_CT {
var integer vl_idx := f_EPTF_ExecCtrl_getStartStopScenarioIdx(pl_scIdName);
if (vl_idx!=-1) {
v_EPTF_ExecCtrl_StartStopScenarioDisable[vl_idx].disabled := true;
return;
}
// add new item
vl_idx := sizeof(v_EPTF_ExecCtrl_StartStopScenarioDisable);
v_EPTF_ExecCtrl_StartStopScenarioDisable[vl_idx].disabled := true;
v_EPTF_ExecCtrl_StartStopScenarioDisable[vl_idx].scIdName := pl_scIdName;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_disableScenariosForPhaseGroups
//
// Purpose:
// Disables scenarios that are in scenarioGroups
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_disableScenariosForPhaseGroups() runs on EPTF_ExecCtrl_CT {
f_EPTF_ExecCtrl_debug(%definitionId&": started...");
f_EPTF_ExecCtrl_debug(log2str("v_ExecCtrl_ScenarioGroupInstanceDB: ", v_ExecCtrl_ScenarioGroupInstanceDB));
for(var integer scGroup:=0, size := sizeof(v_ExecCtrl_ScenarioGroupInstanceDB.data); scGroup<size;scGroup:=scGroup+1) {
for(var integer sc:=0, sizesc := sizeof(v_ExecCtrl_ScenarioGroupInstanceDB.data[scGroup].scenarios); sc<sizesc; sc:=sc+1) {
// FIXME: check if it is not a removed item (FBQ element is busy)
var charstring vl_scName := v_ExecCtrl_ScenarioGroupInstanceDB.data[scGroup].scenarios[sc].name;
var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioIdxByInstanceName(vl_scName);
f_EPTF_ExecCtrl_debug(log2str("Disabling scenarioStartStop for scenario: ", vl_scName));
if (vl_scIdx==-1) {
f_EPTF_ExecCtrl_debug(log2str("Scenario not found: ", vl_scName));
continue;
}
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[vl_scIdx].eGroupIdx;
var charstring vl_eGrpName := v_ExecCtrl_entityGroups[vl_eGrpIdx].name;
var charstring vl_scTypeName := v_ExecCtrl_scenarios[vl_scIdx].scData.name;
var EPTF_ExecCtrl_SCName vl_scIdName := {
vl_eGrpName,
vl_scTypeName
};
f_EPTF_ExecCtrl_disableStartStopScenario(vl_scIdName);
}
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_scenarioIsNotInScenarioGroup
//
// Purpose:
// Checks if a scenario belongs to a scenario group
//
// Parameters:
// - pl_scIdName - *in* <EPTF_ExecCtrl_SCName> - entity group and scenario name
//
// Return Value:
// boolean
//
// Errors & assertions:
// -
//
// Detailed Comments:
// Returns true if the scenario does not belong to any scenario group
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_scenarioIsNotInScenarioGroup(in integer pl_scIdx)
runs on EPTF_ExecCtrl_CT
return boolean {
return (f_EPTF_ExecCtrl_ScenarioGroup_get_byScIndex(pl_scIdx)==-1)
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_isDisabledStartStopScenario
//
// Purpose:
// Checks if start/stop scenario button is disabled
//
// Parameters:
// - pl_scIdName - *in* <EPTF_ExecCtrl_SCName> - entity group and scenario name
//
// Return Value:
// boolean - true if disabled, false if not (if not specified it is considered to be false (enabled))
//
// Errors & assertions:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_isDisabledStartStopScenario(in EPTF_ExecCtrl_SCName pl_scIdName) runs on EPTF_ExecCtrl_CT return boolean {
var integer vl_idx := f_EPTF_ExecCtrl_getStartStopScenarioIdx(pl_scIdName);
if (vl_idx!=-1 and v_EPTF_ExecCtrl_StartStopScenarioDisable[vl_idx].disabled) {
return true;
}
return false;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_getStartStopScenarioIdx
//
// Purpose:
// Returns the idx of the start/stop scenario button item
//
// Parameters:
// - pl_scIdName - *in* <EPTF_ExecCtrl_SCName> - entity group and scenario name
//
// Return Value:
// integer - the index in v_EPTF_ExecCtrl_StartStopScenarioDisable of the enable data
//
// Errors & assertions:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_getStartStopScenarioIdx(in EPTF_ExecCtrl_SCName pl_scIdName) runs on EPTF_ExecCtrl_CT return integer {
for(var integer i:=0, size := sizeof(v_EPTF_ExecCtrl_StartStopScenarioDisable); i<size;i:=i+1) {
if (v_EPTF_ExecCtrl_StartStopScenarioDisable[i].scIdName == pl_scIdName) {
return i;
}
}
return -1; // not found
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_createStartStopAllTC
//
// Purpose:
// Calls <f_EPTF_ExecCtrl_createStartStopTC> for all traffic cases for the specified eGrp and scen
//
// Parameters:
// - pl_scIdx - *in integer* - the scenario index in <EPTF_ExecCtrl_ScenarioList>
//
// Return Value:
// -
//
// Errors & assertions:
// - the specified indexes should point to valid groups and scenarios
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_createStartStopAllTC(
in integer pl_scIdx
) runs on EPTF_ExecCtrl_CT {
var charstring scenName := v_ExecCtrl_scenarios[pl_scIdx].scData.name;
for(var integer i:=0, size := sizeof(v_ExecCtrl_scenarios[pl_scIdx].scData.tcList); i<size; i:=i+1) {
f_EPTF_ExecCtrl_createStartStopTC(pl_scIdx,i);
f_EPTF_ExecCtrl_createResetStatsTC(pl_scIdx,i);
f_EPTF_ExecCtrl_createResetFSMStatsTC(pl_scIdx,i);
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_createStartStopTC
//
// Purpose:
// Creates a variable that can be used to start/stop the TC
//
// Parameters:
// - pl_scIdx - *in integer* - the scenario index in <EPTF_ExecCtrl_ScenarioList>
// - pl_tcOfScIdx - *in integer* - the tclist index in <EPTF_ExecCtrl_ScenarioList>.scData.tcList
//
// Return Value:
// -
//
// Errors & assertions:
// - the specified indexes should point to valid groups and scenarios and traffic case
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_createStartStopTC(
in integer pl_scIdx,
in integer pl_tcOfScIdx
)
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug("### "& %definitionId&": start");
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[pl_scIdx].eGroupIdx;
var charstring eGrpName := v_ExecCtrl_entityGroups[vl_eGrpIdx].name;
var charstring scenName := v_ExecCtrl_scenarios[pl_scIdx].scData.name;
var charstring tcName := f_EPTF_LGenBase_tcNameOfTcOfSc(v_ExecCtrl_scenarios[pl_scIdx].scData,pl_tcOfScIdx)
var integer vl_startTCVarIdx;
var integer vl_stopTCVarIdx;
var charstring vl_varName;// := "ExecCtrl.scenarioStatus."&eGrpName&"."&scenName;
// var integer vl_scenarioStateVarIdx := f_EPTF_Var_getId(vl_varName);
// Start TC
vl_varName := "ExecCtrl.startTC."&eGrpName&"."&scenName&"."&tcName;
f_EPTF_Var_newBool(vl_varName,false,vl_startTCVarIdx);
// Stop Tc
vl_varName := "ExecCtrl.stopTC."&eGrpName&"."&scenName&"."&tcName;
f_EPTF_Var_newBool(vl_varName,false,vl_stopTCVarIdx);
var EPTF_IntegerList vl_args := {};
// Start Tc
f_EPTF_Var_addGuardFn(
vl_startTCVarIdx,
{
funcRef := refers(f_EPTF_ExecCtrl_startTCGuardFn),
argList := {pl_scIdx,pl_tcOfScIdx/*,vl_scenarioStateVarIdx*/,vl_stopTCVarIdx}
}
);
// Stop Tc
f_EPTF_Var_addGuardFn(
vl_stopTCVarIdx,
{
funcRef := refers(f_EPTF_ExecCtrl_stopTCGuardFn),
argList := {pl_scIdx,pl_tcOfScIdx/*,vl_scenarioStateVarIdx*/,vl_startTCVarIdx}
}
);
// create same with integers:
// Control buttons (start/stop):
// start tc button:
var charstring vl_currentName := c_EPTF_ExecCtrl_statisticsRoot&".EG."&eGrpName&".SC."&scenName&".TC."&tcName&".ControlButtons.Start";
var integer vl_startTcVarIdx,vl_stopTcVarIdx;
f_EPTF_Var_newInt(
vl_currentName, 0, vl_startTcVarIdx);
// stop tc button:
vl_currentName := c_EPTF_ExecCtrl_statisticsRoot&".EG."&eGrpName&".SC."&scenName&".TC."&tcName&".ControlButtons.Stop";
f_EPTF_Var_newInt(
vl_currentName, 0, vl_stopTcVarIdx);
// add postProc-es:
f_EPTF_Var_addPostProcFn(
vl_startTcVarIdx, { refers(f_EPTF_ExecCtrl_UIVars_startTc_PostProc), {pl_scIdx,pl_tcOfScIdx,vl_startTcVarIdx,vl_stopTcVarIdx}} );
f_EPTF_Var_addPostProcFn(
vl_stopTcVarIdx, { refers(f_EPTF_ExecCtrl_UIVars_stopTc_PostProc), {pl_scIdx,pl_tcOfScIdx,vl_startTcVarIdx,vl_stopTcVarIdx}} );
// call f_EPTF_ExecCtrl_startStopScenario_scenarioStateChangedCallback to initialize button status:
vl_currentName := "ExecCtrl.trafficCaseStatus."&eGrpName&"."&scenName&"."&tcName;
var integer vl_idx := f_EPTF_Var_getId(vl_currentName);
if (vl_idx != -1) {
var EPTF_StatusLED vl_EPTF_StatusLED := f_EPTF_Var_getStatusLEDValue(vl_idx);
f_EPTF_ExecCtrl_startStopTc_tcStateChangedCallback(eGrpName,scenName,tcName,vl_EPTF_StatusLED.text);
}
// disable start/stop tc buttons if tc is in scenario group:
if (not f_EPTF_ExecCtrl_scenarioIsNotInScenarioGroup(pl_scIdx)) {
f_EPTF_Var_setSubsCanAdjust(vl_startTcVarIdx,false);
f_EPTF_Var_setSubsCanAdjust(vl_stopTcVarIdx,false);
}
f_EPTF_ExecCtrl_debug(%definitionId&": finished");
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_createResetStatsTC
//
// Purpose:
// Creates a variable that can be used to reset some TC stats
//
// Parameters:
// - pl_scIdx - *in integer* - the scenario index in <EPTF_ExecCtrl_ScenarioList>
// - pl_tcOfScIdx - *in integer* - the tclist index in <EPTF_ExecCtrl_ScenarioList>.scData.tcList
//
// Return Value:
// -
//
// Errors & assertions:
// - the specified indexes should point to valid groups and scenarios and traffic case
//
// Detailed Comments:
// The created variable can be used to reset the following TC stats:
// -Start
// -Success
// -Fail
// -Timeout
// -Error
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_createResetStatsTC(in integer pl_scIdx, in integer pl_tcOfScIdx)
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug("### "& %definitionId&": start");
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[pl_scIdx].eGroupIdx;
var charstring eGrpName := v_ExecCtrl_entityGroups[vl_eGrpIdx].name;
var charstring scenName := v_ExecCtrl_scenarios[pl_scIdx].scData.name;
var charstring tcName := f_EPTF_LGenBase_tcNameOfTcOfSc(v_ExecCtrl_scenarios[pl_scIdx].scData,pl_tcOfScIdx)
var integer vl_resetStatsTcVarIdx;
var charstring vl_varName := "ExecCtrl.resetStatsTC."&eGrpName&"."&scenName&"."&tcName;
f_EPTF_Var_newInt(vl_varName, 0, vl_resetStatsTcVarIdx);
// add postProc-es:
f_EPTF_Var_addPostProcFn(vl_resetStatsTcVarIdx, {refers(f_EPTF_ExecCtrl_UIVars_resetStatsTc_PostProc), {pl_scIdx, pl_tcOfScIdx}});
f_EPTF_ExecCtrl_debug(%definitionId&": finished");
}
private function f_EPTF_ExecCtrl_createResetStatsAllTC()
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug("### "& %definitionId&": start");
var integer vl_resetStatsTcVarIdx;
var charstring vl_varName := "ExecCtrl.resetStatsAllTC";
f_EPTF_Var_newInt(vl_varName, 0, vl_resetStatsTcVarIdx);
// add postProc-es:
f_EPTF_Var_addPostProcFn(vl_resetStatsTcVarIdx, {refers(f_EPTF_ExecCtrl_UIVars_resetStatsAllTc_PostProc), {}});
f_EPTF_ExecCtrl_debug(%definitionId&": finished");
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_createResetFSMStatsTC
//
// Purpose:
// Creates a variable that can be used to reset the FSM stats of a Traffic Case
//
// Parameters:
// - pl_scIdx - *in integer* - the scenario index in <EPTF_ExecCtrl_ScenarioList>
// - pl_tcOfScIdx - *in integer* - the tclist index in <EPTF_ExecCtrl_ScenarioList>.scData.tcList
//
// Return Value:
// -
//
// Errors & assertions:
// - the specified indexes should point to valid groups and scenarios and traffic case
//
// Detailed Comments:
// The created variable can be used to reset the following TC stats:
// -Start
// -Success
// -Fail
// -Timeout
// -Error
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_createResetFSMStatsTC(in integer pl_scIdx, in integer pl_tcOfScIdx)
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug("### "& %definitionId&": start");
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[pl_scIdx].eGroupIdx;
var charstring eGrpName := v_ExecCtrl_entityGroups[vl_eGrpIdx].name;
var charstring scenName := v_ExecCtrl_scenarios[pl_scIdx].scData.name;
var charstring tcName := f_EPTF_LGenBase_tcNameOfTcOfSc(v_ExecCtrl_scenarios[pl_scIdx].scData,pl_tcOfScIdx)
var integer vl_resetStatsTcVarIdx;
var charstring vl_varName := "ExecCtrl.resetFSMStatsTC."&eGrpName&"."&scenName&"."&tcName;
f_EPTF_Var_newInt(vl_varName, 0, vl_resetStatsTcVarIdx);
// add postProc-es:
f_EPTF_Var_addPostProcFn(vl_resetStatsTcVarIdx, {refers(f_EPTF_ExecCtrl_UIVars_resetFSMStatsTc_PostProc), {pl_scIdx, pl_tcOfScIdx}});
f_EPTF_ExecCtrl_debug(%definitionId&": finished");
}
private function f_EPTF_ExecCtrl_createResetFSMStatsAllTC()
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug("### "& %definitionId&": start");
var integer vl_resetStatsTcVarIdx;
var charstring vl_varName := "ExecCtrl.resetFSMStatsAllTC";
f_EPTF_Var_newInt(vl_varName, 0, vl_resetStatsTcVarIdx);
// add postProc-es:
f_EPTF_Var_addPostProcFn(vl_resetStatsTcVarIdx, {refers(f_EPTF_ExecCtrl_UIVars_resetFSMStatsAllTc_PostProc), {}});
f_EPTF_ExecCtrl_debug(%definitionId&": finished");
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_startTCGuardFn
//
// Purpose:
// GuardFn function to start/stop the TC
//
// Parameters:
// - pl_idx - *in integer* - idx of the EPTF Variable containing the runScenario variable
// - pl_argList - *in* <EPTF_IntegerList> - not used
// - pl_newContent - *in* <EPTF_Var_DirectContent> - the new value of the runScenario
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
// if the scenario is not running: starts the scenario and sets it to true
// if the scenario is not stopped: stops the scenario and sets the value to false
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_startTCGuardFn(in integer pl_idx, in EPTF_IntegerList pl_argList, in EPTF_Var_DirectContent pl_newContent) runs on EPTF_ExecCtrl_CT return boolean {
var integer vl_scIdx := pl_argList[0];
// var integer vl_scenarioStateVarIdx := pl_argList[2];
var integer vl_tcOfScIdx := pl_argList[1];
var integer vl_stopTCVarIdx := pl_argList[2];
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[vl_scIdx].eGroupIdx;
var charstring eGrpName := v_ExecCtrl_entityGroups[vl_eGrpIdx].name;
var charstring scenName := v_ExecCtrl_scenarios[vl_scIdx].scData.name;
var charstring tcName := f_EPTF_LGenBase_tcNameOfTcOfSc(v_ExecCtrl_scenarios[vl_scIdx].scData,vl_tcOfScIdx)
if (pl_newContent.boolVal==true) {
// check if button is disabled:
if (f_EPTF_ExecCtrl_isDisabledStartStopTC(
{eGrpName, scenName, tcName}
)) {
f_EPTF_Var_refreshContent(pl_idx); // update the gui with the previous value
return false;
}
// // uncheck the other:
// f_EPTF_Var_adjustContent(vl_stopTCVarIdx,{boolVal := false})
// start TC:
f_EPTF_ExecCtrl_startTCOnLGens(vl_scIdx,vl_tcOfScIdx);
return true;
}
return true;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_stopTCGuardFn
//
// Purpose:
// GuardFn function to start/stop the TC
//
// Parameters:
// - pl_idx - *in integer* - idx of the EPTF Variable containing the runScenario variable
// - pl_argList - *in* <EPTF_IntegerList> - not used
// - pl_newContent - *in* <EPTF_Var_DirectContent> - the new value of the runScenario
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
// if the scenario is not running: starts the scenario and sets it to true
// if the scenario is not stopped: stops the scenario and sets the value to false
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_stopTCGuardFn(in integer pl_idx, in EPTF_IntegerList pl_argList, in EPTF_Var_DirectContent pl_newContent) runs on EPTF_ExecCtrl_CT return boolean {
var integer vl_scIdx := pl_argList[0];
// var integer vl_scenarioStateVarIdx := pl_argList[2];
var integer vl_tcOfScIdx := pl_argList[1];
var integer vl_startTCVarIdx := pl_argList[2];
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[vl_scIdx].eGroupIdx;
var charstring eGrpName := v_ExecCtrl_entityGroups[vl_eGrpIdx].name;
var charstring scenName := v_ExecCtrl_scenarios[vl_scIdx].scData.name;
var charstring tcName := f_EPTF_LGenBase_tcNameOfTcOfSc(v_ExecCtrl_scenarios[vl_scIdx].scData,vl_tcOfScIdx)
if (pl_newContent.boolVal==true) {
// check if button is disabled:
if (f_EPTF_ExecCtrl_isDisabledStartStopTC(
{eGrpName, scenName, tcName}
)) {
f_EPTF_Var_refreshContent(pl_idx); // update the gui with the previous value
return false;
}
// // uncheck the other:
// f_EPTF_Var_adjustContent(vl_startTCVarIdx,{boolVal := false})
// stop TC:
f_EPTF_ExecCtrl_stopTCOnLGens(vl_scIdx,vl_tcOfScIdx);
return true;
}
return true;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_enableStartStopTC
//
// Purpose:
// Adds or enables start/stop TC button
//
// Parameters:
// - pl_tcIdName - *in* <EPTF_ExecCtrl_TCName> - entity group scenario and traffic case name
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_enableStartStopTC(in EPTF_ExecCtrl_TCName pl_tcIdName) runs on EPTF_ExecCtrl_CT {
var integer vl_idx := f_EPTF_ExecCtrl_getStartStopTCIdx(pl_tcIdName);
if (vl_idx!=-1) {
v_EPTF_ExecCtrl_StartStopTCDisable[vl_idx].disabled := false;
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_disableStartStopTC
//
// Purpose:
// Adds or disables start/stop TC button
//
// Parameters:
// - pl_tcIdName - *in* <EPTF_ExecCtrl_SCName> - entity group scenario and traffic case name
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_disableStartStopTC(in EPTF_ExecCtrl_TCName pl_tcIdName) runs on EPTF_ExecCtrl_CT {
var integer vl_idx := f_EPTF_ExecCtrl_getStartStopTCIdx(pl_tcIdName);
if (vl_idx!=-1) {
v_EPTF_ExecCtrl_StartStopTCDisable[vl_idx].disabled := true;
return;
}
// add new item
vl_idx := sizeof(v_EPTF_ExecCtrl_StartStopTCDisable);
v_EPTF_ExecCtrl_StartStopTCDisable[vl_idx].disabled := true;
v_EPTF_ExecCtrl_StartStopTCDisable[vl_idx].tcIdName := pl_tcIdName;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_isDisabledStartStopTC
//
// Purpose:
// Checks if start/stop TC button is disabled
//
// Parameters:
// - pl_tcIdName - *in* <EPTF_ExecCtrl_TCName> - entity group scenario and traffic case name
//
// Return Value:
// boolean - true if disabled, false if not (if not specified it is considered to be false (enabled))
//
// Errors & assertions:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_isDisabledStartStopTC(in EPTF_ExecCtrl_TCName pl_tcIdName) runs on EPTF_ExecCtrl_CT return boolean {
var integer vl_idx := f_EPTF_ExecCtrl_getStartStopTCIdx(pl_tcIdName);
if (vl_idx!=-1 and v_EPTF_ExecCtrl_StartStopTCDisable[vl_idx].disabled) {
return true;
}
return false;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_getStartStopTCIdx
//
// Purpose:
// Returns the idx of the start/stop TC button item
//
// Parameters:
// - pl_tcIdName - *in* <EPTF_ExecCtrl_TCName> - entity group scenario and traffic case name
//
// Return Value:
// integer - the index in v_EPTF_ExecCtrl_StartStopTCDisable of the enable data
//
// Errors & assertions:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_getStartStopTCIdx(in EPTF_ExecCtrl_TCName pl_tcIdName) runs on EPTF_ExecCtrl_CT return integer {
for(var integer i:=0, size := sizeof(v_EPTF_ExecCtrl_StartStopTCDisable); i<size;i:=i+1) {
if (v_EPTF_ExecCtrl_StartStopTCDisable[i].tcIdName == pl_tcIdName) {
return i;
}
}
return -1; // not found
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_startScenarioOnLGensByName
//
// Purpose:
// Start a scenario on ExecCtrlClient/LGen
//
// Parameters:
// - pl_eGrpName - *in charstring* - the entityGroup name
// - pl_scenName - *in charstring* - the scenarioName
//
// Return Value:
// -
//
// Errors & assertions:
//
// Detailed Comments:
// Avoid using this function! It uses hashMap to find the scenario index.
// Kept for backward compatibility.
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_startScenarioOnLGensByName(
in charstring pl_eGrpName,
in charstring pl_scenName)
runs on EPTF_ExecCtrl_CT {
var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioIdx(pl_eGrpName,pl_scenName);
if(vl_scIdx == -1){
f_EPTF_ExecCtrl_error(%definitionId&": Cannot find scenario "&pl_scenName&" of entity group "&pl_eGrpName&" in database.");
}
f_EPTF_ExecCtrl_startScenarioOnLGens(vl_scIdx);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_startScenarioOnLGens
//
// Purpose:
// Start a scenario on ExecCtrlClient/LGen
//
// Parameters:
// - pl_scIdx - *in integer* - the scenario index in <EPTF_ExecCtrl_ScenarioList>
//
// Return Value:
// -
//
// Errors & assertions:
// - the specified indexes should point to valid gropus and scenarios
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_startScenarioOnLGens(
in integer pl_scIdx)
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug(%definitionId&": start");
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[pl_scIdx].eGroupIdx;
var charstring vl_eGrpName := v_ExecCtrl_entityGroups[vl_eGrpIdx].name;
var charstring vl_scenName := v_ExecCtrl_scenarios[pl_scIdx].scData.name;
f_EPTF_ExecCtrl_resetGroupFinishDataForSc(pl_scIdx);
for (var integer lgenidx:=0, size := sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList);lgenidx<size;lgenidx:=lgenidx+1)
{
var integer vl_lgenIdx := v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].lgenIdx;
// if no entities are allocated on the LGen
if (v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].eCount == 0 ) {
continue; // nothing to do
}
if(c_EPTF_Common_debugSwitch) {
f_EPTF_ExecCtrl_debug(log2str("Sending start scenario to LGen (", v_ExecCtrl_lgens[vl_lgenIdx].lgenCompRef, ") ",
v_ExecCtrl_lgens[vl_lgenIdx].name, " for scenario (grp / scenName): ", vl_eGrpName, " / ", vl_scenName));
}
ExecCtrl_MgmtIf_CP.send(EPTF_ExecCtrl_StartScenario:{ eGrpName := vl_eGrpName, scenarioName := vl_scenName})
to f_EPTF_Base_downcast(v_ExecCtrl_lgens[vl_lgenIdx].lgenCompRef);
} // lgenidx
f_EPTF_ExecCtrl_debug(%definitionId&": finish");
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_stopScenarioOnLGensByName
//
// Purpose:
// Stops a scenario on ExecCtrlClient/LGen
//
// Parameters:
// - pl_eGrpName - *in charstring* - the entityGroup name
// - pl_scenName - *in charstring* - the scenarioName
//
// Return Value:
// -
//
// Errors & assertions:
// - the specified indexes should point to valid gropus and scenarios
//
// Detailed Comments:
// Avoid using this function! It uses hashMap to find the scenario index.
// Kept for backward compatibility.
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_stopScenarioOnLGensByName(
in charstring pl_eGrpName,
in charstring pl_scenName)
runs on EPTF_ExecCtrl_CT
{
var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioIdx(pl_eGrpName,pl_scenName);
if(vl_scIdx == -1){
f_EPTF_ExecCtrl_error(%definitionId&": Cannot find scenario "&pl_scenName&" of entity group "&pl_eGrpName&" in database.");
}
f_EPTF_ExecCtrl_stopScenarioOnLGens(vl_scIdx);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_stopScenarioOnLGens
//
// Purpose:
// Stops a scenario on ExecCtrlClient/LGen
//
// Parameters:
// - pl_scIdx - *in integer* - the scenario index in <EPTF_ExecCtrl_ScenarioList>
//
// Return Value:
// -
//
// Errors & assertions:
// - the specified indexes should point to valid gropus and scenarios
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_stopScenarioOnLGens(
in integer pl_scIdx)
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug(%definitionId&": start");
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[pl_scIdx].eGroupIdx;
var charstring vl_eGrpName := v_ExecCtrl_entityGroups[vl_eGrpIdx].name;
var charstring vl_scenName := v_ExecCtrl_scenarios[pl_scIdx].scData.name;
for (var integer lgenidx:=0, size := sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList);lgenidx<size;lgenidx:=lgenidx+1)
{
var integer vl_lgenIdx := v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].lgenIdx;
// if no entities are allocated on the LGen
if (v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].eCount == 0 ) {
continue; // nothing to do
}
ExecCtrl_MgmtIf_CP.send(EPTF_ExecCtrl_StopScenario:{eGrpName := vl_eGrpName,scenarioName := vl_scenName})
to f_EPTF_Base_downcast(v_ExecCtrl_lgens[vl_lgenIdx].lgenCompRef);
} // lgenidx
f_EPTF_ExecCtrl_debug(%definitionId&": finish");
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_resetScenarioOnLGens
//
// Purpose:
// Reset a scenario on ExecCtrlClient/LGen
//
// Parameters:
// - pl_scIdx - *in integer* - the scenario index in <EPTF_ExecCtrl_ScenarioList>
//
// Return Value:
// -
//
// Errors & assertions:
// - the specified indexes should point to valid gropus and scenarios
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_resetScenarioOnLGens(
in integer pl_scIdx)
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_resetScenarioOnLGens_private(pl_scIdx);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_stopScenarioGroupOnLGens
//
// Purpose:
// Stops a scenario group on ExecCtrlClient/LGen
//
// Parameters:
// - pl_scGrpIdx - *in integer* - the scenario group index
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_stopScenarioGroupOnLGens(in integer pl_scGrpIdx) runs on EPTF_ExecCtrl_CT {
f_EPTF_ExecCtrl_ScenarioGroup_stopExecution(pl_scGrpIdx);
for (var integer i:=0, size := sizeof(v_ExecCtrl_ScenarioGroupInstanceDB.data[pl_scGrpIdx].scenarios); i<size; i:=i+1) {
var integer vl_scIdx := v_ExecCtrl_ScenarioGroupInstanceDB.data[pl_scGrpIdx].scenarios[i].idx;
f_EPTF_ExecCtrl_stopScenarioOnLGens(vl_scIdx);
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_startTCOnLGens
//
// Purpose:
// Start a traffic case on ExecCtrlClient/LGen
//
// Parameters:
// - pl_scIdx - *in integer* - the scenario index in <EPTF_ExecCtrl_ScenarioList>
// - pl_tcOfScIdx - *in integer* - index of the traffic case in <EPTF_ExecCtrl_ScenarioList>[pl_scIdx].scData.tcList
//
// Return Value:
// -
//
// Errors & assertions:
// - the specified indexes should point to valid groups and scenarios
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_startTCOnLGens(
in integer pl_scIdx,
in integer pl_tcOfScIdx)
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug(%definitionId&": start");
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[pl_scIdx].eGroupIdx;
var charstring vl_eGrpName := v_ExecCtrl_entityGroups[vl_eGrpIdx].name;
var charstring vl_scenName := v_ExecCtrl_scenarios[pl_scIdx].scData.name;
var charstring vl_tcName := f_EPTF_LGenBase_tcNameOfTcOfSc(v_ExecCtrl_scenarios[pl_scIdx].scData,pl_tcOfScIdx)
f_EPTF_ExecCtrl_resetGroupFinishDataForTc(v_ExecCtrl_scenarios[pl_scIdx].tcIdxList[pl_tcOfScIdx]);
for (var integer lgenidx:=0, size := sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList);lgenidx<size;lgenidx:=lgenidx+1)
{
var integer vl_lgenIdx := v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].lgenIdx;
// if no entities are allocated on the LGen
if (v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].eCount == 0 ) {
continue; // nothing to do
}
if(c_EPTF_Common_debugSwitch) {
f_EPTF_ExecCtrl_debug(log2str("Sending start traffic case to LGen (", v_ExecCtrl_lgens[vl_lgenIdx].lgenCompRef, "): ",
v_ExecCtrl_lgens[vl_lgenIdx].name));
f_EPTF_ExecCtrl_debug(log2str("TC desc (grp / scenName / TcName): ", vl_eGrpName, " / ", vl_scenName, " / ", vl_tcName));
}
ExecCtrl_MgmtIf_CP.send(EPTF_ExecCtrl_StartTrafficCase:{ eGrpName := vl_eGrpName, scenName := vl_scenName, tcName := vl_tcName})
to f_EPTF_Base_downcast(v_ExecCtrl_lgens[vl_lgenIdx].lgenCompRef);
} // lgenidx
f_EPTF_ExecCtrl_debug(%definitionId&": finish");
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_stopTCOnLGens
//
// Purpose:
// Stop a traffic case on ExecCtrlClient/LGen
//
// Parameters:
// - pl_scIdx - *in integer* - the scenario index in <EPTF_ExecCtrl_ScenarioList>
// - pl_tcOfScIdx - *in integer* - index of the traffic case in <EPTF_ExecCtrl_ScenarioList>[pl_scIdx].scData.tcList
//
// Return Value:
// -
//
// Errors & assertions:
// - the specified indexes should point to valid groups and scenarios
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_stopTCOnLGens(
in integer pl_scIdx,
in integer pl_tcOfScIdx)
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug(%definitionId&": start");
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[pl_scIdx].eGroupIdx;
var charstring vl_eGrpName := v_ExecCtrl_entityGroups[vl_eGrpIdx].name;
var charstring vl_scenName := v_ExecCtrl_scenarios[pl_scIdx].scData.name;
var charstring vl_tcName := f_EPTF_LGenBase_tcNameOfTcOfSc(v_ExecCtrl_scenarios[pl_scIdx].scData,pl_tcOfScIdx)
for (var integer lgenidx:=0, size := sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList);lgenidx<size;lgenidx:=lgenidx+1)
{
var integer vl_lgenIdx := v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].lgenIdx;
// if no entities are allocated on the LGen
if (v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].eCount == 0 ) {
continue; // nothing to do
}
if(c_EPTF_Common_debugSwitch) {
f_EPTF_ExecCtrl_debug(log2str("Sending start traffic case to LGen (", v_ExecCtrl_lgens[vl_lgenIdx].lgenCompRef, "): ",
v_ExecCtrl_lgens[vl_lgenIdx].name));
f_EPTF_ExecCtrl_debug(log2str("TC desc (grp / scenName / TcName): ", vl_eGrpName, " / ", vl_scenName, " / ", vl_tcName));
}
ExecCtrl_MgmtIf_CP.send(EPTF_ExecCtrl_StopTrafficCase:{ eGrpName := vl_eGrpName, scenName := vl_scenName, tcName := vl_tcName})
to f_EPTF_Base_downcast(v_ExecCtrl_lgens[vl_lgenIdx].lgenCompRef);
} // lgenidx
f_EPTF_ExecCtrl_debug(%definitionId&": finish");
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_singleShotTc
//
// Purpose:
// Start a traffic case on ExecCtrlClient/LGen only for one entity (single shot)
//
// Parameters:
// - pl_tcIdx - *in integer* - the traffic case instance index in <EPTF_ExecCtrl_TrafficCaseList>
// - pl_eIdx - *in integer* - index of the entity in the entity group relative to the EGrp offset (-1 for auto selection, default)
// - pl_enableLog - *in boolean* - true if logging should be enabled for the singleShot (default: false)
//
// Return Value:
// -
//
// Errors & assertions:
// - the specified indexes should point to valid groups and traffic case
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_singleShotTc(
in integer pl_tcIdx,
in integer pl_eIdx := -1,
in boolean pl_enableLog := false)
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug(%definitionId&": start");
f_EPTF_Base_assert(%definitionId&": Invalid tc index "&int2str(pl_tcIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_trafficCases))&").",
pl_tcIdx >= 0 and pl_tcIdx < sizeof(v_ExecCtrl_trafficCases));
var integer vl_scIdx := v_ExecCtrl_trafficCases[pl_tcIdx].scenarioIdx;
var integer vl_tcOfScenarioIdx := v_ExecCtrl_trafficCases[pl_tcIdx].tcOfScenarioIdx
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[vl_scIdx].eGroupIdx;
var charstring vl_eGrpName := v_ExecCtrl_entityGroups[vl_eGrpIdx].name;
var charstring vl_scenName := v_ExecCtrl_scenarios[vl_scIdx].scData.name;
var charstring vl_tcName := f_EPTF_LGenBase_tcNameOfTcOfSc(v_ExecCtrl_scenarios[vl_scIdx].scData,vl_tcOfScenarioIdx);
var integer vl_eOffsetOfLGen;
// check if pl_eIdx is below the entity group size:
if(pl_eIdx!=-1 and pl_eIdx>=v_ExecCtrl_entityGroups[vl_eGrpIdx].eCount) {
f_EPTF_ExecCtrl_warning(log2str("Cannot start singleShot on entity group ",vl_eGrpName&" for scenario "&vl_scenName&" and traffic case "&vl_tcName,
": The entity index ",pl_eIdx, " is out of range. Should be in the range [0..", v_ExecCtrl_entityGroups[vl_eGrpIdx].eCount-1,"]"));
return;
}
// find the LGen that contains the entity:
var integer vl_selectedLGenIdx := -1; // invalid
for (var integer lgenidx:=0, size := sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList);lgenidx<size;lgenidx:=lgenidx+1)
{
var integer vl_lgenIdx := v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].lgenIdx;
// if no entities are allocated on the LGen
if (v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].eCount == 0 ) {
continue; // nothing to do
}
if (pl_eIdx==-1) {
vl_selectedLGenIdx := vl_lgenIdx;
vl_eOffsetOfLGen := v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].eOffset;
break; // automatically select the first available LGen
}
if (v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].eOffset>pl_eIdx and vl_selectedLGenIdx==-1) {
// cannot find the LGen
f_EPTF_ExecCtrl_debug(log2str("Cannot find the LGen (LGen offset is greater than ", pl_eIdx));
break; // this LGen is the first that is allocated above pl_eIdx => previous LGen is The One
}
// if LGen contains the entity:
if (v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].eOffset+v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].eCount>pl_eIdx) {
vl_selectedLGenIdx := vl_lgenIdx; // this LGen contains the entity
f_EPTF_ExecCtrl_debug(log2str("The LGen to start singleShot for the entity at ",pl_eIdx, " is: (", v_ExecCtrl_lgens[vl_selectedLGenIdx].lgenCompRef, "): ",
v_ExecCtrl_lgens[vl_selectedLGenIdx].name));
vl_eOffsetOfLGen := v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].eOffset;
break;
}
} // lgenidx
if (vl_selectedLGenIdx==-1) {
f_EPTF_ExecCtrl_warning(log2str("Cannot start singleShot on entity group ",vl_eGrpName&" for scenario "&vl_scenName&" and traffic case "&vl_tcName,
": Unable to find the LGen that contains the entity at index ",pl_eIdx));
return;
}
if(c_EPTF_Common_debugSwitch) {
f_EPTF_ExecCtrl_debug(log2str("Sending singleShot of traffic case to LGen (", v_ExecCtrl_lgens[vl_selectedLGenIdx].lgenCompRef, "): ",
v_ExecCtrl_lgens[vl_selectedLGenIdx].name));
f_EPTF_ExecCtrl_debug(log2str("TC desc (grp / scenName / TcName): ", vl_eGrpName, " / ", vl_scenName, " / ", vl_tcName));
}
var integer vl_eIdx := pl_eIdx;
if (pl_eIdx!=-1) {
vl_eIdx:=pl_eIdx-vl_eOffsetOfLGen; // remove the offset of the LGen: gives eIdx on LGen
}
ExecCtrl_MgmtIf_CP.send(EPTF_ExecCtrl_SingleShotTc:{
eGrpName := vl_eGrpName, scName := vl_scenName, tcName := vl_tcName,
eIdx := vl_eIdx,
enableLog := pl_enableLog
}) to f_EPTF_Base_downcast(v_ExecCtrl_lgens[vl_selectedLGenIdx].lgenCompRef);
f_EPTF_ExecCtrl_debug(%definitionId&": finish");
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_checkScenarioStatus
//
// Purpose:
// Check if the execution state of a specified scenario is consistent
// in all LGens
//
// Parameters:
// - pl_idName - *in* <EPTF_ExecCtrl_TCName> - the regulated item ID
// - pl_status - *in template charstring* - the desired state
//
// Return Value:
// *boolean* - true, if the execution state of a scenario matches the specifid state
//
// Errors & assertions:
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_checkScenarioStatus(in EPTF_ExecCtrl_SCName pl_idName, in template charstring pl_status) runs on EPTF_ExecCtrl_CT return boolean
{
f_EPTF_ExecCtrl_debug(%definitionId&": started");
var charstring vl_currentName := "ExecCtrl.scenarioStatus."&pl_idName.eGrpName&"."&pl_idName.scName;
var integer vl_idx := f_EPTF_Var_getId(vl_currentName);
if (vl_idx == -1) {
return false;
}
var EPTF_StatusLED vl_status := f_EPTF_Var_getStatusLEDValue(vl_idx);
var charstring vl_scenStatus := vl_status.text;
if (not match(vl_scenStatus, pl_status)) {
return false;
}
f_EPTF_ExecCtrl_debug(%definitionId&": finish");
return true;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_checkAllScenarios
//
// Purpose:
// Check all scenarios in ExecCtrl
//
// Parameters:
// Scenario status set as a charstring template
//
// Return Value:
// boolean - true if all statuses match the the set
//
// Errors & assertions:
// -
//
// Detailed Comments:
// Check all scenarios in ExecCtrl whether they are
// in a status set or not
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_checkAllScenarios(in template charstring pl_scenarioStatus) runs on EPTF_ExecCtrl_CT return boolean
{
var boolean vl_verdict := true;
for(var integer sc:=0, size := sizeof(v_ExecCtrl_scenarios); sc<size and vl_verdict==true; sc:=sc+1) {
f_EPTF_ExecCtrl_debug(%definitionId&": Checking scenario status");
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[sc].eGroupIdx;
var charstring eGrpName := v_ExecCtrl_entityGroups[vl_eGrpIdx].name;
var charstring scenName := v_ExecCtrl_scenarios[sc].scData.name;
if (f_EPTF_ExecCtrl_checkScenarioStatus({
eGrpName := eGrpName,
scName := scenName
},
pl_scenarioStatus))
{
f_EPTF_ExecCtrl_debug(log2str(
"Scenario: {", eGrpName,
", ", scenName,
" is in a status: ",pl_scenarioStatus));
}
else {
f_EPTF_ExecCtrl_debug(log2str(
"Scenario: {", eGrpName,
", ", scenName,
" is NOT in a status: ",pl_scenarioStatus));
vl_verdict := false;
}
}
return vl_verdict;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_scenarioEnabled
//
// Purpose:
// Checks if the scenario is enabled
//
// Parameters:
// pl_scIdx - *in integer* - scenario index
//
// Return Value:
// boolean
//
// Errors & assertions:
//
// Detailed Comments:
// For non-weighted scenarios it returned true always in R2.
//
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_scenarioEnabled(in integer pl_scIdx) runs on EPTF_ExecCtrl_CT return boolean {
// FIXME: shall non-weighted scenarios be always enabled? This is how it was in R2!
return v_ExecCtrl_scenarios[pl_scIdx].scData.enabled;
}
///////////////////////////////////////////////////////////
// Altstep: as_EPTF_ExecCtrl_MgmtIf_groupFinished
//
// Purpose:
// Receive groupFinished from ExecCtrlClient
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private altstep as_EPTF_ExecCtrl_MgmtIf_groupFinished() runs on EPTF_ExecCtrl_CT {
var EPTF_ExecCtrlClient_CT vl_sender;
var EPTF_ExecCtrlClient_GroupFinished v_msg;
[] ExecCtrl_MgmtIf_CP.receive(EPTF_ExecCtrlClient_GroupFinished:?) -> value v_msg sender vl_sender {
f_EPTF_ExecCtrl_debug("DEBUG: EPTF_ExecCtrlClient_GroupFinished received...");
// find lgenIdx for pl_LGenCompRef
var integer vl_lgenIdx := f_EPTF_ExecCtrl_getLGenIdx(int2str(f_EPTF_Base_upcast(vl_sender)));
f_EPTF_ExecCtrl_handleGroupFinished(vl_lgenIdx,v_msg.tcId,v_msg.condition,v_msg.thresholds);
repeat;
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_handleGroupFinished
//
// Purpose:
// Registers the groupFinish event received from the LGen, notifies all LGens if necessary
//
// Parameters:
// - pl_lgenIdx - *in integer* - LGen Idx in v_ExecCtrl_lgens
// - pl_tcIdx - *in integer* - the tc Idx
// - pl_condition - *in* <EPTF_LGenBase_ConditionTrue> - cause of group finish (true for those that are fired)
// - pl_currentCounters - *in* <EPTF_IntegerList> - the current value of the onGroupFinishCounters for the conditions fired
//
//
// Return Value:
// -
//
// Errors & assertions:
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_handleGroupFinished(
in integer pl_lgenIdx,
in EPTF_ExecCtrl_TCName pl_tcId,
in EPTF_LGenBase_ConditionTrue pl_condition,
in EPTF_IntegerList pl_currentCounters
) runs on EPTF_ExecCtrl_CT {
var integer vl_tcIdx := f_EPTF_ExecCtrl_getTrafficCaseIdx(pl_tcId.eGrpName,pl_tcId.scName,pl_tcId.tcName);
f_EPTF_Base_assert(%definitionId&": Invalid tc : "&pl_tcId.eGrpName&"."&pl_tcId.scName&"."&pl_tcId.tcName,-1 != vl_tcIdx);
// onGroupFinishCondition:
var EPTF_ExecCtrl_GrpFinishConditionTypes vl_grpFinishConditionTypes := f_EPTF_ExecCtrl_condition2GrpFinishConditionType(pl_condition);
for(var integer i:=0, size := sizeof(vl_grpFinishConditionTypes);i<size; i:=i+1) {
if (vl_grpFinishConditionTypes[i]==-1) {
continue;
}
f_EPTF_ExecCtrl_handlePauseTC(
pl_lgenIdx := pl_lgenIdx,
pl_tcId := pl_tcId,
pl_grpFinishConditionType := vl_grpFinishConditionTypes[i],
pl_currentCounters := pl_currentCounters
);
}
}
private function f_EPTF_ExecCtrl_checkGroupFinishForAllLGensGuard(
in EPTF_ScheduledAction pl_action,
in integer pl_eventIndex
) runs on EPTF_ExecCtrl_CT return boolean {
var integer vl_tcIdx := pl_action.actionId[0];
var integer vl_groupFinishConditionType := pl_action.actionId[1];
var integer vl_currentCounterSum;
if (f_EPTF_ExecCtrl_checkIfAllLGensArePaused(vl_tcIdx,vl_groupFinishConditionType,vl_currentCounterSum)) {
// if all LGens are paused (e.g. other group finish condition was detected on the running LGen, => all LGen became paused)
// simulate a pause for this condition and call the f_EPTF_ExecCtrl_handlePauseTC to "register" it
var integer vl_lgenIdx := 0; //simulate pause for the 0-th LGen
var integer vl_scIdx := v_ExecCtrl_trafficCases[vl_tcIdx].scenarioIdx;
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[vl_scIdx].eGroupIdx;
var integer vl_lgenIdxInEGrp := f_EPTF_ExecCtrl_getLGenIdxInEGrpForLGenAndEgrp(vl_lgenIdx,vl_eGrpIdx);
var EPTF_IntegerList vl_counters := {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
// use the current counters of the selected LGen:
if (isbound(v_ExecCtrl_trafficCases[vl_tcIdx].groupFinishData.onGroupFinish.conditionStatus[c_EPTF_ExecCtrl_groupFinishNofExecStartIdx][vl_lgenIdxInEGrp].currentCounter)) {
vl_counters[c_EPTF_ExecCtrl_groupFinishNofExecStartIdx ] := v_ExecCtrl_trafficCases[vl_tcIdx].groupFinishData.onGroupFinish.conditionStatus[c_EPTF_ExecCtrl_groupFinishNofExecStartIdx][vl_lgenIdxInEGrp].currentCounter;
}
if (isbound(v_ExecCtrl_trafficCases[vl_tcIdx].groupFinishData.onGroupFinish.conditionStatus[c_EPTF_ExecCtrl_groupFinishNofSuccessIdx][vl_lgenIdxInEGrp].currentCounter)) {
vl_counters[c_EPTF_ExecCtrl_groupFinishNofSuccessIdx] := v_ExecCtrl_trafficCases[vl_tcIdx].groupFinishData.onGroupFinish.conditionStatus[c_EPTF_ExecCtrl_groupFinishNofSuccessIdx][vl_lgenIdxInEGrp].currentCounter;
}
if (isbound(v_ExecCtrl_trafficCases[vl_tcIdx].groupFinishData.onGroupFinish.conditionStatus[c_EPTF_ExecCtrl_groupFinishNofFailIdx][vl_lgenIdxInEGrp].currentCounter)) {
vl_counters[c_EPTF_ExecCtrl_groupFinishNofFailIdx] := v_ExecCtrl_trafficCases[vl_tcIdx].groupFinishData.onGroupFinish.conditionStatus[c_EPTF_ExecCtrl_groupFinishNofFailIdx][vl_lgenIdxInEGrp].currentCounter;
}
if (isbound(v_ExecCtrl_trafficCases[vl_tcIdx].groupFinishData.onGroupFinish.conditionStatus[c_EPTF_ExecCtrl_groupFinishNofTimeoutIdx][vl_lgenIdxInEGrp].currentCounter)) {
vl_counters[c_EPTF_ExecCtrl_groupFinishNofTimeoutIdx] := v_ExecCtrl_trafficCases[vl_tcIdx].groupFinishData.onGroupFinish.conditionStatus[c_EPTF_ExecCtrl_groupFinishNofTimeoutIdx][vl_lgenIdxInEGrp].currentCounter;
}
if (isbound(v_ExecCtrl_trafficCases[vl_tcIdx].groupFinishData.onGroupFinish.conditionStatus[c_EPTF_ExecCtrl_groupFinishNofErrorIdx][vl_lgenIdxInEGrp].currentCounter)) {
vl_counters[c_EPTF_ExecCtrl_groupFinishNofErrorIdx] := v_ExecCtrl_trafficCases[vl_tcIdx].groupFinishData.onGroupFinish.conditionStatus[c_EPTF_ExecCtrl_groupFinishNofErrorIdx][vl_lgenIdxInEGrp].currentCounter;
}
if (isbound(v_ExecCtrl_trafficCases[vl_tcIdx].groupFinishData.onGroupFinish.conditionStatus[c_EPTF_ExecCtrl_groupFinish_RangeLoops][vl_lgenIdxInEGrp].currentCounter)) {
vl_counters[c_EPTF_ExecCtrl_groupFinish_RangeLoops] := v_ExecCtrl_trafficCases[vl_tcIdx].groupFinishData.onGroupFinish.conditionStatus[c_EPTF_ExecCtrl_groupFinish_RangeLoops][vl_lgenIdxInEGrp].currentCounter;
}
var integer vl_tcOfScIdx := v_ExecCtrl_trafficCases[vl_tcIdx].tcOfScenarioIdx;
var charstring vl_tcName := f_EPTF_LGenBase_tcNameOfTcOfSc(v_ExecCtrl_scenarios[vl_scIdx].scData,vl_tcOfScIdx)
var EPTF_ExecCtrl_TCName vl_tcId := {
v_ExecCtrl_entityGroups[vl_eGrpIdx].name,
v_ExecCtrl_scenarios[vl_scIdx].scData.name,
vl_tcName
}
f_EPTF_ExecCtrl_handlePauseTC(
pl_lgenIdx := vl_lgenIdx,
pl_tcId := vl_tcId,
pl_grpFinishConditionType := vl_groupFinishConditionType,
pl_currentCounters := vl_counters
);
} else {
// send pause to all LGens that did not finish to pause the traffic case
f_EPTF_ExecCtrl_sendPauseTCToAllClients(vl_tcIdx, vl_groupFinishConditionType);
}
// if all LGens are paused:
// request the current counters
// redistribute the remaining counters and calculate the updated condition counters
// send groupFinished==false to LGens to restart the traffic case
v_ExecCtrl_trafficCases[vl_tcIdx].groupFinishData.onGroupFinish.groupFinishedGuardTimerId[vl_groupFinishConditionType] := -1;
return true;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_sendGroupFinishedToAllClients
//
// Purpose:
// Sends groupFinished notification to all LGens
//
// Parameters:
// - pl_tcIdx - *in integer* - the tc Idx
// - pl_cause - *in* <EPTF_LGenBase_finishCallbackCause> - cause of group finish
// - local - *in boolean* - true if local, false if global evaluated group finish condition
//
// Return Value:
// -
//
// Errors & assertions:
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_sendGroupFinishedToAllClients(
in integer pl_tcIdx,
in EPTF_LGenBase_ConditionTrue pl_condition,
in EPTF_ExecCtrl_OnGroupFinish_LGenStatusList pl_newLimits := {}
) runs on EPTF_ExecCtrl_CT {
var integer vl_scIdx := v_ExecCtrl_trafficCases[pl_tcIdx].scenarioIdx;
var integer vl_tcOfScIdx := v_ExecCtrl_trafficCases[pl_tcIdx].tcOfScenarioIdx;
var charstring vl_tcName := f_EPTF_LGenBase_tcNameOfTcOfSc(v_ExecCtrl_scenarios[vl_scIdx].scData,vl_tcOfScIdx)
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[vl_scIdx].eGroupIdx;
for (var integer lgenidx:=0, size := sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList);lgenidx<size;lgenidx:=lgenidx+1) {
if (v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].eCount == 0) {
continue; // do not send packet to LGen if there is no entity on the LGen
}
var EPTF_ExecCtrl_TCName vl_tcId := {
v_ExecCtrl_entityGroups[vl_eGrpIdx].name,
v_ExecCtrl_scenarios[vl_scIdx].scData.name,
vl_tcName
}
var integer vl_lgenIdx := v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].lgenIdx;
var integer vl_newThreshold := -1;
if (sizeof(pl_newLimits)>0) {
vl_newThreshold := pl_newLimits[lgenidx].currentCounter;
f_EPTF_Base_assert("LGen Index does not match", pl_newLimits[lgenidx].lgenIdx == vl_lgenIdx);
}
var EPTF_IntegerList vl_newThresholds := {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
var EPTF_ExecCtrl_GrpFinishConditionTypes vl_conditionTypes := f_EPTF_ExecCtrl_condition2GrpFinishConditionType(pl_condition);
for(var integer i:=0;i<sizeof(vl_conditionTypes); i:=i+1) {
vl_newThresholds[vl_conditionTypes[i]] := vl_newThreshold;
}
if (pl_condition.anythingFinished
or vl_newThreshold != v_ExecCtrl_trafficCases[pl_tcIdx].groupFinishData.onGroupFinish.conditionStatusPrev[vl_conditionTypes[0]][lgenidx]) {
ExecCtrl_MgmtIf_CP.send(EPTF_ExecCtrlClient_GroupFinished : {vl_tcId,pl_condition, vl_newThresholds}) to f_EPTF_Base_downcast(v_ExecCtrl_lgens[vl_lgenIdx].lgenCompRef);
//reset groupFinish.conditionStatus for this LGen for all conditions when LGen resumes the traffic case execution (all conditions are updated)
if (pl_condition.anythingFinished) {
// add current condition (LGen remains paused):
f_EPTF_ExecCtrl_accumulateConditions(pl_condition, v_ExecCtrl_trafficCases[pl_tcIdx].groupFinishData.onGroupFinish.groupFinishedPerLGen[lgenidx]);
} else {
// clear current condition (condition is updated):
f_EPTF_ExecCtrl_clearGroupFinishConditionFired(pl_condition,v_ExecCtrl_trafficCases[pl_tcIdx].groupFinishData.onGroupFinish.groupFinishedPerLGen[lgenidx]);
}
if(not pl_condition.anythingFinished
and not f_EPTF_ExecCtrl_checkGroupFinishConditionFired(v_ExecCtrl_trafficCases[pl_tcIdx].groupFinishData.onGroupFinish.groupFinishedPerLGen[lgenidx])) {
// if no more condition remains and condition is not fulfilled (LGen resumes):
f_EPTF_ExecCtrl_deleteItem(v_ExecCtrl_trafficCases[pl_tcIdx].groupFinishData.onGroupFinish.conditionStatus[c_EPTF_ExecCtrl_groupFinishNofExecStartIdx],lgenidx);
f_EPTF_ExecCtrl_deleteItem(v_ExecCtrl_trafficCases[pl_tcIdx].groupFinishData.onGroupFinish.conditionStatus[c_EPTF_ExecCtrl_groupFinishNofSuccessIdx],lgenidx);
f_EPTF_ExecCtrl_deleteItem(v_ExecCtrl_trafficCases[pl_tcIdx].groupFinishData.onGroupFinish.conditionStatus[c_EPTF_ExecCtrl_groupFinishNofFailIdx],lgenidx);
f_EPTF_ExecCtrl_deleteItem(v_ExecCtrl_trafficCases[pl_tcIdx].groupFinishData.onGroupFinish.conditionStatus[c_EPTF_ExecCtrl_groupFinishNofTimeoutIdx],lgenidx);
f_EPTF_ExecCtrl_deleteItem(v_ExecCtrl_trafficCases[pl_tcIdx].groupFinishData.onGroupFinish.conditionStatus[c_EPTF_ExecCtrl_groupFinishNofErrorIdx],lgenidx);
f_EPTF_ExecCtrl_deleteItem(v_ExecCtrl_trafficCases[pl_tcIdx].groupFinishData.onGroupFinish.conditionStatus[c_EPTF_ExecCtrl_groupFinish_RangeLoops],lgenidx);
}
} else {
// threshold for this condition was not changed => LGen remains paused,
// leave the groupFinish.conditionStatus for this LGen for all conditions on the previous value
}
}
}
private function f_EPTF_ExecCtrl_deleteItem(inout EPTF_ExecCtrl_OnGroupFinish_LGenStatusList pl_lgenStatusList, in integer pl_lgenIdx) {
var EPTF_ExecCtrl_OnGroupFinish_LGenStatusList vl_lgenStatusList;
for (var integer i:=0; i<sizeof(pl_lgenStatusList); i:=i+1) {
if (i==pl_lgenIdx) {
continue;
}
if(isbound(pl_lgenStatusList[i])) {
vl_lgenStatusList[i] := pl_lgenStatusList[i];
}
}
if(isbound(vl_lgenStatusList)) {
pl_lgenStatusList := vl_lgenStatusList;
} else {
pl_lgenStatusList := {};
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_clearGroupFinishConditionFired
//
// Purpose:
// Clears the finish conditions given in the pl_source from pl_dest
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_clearGroupFinishConditionFired(
in EPTF_LGenBase_ConditionTrue pl_source,
inout EPTF_LGenBase_ConditionTrue pl_dest
) {
pl_dest.nrOfExecStart := pl_dest.nrOfExecStart and pl_dest.nrOfExecStart xor pl_source.nrOfExecStart;
pl_dest.nrOfSuccesses := pl_dest.nrOfSuccesses and pl_dest.nrOfSuccesses xor pl_source.nrOfSuccesses
pl_dest.nrOfFails := pl_dest.nrOfFails and pl_dest.nrOfFails xor pl_source.nrOfFails
pl_dest.nrOfErrors := pl_dest.nrOfErrors and pl_dest.nrOfErrors xor pl_source.nrOfErrors
pl_dest.nrOfTimeouts := pl_dest.nrOfTimeouts and pl_dest.nrOfTimeouts xor pl_source.nrOfTimeouts
pl_dest.nrOfRangeLoop := pl_dest.nrOfRangeLoop and pl_dest.nrOfRangeLoop xor pl_source.nrOfRangeLoop
pl_dest.execTime := pl_dest.execTime and pl_dest.execTime xor pl_source.execTime
pl_dest.entitiesFinished := pl_dest.entitiesFinished and pl_dest.entitiesFinished xor pl_source.entitiesFinished
pl_dest.availableEntitiesFinished := pl_source.availableEntitiesFinished and pl_source.availableEntitiesFinished xor pl_source.availableEntitiesFinished
pl_dest.customFinishCondition := pl_dest.customFinishCondition and pl_dest.customFinishCondition xor pl_source.customFinishCondition
pl_dest.anythingFinished := pl_dest.anythingFinished and pl_dest.anythingFinished xor pl_source.anythingFinished
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_checkGroupFinishConditionFired
//
// Purpose:
// Checks if any of the finish conditions given in the pl_source are true
// Ignores anythingFinished
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_checkGroupFinishConditionFired(
in EPTF_LGenBase_ConditionTrue pl_source
) return boolean {
return pl_source.nrOfExecStart
or pl_source.nrOfSuccesses
or pl_source.nrOfFails
or pl_source.nrOfErrors
or pl_source.nrOfTimeouts
or pl_source.nrOfRangeLoop
or pl_source.execTime
or pl_source.entitiesFinished
or pl_source.availableEntitiesFinished
or pl_source.customFinishCondition
//or pl_source.anythingFinished
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_accumulateConditions
//
// Purpose:
// Accumulates the finish conditions given in the pl_newConditionsDetected to pl_dest
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_accumulateConditions(
in EPTF_LGenBase_ConditionTrue pl_newConditionsDetected,
inout EPTF_LGenBase_ConditionTrue pl_dest
) {
if(not isbound(pl_dest)) {
pl_dest := pl_newConditionsDetected;
} else {
// accumulate the flags:
f_EPTF_ExecCtrl_setGroupFinishConditionFired(pl_newConditionsDetected,pl_dest);
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_setGroupFinishConditionFired
//
// Purpose:
// Registers the finish conditions fired
// (Copy of f_EPTF_LGenBase_setGroupFinishConditionFired)
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_setGroupFinishConditionFired(
in EPTF_LGenBase_ConditionTrue pl_source,
inout EPTF_LGenBase_ConditionTrue pl_dest)
{
pl_dest.nrOfExecStart := pl_dest.nrOfExecStart or pl_source.nrOfExecStart
pl_dest.nrOfSuccesses := pl_dest.nrOfSuccesses or pl_source.nrOfSuccesses
pl_dest.nrOfFails := pl_dest.nrOfFails or pl_source.nrOfFails
pl_dest.nrOfErrors := pl_dest.nrOfErrors or pl_source.nrOfErrors
pl_dest.nrOfTimeouts := pl_dest.nrOfTimeouts or pl_source.nrOfTimeouts
pl_dest.nrOfRangeLoop := pl_dest.nrOfRangeLoop or pl_source.nrOfRangeLoop
pl_dest.execTime := pl_dest.execTime or pl_source.execTime
pl_dest.entitiesFinished := pl_dest.entitiesFinished or pl_source.entitiesFinished
pl_dest.availableEntitiesFinished := pl_source.availableEntitiesFinished or pl_source.availableEntitiesFinished
pl_dest.customFinishCondition := pl_dest.customFinishCondition or pl_source.customFinishCondition
pl_dest.anythingFinished := pl_dest.anythingFinished or pl_source.anythingFinished
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_sendPauseTCToAllClients
//
// Purpose:
// Sends pause TC request to all LGens
//
// Parameters:
// - pl_tcIdx - *in integer* - the tc Idx
// - pl_groupFinishConditionType - *in* <EPTF_ExecCtrl_GrpFinishConditionType> - the type of the evaluated group finish condition
//
// Return Value:
// -
//
// Errors & assertions:
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_sendPauseTCToAllClients(
in integer pl_tcIdx,
in EPTF_ExecCtrl_GrpFinishConditionType pl_groupFinishConditionType
) runs on EPTF_ExecCtrl_CT {
var integer vl_scIdx := v_ExecCtrl_trafficCases[pl_tcIdx].scenarioIdx;
var integer vl_tcOfScIdx := v_ExecCtrl_trafficCases[pl_tcIdx].tcOfScenarioIdx;
var charstring vl_tcName := f_EPTF_LGenBase_tcNameOfTcOfSc(v_ExecCtrl_scenarios[vl_scIdx].scData,vl_tcOfScIdx)
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[vl_scIdx].eGroupIdx;
for (var integer lgenidx:=0, size := sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList);lgenidx<size;lgenidx:=lgenidx+1) {
if (v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].eCount == 0) {
continue; // do not send packet to LGen if there is no entity on the LGen
}
if (isbound(v_ExecCtrl_trafficCases[pl_tcIdx].groupFinishData.onGroupFinish.conditionStatus[pl_groupFinishConditionType][lgenidx])) {
continue; // already paused
}
var EPTF_ExecCtrl_TCName vl_tcId := {
v_ExecCtrl_entityGroups[vl_eGrpIdx].name,
v_ExecCtrl_scenarios[vl_scIdx].scData.name,
vl_tcName
}
var integer vl_lgenIdx := v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].lgenIdx;
ExecCtrl_MgmtIf_CP.send(EPTF_ExecCtrlClient_PauseTC : {vl_tcId,pl_groupFinishConditionType,{}}) to f_EPTF_Base_downcast(v_ExecCtrl_lgens[vl_lgenIdx].lgenCompRef);
// accumulate condition for LGen:
var EPTF_LGenBase_ConditionTrue vl_condition := f_EPTF_ExecCtrl_grpFinishConditionType2Condition(pl_groupFinishConditionType);
f_EPTF_ExecCtrl_accumulateConditions(vl_condition, v_ExecCtrl_trafficCases[pl_tcIdx].groupFinishData.onGroupFinish.groupFinishedPerLGen[lgenidx]);
}
}
///////////////////////////////////////////////////////////
// Altstep: as_EPTF_ExecCtrl_MgmtIf_pauseTC
//
// Purpose:
// Receive pauseTC from ExecCtrlClient
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private altstep as_EPTF_ExecCtrl_MgmtIf_pauseTC() runs on EPTF_ExecCtrl_CT {
var EPTF_ExecCtrlClient_CT vl_sender;
var EPTF_ExecCtrlClient_PauseTC v_msg;
[] ExecCtrl_MgmtIf_CP.receive(EPTF_ExecCtrlClient_PauseTC:?) -> value v_msg sender vl_sender {
f_EPTF_ExecCtrl_debug("DEBUG: EPTF_ExecCtrlClient_PauseTC received...");
// find lgenIdx for pl_LGenCompRef
var integer vl_lgenIdx := f_EPTF_ExecCtrl_getLGenIdx(int2str(f_EPTF_Base_upcast(vl_sender)));
f_EPTF_ExecCtrl_handlePauseTC(vl_lgenIdx,v_msg.tcId,v_msg.conditionType,v_msg.counters);
repeat;
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_handlePauseTC
//
// Purpose:
// Handles incoming PauseTC events from clients,
// redistributes the group finish threshold accoring to the current progress
//
// Parameters:
// - pl_lgenIdx - *in integer* - LGen Idx in v_ExecCtrl_lgens
// - pl_tcIdx - *in integer* - the tc Idx
// - pl_grpFinishConditionType - *in* <EPTF_ExecCtrl_GrpFinishConditionType> - the type of the evaluated group finish condition
// - pl_currentCounters - *in* <EPTF_IntegerList> - the counters of all group finish conditions
//
//
// Return Value:
// -
//
// Errors & assertions:
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_handlePauseTC(
in integer pl_lgenIdx,
in EPTF_ExecCtrl_TCName pl_tcId,
in EPTF_ExecCtrl_GrpFinishConditionType pl_grpFinishConditionType,
in EPTF_IntegerList pl_currentCounters
) runs on EPTF_ExecCtrl_CT {
var integer vl_tcIdx := f_EPTF_ExecCtrl_getTrafficCaseIdx(pl_tcId.eGrpName,pl_tcId.scName,pl_tcId.tcName);
f_EPTF_Base_assert(%definitionId&": Invalid tc : "&pl_tcId.eGrpName&"."&pl_tcId.scName&"."&pl_tcId.tcName,-1 != vl_tcIdx);
// find lgenIdxInEGrp for pl_lgenIdx
var integer vl_scIdx := v_ExecCtrl_trafficCases[vl_tcIdx].scenarioIdx;
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[vl_scIdx].eGroupIdx;
var integer vl_lgenIdxInEGrp := f_EPTF_ExecCtrl_getLGenIdxInEGrpForLGenAndEgrp(pl_lgenIdx,vl_eGrpIdx);
var EPTF_LGenBase_ConditionTrue vl_condition := f_EPTF_ExecCtrl_grpFinishConditionType2Condition(pl_grpFinishConditionType);
f_EPTF_ExecCtrl_accumulateConditions(vl_condition, v_ExecCtrl_trafficCases[vl_tcIdx].groupFinishData.onGroupFinish.groupFinishedPerLGen[vl_lgenIdxInEGrp]);
for(var integer i:=0; i<sizeof(pl_currentCounters); i:=i+1) {
if (pl_currentCounters[i]<0) {
continue;
}
// // backup previous data:
// if(isbound(v_ExecCtrl_trafficCases[vl_tcIdx].groupFinishData.onGroupFinish.conditionStatus[i][vl_lgenIdxInEGrp].currentCounter)) {
// v_ExecCtrl_trafficCases[vl_tcIdx].groupFinishData.onGroupFinish.conditionStatusPrev[i][vl_lgenIdxInEGrp] :=
// v_ExecCtrl_trafficCases[vl_tcIdx].groupFinishData.onGroupFinish.conditionStatus[i][vl_lgenIdxInEGrp].currentCounter;
// }
// use vl_lgenIdxInEGrp to update the counter value in v_ExecCtrl_trafficCases[vl_tcIdx].groupFinishData.onGroupFinish.conditionStatus[pl_grpFinishConditionType]
v_ExecCtrl_trafficCases[vl_tcIdx].groupFinishData.onGroupFinish.conditionStatus[i][vl_lgenIdxInEGrp].lgenIdx := pl_lgenIdx;
v_ExecCtrl_trafficCases[vl_tcIdx].groupFinishData.onGroupFinish.conditionStatus[i][vl_lgenIdxInEGrp].currentCounter := pl_currentCounters[i];
}
// if all LGens are paused:
var integer vl_currentCounterSum;
if (f_EPTF_ExecCtrl_checkIfAllLGensArePaused(vl_tcIdx,pl_grpFinishConditionType,vl_currentCounterSum)) {
var integer vl_threshold := f_EPTF_ExecCtrl_getThreshold(vl_tcIdx,pl_grpFinishConditionType);
var EPTF_ExecCtrl_OnGroupFinish_LGenStatusList vl_distributedThreshold := {};
if(vl_threshold>vl_currentCounterSum) {
// redistribute the remaining counters and calculate the updated condition counters
f_EPTF_ExecCtrl_recalculateConditionLimits(vl_tcIdx,pl_grpFinishConditionType,vl_currentCounterSum,vl_threshold,vl_distributedThreshold);
//vl_condition:=c_EPTF_LGenBase_emptyConditionTrue
vl_condition.anythingFinished:=c_EPTF_LGenBase_emptyConditionTrue.anythingFinished;
// send anythingFinished==false to LGens to restart the traffic case =>
// modify the group finish condition limits, condition shows which limit has to be modified
} else {
// group finished
//set final counter values (at group finish):
f_EPTF_ExecCtrl_recalculateConditionLimits(vl_tcIdx,pl_grpFinishConditionType,vl_currentCounterSum,vl_threshold,vl_distributedThreshold);
f_EPTF_ExecCtrl_setOnGroupFinished(vl_tcIdx,pl_grpFinishConditionType);
f_EPTF_ExecCtrl_callOnGroupFinishCallbackFns(vl_tcIdx,pl_grpFinishConditionType);
// cause.anythingFinished is true: group finish condition is fulfilled => send to all LGens to finish the traffic
}
f_EPTF_ExecCtrl_sendGroupFinishedToAllClients(vl_tcIdx,vl_condition,vl_distributedThreshold);
// cancel guard:
if (v_ExecCtrl_trafficCases[vl_tcIdx].groupFinishData.onGroupFinish.groupFinishedGuardTimerId[pl_grpFinishConditionType] != -1) {
f_EPTF_SchedulerComp_CancelEvent(v_ExecCtrl_trafficCases[vl_tcIdx].groupFinishData.onGroupFinish.groupFinishedGuardTimerId[pl_grpFinishConditionType]);
v_ExecCtrl_trafficCases[vl_tcIdx].groupFinishData.onGroupFinish.groupFinishedGuardTimerId[pl_grpFinishConditionType] := -1;
}
} else {
// start guard to check if any other LGen does not finish in time:
if (v_ExecCtrl_trafficCases[vl_tcIdx].groupFinishData.onGroupFinish.groupFinishedGuardTimerId[pl_grpFinishConditionType] == -1
and tsp_EPTF_ExecCtrl_GroupFinishedGuardTime > 0.0
) {
// start guard for these conditions:
// nrOfExecStart ,
// nrOfSuccesses ,
// nrOfFails ,
// nrOfErrors ,
// nrOfTimeouts
if (pl_grpFinishConditionType==c_EPTF_ExecCtrl_groupFinishNofExecStartIdx
or pl_grpFinishConditionType==c_EPTF_ExecCtrl_groupFinishNofSuccessIdx
or pl_grpFinishConditionType==c_EPTF_ExecCtrl_groupFinishNofFailIdx
or pl_grpFinishConditionType==c_EPTF_ExecCtrl_groupFinishNofTimeoutIdx
or pl_grpFinishConditionType==c_EPTF_ExecCtrl_groupFinishNofErrorIdx
//or pl_grpFinishConditionType==c_EPTF_ExecCtrl_groupFinish_RangeLoops // this is not needed because rangeLoops are not redistributed
) {
if(not f_EPTF_SchedulerComp_scheduleAction(
f_EPTF_Base_getRelTimeInSecs() + tsp_EPTF_ExecCtrl_GroupFinishedGuardTime,
refers(f_EPTF_ExecCtrl_checkGroupFinishForAllLGensGuard),
{vl_tcIdx,pl_grpFinishConditionType},
v_ExecCtrl_trafficCases[vl_tcIdx].groupFinishData.onGroupFinish.groupFinishedGuardTimerId[pl_grpFinishConditionType]
)) {
f_EPTF_ExecCtrl_error(%definitionId& ": Could not schedule group finish condition guard.");
}
}
// does not start guard for these (wait until they are finished on all LGens):
// nrOfRangeLoop ,
// execTime ,
// entitiesFinished ,
// availableEntitiesFinished ,
// customFinish
// condition types:
// c_EPTF_ExecCtrl_groupFinish_ExecTime,
// c_EPTF_ExecCtrl_groupFinish_RangeLoops,
// c_EPTF_ExecCtrl_groupFinish_EntitiesFinished,
// c_EPTF_ExecCtrl_groupFinish_AvailableEntitiesFinished,
// c_EPTF_ExecCtrl_groupFinish_Custom
}
}
// v_ExecCtrl_trafficCases[vl_tcIdx].groupFinishData.onGroupFinish.groupFinishedGuardTimerId[pl_grpFinishConditionType] := -1;
}
private function f_EPTF_ExecCtrl_checkIfAllLGensArePaused(
in integer pl_tcIdx,
in integer pl_grpFinishConditionType,
out integer pl_currentCounterSum
) runs on EPTF_ExecCtrl_CT return boolean {
pl_currentCounterSum := 0;
var integer vl_scIdx := v_ExecCtrl_trafficCases[pl_tcIdx].scenarioIdx;
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[vl_scIdx].eGroupIdx;
for(var integer i:=0; i<sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList); i:=i+1) {
// if no entities are allocated on the LGen
if (v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[i].eCount == 0 ) {
continue; // nothing to do
}
if (not isbound(v_ExecCtrl_trafficCases[pl_tcIdx].groupFinishData.onGroupFinish.conditionStatus[pl_grpFinishConditionType][i])) {
return false;
}
pl_currentCounterSum := pl_currentCounterSum + v_ExecCtrl_trafficCases[pl_tcIdx].groupFinishData.onGroupFinish.conditionStatus[pl_grpFinishConditionType][i].currentCounter;
}
return true;
}
private function f_EPTF_ExecCtrl_recalculateConditionLimits(
in integer pl_tcIdx,
in integer pl_grpFinishConditionType,
in integer pl_currentCounterSum,
in integer pl_threshold,
out EPTF_ExecCtrl_OnGroupFinish_LGenStatusList pl_distributedThreshold
) runs on EPTF_ExecCtrl_CT {
var integer vl_remainingCounter := pl_threshold - pl_currentCounterSum;
var integer vl_toDistribute := vl_remainingCounter;
pl_distributedThreshold := v_ExecCtrl_trafficCases[pl_tcIdx].groupFinishData.onGroupFinish.conditionStatus[pl_grpFinishConditionType];
// use delta between previous run and the current for better estimation
// sum up all the counter increments:
var integer vl_deltaCounterSum := 0;
var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioIdxForTc(pl_tcIdx);
var integer vl_eGrpIdx := f_EPTF_ExecCtrl_getScenarioEGroupIdx(vl_scIdx);
for(var integer i:=0; i<sizeof(pl_distributedThreshold);i:=i+1) {
var integer vl_prevCounter := 0;
if (isbound(v_ExecCtrl_trafficCases[pl_tcIdx].groupFinishData.onGroupFinish.conditionStatusPrev[pl_grpFinishConditionType][i])) {
vl_prevCounter := v_ExecCtrl_trafficCases[pl_tcIdx].groupFinishData.onGroupFinish.conditionStatusPrev[pl_grpFinishConditionType][i];
}
if (not isbound(pl_distributedThreshold[i])) {
pl_distributedThreshold[i].currentCounter := 0;
pl_distributedThreshold[i].lgenIdx := v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[i].lgenIdx;
}
vl_deltaCounterSum := vl_deltaCounterSum +
pl_distributedThreshold[i].currentCounter - vl_prevCounter;
}
// set remaining to the LGen at the random index between 0 and sizeof(pl_distributedThreshold):
var integer vl_remainingIdx := float2int(int2float(sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList))*rnd());
if (v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[vl_remainingIdx].eCountActive == 0) {
// if the chosen remaining LGen has no active entities: choose the first with active entities
vl_remainingIdx := 0;
}
for(var integer i:=0; i<sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList); i:=i+1) {
if (v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[i].eCountActive == 0) {
if (i==vl_remainingIdx) {
vl_remainingIdx := vl_remainingIdx + 1; // this remaining has no active entities => choose next one
}
v_ExecCtrl_trafficCases[pl_tcIdx].groupFinishData.onGroupFinish.conditionStatusPrev[pl_grpFinishConditionType][i] := 0;
pl_distributedThreshold[i].currentCounter := 0;
continue; // no active entities on this LGen
}
if (not isbound(pl_distributedThreshold[i])) {
pl_distributedThreshold[i].currentCounter := 0;
pl_distributedThreshold[i].lgenIdx := v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[i].lgenIdx;
}
if (i==vl_remainingIdx) {
continue; // skip this, it will receive the remaining after the cycle
}
var integer vl_limitIncrement
if (vl_deltaCounterSum==0) {
vl_limitIncrement := vl_remainingCounter/sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList);
} else {
var integer vl_prevCounter := 0;
if (isbound(v_ExecCtrl_trafficCases[pl_tcIdx].groupFinishData.onGroupFinish.conditionStatusPrev[pl_grpFinishConditionType][i])) {
vl_prevCounter := v_ExecCtrl_trafficCases[pl_tcIdx].groupFinishData.onGroupFinish.conditionStatusPrev[pl_grpFinishConditionType][i];
}
if (pl_distributedThreshold[i].currentCounter==0 and vl_toDistribute>1) {
vl_limitIncrement := 1; // give 1 to the LGen with 0 prev threshold, but activeEntities>0
} else {
vl_limitIncrement := (vl_remainingCounter*
(pl_distributedThreshold[i].currentCounter-vl_prevCounter)
)/vl_deltaCounterSum;
if (vl_limitIncrement==vl_remainingCounter and vl_limitIncrement>1) {
vl_limitIncrement := vl_limitIncrement - 1;
}
}
}
// backup previous values:
v_ExecCtrl_trafficCases[pl_tcIdx].groupFinishData.onGroupFinish.conditionStatusPrev[pl_grpFinishConditionType][i] := pl_distributedThreshold[i].currentCounter;
pl_distributedThreshold[i].currentCounter := pl_distributedThreshold[i].currentCounter + vl_limitIncrement;
vl_toDistribute := vl_toDistribute - vl_limitIncrement;
}
// backup previous values:
v_ExecCtrl_trafficCases[pl_tcIdx].groupFinishData.onGroupFinish.conditionStatusPrev[pl_grpFinishConditionType][vl_remainingIdx] := pl_distributedThreshold[vl_remainingIdx].currentCounter;
pl_distributedThreshold[vl_remainingIdx].currentCounter := pl_distributedThreshold[vl_remainingIdx].currentCounter + vl_toDistribute;
}
// returns the threshold value. (-1 if not available)
friend function f_EPTF_ExecCtrl_getThreshold(
in integer pl_tcIdx,
in EPTF_ExecCtrl_GrpFinishConditionType pl_conditionType
)
runs on EPTF_ExecCtrl_CT
return integer {
if (not v_ExecCtrl_initialized) {
return -1; // not available
}
var integer vl_scIdx := v_ExecCtrl_trafficCases[pl_tcIdx].scenarioIdx;
var integer vl_tcOfScidx := v_ExecCtrl_trafficCases[pl_tcIdx].tcOfScenarioIdx;
if (pl_conditionType==c_EPTF_ExecCtrl_groupFinishNofExecStartIdx) {
if (v_ExecCtrl_scenarios[vl_scIdx].scData.tcList[vl_tcOfScidx].trafficStartFinishConditionsAndActions.nrOfExecStart==omit
) {
return -1; // threshold not available
}
return v_ExecCtrl_scenarios[vl_scIdx].scData.tcList[vl_tcOfScidx].trafficStartFinishConditionsAndActions.nrOfExecStart.count;
}
if (pl_conditionType==c_EPTF_ExecCtrl_groupFinishNofSuccessIdx) {
if (v_ExecCtrl_scenarios[vl_scIdx].scData.tcList[vl_tcOfScidx].trafficStartFinishConditionsAndActions.nrOfSuccesses==omit
) {
return -1; // threshold not available
}
return v_ExecCtrl_scenarios[vl_scIdx].scData.tcList[vl_tcOfScidx].trafficStartFinishConditionsAndActions.nrOfSuccesses.count;
}
if (pl_conditionType==c_EPTF_ExecCtrl_groupFinishNofFailIdx) {
if (v_ExecCtrl_scenarios[vl_scIdx].scData.tcList[vl_tcOfScidx].trafficStartFinishConditionsAndActions.nrOfFails==omit
) {
return -1; // threshold not available
}
return v_ExecCtrl_scenarios[vl_scIdx].scData.tcList[vl_tcOfScidx].trafficStartFinishConditionsAndActions.nrOfFails.count;
}
if (pl_conditionType==c_EPTF_ExecCtrl_groupFinishNofTimeoutIdx) {
if (v_ExecCtrl_scenarios[vl_scIdx].scData.tcList[vl_tcOfScidx].trafficStartFinishConditionsAndActions.nrOfTimeouts==omit
) {
return -1; // threshold not available
}
return v_ExecCtrl_scenarios[vl_scIdx].scData.tcList[vl_tcOfScidx].trafficStartFinishConditionsAndActions.nrOfTimeouts.count;
}
if (pl_conditionType==c_EPTF_ExecCtrl_groupFinishNofErrorIdx) {
if (v_ExecCtrl_scenarios[vl_scIdx].scData.tcList[vl_tcOfScidx].trafficStartFinishConditionsAndActions.nrOfErrors==omit
) {
return -1; // threshold not available
}
return v_ExecCtrl_scenarios[vl_scIdx].scData.tcList[vl_tcOfScidx].trafficStartFinishConditionsAndActions.nrOfErrors.count;
}
if (pl_conditionType==c_EPTF_ExecCtrl_groupFinish_RangeLoops) {
if (v_ExecCtrl_scenarios[vl_scIdx].scData.tcList[vl_tcOfScidx].trafficStartFinishConditionsAndActions.nrOfRangeLoop==omit
) {
return -1; // threshold not available
}
// return v_ExecCtrl_scenarios[vl_scIdx].scData.tcList[vl_tcOfScidx].trafficStartFinishConditionsAndActions.nrOfRangeLoop.count;
// return the number of LGens * v_ExecCtrl_scenarios[vl_scIdx].scData.tcList[vl_tcOfScidx].trafficStartFinishConditionsAndActions.nrOfRangeLoop.count:
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[vl_scIdx].eGroupIdx;
return v_ExecCtrl_scenarios[vl_scIdx].scData.tcList[vl_tcOfScidx].trafficStartFinishConditionsAndActions.nrOfRangeLoop.count
* sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList);
}
// these are not split:
// nrOfRangeLoop ,
// execTime ,
// entitiesFinished ,
// availableEntitiesFinished ,
// customFinish ,
// anythingFinished
if (pl_conditionType==c_EPTF_ExecCtrl_groupFinish_ExecTime) {
if (v_ExecCtrl_scenarios[vl_scIdx].scData.tcList[vl_tcOfScidx].trafficStartFinishConditionsAndActions.execTime==omit
) {
return -1; // threshold not available
}
// return the number of LGens:
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[vl_scIdx].eGroupIdx;
return sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList);
}
if (pl_conditionType==c_EPTF_ExecCtrl_groupFinish_EntitiesFinished) {
if (v_ExecCtrl_scenarios[vl_scIdx].scData.tcList[vl_tcOfScidx].trafficStartFinishConditionsAndActions.entitiesFinished==omit
) {
return -1; // threshold not available
}
// return the number of LGens:
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[vl_scIdx].eGroupIdx;
return sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList);
}
if (pl_conditionType==c_EPTF_ExecCtrl_groupFinish_AvailableEntitiesFinished) {
if (v_ExecCtrl_scenarios[vl_scIdx].scData.tcList[vl_tcOfScidx].trafficStartFinishConditionsAndActions.availableEntitiesFinished==omit
) {
return -1; // threshold not available
}
// return the number of LGens:
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[vl_scIdx].eGroupIdx;
return sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList);
}
if (pl_conditionType==c_EPTF_ExecCtrl_groupFinish_Custom) {
if (v_ExecCtrl_scenarios[vl_scIdx].scData.tcList[vl_tcOfScidx].trafficStartFinishConditionsAndActions.customFinish==omit
) {
return -1; // threshold not available
}
// return the number of LGens:
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[vl_scIdx].eGroupIdx;
return sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList);
}
// unsupported condition:
return -1;
}
// returns the threshold value for float type contitions (e.g. execTime). (-1 if not available)
friend function f_EPTF_ExecCtrl_getThresholdFloat(
in integer pl_tcIdx,
in EPTF_ExecCtrl_GrpFinishConditionType pl_conditionType
)
runs on EPTF_ExecCtrl_CT
return float {
if (not v_ExecCtrl_initialized) {
return -1.0; // not available
}
var integer vl_scIdx := v_ExecCtrl_trafficCases[pl_tcIdx].scenarioIdx;
var integer vl_tcOfScidx := v_ExecCtrl_trafficCases[pl_tcIdx].tcOfScenarioIdx;
if (pl_conditionType==c_EPTF_ExecCtrl_groupFinish_ExecTime) {
if (v_ExecCtrl_scenarios[vl_scIdx].scData.tcList[vl_tcOfScidx].trafficStartFinishConditionsAndActions.execTime==omit
) {
return -1.0; // threshold not available
}
return v_ExecCtrl_scenarios[vl_scIdx].scData.tcList[vl_tcOfScidx].trafficStartFinishConditionsAndActions.execTime.time;
}
// unsupported condition:
return -1.0;
}
// returns the threshold value for boolean type contitions (entitiesFinished, availableEntitiesFinished). (-1 if not available)
friend function f_EPTF_ExecCtrl_getThresholdBoolean(
in integer pl_tcIdx,
in EPTF_ExecCtrl_GrpFinishConditionType pl_conditionType
)
runs on EPTF_ExecCtrl_CT
return boolean {
if (not v_ExecCtrl_initialized) {
return false; // not available
}
var integer vl_scIdx := v_ExecCtrl_trafficCases[pl_tcIdx].scenarioIdx;
var integer vl_tcOfScidx := v_ExecCtrl_trafficCases[pl_tcIdx].tcOfScenarioIdx;
if (pl_conditionType==c_EPTF_ExecCtrl_groupFinish_EntitiesFinished
or pl_conditionType==c_EPTF_ExecCtrl_groupFinish_AvailableEntitiesFinished) {
return (v_ExecCtrl_scenarios[vl_scIdx].scData.tcList[vl_tcOfScidx].trafficStartFinishConditionsAndActions.entitiesFinished!=omit)
or (v_ExecCtrl_scenarios[vl_scIdx].scData.tcList[vl_tcOfScidx].trafficStartFinishConditionsAndActions.availableEntitiesFinished!=omit);
}
// unsupported condition:
return false;
}
// OnGroupFinishCallBack function to update the GroupFinishStatusLED of the traffic case on the GUI
private function f_EPTF_ExecCtrl_setLEDForOnGroupFinishCallBack(
in integer pl_tcIdx,
in EPTF_ExecCtrl_GrpFinishConditionType pl_conditionType
) runs on EPTF_ExecCtrl_CT {
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioIdxForTc(pl_tcIdx);
var integer vl_tcOfScenarioIdx := f_EPTF_ExecCtrl_getTcOfScenarioIdx(pl_tcIdx);
var integer vl_eGrpIdx := f_EPTF_ExecCtrl_getScenarioEGroupIdx(vl_scIdx);
var charstring vl_eGrpName := f_EPTF_ExecCtrl_eGrp_name(vl_eGrpIdx);
var charstring vl_scTypeName := f_EPTF_ExecCtrl_getScenarioName(vl_scIdx);
var charstring vl_tcName := f_EPTF_ExecCtrl_tcNameOfTcOfSc(vl_scIdx,vl_tcOfScenarioIdx);
var charstring vl_namePrefix := c_EPTF_ExecCtrl_statisticsRoot&".EG."&vl_eGrpName&".SC."&vl_scTypeName&".TC."&vl_tcName;
// GroupFinishStatusLED
var integer vl_idx := f_EPTF_Var_getId(vl_namePrefix&".GroupFinishStatusLED");
if(vl_idx!=-1) {
f_EPTF_ExecCtrl_debug("Updating GroupFinishStatusLED for tc: "&f_EPTF_ExecCtrl_getTrafficCaseName(pl_tcIdx));
f_EPTF_Var_adjustContent(vl_idx,{statusLEDVal := f_EPTF_ExecCtrl_UIVars_getLEDForGroupFinish(pl_tcIdx,pl_conditionType)});
}
// GroupFinishCondStatusLED
var integer vl_tcStatId := f_EPTF_ExecCtrl_grpFinishConditionType2TcStatId(pl_conditionType);
if (pl_conditionType==c_EPTF_ExecCtrl_groupFinish_Custom) {
// do nothing with GroupFinishCondStatusLED-s
} else if (vl_tcStatId!=c_EPTF_ExecCtrl_tcStatId_Unknown) {
vl_idx := f_EPTF_Var_getId(vl_namePrefix&".GroupFinishCondStatusLED."&c_EPTF_ExecCtrl_tcStatNames[vl_tcStatId]);
if(vl_idx!=-1) {
f_EPTF_ExecCtrl_debug("Updating GroupFinishCondStatusLED for "&c_EPTF_ExecCtrl_tcStatNames[vl_tcStatId]&" for tc: "&f_EPTF_ExecCtrl_getTrafficCaseName(pl_tcIdx));
f_EPTF_Var_adjustContent(vl_idx,{statusLEDVal := f_EPTF_ExecCtrl_UIVars_getLEDForGroupFinishCond(pl_tcIdx,pl_conditionType)});
}
} else {
// reset GroupFinishCondStatusLED for all groupFinish conditions:
f_EPTF_ExecCtrl_debug("Updating GroupFinishCondStatusLED for all conditions in tc: "&f_EPTF_ExecCtrl_getTrafficCaseName(pl_tcIdx));
for(var integer st:=0; st<sizeof(c_EPTF_ExecCtrl_tcStatNames);st:=st+1) {
var EPTF_ExecCtrl_GrpFinishConditionType vl_grpFinishConditionType := f_EPTF_ExecCtrl_UIVars_tcStatId2GrpFinishConditionType(st);
if (vl_grpFinishConditionType == c_EPTF_ExecCtrl_groupFinishConditionUnknown) {
continue; // no conditions for these stats
}
vl_idx := f_EPTF_Var_getId(vl_namePrefix&".GroupFinishCondStatusLED."&c_EPTF_ExecCtrl_tcStatNames[st]);
if(vl_idx!=-1) {
var EPTF_StatusLED vl_currentLED := f_EPTF_Var_getStatusLEDValue(vl_idx);
if (vl_currentLED.color==led_blue or (vl_currentLED == c_EPTF_ExecCtrl_UIVars_GroupFinishCondStatusLED_init)) {
continue; // led is blue or condition is not monitored
}
f_EPTF_ExecCtrl_debug("Updating GroupFinishCondStatusLED for "&c_EPTF_ExecCtrl_tcStatNames[st]&" for tc: "&f_EPTF_ExecCtrl_getTrafficCaseName(pl_tcIdx));
f_EPTF_Var_adjustContent(vl_idx,{statusLEDVal := f_EPTF_ExecCtrl_UIVars_getLEDForGroupFinishCond(pl_tcIdx,vl_grpFinishConditionType)});
}
}
}
}
private function f_EPTF_ExecCtrl_grpFinishConditionType2TcStatId(
in EPTF_ExecCtrl_GrpFinishConditionType pl_grpFinishConditionType
) return EPTF_ExecCtrl_TcStatId {
if (pl_grpFinishConditionType==c_EPTF_ExecCtrl_groupFinishConditionUnknown) {
return c_EPTF_ExecCtrl_tcStatId_Unknown;
}
if (pl_grpFinishConditionType==c_EPTF_ExecCtrl_groupFinish_RangeLoops) {
return c_EPTF_ExecCtrl_tcStatId_RangeLoops;
}
if (pl_grpFinishConditionType==c_EPTF_ExecCtrl_groupFinish_EntitiesFinished
or pl_grpFinishConditionType==c_EPTF_ExecCtrl_groupFinish_AvailableEntitiesFinished) {
return c_EPTF_ExecCtrl_tcStatId_FinTraffic;
}
if (pl_grpFinishConditionType==c_EPTF_ExecCtrl_groupFinish_ExecTime) {
return c_EPTF_ExecCtrl_tcStatId_ExecTime;
}
if (pl_grpFinishConditionType==c_EPTF_ExecCtrl_groupFinish_Custom) {
return c_EPTF_ExecCtrl_tcStatId_Unknown; // no stat for custom
}
// the rest are in the same order: simply adding the offset of Starts works:
return pl_grpFinishConditionType + c_EPTF_ExecCtrl_tcStatId_Starts;
}
///////////////////////////////////////////////////////////
// Altstep: as_EPTF_ExecCtrl_MgmtIf
//
// Purpose:
// Management interface handler of EPTF_ExecCtrl feature
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
private altstep as_EPTF_ExecCtrl_MgmtIf() runs on EPTF_ExecCtrl_CT
{
// [] as_EPTF_ExecCtrl_MgmtIf_ExecStatus() { repeat;}
[] as_EPTF_ExecCtrl_MgmtIf_handleLoadConfig();
[] as_EPTF_ExecCtrl_MgmtIf_groupFinished();
[] as_EPTF_ExecCtrl_MgmtIf_pauseTC();
[] as_EPTF_ExecCtrl_MgmtIf_handleEntityResourceInfo();
[] as_EPTF_ExecCtrl_MgmtIf_handlePhaseMsgs();
[] as_EPTF_ExecCtrl_MgmtIf_handleReadytoRun();
[] as_EPTF_ExecCtrl_MgmtIf_handleCreateFSMStats();
[] as_EPTF_ExecCtrl_MgmtIf_handleByeMsgs();
[] as_EPTF_ExecCtrl_handleAllLGensCreated();
[] as_EPTF_ExecCtrl_handleEofTest();
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_behavior
//
// Purpose:
// Main behavior of EPTF_ExecCtrl feature
//
// Parameters:
// - pl_selfName - *in charstring* - the name of the component
// - pl_nrOfClients - *in integer* - the number of the connected EPTF_ExecCtrlClient components
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_behavior(
in charstring pl_selfName,
in integer pl_nrOfClients
) runs on EPTF_ExecCtrl_CT
{
// f_EPTF_ExecCtrl_debug(%definitionId&": start");
//f_EPTF_ExecCtrl_loadConfig(pl_EPTF_ExecCtrl_LGenFunction_Entry_List := p_fn_list);
f_EPTF_ExecCtrl_init_CT(pl_selfName, pl_nrOfClients);
f_EPTF_Base_wait4Shutdown(); // main alt-loop
// f_EPTF_ExecCtrl_debug(%definitionId&": finish");
}
} // group EPTF_ExecCtrl
///////////////////////////////////////////////////////////
// Group: R3
//
// Purpose:
// Functions introduced in the R3 release
//
///////////////////////////////////////////////////////////
group R3 {
///////////////////////////////////////////////////////////
// Type: EPTF_ExecCtrl_Condition_FN
//
// Purpose:
// General function that check a condition
//
// Parameters:
// -
//
// Return Value:
// boolean - True if condition is fulfilled, false otherwise
//
// Errors & assertions:
// -
//
// Detailed Comments:
// Used by <f_EPTF_ExecCtrl_waitForCondition>
//
///////////////////////////////////////////////////////////
type function EPTF_ExecCtrl_Condition_FN() runs on self return boolean;
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_waitForCondition
//
// Purpose:
// general function to wait for any condition (until the conditionFn returns true)
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
// Can be used in alt statements to wake up when the condition is true
// The user can block execution until a given event (=the event when the condition reported
// by the pl_condFn becomes true) by calling this function.
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_waitForCondition(in EPTF_ExecCtrl_Condition_FN pl_condFn) {
timer t_wait := 0.0;
t_wait.start;
alt {
[pl_condFn!=null and pl_condFn.apply()] t_wait.timeout;
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_checkReadyToRun
//
// Purpose:
// Returns true when ExecCtrl is readyToRun
//
// Parameters:
// -
//
// Return Value:
// boolean - true if the ReadyToRun event in ExecCtrl occurs
//
// Errors & assertions:
// -
//
// Detailed Comments:
// Can be used in alt statements to wake up when ExecCtrl is readyToRun
// Usage: If the user would like a callback to the event when all ExecCtrlClients reported
// ReadyToRun, this is what he should do:
// Write the following altstep:
// altstep as_My_ReadyToRunCallBack () runs on My_ExcCtrl_Extending_CT {
// [f_EPTF_ExecCtrl_checkReadyToRun()] t_my_ExecCtrl_ReadyToRun.timeout {
// // User handler functions to call:
// f_My_ReadyToRunCallBack_handler();
// }
// }
// Then in the init function of My_ExcCtrl_Extending_CT put this code:
// t_my_ExecCtrl_ReadyToRun.start(0.0); // this timer should be declared inside My_ExcCtrl_Extending_CT
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_checkReadyToRun()
runs on EPTF_ExecCtrl_CT
return boolean
{
return v_ExecCtrl_readyToRun;
}
group EntityGroupCreation {
private function f_EPTF_ExecCtrl_checkPendingMsgs()
runs on EPTF_ExecCtrl_CT
return boolean
{
// Since the f_EPTF_ExecCtrl_updateProgressbar sends a message to the uihandler => if uihandlerCT=execCtrlCT, it generates infinite loop
//f_EPTF_ExecCtrl_updateProgressbar(10.0/int2float((sizeof(v_ExecCtrl_lgens)+1)*(sizeof(v_ExecCtrl_scenarios)+sizeof(v_ExecCtrl_trafficCases)+1))); // random noise (max 10%)
return (v_ExecCtrl_pendingMsgCounter==0);
}
// returns the number of LGens the EGrp is distributed on (does not count LGens with eCount==0)
private function f_EPTF_ExecCtrl_getNofLGensForEGrp(in integer pl_eGrpIdx)
runs on EPTF_ExecCtrl_CT return integer {
var integer vl_lgenNum := 0;
for(var integer i:=0, size := sizeof(v_ExecCtrl_entityGroups[pl_eGrpIdx].lgenList); i<size; i:=i+1) {
if (v_ExecCtrl_entityGroups[pl_eGrpIdx].lgenList[i].eCount==0) {
continue; // eGrp is not created on the LGen
}
vl_lgenNum := vl_lgenNum + 1;
}
return vl_lgenNum;
}
private function f_EPTF_ExecCtrl_getCurrentLGenNumForEGrp(in integer pl_lgenIdx, in integer pl_eGrpIdx)
runs on EPTF_ExecCtrl_CT return integer {
var integer vl_currentLGenNum := -1; // first LGen will get 0
for(var integer i:=0, size := sizeof(v_ExecCtrl_entityGroups[pl_eGrpIdx].lgenList); i<size; i:=i+1) {
if (v_ExecCtrl_entityGroups[pl_eGrpIdx].lgenList[i].eCount==0) {
continue; // eGrp is not created on the LGen
}
vl_currentLGenNum := vl_currentLGenNum + 1;
var integer vl_lgenIdx := v_ExecCtrl_entityGroups[pl_eGrpIdx].lgenList[i].lgenIdx;
if (vl_lgenIdx==pl_lgenIdx) {
return vl_currentLGenNum;
}
}
return -1;
}
// creates the Entity Group on the LGens
private function f_EPTF_ExecCtrl_createEntityGroupOnLGens(in integer pl_eGrpIdx)
runs on EPTF_ExecCtrl_CT {
f_EPTF_Base_assert(%definitionId&": Invalid eGrp index "&int2str(pl_eGrpIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_entityGroups))&").",
pl_eGrpIdx >= 0 and pl_eGrpIdx < sizeof(v_ExecCtrl_entityGroups));
var EPTF_ExecCtrl_CreateEntityGrp vl_createEGrp;
v_ExecCtrl_pendingMsgCounter := 0;
var integer vl_totalLGenNum := f_EPTF_ExecCtrl_getNofLGensForEGrp(pl_eGrpIdx);
var integer vl_currentLGenNum := -1; // first LGen will get 0
for(var integer i:=0, size := sizeof(v_ExecCtrl_entityGroups[pl_eGrpIdx].lgenList); i<size; i:=i+1) {
if (v_ExecCtrl_entityGroups[pl_eGrpIdx].lgenList[i].eCount==0) {
continue; // eGrp is not created on the LGen
}
vl_currentLGenNum := vl_currentLGenNum + 1;
vl_createEGrp := {
name := v_ExecCtrl_entityGroups[pl_eGrpIdx].name,
eType := v_ExecCtrl_entityGroups[pl_eGrpIdx].eType,
gOffset := v_ExecCtrl_entityGroups[pl_eGrpIdx].eOffset,
gCount := v_ExecCtrl_entityGroups[pl_eGrpIdx].eCount,
eOffset := v_ExecCtrl_entityGroups[pl_eGrpIdx].eOffset+v_ExecCtrl_entityGroups[pl_eGrpIdx].lgenList[i].eOffset,
eCount := v_ExecCtrl_entityGroups[pl_eGrpIdx].lgenList[i].eCount,
trafficCorrigation := int2float(vl_currentLGenNum)/int2float(vl_totalLGenNum)
}
var integer vl_lgenIdx := v_ExecCtrl_entityGroups[pl_eGrpIdx].lgenList[i].lgenIdx;
ExecCtrl_MgmtIf_CP.send(EPTF_ExecCtrl_CreateEntityGrp:vl_createEGrp) to f_EPTF_Base_downcast(v_ExecCtrl_lgens[vl_lgenIdx].lgenCompRef);
v_ExecCtrl_pendingMsgCounter := v_ExecCtrl_pendingMsgCounter + 1;
}
if (v_ExecCtrl_pendingMsgCounter==0) {
f_EPTF_ExecCtrl_debug(log2str("Entity Group ",v_ExecCtrl_entityGroups[pl_eGrpIdx].name, " is not created on any LGen."));
return; // this return is not necessary but prevents the printout at the end
}
// wait until resource info is received from all LGens:
var EPTF_ExecCtrl_Condition_FN vl_checkPending := refers(f_EPTF_ExecCtrl_checkPendingMsgs);
f_EPTF_ExecCtrl_waitForCondition(vl_checkPending);
// timer t_wait := 1e-6;
// t_wait.start;
// alt {
// [v_ExecCtrl_pendingMsgCounter==0] t_wait.timeout;
// }
f_EPTF_ExecCtrl_debug(log2str("Entity Group ",v_ExecCtrl_entityGroups[pl_eGrpIdx].name, " is created on LGens."));
}
// creates all Entity Groups with the given eType on the LGen
// returns true if entity groups were created, false if not
private function f_EPTF_ExecCtrl_createEntityGroupsOnLGen(in integer pl_lgenIdx,in charstring pl_eType)
runs on EPTF_ExecCtrl_CT
return boolean {
f_EPTF_Base_assert(%definitionId&": Invalid LGen index "&int2str(pl_lgenIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_lgens))&").",
pl_lgenIdx >= 0 and pl_lgenIdx < sizeof(v_ExecCtrl_lgens));
var EPTF_ExecCtrl_CreateEntityGrpList vl_createEGrpList := {};
// go through all eGroups of this LGen:
for(var integer e:=0, size := sizeof(v_ExecCtrl_lgens[pl_lgenIdx].eGroups); e<size; e:=e+1) {
var integer vl_eGrpIdx := v_ExecCtrl_lgens[pl_lgenIdx].eGroups[e].eGrpIdx;
// Process only those groups that have the given eType:
if (v_ExecCtrl_entityGroups[vl_eGrpIdx].eType != pl_eType) {
continue;
}
// the Idx of the lgen entry in the eGroup for this LGen
var integer vl_lgenIdxInEGrp := v_ExecCtrl_lgens[pl_lgenIdx].eGroups[e].lgenIdxInEGrp;
if (v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[vl_lgenIdxInEGrp].eCount==0) {
continue; // eGrp is not created on the LGen
}
var integer vl_totalLGenNum := f_EPTF_ExecCtrl_getNofLGensForEGrp(vl_eGrpIdx);
var integer vl_currentLGenNum := f_EPTF_ExecCtrl_getCurrentLGenNumForEGrp(pl_lgenIdx,vl_eGrpIdx);
vl_createEGrpList[sizeof(vl_createEGrpList)] := {
name := v_ExecCtrl_entityGroups[vl_eGrpIdx].name,
eType := v_ExecCtrl_entityGroups[vl_eGrpIdx].eType,
gOffset := v_ExecCtrl_entityGroups[vl_eGrpIdx].eOffset,
gCount := v_ExecCtrl_entityGroups[vl_eGrpIdx].eCount,
eOffset := v_ExecCtrl_entityGroups[vl_eGrpIdx].eOffset+v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[vl_lgenIdxInEGrp].eOffset,
eCount := v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[vl_lgenIdxInEGrp].eCount,
trafficCorrigation := int2float(vl_currentLGenNum)/int2float(vl_totalLGenNum)
}
}
if (sizeof(vl_createEGrpList)>0) {
ExecCtrl_MgmtIf_CP.send(EPTF_ExecCtrl_CreateEntityGrpList:vl_createEGrpList) to f_EPTF_Base_downcast(v_ExecCtrl_lgens[pl_lgenIdx].lgenCompRef);
f_EPTF_ExecCtrl_debug(log2str("Entity Groups ",vl_createEGrpList, " are created on LGen ", v_ExecCtrl_lgens[pl_lgenIdx].name));
return true;
}
return false;
}
// allocates and creates all entity groups on all LGens
// All entity groups with same eType are processed together (one message per eType)
private function f_EPTF_ExecCtrl_configureEntityGroups() runs on EPTF_ExecCtrl_CT {
f_EPTF_ExecCtrl_debug(%definitionId&": started...");
var EPTF_CharstringList vl_eTypeList := f_EPTF_ExecCtrl_findETypes();
for(var integer et :=0, size := sizeof(vl_eTypeList); et<size; et := et+1) {
// find eGroups with current eType:
f_EPTF_ExecCtrl_debug(log2str("Processing EGroups with eType ",vl_eTypeList[et]));
var EPTF_IntegerList vl_eGrpIdxList := f_EPTF_ExecCtrl_findEGroups(vl_eTypeList[et]);
var integer vl_numEGrps := sizeof(vl_eGrpIdxList);
for(var integer i:=0; i<vl_numEGrps; i:=i+1) {
f_EPTF_ExecCtrl_allocateEntityGroup(vl_eGrpIdxList[i]);
}
f_EPTF_ExecCtrl_dumpInstanceDB();
// send create group to lgens and wait the response (=resource update)
if (vl_numEGrps==0) {
return; // nothing to do
}
// go through all LGens:
v_ExecCtrl_pendingMsgCounter := 0;
for(var integer i:=0, csize := sizeof(v_ExecCtrl_lgens); i<csize; i:=i+1) {
var integer vl_lgenIdx := i;
if (f_EPTF_ExecCtrl_createEntityGroupsOnLGen(vl_lgenIdx,vl_eTypeList[et])) {
v_ExecCtrl_pendingMsgCounter := v_ExecCtrl_pendingMsgCounter + 1;
}
}
if (v_ExecCtrl_pendingMsgCounter==0) {
f_EPTF_ExecCtrl_debug(log2str("No Entity Group with eType ", vl_eTypeList[et], " was created."));
continue; // this continue is not necessary
}
// wait until resource info is received from all LGens:
var EPTF_ExecCtrl_Condition_FN vl_checkPending := refers(f_EPTF_ExecCtrl_checkPendingMsgs);
f_EPTF_ExecCtrl_waitForCondition(vl_checkPending);
}
f_EPTF_ExecCtrl_debug(%definitionId&": finished");
}
// sends all clients a endOfConfig message and waits for readyToRun
private function f_EPTF_ExecCtrl_endOfConfig() runs on EPTF_ExecCtrl_CT {
v_ExecCtrl_pendingMsgCounter := 0;
for(var integer lgenIdx:=0, size := sizeof(v_ExecCtrl_lgens); lgenIdx<size; lgenIdx:=lgenIdx+1) {
if (v_ExecCtrl_lgens[lgenIdx].lgenCompRef==-1) {
continue; // do not send packet to LGen if LGen exited
}
ExecCtrl_MgmtIf_CP.send(EPTF_ExecCtrl_EndOfConfig:{v_ExecCtrl_dataSourceCompRef}) to f_EPTF_Base_downcast(v_ExecCtrl_lgens[lgenIdx].lgenCompRef);
v_ExecCtrl_pendingMsgCounter := v_ExecCtrl_pendingMsgCounter + 1;
}
// wait until response (ReadyToRun) is received from all LGens:
var EPTF_ExecCtrl_Condition_FN vl_checkPending := refers(f_EPTF_ExecCtrl_checkPendingMsgs);
f_EPTF_ExecCtrl_waitForCondition(vl_checkPending);
f_EPTF_ExecCtrl_createIteratorVars();
f_EPTF_ExecCtrl_setStatusEndOfConfig();
}
// this function is called when the readyToRun from all clients arrived
// also flips the v_ExecCtrl_readyToRun flag to true
private function f_EPTF_ExecCtrl_readyToRun() runs on EPTF_ExecCtrl_CT {
// create variables
f_EPTF_ExecCtrl_createScenarioVariables();
f_EPTF_ExecCtrl_createGUI_vars();
if(v_ExecCtrl_dataSourceCompRef != null){
f_EPTF_DataSourceClient_sendReady(c_ExecCtrl_DataSource_sourceId, f_EPTF_Base_selfName());
if (v_ExecCtrl_progressEnabled and v_ExecCtrl_progressBarUIHandler_Idx!=-1) {
f_EPTF_Var_adjustContent(v_ExecCtrl_progressBarUIHandler_Idx,{charstringVal := "ExecCtrl: Ready."});
}
}
f_EPTF_ExecCtrl_setStatusReadyToRun();
// flip readyToRun flag to true:
v_ExecCtrl_readyToRun := true;
// How to call readyToRun == true callbacks:
// This altstep will catch the readyToRun == true event instantly:
// alt{
// [f_EPTF_ExecCtrl_checkReadyToRun()] t_user_readyToRunTimer_startedWithZeroTime.timeout { f_userDefinedCallback(userArgs); }
// }
// This is how the ExecCtrlUIHandler will catch the readyToRun event too
}
private altstep as_EPTF_ExecCtrl_MgmtIf_handleReadytoRun() runs on EPTF_ExecCtrl_CT {
[] ExecCtrl_MgmtIf_CP.receive(EPTF_ExecCtrl_ReadyToRun:?) {
v_ExecCtrl_pendingMsgCounter := v_ExecCtrl_pendingMsgCounter - 1;
f_EPTF_ExecCtrl_updateProgressbar(100.0/int2float(sizeof(v_ExecCtrl_lgens))); // ReadyToRun 0-100%
repeat;
}
}
private altstep as_EPTF_ExecCtrl_MgmtIf_handleCreateFSMStats() runs on EPTF_ExecCtrl_CT {
var EPTF_ExecCtrl_CreateFSMStats vl_msg;
var EPTF_ExecCtrlClient_CT vl_client;
[not v_ExecCtrl_processingCreateFSMStats] ExecCtrl_MgmtIf_CP.receive(EPTF_ExecCtrl_CreateFSMStats:?) -> value vl_msg sender vl_client {
f_EPTF_ExecCtrl_handleCreateFSMStats(vl_msg, vl_client);
repeat;
}
}
// stores new FSMStats into database and calls FSMStatCreatedCallbacks
private function f_EPTF_ExecCtrl_handleCreateFSMStats(
in EPTF_ExecCtrl_CreateFSMStats pl_createFSMStats,
in EPTF_ExecCtrlClient_CT pl_client
) runs on EPTF_ExecCtrl_CT {
v_ExecCtrl_processingCreateFSMStats := true;
var EPTF_LGenBase_StatisticListOfTCList vl_statList := pl_createFSMStats;
var EPTF_LGenBase_StatisticListOfTCList vl_newStatList := {};
var charstring vl_statName,vl_shName;
var charstring vl_eGrpName,vl_scTypeName,vl_tcName;
var EPTF_StatHandler_StatMethod vl_statMethod;
var EPTF_Var_DirectContent vl_resetValue;
// for each stat
for(var integer i:=0; i<sizeof(vl_statList);i:=i+1) {
vl_eGrpName:=vl_statList[i].entityGroup;
vl_scTypeName:=vl_statList[i].scenario;
vl_tcName:=vl_statList[i].tc;
for(var integer st:=0; st<sizeof(vl_statList[i].stats);st:=st+1) {
vl_statName := vl_statList[i].stats[st].declaredName;
vl_shName := vl_statList[i].stats[st].statName;
vl_statMethod := vl_statList[i].stats[st].statMethod;
vl_resetValue := vl_statList[i].stats[st].statResetValue;
// declare stat:
var integer vl_tcIdx := f_EPTF_ExecCtrl_getTrafficCaseIdx(vl_eGrpName,vl_scTypeName,vl_tcName);
v_EPTF_ExecCtrl_statHandler_autoSelector := vl_tcIdx; // use the same statHandler for FSM stats and TC stats
if(not f_EPTF_ExecCtrl_StatHandlerClient_declareStat(
pl_statName := c_EPTF_ExecCtrl_statisticsRoot&".EG."&vl_eGrpName&".SC."&vl_scTypeName&".TC."&vl_tcName&".FSMStats."&vl_statName,
pl_statMethod := vl_statMethod,
pl_statResetValue := vl_resetValue
)) {/*cannot happen*/} else {
f_EPTF_ExecCtrl_debug(%definitionId&": f_EPTF_StatHandlerClient_declareStat: "&vl_statName);
};
var EPTF_Var_SubscriptionMode vl_subscriptionMode := sampledAtSync;
if (v_ExecCtrl_usePullModeForStats) {
vl_subscriptionMode := pull;
}
// register stat:
if(not f_EPTF_ExecCtrl_StatHandlerClient_registerAggregatedStat(
pl_sourceStatHandler := pl_client,
pl_sourceStatName := vl_shName,
pl_targetStatName := c_EPTF_ExecCtrl_statisticsRoot&".EG."&vl_eGrpName&".SC."&vl_scTypeName&".TC."&vl_tcName&".FSMStats."&vl_statName,
pl_subscriptionMode := vl_subscriptionMode,
pl_wait4response := true//tsp_EPTF_ExecCtrl_StatHandler_wait4response
)) {/*cannot happen*/};
}
// filter stats with no statList:
if (sizeof(vl_statList[i].stats)>0) {
vl_newStatList[sizeof(vl_newStatList)] := vl_statList[i];
}
}
f_EPTF_ExecCtrl_storeFSMStats(vl_newStatList);
v_ExecCtrl_processingCreateFSMStats := false;
}
// stores new FSMStats into database and calls FSMStatCreatedCallbacks
private function f_EPTF_ExecCtrl_storeFSMStats(
in EPTF_ExecCtrl_CreateFSMStats pl_createFSMStats
) runs on EPTF_ExecCtrl_CT {
var EPTF_ExecCtrl_CreateFSMStats vl_newFSMStats := {};
for(var integer st:=0, size := sizeof(pl_createFSMStats); st<size;st:=st+1) {
// check if it was not already added:
var boolean vl_found := false;
for(var integer i:=0, csize := sizeof(v_ExecCtrl_FSMStats); i<csize;i:=i+1) {
if (v_ExecCtrl_FSMStats[i]==pl_createFSMStats[st]) {
vl_found:= true;
break; // i-cycle
}
}
if(not vl_found) {
// add to database:
v_ExecCtrl_FSMStats[sizeof(v_ExecCtrl_FSMStats)] := pl_createFSMStats[st];
vl_newFSMStats[sizeof(vl_newFSMStats)] := pl_createFSMStats[st];
}
}
//call callbacks:
if (sizeof(vl_newFSMStats)>0) {
f_EPTF_ExecCtrl_callFSMStatsCreatedCallbacks(vl_newFSMStats);
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_registerFSMStatsCreatedCallback
//
// Purpose:
// registers callback function to call when FSM statistics are created
//
// Parameters:
// pl_fsmStatsCreatedFn - in <EPTF_ExecCtrl_FSMStatsCreatedCallbackFn> - the FSM stats created callback fn to register
//
// Return Value:
//
// Errors:
//
// Detailed Comments:
// Called when the FSM statistics are declared (somewhere after the EndOfConfig event)
// The GUIDone event might not have happened, i.e. the GUI is not certainly prepared
// when this function is called.
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_registerFSMStatsCreatedCallback(in EPTF_ExecCtrl_FSMStatsCreatedCallbackFn pl_fsmStatsCreatedFn)
runs on EPTF_ExecCtrl_CT {
v_EPTF_ExecCtrl_fsmStatsCreatedCallbackFns[sizeof(v_EPTF_ExecCtrl_fsmStatsCreatedCallbackFns)] := pl_fsmStatsCreatedFn;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_deregisterFSMStatsCreatedCallback
//
// Purpose:
// removes the callback function registered earlier by <f_EPTF_ExecCtrl_registerFSMStatsCreatedCallback>
//
// Parameters:
// pl_fsmStatsCreatedFn - in <EPTF_ExecCtrl_FSMStatsCreatedCallbackFn> - the FSM stats created callback fn to deregister
//
// Return Value:
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_deregisterFSMStatsCreatedCallback(in EPTF_ExecCtrl_FSMStatsCreatedCallbackFn pl_fsmStatsCreatedFn)
runs on EPTF_ExecCtrl_CT {
for(var integer i:=0, size := sizeof(v_EPTF_ExecCtrl_fsmStatsCreatedCallbackFns); i<size; i:=i+1) {
if(v_EPTF_ExecCtrl_fsmStatsCreatedCallbackFns[i]==pl_fsmStatsCreatedFn) {
v_EPTF_ExecCtrl_fsmStatsCreatedCallbackFns[i] := null;
}
}
}
private function f_EPTF_ExecCtrl_callFSMStatsCreatedCallbacks(
in EPTF_ExecCtrl_CreateFSMStats pl_createFSMStats
) runs on EPTF_ExecCtrl_CT {
f_EPTF_ExecCtrl_debug(log2str(%definitionId&": Calling callbacks for FSMStats: ",pl_createFSMStats));
for(var integer i:=0, size := sizeof(v_EPTF_ExecCtrl_fsmStatsCreatedCallbackFns); i<size; i:=i+1) {
if(v_EPTF_ExecCtrl_fsmStatsCreatedCallbackFns[i]!=null) {
f_EPTF_ExecCtrl_debug(log2str(%definitionId&": Calling FSMStatsCreated function: ",v_EPTF_ExecCtrl_fsmStatsCreatedCallbackFns[i]));
v_EPTF_ExecCtrl_fsmStatsCreatedCallbackFns[i].apply(pl_createFSMStats);
f_EPTF_ExecCtrl_debug(log2str(%definitionId&": FSMStatsCreated function finished: ",v_EPTF_ExecCtrl_fsmStatsCreatedCallbackFns[i]));
}
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_getFSMStatisticsOfTcs
//
// Purpose:
// returns the FSM statistics created for all TCs
//
// Parameters:
// pl_fsmStats - out <EPTF_LGenBase_StatisticListOfTCList> - the list of FSM statistics
//
// Return Value:
//
// Errors:
//
// Detailed Comments:
// This function is similar to the <f_EPTF_LGenBase_getStatisticsOfTcs> in LGenBase.
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_getFSMStatisticsOfTcs(out EPTF_LGenBase_StatisticListOfTCList pl_fsmStats) runs on EPTF_ExecCtrl_CT {
pl_fsmStats := v_ExecCtrl_FSMStats;
}
// configures the LGens
private function f_EPTF_ExecCtrl_configureLGens() runs on EPTF_ExecCtrl_CT {
f_EPTF_ExecCtrl_debug(%definitionId&": started...");
f_EPTF_ExecCtrl_updateProgressbar(0.0,"Deploying scenarios")
// Configure entity groups:
f_EPTF_ExecCtrl_configureEntityGroups(); // to process all eGroups with the same eType together
// declare phase lists:
f_EPTF_ExecCtrl_declarePhaseLists();
// declare traffic cases
f_EPTF_ExecCtrl_declareTrafficCases();
// declare scenarios
f_EPTF_ExecCtrl_declareScenarios();
//deploy scenario groups
f_EPTF_ExecCtrl_Phase_deployScenarioGroups();
f_EPTF_ExecCtrl_disableScenariosForPhaseGroups();
// notify LGens that the configuration is finished and wait for ready to start;
f_EPTF_ExecCtrl_endOfConfig();
v_ExecCtrl_cfgState := c_ExecCtrl_Cfg_CONFIGURED;
f_EPTF_ExecCtrl_debug(%definitionId&": finished");
}
// returns true if repeat needed
private function f_EPTF_ExecCtrl_handle_EntityResourceInfo(in EPTF_ExecCtrlClient_CT pl_client, in EPTF_ExecCtrl_EntityResourceInfo pl_msg)
runs on EPTF_ExecCtrl_CT {
f_EPTF_ExecCtrl_debug(log2str("EntityResourceInfo received from ",pl_client,": ", pl_msg));
var integer vl_lgenPoolIdxOfLGen;
if (not v_ExecCtrl_started or (not v_ExecCtrl_allLGensCreated and not f_EPTF_int2int_HashMap_Find(v_EPTF_ExecCtrl_lgenPoolCompRefHash, f_EPTF_Base_upcast(pl_client), vl_lgenPoolIdxOfLGen))) {
// buffer resource info message if ExecCtrl is not started or LGen is not added to pool database (yet)
v_EPTF_ExecCtrl_EntityResourceInfo_Buffer[sizeof(v_EPTF_ExecCtrl_EntityResourceInfo_Buffer)] := {
pl_client,
pl_msg
}
f_EPTF_ExecCtrl_debug(%definitionId&": EntityResourceInfo is buffered. Number of buffered messages: "&int2str(sizeof(v_EPTF_ExecCtrl_EntityResourceInfo_Buffer)));
return;
}
v_ExecCtrl_pendingMsgCounter := v_ExecCtrl_pendingMsgCounter - 1;
var integer vl_lgenIdx := f_EPTF_ExecCtrl_getLGenIdx(pl_msg.lgenName);
if (vl_lgenIdx==-1) {
var EPTF_ExecCtrl_LGenData lgenData := c_EPTF_ExecCtrl_LGenData_initialValue;
lgenData.name := pl_msg.lgenName;
lgenData.lgenCompRef := f_EPTF_Base_upcast(pl_client);
lgenData.resourceList := pl_msg.available;
vl_lgenIdx := f_EPTF_ExecCtrl_addLGenInstance(lgenData);
f_EPTF_ExecCtrl_addLGen2EntityGrps(vl_lgenIdx);
if (v_ExecCtrl_nrOfClients>0 and v_ExecCtrl_allLGensCreated) {
f_EPTF_ExecCtrl_updateProgressbar(100.0/int2float(v_ExecCtrl_nrOfClients)); // LGen progress: 0-100%
} else {
// this is reached if the creator function is a blocking function
var integer vl_nrOfExpectedClients := f_EPTF_ExecCtrl_getNrOfExpectedClients();
if(vl_nrOfExpectedClients > 0){
f_EPTF_ExecCtrl_updateProgressbar(100.0/int2float(vl_nrOfExpectedClients)); // LGen progress: approx // number of clients unknown: EntityResourceInfo received before creator function returned!
} else {
f_EPTF_ExecCtrl_updateProgressbar(1.0); // LGen progress: approx // number of clients unknown: EntityResourceInfo received before creator function returned!
}
}
} else {
f_EPTF_ExecCtrl_updateLGenResourceList(vl_lgenIdx,pl_msg.available);
f_EPTF_ExecCtrl_dumpInstanceDB();
return;
}
// debug:
f_EPTF_ExecCtrl_dumpInstanceDB();
return;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_getNrOfExpectedClients
//
// Purpose:
// Gets the number of Expected Clients set previously
// by f_EPTF_ExecCtrl_setNrOfExpectedClients()
//
// Parameters:
// -
//
// Return Value:
// pl_nrOfClient - in *integer* - number of expected clients
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_getNrOfExpectedClients()
runs on EPTF_ExecCtrl_CT
return integer{
return v_ExecCtrl_nrOfExpectedClients;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_setNrOfExpectedClients
//
// Purpose:
// Sets the number of Expected Clients - this number is used during
// displaying the progress of the initialisation of the ExecCtrl
// lgenpool section.
//
// Parameters:
// pl_nrOfClient - in *integer* - number of expected clients
//
// Return Value:
//
// Errors:
//
// Detailed Comments:
// Should be called after the f_EPTF_ExecCtrl_loadConfig() but
// before the f_EPTF_ExecCtrl_start() or the f_EPTF_ExecCtrl_LGenPool_createLGens(),
// if no parameter is given, else has no effect. If parameter is given, than only
// before part of the sentence is true.
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_setNrOfExpectedClients(in integer pl_nrOfClient := 0)
runs on EPTF_ExecCtrl_CT {
if(pl_nrOfClient > 0){
v_ExecCtrl_nrOfExpectedClients := pl_nrOfClient;
} else {
v_ExecCtrl_nrOfExpectedClients := 0;
//add the lgens from the lgenpools
for(var integer vl_lgenPoolIdx:=0, size := sizeof(v_EPTF_ExecCtrl_LGenPool_Declarators); vl_lgenPoolIdx<size;vl_lgenPoolIdx:=vl_lgenPoolIdx+1) {
for (var integer i:=0, isize := sizeof(v_EPTF_ExecCtrl_LGenPool_Declarators[vl_lgenPoolIdx].lgenPoolItems); i<isize; i:=i+1){
v_ExecCtrl_nrOfExpectedClients := v_ExecCtrl_nrOfExpectedClients + v_EPTF_ExecCtrl_LGenPool_Declarators[vl_lgenPoolIdx].lgenPoolItems[i].num;
}
}
//add the manual lgen clients
v_ExecCtrl_nrOfExpectedClients := v_ExecCtrl_nrOfExpectedClients + v_ExecCtrl_nrOfClients;
}
}
private function f_EPTF_ExecCtrl_loadBuffered_EntityResourceInfo() runs on EPTF_ExecCtrl_CT {
if (not v_ExecCtrl_started or not v_ExecCtrl_allLGensCreated) {
return;
}
for(var integer i:=0, size := sizeof(v_EPTF_ExecCtrl_EntityResourceInfo_Buffer); i<size; i:=i+1) {
f_EPTF_ExecCtrl_handle_EntityResourceInfo(
v_EPTF_ExecCtrl_EntityResourceInfo_Buffer[i].client,
v_EPTF_ExecCtrl_EntityResourceInfo_Buffer[i].msg
);
}
v_EPTF_ExecCtrl_EntityResourceInfo_Buffer := {};
}
private altstep as_EPTF_ExecCtrl_handleAllLGensCreated() runs on EPTF_ExecCtrl_CT {
[v_ExecCtrl_allLGensCreated and f_EPTF_ExecCtrl_numLGens() == v_ExecCtrl_nrOfClients] t_ExecCtrl_allLGensCreated.timeout {
// if initial resource info received for all LGens -> configure entity groups:
f_EPTF_ExecCtrl_debug(log2str("All ",v_ExecCtrl_nrOfClients," LGens are started."));
// All LGens have started up
f_EPTF_ExecCtrl_configureLGens();
// All LGens are configured
f_EPTF_ExecCtrl_readyToRun();
if(not v_ExecCtrl_manualControl) {
f_EPTF_ExecCtrl_startAllScenarios();
}
f_EPTF_ExecCtrl_debug("t_ExecCtrl_allLGensCreated.timeout handling finished");
repeat;
}
}
// increases the progressbar variable (range: 0-100) by pl_weight if 0 < pl_weight <=100,
// updates progressbar (slowly approaches 99) if -100 <= pl_weight < 0
// if pl_text is != "" the text is updated with pl_text and the progress is set to 0 if pl_weight==0,
// otherwise progressbar value is is increased with the new value calculated from pl_weight
friend function f_EPTF_ExecCtrl_updateProgressbar(in float pl_weight := 1.0, in charstring pl_text := "") runs on EPTF_ExecCtrl_CT {
var integer vl_idx := f_EPTF_Var_getId(c_EPTF_ExecCtrl_statisticsRoot&".notif.progressbar");
if (vl_idx<0) {
return;
}
var float vl_currentVal := str2float(f_EPTF_Var_getCharstringValue(vl_idx));
var float vl_newVal;
if (pl_weight<0.0 or vl_currentVal + pl_weight > 95.0) {
if (pl_weight<0.0) { pl_weight := - pl_weight; }
vl_newVal := vl_currentVal + pl_weight*(100.0-vl_currentVal)*vl_currentVal/1000000.0;
} else {
vl_newVal := vl_currentVal + pl_weight
}
// round it:
vl_newVal := int2float(float2int(100.0*vl_newVal))/100.0;
// if (vl_newVal>100.0) {
// vl_newVal := 100.0
// }
f_EPTF_ExecCtrl_updateGlobalProgressbar(vl_newVal-vl_currentVal);
// update text:
var integer vl_idxText := f_EPTF_Var_getId(c_EPTF_ExecCtrl_statisticsRoot&".notif.progressbar.text");
if (vl_idxText>=0) {
if (pl_text != "") {
f_EPTF_ExecCtrl_updateGlobalProgressbar(100.0-vl_newVal);
if (pl_text == "Done") {
vl_newVal := 100.0;
f_EPTF_ExecCtrl_updateGlobalProgressbar(-100.0);
} else if (pl_weight==0.0) { // reset progressbar value
vl_newVal := 0.0;
//set the previous one to 100%
f_EPTF_Var_adjustContent(vl_idx,{charstringVal := "100.0"});
}
f_EPTF_Var_adjustContent(vl_idxText,{charstringVal := pl_text});
} else if (v_ExecCtrl_nrOfClients>sizeof(v_ExecCtrl_lgens)) {
f_EPTF_Var_adjustContent(vl_idxText,{charstringVal := "Waiting for LGens to start up: "&int2str(v_ExecCtrl_nrOfClients-sizeof(v_ExecCtrl_lgens))});
} /*else if (vl_newVal<=20.0) {
f_EPTF_Var_adjustContent(vl_idxText,{charstringVal := "All LGens are up."});
} else if (vl_newVal>20.0 and vl_currentVal<=30.0) {
f_EPTF_Var_adjustContent(vl_idxText,{charstringVal := "Deploying entity groups"});
} else if (vl_newVal>58.0 and vl_currentVal<=58.0) {
f_EPTF_Var_adjustContent(vl_idxText,{charstringVal := "Declaring traffic cases"});
} else if (vl_newVal>75.0 and vl_currentVal<=75.0) {
f_EPTF_Var_adjustContent(vl_idxText,{charstringVal := "Distributing scenarios"});
} else if (vl_newVal>90.0 and vl_currentVal<=90.0) {
f_EPTF_Var_adjustContent(vl_idxText,{charstringVal := "Finalizing configuration"});
}*/
}
if(str2float(substr(float2str(vl_newVal),0,5))>str2float(substr(float2str(vl_currentVal),0,5)) or (pl_text != "" and pl_weight==0.0) ){
f_EPTF_Var_adjustContent(vl_idx,{charstringVal := substr(float2str(vl_newVal),0,5)});
}
}
friend function f_EPTF_ExecCtrl_updateGlobalProgressbar(in float pl_weight := 1.0) runs on EPTF_ExecCtrl_CT {
//"Creating LGen pools"
//"Deploying scenarios"
//"Creating Entity Groups panel variables"
//"Creating Client Resources panel variables"
//"Creating Traffic Cases panel variables"
//"Creating Regulator panel variables"
//"Creating Phase Lists variables"
const float cl_numOfProgressPhases := 7.0; //see above
var integer vl_idx := f_EPTF_Var_getId(c_EPTF_ExecCtrl_statisticsRoot&".notif.globalProgressbar");
if (vl_idx<0) {
return;
}
var float vl_currentVal := str2float(f_EPTF_Var_getCharstringValue(vl_idx));
var float vl_newVal;
if (pl_weight == -100.0) {
vl_newVal := 100.0;
} else {
pl_weight := pl_weight / cl_numOfProgressPhases;
vl_newVal := vl_currentVal + pl_weight
}
// round it:
vl_newVal := int2float(float2int(100.0*vl_newVal))/100.0;
f_EPTF_Var_adjustContent(vl_idx,{charstringVal := substr(float2str(vl_newVal),0,5)});
}
private altstep as_EPTF_ExecCtrl_MgmtIf_handleEntityResourceInfo() runs on EPTF_ExecCtrl_CT {
var EPTF_ExecCtrl_EntityResourceInfo vl_msg;
var EPTF_ExecCtrlClient_CT vl_client;
//[v_ExecCtrl_allLGensCreated]
[] ExecCtrl_MgmtIf_CP.receive(EPTF_ExecCtrl_EntityResourceInfo:?) -> value vl_msg sender vl_client {
f_EPTF_ExecCtrl_handle_EntityResourceInfo(vl_client, vl_msg);
repeat;
}
}
} // group EntityGroupCreation
// declares phase lists on LGens:
private function f_EPTF_ExecCtrl_declarePhaseLists() runs on EPTF_ExecCtrl_CT {
f_EPTF_ExecCtrl_debug(%definitionId&": started...");
f_EPTF_ExecCtrl_debug(log2str("The declared PhaseLists: ", v_EPTF_ExecCtrl_PhaseList_Declarators));
// go through all LGens
for(var integer lgenIdx:=0, size := sizeof(v_ExecCtrl_lgens); lgenIdx<size; lgenIdx:=lgenIdx+1) {
if (v_ExecCtrl_lgens[lgenIdx].lgenCompRef==-1) {
continue; // do not send packet to LGen if it already exited
}
// create the message for the LGen
var EPTF_ExecCtrl_DeclarePhaseLists vl_declarePhaseLists := v_EPTF_ExecCtrl_PhaseList_Declarators;
//send the message to the LGen
ExecCtrl_MgmtIf_CP.send(EPTF_ExecCtrl_DeclarePhaseLists:v_EPTF_ExecCtrl_PhaseList_Declarators) to f_EPTF_Base_downcast(v_ExecCtrl_lgens[lgenIdx].lgenCompRef);
// no response is sent from client
}
f_EPTF_ExecCtrl_debug(%definitionId&": finished");
}
// declares traffic cases on LGens
private function f_EPTF_ExecCtrl_declareTrafficCases() runs on EPTF_ExecCtrl_CT {
f_EPTF_ExecCtrl_debug(%definitionId&": started...");
f_EPTF_ExecCtrl_debug(log2str("The declared TC Types: ", v_ExecCtrl_tcTypes));
// go through all LGens
for(var integer lgenIdx:=0, size := sizeof(v_ExecCtrl_lgens); lgenIdx<size; lgenIdx:=lgenIdx+1) {
if (v_ExecCtrl_lgens[lgenIdx].lgenCompRef==-1) {
continue; // do not send packet to LGen if it already exited
}
// create the message for the LGen
var EPTF_ExecCtrl_DeclareTcs vl_declareTCs := {};
// Find the entity types that are used on the LGen
var EPTF_CharstringList vl_eTypesUsed := f_EPTF_ExecCtrl_getUsedETypesForLGen(lgenIdx);
f_EPTF_ExecCtrl_debug(log2str("Entity Types used on LGen ", v_ExecCtrl_lgens[lgenIdx].name, " are: ", vl_eTypesUsed));
//Find the traffic cases for these eType-s
for(var integer e:=0, esize := sizeof(vl_eTypesUsed); e<esize; e:=e+1) {
var EPTF_IntegerList vl_tcTypeIdxList := f_EPTF_ExecCtrl_getTcTypeIdxsForEType(vl_eTypesUsed[e]);
f_EPTF_ExecCtrl_debug(log2str("TC Types that use the eType ",vl_eTypesUsed[e], " are: ", vl_tcTypeIdxList));
for(var integer tc:=0, tsize := sizeof(vl_tcTypeIdxList); tc<tsize; tc:=tc+1) {
vl_declareTCs[sizeof(vl_declareTCs)] := v_ExecCtrl_tcTypes[vl_tcTypeIdxList[tc]];
}
}
//send the message to the LGen
ExecCtrl_MgmtIf_CP.send(EPTF_ExecCtrl_DeclareTcs:vl_declareTCs) to f_EPTF_Base_downcast(v_ExecCtrl_lgens[lgenIdx].lgenCompRef);
// no response is sent from client
}
f_EPTF_ExecCtrl_debug(%definitionId&": finished");
}
// declares scenarios on LGens
private function f_EPTF_ExecCtrl_declareScenarios() runs on EPTF_ExecCtrl_CT {
f_EPTF_ExecCtrl_debug(%definitionId&": start");
// A) go through all scenarios and declare them on LGens
var EPTF_ExecCtrl_ScenarioTypeLists vl_scenarioTypeLists := {}; // [scIdx][lgenidx]
for(var integer scIdx:=0, size := sizeof(v_ExecCtrl_scenarios);scIdx<size;scIdx:=scIdx+1) {
vl_scenarioTypeLists[scIdx] := f_EPTF_ExecCtrl_distributeScenarioOnLGens(scIdx);
}
// B) go through all LGens and send scenarios to them
// go through all LGens:
for(var integer lgenIdx:=0, size := sizeof(v_ExecCtrl_lgens); lgenIdx<size; lgenIdx:=lgenIdx+1) {
if (v_ExecCtrl_lgens[lgenIdx].lgenCompRef==-1) {
continue; // do not send packet to LGen if it already exited
}
// create the message for the LGen
var EPTF_LGenBase_ScenarioTypeInternalDeclaratorList vl_declareScs := {}; // [sc]
var EPTF_ExecCtrl_NamesInScenarioList vl_scNameLists := {}; // [sc][tcOfScIdx]
// go through the eGrp-s:
for(var integer e:=0, gsize := sizeof(v_ExecCtrl_lgens[lgenIdx].eGroups); e<gsize; e:=e+1) {
// if eGrp is not allocated: continue
var integer vl_eGrpIdx := v_ExecCtrl_lgens[lgenIdx].eGroups[e].eGrpIdx;
var integer vl_lgenIdxInEGrp := v_ExecCtrl_lgens[lgenIdx].eGroups[e].lgenIdxInEGrp;
if(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[vl_lgenIdxInEGrp].eCount==0) {
continue;
}
// go through the scenarios of this eGrp:
for(var integer s:=0, ssize := sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].scenarios); s<ssize;s:=s+1) {
var integer vl_scIdx := v_ExecCtrl_entityGroups[vl_eGrpIdx].scenarios[s];
// distribute scenario into the LGen
var integer sc := sizeof(vl_declareScs);
f_EPTF_ExecCtrl_convertScenarioInstance2Declarator(vl_scenarioTypeLists[vl_scIdx][vl_lgenIdxInEGrp],vl_declareScs[sc]);
// set the TCNames:
vl_scNameLists[sc] := {
v_ExecCtrl_entityGroups[vl_eGrpIdx].name,
v_ExecCtrl_scenarios[vl_scIdx].scData.name,
{}
}
for(var integer tcOfScIdx:=0, tsize := sizeof(v_ExecCtrl_scenarios[vl_scIdx].scData.tcList); tcOfScIdx<tsize;tcOfScIdx:=tcOfScIdx+1) {
var charstring vl_tcName := f_EPTF_LGenBase_tcNameOfTcOfSc(v_ExecCtrl_scenarios[vl_scIdx].scData,tcOfScIdx)
vl_scNameLists[sc].tcNames[tcOfScIdx] := vl_tcName;
}
}
}
f_EPTF_ExecCtrl_debug(log2str("Outgoing packet to LGen ",v_ExecCtrl_lgens[lgenIdx].name,": ", vl_declareScs, " TcNames: ", vl_scNameLists));
//send the message to the LGen
ExecCtrl_MgmtIf_CP.send(EPTF_ExecCtrl_CreateScenario:{vl_declareScs,vl_scNameLists}) to f_EPTF_Base_downcast(v_ExecCtrl_lgens[lgenIdx].lgenCompRef);
}
f_EPTF_ExecCtrl_debug(%definitionId&": finish");
}
private function f_EPTF_ExecCtrl_convertScenarioInstance2Declarator(in EPTF_ExecCtrl_ScenarioType pl_scInstance, out EPTF_LGenBase_ScenarioTypeInternalDeclarator pl_scDecl) runs on EPTF_ExecCtrl_CT {
pl_scDecl := pl_scInstance;
}
// creates the varibles for the scenario (for gui):
// scenario status, start/stop scenario, start/stop all traffic cases in the scenario
private function f_EPTF_ExecCtrl_createScenarioVariables() runs on EPTF_ExecCtrl_CT {
// create Variables:
for(var integer sc:=0, size := sizeof(v_ExecCtrl_scenarios); sc<size; sc:=sc+1) {
f_EPTF_ExecCtrl_subscribeScenarioState(sc);
f_EPTF_ExecCtrl_createTrafficCaseVariablesOfSc(sc);
f_EPTF_ExecCtrl_createStartStopScenario(sc);
f_EPTF_ExecCtrl_createStartStopAllTC(sc);
}
// create resetAllTC counters button variable
f_EPTF_ExecCtrl_createResetStatsAllTC();
// create resetAllTC FSM stats button variable
f_EPTF_ExecCtrl_createResetFSMStatsAllTC();
// register execTime updater callback:
f_EPTF_ExecCtrl_registerTrafficCaseStateChangedCallback(refers(f_EPTF_ExecCtrl_execTimeUpdate_TCStateChangedCallbackFn));
}
// Distribute scenario on LGens
// Returns a scenario type list for all LGens [lgenidx]
// The scenarios are declared on LGens with the instance name instead of the declarator name!
private function f_EPTF_ExecCtrl_distributeScenarioOnLGens(in integer pl_scIdx) runs on EPTF_ExecCtrl_CT
return EPTF_ExecCtrl_ScenarioTypeList {
f_EPTF_ExecCtrl_debug(%definitionId&": start");
f_EPTF_Base_assert(%definitionId&": Invalid scenario index "&int2str(pl_scIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_scenarios))&").",
pl_scIdx >= 0 and pl_scIdx < sizeof(v_ExecCtrl_scenarios));
// go through all TCs of this scenario and split them according to the LGen distribution of the entity group this scenario is assigned
var EPTF_ExecCtrl_ScenarioTypeList vl_scenarioList := {}; // [lgenidx]
var EPTF_ExecCtrl_ScenarioType vl_scenario := v_ExecCtrl_scenarios[pl_scIdx].scData;
var EPTF_ExecCtrl_ParamRangeDeclaratorTableList vl_rangeDeclDB := {}; // [<tcidx>][<lgenidx>][<rangeidx>]
var EPTF_FloatTable vl_cpsDistributionDb := {}; // [<tcidx>][<lgenidx>]
var EPTF_ExecCtrl_TrafficStartFinishConditionsInternalDeclaratorTableList vl_trafficStartFinishConditionsAndActionsDistributionDb := {}; // [<tcidx>][<lgenidx>]
var EPTF_FloatList vl_cpsDistributionOfScDb := f_EPTF_ExecCtrl_splitCPSOfSc(pl_scIdx); // [<lgenidx>]
// FIXME: shall we need this? :
// modify scenario name to the instance name to avoid declarator ambiguity if one scenario is added to more than one eGrp:
//vl_scenario.name := v_ExecCtrl_scenarios[pl_scIdx].name;
for (var integer tcidx:=0, size := sizeof(vl_scenario.tcList);tcidx<size;tcidx:=tcidx+1) {
vl_rangeDeclDB[tcidx] := f_EPTF_ExecCtrl_splitRangesOfTc(pl_scIdx,tcidx);
vl_cpsDistributionDb[tcidx] := f_EPTF_ExecCtrl_splitCPSOfTc(pl_scIdx,tcidx)
vl_trafficStartFinishConditionsAndActionsDistributionDb[tcidx] := f_EPTF_ExecCtrl_splitTrafficStartFinishConditionsAndActionsOfTc(pl_scIdx,tcidx)
} // tcidx
// Sending to LGens
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[pl_scIdx].eGroupIdx;
for (var integer lgenidx:=0, size := sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList);lgenidx<size;lgenidx:=lgenidx+1) {
if (v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].eCount == 0) {
continue; // do not send packet to LGen if there is no entity on the LGen
}
if (sizeof(vl_cpsDistributionOfScDb)>0) {
vl_scenario.weightedScData.cpsToReach := vl_cpsDistributionOfScDb[lgenidx];
}
for (var integer tcidx:=0, tsize := sizeof(vl_scenario.tcList);tcidx<tsize;tcidx:=tcidx+1) {
// Updating cps
if (ischosen(vl_scenario.tcList[tcidx].target.cpsToReach)) {
vl_scenario.tcList[tcidx].target.cpsToReach := vl_cpsDistributionDb[tcidx][lgenidx];
}
// Updating range params
if (sizeof(vl_scenario.tcList[tcidx].ranges) == 0) {
vl_scenario.tcList[tcidx].ranges := {}
} else {
vl_scenario.tcList[tcidx].ranges := vl_rangeDeclDB[tcidx][lgenidx];
}
// Updating trafficStartFinishConditionsAndActions
vl_scenario.tcList[tcidx].trafficStartFinishConditionsAndActions := vl_trafficStartFinishConditionsAndActionsDistributionDb[tcidx][lgenidx];
} //tcidx
var integer vl_lgenIdx := v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].lgenIdx;
f_EPTF_ExecCtrl_debug(log2str("Scenario to be declared on LGen ",v_ExecCtrl_lgens[vl_lgenIdx].name,": ", vl_scenario));
vl_scenarioList[lgenidx] := vl_scenario;
// ExecCtrl_MgmtIf_CP.send(vl_scenario) to f_EPTF_Base_downcast(v_ExecCtrl_lgens[vl_lgenIdx].lgenCompRef);
// will be sent together with other scenarios to LGen => only one message is sent/LGen
} // lgenidx
f_EPTF_ExecCtrl_debug(%definitionId&": finish");
return vl_scenarioList;
}
// splits the trafficStartFinishConditionsAndActions of the traffic case on the LGens
// the returned value contains the list of trafficStartFinishConditionsAndActions-es on the LGens in the order they are placed in the eGrp of the scenario
private function f_EPTF_ExecCtrl_splitTrafficStartFinishConditionsAndActionsOfTc(in integer pl_scIdx, in integer pl_tcOfScIdx)
runs on EPTF_ExecCtrl_CT
return EPTF_ExecCtrl_TrafficStartFinishConditionsInternalDeclaratorTable {
f_EPTF_Base_assert(%definitionId&": Invalid scenario index "&int2str(pl_scIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_scenarios))&").",
pl_scIdx >= 0 and pl_scIdx < sizeof(v_ExecCtrl_scenarios));
f_EPTF_Base_assert(%definitionId&": Invalid tcOfScenario index "&int2str(pl_tcOfScIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_scenarios[pl_scIdx].scData.tcList))&").",
pl_tcOfScIdx >= 0 and pl_tcOfScIdx < sizeof(v_ExecCtrl_scenarios[pl_scIdx].scData.tcList));
var EPTF_ExecCtrl_TrafficStartFinishConditionsInternalDeclaratorTable vl_trafficStartFinishConditionsAndActionsDistribution := {}; // [<lgenidx>]
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[pl_scIdx].eGroupIdx;
//var float vl_eGrpSize := int2float(v_ExecCtrl_entityGroups[vl_eGrpIdx].eCount);
var integer vl_activeEntities := f_EPTF_ExecCtrl_getActiveEntities(vl_eGrpIdx);
if (vl_activeEntities==0) {
for (var integer lgenidx:=0, size := sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList);lgenidx<size;lgenidx:=lgenidx+1) {
// do not split:
vl_trafficStartFinishConditionsAndActionsDistribution[lgenidx] := v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].trafficStartFinishConditionsAndActions;
}
return vl_trafficStartFinishConditionsAndActionsDistribution;
}
var EPTF_LGenBase_TrafficStartFinishConditionsInternalDeclarator vl_remaining := v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].trafficStartFinishConditionsAndActions;
f_EPTF_ExecCtrl_debug(log2str("Distributing trafficStartFinishConditionsAndActions of traffic case ",pl_tcOfScIdx, " of scenario ", pl_scIdx, ": ",
v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].trafficStartFinishConditionsAndActions));
var integer vl_lastLGenIdxUsed := -1;
// do it backwards so that the first always receive 1
for (var integer size := sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList), lgenidx:=size-1;lgenidx>=0;lgenidx:=lgenidx-1) {
var boolean vl_enableSplit := true; // false for weighted, but here it cannot be weighted
if (vl_enableSplit) {
// Split the values
var integer vl_lgenSize := v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].eCountActive;//int2float(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].eCount);
if (vl_lgenSize>0) {
vl_lastLGenIdxUsed := lgenidx;
}
// initialize the value with the original:
vl_trafficStartFinishConditionsAndActionsDistribution[lgenidx] := v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].trafficStartFinishConditionsAndActions;
if (ispresent(v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].trafficStartFinishConditionsAndActions.nrOfExecStart)) {
vl_trafficStartFinishConditionsAndActionsDistribution[lgenidx].nrOfExecStart.count :=
v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].trafficStartFinishConditionsAndActions.nrOfExecStart.count * vl_lgenSize/vl_activeEntities;
vl_remaining.nrOfExecStart.count :=
vl_remaining.nrOfExecStart.count-vl_trafficStartFinishConditionsAndActionsDistribution[lgenidx].nrOfExecStart.count;
}
if (ispresent(v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].trafficStartFinishConditionsAndActions.nrOfSuccesses)) {
vl_trafficStartFinishConditionsAndActionsDistribution[lgenidx].nrOfSuccesses.count :=
v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].trafficStartFinishConditionsAndActions.nrOfSuccesses.count * vl_lgenSize/vl_activeEntities;
vl_remaining.nrOfSuccesses.count :=
vl_remaining.nrOfSuccesses.count-vl_trafficStartFinishConditionsAndActionsDistribution[lgenidx].nrOfSuccesses.count;
}
if (ispresent(v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].trafficStartFinishConditionsAndActions.nrOfFails)) {
vl_trafficStartFinishConditionsAndActionsDistribution[lgenidx].nrOfFails.count :=
v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].trafficStartFinishConditionsAndActions.nrOfFails.count * vl_lgenSize/vl_activeEntities;
vl_remaining.nrOfFails.count :=
vl_remaining.nrOfFails.count-vl_trafficStartFinishConditionsAndActionsDistribution[lgenidx].nrOfFails.count;
}
if (ispresent(v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].trafficStartFinishConditionsAndActions.nrOfErrors)) {
vl_trafficStartFinishConditionsAndActionsDistribution[lgenidx].nrOfErrors.count :=
v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].trafficStartFinishConditionsAndActions.nrOfErrors.count * vl_lgenSize/vl_activeEntities;
vl_remaining.nrOfErrors.count :=
vl_remaining.nrOfErrors.count-vl_trafficStartFinishConditionsAndActionsDistribution[lgenidx].nrOfErrors.count;
}
if (ispresent(v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].trafficStartFinishConditionsAndActions.nrOfTimeouts)) {
vl_trafficStartFinishConditionsAndActionsDistribution[lgenidx].nrOfTimeouts.count :=
v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].trafficStartFinishConditionsAndActions.nrOfTimeouts.count * vl_lgenSize/vl_activeEntities;
vl_remaining.nrOfTimeouts.count :=
vl_remaining.nrOfTimeouts.count-vl_trafficStartFinishConditionsAndActionsDistribution[lgenidx].nrOfTimeouts.count;
}
// if (ispresent(v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].trafficStartFinishConditionsAndActions.nrOfRangeLoop)) {
// vl_trafficStartFinishConditionsAndActionsDistribution[lgenidx].nrOfRangeLoop.count :=
// v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].trafficStartFinishConditionsAndActions.nrOfRangeLoop.count * vl_lgenSize/vl_activeEntities;
//
// vl_remaining.nrOfRangeLoop.count :=
// vl_remaining.nrOfRangeLoop.count-vl_trafficStartFinishConditionsAndActionsDistribution[lgenidx].nrOfRangeLoop.count;
// }
//...
// these are not split:
// nrOfRangeLoop ,
// execTime ,
// entitiesFinished ,
// availableEntitiesFinished ,
// customFinish ,
// anythingFinished
} else {
// Assign the same values, no split
vl_trafficStartFinishConditionsAndActionsDistribution[lgenidx] := v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].trafficStartFinishConditionsAndActions;
}
}
// correct the last element to store the remaining count
if (vl_lastLGenIdxUsed!=-1) {
if(ispresent(vl_trafficStartFinishConditionsAndActionsDistribution[vl_lastLGenIdxUsed].nrOfExecStart)) {
vl_trafficStartFinishConditionsAndActionsDistribution[vl_lastLGenIdxUsed].nrOfExecStart.count :=
vl_trafficStartFinishConditionsAndActionsDistribution[vl_lastLGenIdxUsed].nrOfExecStart.count + vl_remaining.nrOfExecStart.count;
vl_remaining.nrOfExecStart.count := 0;
}
if(ispresent(vl_trafficStartFinishConditionsAndActionsDistribution[vl_lastLGenIdxUsed].nrOfSuccesses)) {
vl_trafficStartFinishConditionsAndActionsDistribution[vl_lastLGenIdxUsed].nrOfSuccesses.count :=
vl_trafficStartFinishConditionsAndActionsDistribution[vl_lastLGenIdxUsed].nrOfSuccesses.count + vl_remaining.nrOfSuccesses.count;
vl_remaining.nrOfSuccesses.count := 0;
}
if(ispresent(vl_trafficStartFinishConditionsAndActionsDistribution[vl_lastLGenIdxUsed].nrOfFails)) {
vl_trafficStartFinishConditionsAndActionsDistribution[vl_lastLGenIdxUsed].nrOfFails.count :=
vl_trafficStartFinishConditionsAndActionsDistribution[vl_lastLGenIdxUsed].nrOfFails.count + vl_remaining.nrOfFails.count;
vl_remaining.nrOfFails.count := 0;
}
if(ispresent(vl_trafficStartFinishConditionsAndActionsDistribution[vl_lastLGenIdxUsed].nrOfErrors)) {
vl_trafficStartFinishConditionsAndActionsDistribution[vl_lastLGenIdxUsed].nrOfErrors.count :=
vl_trafficStartFinishConditionsAndActionsDistribution[vl_lastLGenIdxUsed].nrOfErrors.count + vl_remaining.nrOfErrors.count;
vl_remaining.nrOfErrors.count := 0;
}
if(ispresent(vl_trafficStartFinishConditionsAndActionsDistribution[vl_lastLGenIdxUsed].nrOfTimeouts)) {
vl_trafficStartFinishConditionsAndActionsDistribution[vl_lastLGenIdxUsed].nrOfTimeouts.count :=
vl_trafficStartFinishConditionsAndActionsDistribution[vl_lastLGenIdxUsed].nrOfTimeouts.count + vl_remaining.nrOfTimeouts.count;
vl_remaining.nrOfTimeouts.count := 0;
}
// if(ispresent(vl_trafficStartFinishConditionsAndActionsDistribution[vl_lastLGenIdxUsed].nrOfRangeLoop)) {
// vl_trafficStartFinishConditionsAndActionsDistribution[vl_lastLGenIdxUsed].nrOfRangeLoop.count :=
// vl_trafficStartFinishConditionsAndActionsDistribution[vl_lastLGenIdxUsed].nrOfRangeLoop.count + vl_remaining.nrOfRangeLoop.count;
// vl_remaining.nrOfRangeLoop.count := 0;
// }
// these are not split:
// nrOfRangeLoop ,
// execTime ,
// entitiesFinished ,
// availableEntitiesFinished ,
// customFinish ,
// anythingFinished
}
// if (vl_remaining>0.0) {
// f_EPTF_ExecCtrl_debug(log2str(%definitionId&": Cannot distribute CPS of TC ",v_ExecCtrl_trafficCases[v_ExecCtrl_scenarios[pl_scIdx].tcIdxList[pl_tcOfScIdx]].name))
// }
f_EPTF_ExecCtrl_debug(log2str("Calculated vl_trafficStartFinishConditionsAndActionsDistribution on LGens: ", vl_trafficStartFinishConditionsAndActionsDistribution))
return vl_trafficStartFinishConditionsAndActionsDistribution;
}
// splits the ranges of the traffic case on the LGens
// the returned value contains the list of ranges-es on the LGens in the order they are placed in the eGrp of the scenario
private function f_EPTF_ExecCtrl_splitRangesOfTc(in integer pl_scIdx, in integer pl_tcOfScIdx)
runs on EPTF_ExecCtrl_CT
return EPTF_ExecCtrl_ParamRangeDeclaratorTable {
f_EPTF_Base_assert(%definitionId&": Invalid scenario index "&int2str(pl_scIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_scenarios))&").",
pl_scIdx >= 0 and pl_scIdx < sizeof(v_ExecCtrl_scenarios));
f_EPTF_Base_assert(%definitionId&": Invalid tcOfScenario index "&int2str(pl_tcOfScIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_scenarios[pl_scIdx].scData.tcList))&").",
pl_tcOfScIdx >= 0 and pl_tcOfScIdx < sizeof(v_ExecCtrl_scenarios[pl_scIdx].scData.tcList));
var EPTF_ExecCtrl_ParamRangeDeclaratorTable vl_rangeDeclDB := {}; // [<lgenidx>][<rangeidx>]
var EPTF_IntegerList vl_rangeCountDistributionDB := {};
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[pl_scIdx].eGroupIdx;
//var float vl_eGrpSize := int2float(v_ExecCtrl_entityGroups[vl_eGrpIdx].eCount);
var float vl_allocatedEntities := int2float(f_EPTF_ExecCtrl_getAllocatedEntities(vl_eGrpIdx));
if (vl_allocatedEntities==0.0) {
return vl_rangeDeclDB;
}
f_EPTF_ExecCtrl_debug(log2str("Distributing ranges of traffic case: ",pl_tcOfScIdx, " of scenario ", pl_scIdx));
// Process all the ranges in the TC
for (var integer rangeidx:=0, size := sizeof(v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].ranges);rangeidx<size;rangeidx:=rangeidx+1) {
f_EPTF_ExecCtrl_debug(log2str("Distributing on LGens the range: ", v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].ranges[rangeidx]));
var integer vl_remaining := v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].ranges[rangeidx].count;
for (var integer lgenidx:=0, lsize := sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList);lgenidx<lsize;lgenidx:=lgenidx+1) {
if (v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].ranges[rangeidx].enableSplit) {
// Split the values
var float vl_lgenSize := int2float(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].eCount);
var float vl_lgenWeight := vl_lgenSize/vl_allocatedEntities;
vl_rangeCountDistributionDB[lgenidx] := float2int(vl_lgenWeight * int2float(v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].ranges[rangeidx].count));
if (float2int(vl_lgenSize)==0) {
f_EPTF_ExecCtrl_warning(%definitionId&": Zero sized range of "&v_ExecCtrl_scenarios[pl_scIdx].name&"."&f_EPTF_ExecCtrl_tcNameOfTcOfSc(pl_scIdx,pl_tcOfScIdx)
&" is distributed on LGen "&v_ExecCtrl_lgens[v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].lgenIdx].name&": "
&log2str(v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].ranges[rangeidx]));
} else if (vl_rangeCountDistributionDB[lgenidx]==0) {
f_EPTF_ExecCtrl_error(%definitionId&": Range of "&v_ExecCtrl_scenarios[pl_scIdx].name&"."&f_EPTF_ExecCtrl_tcNameOfTcOfSc(pl_scIdx,pl_tcOfScIdx)
&" too small to be able to split among the deployed LGens: "
&log2str(v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].ranges[rangeidx]));
}
} else {
// Assign the same values, no split
vl_rangeCountDistributionDB[lgenidx] := v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].ranges[rangeidx].count;
}
vl_remaining := vl_remaining-vl_rangeCountDistributionDB[lgenidx];
// correct the last element to store the remaining count
if (lgenidx==sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList)-1 and vl_remaining>0) {
vl_rangeCountDistributionDB[lgenidx] := vl_rangeCountDistributionDB[lgenidx] + vl_remaining;
}
}
f_EPTF_ExecCtrl_debug(log2str("Calculated vl_rangeCountDistributionDB on LGens: ", vl_rangeCountDistributionDB))
// Compose the range parameters
var integer vl_cumulativOffset := 0;
for (var integer lgenidx:=0, lsize := sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList);lgenidx<lsize;lgenidx:=lgenidx+1) {
vl_rangeDeclDB[lgenidx][rangeidx].name := v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].ranges[rangeidx].name;
vl_rangeDeclDB[lgenidx][rangeidx].enableSplit := v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].ranges[rangeidx].enableSplit;
vl_rangeDeclDB[lgenidx][rangeidx].count := vl_rangeCountDistributionDB[lgenidx];
vl_rangeDeclDB[lgenidx][rangeidx].baseOffset := vl_cumulativOffset + v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].ranges[rangeidx].baseOffset;
if (vl_rangeDeclDB[lgenidx][rangeidx].enableSplit) {
vl_cumulativOffset := vl_cumulativOffset + vl_rangeCountDistributionDB[lgenidx];
}
} // lgenidx
} // rangeidx
return vl_rangeDeclDB;
}
// splits the number of active entities of the entity group on the LGens
// the returned value contains the list of number of active entities on the LGens in the order they are placed in the eGrp
private function f_EPTF_ExecCtrl_splitActiveEntitiesOfEGrp(in integer pl_eGrpIdx)
runs on EPTF_ExecCtrl_CT
return EPTF_IntegerList {
f_EPTF_Base_assert(%definitionId&": Invalid entity group index "&int2str(pl_eGrpIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_entityGroups))&").",
pl_eGrpIdx >= 0 and pl_eGrpIdx < sizeof(v_ExecCtrl_entityGroups));
var EPTF_IntegerList vl_activeEntityDistribution := {};// [<lgenidx>]
var integer vl_eGrpIdx := pl_eGrpIdx;
//var float vl_eGrpSize := int2float(v_ExecCtrl_entityGroups[vl_eGrpIdx].eCount);
var float vl_allocatedEntities := int2float(f_EPTF_ExecCtrl_getAllocatedEntities(vl_eGrpIdx));
if (vl_allocatedEntities==0.0) {
return vl_activeEntityDistribution;
}
var integer vl_remaining := f_EPTF_ExecCtrl_getActiveEntities(vl_eGrpIdx);
f_EPTF_ExecCtrl_debug(log2str("Distributing number of active entities of entity group ", f_EPTF_ExecCtrl_eGrp_name(vl_eGrpIdx), ": ",
vl_remaining));
var integer vl_lastLGenIdxUsed := -1; // remainder will be allocated to this LGen
// do it backwards so that the first always receive 1
for (var integer size := sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList), lgenidx:=size-1; lgenidx>=0;lgenidx:=lgenidx-1) {
// Split the values
var float vl_lgenSize := int2float(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].eCount);
var float vl_lgenWeight := vl_lgenSize/vl_allocatedEntities;
vl_activeEntityDistribution[lgenidx] := float2int(vl_lgenWeight * int2float(f_EPTF_ExecCtrl_getActiveEntities(vl_eGrpIdx)));
vl_remaining := vl_remaining-vl_activeEntityDistribution[lgenidx];
if (vl_lgenSize>0.0) {
vl_lastLGenIdxUsed := lgenidx;
}
}
// correct the last element to store the remaining count
if (vl_lastLGenIdxUsed!=-1 and vl_remaining>0) {
if (vl_activeEntityDistribution[vl_lastLGenIdxUsed] + vl_remaining>v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[vl_lastLGenIdxUsed].eCount) {
//if it is not possible to add the remaining active entities to this LGen:
//choose an LGen where it is possible to add (distribute remaining 1-by-1):
for (var integer lgenidx := 0, size := sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList); lgenidx<size;lgenidx:=lgenidx+1) {
if (vl_activeEntityDistribution[lgenidx] + 1 <= v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].eCount) {
vl_activeEntityDistribution[lgenidx] := vl_activeEntityDistribution[lgenidx] + 1;
vl_remaining := vl_remaining-1;
if (vl_remaining==0) {
break;
} else {
lgenidx := lgenidx - 1; // retry current LGen again for if it is possible to add one more
}
}
}
} else {
vl_activeEntityDistribution[vl_lastLGenIdxUsed] := vl_activeEntityDistribution[vl_lastLGenIdxUsed] + vl_remaining;
vl_remaining := 0;
}
}
f_EPTF_ExecCtrl_debug(log2str("Calculated vl_activeEntityDistribution on LGens: ", vl_activeEntityDistribution))
return vl_activeEntityDistribution;
}
// splits the CPS/weight of the traffic case on the LGens
// the returned value contains the list of CPS/weights-es on the LGens in the order they are placed in the eGrp of the scenario
private function f_EPTF_ExecCtrl_splitCPSOfTc(in integer pl_scIdx, in integer pl_tcOfScIdx)
runs on EPTF_ExecCtrl_CT
return EPTF_FloatList {
f_EPTF_Base_assert(%definitionId&": Invalid scenario index "&int2str(pl_scIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_scenarios))&").",
pl_scIdx >= 0 and pl_scIdx < sizeof(v_ExecCtrl_scenarios));
f_EPTF_Base_assert(%definitionId&": Invalid tcOfScenario index "&int2str(pl_tcOfScIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_scenarios[pl_scIdx].scData.tcList))&").",
pl_tcOfScIdx >= 0 and pl_tcOfScIdx < sizeof(v_ExecCtrl_scenarios[pl_scIdx].scData.tcList));
if(ischosen(v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].target.dummy)) {
f_EPTF_ExecCtrl_error(%definitionId&": No targetCPS/Weight specified in traffic case "&v_ExecCtrl_trafficCases[v_ExecCtrl_scenarios[pl_scIdx].tcIdxList[pl_tcOfScIdx]].name);
}
var EPTF_FloatList vl_cpsDistribution := {};// [<lgenidx>]
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[pl_scIdx].eGroupIdx;
if (not ischosen(v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].target.cpsToReach)) {
f_EPTF_ExecCtrl_debug(log2str("Only cpsToReach is distributed, but current tc does not use cpsToReach"));
for (var integer lgenidx:=0, size := sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList);lgenidx<size;lgenidx:=lgenidx+1) {
vl_cpsDistribution[lgenidx] := v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].target.trafficWeight;
}
return vl_cpsDistribution; // weight is not split
}
//var float vl_eGrpSize := int2float(v_ExecCtrl_entityGroups[vl_eGrpIdx].eCount);
var float vl_activeEntities := int2float(f_EPTF_ExecCtrl_getActiveEntities(vl_eGrpIdx));
if (vl_activeEntities==0.0) {
for (var integer lgenidx:=0, size := sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList);lgenidx<size;lgenidx:=lgenidx+1) {
vl_cpsDistribution[lgenidx] := 0.0
}
return vl_cpsDistribution;
}
var float vl_remaining := v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].target.cpsToReach;
f_EPTF_ExecCtrl_debug(log2str("Distributing CPS of traffic case ",pl_tcOfScIdx, " of scenario ", pl_scIdx, ": ",
v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].target.cpsToReach));
var integer vl_lastLGenIdxUsed := -1;
for (var integer lgenidx:=0, size := sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList);lgenidx<size;lgenidx:=lgenidx+1) {
var boolean vl_enableSplit := true; // false for weighted, but here it cannot be weighted
if (vl_enableSplit) {
// Split the values
var float vl_lgenSize := int2float(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].eCountActive);//int2float(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].eCount);
var float vl_lgenWeight := vl_lgenSize/vl_activeEntities;
vl_cpsDistribution[lgenidx] := vl_lgenWeight * v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].target.cpsToReach;
} else {
// Assign the same values, no split
vl_cpsDistribution[lgenidx] := v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].target.cpsToReach;
}
if (vl_cpsDistribution[lgenidx]>0.0) {
vl_lastLGenIdxUsed := lgenidx;
}
vl_remaining := vl_remaining-vl_cpsDistribution[lgenidx];
}
// correct the last element to store the remaining count
if (vl_lastLGenIdxUsed!=-1 and vl_remaining>0.0) {
vl_cpsDistribution[vl_lastLGenIdxUsed] := vl_cpsDistribution[vl_lastLGenIdxUsed] + vl_remaining;
vl_remaining := 0.0;
}
if (vl_remaining>0.0) {
f_EPTF_ExecCtrl_debug(log2str(%definitionId&": Cannot distribute CPS of TC ",v_ExecCtrl_trafficCases[v_ExecCtrl_scenarios[pl_scIdx].tcIdxList[pl_tcOfScIdx]].name))
}
f_EPTF_ExecCtrl_debug(log2str("Calculated vl_cpsDistribution on LGens: ", vl_cpsDistribution))
return vl_cpsDistribution;
}
// splits the CPS of the scenario on the LGens
// the returned value contains the list of CPS-es on the LGens in the order they are placed in the eGrp of the scenario
private function f_EPTF_ExecCtrl_splitCPSOfSc(in integer pl_scIdx)
runs on EPTF_ExecCtrl_CT
return EPTF_FloatList {
f_EPTF_Base_assert(%definitionId&": Invalid scenario index "&int2str(pl_scIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_scenarios))&").",
pl_scIdx >= 0 and pl_scIdx < sizeof(v_ExecCtrl_scenarios));
var EPTF_FloatList vl_cpsDistribution := {};// [<lgenidx>]
if (not ispresent(v_ExecCtrl_scenarios[pl_scIdx].scData.weightedScData)) {
f_EPTF_ExecCtrl_debug(log2str("Only cpsToReach is distributed, but current Sc does not use cpsToReach"))
return vl_cpsDistribution; // nothing to do
}
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[pl_scIdx].eGroupIdx;
//var float vl_eGrpSize := int2float(v_ExecCtrl_entityGroups[vl_eGrpIdx].eCount);
var float vl_activeEntities := int2float(f_EPTF_ExecCtrl_getActiveEntities(vl_eGrpIdx));
if (vl_activeEntities==0.0) {
for (var integer lgenidx:=0, size := sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList);lgenidx<size;lgenidx:=lgenidx+1) {
vl_cpsDistribution[lgenidx] := 0.0
}
return vl_cpsDistribution;
}
var float vl_remaining := v_ExecCtrl_scenarios[pl_scIdx].scData.weightedScData.cpsToReach;
f_EPTF_ExecCtrl_debug(log2str("Distributing CPS of scenario ", pl_scIdx, ": ",
v_ExecCtrl_scenarios[pl_scIdx].scData.weightedScData.cpsToReach));
var integer vl_lastLGenIdxUsed := -1;
for (var integer lgenidx:=0, size := sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList);lgenidx<size;lgenidx:=lgenidx+1) {
var boolean vl_enableSplit := true; // true for weighted, but here it cannot be non-weighted
if (vl_enableSplit) {
// Split the values
var float vl_lgenSize := int2float(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].eCountActive);//int2float(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[lgenidx].eCount);
var float vl_lgenWeight := vl_lgenSize/vl_activeEntities;
vl_cpsDistribution[lgenidx] := vl_lgenWeight * v_ExecCtrl_scenarios[pl_scIdx].scData.weightedScData.cpsToReach;
} else {
// Assign the same values, no split
vl_cpsDistribution[lgenidx] := v_ExecCtrl_scenarios[pl_scIdx].scData.weightedScData.cpsToReach;
}
if (vl_cpsDistribution[lgenidx]>0.0) {
vl_lastLGenIdxUsed := lgenidx;
}
vl_remaining := vl_remaining-vl_cpsDistribution[lgenidx];
}
// correct the last element to store the remaining count
if (vl_lastLGenIdxUsed!=-1 and vl_remaining>0.0) {
vl_cpsDistribution[vl_lastLGenIdxUsed] := vl_cpsDistribution[vl_lastLGenIdxUsed] + vl_remaining;
vl_remaining := 0.0;
}
if (vl_remaining>0.0) {
f_EPTF_ExecCtrl_debug(log2str(%definitionId&": Cannot distribute CPS of SC ",v_ExecCtrl_scenarios[pl_scIdx].name))
}
f_EPTF_ExecCtrl_debug(log2str("Calculated vl_cpsDistribution of the scenario on LGens: ", vl_cpsDistribution))
return vl_cpsDistribution;
}
friend function f_EPTF_ExecCtrl_sendGuiDoneToLGen(in integer pl_lgenIdx, in boolean pl_guiPresent := false) runs on EPTF_ExecCtrl_CT {
if (v_ExecCtrl_lgens[pl_lgenIdx].lgenCompRef==-1) {
return; // do not send packet to LGen if LGen exited
}
ExecCtrl_MgmtIf_CP.send(EPTF_ExecCtrl_GuiDone:{pl_guiPresent}) to f_EPTF_Base_downcast(v_ExecCtrl_lgens[pl_lgenIdx].lgenCompRef);
}
friend altstep as_EPTF_ExecCtrl_receiveGuiDone() runs on EPTF_ExecCtrl_CT {
[] ExecCtrl_MgmtIf_CP.receive(EPTF_ExecCtrl_GuiDone:?) {
}
}
// R3: final test report generation
group EPTF_ExecCtrl_FinalTestReport {
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_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_ExecCtrl_registerFinalTestReportGeneratorFn(in EPTF_ExecCtrl_FinalTestReportGenerator_FT pl_reportGeneratorFn)
runs on EPTF_ExecCtrl_CT {
v_EPTF_ExecCtrl_finalTestReportGeneratorFns[sizeof(v_EPTF_ExecCtrl_finalTestReportGeneratorFns)] := pl_reportGeneratorFn;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_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_ExecCtrl_deregisterFinalTestReportGeneratorFn(in EPTF_ExecCtrl_FinalTestReportGenerator_FT pl_reportGeneratorFn)
runs on EPTF_ExecCtrl_CT {
for(var integer i:=0, size := sizeof(v_EPTF_ExecCtrl_finalTestReportGeneratorFns); i<size; i:=i+1) {
if(v_EPTF_ExecCtrl_finalTestReportGeneratorFns[i]==pl_reportGeneratorFn) {
v_EPTF_ExecCtrl_finalTestReportGeneratorFns[i] := null;
}
}
}
// calls all F.T.R. generator functions
private function f_EPTF_ExecCtrl_callFinalTestReportGeneratorFns(inout charstring pl_report)
runs on EPTF_ExecCtrl_CT {
for(var integer i:=0, size := sizeof(v_EPTF_ExecCtrl_finalTestReportGeneratorFns); i<size; i:=i+1) {
if(v_EPTF_ExecCtrl_finalTestReportGeneratorFns[i]!=null) {
f_EPTF_ExecCtrl_debug(log2str(%definitionId&": Calling final test report generator function: ",v_EPTF_ExecCtrl_finalTestReportGeneratorFns[i]));
v_EPTF_ExecCtrl_finalTestReportGeneratorFns[i].apply(pl_report);
f_EPTF_ExecCtrl_debug(log2str(%definitionId&": Final test report generator function finished: ",v_EPTF_ExecCtrl_finalTestReportGeneratorFns[i]));
}
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_generateFinalTestReport
//
// Purpose:
// generates the final test report
//
// Parameters:
//
// Return Value:
//
// Errors:
//
// Detailed Comments:
// Called automatically if the Exit Button is pressed,
// or when any LGen detects the exit event in LGenBase
// (added to the postproc of the exit button also)
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_generateFinalTestReport()
runs on EPTF_ExecCtrl_CT {
if (tsp_EPTF_ExecCtrl_finalTestReportFile=="") {
f_EPTF_ExecCtrl_debug(log2str(%definitionId&": No report generated: Final test report generation is disabled"));
return; // final test report generation is disabled
}
if (v_ExecCtrl_endOfTest) {
return; // test already ended, prevent multiple report generation
}
v_ExecCtrl_endOfTest:=true;
// collect reports from all LGens:
f_EPTF_ExecCtrl_sendEofTestToAllLGens();
// call ExecCtrl report generators:
f_EPTF_ExecCtrl_callFinalTestReportGeneratorFns(v_EPTF_ExecCtrl_finalTestReport);
// write report to file:
if (v_EPTF_ExecCtrl_finalTestReport=="") {
f_EPTF_ExecCtrl_warning(log2str(%definitionId&": No report generated: Generated final test report is empty. If You want so, please set tsp_EPTF_ExecCtrl_finalTestReportFile to empty string."));
return; // no report available
}
var charstring vl_generatedAt := f_getTimeFormatted(float2int(f_EPTF_Base_getAbsTimeInSecs()),"\nGenerated at: %Y/%m/%d %H:%M:%S\n\n");
var charstring vl_textWritten := f_EPTF_ExecCtrl_writeToFile(
"----------------------------\n"&
"- Final test report -\n"&
"----------------------------\n"&
vl_generatedAt&
v_EPTF_ExecCtrl_finalTestReport&"\n"&
"----------------------------\n"&
"- End of final test report -\n"&
"----------------------------\n",
tsp_EPTF_ExecCtrl_finalTestReportFile
)
f_EPTF_ExecCtrl_debug(log2str(%definitionId&": Final test report is written to file: "&vl_textWritten));
f_EPTF_ExecCtrl_setStatusEndOfTest();
}
// Own final test report generator function
private function f_EPTF_ExecCtrl_generateOwnFinalTestReport(inout charstring pl_report) runs on EPTF_ExecCtrl_CT {
var charstring vl_report := "\n---- ExecCtrl Final Report ----\n";
// for all traffic cases write stattistics data to the report:
for(var integer tcIdx:=0; tcIdx<f_EPTF_ExecCtrl_numTrafficCases(); tcIdx:=tcIdx+1) {
var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioIdxForTc(tcIdx);
var integer vl_tcOfScenarioIdx := f_EPTF_ExecCtrl_getTcOfScenarioIdx(tcIdx);
var integer vl_eGrpIdx := f_EPTF_ExecCtrl_getScenarioEGroupIdx(vl_scIdx);
var charstring vl_eGrpName := f_EPTF_ExecCtrl_eGrp_name(vl_eGrpIdx);
var charstring vl_scTypeName := f_EPTF_ExecCtrl_getScenarioName(vl_scIdx);
var charstring vl_tcName := f_EPTF_ExecCtrl_tcNameOfTcOfSc(vl_scIdx,vl_tcOfScenarioIdx)
var charstring vl_namePrefix := c_EPTF_ExecCtrl_statisticsRoot&".EG."&vl_eGrpName&".SC."&vl_scTypeName&".TC."&vl_tcName;
var charstring vl_statName;
var integer vl_idx;
var charstring vl_varName;
vl_report := vl_report & "\nTraffic case stats for EntityGroup: "&vl_eGrpName&", Scenario: "&vl_scTypeName&", TrafficCase: "&vl_tcName&"\n";
// instanceName:
vl_report := vl_report &"InstanceName : " &f_EPTF_ExecCtrl_getTrafficCaseName(tcIdx)&"\n";
// state:
vl_varName := "ExecCtrl.trafficCaseStatus."&vl_eGrpName&"."&vl_scTypeName&"."&vl_tcName; //widget: vl_namePrefix&".StatusLED";
vl_idx := f_EPTF_Var_getId(vl_varName);
if (vl_idx==-1) {
vl_report := vl_report & "State : " &"N/A\n";
// variable not found
} else {
var EPTF_StatusLED vl_statusLed := f_EPTF_Var_getStatusLEDValue(vl_idx);
var charstring vl_strValue := vl_statusLed.text;
vl_report := vl_report &"State : " &vl_strValue&"\n";
}
// all stats
for(var integer st:=0, size := sizeof(c_EPTF_ExecCtrl_tcStatNames); st<size;st:=st+1) {
if (st==c_EPTF_ExecCtrl_tcStatId_ExecTime) {
// execTime:
vl_varName := vl_namePrefix&"."&c_EPTF_ExecCtrl_tcStatNames[st]
vl_idx := f_EPTF_Var_getId(vl_varName);
} else {
// stathandler stats:
vl_statName := vl_namePrefix&"."&c_EPTF_ExecCtrl_tcStatNames[st];
vl_varName := f_EPTF_ExecCtrl_StatHandlerClient_getStatVariableRef(vl_statName);
vl_idx := f_EPTF_Var_getId(vl_varName);
}
if (vl_idx==-1) {
vl_report := vl_report & c_EPTF_ExecCtrl_tcStatNames[st]&" : " &"N/A\n";
continue; // variable not found
}
var charstring vl_strValue := f_EPTF_Var_content2str(vl_idx);
vl_report := vl_report & c_EPTF_ExecCtrl_tcStatNames[st]&" : " &vl_strValue&"\n";
}
// {Delta statistics}: all stat deltas
for(var integer st:=0, size := sizeof(c_EPTF_ExecCtrl_tcDeltaStatVarIds); st<size;st:=st+1) {
var integer vl_tcDeltaStatVarId := c_EPTF_ExecCtrl_tcDeltaStatVarIds[st];
vl_statName := vl_namePrefix&"."& c_EPTF_ExecCtrl_tcStatNames[vl_tcDeltaStatVarId] &".delta";
vl_varName := f_EPTF_ExecCtrl_StatHandlerClient_getStatVariableRef(vl_statName);
vl_idx := f_EPTF_Var_getId(vl_varName);
if (vl_idx==-1) {
vl_report := vl_report & c_EPTF_ExecCtrl_tcStatNames[vl_tcDeltaStatVarId] &" : " &"N/A\n";
continue; // variable not found
}
var charstring vl_strValue := f_EPTF_Var_content2str(vl_idx);
vl_report := vl_report & c_EPTF_ExecCtrl_tcStatNames[vl_tcDeltaStatVarId] &" : " &vl_strValue&"\n";
}
}
vl_report := vl_report & "---- End of ExecCtrl Report ----\n";
// append the generated report to the original report:
pl_report := pl_report & vl_report;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_writeToFile
//
// Purpose:
// Saves pl_stringToWrite in a file
//
// Parameters:
// pl_stringToWrite - *in charstring* - the module parameter name to save the values into.
// pl_fileName - *in charstring* - the filename where the pl_stringToWrite shall be saved
//
// Return Value:
// charstring - name of the file the pl_stringToWrite was saved in. Empty string ("") is returned on error.
//
// Errors:
// -
//
// Detailed Comments:
// The name of the file can be a format string where the timestamp can be specified also.
// For the supported time-format strings see <f_getTimeFormatted>.
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_writeToFile(
in charstring pl_stringToWrite,
in charstring pl_fileName
) runs on EPTF_ExecCtrl_CT return charstring {
var charstring vl_filename := f_getTimeFormatted(float2int(f_EPTF_Base_getAbsTimeInSecs()),pl_fileName);
if (vl_filename=="") {
f_EPTF_ExecCtrl_warning(log2str(%definitionId&": cannot save data to file: filename is not specified"));
return "";
}
f_EPTF_ExecCtrl_debug(log2str("vl_filename: ", vl_filename));
f_EPTF_ExecCtrl_debug(log2str("pl_stringToWrite: ", pl_stringToWrite));
var integer vl_fd := f_FIO_open_trunc_wronly_excl(vl_filename);
if (vl_fd == -1) {
f_EPTF_ExecCtrl_warning(log2str(%definitionId&": cannot open file ", vl_filename, ": ", f_FIO_get_error_string()));
return "";
}
var charstring vl_fileNameSaved := vl_filename;
if (f_FIO_write_text(vl_fd, pl_stringToWrite) == -1) {
f_EPTF_ExecCtrl_warning(log2str(%definitionId&": cannot save data to file ", vl_filename, ": ", f_FIO_get_error_string()));
return "";
};
if (-1==f_FIO_close(vl_fd)) {/*to remove the warning*/};
return vl_filename;
}
// sends EofTest request to all LGens
private function f_EPTF_ExecCtrl_sendEofTestToAllLGens()
runs on EPTF_ExecCtrl_CT {
v_ExecCtrl_pendingMsgCounter := 0;
for(var integer lgenIdx:=0, size := sizeof(v_ExecCtrl_lgens); lgenIdx<size; lgenIdx:=lgenIdx+1) {
if (v_ExecCtrl_lgens[lgenIdx].lgenCompRef==-1) {
continue; // do not send packet to LGen if it already exited
}
ExecCtrl_MgmtIf_CP.send(EPTF_ExecCtrl_EofTest:{}) to f_EPTF_Base_downcast(v_ExecCtrl_lgens[lgenIdx].lgenCompRef);
v_ExecCtrl_pendingMsgCounter := v_ExecCtrl_pendingMsgCounter + 1;
}
// wait until response (EofTestDone) is received from all LGens:
var EPTF_ExecCtrl_Condition_FN vl_checkPending := refers(f_EPTF_ExecCtrl_checkPendingMsgs);
f_EPTF_ExecCtrl_waitForCondition(vl_checkPending);
}
private function f_EPTF_ExecCtrl_checkEndOfTest() runs on EPTF_ExecCtrl_CT return boolean {
return v_ExecCtrl_endOfTest;
}
//
// EofTest message sequence:
//
// ExecCtrl ExecCtrlClient
//
// Exit button pressed
// OR
// <-- EofTest
//
//
// --> EofTest to all Clients
// ExecCtrlClients call Report generators
// <-- EofTestDone from all clients
//
// ExecCtrl Waits until all EofTestDone arrives
// ExecCtrl calls Report generators and creates the report
// ExecCtrl terminates execution (if manual mode false)
// handles EofTest/EofTestDone messages coming from the LGens
private altstep as_EPTF_ExecCtrl_handleEofTest() runs on EPTF_ExecCtrl_CT {
var EPTF_ExecCtrl_EofTest vl_msg0;
var EPTF_ExecCtrl_EofTestDone vl_msg;
var EPTF_ExecCtrlClient_CT vl_client;
[] ExecCtrl_MgmtIf_CP.receive(EPTF_ExecCtrl_EofTestDone:?) -> value vl_msg sender vl_client {
v_EPTF_ExecCtrl_finalTestReport := v_EPTF_ExecCtrl_finalTestReport & vl_msg.report;
v_ExecCtrl_pendingMsgCounter := v_ExecCtrl_pendingMsgCounter - 1;
repeat;
}
[] ExecCtrl_MgmtIf_CP.receive(EPTF_ExecCtrl_EofTest:?) -> value vl_msg0 sender vl_client {
f_EPTF_ExecCtrl_debug(log2str(%definitionId&": EofTest received from ",vl_client, ". Generating final test report before exiting..."));
if (v_ExecCtrl_endOfTest) {
f_EPTF_ExecCtrl_debug(log2str(%definitionId&": EofTest received from ",vl_client, ". Message dropped: Report generation is already in progress"));
repeat; // drop message if report generation is already in progress
}
f_EPTF_ExecCtrl_generateFinalTestReport();
if(not v_ExecCtrl_manualControl) {
f_EPTF_Base_stopAll(none);
}
repeat;
}
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_exit
//
// Purpose:
// Terminate the execution and exit, generate final test riport
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_exit()
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_generateFinalTestReport();
f_EPTF_ExecCtrl_sendByeToAllClients();
f_EPTF_Base_stopAll(none);
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_setGenerateOwnReport
//
// Purpose:
// Tells that the ExecCtrl's own final report has to be generated or not
//
// Parameters:
// pl_generateOwnReport - *boolean* - tells that the ExecCtrl's own final
// report has to be generated or not.
//
// Return Value:
// -
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_setGenerateOwnReport(in boolean pl_generateOwnReport) runs on EPTF_ExecCtrl_CT
{
if(pl_generateOwnReport and not v_EPTF_ExecCtrl_generateOwnReport){
f_EPTF_ExecCtrl_registerFinalTestReportGeneratorFn(refers(f_EPTF_ExecCtrl_generateOwnFinalTestReport));
} else if(not pl_generateOwnReport and v_EPTF_ExecCtrl_generateOwnReport){
f_EPTF_ExecCtrl_deregisterFinalTestReportGeneratorFn(refers(f_EPTF_ExecCtrl_generateOwnFinalTestReport));
}
v_EPTF_ExecCtrl_generateOwnReport := pl_generateOwnReport;
}
} // group EPTF_ExecCtrl_FinalTestReport
group EPTF_ExecCtrl_UIVars {
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_UIVars_InitGUILayout_vars
//
// Purpose:
// Function to init dynamic execution control GUI layout
//
// Parameters:
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// Appends varios dynamic elements to GUI in order to create execution
// control handling interface
//
///////////////////////////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_UIVars_InitGUILayout_vars()
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
// f_EPTF_ExecCtrl_UIVars_createMainImages();
// f_EPTF_ExecCtrl_UIVars_createMainTab(pl_EPTF_GUI_Main_Tabbox_WidgetId);
f_EPTF_ExecCtrl_UIVars_AppendMainTabs_vars();
// f_EPTF_ExecCtrl_UIVars_AppendEntityGroupTab();
// f_EPTF_ExecCtrl_UIVars_AppendResourceTab();
// f_EPTF_ExecCtrl_UIVars_AppendTrafficTab();
// f_EPTF_ExecCtrl_UIVars_AppendRegulatedItemsTab();
//f_EPTF_ExecCtrl_UIVars_AppendControlTab();
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_UIVars_AppendMainTabs_vars
//
// Purpose:
// Append main tabs to execution control panel
//
// Parameters:
// pl_EPTF_GUI_ExecCtrl_tabbox_WidgetId - *in* <EPTF_UIVars_WidgetIdString> - parent
// widget id
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_UIVars_AppendMainTabs_vars()
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
var integer vl_progressBar_idx,vl_progressBarText_idx,vl_globalProgressBar_idx;
f_EPTF_Var_newCharstring(c_EPTF_ExecCtrl_statisticsRoot&".notif.progressbar","0.0",vl_progressBar_idx);
f_EPTF_Var_setSubsCanAdjust(vl_progressBar_idx,false);
f_EPTF_Var_newCharstring(c_EPTF_ExecCtrl_statisticsRoot&".notif.progressbar.text","Creating LGen pools",vl_progressBarText_idx);
f_EPTF_Var_setSubsCanAdjust(vl_progressBarText_idx,false);
f_EPTF_Var_newCharstring(c_EPTF_ExecCtrl_statisticsRoot&".notif.globalProgressbar","0.0",vl_globalProgressBar_idx);
f_EPTF_Var_setSubsCanAdjust(vl_globalProgressBar_idx,false);
var EPTF_Var_DirectContent vl_PTCList;
if (0==f_EPTF_DataSourceClient_getDataValue(
vl_PTCList,
pl_source := "DataSource",
pl_ptcName := "",
pl_element := "PTCs",
pl_params := {
{
paramName := "Source",
paramValue := "UIHandler"
}
}
)) {
if (sizeof(vl_PTCList.charstringlistVal) > 0) {
// to update UIHandler progressbar:
var charstring vl_progressBarUIHandlerName;
if (0==f_EPTF_DataSourceClient_getData(
pl_dataVarName := vl_progressBarUIHandlerName,
pl_source := "UIHandler",
pl_ptcName := "",
pl_element := "progressBar",
pl_params := {}
)) {
v_ExecCtrl_progressBarUIHandler_Idx := f_EPTF_Var_getId(vl_progressBarUIHandlerName);
f_EPTF_Var_addPostProcFn(vl_progressBar_idx,{
refers(f_EPTF_ExecCtrl_progressBar_PostProc),
{vl_progressBar_idx,vl_progressBarText_idx}
});
}
}
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExeCtrl_enableUIHandlerProgress
//
// Purpose:
// Enables updates of UIHandler's progress information with ExecCtrl info
//
// Parameters:
// pl_enableProgress - *in* *boolean* - true: enable, false: disable
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExeCtrl_enableUIHandlerProgress(in boolean pl_enableProgress) runs on EPTF_ExecCtrl_CT {
v_ExecCtrl_progressEnabled := pl_enableProgress;
}
// copies the progressbar text to the UIHandler progressBar:
private function f_EPTF_ExecCtrl_progressBar_PostProc(in integer pl_idx, in EPTF_IntegerList pl_argList) runs on EPTF_ExecCtrl_CT {
if (not v_ExecCtrl_progressEnabled or v_ExecCtrl_progressBarUIHandler_Idx==-1 or v_ExecCtrl_progressBarUIHandler_updateSent) {
return;
}
var integer vl_progressBarId := pl_argList[0];
var integer vl_progressBarTextId := pl_argList[1];
f_EPTF_Var_adjustContent(
v_ExecCtrl_progressBarUIHandler_Idx,
{
charstringVal := "ExecCtrl: "&f_EPTF_Var_getCharstringValue(vl_progressBarTextId)&" "&f_EPTF_Var_getCharstringValue(vl_progressBarId)&"%"
}
);
v_ExecCtrl_progressBarUIHandler_updateSent := true;
var float vl_EPTF_ExecCtrl_timePeriodForProgressUpdate := 3.0;
var float vl_when := f_EPTF_Base_getRelTimeInSecs()+vl_EPTF_ExecCtrl_timePeriodForProgressUpdate;
var EPTF_Scheduler_ActionHandler vl_actionHandler := refers(f_EPTF_ExecCtrl_progressBarUIHandler_enabler);
var EPTF_ActionId vl_action := { }; // nothing
var integer vl_eventIndex;
if (f_EPTF_SchedulerComp_scheduleAction(
vl_when,
vl_actionHandler,
vl_action,
vl_eventIndex
)) {}; // to remove the warning
}
private function f_EPTF_ExecCtrl_progressBarUIHandler_enabler(in EPTF_ScheduledAction pl_action, in integer pl_eventIndex) runs on EPTF_ExecCtrl_CT return boolean {
v_ExecCtrl_progressBarUIHandler_updateSent := false;
return true;
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_exit_PostProc
//
// Purpose:
// Test management post proc function to exit ttcn
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_exit_PostProc(
in integer pl_idx,
in EPTF_IntegerList pl_argList)
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_exit();
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_Subscribe2ExitButton_vars
//
// Purpose:
// Subscribe variable to exit button and adds test management
// post processing functions
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_Subscribe2ExitButton_vars() runs on EPTF_ExecCtrl_CT {
// Exit button
var integer vl_idx;
f_EPTF_Var_newInt(
c_EPTF_ExecCtrl_Exit, 0, vl_idx);
f_EPTF_Var_addPostProcFn(
vl_idx, { refers(f_EPTF_ExecCtrl_exit_PostProc), {}} );
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (Exit button) name: "
&c_EPTF_ExecCtrl_Exit);
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_UIVars_startScenario_PostProc
//
// Purpose:
// Test management post proc function to start scenario
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// This is what happens when user presses the start button at widgetId
// c_EPTF_ExecCtrl_statisticsRoot&".EG."&vl_eGrpName&".SC."&vl_scTypeName&".ControlButtons.Start"
//
///////////////////////////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_UIVars_startScenario_PostProc(
in integer pl_idx,
in EPTF_IntegerList pl_argList)
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
var integer vl_scIdx := pl_argList[0];
var integer vl_startScIdx := pl_argList[1];
var integer vl_stopScIdx := pl_argList[2];
var integer vl_resetScIdx := pl_argList[3];
f_EPTF_Var_setSubsCanAdjust(vl_startScIdx,false);
f_EPTF_Var_setSubsCanAdjust(vl_stopScIdx,true);
f_EPTF_Var_setSubsCanAdjust(vl_resetScIdx,false);
// Start the scenario
f_EPTF_ExecCtrl_startScenarioOnLGens(vl_scIdx);
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_UIVars_stopScenario_PostProc
//
// Purpose:
// Test management post proc function stop scenario
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// This is what happens when user presses the stop button at widgetId
// c_EPTF_ExecCtrl_statisticsRoot&".EG."&vl_eGrpName&".SC."&vl_scTypeName&".ControlButtons.Stop"
//
///////////////////////////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_UIVars_stopScenario_PostProc(
in integer pl_idx,
in EPTF_IntegerList pl_argList)
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
var integer vl_scIdx := pl_argList[0];
var integer vl_startScIdx := pl_argList[1];
var integer vl_stopScIdx := pl_argList[2];
var integer vl_resetScIdx := pl_argList[3];
f_EPTF_Var_setSubsCanAdjust(vl_startScIdx,true);
f_EPTF_Var_setSubsCanAdjust(vl_stopScIdx,false);
f_EPTF_Var_setSubsCanAdjust(vl_resetScIdx,true);
// Start the scenario
f_EPTF_ExecCtrl_stopScenarioOnLGens(vl_scIdx);
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_UIVars_resetScenario_PostProc
//
// Purpose:
// Test management post proc function to reset scenario
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// This is what happens when user presses the reset button at widgetId
// c_EPTF_ExecCtrl_statisticsRoot&".EG."&vl_eGrpName&".SC."&vl_scTypeName&".ControlButtons.Reset"
//
///////////////////////////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_UIVars_resetScenario_PostProc(
in integer pl_idx,
in EPTF_IntegerList pl_argList)
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
var integer vl_scIdx := pl_argList[0];
var integer vl_startScIdx := pl_argList[1];
var integer vl_stopScIdx := pl_argList[2];
var integer vl_resetScIdx := pl_argList[3];
f_EPTF_Var_setSubsCanAdjust(vl_startScIdx,true);
f_EPTF_Var_setSubsCanAdjust(vl_stopScIdx,false);
f_EPTF_Var_setSubsCanAdjust(vl_resetScIdx,true);
// Reset the scenario
f_EPTF_ExecCtrl_resetScenarioOnLGens(vl_scIdx);
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_UIVars_startTc_PostProc
//
// Purpose:
// Test management post proc function to start traffic case
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// This is what happens when user presses the start button at widgetId
// c_EPTF_ExecCtrl_statisticsRoot&".EG."&vl_eGrpName&".SC."&vl_scTypeName&".ControlButtons.Start"
//
///////////////////////////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_UIVars_startTc_PostProc(
in integer pl_idx,
in EPTF_IntegerList pl_argList)
runs on EPTF_ExecCtrl_CT
{
if (not v_ExecCtrl_initialized) {
return;
}
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
var integer vl_scIdx := pl_argList[0];
var integer vl_tcOfScIdx := pl_argList[1];
var integer vl_startTcIdx := pl_argList[2];
var integer vl_stopTcIdx := pl_argList[3];
f_EPTF_Var_setSubsCanAdjust(vl_startTcIdx,false);
f_EPTF_Var_setSubsCanAdjust(vl_stopTcIdx,true);
// Start the tc
f_EPTF_ExecCtrl_startTCOnLGens(vl_scIdx,vl_tcOfScIdx);
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_UIVars_stopTc_PostProc
//
// Purpose:
// Test management post proc function stop traffic case
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// This is what happens when user presses the stop button at widgetId
// c_EPTF_ExecCtrl_statisticsRoot&".EG."&vl_eGrpName&".SC."&vl_scTypeName&".ControlButtons.Stop"
//
///////////////////////////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_UIVars_stopTc_PostProc(
in integer pl_idx,
in EPTF_IntegerList pl_argList)
runs on EPTF_ExecCtrl_CT
{
if (not v_ExecCtrl_initialized) {
return;
}
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
var integer vl_scIdx := pl_argList[0];
var integer vl_tcOfScIdx := pl_argList[1];
var integer vl_startTcIdx := pl_argList[2];
var integer vl_stopTcIdx := pl_argList[3];
f_EPTF_Var_setSubsCanAdjust(vl_startTcIdx,true);
f_EPTF_Var_setSubsCanAdjust(vl_stopTcIdx,false);
// Start the tc
f_EPTF_ExecCtrl_stopTCOnLGens(vl_scIdx,vl_tcOfScIdx);
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_UIVars_resetStatsTc_PostProc
//
// Purpose:
// Test management post proc function to reset stats of traffic case
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// Resets the following statistics: Start, Success, Fail, Timeout, Error of the traffic case
//
///////////////////////////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_UIVars_resetStatsTc_PostProc(in integer pl_idx, in EPTF_IntegerList pl_argList)
runs on EPTF_ExecCtrl_CT
{
if (not v_ExecCtrl_initialized) {
return;
}
f_EPTF_ExecCtrl_debug("### "&%definitionId&"()");
var integer vl_scIdx := pl_argList[0];
var integer vl_tcOfScIdx := pl_argList[1];
var integer vl_tcIdx := f_EPTF_ExecCtrl_getScenarioTcIdx(vl_scIdx, vl_tcOfScIdx);
// reset the stats
var integer vl_statHandlerCompIdx;
if (v_EPTF_ExecCtrl_nofExternalStatHandlers==0) {
vl_statHandlerCompIdx := 0;
} else {
vl_statHandlerCompIdx := vl_tcIdx mod v_EPTF_ExecCtrl_nofExternalStatHandlers;
}
var EPTF_StatHandler_CT vl_statHandler := v_EPTF_ExecCtrl_statHandler_comprefList[vl_statHandlerCompIdx];
var integer vl_eGrpIdx := f_EPTF_ExecCtrl_getScenarioEGroupIdx(vl_scIdx);
var charstring vl_eGrpName := f_EPTF_ExecCtrl_eGrp_name(vl_eGrpIdx);
var charstring vl_scTypeName := f_EPTF_ExecCtrl_getScenarioName(vl_scIdx);
var charstring vl_tcName := f_EPTF_ExecCtrl_tcNameOfTcOfSc(vl_scIdx,vl_tcOfScIdx)
var charstring vl_namePrefix := c_EPTF_ExecCtrl_statisticsRoot&".EG."&vl_eGrpName&".SC."&vl_scTypeName&".TC."&vl_tcName;
var charstring vl_statName;
var EPTF_IntegerList vl_statsToReset := {
c_EPTF_ExecCtrl_tcStatId_Starts,
c_EPTF_ExecCtrl_tcStatId_Success,
c_EPTF_ExecCtrl_tcStatId_Fail,
c_EPTF_ExecCtrl_tcStatId_Timeout,
c_EPTF_ExecCtrl_tcStatId_Error
}
for(var integer i:=0, size:=sizeof(vl_statsToReset);i<size;i:=i+1){
vl_statName := vl_namePrefix&"."&c_EPTF_ExecCtrl_tcStatNames[vl_statsToReset[i]];
// var EPTF_StatHandler_CT vl_statHandler := f_EPTF_ExecCtrl_findStatHandler(vl_statName);
var boolean vl_res := f_EPTF_StatHandlerClient_resetStatistics(vl_statName, vl_statHandler);
if (vl_res != true) {
f_EPTF_ExecCtrl_debug(log2str("Error reseting " & vl_statName));
}
}
}
private function f_EPTF_ExecCtrl_UIVars_resetStatsAllTc_PostProc(in integer pl_idx, in EPTF_IntegerList pl_argList)
runs on EPTF_ExecCtrl_CT
{
if (not v_ExecCtrl_initialized) {
return;
}
f_EPTF_ExecCtrl_debug("### "&%definitionId&"()");
var integer vl_sizeScen := f_EPTF_ExecCtrl_numScenarios();
var integer vl_sizeTCs;
for (var integer sidx := 0; sidx < vl_sizeScen; sidx := sidx + 1){
vl_sizeTCs := f_EPTF_ExecCtrl_numTcOfScenario(sidx);
for (var integer tcidx := 0; tcidx < vl_sizeTCs; tcidx := tcidx + 1){
f_EPTF_ExecCtrl_UIVars_resetStatsTc_PostProc(-1, {sidx, tcidx});
}
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_resetStatFunctions
//
// Purpose:
// Function to call all reset callback functions registered by ExecCtrl
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
// -
///////////////////////////////////////////////////////////
// TR HR20548 - Reset All statistics button
private function f_EPTF_ExecCtrl_resetStatFunctions()
runs on EPTF_ExecCtrl_CT
{
if (not v_ExecCtrl_initialized) {
return;
}
var EPTF_Var_DirectContent vl_currentContent;
var charstring vl_eGrpName;
var charstring vl_scTypeName;
var charstring vl_tcName;
var charstring vl_namePrefix;
var charstring vl_statName;
var EPTF_TopProviderType vl_providerType;
var EPTF_IntegerList vl_auxVarList;
var integer vl_nrOfSources;
f_EPTF_ExecCtrl_debug("### "&%definitionId&"()");
// LGenList: v_ExecCtrl_lgens
var integer vl_nOfLGens := sizeof(v_ExecCtrl_lgens);
for(var integer vl_lgenIdx:=0;vl_lgenIdx<vl_nOfLGens;vl_lgenIdx:=vl_lgenIdx+1){
ExecCtrl_MgmtIf_CP.send(EPTF_ExecCtrl_ResetStats:{})
to f_EPTF_Base_downcast(v_ExecCtrl_lgens[vl_lgenIdx].lgenCompRef);
}
// // go through all scenarios:
// var integer vl_sizeScen := f_EPTF_ExecCtrl_numScenarios();
// var integer vl_sizeTCs;
//
// for (var integer sidx := 0; sidx < vl_sizeScen; sidx := sidx + 1){
// var integer vl_eGrpIdx := f_EPTF_ExecCtrl_getScenarioEGroupIdx(sidx);
// vl_eGrpName := f_EPTF_ExecCtrl_eGrp_name(vl_eGrpIdx);
// vl_scTypeName := f_EPTF_ExecCtrl_getScenarioName(sidx);
// vl_sizeTCs := f_EPTF_ExecCtrl_numTcOfScenario(sidx);
// for (var integer tcidx := 0; tcidx < vl_sizeTCs; tcidx := tcidx + 1){
// vl_tcName := f_EPTF_ExecCtrl_tcNameOfTcOfSc(sidx,tcidx)
// vl_namePrefix := c_EPTF_ExecCtrl_statisticsRoot&".EG."&vl_eGrpName&".SC."&vl_scTypeName&".TC."&vl_tcName;
// // all integer stats except CurrentCPS and ExecTime
// for(var integer st:=0, size := sizeof(c_EPTF_ExecCtrl_tcStatNames); st<size;st:=st+1) {
// if (st==c_EPTF_ExecCtrl_tcStatId_CurrentCPS
// or st==c_EPTF_ExecCtrl_tcStatId_ExecTime) {
// continue; // they are handled differently
// }
// vl_statName := vl_namePrefix&"."&c_EPTF_ExecCtrl_tcStatNames[st];
//
// var EPTF_StatHandler_CT vl_statHandler := f_EPTF_ExecCtrl_findStatHandler(vl_statName);
// f_EPTF_StatHandlerClient_resetStatistics(vl_statName,vl_statHandler);
// }
// }
// }
//
// // get statList: v_ExecCtrl_FSMStats
// var charstring vl_shName;
// var EPTF_StatHandler_StatMethod vl_statMethod;
// var EPTF_Var_DirectContent vl_resetValue;
//
// // for each stat
// for(var integer i:=0, size := sizeof(v_ExecCtrl_FSMStats); i<size;i:=i+1) {
// vl_eGrpName:=v_ExecCtrl_FSMStats[i].entityGroup;
// vl_scTypeName:=v_ExecCtrl_FSMStats[i].scenario;
// vl_tcName:=v_ExecCtrl_FSMStats[i].tc;
//
// for(var integer st:=0, ssize := sizeof(v_ExecCtrl_FSMStats[i].stats); st<ssize;st:=st+1) {
// vl_statName := v_ExecCtrl_FSMStats[i].stats[st].declaredName;
// // reset stat:
// f_EPTF_ExecCtrl_resetFSMStat(vl_eGrpName,vl_scTypeName,vl_tcName,vl_statName);
// }
// }
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_resetFSMStat
//
// Purpose:
// Resets a given fsmStat
//
// Parameters:
// - pl_eGrpName - *in charstring* - the entityGroup name
// - pl_scenName - *in charstring* - the scenarioName
// - pl_tcName - *in charstring* - name of the trafficCase
// - pl_fsmStatName - *in charstring* - name of the fsm stat
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// The list of available FSM stats is given by the iterator
// <c_ExecCtrl_iteratorFSMStats>
// Only the min/max/sum method stats will be reset
// (For the others that are complex calculated stats coming from StatHandler
// reset is not supported yet, see <f_EPTF_StatHandler_resetStatistics>)
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_resetFSMStat(
in charstring pl_eGrpName,
in charstring pl_scTypeName,
in charstring pl_tcName,
in charstring pl_fsmStatName
) runs on EPTF_ExecCtrl_CT {
// reset stat on ExecCtrl
var charstring vl_statName := c_EPTF_ExecCtrl_statisticsRoot&".EG."&pl_eGrpName&".SC."&pl_scTypeName&".TC."&pl_tcName&".FSMStats."&pl_fsmStatName;
var EPTF_StatHandler_CT vl_statHandler := f_EPTF_ExecCtrl_findStatHandler(vl_statName);
if (vl_statHandler!=null) {
f_EPTF_StatHandlerClient_resetStatistics(vl_statName,vl_statHandler);
}
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_UIVars_resetFSMStatsTc_PostProc
//
// Purpose:
// Test management post proc function to reset FSM stats of traffic case
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// Resets the FSM statistics of the traffic case
//
///////////////////////////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_UIVars_resetFSMStatsTc_PostProc(in integer pl_idx, in EPTF_IntegerList pl_argList)
runs on EPTF_ExecCtrl_CT
{
if (not v_ExecCtrl_initialized) {
return;
}
f_EPTF_ExecCtrl_debug("### "&%definitionId&"()");
var integer vl_scIdx := pl_argList[0];
var integer vl_tcOfScIdx := pl_argList[1];
var integer vl_eGrpIdx := f_EPTF_ExecCtrl_getScenarioEGroupIdx(vl_scIdx);
var charstring vl_eGrpName := f_EPTF_ExecCtrl_eGrp_name(vl_eGrpIdx);
var charstring vl_scTypeName := f_EPTF_ExecCtrl_getScenarioName(vl_scIdx);
var charstring vl_tcName := f_EPTF_ExecCtrl_tcNameOfTcOfSc(vl_scIdx,vl_tcOfScIdx)
var charstring vl_statName;
// get statList: v_ExecCtrl_FSMStats
var charstring vl_fsmStatVarName := c_ExecCtrl_DS_iteratorVar_prefix & c_ExecCtrl_iteratorFSMStats_varName & "." & vl_eGrpName & "." & vl_scTypeName & "." & vl_tcName;
var integer vl_fsmStatsId := f_EPTF_Var_getId(vl_fsmStatVarName);
var EPTF_CharstringList vl_fsmStats := f_EPTF_Var_getCharstringlistValue(vl_fsmStatsId);
// for each stat
for(var integer i:=0, size := sizeof(vl_fsmStats); i<size;i:=i+1) {
// reset stat:
f_EPTF_ExecCtrl_resetFSMStat(vl_eGrpName,vl_scTypeName,vl_tcName,vl_fsmStats[i]);
}
}
private function f_EPTF_ExecCtrl_UIVars_resetFSMStatsAllTc_PostProc(in integer pl_idx, in EPTF_IntegerList pl_argList)
runs on EPTF_ExecCtrl_CT
{
if (not v_ExecCtrl_initialized) {
return;
}
f_EPTF_ExecCtrl_debug("### "&%definitionId&"()");
var integer vl_sizeScen := f_EPTF_ExecCtrl_numScenarios();
var integer vl_sizeTCs;
for (var integer sidx := 0; sidx < vl_sizeScen; sidx := sidx + 1){
vl_sizeTCs := f_EPTF_ExecCtrl_numTcOfScenario(sidx);
for (var integer tcidx := 0; tcidx < vl_sizeTCs; tcidx := tcidx + 1){
f_EPTF_ExecCtrl_UIVars_resetFSMStatsTc_PostProc(-1, {sidx, tcidx});
}
}
}
// calculates the StatusLED for the group finish condition state
friend function f_EPTF_ExecCtrl_UIVars_getLEDForGroupFinish(
in integer pl_tcIdx,
in EPTF_ExecCtrl_GrpFinishConditionType pl_conditionType := c_EPTF_ExecCtrl_groupFinishConditionUnknown
) runs on EPTF_ExecCtrl_CT return EPTF_StatusLED
{
var EPTF_StatusLED vl_statusLED := {color := led_blue, text := "None fired"};
if (f_EPTF_ExecCtrl_checkOnGroupFinished(pl_tcIdx,pl_conditionType)) {
vl_statusLED.color := led_red;
// check if onGroupFinish is fired:
if (pl_conditionType==c_EPTF_ExecCtrl_groupFinishConditionUnknown) {
vl_statusLED.text := "OnGroupFinish fired"
} else if (pl_conditionType==c_EPTF_ExecCtrl_groupFinish_ExecTime) {
vl_statusLED.text := "ExecTime fired"
} else if (pl_conditionType==c_EPTF_ExecCtrl_groupFinish_RangeLoops) {
vl_statusLED.text := "RangeLoops fired"
} else if (pl_conditionType==c_EPTF_ExecCtrl_groupFinish_EntitiesFinished) {
vl_statusLED.text := "EntitiesFinished fired"
} else if (pl_conditionType==c_EPTF_ExecCtrl_groupFinish_AvailableEntitiesFinished) {
vl_statusLED.text := "AvailableEntitiesFinished fired"
} else if (pl_conditionType==c_EPTF_ExecCtrl_groupFinish_Custom) {
vl_statusLED.text := "Custom fired"
} else {
vl_statusLED.text := c_EPTF_ExecCtrl_nameOfVarsInLGen[pl_conditionType]&" fired"
}
}
return vl_statusLED;
}
// creates TC entity stats using the statHandler API for the traffic case
private function f_EPTF_ExecCtrl_UIVars_createStatsForTc_vars(in integer pl_tcIdx)
runs on EPTF_ExecCtrl_CT {
var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioIdxForTc(pl_tcIdx);
var integer vl_tcOfScenarioIdx := f_EPTF_ExecCtrl_getTcOfScenarioIdx(pl_tcIdx);
var integer vl_eGrpIdx := f_EPTF_ExecCtrl_getScenarioEGroupIdx(vl_scIdx);
var charstring vl_eGrpName := f_EPTF_ExecCtrl_eGrp_name(vl_eGrpIdx);
var charstring vl_scTypeName := f_EPTF_ExecCtrl_getScenarioName(vl_scIdx);
var charstring vl_tcName := f_EPTF_ExecCtrl_tcNameOfTcOfSc(vl_scIdx,vl_tcOfScenarioIdx)
var charstring vl_namePrefix := c_EPTF_ExecCtrl_statisticsRoot&".EG."&vl_eGrpName&".SC."&vl_scTypeName&".TC."&vl_tcName;
var charstring vl_statName;
// declare stats:
f_EPTF_ExecCtrl_debug("Declaring TC statistics for "&vl_namePrefix);
// CurrentCPS:
vl_statName := vl_namePrefix&"."&c_EPTF_ExecCtrl_tcStatNames[c_EPTF_ExecCtrl_tcStatId_CurrentCPS]; // c_EPTF_ExecCtrl_tcStatId_CurrentCPS == 0
v_EPTF_ExecCtrl_statHandler_autoSelector := pl_tcIdx; // use same StatHandler for the Stats of the same TC
if (not f_EPTF_ExecCtrl_StatHandlerClient_declareStat(
pl_statName := vl_statName,
pl_statMethod := c_EPTF_StatHandler_Method_Sum,
pl_statResetValue := {floatVal := 0.0}
)) {
f_EPTF_ExecCtrl_error(log2str(%definitionId&": Cannot declare Statistics: ", vl_statName));
} else {
}
// all integer stats except CurrentCPS and ExecTime
for(var integer st:=0, size := sizeof(c_EPTF_ExecCtrl_tcStatNames); st<size;st:=st+1) {
if (st==c_EPTF_ExecCtrl_tcStatId_CurrentCPS
or st==c_EPTF_ExecCtrl_tcStatId_ExecTime) {
continue; // they are handled differently
}
vl_statName := vl_namePrefix&"."&c_EPTF_ExecCtrl_tcStatNames[st];
v_EPTF_ExecCtrl_statHandler_autoSelector := pl_tcIdx; // use same StatHandler for the Stats of the same TC
if(not f_EPTF_ExecCtrl_StatHandlerClient_declareStat(
pl_statName := vl_statName,
pl_statMethod := c_EPTF_StatHandler_Method_Sum,
pl_statResetValue := {intVal := 0}
)) {
f_EPTF_ExecCtrl_error(log2str(%definitionId&": Cannot declare Statistics: ", vl_statName));
} else {
}
}
var EPTF_Var_SubscriptionMode vl_subscriptionModeForStats := sampledAtSync;
if (v_ExecCtrl_usePullModeForStats) {
vl_subscriptionModeForStats := pull;
}
var EPTF_Var_SubscriptionMode vl_subscriptionModeForVars := sampled;
if (v_ExecCtrl_usePullModeForStats) {
vl_subscriptionModeForVars := pull;
}
// register sources:
// name of source variable on the LGen:
var charstring vl_lgenDataSourceVarName := f_EPTF_LGenBaseStats_getNamePrefix(vl_eGrpName,vl_scTypeName,vl_tcName);
var EPTF_ExecCtrl_EntityGroupDistributionList vl_lgenList := f_EPTF_ExecCtrl_eGrp_lgenList(vl_eGrpIdx);
for(var integer lg:=0, size := sizeof(vl_lgenList); lg<size;lg:=lg+1) {
if (vl_lgenList[lg].eCount == 0) {
continue; // do not send packet to LGen if there is no entity on the LGen
}
var integer vl_lgenIdx := vl_lgenList[lg].lgenIdx;
// CurrentCPS
vl_statName := vl_namePrefix&"."&c_EPTF_ExecCtrl_tcStatNames[c_EPTF_ExecCtrl_tcStatId_CurrentCPS]; // c_EPTF_ExecCtrl_tcStatId_CurrentCPS == 0
if (not f_EPTF_ExecCtrl_StatHandlerClient_registerStat(
pl_providerVarList := {vl_lgenDataSourceVarName&c_EPTF_ExecCtrl_tcStatVarNamesInLGen[c_EPTF_ExecCtrl_tcStatId_CurrentCPS]},
pl_statName := vl_statName,
pl_subscriptionMode := vl_subscriptionModeForStats,
pl_wait4response := true,//tsp_EPTF_ExecCtrl_StatHandler_wait4response,
pl_sourceCompRef := f_EPTF_Var_downcast(f_EPTF_Base_downcast(f_EPTF_ExecCtrl_getLGenCompRef(vl_lgenIdx))),
pl_refreshRate := 0//v_ExecCtrl_UIVars_refreshRate_currentCPS
)) {/*cannot happen*/};
// all integer stats
for(var integer st:=0, tsize := sizeof(c_EPTF_ExecCtrl_tcStatNames); st<tsize;st:=st+1) {
if (st==c_EPTF_ExecCtrl_tcStatId_CurrentCPS
or st==c_EPTF_ExecCtrl_tcStatId_ExecTime) {
continue; // they are handled differently
}
vl_statName := vl_namePrefix&"."&c_EPTF_ExecCtrl_tcStatNames[st];
if (not f_EPTF_ExecCtrl_StatHandlerClient_registerStat(
pl_providerVarList := {vl_lgenDataSourceVarName&c_EPTF_ExecCtrl_tcStatVarNamesInLGen[st]},
pl_statName := vl_statName,
pl_subscriptionMode := vl_subscriptionModeForStats,
pl_wait4response := true,//tsp_EPTF_ExecCtrl_StatHandler_wait4response,
pl_sourceCompRef := f_EPTF_Var_downcast(f_EPTF_Base_downcast(f_EPTF_ExecCtrl_getLGenCompRef(vl_lgenIdx))),
pl_refreshRate := 0//v_ExecCtrl_UIVars_refreshRate_TCStats
)) {/*cannot happen*/};
}
}
// {Delta statistics}: all delta stats - Create new StatMeasure
for(var integer st:=0, size := sizeof(c_EPTF_ExecCtrl_tcDeltaStatVarIds); st<size;st:=st+1) {
var integer vl_tcDeltaStatVarId := c_EPTF_ExecCtrl_tcDeltaStatVarIds[st];
var charstring vl_varBaseName := vl_namePrefix&"."&c_EPTF_ExecCtrl_tcStatNames[vl_tcDeltaStatVarId];
var charstring vl_statBaseName := vl_varBaseName;
var EPTF_StatHandler_CT vl_statHandler := f_EPTF_ExecCtrl_findStatHandler(vl_varBaseName);
if (vl_statHandler != self) {
// wait until war exists:
timer t_wait := 0.5;
var boolean vl_present := false;
while(true) {
if (f_EPTF_Var_isPresentRemote(vl_statHandler,vl_varBaseName)) {
break;
} else {
t_wait.start;
t_wait.timeout;
}
}
var integer vl_idx;
f_EPTF_Var_subscribeRemote(
pl_remoteCompRef := vl_statHandler,
pl_remoteProviderVarName := vl_varBaseName,
pl_subscriptionMode := vl_subscriptionModeForVars,
pl_idx := vl_idx,
pl_localName := vl_varBaseName&"_Local"
);
vl_varBaseName := f_EPTF_Var_getName(vl_idx);
}
var charstring vl_varDeltaName := vl_statBaseName&".delta";
var integer vl_varBaseId := f_EPTF_Var_getId(vl_varBaseName);
if(vl_varBaseId<0) {
f_EPTF_ExecCtrl_error(log2str(%definitionId&": Cannot declare delta Statistics - base variable Id not found: ", vl_varDeltaName,"->",vl_varBaseName));
} else {
var integer vl_statDeltaId := f_EPTF_StatMeasure_newStat_delta();
if(vl_statDeltaId<0) {
f_EPTF_ExecCtrl_error(log2str(%definitionId&": Cannot declare delta Statistics: ", vl_varDeltaName));
} else {
f_EPTF_StatMeasure_addData_delta(vl_statDeltaId,{intVal := 0});
var integer vl_deltaStatVarId := f_EPTF_StatMeasure_createVarFromStat(vl_statDeltaId, vl_varDeltaName);
if(vl_deltaStatVarId<0){
f_EPTF_ExecCtrl_error(log2str(%definitionId&": Cannot declare delta Statistics - create Var From Stat fail: ", vl_varDeltaName));
} else {
// add Scheduler that updates the stat periodically:
f_EPTF_ExecCtrl_registerUpdateEventForTc_delta_Stat(pl_tcIdx,vl_statDeltaId, vl_varBaseId);
}
}
}
}
//request GoS from StatManager so that getData handler would not block when GoS is requested
var charstring pl_dataVarName;
var charstring vl_nofSuccVarName,vl_nofFailVarName,vl_nofTimeoutVarName,vl_nofErrorVarName;
vl_nofSuccVarName := c_EPTF_ExecCtrl_statisticsRoot&".EG."&vl_eGrpName&".SC."&vl_scTypeName&".TC."&vl_tcName&"."&c_EPTF_ExecCtrl_tcStatNames[c_EPTF_ExecCtrl_tcStatId_Success]
vl_nofFailVarName := c_EPTF_ExecCtrl_statisticsRoot&".EG."&vl_eGrpName&".SC."&vl_scTypeName&".TC."&vl_tcName&"."&c_EPTF_ExecCtrl_tcStatNames[c_EPTF_ExecCtrl_tcStatId_Fail]
vl_nofErrorVarName := c_EPTF_ExecCtrl_statisticsRoot&".EG."&vl_eGrpName&".SC."&vl_scTypeName&".TC."&vl_tcName&"."&c_EPTF_ExecCtrl_tcStatNames[c_EPTF_ExecCtrl_tcStatId_Error]
vl_nofTimeoutVarName := c_EPTF_ExecCtrl_statisticsRoot&".EG."&vl_eGrpName&".SC."&vl_scTypeName&".TC."&vl_tcName&"."&c_EPTF_ExecCtrl_tcStatNames[c_EPTF_ExecCtrl_tcStatId_Timeout]
var charstring vl_statManagerPTCName := f_EPTF_Base_selfName();
if (v_EPTF_ExecCtrl_nofExternalStatHandlers>0) {
vl_statManagerPTCName := "ExecCtrl_ExternalStatHandler_Comp_"&log2str(pl_tcIdx mod v_EPTF_ExecCtrl_nofExternalStatHandlers)
}
if (0 != f_EPTF_DataSourceClient_getData(
pl_dataVarName := pl_dataVarName,
pl_source := "StatManager",
pl_ptcName := vl_statManagerPTCName,
pl_element := "GoS",
pl_params := {
{paramName := "SuccessVarName", paramValue := vl_nofSuccVarName},
{paramName := "FailVarName", paramValue := vl_nofFailVarName},
{paramName := "TimeoutVarName", paramValue := vl_nofTimeoutVarName},
{paramName := "ErrorVarName", paramValue := vl_nofErrorVarName}
}
)) {
pl_dataVarName := "GoS does not exist"
}
}
// creates scheduled event for TC entity stat deltas using the statHandler API for the traffic case
private function f_EPTF_ExecCtrl_registerUpdateEventForTc_delta_Stat(in integer pl_tcIdx, in integer pl_statisticsId, in integer pl_variableId)
runs on EPTF_ExecCtrl_CT {
if(vl_eventIndexUpdateEvent==-1){
var float vl_when := f_EPTF_Base_getRelTimeInSecs()+v_EPTF_ExecCtrl_timePeriodForTcDeltaStats;
var EPTF_Scheduler_ActionHandler vl_actionHandler := refers(f_EPTF_ExecCtrl_updateDeltaStatVarForTcSyncCallBack);
var EPTF_ActionId vl_action := { 0 }; // nothing
var integer vl_eventIndex;
if (f_EPTF_SchedulerComp_scheduleAction(
vl_when,
vl_actionHandler,
vl_action,
vl_eventIndex
)) {}; // to remove the warning
// store event idx:
vl_eventIndexUpdateEvent := vl_eventIndex;
}
f_EPTF_Base_assert(%definitionId&": Invalid index "&int2str(pl_tcIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_trafficCases))&").",
pl_tcIdx >= 0 and pl_tcIdx < sizeof(v_ExecCtrl_trafficCases));
// Put it into table
var integer vl_nextIdx := sizeof(v_ExecCtrl_trafficCases[pl_tcIdx].deltaStatList);
v_ExecCtrl_trafficCases[pl_tcIdx].deltaStatList[vl_nextIdx] := {pl_statisticsId, pl_variableId};
}
// the function that updates the delta stats pl_argList[0] : the statId
private function f_EPTF_ExecCtrl_updateDeltaStatVarForTcSyncCallBack(in EPTF_ScheduledAction pl_action, in integer pl_eventIndex) runs on EPTF_ExecCtrl_CT return boolean {
var boolean vl_ret := f_EPTF_Base_cleanupIsInProgress();
if(vl_ret == true){
// all down the line
for(var integer idx:=0, size := sizeof(v_ExecCtrl_trafficCases); idx<size;idx:=idx+1){
// If Running
var boolean vl_tcStatus := f_EPTF_ExecCtrl_isTcRunning(idx);
if(vl_tcStatus == true){
for(var integer st:=0, dsize := sizeof(v_ExecCtrl_trafficCases[idx].deltaStatList); st<dsize;st:=st+1){
var integer vl_statisticsId := v_ExecCtrl_trafficCases[idx].deltaStatList[st].statisticsId;
var integer vl_variableId := v_ExecCtrl_trafficCases[idx].deltaStatList[st].variableId;
var integer vl_variableValue := f_EPTF_Var_getIntValue(vl_variableId);
f_EPTF_StatMeasure_addData_delta(vl_statisticsId,{intVal := vl_variableValue});
}
}
}
var float vl_when := pl_action.when + v_EPTF_ExecCtrl_timePeriodForTcDeltaStats;
var EPTF_Scheduler_ActionHandler vl_actionHandler := refers(f_EPTF_ExecCtrl_updateDeltaStatVarForTcSyncCallBack);
var EPTF_ActionId vl_action := { 0 }; // nothing
var integer vl_eventIndex;
if (f_EPTF_SchedulerComp_scheduleAction(
vl_when,
vl_actionHandler,
vl_action,
vl_eventIndex
)) {}; // to remove the warning
// store event idx:
vl_eventIndexUpdateEvent := vl_eventIndex;
}
return(vl_ret);
}
// creates Global stats using the statHandler API
private function f_EPTF_ExecCtrl_UIVars_createGlobalStats_vars()
runs on EPTF_ExecCtrl_CT {
// create itertor var which contains all global stats:
var integer vl_idx;
f_EPTF_Var_newCharstringlist(c_ExecCtrl_DS_iteratorVar_prefix & c_ExecCtrl_iteratorGlobalStats_varName, c_EPTF_ExecCtrl_globalStatNames, vl_idx);
// declare all global stats:
// all integer global stats
for(var integer st:=0, size := sizeof(c_EPTF_ExecCtrl_globalStatNames); st<size;st:=st+1) {
var charstring vl_globalStatName := c_EPTF_ExecCtrl_globalStatNames[st];
var charstring vl_globalStatNameFull := c_EPTF_ExecCtrl_statisticsRoot&"."&vl_globalStatName;
if(not f_EPTF_ExecCtrl_StatHandlerClient_declareStat(
pl_statName := vl_globalStatNameFull,
pl_statMethod := c_EPTF_StatHandler_Method_Sum,
pl_statResetValue := {intVal := 0}
)) {
f_EPTF_ExecCtrl_error(log2str(%definitionId&": Cannot declare Statistics: ", vl_globalStatName));
}
}
var EPTF_Var_SubscriptionMode vl_subscriptionModeForStats := sampledAtSync;
if (v_ExecCtrl_usePullModeForStats) {
vl_subscriptionModeForStats := pull;
}
var EPTF_Var_SubscriptionMode vl_subscriptionModeForVars := sampled;
if (v_ExecCtrl_usePullModeForStats) {
vl_subscriptionModeForVars := pull;
}
// register sources:
for(var integer st:=0, size := sizeof(c_EPTF_ExecCtrl_globalStatNames); st<size;st:=st+1) {
var charstring vl_globalStatName := c_EPTF_ExecCtrl_globalStatNames[st];
// have to sum all values => go through all TC-s:
for(var integer tc:=0, tsize := sizeof(v_ExecCtrl_trafficCases); tc<tsize;tc :=tc+1) {
var integer sc := v_ExecCtrl_trafficCases[tc].scenarioIdx;
var charstring vl_entityGrpName := v_ExecCtrl_entityGroups[v_ExecCtrl_scenarios[sc].eGroupIdx].name;
var charstring vl_scName := v_ExecCtrl_scenarios[sc].scData.name;
var charstring vl_tcName := v_ExecCtrl_scenarios[sc].scData.tcList[v_ExecCtrl_trafficCases[tc].tcOfScenarioIdx].tcPrivateName;
// name of source variable:
var charstring vl_dataVarName;
var charstring vl_statName := c_EPTF_ExecCtrl_statisticsRoot&".EG."&vl_entityGrpName&".SC."&vl_scName&".TC."&vl_tcName&"."&vl_globalStatName;
var EPTF_StatHandler_CT vl_statHandler := f_EPTF_ExecCtrl_findStatHandler(vl_statName);
if (vl_statHandler!=self) {
f_EPTF_Var_subscribeRemote(
pl_remoteCompRef := vl_statHandler,
pl_remoteProviderVarName := vl_statName,
pl_subscriptionMode := vl_subscriptionModeForVars,
pl_idx := vl_idx,
pl_localName := vl_statName&"_Local"
);
if (vl_idx==-1) {
f_EPTF_ExecCtrl_warning(%definitionId& ": Statistic doesn't exist: "&vl_statName);
continue;
}
vl_dataVarName := f_EPTF_Var_getName(vl_idx);
} else {
if (not f_EPTF_StatHandler_getVarNameByStatName(vl_statName, vl_dataVarName)){
f_EPTF_ExecCtrl_warning(%definitionId& ": Statistic doesn't exist: "&vl_statName);
continue;
}
}
var charstring vl_globalStatNameFull := c_EPTF_ExecCtrl_statisticsRoot&"."&vl_globalStatName;
if (not f_EPTF_ExecCtrl_StatHandlerClient_registerStat(
pl_providerVarList := {vl_dataVarName},
pl_statName := vl_globalStatNameFull,
pl_subscriptionMode := vl_subscriptionModeForStats,
pl_wait4response := true,//tsp_EPTF_ExecCtrl_StatHandler_wait4response,
pl_sourceCompRef := self,
pl_refreshRate := 0//v_ExecCtrl_UIVars_refreshRate_TCStats
)) {/*cannot happen*/};
}
}
}
// Test Case is Runing?
friend function f_EPTF_ExecCtrl_isTcRunning(in integer pl_tcIdx) runs on EPTF_ExecCtrl_CT return boolean {
var boolean vl_ret := false;
var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioIdxForTc(pl_tcIdx);
var integer vl_tcOfScenarioIdx := f_EPTF_ExecCtrl_getTcOfScenarioIdx(pl_tcIdx);
var integer vl_eGrpIdx := f_EPTF_ExecCtrl_getScenarioEGroupIdx(vl_scIdx);
var charstring vl_eGrpName := f_EPTF_ExecCtrl_eGrp_name(vl_eGrpIdx);
var charstring vl_scTypeName := f_EPTF_ExecCtrl_getScenarioName(vl_scIdx);
var charstring vl_tcName := f_EPTF_ExecCtrl_tcNameOfTcOfSc(vl_scIdx,vl_tcOfScenarioIdx)
var EPTF_ExecCtrl_TCName vl_idName := {vl_eGrpName,vl_scTypeName,vl_tcName};
vl_ret := f_EPTF_ExecCtrl_checkTrafficCaseStatus(vl_idName,
c_EPTF_LGenBase_stateNames[c_EPTF_LGenBase_tcStateRunning]);
return(vl_ret);
}
friend function f_EPTF_ExecCtrl_UIVars_tcStatId2GrpFinishConditionType(
in EPTF_ExecCtrl_TcStatId pl_tcStatId
) return EPTF_ExecCtrl_GrpFinishConditionType {
if (pl_tcStatId==c_EPTF_ExecCtrl_tcStatId_RangeLoops) {
return c_EPTF_ExecCtrl_groupFinish_RangeLoops;
}
if (pl_tcStatId==c_EPTF_ExecCtrl_tcStatId_FinTraffic) {
return c_EPTF_ExecCtrl_groupFinish_EntitiesFinished;
}
if (pl_tcStatId==c_EPTF_ExecCtrl_tcStatId_ExecTime) {
return c_EPTF_ExecCtrl_groupFinish_ExecTime;
}
if (pl_tcStatId==c_EPTF_ExecCtrl_tcStatId_Unknown
or pl_tcStatId<c_EPTF_ExecCtrl_tcStatId_Starts
or pl_tcStatId>c_EPTF_ExecCtrl_tcStatId_Error) {
return c_EPTF_ExecCtrl_groupFinishConditionUnknown;
}
// the rest are in the same order: simply subtracting the offset of Starts works:
return pl_tcStatId - c_EPTF_ExecCtrl_tcStatId_Starts;
}
friend function f_EPTF_ExecCtrl_UIVars_getLEDForGroupFinishCond(
in integer pl_tcIdx,
in EPTF_ExecCtrl_GrpFinishConditionType pl_conditionType
) runs on EPTF_ExecCtrl_CT return EPTF_StatusLED {
var EPTF_StatusLED vl_EPTF_StatusLED := c_EPTF_ExecCtrl_UIVars_GroupFinishCondStatusLED_init;
// if condition is monitored: set text to the threshold
var integer vl_threshold := f_EPTF_ExecCtrl_getThreshold(pl_tcIdx,pl_conditionType);
if (vl_threshold!=-1) {
vl_EPTF_StatusLED.text := int2str(vl_threshold);
vl_EPTF_StatusLED.color := led_blue;
}
var float vl_thresholdFloat := f_EPTF_ExecCtrl_getThresholdFloat(pl_tcIdx,pl_conditionType);
if (vl_thresholdFloat>=0.0) {
vl_EPTF_StatusLED.text := float2str(vl_thresholdFloat);
vl_EPTF_StatusLED.color := led_blue;
}
var boolean vl_thresholdBoolean := f_EPTF_ExecCtrl_getThresholdBoolean(pl_tcIdx,pl_conditionType);
if (vl_thresholdBoolean) {
vl_EPTF_StatusLED.text := "On";
vl_EPTF_StatusLED.color := led_blue;
}
// if pl_conditionType condition is fired: set color to red if the condition is monitored
if (vl_EPTF_StatusLED.color == led_blue
and f_EPTF_ExecCtrl_checkOnGroupFinished(pl_tcIdx,pl_conditionType)
and pl_conditionType != c_EPTF_ExecCtrl_groupFinishConditionUnknown) {
vl_EPTF_StatusLED.color := led_red
}
return vl_EPTF_StatusLED;
}
private function f_EPTF_ExecCtrl_UIVars_createVarsForGroupFinishCondStatusLEDsForTc_vars(in integer pl_tcIdx) runs on EPTF_ExecCtrl_CT {
var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioIdxForTc(pl_tcIdx);
var integer vl_tcOfScenarioIdx := f_EPTF_ExecCtrl_getTcOfScenarioIdx(pl_tcIdx);
var integer vl_eGrpIdx := f_EPTF_ExecCtrl_getScenarioEGroupIdx(vl_scIdx);
var charstring vl_eGrpName := f_EPTF_ExecCtrl_eGrp_name(vl_eGrpIdx);
var charstring vl_scTypeName := f_EPTF_ExecCtrl_getScenarioName(vl_scIdx);
var charstring vl_tcName := f_EPTF_ExecCtrl_tcNameOfTcOfSc(vl_scIdx,vl_tcOfScenarioIdx)
var charstring vl_namePrefix := c_EPTF_ExecCtrl_statisticsRoot&".EG."&vl_eGrpName&".SC."&vl_scTypeName&".TC."&vl_tcName;
var charstring vl_currentName; // name of variable to connect
var charstring vl_widgetId; // name of widgetId to connect to
var integer vl_idx; // index of vars
// create GroupFinishCondStatusLED for all groupFinisih conditions:
for(var integer st:=0, size := sizeof(c_EPTF_ExecCtrl_tcStatNames); st<size;st:=st+1) {
var EPTF_ExecCtrl_GrpFinishConditionType vl_grpFinishConditionType := f_EPTF_ExecCtrl_UIVars_tcStatId2GrpFinishConditionType(st);
if (vl_grpFinishConditionType == c_EPTF_ExecCtrl_groupFinishConditionUnknown) {
continue; // no conditions for these stats
}
// GroupFinishCondStatusLED:
vl_widgetId := vl_namePrefix&".GroupFinishCondStatusLED."&c_EPTF_ExecCtrl_tcStatNames[st];
vl_currentName := vl_widgetId;
f_EPTF_Var_newStatusLED(
vl_currentName,
f_EPTF_ExecCtrl_UIVars_getLEDForGroupFinishCond(pl_tcIdx,vl_grpFinishConditionType),
vl_idx);
f_EPTF_Var_setSubsCanAdjust(vl_idx,false);
}
}
private function f_EPTF_ExecCtrl_UIVars_singleShotPostProc(
in integer pl_idx,
in EPTF_IntegerList pl_argList)
runs on EPTF_ExecCtrl_CT
{
if (not v_ExecCtrl_initialized) {
return;
}
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
var integer vl_tcIdx := pl_argList[0];
var integer vl_eIdx_Idx := pl_argList[1];
var integer vl_enableLog_Idx := pl_argList[2];
var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioIdxForTc(vl_tcIdx);
var integer vl_tcOfScenarioIdx := f_EPTF_ExecCtrl_getTcOfScenarioIdx(vl_tcIdx);
var integer vl_eGrpIdx := f_EPTF_ExecCtrl_getScenarioEGroupIdx(vl_scIdx);
var charstring vl_eGrpName := f_EPTF_ExecCtrl_eGrp_name(vl_eGrpIdx);
var charstring vl_scTypeName := f_EPTF_ExecCtrl_getScenarioName(vl_scIdx);
var charstring vl_tcName := f_EPTF_ExecCtrl_tcNameOfTcOfSc(vl_scIdx,vl_tcOfScenarioIdx);
var integer vl_eIdx := f_EPTF_Var_getIntValue(vl_eIdx_Idx);
var boolean vl_enableLog := f_EPTF_Var_getBoolValue(vl_enableLog_Idx);
f_EPTF_ExecCtrl_singleShotTc(vl_tcIdx,vl_eIdx,vl_enableLog);
}
private function f_EPTF_ExecCtrl_UIVars_connectVarsToStatisticsTabForTc_vars(in integer pl_tcIdx)
runs on EPTF_ExecCtrl_CT {
var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioIdxForTc(pl_tcIdx);
var integer vl_tcOfScenarioIdx := f_EPTF_ExecCtrl_getTcOfScenarioIdx(pl_tcIdx);
var integer vl_eGrpIdx := f_EPTF_ExecCtrl_getScenarioEGroupIdx(vl_scIdx);
var charstring vl_eGrpName := f_EPTF_ExecCtrl_eGrp_name(vl_eGrpIdx);
var charstring vl_scTypeName := f_EPTF_ExecCtrl_getScenarioName(vl_scIdx);
var charstring vl_tcName := f_EPTF_ExecCtrl_tcNameOfTcOfSc(vl_scIdx,vl_tcOfScenarioIdx)
var charstring vl_namePrefix := c_EPTF_ExecCtrl_statisticsRoot&".EG."&vl_eGrpName&".SC."&vl_scTypeName&".TC."&vl_tcName;
var charstring vl_currentName; // name of variable to connect
var charstring vl_widgetId; // name of widgetId to connect to
var integer vl_eIdx_Idx, vl_enableLog_Idx, vl_idx; // index of vars
// entityStats:
f_EPTF_ExecCtrl_UIVars_createStatsForTc_vars(pl_tcIdx);
// CPS Chart:
// f_EPTF_ExecCtrl_UIVars_createStatsForTcCPSChart(pl_tcIdx);
// group finish conditions:
f_EPTF_ExecCtrl_UIVars_createVarsForGroupFinishCondStatusLEDsForTc_vars(pl_tcIdx);
// ExecTime:
vl_widgetId := vl_namePrefix&".ExecTime";
vl_currentName := vl_widgetId;
vl_idx := f_EPTF_ExecCtrl_getTrafficCaseExecTimeStatId(pl_tcIdx);
if(-1==f_EPTF_StatMeasure_createVarFromStat(
vl_idx,vl_currentName)) {/*cannot happen*/}
// single shot params/button
// entity index:
vl_widgetId := vl_namePrefix&".SingleShotTc.EIdx";
vl_currentName := vl_widgetId;
f_EPTF_Var_newInt(
vl_currentName, -1, vl_eIdx_Idx);
// enableLog checkbox:
vl_widgetId := vl_namePrefix&".SingleShotTc.EnableLog";
vl_currentName := vl_widgetId;
f_EPTF_Var_newBool(
vl_currentName, false, vl_enableLog_Idx);
// singleShot button:
vl_widgetId := vl_namePrefix&".SingleShotTc.Start";
vl_currentName := vl_widgetId;
f_EPTF_Var_newInt(
vl_currentName, 0, vl_idx);
f_EPTF_Var_addPostProcFn(
vl_idx, { refers(f_EPTF_ExecCtrl_UIVars_singleShotPostProc), {pl_tcIdx,vl_eIdx_Idx,vl_enableLog_Idx}}
);
// f_EPTF_UIVarsClient_enableGUIElement(vl_widgetId);
}
// creates SC entity stats using the statHandler API for the scenario
private function f_EPTF_ExecCtrl_UIVars_createStatsForSc_vars(in integer pl_scIdx)
runs on EPTF_ExecCtrl_CT {
if (not f_EPTF_ExecCtrl_isWeightedScenario(pl_scIdx)) {
return; // for non-weighted scenarios there is no CPS stat
}
var integer vl_eGrpIdx := f_EPTF_ExecCtrl_getScenarioEGroupIdx(pl_scIdx);
var charstring vl_eGrpName := f_EPTF_ExecCtrl_eGrp_name(vl_eGrpIdx);
var charstring vl_scTypeName := f_EPTF_ExecCtrl_getScenarioName(pl_scIdx);
var charstring vl_scName := f_EPTF_ExecCtrl_getScenarioInstanceName(pl_scIdx);
var charstring vl_namePrefix := c_EPTF_ExecCtrl_statisticsRoot&".EG."&vl_eGrpName&".SC."&vl_scTypeName;
var charstring vl_statName;
// declare stats:
f_EPTF_ExecCtrl_debug("Declaring SC statistics for "&vl_namePrefix);
// CurrentCPS:
vl_statName := vl_namePrefix&".CurrentCPS";
if(not f_EPTF_ExecCtrl_StatHandlerClient_declareStat(
pl_statName := vl_statName,
pl_statMethod := c_EPTF_StatHandler_Method_Sum,
pl_statResetValue := {floatVal := 0.0}
)) {/*cannot happen*/} else {
};
var EPTF_Var_SubscriptionMode vl_subscriptionModeForStats := sampledAtSync;
if (v_ExecCtrl_usePullModeForStats) {
vl_subscriptionModeForStats := pull;
}
var charstring vl_lgenDataSourceVarName := f_EPTF_LGenBaseStats_getScNamePrefix(vl_eGrpName,vl_scTypeName);
var EPTF_ExecCtrl_EntityGroupDistributionList vl_lgenList := f_EPTF_ExecCtrl_eGrp_lgenList(vl_eGrpIdx);
for(var integer lg:=0, size := sizeof(vl_lgenList); lg<size;lg:=lg+1) {
if (vl_lgenList[lg].eCount == 0) {
continue; // do not send packet to LGen if there is no entity on the LGen
}
var integer vl_lgenIdx := vl_lgenList[lg].lgenIdx;
// CurrentCPS
// FIXME IN LGenBase: NO CURRENT CPS FOR WEIGHTED SCENARIO!!!!!!!! => Calculating here
for (var integer tc:=0; tc<f_EPTF_ExecCtrl_getScenarioTcIdxListSize(pl_scIdx);tc:=tc+1) {
var charstring vl_tcName := f_EPTF_ExecCtrl_tcNameOfTcOfSc(pl_scIdx,tc)
var charstring vl_lgenDataSourceVarName_Tc_CPS := f_EPTF_LGenBaseStats_getNamePrefix(vl_eGrpName,vl_scTypeName,vl_tcName);
if(not f_EPTF_ExecCtrl_StatHandlerClient_registerStat(
pl_providerVarList := {vl_lgenDataSourceVarName_Tc_CPS&c_EPTF_LGenBaseStats_nameOfTcLastCps},
pl_statName := vl_namePrefix&".CurrentCPS",
pl_subscriptionMode := vl_subscriptionModeForStats,
pl_wait4response := true,//tsp_EPTF_ExecCtrl_StatHandler_wait4response,
pl_sourceCompRef := f_EPTF_Var_downcast(f_EPTF_Base_downcast(f_EPTF_ExecCtrl_getLGenCompRef(vl_lgenIdx))),
pl_refreshRate := 0//v_ExecCtrl_UIVars_refreshRate_currentCPS
)) {/*cannot happen*/};
}
// f_EPTF_StatHandlerClient_registerStat(
// pl_providerVarList := {vl_lgenDataSourceVarName&c_EPTF_LGenBaseStats_nameOfCURRENT_CPS}, // MISSING IN LGenBase
// pl_statName := vl_namePrefix&".CurrentCPS",
// pl_subscriptionMode := realtime,
// pl_wait4response := false,
// pl_sourceCompRef := f_EPTF_Var_downcast(f_EPTF_Base_downcast(f_EPTF_ExecCtrl_getLGenCompRef(vl_lgenIdx)))
// );
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_eGrp_activeEntities_GuardFn
//
// Purpose:
// Guard function for the activeEntities of the entity groups
//
// Parameters:
// pl_idx - *in integer* - id of the varible containing the number of active entities
// pl_argList - *in* <EPTF_IntegerList> - its 0-th element is the index of the entity group in v_ExecCtrl_entityGroups
// pl_newContent - *in* <EPTF_Var_DirectContent> - the new value to be set
//
// Return Value:
// integer - true if accepted, false if not
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_eGrp_activeEntities_GuardFn(in integer pl_idx, in EPTF_IntegerList pl_argList, in EPTF_Var_DirectContent pl_newContent)
runs on EPTF_ExecCtrl_CT
return boolean
{
var integer vl_eGrpIdx := pl_argList[0];
var integer vl_newActiveEntities := pl_newContent.intVal;
if (vl_newActiveEntities<0) {
vl_newActiveEntities := 0;
f_EPTF_Var_adjustContent(pl_idx, {intVal := vl_newActiveEntities});
return false;
}
var integer vl_allocatedEntities := f_EPTF_ExecCtrl_getAllocatedEntities(vl_eGrpIdx);
if (vl_newActiveEntities>vl_allocatedEntities) {
vl_newActiveEntities := vl_allocatedEntities;
f_EPTF_Var_adjustContent(pl_idx, {intVal := vl_newActiveEntities});
return false;
}
return true;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_eGrp_activeEntities_PostProcFn
//
// Purpose:
// PostProc function for the active entities to distribute the value
// on the LGens
//
// Parameters:
// pl_idx - *in integer* - id of the varible containing the number of active entities
// pl_argList - *in* <EPTF_IntegerList> - its 0-th element is the index of the entity group in v_ExecCtrl_entityGroups
//
// Return Value:
// -
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_eGrp_activeEntities_PostProcFn(in integer pl_idx, in EPTF_IntegerList pl_argList)
runs on EPTF_ExecCtrl_CT
{
var integer vl_eGrpIdx := pl_argList[0];
var integer vl_newValue := f_EPTF_Var_getIntValue(pl_idx);
f_EPTF_ExecCtrl_debug(log2str("Active entities for the EGrp ",f_EPTF_ExecCtrl_eGrp_name(vl_eGrpIdx), " is set to ",vl_newValue));
//distribute active entities among the LGens to which the entity group is deployed
f_EPTF_ExecCtrl_sendUpdatedActiveEntities(vl_eGrpIdx);
f_EPTF_ExecCtrl_sendCurrentCPSForAllSCInEGrp(vl_eGrpIdx);
}
// connects the widges on the Statistics tab to variables
private function f_EPTF_ExecCtrl_UIVars_connectVarsToStatisticsTab_vars()
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
var charstring vl_currentName; // name of variable to connect
var charstring vl_widgetId; // name of widgetId to connect to
var integer vl_idx; // index of var vl_currentName
// go through all entity groups:
for(var integer eg:=0; eg<f_EPTF_ExecCtrl_numEntityGroups(); eg:=eg+1) {
var charstring vl_eGrpName := f_EPTF_ExecCtrl_eGrp_name(eg);
vl_widgetId := c_EPTF_ExecCtrl_statisticsRoot&".EG."&vl_eGrpName&".nofLGens";
vl_currentName := vl_widgetId;
// count number of LGens deployed on:
var integer vl_numLGensDeployed:=0;
var EPTF_ExecCtrl_EntityGroupDistributionList vl_lgenList := f_EPTF_ExecCtrl_eGrp_lgenList(eg);
for(var integer lg:=0, lsize := sizeof(vl_lgenList); lg<lsize;lg:=lg+1) {
if (vl_lgenList[lg].eCount == 0 ) {
continue; // nothing to do
}
vl_numLGensDeployed:=vl_numLGensDeployed+1;
}
f_EPTF_Var_newCharstring(vl_currentName, int2str(vl_numLGensDeployed), vl_idx);
f_EPTF_ExecCtrl_debug(
"Variable "&vl_currentName&" (Statistics / EntityGroups / nofLGens) created with widgetId: "&vl_widgetId
);
//number of active entities:
vl_widgetId := c_EPTF_ExecCtrl_statisticsRoot&".EG."&vl_eGrpName&".nofActiveEntities";
vl_currentName := vl_widgetId;
f_EPTF_Var_newInt(vl_currentName, f_EPTF_ExecCtrl_getActiveEntities(eg), vl_idx);
f_EPTF_Var_addGuardFn(vl_idx,{refers(f_EPTF_ExecCtrl_eGrp_activeEntities_GuardFn),{eg}})
f_EPTF_Var_addPostProcFn(vl_idx,{refers(f_EPTF_ExecCtrl_eGrp_activeEntities_PostProcFn),{eg}})
f_EPTF_ExecCtrl_debug(
"Variable "&vl_currentName&" (Statistics / EntityGroups / nofActiveEntities) created with widgetId: "&vl_widgetId
);
//offset of entityGroup:
vl_widgetId := c_EPTF_ExecCtrl_statisticsRoot&".EG."&vl_eGrpName&".eOffset";
vl_currentName := vl_widgetId;
f_EPTF_Var_newInt(vl_currentName, f_EPTF_ExecCtrl_eGrp_eOffset(eg), vl_idx);
f_EPTF_ExecCtrl_debug(
"Variable "&vl_currentName&" (Statistics / EntityGroups / eOffset) created with widgetId: "&vl_widgetId
);
//LGenPool of entityGroup:
vl_widgetId := c_EPTF_ExecCtrl_statisticsRoot&".EG."&vl_eGrpName&".LGenPool";
vl_currentName := vl_widgetId;
f_EPTF_Var_newCharstring(vl_currentName, f_EPTF_ExecCtrl_eGrp_lgenPoolName(eg), vl_idx);
f_EPTF_ExecCtrl_debug(
"Variable "&vl_currentName&" (Statistics / EntityGroups / LGenPool) created with widgetId: "&vl_widgetId
);
}
// go through all scenarios:
for(var integer sc:=0; sc<f_EPTF_ExecCtrl_numScenarios(); sc:=sc+1) {
f_EPTF_ExecCtrl_updateProgressbar(100.0/int2float(f_EPTF_ExecCtrl_numScenarios()));
var integer vl_eGrpIdx := f_EPTF_ExecCtrl_getScenarioEGroupIdx(sc);
var charstring vl_eGrpName := f_EPTF_ExecCtrl_eGrp_name(vl_eGrpIdx);
var charstring vl_scTypeName := f_EPTF_ExecCtrl_getScenarioName(sc);
var charstring vl_scName := f_EPTF_ExecCtrl_getScenarioInstanceName(sc);
// Control buttons (start/stop/reset):
// start scenario button:
//vl_currentName := "ExecCtrl.startScenario."&vl_eGrpName&"."&vl_scTypeName; // this is the name in the TrafficCase table
vl_widgetId := c_EPTF_ExecCtrl_statisticsRoot&".EG."&vl_eGrpName&".SC."&vl_scTypeName&".ControlButtons.Start";
vl_currentName := vl_widgetId;
var integer vl_startScVarIdx,vl_stopScVarIdx,vl_resetScVarIdx;
f_EPTF_Var_newInt(
vl_currentName, 0, vl_startScVarIdx);
// stop scenario button:
//vl_currentName := "ExecCtrl.stopScenario."&vl_eGrpName&"."&vl_scTypeName; // this is the name in the TrafficCase table
vl_widgetId := c_EPTF_ExecCtrl_statisticsRoot&".EG."&vl_eGrpName&".SC."&vl_scTypeName&".ControlButtons.Stop";
vl_currentName := vl_widgetId;
f_EPTF_Var_newInt(
vl_currentName, 0, vl_stopScVarIdx);
// reset scenario button:
//vl_currentName := "ExecCtrl.startScenario."&vl_eGrpName&"."&vl_scTypeName; // this is the name in the TrafficCase table
vl_widgetId := c_EPTF_ExecCtrl_statisticsRoot&".EG."&vl_eGrpName&".SC."&vl_scTypeName&".ControlButtons.Reset";
vl_currentName := vl_widgetId;
f_EPTF_Var_newInt(
vl_currentName, 0, vl_resetScVarIdx);
// add postProc-es:
f_EPTF_Var_addPostProcFn(
vl_startScVarIdx, { refers(f_EPTF_ExecCtrl_UIVars_startScenario_PostProc), {sc,vl_startScVarIdx,vl_stopScVarIdx,vl_resetScVarIdx}} );
f_EPTF_Var_addPostProcFn(
vl_stopScVarIdx, { refers(f_EPTF_ExecCtrl_UIVars_stopScenario_PostProc), {sc,vl_startScVarIdx,vl_stopScVarIdx,vl_resetScVarIdx}} );
f_EPTF_Var_addPostProcFn(
vl_resetScVarIdx, { refers(f_EPTF_ExecCtrl_UIVars_resetScenario_PostProc), {sc,vl_startScVarIdx,vl_stopScVarIdx,vl_resetScVarIdx}} );
// disable start/stop/reset scenario buttons if scenario is in scenario group:
if (not f_EPTF_ExecCtrl_scenarioIsNotInScenarioGroup(sc)) {
f_EPTF_Var_setSubsCanAdjust(vl_startScVarIdx,false);
f_EPTF_Var_setSubsCanAdjust(vl_stopScVarIdx,false);
f_EPTF_Var_setSubsCanAdjust(vl_resetScVarIdx,false);
}
// call f_EPTF_ExecCtrl_startStopScenario_scenarioStateChangedCallback to initialize button status:
vl_currentName := "ExecCtrl.scenarioStatus."&vl_eGrpName&"."&vl_scTypeName;
vl_idx := f_EPTF_Var_getId(vl_currentName);
if (vl_idx != -1) {
var EPTF_StatusLED vl_EPTF_StatusLED := f_EPTF_Var_getStatusLEDValue(vl_idx);
f_EPTF_ExecCtrl_startStopScenario_scenarioStateChangedCallback(vl_eGrpName,vl_scTypeName,vl_EPTF_StatusLED.text);
}
// name of scenario instance
vl_widgetId := c_EPTF_ExecCtrl_statisticsRoot&".EG."&vl_eGrpName&".SC."&vl_scTypeName&".instanceName";
vl_currentName := vl_widgetId;
f_EPTF_Var_newCharstring(vl_currentName, vl_scName, vl_idx);
f_EPTF_ExecCtrl_debug(
"Variable "&vl_currentName&" (Statistics / Scenario instance name) connected to widgetId: "&vl_widgetId
);
if (not f_EPTF_ExecCtrl_scenarioIsNotInScenarioGroup(sc)) {
var integer vl_scGrpIdx := f_EPTF_ExecCtrl_ScenarioGroup_get_byScIndex(sc);
// phase list name of scenario instance
vl_widgetId := c_EPTF_ExecCtrl_statisticsRoot&".EG."&vl_eGrpName&".SC."&vl_scTypeName&".phaseListName";
vl_currentName := vl_widgetId;
f_EPTF_Var_newCharstring(
vl_currentName, f_EPTF_ExecCtrl_getScenarioPhaseListName(sc), vl_idx);
f_EPTF_ExecCtrl_debug(
"Variable "&vl_currentName&" (Statistics / Phase list name for scenario instance) connected to widgetId: "&vl_widgetId
);
// scenario group name of scenario instance
vl_widgetId := c_EPTF_ExecCtrl_statisticsRoot&".EG."&vl_eGrpName&".SC."&vl_scTypeName&".scGrpName";
vl_currentName := vl_widgetId;
f_EPTF_Var_newCharstring(vl_currentName, f_EPTF_ExecCtrl_getScenarioGroupInstanceName(vl_scGrpIdx), vl_idx);
f_EPTF_ExecCtrl_debug(
"Variable "&vl_currentName&" (Statistics / Scenario group name for scenario instance) connected to widgetId: "&vl_widgetId
);
}
// connect traffic case widgets:
for(var integer tc:=0; tc<f_EPTF_ExecCtrl_getScenarioTcIdxListSize(sc); tc:=tc+1) {
var integer vl_tcIdx := f_EPTF_ExecCtrl_getScenarioTcIdx(sc,tc);
var charstring vl_tcName := f_EPTF_ExecCtrl_tcNameOfTcOfSc(sc,tc)
// traffic case GroupFinishStatusLED:
vl_widgetId := c_EPTF_ExecCtrl_statisticsRoot&".EG."&vl_eGrpName&".SC."&vl_scTypeName&".TC."&vl_tcName&".GroupFinishStatusLED";
vl_currentName := vl_widgetId;
f_EPTF_Var_newStatusLED(
vl_currentName, f_EPTF_ExecCtrl_UIVars_getLEDForGroupFinish(vl_tcIdx), vl_idx);
f_EPTF_Var_setSubsCanAdjust(vl_idx,false);
f_EPTF_ExecCtrl_debug(
"Variable "&vl_currentName&" (Statistics / Traffic case group finish status) connected to widgetId: "&vl_widgetId
);
f_EPTF_ExecCtrl_UIVars_connectVarsToStatisticsTabForTc_vars(vl_tcIdx);
} // for tc
f_EPTF_ExecCtrl_UIVars_createStatsForSc_vars(sc);
} // for sc
//f_EPTF_ExecCtrl_UIVars_createStatsForAllTcs();
f_EPTF_ExecCtrl_UIVars_createGlobalStats_vars();
}
private function f_EPTF_ExecCtrl_createGUI_vars() runs on EPTF_ExecCtrl_CT {
f_EPTF_ExecCtrl_debug(%definitionId&
": Trying to subscribe variables to GUI for init!");
// Init already subscribed database
f_EPTF_ExecCtrl_UIVars_Subscribe2TimeElapsed_vars();
f_EPTF_ExecCtrl_UIVars_Subscribe2TestMgmtButtons_vars();
f_EPTF_ExecCtrl_UIVars_connectVarsToStatisticsTab_vars();
f_EPTF_ExecCtrl_UIVars_SubscribeVars2GUI_vars();
}
// Create_vars
//////////////
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_UIVars_SubscribeVars2ResourceTab_vars
//
// Purpose:
// Subscribe resource related variables to GUI
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_UIVars_SubscribeVars2ResourceTab_vars()
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
f_EPTF_ExecCtrl_updateProgressbar(0.0, "Creating Client Resources panel variables");
var charstring vl_currentName;
var integer vl_offset := 0;
var integer vl_sizeLG := f_EPTF_ExecCtrl_numLGens();
var integer vl_varId := 0;
for (var integer lgenidx := 0; lgenidx < vl_sizeLG; lgenidx := lgenidx + 1)
{
f_EPTF_ExecCtrl_updateProgressbar(50.0/int2float(vl_sizeLG));
// LGen name
vl_currentName := "Resource.LGenName." & int2str(lgenidx);
if (f_EPTF_Var_getId(vl_currentName) == -1)
{
// vl_widgetId :=
// c_EPTF_ExecCtrl_ResourceTabId & "." & int2str(vl_offset) & ".0";
f_EPTF_Var_newCharstring(
vl_currentName, f_EPTF_ExecCtrl_getLGenName(lgenidx),
vl_varId);
f_EPTF_Var_setSubsCanAdjust(vl_varId,false);
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (RES / LGen name) id: "
&int2str(vl_varId));
}
var integer vl_sizeAvail := f_EPTF_ExecCtrl_getLGenResourceListNum(lgenidx);
if (vl_sizeAvail==0) {
// Increase offset for each group
vl_offset := vl_offset + 1;
}
// Resource info (entity group - available - allocated)
for (var integer eidx := 0; eidx < vl_sizeAvail; eidx := eidx + 1)
{
vl_currentName := "Resource.EntityType." & int2str(lgenidx) & "." & int2str(eidx);
// Entity type
if (f_EPTF_Var_getId(vl_currentName) == -1)
{
// vl_widgetId :=
// c_EPTF_ExecCtrl_ResourceTabId & "." & int2str(vl_offset) & ".1";
f_EPTF_ExecCtrl_debug(
"Available list: " & f_EPTF_ExecCtrl_getLGenResourceList2Str(lgenidx));
f_EPTF_Var_newCharstring(
vl_currentName,
f_EPTF_ExecCtrl_getLGenResourceListEType(lgenidx,eidx),
vl_varId);
f_EPTF_Var_setSubsCanAdjust(vl_varId,false);
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (RES / Entity type) id: "
&int2str(vl_varId));
}
// Available and allocated number of entity types
vl_currentName := "Resource.EntityAvailNum." & int2str(lgenidx) & "." & int2str(eidx);
if (f_EPTF_Var_getId(vl_currentName) == -1)
{
// vl_widgetId :=
// c_EPTF_ExecCtrl_ResourceTabId & "." & int2str(vl_offset) & ".2";
f_EPTF_ExecCtrl_debug(
"Available list: " & f_EPTF_ExecCtrl_getLGenResourceList2Str(lgenidx));
f_EPTF_ExecCtrl_createRefVarForMaxCount(
vl_currentName,
lgenidx,eidx,
vl_varId);
f_EPTF_Var_setSubsCanAdjust(vl_varId,false);
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (RES / Entity Max available num) id: "
&int2str(vl_varId));
vl_currentName := "Resource.EntityAllocNum." & int2str(lgenidx) & "." & int2str(eidx);
// vl_widgetId :=
// c_EPTF_ExecCtrl_ResourceTabId & "." & int2str(vl_offset) & ".3";
f_EPTF_ExecCtrl_debug(
"Allocated list: " & f_EPTF_ExecCtrl_getLGenResourceList2Str(lgenidx));
f_EPTF_ExecCtrl_createRefVarForEAvail(
vl_currentName,
lgenidx,eidx,
vl_varId);
f_EPTF_Var_setSubsCanAdjust(vl_varId,false);
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (RES / Entity Current available num) id: "
&int2str(vl_varId));
}
// Increase offset for each group
vl_offset := vl_offset + 1;
}
}
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_UIVars_SubscribeVars2EntityGroupsTab_vars
//
// Purpose:
// Subscribe entity group related variables to GUI
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_UIVars_SubscribeVars2EntityGroupsTab_vars()
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
f_EPTF_ExecCtrl_updateProgressbar(0.0, "Creating Entity Groups panel variables");
var charstring vl_currentName;
var integer vl_idx;
var integer vl_size := f_EPTF_ExecCtrl_numEntityGroups();
for (var integer i := 0; i < vl_size; i := i + 1)
{
f_EPTF_ExecCtrl_updateProgressbar(100.0/int2float(vl_size));
// Entity name
vl_currentName := "EntityGroup." & int2str(i);
// vl_widgetId := c_EPTF_ExecCtrl_EntityGrpTabId & "." & int2str(i) & ".0";
f_EPTF_Var_newCharstring(
vl_currentName, f_EPTF_ExecCtrl_eGrp_name(i), vl_idx);
f_EPTF_Var_setSubsCanAdjust(vl_idx,false);
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (EG / Entity group) id: "
&int2str(vl_idx));
// Entity type
vl_currentName := "EntityType." & int2str(i);
// vl_widgetId := c_EPTF_ExecCtrl_EntityGrpTabId & "." & int2str(i) & ".1";
f_EPTF_Var_newCharstring(
vl_currentName, f_EPTF_ExecCtrl_eGrp_eType(i), vl_idx);
f_EPTF_Var_setSubsCanAdjust(vl_idx,false);
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (EG / Entity type) id: "
&int2str(vl_idx));
// Entity number of entity group
vl_currentName := "EntityNum." & int2str(i);
// vl_widgetId := c_EPTF_ExecCtrl_EntityGrpTabId & "." & int2str(i) & ".2";
f_EPTF_Var_newInt(
vl_currentName, f_EPTF_ExecCtrl_eGrp_eCount(i), vl_idx);
f_EPTF_Var_setSubsCanAdjust(vl_idx,false);
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (EG / Entity num) id: "
&int2str(vl_idx));
}
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_UIVars_SubscribeVars2EGrpDistributionTab_vars
//
// Purpose:
// Subscribe entity group distribution related variables to GUI
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_UIVars_SubscribeVars2EGrpDistributionTab_vars()
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
var charstring vl_currentName;
var integer vl_offset := 0;
var integer vl_sizeEGrp := f_EPTF_ExecCtrl_numEntityGroups();
var integer vl_varId := 0;
for (var integer eGrpIdx := 0; eGrpIdx < vl_sizeEGrp; eGrpIdx := eGrpIdx + 1)
{
f_EPTF_ExecCtrl_updateProgressbar(50.0/int2float(vl_sizeEGrp));
// EGrpName name
vl_currentName := "EGrpDistr.EGrpName." & int2str(eGrpIdx);
if (f_EPTF_Var_getId(vl_currentName) == -1)
{
// vl_widgetId :=
// c_EPTF_ExecCtrl_GroupDistributionTabId & "." & int2str(vl_offset) & ".0";
f_EPTF_Var_newCharstring(
vl_currentName, f_EPTF_ExecCtrl_eGrp_name(eGrpIdx),
vl_varId);
f_EPTF_Var_setSubsCanAdjust(vl_varId,false);
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (EGrpDistr / EGrp name) id: "
&int2str(vl_varId));
}
var EPTF_ExecCtrl_EntityGroupDistributionList vl_lgenList := f_EPTF_ExecCtrl_eGrp_lgenList(eGrpIdx);
var integer vl_sizeLGen := sizeof(
vl_lgenList);
// Resource info (entity group - available - allocated)
if (vl_sizeLGen==0) {
// Increase offset for each group
vl_offset := vl_offset + 1;
}
for (var integer lgenIdx := 0; lgenIdx < vl_sizeLGen; lgenIdx := lgenIdx + 1)
{
var integer vl_lgenIdx := vl_lgenList[lgenIdx].lgenIdx;
// LGen name
vl_currentName := "EGrpDistr.LGenName." & int2str(eGrpIdx) & "." & int2str(lgenIdx);
if (f_EPTF_Var_getId(vl_currentName) == -1)
{
// vl_widgetId :=
// c_EPTF_ExecCtrl_GroupDistributionTabId & "." & int2str(vl_offset) & ".1";
f_EPTF_Var_newCharstring(
vl_currentName,
f_EPTF_ExecCtrl_getLGenName(vl_lgenIdx),
vl_varId);
f_EPTF_Var_setSubsCanAdjust(vl_varId,false);
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (EGrpDistr / LGen name) id: "
&int2str(vl_varId));
}
// EGroup size and offset
vl_currentName := "EGrpDistr.ECount." & int2str(eGrpIdx) & "." & int2str(lgenIdx);
if (f_EPTF_Var_getId(vl_currentName) == -1)
{
// vl_widgetId :=
// c_EPTF_ExecCtrl_GroupDistributionTabId & "." & int2str(vl_offset) & ".2";
f_EPTF_ExecCtrl_debug(
"Available list: " & log2str(vl_lgenList[lgenIdx]));
f_EPTF_Var_newInt(
vl_currentName,
vl_lgenList[lgenIdx].eCount,
vl_varId);
f_EPTF_Var_setSubsCanAdjust(vl_varId,false);
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (EGrpDistr / ECount ) id: "
&int2str(vl_varId));
vl_currentName := "EGrpDistr.EOffset." & int2str(eGrpIdx) & "." & int2str(lgenIdx);
// vl_widgetId :=
// c_EPTF_ExecCtrl_GroupDistributionTabId & "." & int2str(vl_offset) & ".3";
f_EPTF_Var_newInt(
vl_currentName,
vl_lgenList[lgenIdx].eOffset + f_EPTF_ExecCtrl_eGrp_eOffset(eGrpIdx),
vl_varId);
f_EPTF_Var_setSubsCanAdjust(vl_varId,false);
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (EGrpDistr / Entity Offset) id: "
&int2str(vl_varId));
}
// Increase offset for each group
vl_offset := vl_offset + 1;
}
}
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_UIVars_SubscribeVars2ScenarioTab_vars
//
// Purpose:
// Subscribe scenario and traffic case related variables to GUI
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_UIVars_SubscribeVars2ScenarioTab_vars()
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
f_EPTF_ExecCtrl_UIVars_SubscribeVars2ScenarioTab_Scenario_vars();
f_EPTF_ExecCtrl_UIVars_SubscribeVars2ScenarioTab_TrafficCase_vars();
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_UIVars_CreateLEDFromExecStatus
//
// Purpose:
// Creates a status LED from execution control status
//
//
// Parameters:
// pl_idx - *in* *integer* - index of the subscriber variable
// pl_argList - *in* <EPTF_IntegerList> - list of argument variable indices
// pl_nonVarArgList - *in* <EPTF_IntegerList> - list of other argument indices
// pl_retVal - *inout* <EPTF_Var_DirectContent> - result of the function
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_UIVars_CreateLEDFromExecStatus(
in integer pl_idx,
in EPTF_IntegerList pl_argList,
in EPTF_IntegerList pl_nonVarArgList,
inout EPTF_Var_DirectContent pl_retVal) runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
if (v_ExecCtrl_initialized==false) {
return; // cleanup is in progress, or not initialized
}
var charstring vl_execState :=
f_EPTF_Var_getCharstringValue(pl_argList[0]);
pl_retVal := {
statusLEDVal := f_EPTF_ExecCtrl_stateStrToEPTF_StatusLED(vl_execState)
}
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_UIVars_SubscribeVars2ScenarioTab_Scenario_vars
//
// Purpose:
// Subscribe scenario related variables to GUI
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_UIVars_SubscribeVars2ScenarioTab_Scenario_vars()
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
f_EPTF_ExecCtrl_updateProgressbar(0.0, "Creating Traffic Cases panel variables");
var charstring vl_currentName;
var integer vl_idx, vl_offset := 0;
var integer vl_sizeLG := f_EPTF_ExecCtrl_numLGens();
var integer vl_varId := 0;
for (var integer lgenidx := 0; lgenidx < vl_sizeLG; lgenidx := lgenidx + 1)
{
f_EPTF_ExecCtrl_updateProgressbar(50.0/int2float(vl_sizeLG));
// LGen name
vl_currentName := "Scenario.LGenName." & int2str(lgenidx);
if (f_EPTF_Var_getId(vl_currentName) == -1)
{
// vl_widgetId :=
// c_EPTF_ExecCtrl_TrafficTabId_Scenario & "." & int2str(vl_offset) & ".0";
f_EPTF_Var_newCharstring(
vl_currentName, f_EPTF_ExecCtrl_getLGenName(lgenidx),
vl_varId);
f_EPTF_Var_setSubsCanAdjust(vl_varId,false);
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (SCEN / LGen name) id: "
&int2str(vl_varId));
}
var integer sidx := -1;
if (f_EPTF_ExecCtrl_getLGenNumEGroups(lgenidx)==0) {
// Increase offset for each group
vl_offset := vl_offset + 1;
}
for(var integer eg:=0; eg<f_EPTF_ExecCtrl_getLGenNumEGroups(lgenidx); eg:=eg+1) {
var integer vl_eGrpIdx := f_EPTF_ExecCtrl_getLGenEGrpIdx(lgenidx,eg);
var EPTF_IntegerList vl_eGrpScenarios := f_EPTF_ExecCtrl_eGrp_scenarios(vl_eGrpIdx);
if (sizeof(vl_eGrpScenarios)==0) {
// Allocated of entity group
sidx := sidx + 1;
// Resource info (entity group - available - allocated)
vl_currentName := "Scenario.ScenarioGroup." & int2str(lgenidx) & "." & int2str(sidx);
if (f_EPTF_Var_getId(vl_currentName) == -1)
{
// vl_widgetId :=
// c_EPTF_ExecCtrl_TrafficTabId_Scenario & "." & int2str(vl_offset) & ".1";
f_EPTF_Var_newCharstring(
vl_currentName,
f_EPTF_ExecCtrl_eGrp_name(vl_eGrpIdx),
vl_varId);
f_EPTF_Var_setSubsCanAdjust(vl_varId,false);
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (SCEN / Scenario group) id: "
&int2str(vl_varId));
}
vl_offset := vl_offset+1;
//continue; // the for cycle is not executed, continue is not necessary
}
for(var integer sc:=0, size := sizeof(vl_eGrpScenarios); sc<size;sc:=sc+1) {
var integer vl_scIdx := vl_eGrpScenarios[sc];
sidx := sidx + 1;
// Resource info (entity group - available - allocated)
// Allocated of entity group
vl_currentName := "Scenario.ScenarioGroup." & int2str(lgenidx) & "." & int2str(sidx);
if (f_EPTF_Var_getId(vl_currentName) == -1)
{
// vl_widgetId :=
// c_EPTF_ExecCtrl_TrafficTabId_Scenario & "." & int2str(vl_offset) & ".1";
f_EPTF_Var_newCharstring(
vl_currentName,
f_EPTF_ExecCtrl_eGrp_name(vl_eGrpIdx),
vl_varId);
f_EPTF_Var_setSubsCanAdjust(vl_varId,false);
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (SCEN / Scenario group) id: "
&int2str(vl_varId));
}
// Scenario name
vl_currentName := "Scenario.ScenarioName." & int2str(lgenidx) & "." & int2str(sidx);
if (f_EPTF_Var_getId(vl_currentName) == -1)
{
// vl_widgetId :=
// c_EPTF_ExecCtrl_TrafficTabId_Scenario & "." & int2str(vl_offset) & ".2";
f_EPTF_Var_newCharstring(
vl_currentName,
f_EPTF_ExecCtrl_getScenarioName(vl_scIdx),
vl_varId);
f_EPTF_Var_setSubsCanAdjust(vl_varId,false);
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (SCEN / Scenario name) id: "
&int2str(vl_varId));
}
// Scenario status
vl_currentName := "Scenario.LGenStatus." & f_EPTF_ExecCtrl_getLGenName(lgenidx) & "." &f_EPTF_ExecCtrl_eGrp_name(vl_eGrpIdx)&
"."&f_EPTF_ExecCtrl_getScenarioName(vl_scIdx);
if (f_EPTF_Var_getId(vl_currentName) == -1)
{
// lgen status
var EPTF_Var_ProviderLocal vl_providerLocal;
// vl_currentName := "Scenario.LGenStatus." & int2str(lgenidx) & "." & int2str(sidx);
// vl_widgetId :=
// c_EPTF_ExecCtrl_TrafficTabId_Scenario & "." & int2str(vl_offset) & ".3";
f_EPTF_Var_newStatusLED(
"StatusLED." & vl_currentName,
c_EPTF_ExecCtrl_UIVars_StatusLED_init,
vl_idx);
var charstring vl_varName := "ExecCtrlClient.scenarioStatus."&f_EPTF_ExecCtrl_eGrp_name(vl_eGrpIdx)&
"."&f_EPTF_ExecCtrl_getScenarioName(vl_scIdx);
vl_varId := f_EPTF_Var_getId(vl_varName&"."&f_EPTF_ExecCtrl_getLGenName(lgenidx));
vl_providerLocal := {calcFn:={
funcRef := refers(f_EPTF_ExecCtrl_UIVars_CreateLEDFromExecStatus),
argList := {vl_varId},
nonVarArgList := {}
}};
// FIXME: update the function ExecCtrl_Functions.f_EPTF_ExecCtrl_subscribeScenarioState
if (vl_varId == -1) {
vl_offset := vl_offset + 1;
continue;
}
f_EPTF_Var_subscribeLocal(vl_idx, vl_providerLocal);
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (SCEN / LGen status) id: "
&int2str(vl_varId));
}
// Increase offset for each group
vl_offset := vl_offset + 1;
} // sc
} // eg
}
}
private function f_EPTF_ExecCtrl_UIVars_SubscribeVars2ScenarioTab_TrafficCase_vars() runs on EPTF_ExecCtrl_CT{
f_EPTF_ExecCtrl_UIVars_SubscribeVars2ScenarioTab_TrafficCase2_vars();
f_EPTF_ExecCtrl_registerScenarioStateChangedCallback(refers(f_EPTF_ExecCtrl_startStopScenario_scenarioStateChangedCallback));
f_EPTF_ExecCtrl_registerTrafficCaseStateChangedCallback(refers(f_EPTF_ExecCtrl_startStopTc_tcStateChangedCallback));
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_startStopScenario_scenarioStateChangedCallback
//
// Purpose:
// A scenarioStateChangedCallback to automatically disable the start/stop/reset buttons
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_startStopScenario_scenarioStateChangedCallback(in charstring pl_eGrpName, in charstring pl_scName, in charstring pl_state) runs on EPTF_ExecCtrl_CT {
var charstring vl_currentName;
var integer vl_idx;
if (pl_state==c_EPTF_LGenBase_stateNames[c_EPTF_LGenBase_tcStateRunning]) {
// disables startScenario:
// enables stopScenario:
f_EPTF_ExecCtrl_debug(
"**********STOP SCENARIO ENABLED***********");
vl_currentName := "ExecCtrl.startScenario."&pl_eGrpName&"."&pl_scName;
vl_idx := f_EPTF_Var_getId(vl_currentName);
f_EPTF_Var_adjustContent(vl_idx,{boolVal := false});
// this scenario cannot be stopped if it belongs to a scenario group:
var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioIdx(pl_eGrpName,pl_scName);
f_EPTF_Base_assert(%definitionId&": Cannot find scenario "&pl_scName&" of entity group "&pl_eGrpName&" in database.", vl_scIdx != -1);
if (f_EPTF_ExecCtrl_scenarioIsNotInScenarioGroup(vl_scIdx)) {
// Manage Statistics/Scenario control buttons enabled state
vl_currentName := c_EPTF_ExecCtrl_statisticsRoot&".EG."&pl_eGrpName&".SC."&pl_scName&".ControlButtons.Stop";
vl_idx := f_EPTF_Var_getId(vl_currentName);
f_EPTF_Var_setSubsCanAdjust(vl_idx,true);
vl_currentName := c_EPTF_ExecCtrl_statisticsRoot&".EG."&pl_eGrpName&".SC."&pl_scName&".ControlButtons.Start";
vl_idx := f_EPTF_Var_getId(vl_currentName);
f_EPTF_Var_setSubsCanAdjust(vl_idx,false);
vl_currentName := c_EPTF_ExecCtrl_statisticsRoot&".EG."&pl_eGrpName&".SC."&pl_scName&".ControlButtons.Reset";
vl_idx := f_EPTF_Var_getId(vl_currentName);
f_EPTF_Var_setSubsCanAdjust(vl_idx,false);
}
}
if (pl_state==c_EPTF_LGenBase_stateNames[c_EPTF_LGenBase_tcStateStopped]
or pl_state==c_EPTF_LGenBase_stateNames[c_EPTF_LGenBase_tcStateFinished]
or pl_state==c_EPTF_LGenBase_stateNames[c_EPTF_LGenBase_tcStatePaused]
or pl_state==c_EPTF_LGenBase_stateNames[c_EPTF_LGenBase_tcStateAborted]
or pl_state==c_EPTF_LGenBase_stateNames[c_EPTF_LGenBase_tcStateTerminated]
or pl_state==c_EPTF_LGenBase_stateNames[c_EPTF_LGenBase_tcStateIdle]) {
// pl_state=="Idle" or pl_state=="Stopped" or pl_state=="Stopping" or pl_state=="Finished" or pl_state=="Paused" or pl_state=="Aborted"
// enables startScenario:
// disables stopScenario:
f_EPTF_ExecCtrl_debug(
"**********START SCENARIO ENABLED***********");
vl_currentName := "ExecCtrl.stopScenario."&pl_eGrpName&"."&pl_scName;
vl_idx := f_EPTF_Var_getId(vl_currentName);
f_EPTF_Var_adjustContent(vl_idx,{boolVal := false});
// this scenario cannot be started if it belongs to a scenario group:
var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioIdx(pl_eGrpName,pl_scName);
f_EPTF_Base_assert(%definitionId&": Cannot find scenario "&pl_scName&" of entity group "&pl_eGrpName&" in database.", vl_scIdx != -1);
if (f_EPTF_ExecCtrl_scenarioIsNotInScenarioGroup(vl_scIdx)) {
// Manage Statistics/Scenario control buttons enabled state
vl_currentName := c_EPTF_ExecCtrl_statisticsRoot&".EG."&pl_eGrpName&".SC."&pl_scName&".ControlButtons.Stop";
vl_idx := f_EPTF_Var_getId(vl_currentName);
f_EPTF_Var_setSubsCanAdjust(vl_idx,false);
vl_currentName := c_EPTF_ExecCtrl_statisticsRoot&".EG."&pl_eGrpName&".SC."&pl_scName&".ControlButtons.Start";
vl_idx := f_EPTF_Var_getId(vl_currentName);
f_EPTF_Var_setSubsCanAdjust(vl_idx,true);
vl_currentName := c_EPTF_ExecCtrl_statisticsRoot&".EG."&pl_eGrpName&".SC."&pl_scName&".ControlButtons.Reset";
vl_idx := f_EPTF_Var_getId(vl_currentName);
f_EPTF_Var_setSubsCanAdjust(vl_idx,true);
}
}
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_startStopTc_tcStateChangedCallback
//
// Purpose:
// A tcStateChangedCallback to automatically disable the start/stop buttons
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_startStopTc_tcStateChangedCallback(in charstring pl_eGrpName, in charstring pl_scName, in charstring pl_tcName, in charstring pl_state) runs on EPTF_ExecCtrl_CT {
var charstring vl_currentName;
var integer vl_idx;
if (pl_state==c_EPTF_LGenBase_stateNames[c_EPTF_LGenBase_tcStateRunning]) {
// disables startTc:
// enables stopTc:
f_EPTF_ExecCtrl_debug(
"**********STOP TC ENABLED***********");
vl_currentName := "ExecCtrl.startTC."&pl_eGrpName&"."&pl_scName&"."&pl_tcName;
vl_idx := f_EPTF_Var_getId(vl_currentName);
f_EPTF_Var_adjustContent(vl_idx,{boolVal := false});
// this tc cannot be stopped if it belongs to a scenario group:
var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioIdx(pl_eGrpName,pl_scName);
f_EPTF_Base_assert(%definitionId&": Cannot find scenario "&pl_scName&" of entity group "&pl_eGrpName&" in database.", vl_scIdx != -1);
if (f_EPTF_ExecCtrl_scenarioIsNotInScenarioGroup(vl_scIdx)) {
// Manage TrafficCase control buttons enabled state
vl_currentName := c_EPTF_ExecCtrl_statisticsRoot&".EG."&pl_eGrpName&".SC."&pl_scName&".TC."&pl_tcName&".ControlButtons.Stop";
vl_idx := f_EPTF_Var_getId(vl_currentName);
f_EPTF_Var_setSubsCanAdjust(vl_idx,true);
vl_currentName := c_EPTF_ExecCtrl_statisticsRoot&".EG."&pl_eGrpName&".SC."&pl_scName&".TC."&pl_tcName&".ControlButtons.Start";
vl_idx := f_EPTF_Var_getId(vl_currentName);
f_EPTF_Var_setSubsCanAdjust(vl_idx,false);
}
}
if (pl_state==c_EPTF_LGenBase_stateNames[c_EPTF_LGenBase_tcStateStopped]
or pl_state==c_EPTF_LGenBase_stateNames[c_EPTF_LGenBase_tcStateFinished]
or pl_state==c_EPTF_LGenBase_stateNames[c_EPTF_LGenBase_tcStatePaused]
or pl_state==c_EPTF_LGenBase_stateNames[c_EPTF_LGenBase_tcStateAborted]
or pl_state==c_EPTF_LGenBase_stateNames[c_EPTF_LGenBase_tcStateTerminated]
or pl_state==c_EPTF_LGenBase_stateNames[c_EPTF_LGenBase_tcStateIdle]) {
// pl_state=="Idle" or pl_state=="Stopped" or pl_state=="Stopping" or pl_state=="Finished" or pl_state=="Paused" or pl_state=="Aborted"
// enables startTc:
// disables stopTc:
f_EPTF_ExecCtrl_debug(
"**********START TC ENABLED***********");
vl_currentName := "ExecCtrl.stopTC."&pl_eGrpName&"."&pl_scName&"."&pl_tcName;
vl_idx := f_EPTF_Var_getId(vl_currentName);
f_EPTF_Var_adjustContent(vl_idx,{boolVal := false});
// this scenario cannot be started if it belongs to a scenario group:
var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioIdx(pl_eGrpName,pl_scName);
f_EPTF_Base_assert(%definitionId&": Cannot find scenario "&pl_scName&" of entity group "&pl_eGrpName&" in database.", vl_scIdx != -1);
if (f_EPTF_ExecCtrl_scenarioIsNotInScenarioGroup(vl_scIdx)) {
// Manage Statistics/Scenario control buttons enabled state
vl_currentName := c_EPTF_ExecCtrl_statisticsRoot&".EG."&pl_eGrpName&".SC."&pl_scName&".TC."&pl_tcName&".ControlButtons.Stop";
vl_idx := f_EPTF_Var_getId(vl_currentName);
f_EPTF_Var_setSubsCanAdjust(vl_idx,false);
vl_currentName := c_EPTF_ExecCtrl_statisticsRoot&".EG."&pl_eGrpName&".SC."&pl_scName&".TC."&pl_tcName&".ControlButtons.Start";
vl_idx := f_EPTF_Var_getId(vl_currentName);
f_EPTF_Var_setSubsCanAdjust(vl_idx,true);
}
}
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_UIVars_updateStartDelay_PostProc
//
// Purpose:
// Post proc function to update the startDelay for a traffic case
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_UIVars_updateStartDelay_PostProc(
in integer pl_idx,
in EPTF_IntegerList pl_argList)
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
var integer vl_scIdx := pl_argList[0];
var integer vl_tcOfScIdx := pl_argList[1];
var float vl_startDelay := f_EPTF_Var_getFloatValue(pl_idx);
f_EPTF_ExecCtrl_setStartDelay_TC(vl_scIdx,vl_tcOfScIdx,vl_startDelay);
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_UIVars_updateScenarioCPS
//
// Purpose:
// Test management post proc function to update CPS for a weighted scenario in
// entity group
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_UIVars_updateScenarioCPS(
in integer pl_idx,
in EPTF_IntegerList pl_argList,
in EPTF_Var_DirectContent pl_newContent)
runs on EPTF_ExecCtrl_CT return boolean
{
//TR: MTTSM00015935
if(not ischosen(pl_newContent.floatVal)) { return false; }
if(pl_newContent.floatVal < 0.0) { return false; }
// ~TR
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
// do not send update if value is not changed:
if (f_EPTF_Var_getFloatValue(pl_idx) == pl_newContent.floatVal) {
return true; // no change
}
// set into the content (==comp var) because the function reads data from component var
f_EPTF_Var_setContent(pl_idx,pl_newContent);
// Update according to scenario index
f_EPTF_ExecCtrl_sendUpdatedScenarioCps(pl_argList[0]);
return true;
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_UIVars_updateCPS
//
// Purpose:
// Test management post proc function to update CPS for all TCs in
// scenario group
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_UIVars_updateCPS(
in integer pl_idx,
in EPTF_IntegerList pl_argList,
in EPTF_Var_DirectContent pl_newContent)
runs on EPTF_ExecCtrl_CT return boolean
{
//TR: MTTSM00015935
if(not ischosen(pl_newContent.floatVal)) { return false; }
if(pl_newContent.floatVal < 0.0) { return false; }
// ~TR
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
// do not send update if value is not changed:
if (f_EPTF_Var_getFloatValue(pl_idx) == pl_newContent.floatVal) {
return true; // no change
}
// set into the content (==comp var) because the function reads data from component var
f_EPTF_Var_setContent(pl_idx,pl_newContent);
// Update according to scenario index and tcOfScenario idx
f_EPTF_ExecCtrl_sendUpdatedCps(pl_argList[0], pl_argList[1]);
return true;
}
private function f_EPTF_ExecCtrl_UIVars_guardRegulatorName(
in integer pl_idx,
in EPTF_IntegerList pl_argList,
in EPTF_Var_DirectContent pl_newContent)
runs on EPTF_ExecCtrl_CT return boolean
{
var charstring pl_regulatorName := pl_newContent.charstringVal;
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&" :"& pl_regulatorName);
if (match(pl_regulatorName, pattern "\d+")) {
f_EPTF_ExecCtrl_debug(
"Regulator name is a digit, assuming it is the ID. Converting it into name...");
var charstring vl_regulatorName := f_EPTF_ExecCtrl_Regulator_regulatorName(str2int(pl_regulatorName));
if (vl_regulatorName != "") {
pl_regulatorName := vl_regulatorName;
f_EPTF_ExecCtrl_debug(
"Regulator name is converted to: "&pl_regulatorName);
f_EPTF_Var_adjustContent(pl_idx, {charstringVal := pl_regulatorName});
return false;
}
}
// returns true if the regulator exists:
if (pl_regulatorName!="" and f_EPTF_ExecCtrl_Regulator_getRegulatorId(pl_regulatorName)==-1) {
// set back the original value
// NOTE: GUIHanlder should be fixed to handle adjustContentNack to revert back to the original value
// then this line is not needed:
f_EPTF_ExecCtrl_debug(
"Regulator name not accepted: "& pl_regulatorName);
f_EPTF_Var_adjustContent(pl_idx, {charstringVal := f_EPTF_Var_getCharstringValue(pl_idx)});
return false;
}
return true;
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_UIVars_updateRegulator
//
// Purpose:
// Test management post proc function to update Regulator for a regulated item
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_UIVars_updateRegulator(
in integer pl_idx,
in EPTF_IntegerList pl_argList)
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
if (not v_ExecCtrl_initialized) {
f_EPTF_ExecCtrl_warning(%definitionId&": Update during cleanup ignored.");
return;
}
var integer vl_regulatedItemId := pl_argList[0];
var charstring pl_regulatorName := f_EPTF_Var_getCharstringValue(pl_idx);
if (sizeof(pl_argList)==2) {
// update regulator for the current phase!
var EPTF_ExecCtrl_RegulatedItemName vl_idName := f_EPTF_ExecCtrl_Regulator_itemId2ItemName(vl_regulatedItemId);
var EPTF_ExecCtrl_RegulatedItemId vl_regulatedItemData := f_EPTF_ExecCtrl_Regulator_getRegulatedItemDataById(vl_regulatedItemId);
if (ischosen(vl_idName.cps_TCInPhase)) {
var integer scenidx := vl_regulatedItemData.cps_TCInPhase.scenidx;
var integer vl_scGrpidx := f_EPTF_ExecCtrl_ScenarioGroup_get_byScIndex(scenidx);
var charstring vl_currentPhase := f_EPTF_ExecCtrl_getScenarioGroupInstanceActualPhaseName(vl_scGrpidx);
vl_idName.cps_TCInPhase.phase := vl_currentPhase;
vl_regulatedItemId := f_EPTF_ExecCtrl_Regulator_getRegulatedItemId(vl_idName);
// set the content of the other variable (without calling postProc fns to avoid infinite loop):
var charstring vl_otherName := f_EPTF_Var_getName(pl_idx); // this is my name (does not include the phase)
vl_otherName := vl_otherName&".InPhase."&vl_currentPhase; // this is the other var name
var integer vl_otherIdx := f_EPTF_Var_getId(vl_otherName);
f_EPTF_Var_adjustContent(vl_otherIdx,{charstringVal := pl_regulatorName});
f_EPTF_ExecCtrl_debug("Var "&vl_otherName&" changed to: "&pl_regulatorName);
} else if (ischosen(vl_idName.cps_SCInPhase)) {
var integer scenidx := vl_regulatedItemData.cps_SCInPhase.scenidx;
var integer vl_scGrpidx := f_EPTF_ExecCtrl_ScenarioGroup_get_byScIndex(scenidx);
var charstring vl_currentPhase := f_EPTF_ExecCtrl_getScenarioGroupInstanceActualPhaseName(vl_scGrpidx);
vl_idName.cps_SCInPhase.phase := vl_currentPhase;
vl_regulatedItemId := f_EPTF_ExecCtrl_Regulator_getRegulatedItemId(vl_idName);
// set the content of the other variable (without calling postProc fns to avoid infinite loop):
var charstring vl_otherName := f_EPTF_Var_getName(pl_idx); // this is my name (does not include the phase)
vl_otherName := vl_otherName&".InPhase."&vl_currentPhase; // this is the other var name
var integer vl_otherIdx := f_EPTF_Var_getId(vl_otherName);
f_EPTF_Var_adjustContent(vl_otherIdx,{charstringVal := pl_regulatorName});
f_EPTF_ExecCtrl_debug("Var "&vl_otherName&" changed to: "&pl_regulatorName);
}
}
// Update according to group and scenario index in grp2scenario DB
f_EPTF_ExecCtrl_Regulator_setRegulatorName(vl_regulatedItemId,pl_regulatorName);
f_EPTF_ExecCtrl_Regulator_logAll();
}
private function f_EPTF_ExecCtrl_UIVars_SubscribeVars2ScenarioTab_TrafficCase2_vars()
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
var integer vl_offset := 0;
var charstring vl_currentName;
var integer vl_idx;
var integer vl_sizeScen := f_EPTF_ExecCtrl_numScenarios();
var integer vl_sizeTCs;
for (var integer sidx := 0; sidx < vl_sizeScen; sidx := sidx + 1)
{
f_EPTF_ExecCtrl_updateProgressbar(50.0/int2float(vl_sizeScen));
var integer vl_eGrpIdx := f_EPTF_ExecCtrl_getScenarioEGroupIdx(sidx);
var charstring grpName := f_EPTF_ExecCtrl_eGrp_name(vl_eGrpIdx);
var charstring scenName := f_EPTF_ExecCtrl_getScenarioName(sidx);
// Scenario name
vl_currentName := "Traffic.ScenarioName." & grpName&"." & int2str(sidx);
// vl_widgetId :=
// c_EPTF_ExecCtrl_TrafficTabId_TC & "." & int2str(vl_offset) & ".0";
f_EPTF_Var_newCharstring(
vl_currentName, f_EPTF_ExecCtrl_getScenarioInstanceName(sidx), vl_idx);
f_EPTF_Var_setSubsCanAdjust(vl_idx,false);
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (TC / Scenario name) id: "
&int2str(vl_idx));
// Scenario type
vl_currentName := "Traffic.ScenarioType." & grpName&"."& int2str(sidx);
// vl_widgetId :=
// c_EPTF_ExecCtrl_TrafficTabId_TC & "." & int2str(vl_offset) & ".1";
var charstring vl_type := "Decl";
if (f_EPTF_ExecCtrl_isWeightedScenario(sidx)) {
vl_type := "Weighted";
}
f_EPTF_Var_newCharstring(
vl_currentName, vl_type, vl_idx);
f_EPTF_Var_setSubsCanAdjust(vl_idx,false);
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (TC / Scenario type) id: "
&int2str(vl_idx));
// Scenario status
vl_currentName := "ExecCtrl.scenarioStatus."&grpName&"."&scenName;
// vl_widgetId :=
// c_EPTF_ExecCtrl_TrafficTabId_TC & "." & int2str(vl_offset) & ".2";
// FIXME: fix in f_EPTF_ExecCtrl_subscribeScenarioState needed
if (f_EPTF_Var_getId(vl_currentName) == -1) {
vl_offset := vl_offset + 1;
continue;
}
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (TC / Scenario status) id: "
&int2str(vl_idx));
if (f_EPTF_ExecCtrl_isWeightedScenario(sidx)) {
// Scenario CPS
vl_currentName := "Traffic.ScenarioCPS." & grpName&"."& int2str(sidx);
// vl_widgetId :=
// c_EPTF_ExecCtrl_TrafficTabId_TC & "." & int2str(vl_offset) & ".5";
f_EPTF_ExecCtrl_createRefVarForWScCPSToReach(
vl_currentName, sidx, vl_idx);
// Refresh refered variable for TargetCPS
var integer vl_previdx;
f_EPTF_Var_newFloat( vl_currentName&".prevvalue", v_ExecCtrl_scenarios[sidx].scData.weightedScData.cpsToReach, vl_previdx);
f_EPTF_Var_addSyncCallBackFn( refers(f_EPTF_ExecCtrl_refreshCallBackTargetCPS), {vl_idx, vl_previdx});
f_EPTF_Var_addPostProcFn(vl_idx, {refers(f_EPTF_ExecCtrl_refreshPostProcRegulatorTotalCPS), {sidx} } );
f_EPTF_Var_addGuardFn(
vl_idx, { refers(f_EPTF_ExecCtrl_UIVars_updateScenarioCPS), {sidx}} );
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (TC / Scenario CPS) id: "
&int2str(vl_idx));
} // f_EPTF_ExecCtrl_isWeightedScenario(sidx)
vl_sizeTCs := f_EPTF_ExecCtrl_numTcOfScenario(sidx);
for (var integer tcidx := 0; tcidx < vl_sizeTCs; tcidx := tcidx + 1)
{
// Traffic case (of current scenarios)
vl_currentName := "Traffic.TC." & grpName&"."& int2str(sidx) & "." & int2str(tcidx);
// vl_widgetId :=
// c_EPTF_ExecCtrl_TrafficTabId_TC & "." & int2str(vl_offset) & ".6";
var charstring tcName := f_EPTF_ExecCtrl_tcNameOfTcOfSc(sidx,tcidx)
f_EPTF_Var_newCharstring(
vl_currentName,
tcName,
vl_idx);
f_EPTF_Var_setSubsCanAdjust(vl_idx,false);
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (TC / TC name) id: "
&int2str(vl_idx));
// Start Traffic case
vl_currentName := "ExecCtrl.startTC."&grpName&"."&scenName&"."&tcName;
// vl_widgetId :=
// c_EPTF_ExecCtrl_TrafficTabId_TC & "." & int2str(vl_offset) & ".7";
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (TC / Start TC) id: "
&int2str(vl_idx));
// Stop Traffic case
vl_currentName := "ExecCtrl.stopTC."&grpName&"."&scenName&"."&tcName;
// vl_widgetId :=
// c_EPTF_ExecCtrl_TrafficTabId_TC & "." & int2str(vl_offset) & ".8";
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (TC / Stop TC) id: "
&int2str(vl_idx));
if (not f_EPTF_ExecCtrl_isWeightedScenario(sidx)) {
// Traffic case start delay time
vl_currentName := "Traffic.TCDelay."& grpName&"." & int2str(sidx) & "." & int2str(tcidx);
// vl_widgetId :=
// c_EPTF_ExecCtrl_TrafficTabId_TC & "." & int2str(vl_offset) & ".9";
f_EPTF_Var_newFloat(
vl_currentName,
f_EPTF_ExecCtrl_getScenarioTcStartDelay(sidx,tcidx),
vl_idx);
f_EPTF_Var_addPostProcFn(
vl_idx, { refers(f_EPTF_ExecCtrl_UIVars_updateStartDelay_PostProc), {sidx,tcidx}} );
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (TC / TC start delay) id: "
&int2str(vl_idx));
}
// Traffic case target CPS (call per second)
vl_currentName := "Traffic.TCCPS." & grpName&"."& int2str(sidx) & "." & int2str(tcidx);
// vl_widgetId :=
// c_EPTF_ExecCtrl_TrafficTabId_TC & "." & int2str(vl_offset) & ".10";
f_EPTF_ExecCtrl_createRefVarForTcCPSToReach(sidx,tcidx,vl_currentName,vl_idx);
// Refresh refered variable for TargetCPS
var integer vl_previdx;
if (f_EPTF_ExecCtrl_isWeightedScenario(sidx)) {
f_EPTF_Var_newFloat(
vl_currentName&".prevvalue",
v_ExecCtrl_scenarios[sidx].scData.tcList[tcidx].target.trafficWeight,
vl_previdx);
} else {
f_EPTF_Var_newFloat(
vl_currentName&".prevvalue",
v_ExecCtrl_scenarios[sidx].scData.tcList[tcidx].target.cpsToReach,
vl_previdx);
}
f_EPTF_Var_addSyncCallBackFn(refers(f_EPTF_ExecCtrl_refreshCallBackTargetCPS), {vl_idx, vl_previdx});
f_EPTF_Var_addPostProcFn(vl_idx, {refers(f_EPTF_ExecCtrl_refreshPostProcRegulatorTotalCPS), {sidx, tcidx} } )
f_EPTF_Var_addGuardFn(
vl_idx, { refers(f_EPTF_ExecCtrl_UIVars_updateCPS), {sidx, tcidx}} );
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (TC / TC target CPS) id: "
&int2str(vl_idx));
// TimeProfile
if (not f_EPTF_ExecCtrl_isWeightedScenario(sidx)
or (tcidx==0 and f_EPTF_ExecCtrl_isWeightedScenario(sidx))) {
vl_currentName := "Traffic.TimeProfile." & grpName&"."& int2str(sidx) & "." & int2str(tcidx);
// vl_widgetId :=
// c_EPTF_ExecCtrl_TrafficTabId_TC & "." & int2str(vl_offset) & ".11";
var charstring vl_timeProfileName := f_EPTF_ExecCtrl_getTimeProfileNameForTC(sidx,tcidx);
f_EPTF_Var_newCharstring(
vl_currentName,
vl_timeProfileName,
vl_idx);
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (TC / TC time profile) id: "
&int2str(vl_idx));
}// if
// Regulator
if (not f_EPTF_ExecCtrl_isWeightedScenario(sidx)
or (tcidx==0 and f_EPTF_ExecCtrl_isWeightedScenario(sidx))) {
// vl_widgetId :=
// c_EPTF_ExecCtrl_TrafficTabId_TC & "." & int2str(vl_offset) & ".12";
var charstring vl_regulatorName := "";
var EPTF_ExecCtrl_RegulatedItemName vl_idName;
var integer vl_scGrpidx := f_EPTF_ExecCtrl_ScenarioGroup_get_byScIndex(sidx);
if (vl_scGrpidx==-1) {
if (f_EPTF_ExecCtrl_isWeightedScenario(sidx)) {
vl_idName := {cps_SC := {grpName,scenName}};
vl_currentName := "Traffic.Regulator." & grpName&"."& int2str(sidx);
} else {
vl_idName := {cps_TC := {grpName,scenName,tcName}};
vl_currentName := "Traffic.Regulator." & grpName&"."& int2str(sidx) & "." & int2str(tcidx); // tc idx shall be there for non-weighted Sc
}
} else {
// for scenarios in scenario groups: it shows the regulator in the current phase
var EPTF_ExecCtrl_PhaseList_Instance phaseList := f_EPTF_ExecCtrl_getScenarioGroupInstanceGroupPhaseList(vl_scGrpidx);
// create variables for all phases:
for(var integer ph:=0; ph<f_EPTF_ExecCtrl_getScenarioGroupInstanceGroupPhaseListPhasesNum(vl_scGrpidx); ph:=ph+1) {
var charstring vl_phaseName := f_EPTF_ExecCtrl_getScenarioGroupInstanceGroupPhaseListPhaseName(vl_scGrpidx,ph);
if (f_EPTF_ExecCtrl_isWeightedScenario(sidx)) {
vl_idName := {cps_SCInPhase := {grpName,scenName, vl_phaseName}};
vl_currentName := "Traffic.Regulator." & grpName&"."& int2str(sidx)&".InPhase."&vl_phaseName;
} else {
vl_idName := {cps_TCInPhase := {grpName,scenName,tcName, vl_phaseName}};
vl_currentName := "Traffic.Regulator." & grpName&"."& int2str(sidx) & "." & int2str(tcidx)&".InPhase."&vl_phaseName; // tc idx shall be there for non-weighted Sc
}
var integer vl_regulatedItemId := f_EPTF_ExecCtrl_Regulator_getRegulatedItemId(vl_idName);
f_EPTF_Base_assert(%definitionId&": Regulated item is not found: "&log2str(vl_idName), vl_regulatedItemId!=-1);
vl_regulatorName := f_EPTF_ExecCtrl_Regulator_getRegulatorName(vl_regulatedItemId);
f_EPTF_Var_newCharstring(
vl_currentName,
vl_regulatorName,
vl_idx);
f_EPTF_Var_addGuardFn(
vl_idx, { refers(f_EPTF_ExecCtrl_UIVars_guardRegulatorName), {vl_regulatedItemId}} );
f_EPTF_Var_addPostProcFn(
vl_idx, { refers(f_EPTF_ExecCtrl_UIVars_updateRegulator), {vl_regulatedItemId}} );
}
// put regulator in CURRENT PHASE to the GUI:
var charstring vl_phaseName := f_EPTF_ExecCtrl_getScenarioGroupInstanceActualPhaseName(vl_scGrpidx);
if (f_EPTF_ExecCtrl_isWeightedScenario(sidx)) {
vl_idName := {cps_SCInPhase := {grpName,scenName, vl_phaseName}};
vl_currentName := "Traffic.Regulator." & grpName&"."& int2str(sidx);
} else {
vl_idName := {cps_TCInPhase := {grpName,scenName,tcName, vl_phaseName}};
vl_currentName := "Traffic.Regulator." & grpName&"."& int2str(sidx) & "." & int2str(tcidx); // tc idx shall be there for non-weighted Sc
}
}
var integer vl_regulatedItemId := f_EPTF_ExecCtrl_Regulator_getRegulatedItemId(vl_idName);
f_EPTF_Base_assert(%definitionId&": Regulated item is not found: "&log2str(vl_idName), vl_regulatedItemId!=-1);
vl_regulatorName := f_EPTF_ExecCtrl_Regulator_getRegulatorName(vl_regulatedItemId);
f_EPTF_Var_newCharstring(
vl_currentName,
vl_regulatorName,
vl_idx);
f_EPTF_Var_addGuardFn(
vl_idx, { refers(f_EPTF_ExecCtrl_UIVars_guardRegulatorName), {vl_regulatedItemId}} );
f_EPTF_Var_addPostProcFn(
vl_idx, { refers(f_EPTF_ExecCtrl_UIVars_updateRegulator), {vl_regulatedItemId, -1}} ); // -1: update regulator for the current phase
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (TC / TC regulator) id: "
&int2str(vl_idx));
}// if
// Increase offset
vl_offset := vl_offset + 1;
}
// vl_offset := vl_offset + 1;
// f_EPTF_ExecCtrl_UIVars_createScenarioTab_TableRow(c_EPTF_ExecCtrl_TrafficTabId_TC);
}
}
// portProc function for the "RegulatedItemEnabled" variable on the GUI
// this starts/stops the regulator if necessary
private function f_EPTF_ExecCtrl_UIVars_enableRegulatedItem_PostProc(
in integer pl_idx,
in EPTF_IntegerList pl_argList)
runs on EPTF_ExecCtrl_CT
{
if (not v_ExecCtrl_initialized) {
return;
}
var integer vl_regulatedItemId := pl_argList[0];
var integer vl_regulatorId := f_EPTF_ExecCtrl_Regulator_getRegulatorId(f_EPTF_ExecCtrl_Regulator_getRegulatorName(vl_regulatedItemId));
if (vl_regulatorId!=-1) {
f_EPTF_ExecCtrl_Regulator_startStop(vl_regulatorId);
}
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_UIVars_SubscribeVars2RegulatedItemsTab_vars
//
// Purpose:
// Subscribe entity group related variables to GUI
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_UIVars_SubscribeVars2RegulatedItemsTab_vars()
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
f_EPTF_ExecCtrl_updateProgressbar(0.0, "Creating Regulator panel variables");
var charstring vl_currentName;
var integer vl_idx;
var integer vl_size := f_EPTF_ExecCtrl_Regulator_nofRegulatedItems();
for (var integer i := 0; i < vl_size; i := i + 1)
{
f_EPTF_ExecCtrl_updateProgressbar(80.0/int2float(vl_size));
// Item type
vl_currentName := "RegulatedItemType." & int2str(i);
// vl_widgetId := c_EPTF_ExecCtrl_RegulatedItemsTabId & "." & int2str(i) & ".0";
var charstring vl_tmpstr := "";
var EPTF_ExecCtrl_RegulatedItemName vl_idName := f_EPTF_ExecCtrl_Regulator_itemId2ItemName(i);
if (ischosen(vl_idName.cps_TC)) {
vl_tmpstr := "TrafficCase CPS"
}
if (ischosen(vl_idName.cps_SC)) {
vl_tmpstr := "Scenario CPS"
}
if (ischosen(vl_idName.cps_TCInPhase)) {
vl_tmpstr := "TrafficCase CPS @ Phase"
}
if (ischosen(vl_idName.cps_SCInPhase)) {
vl_tmpstr := "Scenario CPS @ Phase"
}
f_EPTF_Var_newCharstring(
vl_currentName, vl_tmpstr, vl_idx);
f_EPTF_Var_setSubsCanAdjust(vl_idx,false);
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (RegItems / Item type) id: "
&int2str(vl_idx));
// Item name
vl_currentName := "RegulatedItemName." & int2str(i);
// vl_widgetId := c_EPTF_ExecCtrl_RegulatedItemsTabId & "." & int2str(i) & ".1";
vl_tmpstr := "";
if (ischosen(vl_idName.cps_TC)) {
vl_tmpstr := vl_idName.cps_TC.eGrpName
&"."&vl_idName.cps_TC.scName
&"."&vl_idName.cps_TC.tcName;
}
if (ischosen(vl_idName.cps_SC)) {
vl_tmpstr := vl_idName.cps_SC.eGrpName
&"."&vl_idName.cps_SC.scName;
}
if (ischosen(vl_idName.cps_TCInPhase)) {
vl_tmpstr := vl_idName.cps_TCInPhase.eGrpName
&"."&vl_idName.cps_TCInPhase.scName
&"."&vl_idName.cps_TCInPhase.tcName
&"@"&vl_idName.cps_TCInPhase.phase;
}
if (ischosen(vl_idName.cps_SCInPhase)) {
vl_tmpstr := vl_idName.cps_SCInPhase.eGrpName
&"."&vl_idName.cps_SCInPhase.scName
&"@"&vl_idName.cps_SCInPhase.phase;
}
f_EPTF_str2int_HashMap_Insert(v_ExecCtrl_regulatedItemsHash, vl_tmpstr, i);
f_EPTF_Var_newCharstring(
vl_currentName, vl_tmpstr, vl_idx);
f_EPTF_Var_setSubsCanAdjust(vl_idx,false);
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (RegItems / Item name) id: "
&int2str(vl_idx));
// Weight
vl_currentName := "RegulatedItemWeight." & int2str(i);
// vl_widgetId := c_EPTF_ExecCtrl_RegulatedItemsTabId & "." & int2str(i) & ".3";
f_EPTF_ExecCtrl_Regulator_createRefVarFromRegulatedItemWeight(
vl_currentName, i, vl_idx);
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (RegItems / Item Weight) id: "
&int2str(vl_idx));
// Enabled
vl_currentName := "RegulatedItemEnabled." & int2str(i);
// vl_widgetId := c_EPTF_ExecCtrl_RegulatedItemsTabId & "." & int2str(i) & ".4";
f_EPTF_ExecCtrl_Regulator_createRefVarFromRegulatedItemEnabled(
vl_currentName, i, vl_idx);
f_EPTF_Var_addPostProcFn(vl_idx, { refers(f_EPTF_ExecCtrl_UIVars_enableRegulatedItem_PostProc), {i} });
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (RegItems / Item Enabled) id: "
&int2str(vl_idx));
}
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_UIVars_SubscribeVars2RegulatorsTargetValueTab_vars
//
// Purpose:
// Subscribe regulator related variables to GUI
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_UIVars_SubscribeVars2RegulatorsTargetValueTab_vars()
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
var charstring vl_currentName;
var integer vl_idx;
var integer vl_size := f_EPTF_ExecCtrl_Regulator_getNofRegulators();
for (var integer i := 0; i < vl_size; i := i + 1)
{
f_EPTF_ExecCtrl_updateProgressbar(20.0/int2float(vl_size));
// Regulator Name
vl_currentName := "RegulatedItems_tab."&"RegulatorName." & int2str(i);
// vl_widgetId := c_EPTF_ExecCtrl_RegulatorsTotalValueTabId & "." & int2str(i) & ".0";
f_EPTF_Var_newCharstring(
vl_currentName, f_EPTF_ExecCtrl_Regulator_getRegulatorNameByRegulatorId(i), vl_idx);
// // FIXME: if this is commented in: regulator cannot set the values of its variables
// vl_idx := f_EPTF_ExecCtrl_Regulator_getRegulatorStatusIdxByRegulatorId(i);
// f_EPTF_Var_addPostProcFn(
// vl_idx, { refers(f_EPTF_ExecCtrl_enableRegulatorTargetLoad), {i}} );
// // call the postproc:
// f_EPTF_ExecCtrl_enableRegulatorTargetLoad(vl_idx,{i});
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (Regulators / Reg Name) id: "
&int2str(vl_idx));
}
}
private function f_EPTF_ExecCtrl_enableRegulatorTargetLoad(
in integer pl_idx,
in EPTF_IntegerList pl_argList
) runs on EPTF_ExecCtrl_CT {
if (f_EPTF_Base_cleanupIsInProgress()==false) {
return; // cleanup is in progress, GUI may not answer disableWidget request after cleanup
}
var integer vl_regulatorIdx := pl_argList[0];
var integer vl_regulatedValueVarIdx := f_EPTF_ExecCtrl_Regulator_getRegulatorTotalValueIdxByRegulatorId(vl_regulatorIdx);
var integer vl_targetLoadVarIdx := f_EPTF_ExecCtrl_Regulator_getRegulatorTargetLoadIdxByRegulatorId(vl_regulatorIdx);
var EPTF_StatusLED vl_statusLEDVal := f_EPTF_Var_getStatusLEDValue(pl_idx);
if (vl_statusLEDVal == {led_red, "Disconnected"}) {
f_EPTF_Var_setSubsCanAdjust(vl_regulatedValueVarIdx,false);
f_EPTF_Var_setSubsCanAdjust(vl_targetLoadVarIdx,true);
} else {
f_EPTF_Var_setSubsCanAdjust(vl_regulatedValueVarIdx,true);
f_EPTF_Var_setSubsCanAdjust(vl_targetLoadVarIdx,false);
}
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_UIVars_start
//
// Purpose:
// Test management post proc function to start traffic cases
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_UIVars_start_PostProc(
in integer pl_idx,
in EPTF_IntegerList pl_argList)
runs on EPTF_ExecCtrl_CT
{
if (not v_ExecCtrl_initialized) {
return;
}
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
var integer vl_startIdx := pl_argList[0];
var integer vl_stopIdx := pl_argList[1];
f_EPTF_Var_setSubsCanAdjust(vl_startIdx,false);
f_EPTF_Var_setSubsCanAdjust(vl_stopIdx,true);
// Start scenarios
f_EPTF_ExecCtrl_startAllScenarios();
// start the time profiles:
// f_EPTF_ExecCtrl_startTimeProfiles(); - already in f_EPTF_ExecCtrl_startAllScenarios()
}
private function f_EPTF_ExecCtrl_UIVars_timeElapsed(
in EPTF_IntegerList pl_argList)
runs on EPTF_ExecCtrl_CT
{
// TR HQ88308 - Refresh sampled & sync variables on GUI.
f_EPTF_ExecCtrl_UIVars_refreshSampledAtSync_vars();
var integer pl_idx := pl_argList[0];
// v_EPTF_ExecCtrl_startTime is -1 if scenarios (=timeProfiles) are not running
if (f_EPTF_ExecCtrl_startTime()>0.0)
{
if(v_EPTF_ExecCtrl_timeFormat == SECONDS)
{
f_EPTF_Var_adjustContent(pl_idx,{charstringVal := "Time elapsed since Test was started: " & float2str(T_EPTF_componentClock.read-f_EPTF_ExecCtrl_startTime())});
}
else if(v_EPTF_ExecCtrl_timeFormat == HH_MM_SS)
{
var integer vl_nrOfSeconds := float2int(T_EPTF_componentClock.read-f_EPTF_ExecCtrl_startTime());
var integer vl_seconds := vl_nrOfSeconds mod 60;
var integer vl_minutes := vl_nrOfSeconds / 60 mod 60;
var integer vl_hours := vl_nrOfSeconds / 3600;
var charstring vl_formattedTime;
if(vl_hours < 10)
{
vl_formattedTime := "0"&int2str(vl_hours);
}
else
{
vl_formattedTime := int2str(vl_hours);
}
if(vl_minutes < 10)
{
vl_formattedTime := vl_formattedTime & ":0" & int2str(vl_minutes);
}
else
{
vl_formattedTime := vl_formattedTime & ":" & int2str(vl_minutes);
}
if(vl_seconds < 10)
{
vl_formattedTime := vl_formattedTime & ":0" & int2str(vl_seconds);
}
else
{
vl_formattedTime := vl_formattedTime & ":" & int2str(vl_seconds);
}
f_EPTF_Var_adjustContent(pl_idx,{charstringVal := "Time elapsed since Test was started: " & vl_formattedTime});
}
}
}
// TR HQ88308 - Refresh sampled & sync variables on GUI.
private function f_EPTF_ExecCtrl_UIVars_storeSampledAtSync_vars(in integer pl_varIdx) runs on EPTF_ExecCtrl_CT {
v_EPTF_ExecCtrl_SampledAtSync_vars[sizeof(v_EPTF_ExecCtrl_SampledAtSync_vars)] := pl_varIdx;
}
// TR HQ88308 - Refresh sampled & sync variables on GUI.
private function f_EPTF_ExecCtrl_UIVars_refreshSampledAtSync_vars() runs on EPTF_ExecCtrl_CT {
if (not v_ExecCtrl_initialized) {
return;
}
for(var integer i := 0, size := sizeof(v_EPTF_ExecCtrl_SampledAtSync_vars); i < size; i := i + 1) {
f_EPTF_Var_refreshContent(v_EPTF_ExecCtrl_SampledAtSync_vars[i]); // update the gui with the current value
}
}
private function f_EPTF_ExecCtrl_UIVars_Subscribe2TimeElapsed_vars() runs on EPTF_ExecCtrl_CT {
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
var integer vl_idx;
if(v_EPTF_ExecCtrl_timeFormat == SECONDS)
{
f_EPTF_Var_newCharstring(c_EPTF_ExecCtrl_TimeElapsed, "Time elapsed since Test was started: 0.0", vl_idx);
}
else if(v_EPTF_ExecCtrl_timeFormat == HH_MM_SS)
{
f_EPTF_Var_newCharstring(c_EPTF_ExecCtrl_TimeElapsed, "Time elapsed since Test was started: 00:00:00", vl_idx);
}
f_EPTF_Var_addSyncCallBackFn(
refers(f_EPTF_ExecCtrl_UIVars_timeElapsed), {vl_idx} );
f_EPTF_ExecCtrl_debug(
"Last created to GUI variable (Time elapsed) id: "
&int2str(vl_idx));
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_UIVars_stop_PostProc
//
// Purpose:
// Test management post proc function to stop traffic cases
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_UIVars_stop_PostProc(
in integer pl_idx,
in EPTF_IntegerList pl_argList)
runs on EPTF_ExecCtrl_CT
{
if (not v_ExecCtrl_initialized) {
return;
}
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
var integer vl_idx := f_EPTF_Var_getId(c_EPTF_ExecCtrl_TimeElapsed);
f_EPTF_ExecCtrl_UIVars_timeElapsed({vl_idx})
var integer vl_startIdx := pl_argList[0];
var integer vl_stopIdx := pl_argList[1];
f_EPTF_Var_setSubsCanAdjust(vl_startIdx,true);
f_EPTF_Var_setSubsCanAdjust(vl_stopIdx,false);
// restart if not manual:
if (not f_EPTF_ExecCtrl_getManualControl() and not tsp_EPTF_ExecCtrl_UIHandler_disableAutoEnablingOfManualControlModeWhenStopButtonIsPressed) {
f_EPTF_ExecCtrl_setManualControl(true);
}
// stop scenarios:
f_EPTF_ExecCtrl_stopAllScenarios();
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_UIVars_terminate_PostProc
//
// Purpose:
// Test management post proc function to terminate traffic cases
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_UIVars_terminate_PostProc(
in integer pl_idx,
in EPTF_IntegerList pl_argList)
runs on EPTF_ExecCtrl_CT
{
if (not v_ExecCtrl_initialized) {
return;
}
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
var integer vl_idx := f_EPTF_Var_getId(c_EPTF_ExecCtrl_TimeElapsed);
f_EPTF_ExecCtrl_UIVars_timeElapsed({vl_idx})
var integer vl_startIdx := pl_argList[0];
var integer vl_stopIdx := pl_argList[1];
f_EPTF_Var_setSubsCanAdjust(vl_startIdx,true);
f_EPTF_Var_setSubsCanAdjust(vl_stopIdx,false);
// restart if not manual:
if (not f_EPTF_ExecCtrl_getManualControl() and not tsp_EPTF_ExecCtrl_UIHandler_disableAutoEnablingOfManualControlModeWhenStopButtonIsPressed) {
f_EPTF_ExecCtrl_setManualControl(true);
}
// terminate scenarios:
f_EPTF_ExecCtrl_terminateAllScenarios();
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_UIVars_Snapshot_PostProc
//
// Purpose:
// Test management post proc function for the snapshot button
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// It logs the variables that are registered to save into the log file.
// Default setting is used for the tsp and selfName is saved into the variable name.
//
///////////////////////////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_UIVars_Snapshot_PostProc(
in integer pl_idx,
in EPTF_IntegerList pl_argList)
runs on EPTF_ExecCtrl_CT
{
if (not v_ExecCtrl_initialized) {
return;
}
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
f_EPTF_ExecCtrl_debug(
"Variables saved to: "& f_EPTF_Var_saveVars2tsp());
if (f_EPTF_ExecCtrl_debugEnabled()) {
f_EPTF_Var_CT_LogAll("-------SNAPSHOT OF EPTF_Vars------------");
}
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_UIVars_Subscribe2TestMgmtButtons_vars
//
// Purpose:
// Subscribe variables to test management buttons and adds test management
// post processing functions
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_UIVars_Subscribe2TestMgmtButtons_vars()
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
var integer vl_varId := 0;
// Start button
var integer vl_startIdx,vl_stopIdx,vl_terminateIdx;
f_EPTF_Var_newInt(
c_EPTF_ExecCtrl_Start, 0, vl_startIdx);
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (Start button) id: "
&int2str(vl_varId));
// Stop button
f_EPTF_Var_newInt(
c_EPTF_ExecCtrl_Stop, 0, vl_stopIdx);
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (Stop button) id: "
&int2str(vl_varId));
// Terminate button
f_EPTF_Var_newInt(
c_EPTF_ExecCtrl_Terminate, 0, vl_terminateIdx);
// add postProc-es:
f_EPTF_Var_addPostProcFn(
vl_startIdx, { refers(f_EPTF_ExecCtrl_UIVars_start_PostProc), {vl_startIdx,vl_stopIdx}} );
f_EPTF_Var_addPostProcFn(
vl_stopIdx, { refers(f_EPTF_ExecCtrl_UIVars_stop_PostProc), {vl_startIdx,vl_stopIdx}} );
f_EPTF_Var_addPostProcFn(
vl_terminateIdx, { refers(f_EPTF_ExecCtrl_UIVars_terminate_PostProc), {vl_startIdx,vl_stopIdx}} );
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (Terminate button) id: "
&int2str(vl_varId));
/* // uncomment it when needed:
// RunTest(Enable test) button
f_EPTF_Var_newInt(
c_EPTF_ExecCtrl_RunTest, 0, vl_varId);
//f_EPTF_Var_addPostProcFn(
// vl_varId, { refers(f_EPTF_ExecCtrl_UIVars_RunTest), {}} );
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (RunTest button) id: "
&int2str(vl_varId));
*/
// Snapshot button
f_EPTF_Var_newInt(
c_EPTF_ExecCtrl_Snapshot, 0, vl_varId);
f_EPTF_Var_addPostProcFn(
vl_varId, { refers(f_EPTF_ExecCtrl_UIVars_Snapshot_PostProc), {}} );
f_EPTF_Var_setSubsCanAdjust(vl_startIdx,false);
f_EPTF_Var_setSubsCanAdjust(vl_stopIdx,false);
// enable start button
if (v_ExecCtrl_manualControl==true) { // test is not running
f_EPTF_Var_setSubsCanAdjust(vl_startIdx,true);
f_EPTF_Var_setSubsCanAdjust(vl_stopIdx,false);
} else {
f_EPTF_Var_setSubsCanAdjust(vl_startIdx,false);
f_EPTF_Var_setSubsCanAdjust(vl_stopIdx,true);
}
f_EPTF_ExecCtrl_debug(
"Last subscribed to GUI variable (Snapshot button) id: "
&int2str(vl_varId));
}
friend function f_EPTF_ExecCtrl_UIVars_getPhaseListTabName_FromPhaseListDB(in integer p_idx)
runs on EPTF_ExecCtrl_CT
return charstring
{
return "Execution_Control.PhaseLists.tabbox"&"."&f_EPTF_ExecCtrl_getPhaseListDeclaratorName(p_idx)&".tab";
}
private function f_EPTF_ExecCtrl_UIVars_enablePhaseInDeclarator(
in integer pl_idx,
in EPTF_IntegerList pl_argList)
runs on EPTF_ExecCtrl_CT
{
if (not v_ExecCtrl_initialized) {
return;
}
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
var integer vl_declaratorIdx := pl_argList[0];
var integer vl_phaseIdx := pl_argList[1];
var boolean vl_phaseState := f_EPTF_Var_getBoolValue(pl_idx);
f_EPTF_ExecCtrl_setPhaseListDeclaratorPhaseEnabled(vl_declaratorIdx,vl_phaseIdx,vl_phaseState);
}
private function f_EPTF_ExecCtrl_UIVars_appendPhaseListTab_vars(in integer p_idx)
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug("### "&%definitionId&"()");
for (var integer i:=0; i<f_EPTF_ExecCtrl_getPhaseListDeclaratorPhasesNum(p_idx); i:=i+1)
{
var charstring vl_widgetId := f_EPTF_ExecCtrl_UIVars_getPhaseListTabName_FromPhaseListDB(p_idx)&
".mainTable."&f_EPTF_ExecCtrl_getPhaseListDeclaratorPhaseName(p_idx,i);
var integer vl_idx;
f_EPTF_Var_newBool(
"Var." & vl_widgetId,
f_EPTF_ExecCtrl_getPhaseListDeclaratorPhaseEnabled(p_idx,i),
vl_idx);
f_EPTF_Var_addPostProcFn(
vl_idx, { refers(f_EPTF_ExecCtrl_UIVars_enablePhaseInDeclarator), {p_idx, i}} );
}
}
friend function f_EPTF_ExecCtrl_UIVars_getPhaseListTabName_FromScenarioGroupDB(in integer p_idx)
runs on EPTF_ExecCtrl_CT
return charstring
{
return "Execution_Control.PhaseLists.tabbox"&"."&f_EPTF_ExecCtrl_getScenarioGroupInstanceGroupPhaseListName(p_idx)&".tab";
}
friend function f_EPTF_ExecCtrl_UIVars_getScenarioGroupTableName_FromScenarioGroupDB(in integer p_idx)
runs on EPTF_ExecCtrl_CT
return charstring
{
return f_EPTF_ExecCtrl_UIVars_getPhaseListTabName_FromScenarioGroupDB(p_idx) & "." &
f_EPTF_ExecCtrl_getScenarioGroupInstanceName(p_idx);
}
private function f_EPTF_ExecCtrl_UIVars_guardPhaseForScenarioGroup(
in integer pl_idx,
in EPTF_IntegerList pl_argList,
in EPTF_Var_DirectContent pl_newContent)
runs on EPTF_ExecCtrl_CT return boolean
{
if (v_ExecCtrl_initialized==false) {
return false; // cleanup is in progress, or not initialized
}
var integer vl_scenarioGroupIdx := pl_argList[0];
var charstring vl_newPhase := pl_newContent.charstringVal;
if (
f_EPTF_ExecCtrl_getScenarioGroupInstanceIsValidPhase(vl_scenarioGroupIdx, vl_newPhase)>-1 and
(
f_EPTF_ExecCtrl_getScenarioGroupInstanceGroupPhaseListActualPhaseState(vl_scenarioGroupIdx) == IDLE or
f_EPTF_ExecCtrl_getScenarioGroupInstanceGroupPhaseListActualPhaseState(vl_scenarioGroupIdx) == FINISHED
)
)
{ return true; }
return false;
}
private function f_EPTF_ExecCtrl_UIVars_setPhaseForScenarioGroup(
in integer pl_idx,
in EPTF_IntegerList pl_argList)
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
if (v_ExecCtrl_initialized==false) {
return; // cleanup is in progress, or not initialized
}
var integer vl_scenarioGroupIdx := pl_argList[0];
var charstring vl_phaseName := f_EPTF_Var_getCharstringValue(pl_idx);
f_EPTF_ExecCtrl_debug(log2str("Setting phase: " & vl_phaseName & " for " & f_EPTF_ExecCtrl_getScenarioGroupInstanceName(vl_scenarioGroupIdx)));
if(not f_EPTF_ExecCtrl_getScenarioGroupInstanceSetPhase(vl_scenarioGroupIdx, vl_phaseName)) {/*this cannot happen*/};
}
friend function f_EPTF_ExecCtrl_UIVars_getModeforScenarioGroup(in EPTF_ExecCtrl_ScenarioGroup_ExecMode p_execMode)
return charstring
{
if (p_execMode == MANUAL)
{
return "MANUAL"
}
else if (p_execMode == AUTOMATIC)
{
return "AUTOMATIC"
}
return "UNKNOWN"
}
private function f_EPTF_ExecCtrl_UIVars_guardModeForScenarioGroup(
in integer pl_idx,
in EPTF_IntegerList pl_argList,
in EPTF_Var_DirectContent pl_newContent)
runs on EPTF_ExecCtrl_CT return boolean
{
if (v_ExecCtrl_initialized==false) {
return false; // cleanup is in progress, or not initialized
}
var integer vl_scenarioGroupIdx := pl_argList[0];
var charstring vl_newMode := pl_newContent.charstringVal;
var EPTF_ExecCtrl_ScenarioGroup_ExecMode vl_dummy;
if (
f_EPTF_ExecCtrl_ScenarioGroup_isValidExecMode(vl_newMode, vl_dummy) and
(
f_EPTF_ExecCtrl_getScenarioGroupInstanceGroupPhaseListActualPhaseState(vl_scenarioGroupIdx) == IDLE or
f_EPTF_ExecCtrl_getScenarioGroupInstanceGroupPhaseListActualPhaseState(vl_scenarioGroupIdx) == FINISHED
)
)
{ return true; }
return false;
}
private function f_EPTF_ExecCtrl_UIVars_setModeForScenarioGroup(
in integer pl_idx,
in EPTF_IntegerList pl_argList)
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
if (v_ExecCtrl_initialized==false) {
return; // cleanup is in progress, or not initialized
}
var integer vl_scenarioGroupIdx := pl_argList[0];
var charstring vl_modeName := f_EPTF_Var_getCharstringValue(pl_idx);
var EPTF_ExecCtrl_ScenarioGroup_ExecMode vl_execMode;
if (not f_EPTF_ExecCtrl_ScenarioGroup_isValidExecMode
(
vl_modeName,
vl_execMode
)) {/*cannot happen*/}
else {
f_EPTF_ExecCtrl_setScenarioGroupInstanceExecMode(vl_scenarioGroupIdx,vl_execMode);
};
f_EPTF_ExecCtrl_debug(log2str("Setting mode: " & vl_modeName & " for " & f_EPTF_ExecCtrl_getScenarioGroupInstanceName(vl_scenarioGroupIdx)));
}
private function f_EPTF_ExecCtrl_UIVars_getLEDforPhaseList(in EPTF_ExecCtrl_PhaseList_Instance p_pl)
return EPTF_StatusLED
{
if (p_pl.phases[p_pl.actualPhaseIndex].state == IDLE)
{
return {led_blue, p_pl.phases[p_pl.actualPhaseIndex].name & " - IDLE"}
}
else if (p_pl.phases[p_pl.actualPhaseIndex].state == RUNNING)
{
return {led_green, p_pl.phases[p_pl.actualPhaseIndex].name & " - RUNNING"}
}
else if (p_pl.phases[p_pl.actualPhaseIndex].state == SKIPPING)
{
return {led_black, p_pl.phases[p_pl.actualPhaseIndex].name & " - SKIPPING"}
}
else if (p_pl.phases[p_pl.actualPhaseIndex].state == STOPPING)
{
return {led_red, p_pl.phases[p_pl.actualPhaseIndex].name & " - STOPPING"}
}
else if (p_pl.phases[p_pl.actualPhaseIndex].state == FINISHED)
{
return {led_yellow, p_pl.phases[p_pl.actualPhaseIndex].name & " - FINISHED"}
}
return {led_red, p_pl.phases[p_pl.actualPhaseIndex].name & " - UNKNOWN"}
}
function fcb_EPTF_ExecCtrl_calcGroupStatus(
in integer pl_idx,
in EPTF_IntegerList pl_argList,
in EPTF_IntegerList pl_nonVarArgList,
inout EPTF_Var_DirectContent pl_retVal
) runs on EPTF_ExecCtrl_CT
{
if (v_ExecCtrl_initialized==false) {
return; // cleanup is in progress, or not initialized
}
var integer vl_scenarioGroupIdx := pl_nonVarArgList[0];
pl_retVal :=
{
statusLEDVal :=
f_EPTF_ExecCtrl_UIVars_getLEDforPhaseList(f_EPTF_ExecCtrl_getScenarioGroupInstanceGroupPhaseList(vl_scenarioGroupIdx))
}
}
private function f_EPTF_ExecCtrl_UIVars_startScenarioGroup(
in integer pl_idx,
in EPTF_IntegerList pl_argList)
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
if (v_ExecCtrl_initialized==false) {
return; // cleanup is in progress, or not initialized
}
var integer vl_scenarioGroupIdx := pl_argList[0];
var boolean vl_start := f_EPTF_Var_getBoolValue(pl_idx);
if (not f_EPTF_ExecCtrl_getScenarioGroupInstanceInternalAdjust(vl_scenarioGroupIdx))
{
if (vl_start)
{
f_EPTF_ExecCtrl_debug(log2str("Starting " & f_EPTF_ExecCtrl_getScenarioGroupInstanceName(vl_scenarioGroupIdx)));
f_EPTF_ExecCtrl_ScenarioGroup_start(vl_scenarioGroupIdx);
}
else
{
f_EPTF_ExecCtrl_debug(log2str("Stopping " & f_EPTF_ExecCtrl_getScenarioGroupInstanceName(vl_scenarioGroupIdx)));
f_EPTF_ExecCtrl_ScenarioGroup_stop(vl_scenarioGroupIdx);
}
}
else
{
f_EPTF_ExecCtrl_setScenarioGroupInstanceInternalAdjust(vl_scenarioGroupIdx, false);
}
}
private function f_EPTF_ExecCtrl_UIVars_stopScenarioGroup(
in integer pl_idx,
in EPTF_IntegerList pl_argList,
in EPTF_Var_DirectContent pl_newContent)
runs on EPTF_ExecCtrl_CT return boolean
{
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
if (v_ExecCtrl_initialized==false) {
return false; // cleanup is in progress, or not initialized
}
//var boolean vl_stop := f_EPTF_Var_getBoolValue(pl_idx);
//if (not vl_stop) {
if (pl_newContent.boolVal == false) {
return true;
}
var integer vl_scenarioGroupIdx := pl_argList[0];
f_EPTF_ExecCtrl_stopScenarioGroupOnLGens(vl_scenarioGroupIdx);
// set the GroupStart button to false:
f_EPTF_Var_adjustContent(f_EPTF_ExecCtrl_getScenarioGroupInstanceIsRunningVarIdx(vl_scenarioGroupIdx), {boolVal := false});
return true;
}
private function f_EPTF_ExecCtrl_UIVars_resetScenarioGroup(
in integer pl_idx,
in EPTF_IntegerList pl_argList )
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
var integer vl_scenarioGroupIdx := pl_argList[0];
var boolean vl_start := f_EPTF_Var_getBoolValue(pl_idx);
if (vl_start)
{
f_EPTF_ExecCtrl_debug("Reseting " & f_EPTF_ExecCtrl_getScenarioGroupInstanceName(vl_scenarioGroupIdx));
f_EPTF_ExecCtrl_ScenarioGroup_reset(vl_scenarioGroupIdx);
f_EPTF_ExecCtrl_setScenarioGroupInstanceInternalAdjust(vl_scenarioGroupIdx, true);
f_EPTF_Var_adjustContent(f_EPTF_ExecCtrl_getScenarioGroupInstanceIsRunningVarIdx(vl_scenarioGroupIdx), {boolVal := false});
f_EPTF_Var_adjustContent(pl_idx, {boolVal := false});
}
}
function fcb_EPTF_ExecCtrl_calcScenarioStatus(
in integer pl_idx,
in EPTF_IntegerList pl_argList,
in EPTF_IntegerList pl_nonVarArgList,
inout EPTF_Var_DirectContent pl_retVal
) runs on EPTF_ExecCtrl_CT
{
if (v_ExecCtrl_initialized==false) {
return; // cleanup is in progress, or not initialized
}
var integer vl_scenarioGroupIdx := pl_nonVarArgList[0];
var integer vl_scenarioIdx := pl_nonVarArgList[1];
pl_retVal :=
{
statusLEDVal :=
f_EPTF_ExecCtrl_UIVars_getLEDforPhaseList(f_EPTF_ExecCtrl_getScenarioGroupInstanceScenarioPhaseList(vl_scenarioGroupIdx,vl_scenarioIdx))
}
}
private function f_EPTF_ExecCtrl_UIVars_enablePhaseInScenarioGroup(
in integer pl_idx,
in EPTF_IntegerList pl_argList)
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
if (v_ExecCtrl_initialized==false) {
return; // cleanup is in progress, or not initialized
}
var integer vl_scenarioGroupIdx := pl_argList[0];
var integer vl_scenarioIdx := pl_argList[1];
var integer vl_phaseIdx := pl_argList[2];
var boolean vl_phaseState := f_EPTF_Var_getBoolValue(pl_idx);
f_EPTF_ExecCtrl_setScenarioGroupInstanceScenarioPhaseListPhaseEnabled(vl_scenarioGroupIdx,vl_scenarioIdx,vl_phaseIdx, vl_phaseState);
}
private function f_EPTF_ExecCtrl_appendScenarioGroupTable_vars(in integer p_idx)
runs on EPTF_ExecCtrl_CT
{
var integer vl_idx;
var charstring vl_widgetId;
vl_widgetId := f_EPTF_ExecCtrl_UIVars_getScenarioGroupTableName_FromScenarioGroupDB(p_idx) & ".GroupPhase";
f_EPTF_Var_newCharstring(
"Var." & vl_widgetId,
f_EPTF_ExecCtrl_getScenarioGroupInstanceActualPhaseName(p_idx),
vl_idx);
f_EPTF_Var_addGuardFn(
vl_idx, { refers(f_EPTF_ExecCtrl_UIVars_guardPhaseForScenarioGroup), {p_idx}} );
f_EPTF_Var_addPostProcFn(
vl_idx, { refers(f_EPTF_ExecCtrl_UIVars_setPhaseForScenarioGroup), {p_idx}} );
vl_widgetId := f_EPTF_ExecCtrl_UIVars_getScenarioGroupTableName_FromScenarioGroupDB(p_idx) & ".GroupMode";
f_EPTF_Var_newCharstring(
"Var." & vl_widgetId,
f_EPTF_ExecCtrl_UIVars_getModeforScenarioGroup(f_EPTF_ExecCtrl_getScenarioGroupInstanceExecMode(p_idx)),
vl_idx);
f_EPTF_Var_addGuardFn(
vl_idx, { refers(f_EPTF_ExecCtrl_UIVars_guardModeForScenarioGroup), {p_idx}} );
f_EPTF_Var_addPostProcFn(
vl_idx, { refers(f_EPTF_ExecCtrl_UIVars_setModeForScenarioGroup), {p_idx}} );
vl_widgetId := f_EPTF_ExecCtrl_UIVars_getScenarioGroupTableName_FromScenarioGroupDB(p_idx) & ".GroupStatus";
f_EPTF_Var_newStatusLED(
"Var." & vl_widgetId,
f_EPTF_ExecCtrl_UIVars_getLEDforPhaseList(f_EPTF_ExecCtrl_getScenarioGroupInstanceGroupPhaseList(p_idx)),
vl_idx);
f_EPTF_Var_subscribeLocal(vl_idx,{calcFn := {funcRef:=refers(fcb_EPTF_ExecCtrl_calcGroupStatus), argList:={}, nonVarArgList:={p_idx} } });
// TR HQ88308 - Refresh sampled & sync variables on GUI.
f_EPTF_ExecCtrl_UIVars_storeSampledAtSync_vars(vl_idx);
vl_widgetId := f_EPTF_ExecCtrl_UIVars_getScenarioGroupTableName_FromScenarioGroupDB(p_idx) & ".GroupStart";
f_EPTF_Var_newBool(
"Var." & vl_widgetId,
false,
vl_idx);
f_EPTF_Var_addPostProcFn(
vl_idx, { refers(f_EPTF_ExecCtrl_UIVars_startScenarioGroup), {p_idx}} );
f_EPTF_ExecCtrl_setScenarioGroupInstanceIsRunningVarIdx(p_idx,vl_idx);
vl_widgetId := f_EPTF_ExecCtrl_UIVars_getScenarioGroupTableName_FromScenarioGroupDB(p_idx) & ".TerminateGroup";
f_EPTF_Var_newBool(
"Var." & vl_widgetId,
false,
vl_idx);
f_EPTF_Var_addGuardFn(
vl_idx, { refers(f_EPTF_ExecCtrl_UIVars_stopScenarioGroup), {p_idx}} );
vl_widgetId := f_EPTF_ExecCtrl_UIVars_getScenarioGroupTableName_FromScenarioGroupDB(p_idx) & ".GroupReset";
f_EPTF_Var_newBool(
"Var." & vl_widgetId,
false,
vl_idx);
f_EPTF_Var_addPostProcFn(
vl_idx, { refers(f_EPTF_ExecCtrl_UIVars_resetScenarioGroup), {p_idx}} );
for (var integer j:=0; j<f_EPTF_ExecCtrl_getScenarioGroupInstanceScenarioNum(p_idx); j:=j+1)
{
vl_widgetId := f_EPTF_ExecCtrl_UIVars_getScenarioGroupTableName_FromScenarioGroupDB(p_idx) & "." &
f_EPTF_ExecCtrl_getScenarioGroupInstanceScenarioName(p_idx,j) & ".ScenarioStatus";
f_EPTF_Var_newStatusLED(
"Var." & vl_widgetId,
f_EPTF_ExecCtrl_UIVars_getLEDforPhaseList(f_EPTF_ExecCtrl_getScenarioGroupInstanceScenarioPhaseList(p_idx,j)),
vl_idx);
f_EPTF_Var_subscribeLocal(vl_idx,{calcFn := {funcRef:=refers(fcb_EPTF_ExecCtrl_calcScenarioStatus), argList:={}, nonVarArgList:={p_idx,j} } });
// TR HQ88308 - Refresh sampled & sync variables on GUI.
f_EPTF_ExecCtrl_UIVars_storeSampledAtSync_vars(vl_idx);
for (var integer i:=0; i<f_EPTF_ExecCtrl_getScenarioGroupInstanceGroupPhaseListPhasesNum(p_idx); i:=i+1)
{
vl_widgetId := f_EPTF_ExecCtrl_UIVars_getScenarioGroupTableName_FromScenarioGroupDB(p_idx) & "." &
f_EPTF_ExecCtrl_getScenarioGroupInstanceScenarioName(p_idx,j) & "." &
f_EPTF_ExecCtrl_getScenarioGroupInstanceScenarioPhaseListPhaseName(p_idx,j,i);
f_EPTF_Var_newBool(
"Var." & vl_widgetId,
f_EPTF_ExecCtrl_getScenarioGroupInstanceScenarioPhaseListPhaseEnabled(p_idx,j,i),
vl_idx);
f_EPTF_Var_addPostProcFn(
vl_idx, { refers(f_EPTF_ExecCtrl_UIVars_enablePhaseInScenarioGroup), {p_idx, j, i}} );
}
}
}
private function f_EPTF_ExecCtrl_appendScenarioGroups_vars()
runs on EPTF_ExecCtrl_CT
{
for (var integer i:=0; i<f_EPTF_ExecCtrl_getScenarioGroupInstanceDataNum(); i:=i+1)
{
f_EPTF_ExecCtrl_updateProgressbar(50.0/int2float(f_EPTF_ExecCtrl_getScenarioGroupInstanceDataNum()));
f_EPTF_ExecCtrl_appendScenarioGroupTable_vars(i);
}
}
private function f_EPTF_ExecCtrl_UIVars_createPhaseListsTab_vars() runs on EPTF_ExecCtrl_CT {
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
f_EPTF_ExecCtrl_updateProgressbar(0.0, "Creating Phase Lists variables");
for (var integer i:=0; i<f_EPTF_ExecCtrl_getPhaseListDeclaratorDataNum(); i:=i+1)
{
f_EPTF_ExecCtrl_updateProgressbar(50.0/int2float(f_EPTF_ExecCtrl_getPhaseListDeclaratorDataNum()));
f_EPTF_ExecCtrl_UIVars_appendPhaseListTab_vars(i);
}
f_EPTF_ExecCtrl_appendScenarioGroups_vars();
f_EPTF_ExecCtrl_updateProgressbar(100.0, "Done");
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_UIVars_SubscribeVars2GUI_vars
//
// Purpose:
// Subscribes execution control related variables to GUI
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// Execution control related params and statistics handled here
//
///////////////////////////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_UIVars_SubscribeVars2GUI_vars()
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug(
"### "&%definitionId&"()");
// Subscribe for entity group widgets
// f_EPTF_ExecCtrl_UIVars_WaitingForDynamicGUI(
// c_EPTF_ExecCtrl_EntityGrpTabId);
f_EPTF_ExecCtrl_UIVars_SubscribeVars2EntityGroupsTab_vars();
// Subscribe for resource widgets
// f_EPTF_ExecCtrl_UIVars_WaitingForDynamicGUI(
// c_EPTF_ExecCtrl_ResourceTabId);
f_EPTF_ExecCtrl_UIVars_SubscribeVars2ResourceTab_vars();
// Subscribe for EntityGroupDistribution widgets
// f_EPTF_ExecCtrl_UIVars_WaitingForDynamicGUI(
// c_EPTF_ExecCtrl_GroupDistributionTabId);
f_EPTF_ExecCtrl_UIVars_SubscribeVars2EGrpDistributionTab_vars();
// Subscribe for scenario and traffic case widgets
// f_EPTF_ExecCtrl_UIVars_WaitingForDynamicGUI(
// c_EPTF_ExecCtrl_TrafficTabId_Scenario);
// f_EPTF_ExecCtrl_UIVars_WaitingForDynamicGUI(
// c_EPTF_ExecCtrl_TrafficTabId_TC);
f_EPTF_ExecCtrl_UIVars_SubscribeVars2ScenarioTab_vars();
// Subscribe for Regulated Items case widgets
f_EPTF_ExecCtrl_UIVars_SubscribeVars2RegulatedItemsTab_vars();
f_EPTF_ExecCtrl_UIVars_SubscribeVars2RegulatorsTargetValueTab_vars();
f_EPTF_ExecCtrl_UIVars_createPhaseListsTab_vars();
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_refreshCallBackTargetCPS
//
// Purpose:
// Refresh the Target CPS variables with realtime subscription mode
//
// Parameters: integer variable index
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_refreshCallBackTargetCPS(in EPTF_IntegerList pl_argList) runs on EPTF_ExecCtrl_CT
{
if(f_EPTF_Base_cleanupIsInProgress()==false) {
return;
}
if(lengthof(pl_argList) < 1) {
f_EPTF_ExecCtrl_warning(%definitionId&": The index of the variable is not set");
return;
}
if(lengthof(pl_argList) == 2) {
var integer vl_actidx := pl_argList[0];
var integer vl_previdx := pl_argList[1];
var float vl_actValue := f_EPTF_Var_getFloatValue(vl_actidx);
var float vl_prevValue := f_EPTF_Var_getFloatValue(vl_previdx);
if(vl_actValue != vl_prevValue){
f_EPTF_Var_refreshContent(pl_argList[0]);
f_EPTF_Var_adjustContent(vl_previdx, { floatVal := vl_actValue });
}
}
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_refreshPostProcRegulatorTotalCPS
//
// Purpose:
// Refresh the Target CPS variables with realtime subscription mode
//
// Parameters: integer scenario index
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_refreshPostProcRegulatorTotalCPS(in integer pl_idx, in EPTF_IntegerList pl_argList) runs on EPTF_ExecCtrl_CT
{
if(f_EPTF_Base_cleanupIsInProgress()==false) {
return;
}
if(lengthof(pl_argList) < 1) {
f_EPTF_ExecCtrl_warning(%definitionId&": The index of the scenario is not set");
return;
}
var integer vl_regulatorIdx := -1;
// scenario CPS
if(lengthof(pl_argList) == 1) {
var integer vl_scIdx := pl_argList[0];
var integer vl_numScenarios := f_EPTF_ExecCtrl_numScenarios();
if(0<vl_numScenarios and vl_scIdx<vl_numScenarios) {
var EPTF_ExecCtrl_RegulatedItemName vl_idName := { cps_SC := {
eGrpName := f_EPTF_ExecCtrl_eGrp_name(f_EPTF_ExecCtrl_getScenarioEGroupIdx(vl_scIdx)),
scName := f_EPTF_ExecCtrl_getScenarioName(vl_scIdx)} };
var integer vl_regulatedItemId := f_EPTF_ExecCtrl_Regulator_getRegulatedItemId(vl_idName);
if(vl_regulatedItemId!=-1) {
var charstring vl_regulatorName := f_EPTF_ExecCtrl_Regulator_getRegulatorName(vl_regulatedItemId);
vl_regulatorIdx := f_EPTF_ExecCtrl_Regulator_getRegulatorId(vl_regulatorName);
} else {
var integer vl_scGroupIndex := f_EPTF_ExecCtrl_ScenarioGroup_get_byScIndex(vl_scIdx);
if(vl_scGroupIndex != -1) {
vl_idName := { cps_SCInPhase := {
eGrpName := f_EPTF_ExecCtrl_eGrp_name(f_EPTF_ExecCtrl_getScenarioEGroupIdx(vl_scIdx)),
scName := f_EPTF_ExecCtrl_getScenarioName(vl_scIdx),
phase := f_EPTF_ExecCtrl_getScenarioGroupInstanceActualPhaseName(vl_scGroupIndex)} };
vl_regulatedItemId := f_EPTF_ExecCtrl_Regulator_getRegulatedItemId(vl_idName);
if(vl_regulatedItemId!=-1) {
var charstring vl_regulatorName := f_EPTF_ExecCtrl_Regulator_getRegulatorName(vl_regulatedItemId);
vl_regulatorIdx := f_EPTF_ExecCtrl_Regulator_getRegulatorId(vl_regulatorName);
} else {}
}
}
}
}
if(lengthof(pl_argList) == 2) {
var integer vl_scIdx := pl_argList[0];
var integer vl_tcIdx := pl_argList[1];
var integer vl_numScenarios := f_EPTF_ExecCtrl_numScenarios();
if(0<vl_numScenarios and vl_scIdx<vl_numScenarios) {
var integer vl_numTcOfScenario := f_EPTF_ExecCtrl_numTcOfScenario(vl_scIdx);
if(0<vl_numTcOfScenario and vl_tcIdx<vl_numTcOfScenario) {
var EPTF_ExecCtrl_RegulatedItemName vl_idName := { cps_TC := {
eGrpName := f_EPTF_ExecCtrl_eGrp_name(f_EPTF_ExecCtrl_getScenarioEGroupIdx(vl_scIdx)),
scName := f_EPTF_ExecCtrl_getScenarioName(vl_scIdx),
tcName := f_EPTF_ExecCtrl_tcNameOfTcOfSc(vl_scIdx,vl_tcIdx)
} };
var integer vl_regulatedItemId := f_EPTF_ExecCtrl_Regulator_getRegulatedItemId(vl_idName);
if(vl_regulatedItemId!=-1) {
var charstring vl_regulatorName := f_EPTF_ExecCtrl_Regulator_getRegulatorName(vl_regulatedItemId);
vl_regulatorIdx := f_EPTF_ExecCtrl_Regulator_getRegulatorId(vl_regulatorName);
} else {
var integer vl_scGroupIndex := f_EPTF_ExecCtrl_ScenarioGroup_get_byScIndex(vl_scIdx);
if(vl_scGroupIndex != -1) {
vl_idName := { cps_TCInPhase := {
eGrpName := f_EPTF_ExecCtrl_eGrp_name(f_EPTF_ExecCtrl_getScenarioEGroupIdx(vl_scIdx)),
scName := f_EPTF_ExecCtrl_getScenarioName(vl_scIdx),
tcName := f_EPTF_ExecCtrl_tcNameOfTcOfSc(vl_scIdx,vl_tcIdx),
phase := f_EPTF_ExecCtrl_getScenarioGroupInstanceActualPhaseName(vl_scGroupIndex)} };
vl_regulatedItemId := f_EPTF_ExecCtrl_Regulator_getRegulatedItemId(vl_idName);
if(vl_regulatedItemId!=-1) {
var charstring vl_regulatorName := f_EPTF_ExecCtrl_Regulator_getRegulatorName(vl_regulatedItemId);
vl_regulatorIdx := f_EPTF_ExecCtrl_Regulator_getRegulatorId(vl_regulatorName);
} else {}
}
}
}
}
}
if(vl_regulatorIdx != -1) {
var integer vl_regulatorStatusIdx := f_EPTF_ExecCtrl_Regulator_getRegulatorStatusIdxByRegulatorId(vl_regulatorIdx);
if (vl_regulatorStatusIdx!=-1) {
var EPTF_StatusLED vl_regulatorStatus := f_EPTF_Var_getStatusLEDValue(vl_regulatorStatusIdx);
if (vl_regulatorStatus.text == "Auto-off" or vl_regulatorStatus.text == "Disabled") {
var float vl_newTotalCps := f_EPTF_ExecCtrl_Regulator_getTotalCps(vl_regulatorIdx);
if (f_EPTF_Var_getFloatValue(v_EPTF_ExecCtrl_Regulators[vl_regulatorIdx].totalValueIdx)!=vl_newTotalCps) {
f_EPTF_Var_adjustContent(v_EPTF_ExecCtrl_Regulators[vl_regulatorIdx].totalValueIdx,{floatVal := vl_newTotalCps});
}
}
}
}
}
} // group EPTF_ExecCtrl_UIVars
group EPTF_ExecCtrl_EventStatus {
// creates and initializes the EventStatus variables
private function f_EPTF_ExecCtrl_initEventStatus() runs on EPTF_ExecCtrl_CT {
var charstring vl_currentName;
var integer vl_idx;
// ReadyToRun
vl_currentName := "EPTF_ExecCtrl.EventStatus.ReadyToRun";
f_EPTF_Var_newStatusLED(
vl_currentName,
{led_blue, "ReadyToRun"},
vl_idx
);
f_EPTF_Var_setSubsCanAdjust(vl_idx,false);
f_EPTF_ExecCtrl_debug(log2str("Variable created to set status for ReadyToRun: ",vl_currentName));
// EndOfConfig
vl_currentName := "EPTF_ExecCtrl.EventStatus.EndOfConfig";
f_EPTF_Var_newStatusLED(
vl_currentName,
{led_blue, "EndOfConfig"},
vl_idx
);
f_EPTF_Var_setSubsCanAdjust(vl_idx,false);
f_EPTF_ExecCtrl_debug(log2str("Variable created to set status for EndOfConfig: ",vl_currentName));
// GUIDone
vl_currentName := "EPTF_ExecCtrl.EventStatus.GUIDone";
f_EPTF_Var_newStatusLED(
vl_currentName,
{led_blue, "GUIDone"},
vl_idx
);
f_EPTF_Var_setSubsCanAdjust(vl_idx,false);
f_EPTF_ExecCtrl_debug(log2str("Variable created to set status for GUIDone: ",vl_currentName));
// EndOfTest
vl_currentName := "EPTF_ExecCtrl.EventStatus.EndOfTest";
f_EPTF_Var_newStatusLED(
vl_currentName,
{led_blue, "EndOfTest"},
vl_idx
);
f_EPTF_Var_setSubsCanAdjust(vl_idx,false);
f_EPTF_ExecCtrl_debug(log2str("Variable created to set status for EndOfTest: ",vl_currentName));
}
private function f_EPTF_ExecCtrl_setStatusReadyToRun() runs on EPTF_ExecCtrl_CT {
f_EPTF_ExecCtrl_debug("ReadyToTun");
var charstring vl_currentName := "EPTF_ExecCtrl.EventStatus.ReadyToRun";
f_EPTF_Var_adjustContent(
f_EPTF_Var_getId(vl_currentName),
{statusLEDVal := {led_green, "ReadyToRun"}}
);
}
private function f_EPTF_ExecCtrl_setStatusEndOfConfig() runs on EPTF_ExecCtrl_CT {
f_EPTF_ExecCtrl_debug("EndOfConfig");
var charstring vl_currentName := "EPTF_ExecCtrl.EventStatus.EndOfConfig";
f_EPTF_Var_adjustContent(
f_EPTF_Var_getId(vl_currentName),
{statusLEDVal := {led_green, "EndOfConfig"}}
);
}
friend function f_EPTF_ExecCtrl_setStatusGUIDone() runs on EPTF_ExecCtrl_CT {
f_EPTF_ExecCtrl_debug("GUIDone");
var charstring vl_currentName := "EPTF_ExecCtrl.EventStatus.GUIDone";
f_EPTF_Var_adjustContent(
f_EPTF_Var_getId(vl_currentName),
{statusLEDVal := {led_green, "GUIDone"}}
);
if (v_ExecCtrl_progressEnabled and v_ExecCtrl_progressBarUIHandler_Idx!=-1) {
f_EPTF_Var_adjustContent(v_ExecCtrl_progressBarUIHandler_Idx,{charstringVal := "ExecCtrl: GUI Done."});
}
}
private function f_EPTF_ExecCtrl_setStatusEndOfTest() runs on EPTF_ExecCtrl_CT {
f_EPTF_ExecCtrl_debug("EndOfTest");
var charstring vl_currentName := "EPTF_ExecCtrl.EventStatus.EndOfTest";
f_EPTF_Var_adjustContent(
f_EPTF_Var_getId(vl_currentName),
{statusLEDVal := {led_green, "EndOfTest"}}
);
}
} //group EPTF_ExecCtrl_EventStatus
// R3 LGenPools DB
group EPTF_ExecCtrl_LGenPools
{
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_LGenPool_initInstanceDB
//
// Purpose:
// Initializes the LGenPool instance DB
//
// Parameters:
//
// Return Value:
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_LGenPool_initInstanceDB()
runs on EPTF_ExecCtrl_CT
{
v_EPTF_ExecCtrl_lgenPools := {};
v_EPTF_ExecCtrl_lgenPoolsHash := f_EPTF_str2int_HashMap_New(c_ExecCtrl_lgenPoolsHashMapName);
v_EPTF_ExecCtrl_lgenPoolCompRefHash := f_EPTF_int2int_HashMap_New(c_ExecCtrl_lgenPoolCompRefHashMapName);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_LGenPool_cleanupInstanceDB
//
// Purpose:
// Cleans up the LGenPool instance DB
//
// Parameters:
//
// Return Value:
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_LGenPool_cleanupInstanceDB()
runs on EPTF_ExecCtrl_CT
{
if (v_EPTF_ExecCtrl_lgenPoolsHash != c_ExecCtrl_invalidIdx) {
f_EPTF_str2int_HashMap_Delete(c_ExecCtrl_lgenPoolsHashMapName);
v_EPTF_ExecCtrl_lgenPoolsHash := c_ExecCtrl_invalidIdx;
}
v_EPTF_ExecCtrl_lgenPools := {};
if (v_EPTF_ExecCtrl_lgenPoolCompRefHash != c_ExecCtrl_invalidIdx) {
f_EPTF_int2int_HashMap_Delete(c_ExecCtrl_lgenPoolCompRefHashMapName);
v_EPTF_ExecCtrl_lgenPoolCompRefHash := c_ExecCtrl_invalidIdx;
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_LGenPool_loadInstanceDB
//
// Purpose:
// Loads the LGen Pool instance DB from declarators
//
// Parameters:
// pl_lgenPoolDeclarators - *in* <EPTF_ExecCtrl_LGenPool_Declarators> - LGen Pool declarators
// pl_entityGroups2LGenPools - *in* <EPTF_ExecCtrl_EntityGroup2LGenPool_List> - Entity group to LGen Pool declarators
//
// Return Value:
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_LGenPool_loadInstanceDB(
in EPTF_ExecCtrl_LGenPool_Declarators pl_lgenPoolDeclarators := {},
in EPTF_ExecCtrl_EntityGroup2LGenPool_List pl_entityGroups2LGenPools := {}
)
runs on EPTF_ExecCtrl_CT {
f_EPTF_ExecCtrl_addLGenPoolsFromDeclarators(
pl_lgenPoolDeclarators);
f_EPTF_ExecCtrl_addEntityGroups2LGenPoolsFromDeclarators(
pl_entityGroups2LGenPools);
// LGenPools are loaded when they log in and when the eGroups are distributed on them
f_EPTF_ExecCtrl_LGenPool_dumpInstanceDB();
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_addLGenPoolsFromDeclarators
//
// Purpose:
// Add LGen Pool declarators to the instance DB
//
// Parameters:
// pl_lgenPoolDecl - *in* <EPTF_ExecCtrl_LGenPool_Declarators> - LGen pool declarators to add
//
// Return Value:
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_addLGenPoolsFromDeclarators(
in EPTF_ExecCtrl_LGenPool_Declarators pl_lgenPoolDecl
)
runs on EPTF_ExecCtrl_CT
{
for(var integer i := 0, size := sizeof(pl_lgenPoolDecl); i < size; i := i + 1) {
f_EPTF_ExecCtrl_addLGenPoolInstance(pl_lgenPoolDecl[i]);
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_addLGenPoolInstance
//
// Purpose:
// Adds an LGenPool to the instance DB
//
// Parameters:
// pl_lgenPool - *in* <EPTF_ExecCtrl_LGenPool_Declarator> - LGen pool to add
//
// Return Value:
// integer - idx of the LGenPool
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_addLGenPoolInstance(in EPTF_ExecCtrl_LGenPool_Declarator pl_lgenPool)
runs on EPTF_ExecCtrl_CT
//return integer
{
var integer vl_idx := sizeof(v_EPTF_ExecCtrl_lgenPools);
f_EPTF_str2int_HashMap_Insert(v_EPTF_ExecCtrl_lgenPoolsHash, pl_lgenPool.name, vl_idx);
v_EPTF_ExecCtrl_lgenPools[vl_idx].name := pl_lgenPool.name;
v_EPTF_ExecCtrl_lgenPools[vl_idx].lgens := {};
v_EPTF_ExecCtrl_lgenPools[vl_idx].lgenPoolItems := pl_lgenPool.lgenPoolItems;
//return vl_idx;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_getLGenPoolIdx
//
// Purpose:
// Returns the id of an entity group in the instance DB
//
// Parameters:
//
// Return Value:
// integer - id of the entity group
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_getLGenPoolIdx(in charstring pl_lgenPoolName)
runs on EPTF_ExecCtrl_CT
return integer
{
var integer vl_idx := -1;
var boolean vl_found := f_EPTF_str2int_HashMap_Find(
v_EPTF_ExecCtrl_lgenPoolsHash,
pl_lgenPoolName,
vl_idx);
f_EPTF_Base_assert(%definitionId&": Cannot find LGenPool "&pl_lgenPoolName&" in database.", vl_found);
return vl_idx;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_LGenPool_createLGens
//
// Purpose:
// Creates the LGens of all LGenPools
//
// Parameters:
//
// Return Value:
//
// Errors:
//
// Detailed Comments:
// This function has to be called after <f_EPTF_ExecCtrl_init_CT> has been called
// if it's call was disabled in <f_EPTF_ExecCtrl_init_CT>.
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_LGenPool_createLGens()
runs on EPTF_ExecCtrl_CT
{
if (v_ExecCtrl_allLGensCreated) {
return;
}
var EPTF_ExecCtrl_CreateLGen_FT vl_createFunc;
var integer vl_lgenCounter := 0;
for(var integer pl_lgenPoolIdx:=0, size := sizeof(v_EPTF_ExecCtrl_lgenPools); pl_lgenPoolIdx<size;pl_lgenPoolIdx:=pl_lgenPoolIdx+1) {
for (var integer i:=0, isize := sizeof(v_EPTF_ExecCtrl_lgenPools[pl_lgenPoolIdx].lgenPoolItems); i<isize; i:=i+1)
{
if (f_EPTF_ExecCtrl_getLGenFunctionByName(v_EPTF_ExecCtrl_lgenPools[pl_lgenPoolIdx].lgenPoolItems[i].createFunctionName, vl_createFunc))
{
for (var integer j:=0; j<v_EPTF_ExecCtrl_lgenPools[pl_lgenPoolIdx].lgenPoolItems[i].num; j:=j+1)
{
if (vl_createFunc==null) {
// this is not possible, null functionRefs are not added to database
continue;
}
var EPTF_ExecCtrlClient_CT vl_client := vl_createFunc.apply(v_EPTF_ExecCtrl_lgenPools[pl_lgenPoolIdx].lgenPoolItems[i].hostname,
"LGen"&int2str(vl_lgenCounter)&"."&v_EPTF_ExecCtrl_lgenPools[pl_lgenPoolIdx].name
&"."&v_EPTF_ExecCtrl_lgenPools[pl_lgenPoolIdx].lgenPoolItems[i].hostname
);
if (vl_client==null) {
f_EPTF_ExecCtrl_warning(log2str(%definitionId&
" Couldn't create LGen with function ", v_EPTF_ExecCtrl_lgenPools[pl_lgenPoolIdx].lgenPoolItems[i].createFunctionName,
" on host ", v_EPTF_ExecCtrl_lgenPools[pl_lgenPoolIdx].lgenPoolItems[i].hostname,
": Function returned null!"
));
continue; // LGen Creation failed
}
vl_lgenCounter := vl_lgenCounter + 1;
// store poolIdx of the lgen into the shadow hashmap:
var integer vl_lgenCompRef := f_EPTF_Base_upcast(vl_client);
f_EPTF_int2int_HashMap_Insert(v_EPTF_ExecCtrl_lgenPoolCompRefHash, vl_lgenCompRef, pl_lgenPoolIdx);
v_ExecCtrl_nrOfClients := v_ExecCtrl_nrOfClients + 1;
}
}
else
{
f_EPTF_ExecCtrl_warning(log2str(
%definitionId&": Couldn't find create function: ", v_EPTF_ExecCtrl_lgenPools[pl_lgenPoolIdx].lgenPoolItems[i].createFunctionName,
" Available create functions: ", v_EPTF_ExecCtrl_lgenFunctions
));
}
}
}
v_ExecCtrl_allLGensCreated:=true;
t_ExecCtrl_allLGensCreated.start;
// load buffered EntityResourceInfo messages
f_EPTF_ExecCtrl_loadBuffered_EntityResourceInfo();
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_nrOfClients
//
// Purpose:
// Returns the number of ExecCtrlClient components
//
// Parameters:
//
// Return Value:
// integer - number of ExecCtrlClients
//
// Errors:
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_nrOfClients() runs on EPTF_ExecCtrl_CT return integer {
return v_ExecCtrl_nrOfClients;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_LGenPool_dumpInstanceDB
//
// Purpose:
// Writes the LGenPool intance DB into the log file for debug purposes
//
// Parameters:
//
// Return Value:
//
// Errors:
//
// Detailed Comments:
// It dumps the entity group, scenario, traffic case and the LGen instance DB
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_LGenPool_dumpInstanceDB()
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug("---------------------------"&%definitionId&"---------------------------");
f_EPTF_ExecCtrl_debug("LGenPools:");
f_EPTF_ExecCtrl_debug(log2str(v_EPTF_ExecCtrl_lgenPools));
f_EPTF_ExecCtrl_debug("LGenFunctions:");
f_EPTF_ExecCtrl_debug(log2str(v_EPTF_ExecCtrl_lgenFunctions));
f_EPTF_ExecCtrl_debug("---------------------------"&%definitionId&"---------------------------");
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_addEntityGroups2LGenPoolsFromDeclarators
//
// Purpose:
// Add Entity group to LGen Pool declarators to the instance DB
//
// Parameters:
// pl_entityGroups2LGenPools - *in* <EPTF_ExecCtrl_EntityGroup2LGenPool_List> - entity group to Lgen pool declarators to add
//
// Return Value:
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_addEntityGroups2LGenPoolsFromDeclarators(
in EPTF_ExecCtrl_EntityGroup2LGenPool_List pl_entityGroup2LGenPool_List
)
runs on EPTF_ExecCtrl_CT
{
for(var integer i := 0, size := sizeof(pl_entityGroup2LGenPool_List); i < size; i := i + 1) {
f_EPTF_ExecCtrl_addEntityGroup2LGenPool(pl_entityGroup2LGenPool_List[i].eGrpName,pl_entityGroup2LGenPool_List[i].lgenPoolName);
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_addEntityGroup2LGenPool
//
// Purpose:
// Adds an entity group to an LGenPool
//
// Parameters:
// pl_entityGroupName - *in* *charstring* - entity group to add
// pl_lgenPoolName - *in* *charstring* - LGen pool to add to
//
// Return Value:
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_addEntityGroup2LGenPool(in charstring pl_entityGroupName, in charstring pl_lgenPoolName)
runs on EPTF_ExecCtrl_CT
{
var integer vl_eGrpIdx := f_EPTF_ExecCtrl_getEntityGroupIdx(pl_entityGroupName);
var integer vl_lgenPoolIdx := f_EPTF_ExecCtrl_getLGenPoolIdx(pl_lgenPoolName);
if (vl_eGrpIdx !=-1) {
// check if the entity group is already in pool
if (v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenPoolIdx!=-1) {
f_EPTF_ExecCtrl_error(%definitionId&": Cannot add Entity Group "&pl_entityGroupName&
" to the LGenPool: "&pl_lgenPoolName&": already in pool: "&
v_EPTF_ExecCtrl_lgenPools[v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenPoolIdx].name);
f_EPTF_Base_stopAll();
}
} else {
f_EPTF_ExecCtrl_error(%definitionId&": Cannot add Entity Group "&pl_entityGroupName&
" to the LGenPool: "&pl_lgenPoolName&": EntityGroup does not exists! ");
f_EPTF_Base_stopAll();
}
v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenPoolIdx := vl_lgenPoolIdx;
}
// R3 LGenFunctions DB
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_LGenFunctions_initInstanceDB
//
// Purpose:
// Initializes the LGen creator functions instance DB of the LGPools
//
// Parameters:
//
// Return Value:
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_LGenFunctions_initInstanceDB()
runs on EPTF_ExecCtrl_CT
{
v_EPTF_ExecCtrl_lgenFunctions :={}
v_EPTF_ExecCtrl_lgenFunctionsHash := f_EPTF_str2int_HashMap_New(c_EPTF_ExecCtrl_LGenFunctionsDB_HashName);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_LGenFunctions_cleanupInstanceDB
//
// Purpose:
// Cleans up the LGen creator functions instance DB of the LGPools
//
// Parameters:
//
// Return Value:
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_LGenFunctions_cleanupInstanceDB()
runs on EPTF_ExecCtrl_CT
{
v_EPTF_ExecCtrl_lgenFunctions :={}
if (v_EPTF_ExecCtrl_lgenFunctionsHash!=c_ExecCtrl_invalidIdx) {
v_EPTF_ExecCtrl_lgenFunctionsHash := c_ExecCtrl_invalidIdx;
f_EPTF_str2int_HashMap_Delete(c_EPTF_ExecCtrl_LGenFunctionsDB_HashName);
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_addLGenFunctionsFromDeclarators
//
// Purpose:
// Adds the LGen creator functions to the instance DB from declarators
//
// Parameters:
// pl_lgenFunctionsDecl - *in* <EPTF_ExecCtrl_LGenFunction_Entry_List> - the lgen creator functions
//
// Return Value:
//
// Errors:
//
// Detailed Comments:
// Note, that in the declarator, the name is optional. If the
// name is not specified, the function is registered with the
// auto-generated name only. The automatic name is generated in the format:
// ModuleName.FunctionName, where ModuleName is the TTCN3 module that
// contains the function, and FunctionName is the name of the
// registered function. This autogenerated name can always be used
// to find the function, but if the name is specified,
// the function can be found by using the specified name too.
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_addLGenFunctionsFromDeclarators(
in EPTF_ExecCtrl_LGenFunction_Entry_List pl_lgenFunctionsDecl
)
runs on EPTF_ExecCtrl_CT
{
for(var integer i := 0, size := sizeof(pl_lgenFunctionsDecl); i < size; i := i + 1) {
if(-1==f_EPTF_ExecCtrl_addLGenFunctionInstance(pl_lgenFunctionsDecl[i])) {/*ignore null functions*/};
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_addLGenFunctionInstance
//
// Purpose:
// Adds an LGen creator function to the instance DB
//
// Parameters:
// p_declarator - *in* <EPTF_ExecCtrl_LGenFunction_Entry> - the lgen creator function
//
// Return Value:
// integer - the id of the registered function, -1 if unsuccessful
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_addLGenFunctionInstance(
in EPTF_ExecCtrl_LGenFunction_Entry p_declarator
) runs on EPTF_ExecCtrl_CT
return integer
{
if (p_declarator.fn==null) {
f_EPTF_ExecCtrl_warning(log2str(
"LGen Creator function ignored, because it is null in declarator: ",p_declarator));
return -1;
}
var integer vl_plIdx := -1;
var charstring vl_fnName := log2str(p_declarator.fn);
var integer vl_strLen := lengthof(vl_fnName);
vl_fnName := substr(log2str(p_declarator.fn),7,vl_strLen-8); // cut the refers() out;
// registering automatic (ModuleName.FunctionName) name:
f_EPTF_ExecCtrl_debug(log2str("Registering automatic function name for function ",p_declarator.fn,": ", vl_fnName));
if (not f_EPTF_str2int_HashMap_Find(v_EPTF_ExecCtrl_lgenFunctionsHash, vl_fnName, vl_plIdx))
{
vl_plIdx := sizeof(v_EPTF_ExecCtrl_lgenFunctions);
v_EPTF_ExecCtrl_lgenFunctions[vl_plIdx] := p_declarator.fn;
f_EPTF_str2int_HashMap_Insert(v_EPTF_ExecCtrl_lgenFunctionsHash, vl_fnName, vl_plIdx);
} else {
f_EPTF_ExecCtrl_warning(log2str(
"LGen Creator function ",p_declarator," ignored, because another function is already added with name: ",vl_fnName));
vl_plIdx := -1;
}
// registering user defined name also
if (not ispresent(p_declarator.name)) {
return vl_plIdx;
}
vl_fnName := p_declarator.name
f_EPTF_ExecCtrl_debug(log2str("Registering user defined function name for function ",p_declarator.fn,": ", vl_fnName));
if (not f_EPTF_str2int_HashMap_Find(v_EPTF_ExecCtrl_lgenFunctionsHash, vl_fnName, vl_plIdx))
{
// do not store it into the database if it was already stored
if (vl_plIdx==-1) {
vl_plIdx := sizeof(v_EPTF_ExecCtrl_lgenFunctions);
v_EPTF_ExecCtrl_lgenFunctions[vl_plIdx] := p_declarator.fn;
}
f_EPTF_str2int_HashMap_Insert(v_EPTF_ExecCtrl_lgenFunctionsHash, vl_fnName, vl_plIdx);
} else {
f_EPTF_ExecCtrl_warning(log2str(
"LGen Creator function ",p_declarator," ignored, because another function is already added with name: ",vl_fnName));
vl_plIdx := -1;
}
return vl_plIdx;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_getLGenFunction
//
// Purpose:
// Returns the LGen creator function reference
//
// Parameters:
// p_idx - *in integer* - the idx of lgen creator function
// p_creatorFunction - *in* <EPTF_ExecCtrl_CreateLGen_FT> - the reference to the lgen creator function
//
// Return Value:
// boolean - true on success, false otherwise (e.g.: invalid idx)
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_getLGenFunction(
in integer p_idx,
out EPTF_ExecCtrl_CreateLGen_FT p_creatorFunction
) runs on EPTF_ExecCtrl_CT
return boolean
{
if (p_idx < 0 or p_idx >= sizeof(v_EPTF_ExecCtrl_lgenFunctions)) {
return false; // invalid idx
}
p_creatorFunction := v_EPTF_ExecCtrl_lgenFunctions[p_idx];
return true;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_getLGenFunctionByName
//
// Purpose:
// Returns the LGen creator function reference
//
// Parameters:
// p_functionName - *in charstring* - the name of lgen creator function
// p_creatorFunction - *in* <EPTF_ExecCtrl_CreateLGen_FT> - the reference to the lgen creator function
//
// Return Value:
// boolean - true on success, false otherwise (e.g.: invalid idx)
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_getLGenFunctionByName(
in charstring p_functionName,
out EPTF_ExecCtrl_CreateLGen_FT p_creatorFunction
) runs on EPTF_ExecCtrl_CT
return boolean
{
var integer vl_key := -1;
if (f_EPTF_str2int_HashMap_Find(v_EPTF_ExecCtrl_lgenFunctionsHash, p_functionName, vl_key))
{
if (f_EPTF_ExecCtrl_getLGenFunction(vl_key, p_creatorFunction))
{
return true;
}
}
return false;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_getLGenCompRefsOfPool
//
// Purpose:
// Returns the LGen component indexes for a given LGen pool
//
// Parameters:
// pl_poolName - *in charstring* - the name of lgen creator function
// pl_lgenIdxList - *out* <EPTF_IntegerList> - the list of LGen component indexes
//
// Return Value:
// -
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_getLGenCompRefsOfPool(in charstring pl_poolName, out EPTF_IntegerList pl_lgenIdxList) runs on EPTF_ExecCtrl_CT {
var integer vl_lgenPoolIdxOfLGen := -1;
pl_lgenIdxList:={};
for(var integer i := 0, size := sizeof(v_ExecCtrl_lgens); i < size; i := i + 1) {
f_EPTF_int2int_HashMap_Find(v_EPTF_ExecCtrl_lgenPoolCompRefHash, v_ExecCtrl_lgens[i].lgenCompRef , vl_lgenPoolIdxOfLGen)
if(pl_poolName == v_EPTF_ExecCtrl_lgenPools[vl_lgenPoolIdxOfLGen].name) {
pl_lgenIdxList[sizeof(pl_lgenIdxList)] := v_ExecCtrl_lgens[i].lgenCompRef;
}
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_checkCreatorFnNameOfPool
//
// Purpose:
// It checks whether an LGen creator function was used to create LGens in a specific pool.
//
// Parameters:
// pl_poolName - *in charstring* - the name of lgen creator function
// pl_creatorFunctionName - *in charstring* - the name of LGen creator function
// pl_poolIdx - *out* *integer* - the index of the LGen pool (-1 if pool is not found)
//
// Return Value:
// *boolean* - true if the behavior function was used to create LGens in the pool,
// false if not, or the pool is not found
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_checkCreatorFnNameOfPool(
in charstring pl_poolName,
in charstring pl_creatorFunctionName,
out integer pl_poolIdx) runs on EPTF_ExecCtrl_CT
return boolean {
pl_poolIdx := -1;
for(var integer i := 0, size := sizeof(v_EPTF_ExecCtrl_lgenPools); i < size; i := i + 1) {
if (v_EPTF_ExecCtrl_lgenPools[i].name == pl_poolName) {
pl_poolIdx := i;
for(var integer j := 0, isize := sizeof(v_EPTF_ExecCtrl_lgenPools[i].lgenPoolItems); j < isize; j := j + 1) {
if (v_EPTF_ExecCtrl_lgenPools[i].lgenPoolItems[j].createFunctionName == pl_creatorFunctionName) {
return true;
}
}
return false; // pool found, but given behavior fn is not present
}
}
return false; // pool not found
}
} // group EPTF_ExecCtrl_LGenPools
group ByeBye {
// handles Bye and ByeAck messages
private altstep as_EPTF_ExecCtrl_MgmtIf_handleByeMsgs() runs on EPTF_ExecCtrl_CT {
var EPTF_ExecCtrlClient_CT vl_client;
[] ExecCtrl_MgmtIf_CP.receive(EPTF_ExecCtrl_Bye:?) -> sender vl_client {
f_EPTF_ExecCtrl_debug("EPTF_ExecCtrl_Bye received from "&log2str(vl_client));
// remove client from database:
var integer vl_lgenCompRef := f_EPTF_Base_upcast(vl_client);
var integer vl_lgenIdx := f_EPTF_ExecCtrl_getLGenIdx(int2str(vl_lgenCompRef));
if (vl_lgenIdx!=-1) {
f_EPTF_ExecCtrl_deleteLGenInstance(vl_lgenIdx);
} else {
f_EPTF_ExecCtrl_warning(%definitionId&": Some problem might have occured with the ExecCtrl client "&log2str(vl_client)
&": It exited before ExecCtrl startup.");
}
ExecCtrl_MgmtIf_CP.send(EPTF_ExecCtrl_ByeAck:{}) to vl_client;
repeat;
}
[] ExecCtrl_MgmtIf_CP.receive(EPTF_ExecCtrl_ByeAck:?) -> sender vl_client {
f_EPTF_ExecCtrl_debug("EPTF_ExecCtrl_ByeAck received from "&log2str(vl_client));
v_ExecCtrl_pendingByeCounter := v_ExecCtrl_pendingByeCounter - 1;
repeat;
}
}
// sends bye to all clients and waits for responses
friend function f_EPTF_ExecCtrl_sendByeToAllClients() runs on EPTF_ExecCtrl_CT {
//Remove variable refresh for EGrps //HP34819
for(var integer eg:=0; eg<f_EPTF_ExecCtrl_numEntityGroups(); eg:=eg+1) {
var charstring vl_eGrpName := f_EPTF_ExecCtrl_eGrp_name(eg);
var charstring vl_varName := c_EPTF_ExecCtrl_statisticsRoot&".EG."&vl_eGrpName&".nofActiveEntities";
var integer vl_varIdx := f_EPTF_Var_getId(vl_varName);
if (-1 < vl_varIdx){
f_EPTF_Var_removePostProcFn(vl_varIdx,{refers(f_EPTF_ExecCtrl_eGrp_activeEntities_PostProcFn),{eg}})
}
}
v_ExecCtrl_pendingByeCounter := 0;
for (var integer lgenidx:=0, size := sizeof(v_ExecCtrl_lgens);lgenidx<size;lgenidx:=lgenidx+1) {
if (v_ExecCtrl_lgens[lgenidx].lgenCompRef == -1) {
continue; // do not send packet to LGen if it already disconnected
}
ExecCtrl_MgmtIf_CP.send(EPTF_ExecCtrl_Bye:{})
to f_EPTF_Base_downcast(v_ExecCtrl_lgens[lgenidx].lgenCompRef);
v_ExecCtrl_pendingByeCounter := v_ExecCtrl_pendingByeCounter + 1;
// remove client from database:
f_EPTF_ExecCtrl_deleteLGenInstance(lgenidx);
}
timer t_wait := 0.0;
t_wait.start;
timer t_maxWait := tsp_EPTF_ExecCtrl_maxKillTime;
t_maxWait.start;
f_EPTF_ExecCtrl_debug(log2str(%definitionId&": Waiting for all LGens to stop..."));
alt {
[v_ExecCtrl_pendingByeCounter==0] t_wait.timeout;
[] t_maxWait.timeout {
f_EPTF_ExecCtrl_warning(log2str(%definitionId&
": MaxWaitTime expired. Not all the LGens stopped. Exiting anyway..."));
}
}
}
} // group ByeBye
} // group R3
} // module