blob: c17cf8aa84d1bb276e274827660ea61a73be7334 [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_ScenarioFunctions
//
// Purpose:
// This module contains the implementation of EPTF_CLL_ExecCtrl database functions.
//
// Module depends on:
// <EPTF_CLL_Base_Functions>
// <EPTF_CLL_Variable_Functions>
// <EPTF_CLL_ExecCtrl_Definitions>
// <EPTF_CLL_ExecCtrl_ScenarioDefinitions>
// <EPTF_CLL_ExecCtrl_LoggingFunctions>
// <EPTF_CLL_LGenBase_ConfigDefinitions>
// <EPTF_CLL_LGenBase_Definitions>
// <EPTF_CLL_LGenBaseStats_Functions>
// <EPTF_CLL_HashMapStr2Int_Functions>
// <EPTF_CLL_HashMapInt2Int_Functions>
// <EPTF_CLL_Common_Definitions>
// <EPTF_CLL_StatMeasure_Functions>
//
// Module Parameters:
//
// Current Owner:
// Jozsef Gyurusi (ethjgi)
//
// Last Review Date:
// 2009-02-03
//
// Detailed Comments:
// This module contains the entity group, scenario, traffic case type and
// instance database functions for the EPTF_CLL_ExecCtrl.
//
// Public functions:
// <f_EPTF_ExecCtrl_dumpTypeDB>
// <f_EPTF_ExecCtrl_eGrp_name>
// <f_EPTF_ExecCtrl_eGrp_lgenList>
// <f_EPTF_ExecCtrl_eGrp_scenarios>
// <f_EPTF_ExecCtrl_numEntities>
// <f_EPTF_ExecCtrl_getEntityGroupIdx>
// <f_EPTF_ExecCtrl_getActiveEntities>
// <f_EPTF_ExecCtrl_setActiveEntities>
// <f_EPTF_ExecCtrl_getAllocatedEntities>
// <f_EPTF_ExecCtrl_getTrafficCaseIdx>
// <f_EPTF_ExecCtrl_getTcOfScenarioIdx>
// <f_EPTF_ExecCtrl_getScenarioIdxForTc>
// <f_EPTF_ExecCtrl_registerOnGroupFinishCallbackFn>
// <f_EPTF_ExecCtrl_deregisterOnGroupFinishCallbackFn>
// <f_EPTF_ExecCtrl_checkOnGroupFinished>
// <f_EPTF_ExecCtrl_registerCPSChangedCallback_TC>
// <f_EPTF_ExecCtrl_deregisterCPSChangedCallback_TC>
// <f_EPTF_ExecCtrl_registerCPSChangedCallback_SC>
// <f_EPTF_ExecCtrl_deregisterCPSChangedCallback_SC>
// <f_EPTF_ExecCtrl_getScenarioName>
// <f_EPTF_ExecCtrl_getScenarioIdx>
// <f_EPTF_ExecCtrl_getScenarioIdxByInstanceName>
// <f_EPTF_ExecCtrl_isWeightedScenario>
// <f_EPTF_ExecCtrl_numTcOfScenario>
// <f_EPTF_ExecCtrl_getAvailableEntitiesOnLGenForEGrp>
// <f_EPTF_ExecCtrl_dumpInstanceDB>
// <f_EPTF_ExecCtrl_getLgenIdxInEGrpForLGenAndEgrp>
// <f_EPTF_ExecCtrl_getLGenNumForTc>
// <f_EPTF_ExecCtrl_getLGenIdx>
// <f_EPTF_ExecCtrl_getLGenName>
// <f_EPTF_ExecCtrl_numLGens>
// <f_EPTF_ExecCtrl_getLGenNumEGroups>
// <f_EPTF_ExecCtrl_getLGenEGrpIdx>
// <f_EPTF_ExecCtrl_getTrafficCaseName>
// <f_EPTF_ExecCtrl_getScenarioInstanceName>
//
// All other functions in this module are private!
//
///////////////////////////////////////////////////////////////
module EPTF_CLL_ExecCtrl_ScenarioFunctions {
import from EPTF_CLL_Base_Functions all;
import from EPTF_CLL_Variable_Functions all;
import from EPTF_CLL_ExecCtrl_Definitions all;
import from EPTF_CLL_ExecCtrl_ScenarioDefinitions all;
import from EPTF_CLL_ExecCtrl_LoggingFunctions all;
import from EPTF_CLL_LGenBase_ConfigDefinitions all;
import from EPTF_CLL_LGenBase_ConfigFunctions all;
import from EPTF_CLL_LGenBase_Definitions all;
import from EPTF_CLL_LGenBaseStats_Functions all;
//import from EPTF_CLL_LGenBase_Definitions all; // c_EPTF_LGenBase_emptyTcOfScenarioInternal
import from EPTF_CLL_HashMapStr2Int_Functions all;
import from EPTF_CLL_HashMapInt2Int_Functions all;
import from EPTF_CLL_Common_Definitions all;
import from EPTF_CLL_StatMeasure_Functions all;
friend module EPTF_CLL_ExecCtrl_PhaseFunctions, EPTF_CLL_ExecCtrl_Functions, EPTF_CLL_ExecCtrl_DSFunctions;
friend module EPTF_CLL_ExecCtrlClient_Functions;
friend module EPTF_CLL_ExecCtrlUIHandler_Functions;
///////////////////////////////////////////////////////////
// Group: EPTF_ExecCtrl_TypeDB
//
// Purpose:
// Contains items corresponding to the type (declarator) database
//
// Elements:
///////////////////////////////////////////////////////////
group EPTF_ExecCtrl_TypeDB {
/* functions:
f_EPTF_ExecCtrl_initTypeDB()
f_EPTF_ExecCtrl_cleanupTypeDB()
f_EPTF_ExecCtrl_loadTypeDB(
in EPTF_LGenBase_ScenarioDeclaratorList pl_scDecl := {},
in EPTF_LGenBase_tcTypeDeclaratorList pl_tcDecl := {},
in EPTF_LGenBase_TcMgmt_ScenarioDeclaratorList pl_sc2Decl := {},
in EPTF_LGenBase_TcMgmt_tcTypeDeclaratorList pl_tc2Decl := {},
in EPTF_LGenBase_TcMgmt_WeightedScenarioDeclaratorList pl_weightedScDecl := {}
)
f_EPTF_ExecCtrl_addTcType(in EPTF_ExecCtrl_TcType pl_tcType)return integer
f_EPTF_ExecCtrl_numTcTypes()return integer
f_EPTF_ExecCtrl_getTcTypeIdx(in charstring pl_tcName)return integer
f_EPTF_ExecCtrl_addScenarioType(in EPTF_ExecCtrl_ScenarioType pl_scType)return integer
f_EPTF_ExecCtrl_numScenarioTypes()return integer
f_EPTF_ExecCtrl_getScenarioTypeIdx(in charstring pl_scName)return integer
f_EPTF_ExecCtrl_getScenarioTypeName(in integer pl_scTypeIdx)return charstring
f_EPTF_ExecCtrl_isWeightedScType(in integer pl_scTypeIdx)return boolean
f_EPTF_ExecCtrl_getWeightedScTypeData(in integer pl_scTypeIdx)return EPTF_ExecCtrl_WeightedScData
f_EPTF_ExecCtrl_numTcOfScenarioType(in integer pl_scTypeIdx)return integer
f_EPTF_Exectrl_getTcOfScenarioType(in integer pl_scTypeIdx, in integer pl_tcIdx)return EPTF_ExecCtrl_TcOfScenario
*/
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_initTypeDB
//
// Purpose:
// Initializes the type database
//
// Parameters:
//
// Return Value:
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_initTypeDB()
runs on EPTF_ExecCtrl_CT
{
v_ExecCtrl_tcTypesHash := f_EPTF_str2int_HashMap_New(c_ExecCtrl_tcTypesHashMapName);
v_ExecCtrl_scenarioTypesHash := f_EPTF_str2int_HashMap_New(c_ExecCtrl_scenarioTypesHashMapName);
// v_ExecCtrl_grpNamesHash := f_EPTF_str2int_HashMap_New(c_ExecCtrl_grpNames);
v_ExecCtrl_tcTypes := {};
v_ExecCtrl_scenarioTypes := {};
// v_ExecCtrl_EntityGrpDeclarators := {};
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_cleanupTypeDB
//
// Purpose:
// Cleans the type database
//
// Parameters:
//
// Return Value:
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_cleanupTypeDB()
runs on EPTF_ExecCtrl_CT
{
if (v_ExecCtrl_tcTypesHash != c_ExecCtrl_invalidIdx) {
f_EPTF_str2int_HashMap_Delete(c_ExecCtrl_tcTypesHashMapName);
v_ExecCtrl_tcTypesHash := c_ExecCtrl_invalidIdx;
}
if (v_ExecCtrl_scenarioTypesHash != c_ExecCtrl_invalidIdx) {
f_EPTF_str2int_HashMap_Delete(c_ExecCtrl_scenarioTypesHashMapName);
// f_EPTF_str2int_HashMap_Delete(c_ExecCtrl_grpNames);
v_ExecCtrl_scenarioTypesHash := c_ExecCtrl_invalidIdx;
// v_ExecCtrl_grpNamesHash := c_ExecCtrl_invalidIdx;
}
v_ExecCtrl_tcTypes := {};
v_ExecCtrl_scenarioTypes := {};
// v_ExecCtrl_EntityGrpDeclarators := {};
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_loadTypeDB
//
// Purpose:
// Load the type database from all kind of declarators
//
// Parameters:
// pl_scDecl - *in* <EPTF_LGenBase_ScenarioDeclaratorList> *optional* - Scenario Declator
// pl_tcDecl - *in* <EPTF_LGenBase_tcTypeDeclaratorList> *optional* - Traffic case declator
// pl_sc2Decl - *in* <EPTF_LGenBase_TcMgmt_ScenarioDeclaratorList> *optional* - Scenario Declator 2
// pl_tc2Decl - *in* <EPTF_LGenBase_TcMgmt_tcTypeDeclaratorList> *optional* - Traffic case declator 2
// pl_weightedScDecl - *in* <EPTF_LGenBase_TcMgmt_WeightedScenarioDeclaratorList> *optional*- Weighted Scenario Declator
// pl_scDeclList - *in* <EPTF_LGenBase_ScenarioTypeDeclaratorList> *optional* - Scenario Declator appeared in R3
//
// Return Value:
//
// Errors:
//
// Detailed Comments:
// The function can be called several times.
// The loaded data is appended to the existing one.
// All parameters are optional. Default values for all is the empty list {}.
// Entity Groups are loaded by <f_EPTF_ExecCtrl_loadInstanceDB>
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_loadTypeDB(
// in EPTF_LGenBase_TcMgmt_EntityGrpDeclaratorList pl_eGrpDecl := {},
in EPTF_LGenBase_ScenarioDeclaratorList pl_scDecl := {},
in EPTF_LGenBase_tcTypeDeclaratorList pl_tcDecl := {},
in EPTF_LGenBase_TcMgmt_ScenarioDeclaratorList pl_sc2Decl := {},
in EPTF_LGenBase_TcMgmt_tcTypeDeclaratorList pl_tc2Decl := {},
in EPTF_LGenBase_TcMgmt_WeightedScenarioDeclaratorList pl_weightedScDecl := {},
in EPTF_LGenBase_ScenarioTypeDeclaratorList pl_scDeclList := {}
)
runs on EPTF_ExecCtrl_CT {
// f_EPTF_ExecCtrl_addEGrpTypesFromDeclarators(
// pl_eGrpDecl
// );
f_EPTF_ExecCtrl_addTcTypesFromDeclarators(
pl_tc2Decl);
f_EPTF_ExecCtrl_addScenario2TypesFromDeclarators(
pl_sc2Decl);
f_EPTF_ExecCtrl_addWeightedScenarioTypesFromDeclarators(
pl_weightedScDecl);
f_EPTF_ExecCtrl_fillTypeDbFromObsoleteDeclarators(
pl_scDecl,
pl_tcDecl);
f_EPTF_ExecCtrl_addScenarioTypesFromDeclaratorsR3(pl_scDeclList);
f_EPTF_ExecCtrl_dumpTypeDB();
}
// ///////////////////////////////
// // Entity Group Type DB functions
// private function f_EPTF_ExecCtrl_addEGrpType(in EPTF_LGenBase_EntityGrpDeclarator pl_eGrpType)
// runs on EPTF_ExecCtrl_CT
// return integer
// {
// var integer vl_idx := sizeof(v_ExecCtrl_EntityGrpDeclarators);
// f_EPTF_str2int_HashMap_Insert(v_ExecCtrl_grpNamesHash, pl_eGrpType.name, vl_idx);
// v_ExecCtrl_EntityGrpDeclarators[vl_idx] := pl_tcType;
// return vl_idx;
// }
//
// private function f_EPTF_ExecCtrl_numEGrpTypes()
// runs on EPTF_ExecCtrl_CT
// return integer
// {
// return sizeof(v_ExecCtrl_EntityGrpDeclarators);
// }
//
// private function f_EPTF_ExecCtrl_getEGrpTypeIdx(in charstring pl_eGrpName)
// runs on EPTF_ExecCtrl_CT
// return integer
// {
// var integer vl_idx := -1;
// var boolean vl_found := f_EPTF_str2int_HashMap_Find(
// v_ExecCtrl_grpNamesHash,
// pl_eGrpName,
// vl_idx);
// f_EPTF_Base_assert(%definitionId&": Cannot find entity group type "&pl_eGrpName&" in database.", vl_found);
// return vl_idx;
// }
///////////////////////////////
// TrafficCase Type DB functions
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_addTcType
//
// Purpose:
// Add a traffic case type to the type DB
//
// Parameters:
// pl_tcType - *in* <f_EPTF_ExecCtrl_addTcType> - the traffic case type to add
//
// Return Value:
//
// Errors:
//
// Detailed Comments:
// The function can be called several times.
// The loaded data is appended to the existing one.
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_addTcType(in EPTF_ExecCtrl_TcType pl_tcType)
runs on EPTF_ExecCtrl_CT
//return integer
{
var integer vl_idx := sizeof(v_ExecCtrl_tcTypes);
f_EPTF_str2int_HashMap_Insert(v_ExecCtrl_tcTypesHash, pl_tcType.name, vl_idx);
v_ExecCtrl_tcTypes[vl_idx] := pl_tcType;
//return vl_idx;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_numTcTypes
//
// Purpose:
// Returns the number of traffic case types in the type DB
//
// Parameters:
//
// Return Value:
// integer - number of traffic case types
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_numTcTypes()
runs on EPTF_ExecCtrl_CT
return integer
{
return sizeof(v_ExecCtrl_tcTypes);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_getTcTypeIdx
//
// Purpose:
// Returns the Id of a traffic case type in the type DB
//
// Parameters:
// pl_tcName - *in* *charstring* - name of the traffic case type
//
// Return Value:
// integer - id of traffic case type
//
// Errors:
// If tc with the given name is not found
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_getTcTypeIdx(in charstring pl_tcName)
runs on EPTF_ExecCtrl_CT
return integer
{
var integer vl_idx := -1;
if(not f_EPTF_str2int_HashMap_Find(
v_ExecCtrl_tcTypesHash,
pl_tcName,
vl_idx)
) {
f_EPTF_ExecCtrl_debug(%definitionId&": Cannot find traffic case type "&pl_tcName&" in database.");
return -1;
}
return vl_idx;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_getTcTypeIdxsForEType
//
// Purpose:
// Returns the tcTypeIdx-es in EPTF_ExecCtrl_TcTypeList of those tcTypes that use the given eType
//
// Parameters:
// pl_eType - *in* *charstring* - name of the entity type
//
// Return Value:
// EPTF_IntegerList - ids of traffic case types that use the given eType
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_getTcTypeIdxsForEType(in charstring pl_eType)
runs on EPTF_ExecCtrl_CT
return EPTF_IntegerList
{
var EPTF_IntegerList vl_tcTypeIdxList := {};
for(var integer i:=0; i<sizeof(v_ExecCtrl_tcTypes); i:=i+1) {
if (v_ExecCtrl_tcTypes[i].entityType == pl_eType) {
vl_tcTypeIdxList[sizeof(vl_tcTypeIdxList)] := i;
}
}
return vl_tcTypeIdxList;
}
///////////////////////////////
// Scenario Type DB functions
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_addScenarioType
//
// Purpose:
// Add a scenario type to the type DB
//
// Parameters:
// pl_scType - *in* <EPTF_ExecCtrl_ScenarioType> - type of the scenario to add
//
// Return Value:
// -
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_addScenarioType(in EPTF_ExecCtrl_ScenarioType pl_scType)
runs on EPTF_ExecCtrl_CT
//return integer
{
var integer vl_idx := sizeof(v_ExecCtrl_scenarioTypes);
f_EPTF_str2int_HashMap_Insert(v_ExecCtrl_scenarioTypesHash, pl_scType.name, vl_idx);
v_ExecCtrl_scenarioTypes[vl_idx] := pl_scType;
//return vl_idx;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_numScenarioTypes
//
// Purpose:
// Returns the number of scenario types in the type DB
//
// Parameters:
//
// Return Value:
// integer - number of the scenario types
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_numScenarioTypes()
runs on EPTF_ExecCtrl_CT
return integer
{
return sizeof(v_ExecCtrl_scenarioTypes);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_getScenarioTypeIdx
//
// Purpose:
// Returns the id of scenario type in the type DB, -1 if not found
//
// Parameters:
// pl_scName - *in charstring* - name of the scenario type
//
// Return Value:
// integer - id of the scenario type
//
// Errors:
// If the scenario not found
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_getScenarioTypeIdx(in charstring pl_scName)
runs on EPTF_ExecCtrl_CT
return integer
{
var integer vl_idx := -1;
var boolean vl_found := f_EPTF_str2int_HashMap_Find(
v_ExecCtrl_scenarioTypesHash,
pl_scName,
vl_idx);
if (not vl_found) {
return -1;
}
return vl_idx;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_getScenarioTypeName
//
// Purpose:
// Returns the name of scenario type
//
// Parameters:
// pl_scTypeIdx - *in integer* - id of the scenario type
//
// Return Value:
// charstring - name of the scenario type
//
// Errors:
// Invalid idx
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_getScenarioTypeName(in integer pl_scTypeIdx)
runs on EPTF_ExecCtrl_CT
return charstring
{
f_EPTF_Base_assert(%definitionId&": Invalid index "&int2str(pl_scTypeIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_scenarioTypes))&").",
pl_scTypeIdx >= 0 and pl_scTypeIdx < sizeof(v_ExecCtrl_scenarioTypes));
return v_ExecCtrl_scenarioTypes[pl_scTypeIdx].name;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_isWeightedScType
//
// Purpose:
// Returns true if the scenario is weighted scenario
//
// Parameters:
// pl_scTypeIdx - *in integer* - id of the scenario type
//
// Return Value:
// boolean - true if the scenario type is weighted
//
// Errors:
// Invalid idx
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_isWeightedScType(in integer pl_scTypeIdx)
runs on EPTF_ExecCtrl_CT
return boolean
{
f_EPTF_Base_assert(%definitionId&": Invalid index "&int2str(pl_scTypeIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_scenarioTypes))&").",
pl_scTypeIdx >= 0 and pl_scTypeIdx < sizeof(v_ExecCtrl_scenarioTypes));
return ispresent(v_ExecCtrl_scenarioTypes[pl_scTypeIdx].weightedScData);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_getWeightedScTypeData
//
// Purpose:
// Returns the weighted scenario data of a scenario type
//
// Parameters:
// pl_scTypeIdx - *in integer* - id of the scenario type
//
// Return Value:
// EPTF_ExecCtrl_WeightedScData - the weighted scenario data
//
// Errors:
// Invalid idx
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_getWeightedScTypeData(in integer pl_scTypeIdx)
runs on EPTF_ExecCtrl_CT
return EPTF_ExecCtrl_WeightedScData
{
f_EPTF_Base_assert(%definitionId&": Invalid index "&int2str(pl_scTypeIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_scenarioTypes))&").",
pl_scTypeIdx >= 0 and pl_scTypeIdx < sizeof(v_ExecCtrl_scenarioTypes));
f_EPTF_Base_assert(%definitionId&": scenario "&v_ExecCtrl_scenarioTypes[pl_scTypeIdx].name&
" is not weighted.", ispresent(v_ExecCtrl_scenarioTypes[pl_scTypeIdx].weightedScData));
return v_ExecCtrl_scenarioTypes[pl_scTypeIdx].weightedScData;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_numTcOfScenarioType
//
// Purpose:
// Returns the number of traffic cases in a scenario type
//
// Parameters:
// pl_scTypeIdx - *in integer* - id of the scenario type
//
// Return Value:
// integer - number of traffic cases in a scenario type
//
// Errors:
// Invalid idx
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_numTcOfScenarioType(in integer pl_scTypeIdx)
runs on EPTF_ExecCtrl_CT
return integer
{
f_EPTF_Base_assert(%definitionId&": Invalid index "&int2str(pl_scTypeIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_scenarioTypes))&").",
pl_scTypeIdx >= 0 and pl_scTypeIdx < sizeof(v_ExecCtrl_scenarioTypes));
return sizeof(v_ExecCtrl_scenarioTypes[pl_scTypeIdx].tcList);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_Exectrl_getTcOfScenarioType
//
// Purpose:
// Returns the traffic case data of a scenario type
//
// Parameters:
// pl_scTypeIdx - *in integer* - id of the scenario type
// pl_tcIdx - *in integer* - id of the traffic case in the scenario
//
// Return Value:
// EPTF_ExecCtrl_TcOfScenario - the traffic case data in the scenario type
//
// Errors:
// Invalid idx-es
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_Exectrl_getTcOfScenarioType(in integer pl_scTypeIdx, in integer pl_tcIdx)
runs on EPTF_ExecCtrl_CT
return EPTF_ExecCtrl_TcOfScenario
{
f_EPTF_Base_assert(%definitionId&": Invalid SC index "&int2str(pl_scTypeIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_scenarioTypes))&").",
pl_scTypeIdx >= 0 and pl_scTypeIdx < sizeof(v_ExecCtrl_scenarioTypes));
f_EPTF_Base_assert(%definitionId&": Invalid TC index "&int2str(pl_tcIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_scenarioTypes[pl_scTypeIdx].tcList))&").",
pl_tcIdx >= 0 and pl_tcIdx < sizeof(v_ExecCtrl_scenarioTypes[pl_scTypeIdx].tcList));
return v_ExecCtrl_scenarioTypes[pl_scTypeIdx].tcList[pl_tcIdx];
}
////////////////////////////////////////////////////////////
// Functions filling the Type DB from the declarators
//f_EPTF_ExecCtrl_addTcTypesFromDeclarators(in EPTF_LGenBase_TcMgmt_tcTypeDeclaratorList pl_tcDecl)
//f_EPTF_ExecCtrl_addScenario2TypesFromDeclarators(in EPTF_LGenBase_TcMgmt_ScenarioDeclaratorList pl_scDecl)
//f_EPTF_ExecCtrl_addWeightedScenarioTypesFromDeclarators(in EPTF_LGenBase_TcMgmt_WeightedScenarioDeclaratorList pl_scDecl)
//f_EPTF_ExecCtrl_fillTypeDbFromObsoleteDeclarators(in EPTF_LGenBase_ScenarioDeclaratorList pl_scDecl,in EPTF_LGenBase_tcTypeDeclaratorList pl_tcDecl)
// private function f_EPTF_ExecCtrl_addEGrpTypesFromDeclarators(
// in EPTF_LGenBase_TcMgmt_EntityGrpDeclaratorList pl_eGrpDecl
// )
// runs on EPTF_ExecCtrl_CT
// {
// for(var integer i := 0; i < sizeof(pl_eGrpDecl); i := i + 1) {
// f_EPTF_ExecCtrl_addEGrpType(pl_eGrpDecl[i]);
// }
// }
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_addTcTypesFromDeclarators
//
// Purpose:
// Add traffic case types to the database using declarators
//
// Parameters:
// pl_tcDecl - *in* <EPTF_LGenBase_TcMgmt_tcTypeDeclaratorList> - traffic case declarator
//
// Return Value:
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_addTcTypesFromDeclarators(
in EPTF_LGenBase_TcMgmt_tcTypeDeclaratorList pl_tcDecl
)
runs on EPTF_ExecCtrl_CT
{
var EPTF_LGenBase_TrafficCaseTypeInternalDeclarator vl_tc;
for(var integer i := 0; i < sizeof(pl_tcDecl); i := i + 1) {
f_EPTF_LGenBase_convertTcTypeDeclarator22Internal(pl_tcDecl[i], vl_tc)
f_EPTF_ExecCtrl_addTcType(vl_tc);
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_addScenarioTypesFromDeclaratorsR3
//
// Purpose:
// Add scenario types to the database using scenario declarator introduced in R3
//
// Parameters:
// pl_scDecl - *in* <EPTF_LGenBase_ScenarioTypeDeclaratorList> - scenario declarator R3
//
// Return Value:
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_addScenarioTypesFromDeclaratorsR3(
in EPTF_LGenBase_ScenarioTypeDeclaratorList pl_scDecl
)
runs on EPTF_ExecCtrl_CT
{
for(var integer i := 0; i < sizeof(pl_scDecl); i := i + 1) {
var EPTF_ExecCtrl_ScenarioType vl_sc;
f_EPTF_LGenBase_convertScenarioTypeDeclarator2Internal(pl_scDecl[i], vl_sc)
for(var integer j := 0; j < sizeof(pl_scDecl[i].tcList); j := j + 1) {
// check if traffic case type exists:
var charstring vl_tcTypeName := f_EPTF_LGenBase_tcTypeNameOfTcOfSc(vl_sc,j)
var integer vl_tcTypeIdx := f_EPTF_ExecCtrl_getTcTypeIdx(vl_tcTypeName);
if(vl_tcTypeIdx < 0) {
f_EPTF_ExecCtrl_debug("Scenario "&pl_scDecl[i].name&
" refers to a non-existent traffic case type "&vl_tcTypeName);
}
}
f_EPTF_ExecCtrl_addScenarioType(vl_sc);
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_addScenario2TypesFromDeclarators
//
// Purpose:
// Add scenario types 2 to the database using scenario declarator
//
// Parameters:
// pl_scDecl - *in* <EPTF_LGenBase_TcMgmt_ScenarioDeclaratorList> - scenario declarator
//
// Return Value:
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_addScenario2TypesFromDeclarators(
in EPTF_LGenBase_TcMgmt_ScenarioDeclaratorList pl_scDecl
)
runs on EPTF_ExecCtrl_CT
{
for(var integer i := 0; i < sizeof(pl_scDecl); i := i + 1) {
var EPTF_ExecCtrl_ScenarioType vl_sc;/* := c_EPTF_LGenBase_emptyScenarioTypeInternalDeclarator
vl_sc := {
name := pl_scDecl[i].name,
enabled := true,
phaseListName := omit,
weightedScData := omit,
tcList := {}
}*/
f_EPTF_LGenBase_convertTcMgmtScenarioDeclarator22Internal(pl_scDecl[i],vl_sc)
for(var integer j := 0; j < sizeof(pl_scDecl[i].tcList); j := j + 1) {
var charstring vl_tcTypeName := f_EPTF_LGenBase_tcTypeNameOfTcOfSc(vl_sc,j)
var integer vl_tcTypeIdx := f_EPTF_ExecCtrl_getTcTypeIdx(vl_tcTypeName);
if(vl_tcTypeIdx < 0) {
f_EPTF_ExecCtrl_error("Scenario "&pl_scDecl[i].name&
" refers to a non-existent traffic case type "&vl_tcTypeName);
}
/*vl_sc.tcList[j] := c_EPTF_LGenBase_TcMgmt_emptyTcOfScenario3;
vl_sc.tcList[j] := {
tcName := pl_scDecl[i].tcList[j].tcName,
startDelay := pl_scDecl[i].tcList[j].startDelay,
target := { cpsToReach := pl_scDecl[i].tcList[j].cpsToReach },
scheduler := omit,
enableEntities := pl_scDecl[i].tcList[j].enableEntities,
enable := pl_scDecl[i].tcList[j].enable,
ranges := pl_scDecl[i].tcList[j].ranges,
params := pl_scDecl[i].tcList[j].params,
groupFinishConditions := pl_scDecl[i].tcList[j].groupFinishConditions,
entityFinishConditions := pl_scDecl[i].tcList[j].entityFinishConditions,
entityFinishActions := pl_scDecl[i].tcList[j].entityFinishActions,
tcFinishActions := pl_scDecl[i].tcList[j].tcFinishActions,
templateSet := omit // no data for template set
}*/
}
f_EPTF_ExecCtrl_addScenarioType(vl_sc);
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_addWeightedScenarioTypesFromDeclarators
//
// Purpose:
// Add weighted scenario types to the database using scenario declarator
//
// Parameters:
// pl_scDecl - *in* <EPTF_LGenBase_TcMgmt_WeightedScenarioDeclaratorList> - weighted scenario declarator
//
// Return Value:
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_addWeightedScenarioTypesFromDeclarators(
in EPTF_LGenBase_TcMgmt_WeightedScenarioDeclaratorList pl_scDecl
)
runs on EPTF_ExecCtrl_CT
{
for(var integer i := 0; i < sizeof(pl_scDecl); i := i + 1) {
var EPTF_ExecCtrl_ScenarioType vl_sc;
f_EPTF_LGenBase_convertWeightedScenarioDeclarator2Internal(pl_scDecl[i], vl_sc);
/*
var EPTF_ExecCtrl_ScenarioType vl_sc := c_EPTF_LGenBase_emptyScenarioTypeInternalDeclarator
vl_sc.weightedScData := c_EPTF_LGenBase_emptyWeightedScData;
vl_sc := {
name := pl_scDecl[i].name,
enabled := pl_scDecl[i].enabled,
phaseListName := omit,
weightedScData := {
cpsToReach := pl_scDecl[i].cpsToReach,
lockCPS := pl_scDecl[i].lockCPS,
deterministicMix := pl_scDecl[i].weightedScData.deterministicMix
},
tcList := {}
}*/
for(var integer j := 0; j < sizeof(pl_scDecl[i].tcList); j := j + 1) {
var charstring vl_tcTypeName := f_EPTF_LGenBase_tcTypeNameOfTcOfSc(vl_sc,j)
var integer vl_tcTypeIdx := f_EPTF_ExecCtrl_getTcTypeIdx(vl_tcTypeName);
if(vl_tcTypeIdx < 0) {
f_EPTF_ExecCtrl_error("Scenario "&pl_scDecl[i].name&
" refers to a non-existent traffic case type "&vl_tcTypeName);
}
/*vl_sc.tcList[j] := c_EPTF_LGenBase_emptyT;
vl_sc.tcList[j] := {
tcName := pl_scDecl[i].tcList[j].tcName,
startDelay := omit,
target := { trafficWeight := pl_scDecl[i].tcList[j].tcWeight },
scheduler := omit,
enableEntities := pl_scDecl[i].tcList[j].enableEntities,
enable := pl_scDecl[i].tcList[j].enable,
ranges := pl_scDecl[i].tcList[j].ranges,
params := pl_scDecl[i].tcList[j].params,
groupFinishConditions := pl_scDecl[i].tcList[j].groupFinishConditions,
entityFinishConditions := pl_scDecl[i].tcList[j].entityFinishConditions,
entityFinishActions := pl_scDecl[i].tcList[j].entityFinishActions,
tcFinishActions := pl_scDecl[i].tcList[j].tcFinishActions,
templateSet := omit // no data for template set
}*/
}
f_EPTF_ExecCtrl_addScenarioType(vl_sc);
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_fillTypeDbFromObsoleteDeclarators
//
// Purpose:
// Add scenario types to the database using obsolete scenario declarator
//
// Parameters:
// pl_scDecl - *in* <EPTF_LGenBase_ScenarioDeclaratorList> - obsolete scenario declarator
// pl_tcDecl - *in* <EPTF_LGenBase_tcTypeDeclaratorList> - obsolete traffic case declarator
//
// Return Value:
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_fillTypeDbFromObsoleteDeclarators(
in EPTF_LGenBase_ScenarioDeclaratorList pl_scDecl,
in EPTF_LGenBase_tcTypeDeclaratorList pl_tcDecl
)
runs on EPTF_ExecCtrl_CT
{
for(var integer i := 0; i < sizeof(pl_tcDecl); i := i + 1) {
var EPTF_ExecCtrl_TcType vl_tcType;/* :=
{
name := pl_tcDecl[i].name,
fsmName := pl_tcDecl[i].fsmName,
entityType := pl_tcDecl[i].entityType,
customEntitySucc := pl_tcDecl[i].customEntitySucc
}*/
f_EPTF_LGenBase_converttcTypeDeclarator2Internal(
pl_tcDecl[i],
vl_tcType)
f_EPTF_ExecCtrl_addTcType(vl_tcType);
}
for(var integer i := 0; i < sizeof(pl_scDecl); i := i + 1) {
var EPTF_ExecCtrl_ScenarioType vl_sc;/* := c_EPTF_LGenBase_emptyScenarioTypeInternalDeclarator
vl_sc := {
name := pl_scDecl[i].name,
enabled := true,
phaseListName := omit,
weightedScData := omit,
tcList := {}
}*/
f_EPTF_LGenBase_convertScenarioDeclarator2Internal(pl_scDecl[i], vl_sc)
for(var integer j := 0; j < sizeof(pl_scDecl[i].tcList); j := j + 1) {
var charstring vl_tcTypeName := f_EPTF_LGenBase_tcTypeNameOfTcOfSc(vl_sc,j)
var integer vl_tcTypeIdx := f_EPTF_ExecCtrl_getTcTypeIdx(vl_tcTypeName);
var integer vl_tcDeclIdx := -1;
for(var integer k := 0; k < sizeof(pl_tcDecl); k := k + 1) {
if(pl_scDecl[i].tcList[j].tcName == pl_tcDecl[k].name) {
vl_tcDeclIdx := k;
k := sizeof(pl_tcDecl);
}
}
if(vl_tcTypeIdx < 0 or vl_tcDeclIdx < 0) {
f_EPTF_ExecCtrl_error("Scenario "&pl_scDecl[i].name&
" refers to a non-existent traffic case type "&vl_tcTypeName);
}
/*vl_sc.tcList[j] := c_EPTF_LGenBase_TcMgmt_emptyTcOfScenario3;
vl_sc.tcList[j] := {
tcName := pl_scDecl[i].tcList[j].tcName,
startDelay := pl_scDecl[i].tcList[j].startDelay,
target := { cpsToReach := pl_scDecl[i].tcList[j].cpsToReach },
scheduler := omit,
enableEntities := pl_scDecl[i].tcList[j].enableEntities,
enable := pl_scDecl[i].tcList[j].enable,
ranges := pl_scDecl[i].tcList[j].ranges,
params := pl_tcDecl[vl_tcDeclIdx].params,
groupFinishConditions := {
nrOfExecStart := pl_tcDecl[vl_tcDeclIdx].groupFinishConditions.nrOfExecStart,
nrOfSuccesses := pl_tcDecl[vl_tcDeclIdx].groupFinishConditions.nrOfSuccesses,
nrOfFails := pl_tcDecl[vl_tcDeclIdx].groupFinishConditions.nrOfFails,
nrOfGrpLoop := pl_tcDecl[vl_tcDeclIdx].groupFinishConditions.nrOfGrpLoop,
nrOfRangeLoop := pl_tcDecl[vl_tcDeclIdx].groupFinishConditions.nrOfRangeLoop,
execTime := pl_tcDecl[vl_tcDeclIdx].groupFinishConditions.execTime,
entitiesFinished := omit,
customFinishCondition := pl_tcDecl[vl_tcDeclIdx].groupFinishConditions.customFinishCondition
},
entityFinishConditions := pl_tcDecl[vl_tcDeclIdx].entityFinishConditions,
entityFinishActions := pl_tcDecl[vl_tcDeclIdx].entityFinishActions,
tcFinishActions := {{actionsType := onGroupFinishCondition, actions := pl_tcDecl[vl_tcDeclIdx].groupFinishActions}},
templateSet := omit // no data for template set
}*/
}
f_EPTF_ExecCtrl_addScenarioType(vl_sc);
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_dumpTypeDB
//
// Purpose:
// Write the type DB into the log file for debug purposes
//
// Parameters:
//
// Return Value:
//
// Errors:
//
// Detailed Comments:
// It dumps the traffic case and the scenario declarator type DB
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_dumpTypeDB()
runs on EPTF_ExecCtrl_CT
{
f_EPTF_ExecCtrl_debug("---------------------------"&%definitionId&"---------------------------");
f_EPTF_ExecCtrl_debug("Traffic Case Types:");
f_EPTF_ExecCtrl_debug(log2str(v_ExecCtrl_tcTypes));
f_EPTF_ExecCtrl_debug("Scenario Types:");
f_EPTF_ExecCtrl_debug(log2str(v_ExecCtrl_scenarioTypes));
f_EPTF_ExecCtrl_debug("---------------------------"&%definitionId&"---------------------------");
}
} // group EPTF_ExecCtrl_TypeDB
///////////////////////////////////////////////////////////
// Group: EPTF_ExecCtrl_InstanceDB
//
// Purpose:
// Contains items corresponding to the instance database
//
// Elements:
///////////////////////////////////////////////////////////
group EPTF_ExecCtrl_InstanceDB {
/* functions:
f_EPTF_ExecCtrl_initInstanceDB()
f_EPTF_ExecCtrl_cleanupInstanceDB()
f_EPTF_ExecCtrl_loadInstanceDB(in EPTF_LGenBase_TcMgmt_EntityGrpDeclaratorList pl_entityGroupDeclarators := {},in EPTF_LGenBase_TcMgmt_Scenarios2GrpList pl_sc2GrpList := {})
f_EPTF_ExecCtrl_addEntityGroupInstance(in EPTF_ExecCtrl_EntityGroup pl_entityGroup)
f_EPTF_ExecCtrl_numEntityGroups()
f_EPTF_ExecCtrl_numEntities()
f_EPTF_ExecCtrl_getEntityGroupIdx(in charstring pl_eGrpName)
f_EPTF_ExecCtrl_addScenario2EntityGroup(in charstring pl_eGrpName, in charstring pl_scTypeName, in charstring pl_scInstanceName := "")
f_EPTF_ExecCtrl_numScenarios()
f_EPTF_ExecCtrl_getScenarioIdx(in charstring pl_scName)
f_EPTF_ExecCtrl_getScenarioName(in integer pl_scIdx)
f_EPTF_ExecCtrl_isWeightedScenario(in integer pl_scIdx)
f_EPTF_ExecCtrl_getWeightedScData(in integer pl_scIdx)
f_EPTF_ExecCtrl_numTcOfScenario(in integer pl_scIdx)
f_EPTF_Exectrl_getTcOfScenario(in integer pl_scIdx, in integer pl_tcIdx)
*/
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_initInstanceDB
//
// Purpose:
// Initializes the instance DB
//
// Parameters:
//
// Return Value:
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_initInstanceDB()
runs on EPTF_ExecCtrl_CT
{
v_ExecCtrl_entityGroupsHash := f_EPTF_str2int_HashMap_New(c_ExecCtrl_entityGroupsHashMapName);
v_ExecCtrl_scenariosHash := f_EPTF_str2int_HashMap_New(c_ExecCtrl_scenariosHashMapName);
v_ExecCtrl_trafficCasesHash := f_EPTF_str2int_HashMap_New(c_ExecCtrl_trafficCasesHashMapName);
v_ExecCtrl_lgensHash := f_EPTF_str2int_HashMap_New(c_ExecCtrl_lgensHashMapName);
v_ExecCtrl_entityGroups := {};
v_ExecCtrl_scenarios := {};
v_ExecCtrl_trafficCases := {};
v_ExecCtrl_lgens := {};
v_ExecCtrl_entityCounter := 0;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_cleanupInstanceDB
//
// Purpose:
// Cleans up the instance DB
//
// Parameters:
//
// Return Value:
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_cleanupInstanceDB()
runs on EPTF_ExecCtrl_CT
{
if (v_ExecCtrl_entityGroupsHash != c_ExecCtrl_invalidIdx) {
f_EPTF_str2int_HashMap_Delete(c_ExecCtrl_entityGroupsHashMapName);
v_ExecCtrl_entityGroupsHash := c_ExecCtrl_invalidIdx;
}
if (v_ExecCtrl_scenariosHash != c_ExecCtrl_invalidIdx) {
f_EPTF_str2int_HashMap_Delete(c_ExecCtrl_scenariosHashMapName);
v_ExecCtrl_scenariosHash := c_ExecCtrl_invalidIdx;
}
if (v_ExecCtrl_trafficCasesHash != c_ExecCtrl_invalidIdx) {
f_EPTF_str2int_HashMap_Delete(c_ExecCtrl_trafficCasesHashMapName);
v_ExecCtrl_trafficCasesHash := c_ExecCtrl_invalidIdx;
}
if (v_ExecCtrl_lgensHash != c_ExecCtrl_invalidIdx) {
f_EPTF_str2int_HashMap_Delete(c_ExecCtrl_lgensHashMapName);
v_ExecCtrl_lgensHash := c_ExecCtrl_invalidIdx;
}
v_ExecCtrl_entityGroups := {};
v_ExecCtrl_scenarios := {};
v_ExecCtrl_trafficCases := {};
v_ExecCtrl_lgens := {};
v_ExecCtrl_entityCounter := 0;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_loadInstanceDB
//
// Purpose:
// Loads the instance DB from declarators
//
// Parameters:
// pl_entityGroupDeclarators - *in* <EPTF_LGenBase_TcMgmt_EntityGrpDeclaratorList> - entity group decl
// pl_sc2GrpList - *in* <EPTF_LGenBase_TcMgmt_Scenarios2GrpList> - scenario to group decl
// pl_scInstanceDeclarators - *in* <EPTF_ExecCtrl_ScenarioInstanceTypeList> - instance decl
//
// Return Value:
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_loadInstanceDB(
in EPTF_LGenBase_TcMgmt_EntityGrpDeclaratorList pl_entityGroupDeclarators := {},
in EPTF_LGenBase_TcMgmt_Scenarios2GrpList pl_sc2GrpList := {},
in EPTF_ExecCtrl_ScenarioInstanceTypeList pl_scInstanceDeclarators := {}
)
runs on EPTF_ExecCtrl_CT {
f_EPTF_ExecCtrl_addEntityGroupsFromDeclarators(
pl_entityGroupDeclarators);
f_EPTF_ExecCtrl_addScenariosFromObsoleteDeclarators(
pl_sc2GrpList);
f_EPTF_ExecCtrl_addScenariosFromDeclarators(
pl_scInstanceDeclarators
);
// LGens are loaded when they log in and when the eGroups are distributed on them
f_EPTF_ExecCtrl_dumpInstanceDB();
}
///////////////////////////////
// EntityGroup DB functions
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_addEntityGroupInstance
//
// Purpose:
// Adds an entity group to the instance DB
//
// Parameters:
// pl_entityGroup - *in* <EPTF_ExecCtrl_EntityGroup> - entity group to add
//
// Return Value:
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_addEntityGroupInstance(in EPTF_ExecCtrl_EntityGroup pl_entityGroup)
runs on EPTF_ExecCtrl_CT
//return integer
{
var integer vl_idx := sizeof(v_ExecCtrl_entityGroups);
f_EPTF_str2int_HashMap_Insert(v_ExecCtrl_entityGroupsHash, pl_entityGroup.name, vl_idx);
v_ExecCtrl_entityGroups[vl_idx] := pl_entityGroup;
//return vl_idx;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_numEntityGroups
//
// Purpose:
// Returns the number of entity groups in the instance DB
//
// Parameters:
//
// Return Value:
// integer - number of entity groups
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_numEntityGroups()
runs on EPTF_ExecCtrl_CT
return integer
{
return sizeof(v_ExecCtrl_entityGroups);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_eGrp_name
//
// Purpose:
// Returns the name of entity group in the instance DB
//
// Parameters:
// pl_eGrpIdx - *in integer* - id of the entity group
//
// Return Value:
// charstring - name of the entity group
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_eGrp_name(in integer pl_eGrpIdx)
runs on EPTF_ExecCtrl_CT
return charstring
{
return v_ExecCtrl_entityGroups[pl_eGrpIdx].name;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_eGrp_eType
//
// Purpose:
// Returns the eType of entity group in the instance DB
//
// Parameters:
// pl_eGrpIdx - *in integer* - id of the entity group
//
// Return Value:
// charstring - eType of the entity group
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_eGrp_eType(in integer pl_eGrpIdx)
runs on EPTF_ExecCtrl_CT
return charstring
{
return v_ExecCtrl_entityGroups[pl_eGrpIdx].eType;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_eGrp_eCount
//
// Purpose:
// Returns the eCount of entity group in the instance DB
//
// Parameters:
// pl_eGrpIdx - *in integer* - id of the entity group
//
// Return Value:
// integer - eCount of the entity group
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_eGrp_eCount(in integer pl_eGrpIdx)
runs on EPTF_ExecCtrl_CT
return integer
{
return v_ExecCtrl_entityGroups[pl_eGrpIdx].eCount;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_getActiveEntities
//
// Purpose:
// Returns the number of active entities of entity group in the instance DB
//
// Parameters:
// pl_eGrpIdx - *in integer* - id of the entity group
//
// Return Value:
// integer - number of active entities of the entity group
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_getActiveEntities(in integer pl_eGrpIdx)
runs on EPTF_ExecCtrl_CT
return integer
{
var charstring vl_currentName := c_EPTF_ExecCtrl_statisticsRoot&".EG."&f_EPTF_ExecCtrl_eGrp_name(pl_eGrpIdx)&".nofActiveEntities";
var integer vl_idx := f_EPTF_Var_getId(vl_currentName);
if (vl_idx==-1) {
return v_ExecCtrl_entityGroups[pl_eGrpIdx].eCount;
}
return f_EPTF_Var_getIntValue(vl_idx);
//return v_ExecCtrl_entityGroups[pl_eGrpIdx].eCount;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_setActiveEntities
//
// Purpose:
// Returns the number of active entities of entity group in the instance DB
//
// Parameters:
// pl_eGrpIdx - *in integer* - id of the entity group
// pl_activeEntities - *in integer* - number of active entities set
//
// Return Value:
// -
//
// Errors:
//
// Detailed Comments:
// If pl_activeEntities<0 the number of active entities is set to 0
// If pl_activeEntities>number of allocated entities the number of
// active entities is set to number of allocated entities
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_setActiveEntities(in integer pl_eGrpIdx, in integer pl_activeEntities)
runs on EPTF_ExecCtrl_CT
{
var charstring vl_currentName := c_EPTF_ExecCtrl_statisticsRoot&".EG."&f_EPTF_ExecCtrl_eGrp_name(pl_eGrpIdx)&".nofActiveEntities";
var integer vl_idx := f_EPTF_Var_getId(vl_currentName);
if (vl_idx==-1) {
return;
}
var integer vl_newActiveEntities := pl_activeEntities;
if (vl_newActiveEntities<0) {
vl_newActiveEntities := 0;
}
var integer vl_allocatedEntities := f_EPTF_ExecCtrl_getAllocatedEntities(pl_eGrpIdx);
if (vl_newActiveEntities>vl_allocatedEntities) {
vl_newActiveEntities := vl_allocatedEntities;
}
f_EPTF_Var_adjustContent(vl_idx, {intVal := vl_newActiveEntities});
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_eGrp_eOffset
//
// Purpose:
// Returns the eOffset of entity group in the instance DB
//
// Parameters:
// pl_eGrpIdx - *in integer* - id of the entity group
//
// Return Value:
// integer - eOffset of the entity group
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_eGrp_eOffset(in integer pl_eGrpIdx)
runs on EPTF_ExecCtrl_CT
return integer
{
return v_ExecCtrl_entityGroups[pl_eGrpIdx].eOffset;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_eGrp_lgenList
//
// Purpose:
// Returns the lgenList of entity group in the instance DB
//
// Parameters:
// pl_eGrpIdx - *in integer* - id of the entity group
//
// Return Value:
// integer - lgenList of the entity group
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_eGrp_lgenList(in integer pl_eGrpIdx)
runs on EPTF_ExecCtrl_CT
return EPTF_ExecCtrl_EntityGroupDistributionList
{
return v_ExecCtrl_entityGroups[pl_eGrpIdx].lgenList;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_eGrp_scenarios
//
// Purpose:
// Returns the scenarios of entity group in the instance DB
//
// Parameters:
// pl_eGrpIdx - *in integer* - id of the entity group
//
// Return Value:
// integer - scenarios of the entity group
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_eGrp_scenarios(in integer pl_eGrpIdx)
runs on EPTF_ExecCtrl_CT
return EPTF_IntegerList
{
return v_ExecCtrl_entityGroups[pl_eGrpIdx].scenarios;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_eGrp_lgenPoolName
//
// Purpose:
// Returns the lgenPoolName of entity group in the instance DB
//
// Parameters:
// pl_eGrpIdx - *in integer* - id of the entity group
//
// Return Value:
// integer - lgenPoolName of the entity group
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_eGrp_lgenPoolName(in integer pl_eGrpIdx)
runs on EPTF_ExecCtrl_CT
return charstring
{
if (v_ExecCtrl_entityGroups[pl_eGrpIdx].lgenPoolIdx==-1) {
return "default";
}
return v_EPTF_ExecCtrl_lgenPools[v_ExecCtrl_entityGroups[pl_eGrpIdx].lgenPoolIdx].name;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_numEntities
//
// Purpose:
// Returns the number of entities in the instance DB
//
// Parameters:
//
// Return Value:
// integer - number of entities
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_numEntities()
runs on EPTF_ExecCtrl_CT
return integer {
return v_ExecCtrl_entityCounter;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_getEntityGroupIdx
//
// Purpose:
// Returns the id of an entity group in the instance DB
//
// Parameters:
//
// Return Value:
// integer - id of the entity group (-1 if not found)
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_getEntityGroupIdx(in charstring pl_eGrpName)
runs on EPTF_ExecCtrl_CT
return integer
{
var integer vl_idx := -1;
var boolean vl_found := f_EPTF_str2int_HashMap_Find(
v_ExecCtrl_entityGroupsHash,
pl_eGrpName,
vl_idx);
//f_EPTF_Base_assert(%definitionId&": Cannot find entity group "&pl_eGrpName&" in database.", vl_found);
return vl_idx;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_findEGroups
//
// Purpose:
// finds the entity groups that use the given eType. List of indexes in <EPTF_ExecCtrl_EntityGroupList> are returned.
//
// Parameters:
// pl_eType - *in charstring* - entity type
//
// Return Value:
// <EPTF_IntegerList> - list of ids of the entity groups
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_findEGroups(in charstring pl_eType)
runs on EPTF_ExecCtrl_CT
return EPTF_IntegerList
{
var EPTF_IntegerList vl_eGrpIdxList := {};
// find eGroups with this eType:
var integer vl_numEGrps := f_EPTF_ExecCtrl_numEntityGroups();
for(var integer i:=0; i<vl_numEGrps; i:=i+1) {
if (v_ExecCtrl_entityGroups[i].eType == pl_eType) {
vl_eGrpIdxList[sizeof(vl_eGrpIdxList)] := i;
}
}
f_EPTF_ExecCtrl_debug(log2str("Entity Groups using eType ",pl_eType," are: ", vl_eGrpIdxList));
return vl_eGrpIdxList;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_findETypes
//
// Purpose:
// finds all the different Entity Types used by the entity groups.
//
// Parameters:
//
// Return Value:
// <EPTF_CharstringList> - list of entity types
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_findETypes()
runs on EPTF_ExecCtrl_CT
return EPTF_CharstringList
{
var EPTF_CharstringList vl_eTypeList := {};
var integer vl_numEGrps := f_EPTF_ExecCtrl_numEntityGroups();
// go through all eGroups:
for(var integer i:=0; i<vl_numEGrps; i:=i+1) {
// find eTypes that are not in the list:
var boolean vl_found := false;
for(var integer e:=0; e<sizeof(vl_eTypeList); e:=e+1) {
if (v_ExecCtrl_entityGroups[i].eType == vl_eTypeList[e]) {
// already added
vl_found := true;
break;
}
}
if (vl_found!=true) {
// new eType found:
vl_eTypeList[sizeof(vl_eTypeList)] := v_ExecCtrl_entityGroups[i].eType;
}
}
f_EPTF_ExecCtrl_debug(log2str("Entity Types used by all EGrps are: ", vl_eTypeList));
return vl_eTypeList;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_EntityGroupDistribution_init
//
// Purpose:
// initializes the entity group distribution database
//
// Parameters:
// pl_EPTF_ExecCtrl_EntityGroupDistributionTypeList - *in* <EPTF_ExecCtrl_EntityGroupDistributionTypeList> - the entity group distribution list
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_EntityGroupDistribution_init(
in EPTF_ExecCtrl_EntityGroupDistributionTypeList pl_EPTF_ExecCtrl_EntityGroupDistributionTypeList
) runs on EPTF_ExecCtrl_CT {
v_EPTF_ExecCtrl_entityGroupDistribution := {}
for(var integer i:=0; i<sizeof(pl_EPTF_ExecCtrl_EntityGroupDistributionTypeList); i:=i+1) {
f_EPTF_ExecCtrl_addEntityGroupDistribution(pl_EPTF_ExecCtrl_EntityGroupDistributionTypeList[i]);
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_addEntityGroupDistribution
//
// Purpose:
// adds an entity group distribution item to database
//
// Parameters:
// pl_EPTF_ExecCtrl_EntityGroupDistribution - *in* <EPTF_ExecCtrl_EntityGroupDistributionType> - an entity group distribution item
//
// Return Value:
// -
//
// Errors:
// If the same entity group is added more than once.
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_addEntityGroupDistribution(
in EPTF_ExecCtrl_EntityGroupDistributionType pl_EPTF_ExecCtrl_EntityGroupDistribution
) runs on EPTF_ExecCtrl_CT {
for(var integer i:=0; i<sizeof(v_EPTF_ExecCtrl_entityGroupDistribution); i:=i+1) {
if (v_EPTF_ExecCtrl_entityGroupDistribution[i].eGrpName==pl_EPTF_ExecCtrl_EntityGroupDistribution.eGrpName) {
f_EPTF_ExecCtrl_error(%definitionId&": Invalid configuration data: Distribution for entity group "&pl_EPTF_ExecCtrl_EntityGroupDistribution.eGrpName&" was already defined in "
&log2str(v_EPTF_ExecCtrl_entityGroupDistribution[i])
);
}
}
// add new item to the end of the database:
v_EPTF_ExecCtrl_entityGroupDistribution[sizeof(v_EPTF_ExecCtrl_entityGroupDistribution)] := pl_EPTF_ExecCtrl_EntityGroupDistribution;
}
// private function f_EPTF_ExecCtrl_getDistributionForEGrp(in charstring pl_eGrpName)
// runs on EPTF_ExecCtrl_CT return EPTF_ExecCtrl_LGenWeightTypeList {
// for(var integer i:=0; i<sizeof(v_EPTF_ExecCtrl_entityGroupDistribution);i:=i+1) {
// if (v_EPTF_ExecCtrl_entityGroupDistribution[i].eGrpName==pl_eGrpName) {
// return v_EPTF_ExecCtrl_entityGroupDistribution[i].lgenWeights;
// }
// }
// return {}; // not found
// }
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_getLGenWeightForEGrp
//
// Purpose:
// allocates an entity group for an LGen
//
// Parameters:
// pl_eGrpName - *in charstring* - name of the entity group
// pl_lgenName - *in charstring* - name of the LGen in the entity group
//
// Return Value:
// float - the weight (normalized to 1.0) of the given LGen in the entity group
//
// Errors:
//
// Detailed Comments:
// If no weight is available for an LGen in the entity group 0.0 is returned.
// The entities of the entity group will be distributed according to the
// returned weight factor.
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_getLGenWeightForEGrp(in charstring pl_eGrpName, in charstring pl_lgenName)
runs on EPTF_ExecCtrl_CT return float {
for(var integer i:=0; i<sizeof(v_EPTF_ExecCtrl_entityGroupDistribution);i:=i+1) {
if (v_EPTF_ExecCtrl_entityGroupDistribution[i].eGrpName==pl_eGrpName) {
var float vl_sumWeight := 0.0;
var float vl_lgenWeight := 0.0;
for (var integer j:=0; j<sizeof(v_EPTF_ExecCtrl_entityGroupDistribution[i].lgenWeights); j:=j+1) {
vl_sumWeight := vl_sumWeight+v_EPTF_ExecCtrl_entityGroupDistribution[i].lgenWeights[j].weight;
if (v_EPTF_ExecCtrl_entityGroupDistribution[i].lgenWeights[j].lgenName==pl_lgenName) {
vl_lgenWeight := v_EPTF_ExecCtrl_entityGroupDistribution[i].lgenWeights[j].weight;
}
}
if (vl_sumWeight==0.0) {
return 0.0;
}
return vl_lgenWeight/vl_sumWeight;
}
}
return 0.0; // not found
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_allocateEGrpForLGen
//
// Purpose:
// allocates an entity group for an LGen
//
// Parameters:
// pl_eGrpIdx - *in integer* - id of the entity group
// pl_lgenIdxInEGrp - *in integer* - id of the LGen in the entity group
// pl_entitiesToAllocate - *in integer* - number of entities to allocate
//
// Return Value:
//
// Errors:
//
// Detailed Comments:
// Can be called only in the order of lgens in the v_ExecCtrl_entityGroups[pl_eGrpIdx].lgenList for a given eGrp
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_allocateEGrpForLGen(in integer pl_eGrpIdx, in integer pl_lgenIdxInEGrp,in integer pl_entitiesToAllocate)
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));
f_EPTF_Base_assert(%definitionId&": Invalid LGen index "&int2str(pl_lgenIdxInEGrp)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_entityGroups[pl_eGrpIdx].lgenList))&").",
pl_lgenIdxInEGrp >= 0 and pl_lgenIdxInEGrp < sizeof(v_ExecCtrl_entityGroups[pl_eGrpIdx].lgenList));
var integer vl_lgenIdx := v_ExecCtrl_entityGroups[pl_eGrpIdx].lgenList[pl_lgenIdxInEGrp].lgenIdx;
f_EPTF_ExecCtrl_debug(log2str("Number of entities allocated on LGen ",
v_ExecCtrl_lgens[vl_lgenIdx].name, " for entity group ",v_ExecCtrl_entityGroups[pl_eGrpIdx].name, ": ",pl_entitiesToAllocate));
var integer vl_prev_eOffset := 0;
var integer vl_prev_eCount := 0;
if (pl_lgenIdxInEGrp>0) {
vl_prev_eOffset := v_ExecCtrl_entityGroups[pl_eGrpIdx].lgenList[pl_lgenIdxInEGrp-1].eOffset
vl_prev_eCount := v_ExecCtrl_entityGroups[pl_eGrpIdx].lgenList[pl_lgenIdxInEGrp-1].eCount;
}
// f_EPTF_Base_assert(%definitionId&": Invalid call of function "&%definitionId&".",
// (pl_lgenIdxInEGrp+1==sizeof(v_ExecCtrl_entityGroups[pl_eGrpIdx].lgenList)) // last LGen in the lgenList
// or(v_ExecCtrl_entityGroups[pl_eGrpIdx].lgenList[pl_lgenIdxInEGrp+1].eOffset==0 and
// v_ExecCtrl_entityGroups[pl_eGrpIdx].lgenList[pl_lgenIdxInEGrp+1].eCount==0)); // next LGen is not allocated
v_ExecCtrl_entityGroups[pl_eGrpIdx].lgenList[pl_lgenIdxInEGrp].eOffset := vl_prev_eOffset + vl_prev_eCount;
v_ExecCtrl_entityGroups[pl_eGrpIdx].lgenList[pl_lgenIdxInEGrp].eCount := pl_entitiesToAllocate;
v_ExecCtrl_entityGroups[pl_eGrpIdx].lgenList[pl_lgenIdxInEGrp].eCountActive := pl_entitiesToAllocate;
// decrease the available entities in the LGen resource database:
f_EPTF_ExecCtrl_decreaseAvailableEntitiesOnLGenForEGrp(vl_lgenIdx,pl_eGrpIdx,pl_entitiesToAllocate)
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_allocateEntityGroup
//
// Purpose:
// allocates entity group for all LGens
//
// Parameters:
// pl_eGrpIdx - *in integer* - id of the entity group
//
// Return Value:
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_allocateEntityGroup(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));
f_EPTF_ExecCtrl_debug(log2str("Processing EGrp: ", v_ExecCtrl_entityGroups[pl_eGrpIdx]));
var integer vl_eAvailTotal := f_EPTF_ExecCtrl_getAvailableEntitiesForEGrp(pl_eGrpIdx);
var integer vl_eRemain := v_ExecCtrl_entityGroups[pl_eGrpIdx].eCount;
f_EPTF_ExecCtrl_debug(log2str("EGrpSize/TotalAvailable entities for eGrp ", v_ExecCtrl_entityGroups[pl_eGrpIdx].name,": ",
vl_eRemain, "/",vl_eAvailTotal));
var integer vl_lgenNum := sizeof(v_ExecCtrl_entityGroups[pl_eGrpIdx].lgenList);
if (vl_lgenNum==0) {
f_EPTF_ExecCtrl_warning(log2str("No LGens available for Entity Group: ",v_ExecCtrl_entityGroups[pl_eGrpIdx].name,
". Maybe no LGen exists with the entityType of the entityGroup: ", v_ExecCtrl_entityGroups[pl_eGrpIdx].eType));
return; // nothing to do
}
if (vl_eAvailTotal<vl_eRemain and vl_eAvailTotal!=-1) {
f_EPTF_ExecCtrl_warning(log2str("Total available entities (",vl_eAvailTotal,
") on all LGens is not enough to distribute entity group (eGrpSize:",vl_eRemain,"): ",v_ExecCtrl_entityGroups[pl_eGrpIdx].name,
". Only the total available entities are allocated for the entity group."));
if (not tsp_ExecCtrl_ignoreOutOfResource) {
f_EPTF_ExecCtrl_error("outOfResources while creating entity groups, stopping...");
//f_EPTF_Base_stopAll(); -- done by error
}
vl_eRemain := vl_eAvailTotal;
}
if (vl_eRemain==0) {
f_EPTF_ExecCtrl_warning(log2str("No entities available for Entity Group: ", v_ExecCtrl_entityGroups[pl_eGrpIdx]));
return; // nothing to do
}
var integer vl_eRemain_prev;
var EPTF_IntegerList vl_entitiesToAllocateRec;
var float vl_lgenWeight_sum := 0.0;
for(var integer i:=0; i<vl_lgenNum; i:=i+1) {
vl_entitiesToAllocateRec[i] := 0;
vl_lgenWeight_sum := vl_lgenWeight_sum + f_EPTF_ExecCtrl_getLGenWeightForEGrp(v_ExecCtrl_entityGroups[pl_eGrpIdx].name,v_ExecCtrl_lgens[v_ExecCtrl_entityGroups[pl_eGrpIdx].lgenList[i].lgenIdx].name);
}
var integer vl_LGenFull := 0;
var integer vl_entityPerLGen := 0;
do {
vl_eRemain_prev := vl_eRemain;
if (vl_lgenWeight_sum==0.0) {
vl_entityPerLGen := vl_eRemain/(vl_lgenNum - vl_LGenFull);
if (vl_entityPerLGen == 0){ vl_entityPerLGen := 1 }
}
vl_LGenFull := 0;
for(var integer i:=0; i<vl_lgenNum; i:=i+1) {
if(vl_eRemain == 0) { break; }
f_EPTF_ExecCtrl_debug(log2str("Average EntityNum/LGen (LGen num: ",vl_lgenNum,") LGenIdx: ",i,": ", vl_entityPerLGen));
// calculate the number of entities to allocate for the eGrp on this LGen
var integer vl_lgenIdx := v_ExecCtrl_entityGroups[pl_eGrpIdx].lgenList[i].lgenIdx;
var float vl_lgenWeight := f_EPTF_ExecCtrl_getLGenWeightForEGrp(v_ExecCtrl_entityGroups[pl_eGrpIdx].name,v_ExecCtrl_lgens[vl_lgenIdx].name);
// if weight is given for the entity group on this LGen, use this weight:
if (vl_lgenWeight_sum!=0.0) {
if (vl_lgenWeight==0.0) {
f_EPTF_ExecCtrl_debug(log2str("LGen with weight: ",vl_lgenWeight,") : No entities allocated"));
continue;
}
// put the vl_lgenWeight percent of the entity group size to the LGen:
vl_entityPerLGen := float2int(vl_lgenWeight*int2float(vl_eRemain_prev));
f_EPTF_ExecCtrl_debug(log2str("EntityNum on LGen with weight: ",vl_lgenWeight,") : ", vl_entityPerLGen));
}
var integer vl_entitiesToAllocate := vl_entityPerLGen + vl_entitiesToAllocateRec[i];
var integer vl_eAvail := f_EPTF_ExecCtrl_getAvailableEntitiesOnLGenForEGrp(vl_lgenIdx,pl_eGrpIdx);
if (vl_entitiesToAllocate>vl_eAvail and vl_eAvail!=-1) {
if(vl_entitiesToAllocateRec[i]!=vl_eAvail and vl_lgenWeight_sum!=0.0){
f_EPTF_ExecCtrl_warning("Not enough available entity on the LGen " & v_ExecCtrl_lgens[vl_lgenIdx].name & " to allocate "&log2str(vl_entitiesToAllocate)&
" number of entities according to the given weight: "& log2str(vl_lgenWeight)& ". All available entities allocated: "&log2str(vl_eAvail));
}
vl_LGenFull := vl_LGenFull + 1;
vl_entitiesToAllocate := vl_eAvail; // use all capacity
}
// on the LGen vl_entitiesToAllocateRec[i] was already allocated
// additional entities allocated in this cycle: vl_entitiesToAllocate - vl_entitiesToAllocateRec[i]
// decrease the number of remaining entities with the additionally allocated entities:
vl_eRemain := vl_eRemain - vl_entitiesToAllocate + vl_entitiesToAllocateRec[i];
vl_entitiesToAllocateRec[i] := vl_entitiesToAllocate;
}
} while (vl_eRemain>0 and vl_eRemain!=vl_eRemain_prev);
if(vl_eRemain > 0){
if (vl_lgenWeight_sum!=0.0) {
f_EPTF_ExecCtrl_warning("Entities cannot be successfully distributed according to the weight ratios. Number of entities remaining : " & log2str(vl_eRemain));
}
f_EPTF_ExecCtrl_debug("Trying to allocate remaining entities using the max available capacity of the LGens");
for(var integer i:=0; i<vl_lgenNum; i:=i+1) {
// calculate the number of entities to allocate for the eGrp on this LGen
f_EPTF_ExecCtrl_debug(log2str("Processing LGen (LGen num: ",vl_lgenNum,") LGenIdx: ",i));
var integer vl_lgenIdx := v_ExecCtrl_entityGroups[pl_eGrpIdx].lgenList[i].lgenIdx;
var float vl_lgenWeight := f_EPTF_ExecCtrl_getLGenWeightForEGrp(v_ExecCtrl_entityGroups[pl_eGrpIdx].name,v_ExecCtrl_lgens[vl_lgenIdx].name);
// if weight is given for the entity group on this LGen, use this weight:
if (vl_lgenWeight==0.0 and vl_lgenWeight_sum!=0.0) {
f_EPTF_ExecCtrl_debug(log2str("LGen with weight: ",vl_lgenWeight,") : No entities allocated"));
continue;
}
// put the vl_lgenWeight percent of the entity group size to the LGen:
f_EPTF_ExecCtrl_debug(log2str("EntityNum on LGen with weight: ",vl_lgenWeight,") : ", vl_eRemain));
var integer vl_entitiesToAllocate := vl_eRemain + vl_entitiesToAllocateRec[i];
var integer vl_eAvail := f_EPTF_ExecCtrl_getAvailableEntitiesOnLGenForEGrp(vl_lgenIdx,pl_eGrpIdx);
if (vl_entitiesToAllocate>vl_eAvail and vl_eAvail!=-1) {
if(vl_entitiesToAllocateRec[i]!=vl_eAvail and vl_lgenWeight_sum!=0.0){
f_EPTF_ExecCtrl_warning("Not enough available entity on the LGen :" & v_ExecCtrl_lgens[vl_lgenIdx].name & ", thus the weight ratios cannot be taken into account.");
}
vl_entitiesToAllocate := vl_eAvail; // use all capacity
}
// on the LGen vl_entitiesToAllocateRec[i] was already allocated
// additional entities allocated in this cycle: vl_entitiesToAllocate - vl_entitiesToAllocateRec[i]
// decrease the number of remaining entities with the additionally allocated entities:
vl_eRemain := vl_eRemain - vl_entitiesToAllocate + vl_entitiesToAllocateRec[i];
vl_entitiesToAllocateRec[i] := vl_entitiesToAllocate;
if (vl_eRemain == 0 ){ break;}
}
}
if(vl_eRemain > 0){
f_EPTF_ExecCtrl_warning("Entities cannot be successfully distributed according to the weight ratios. No more entities left on LGens. Number of entities remaining : " & log2str(vl_eRemain));
}
for(var integer i:=0; i<vl_lgenNum; i:=i+1) {
// allocate the entities for this eGrp on the LGen:
// Even vl_entitiesToAllocate[i]==0 must be registered (the offset need to be updated)
f_EPTF_ExecCtrl_allocateEGrpForLGen(pl_eGrpIdx,i,vl_entitiesToAllocateRec[i]);
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_getAllocatedEntities
//
// Purpose:
// returns the total number of allocated entities on all LGens for the given EntityGroup
//
// Parameters:
// pl_eGrpIdx - *in integer* - id of the entity group
//
// Return Value:
// integer - total number of allocated entities
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_getAllocatedEntities(in integer pl_eGrpIdx)
runs on EPTF_ExecCtrl_CT
return integer
{
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 integer vl_allocated := 0;
for(var integer i:=0; i<sizeof(v_ExecCtrl_entityGroups[pl_eGrpIdx].lgenList); i:=i+1) {
vl_allocated := vl_allocated + v_ExecCtrl_entityGroups[pl_eGrpIdx].lgenList[i].eCount;
}
return vl_allocated;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_eGrpIsAllocated
//
// Purpose:
// returns true if eGrp is allocated, else false
//
// Parameters:
// pl_eGrpIdx - *in integer* - id of the entity group
//
// Return Value:
// boolean - true if entity group is allocated
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_eGrpIsAllocated(in integer pl_eGrpIdx)
runs on EPTF_ExecCtrl_CT
return boolean
{
return (0!=f_EPTF_ExecCtrl_getAllocatedEntities(pl_eGrpIdx));
}
///////////////////////////////
// Traffic Case DB functions
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_addTrafficCaseInstance
//
// Purpose:
// Adds a traffic case to the instance DB
//
// Parameters:
// pl_trafficCase - *in* <EPTF_ExecCtrl_TrafficCase> - the traffic case to add
//
// Return Value:
// integer - the id of the traffic case
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_addTrafficCaseInstance(in EPTF_ExecCtrl_TrafficCase pl_trafficCase)
runs on EPTF_ExecCtrl_CT
return integer
{
var integer vl_idx := sizeof(v_ExecCtrl_trafficCases);
f_EPTF_str2int_HashMap_Insert(v_ExecCtrl_trafficCasesHash, pl_trafficCase.name, vl_idx);
v_ExecCtrl_trafficCases[vl_idx] := pl_trafficCase;
return vl_idx;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_numTrafficCases
//
// Purpose:
// returns the number of traffic cases in the instance DB
//
// Parameters:
//
// Return Value:
// integer - the number of traffic cases
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_numTrafficCases()
runs on EPTF_ExecCtrl_CT
return integer
{
return sizeof(v_ExecCtrl_trafficCases);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_getTrafficCaseIdx
//
// Purpose:
// Returns the traffic case instance idx
//
// Parameters:
// pl_eGrpName - *in charstring* - the entity group name
// pl_scName - *in charstring* - the scenario type name
// pl_tcName - *in charstring* - traffic case type name
//
// Return Value:
// integer - the index of the traffic case instance (-1 if not found)
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_getTrafficCaseIdx(
in charstring pl_eGrpName,
in charstring pl_scName,
in charstring pl_tcName)
runs on EPTF_ExecCtrl_CT
return integer
{
var integer vl_idx := -1;
var charstring vl_tcInstanceName := pl_eGrpName&"."&pl_scName&"."&pl_tcName
if (not f_EPTF_str2int_HashMap_Find(
v_ExecCtrl_trafficCasesHash,
vl_tcInstanceName,
vl_idx
)) {
return -1; // traffic case instance not found
};
return vl_idx;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_getLGenNumForTc
//
// Purpose:
// returns the number of LGens used by the traffic case
//
// Parameters:
// pl_tcIdx - *in integer* - the id of the traffic case in the instance DB
//
// Return Value:
// integer - number of LGens used by the traffic case
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_getLGenNumForTc(in integer pl_tcIdx) runs on EPTF_ExecCtrl_CT return integer {
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 := v_ExecCtrl_trafficCases[pl_tcIdx].scenarioIdx;
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[vl_scIdx].eGroupIdx;
var integer vl_lgenNum := 0;
for (var integer lgenidx:=0;lgenidx<sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList);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
}
vl_lgenNum := vl_lgenNum + 1;
}
return vl_lgenNum;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_getTcOfScenarioData
//
// Purpose:
// returns the traffic case data in the scenario it is in
//
// Parameters:
// pl_tcIdx - *in integer* - the id of the traffic case in the instance DB
//
// Return Value:
// <EPTF_ExecCtrl_TcOfScenario> - traffic case data
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_getTcOfScenarioData(in integer pl_tcIdx)
runs on EPTF_ExecCtrl_CT
return EPTF_ExecCtrl_TcOfScenario
{
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 := v_ExecCtrl_trafficCases[pl_tcIdx].scenarioIdx;
var integer vl_tcOfScIdx := v_ExecCtrl_trafficCases[pl_tcIdx].tcOfScenarioIdx;
return f_EPTF_Exectrl_getTcOfScenario(vl_scIdx,vl_tcOfScIdx);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_getScenarioIdxForTc
//
// Purpose:
// returns the scenario idx of the scenario the traffic case
// instance belongs to
//
// Parameters:
// pl_tcIdx - *in integer* - the id of the traffic case in the instance DB
//
// Return Value:
// integer - idx of the scenario the traffic case belongs to
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_getScenarioIdxForTc(in integer pl_tcIdx)
runs on EPTF_ExecCtrl_CT
return integer
{
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));
return v_ExecCtrl_trafficCases[pl_tcIdx].scenarioIdx;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_getTcOfScenarioIdx
//
// Purpose:
// returns the traffic case idx in the scenario it is in
//
// Parameters:
// pl_tcIdx - *in integer* - the id of the traffic case in the instance DB
//
// Return Value:
// integer - traffic case idx in the scenario instance it belongs to
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_getTcOfScenarioIdx(in integer pl_tcIdx)
runs on EPTF_ExecCtrl_CT
return integer
{
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));
return v_ExecCtrl_trafficCases[pl_tcIdx].tcOfScenarioIdx;
}
// refreshes the group finish condition statuses for all global conditions
// (this is needed after the traffic case is started if the condition threshold is set to 0)
private function f_EPTF_ExecCtrl_refreshGroupFinishConditionsForTc(
in integer pl_tcIdx
) runs on EPTF_ExecCtrl_CT {
// go through all LGens of the traffic case:
var integer vl_scIdx := v_ExecCtrl_trafficCases[pl_tcIdx].scenarioIdx;
var integer vl_eGrpIdx := v_ExecCtrl_scenarios[vl_scIdx].eGroupIdx;
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 charstring vl_varNameBase := f_EPTF_LGenBaseStats_getNamePrefix(v_ExecCtrl_entityGroups[vl_eGrpIdx].name,v_ExecCtrl_scenarios[vl_scIdx].scData.name,vl_tcName);
var integer vl_idx;
vl_idx := f_EPTF_Var_getId("ExecCtrl.GroupFinishGlobalCondition."&vl_varNameBase&c_EPTF_ExecCtrl_nameOfVarsInLGen[c_EPTF_ExecCtrl_groupFinishNofExecStartIdx]);
if (vl_idx!=-1) {
f_EPTF_Var_refreshContent(vl_idx);
}
vl_idx := f_EPTF_Var_getId("ExecCtrl.GroupFinishGlobalCondition."&vl_varNameBase&c_EPTF_ExecCtrl_nameOfVarsInLGen[c_EPTF_ExecCtrl_groupFinishNofSuccessIdx]);
if (vl_idx!=-1) {
f_EPTF_Var_refreshContent(vl_idx);
}
vl_idx := f_EPTF_Var_getId("ExecCtrl.GroupFinishGlobalCondition."&vl_varNameBase&c_EPTF_ExecCtrl_nameOfVarsInLGen[c_EPTF_ExecCtrl_groupFinishNofFailIdx]);
if (vl_idx!=-1) {
f_EPTF_Var_refreshContent(vl_idx);
}
vl_idx := f_EPTF_Var_getId("ExecCtrl.GroupFinishGlobalCondition."&vl_varNameBase&c_EPTF_ExecCtrl_nameOfVarsInLGen[c_EPTF_ExecCtrl_groupFinishNofTimeoutIdx]);
if (vl_idx!=-1) {
f_EPTF_Var_refreshContent(vl_idx);
}
vl_idx := f_EPTF_Var_getId("ExecCtrl.GroupFinishGlobalCondition."&vl_varNameBase&c_EPTF_ExecCtrl_nameOfVarsInLGen[c_EPTF_ExecCtrl_groupFinishNofErrorIdx]);
if (vl_idx!=-1) {
f_EPTF_Var_refreshContent(vl_idx);
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_resetGroupFinishDataForTc
//
// Purpose:
// resets GroupFinishData for the traffic case
//
// Parameters:
// pl_tcIdx - *in integer* - the id of the traffic case in the instance DB
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_resetGroupFinishDataForTc(in integer pl_tcIdx) runs on EPTF_ExecCtrl_CT {
v_ExecCtrl_trafficCases[pl_tcIdx].groupFinishData.onLaunchFinishCounter := 0;
v_ExecCtrl_trafficCases[pl_tcIdx].groupFinishData.onGroupFinish.tcStartTime := f_EPTF_Base_getAbsTimeInSecs();
v_ExecCtrl_trafficCases[pl_tcIdx].groupFinishData.onGroupFinish.groupFinished := c_EPTF_ExecCtrl_OnGroupFinishData_initialValue.groupFinished;
v_ExecCtrl_trafficCases[pl_tcIdx].groupFinishData.onGroupFinish.groupFinishedPerLGen := c_EPTF_ExecCtrl_OnGroupFinishData_initialValue.groupFinishedPerLGen;
v_ExecCtrl_trafficCases[pl_tcIdx].groupFinishData.onGroupFinish.groupFinishedGuardTimerId := c_EPTF_ExecCtrl_OnGroupFinishData_initialValue.groupFinishedGuardTimerId;
v_ExecCtrl_trafficCases[pl_tcIdx].groupFinishData.onGroupFinish.conditionStatus := c_EPTF_ExecCtrl_OnGroupFinishData_initialValue.conditionStatus;
v_ExecCtrl_trafficCases[pl_tcIdx].groupFinishData.onGroupFinish.conditionStatusPrev := c_EPTF_ExecCtrl_OnGroupFinishData_initialValue.conditionStatusPrev;
// groupFinishConditionIdxList is not changed!
// check if there are conditions that already fired at start (eg. threshold is set to zero):
f_EPTF_ExecCtrl_refreshGroupFinishConditionsForTc(pl_tcIdx);
// call OnGroupFinishCallbackFns to notify them about reset
f_EPTF_ExecCtrl_callOnGroupFinishCallbackFns(pl_tcIdx);
// {Delta statistics}: Reset all stat deltas
f_EPTF_ExecCtrl_resetDeltaStatVarForTc(pl_tcIdx);
}
// Reset delta Varibles for Tc
private function f_EPTF_ExecCtrl_resetDeltaStatVarForTc(in integer pl_tcIdx) runs on EPTF_ExecCtrl_CT {
// Reset all stat deltas
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));
for(var integer st:=0; st<sizeof(v_ExecCtrl_trafficCases[pl_tcIdx].deltaStatList); st:=st+1){
f_EPTF_StatMeasure_resetStat(v_ExecCtrl_trafficCases[pl_tcIdx].deltaStatList[st].statisticsId);
f_EPTF_StatMeasure_addData_delta(v_ExecCtrl_trafficCases[pl_tcIdx].deltaStatList[st].statisticsId,{intVal := 0});
}
return;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_registerOnGroupFinishCallbackFn
//
// Purpose:
// registers a callback function that are called when OnGroupFinishCondition state changes
//
// Parameters:
// pl_onGroupFinishCallbackFn - *in* <EPTF_ExecCtrl_OnGroupFinishCallback_FT> - the onGroupFinish callback Function to register
//
// Detailed Comments:
// Functions registered by this function are called automatically when the
// group finish state of the traffic case changes.
// The group finish state change event is when any of the onGroupFinish conditions
// becomes true (fired), or when all becomes false (none fired) in the traffic case.
// If the group finish condition type can be determined when the condition fired,
// the type of the condition that fired is passed to the callback function, otherwise c_EPTF_ExecCtrl_groupFinishConditionUnknown is passed.
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_registerOnGroupFinishCallbackFn(in EPTF_ExecCtrl_OnGroupFinishCallback_FT pl_onGroupFinishCallbackFn) runs on EPTF_ExecCtrl_CT {
v_EPTF_ExecCtrl_onGroupFinishCallbackFns[sizeof(v_EPTF_ExecCtrl_onGroupFinishCallbackFns)] := pl_onGroupFinishCallbackFn;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_deregisterOnGroupFinishCallbackFn
//
// Purpose:
// deregisters a callback function for OnGroupFinishCondition
//
// Parameters:
// pl_onGroupFinishCallbackFn - *in* <EPTF_ExecCtrl_OnGroupFinishCallback_FT> - the onGroupFinish callback Function to deregister
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_deregisterOnGroupFinishCallbackFn(in EPTF_ExecCtrl_OnGroupFinishCallback_FT pl_onGroupFinishCallbackFn) runs on EPTF_ExecCtrl_CT {
for(var integer i:=0; i<sizeof(v_EPTF_ExecCtrl_onGroupFinishCallbackFns); i:=i+1) {
if(v_EPTF_ExecCtrl_onGroupFinishCallbackFns[i]==pl_onGroupFinishCallbackFn) {
v_EPTF_ExecCtrl_onGroupFinishCallbackFns[i] := null;
}
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_callOnGroupFinishCallbackFns
//
// Purpose:
// calls all callback function for OnGroupFinishCondition
//
// Parameters:
// pl_tcIdx - *in integer* - the id of the traffic case in the instance DB
// pl_conditionType - *in* <EPTF_ExecCtrl_GrpFinishConditionType> - the condition type that fired
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_callOnGroupFinishCallbackFns(
in integer pl_tcIdx,
in EPTF_ExecCtrl_GrpFinishConditionType pl_conditionType := c_EPTF_ExecCtrl_groupFinishConditionUnknown
) runs on EPTF_ExecCtrl_CT {
for(var integer i:=0; i<sizeof(v_EPTF_ExecCtrl_onGroupFinishCallbackFns); i:=i+1) {
if(v_EPTF_ExecCtrl_onGroupFinishCallbackFns[i]!=null) {
v_EPTF_ExecCtrl_onGroupFinishCallbackFns[i].apply(pl_tcIdx,pl_conditionType);
}
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_checkOnGroupFinished
//
// Purpose:
// Checks if a given or any OnGroupFinishCondition is fired for the given traffic case
//
// Parameters:
// pl_tcIdx - *in integer* - the id of the traffic case in the instance DB
// pl_grpFinishConditionType - *in* <EPTF_ExecCtrl_GrpFinishConditionType> - the condition to check
// if it is not specified (or c_EPTF_ExecCtrl_groupFinishConditionUnknown) any condition is checked
//
// Return Value:
// boolean - true if the given or any onGroupFinish condition fired false if not or none fired
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_checkOnGroupFinished(
in integer pl_tcIdx,
in EPTF_ExecCtrl_GrpFinishConditionType pl_grpFinishConditionType := c_EPTF_ExecCtrl_groupFinishConditionUnknown
) runs on EPTF_ExecCtrl_CT return boolean {
// check if onGroupFinish conditions fired for the given condition:
if (pl_grpFinishConditionType != c_EPTF_ExecCtrl_groupFinishConditionUnknown) {
return v_ExecCtrl_trafficCases[pl_tcIdx].groupFinishData.onGroupFinish.groupFinished[pl_grpFinishConditionType];
}
// check if any onGroupFinish conditions fired:
for (var integer i:=0; i<sizeof(v_ExecCtrl_trafficCases[pl_tcIdx].groupFinishData.onGroupFinish.groupFinished); i:=i+1) {
if (v_ExecCtrl_trafficCases[pl_tcIdx].groupFinishData.onGroupFinish.groupFinished[i]) {
return true;
}
}
return false;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_setOnGroupFinished
//
// Purpose:
// Sets the OnGroupFinishCondition to fired for the given traffic case
//
// Parameters:
// pl_tcIdx - *in integer* - the id of the traffic case in the instance DB
// pl_grpFinishConditionType - *in* <EPTF_ExecCtrl_GrpFinishConditionType> - the condition to set
// if it is c_EPTF_ExecCtrl_groupFinishConditionUnknown no condition is set
//
// Return Value:
// -
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_setOnGroupFinished(
in integer pl_tcIdx,
in EPTF_ExecCtrl_GrpFinishConditionType pl_grpFinishConditionType
) runs on EPTF_ExecCtrl_CT {
// set the onGroupFinish condition to fired for the given condition:
if (pl_grpFinishConditionType != c_EPTF_ExecCtrl_groupFinishConditionUnknown) {
v_ExecCtrl_trafficCases[pl_tcIdx].groupFinishData.onGroupFinish.groupFinished[pl_grpFinishConditionType] := true;
// This flag together with the counter is reset when scenario of the TC (or the TC) starts
}
}
// converts EPTF_ExecCtrl_GrpFinishConditionType to EPTF_LGenBase_ConditionTrue
friend function f_EPTF_ExecCtrl_grpFinishConditionType2Condition(
in EPTF_ExecCtrl_GrpFinishConditionType pl_grpFinishConditionType
) return EPTF_LGenBase_ConditionTrue {
var EPTF_LGenBase_ConditionTrue vl_condition := c_EPTF_LGenBase_emptyConditionTrue;
if(pl_grpFinishConditionType==c_EPTF_ExecCtrl_groupFinishNofExecStartIdx) {
vl_condition.nrOfExecStart := true;
vl_condition.anythingFinished := true;
}
if(pl_grpFinishConditionType==c_EPTF_ExecCtrl_groupFinishNofSuccessIdx) {
vl_condition.nrOfSuccesses := true;
vl_condition.anythingFinished := true;
}
if(pl_grpFinishConditionType==c_EPTF_ExecCtrl_groupFinishNofFailIdx) {
vl_condition.nrOfFails := true;
vl_condition.anythingFinished := true;
}
if(pl_grpFinishConditionType==c_EPTF_ExecCtrl_groupFinishNofErrorIdx) {
vl_condition.nrOfErrors := true;
vl_condition.anythingFinished := true;
}
if(pl_grpFinishConditionType==c_EPTF_ExecCtrl_groupFinishNofTimeoutIdx) {
vl_condition.nrOfTimeouts := true;
vl_condition.anythingFinished := true;
}
if(pl_grpFinishConditionType==c_EPTF_ExecCtrl_groupFinish_RangeLoops) {
vl_condition.nrOfRangeLoop := true;
vl_condition.anythingFinished := true;
}
if(pl_grpFinishConditionType==c_EPTF_ExecCtrl_groupFinish_ExecTime) {
vl_condition.execTime := true;
vl_condition.anythingFinished := true;
}
if(pl_grpFinishConditionType==c_EPTF_ExecCtrl_groupFinish_EntitiesFinished) {
vl_condition.entitiesFinished := true;
vl_condition.anythingFinished := true;
}
if(pl_grpFinishConditionType==c_EPTF_ExecCtrl_groupFinish_AvailableEntitiesFinished) {
vl_condition.availableEntitiesFinished := true;
vl_condition.anythingFinished := true;
}
if(pl_grpFinishConditionType==c_EPTF_ExecCtrl_groupFinish_Custom) {
vl_condition.customFinishCondition := true;
vl_condition.anythingFinished := true;
}
if(pl_grpFinishConditionType==c_EPTF_ExecCtrl_groupFinishConditionUnknown) {
vl_condition.anythingFinished := true;
}
return vl_condition;
}
// converts EPTF_LGenBase_ConditionTrue to EPTF_ExecCtrl_GrpFinishConditionTypes
friend function f_EPTF_ExecCtrl_condition2GrpFinishConditionType(
in EPTF_LGenBase_ConditionTrue pl_condition
) return EPTF_ExecCtrl_GrpFinishConditionTypes {
var EPTF_ExecCtrl_GrpFinishConditionTypes vl_EPTF_ExecCtrl_GrpFinishConditionTypes := {};
if(pl_condition.nrOfExecStart) {
vl_EPTF_ExecCtrl_GrpFinishConditionTypes[sizeof(vl_EPTF_ExecCtrl_GrpFinishConditionTypes)] := c_EPTF_ExecCtrl_groupFinishNofExecStartIdx;
}
if(pl_condition.nrOfSuccesses) {
vl_EPTF_ExecCtrl_GrpFinishConditionTypes[sizeof(vl_EPTF_ExecCtrl_GrpFinishConditionTypes)] := c_EPTF_ExecCtrl_groupFinishNofSuccessIdx;
}
if(pl_condition.nrOfFails) {
vl_EPTF_ExecCtrl_GrpFinishConditionTypes[sizeof(vl_EPTF_ExecCtrl_GrpFinishConditionTypes)] := c_EPTF_ExecCtrl_groupFinishNofFailIdx;
}
if(pl_condition.nrOfErrors) {
vl_EPTF_ExecCtrl_GrpFinishConditionTypes[sizeof(vl_EPTF_ExecCtrl_GrpFinishConditionTypes)] := c_EPTF_ExecCtrl_groupFinishNofErrorIdx;
}
if(pl_condition.nrOfTimeouts) {
vl_EPTF_ExecCtrl_GrpFinishConditionTypes[sizeof(vl_EPTF_ExecCtrl_GrpFinishConditionTypes)] := c_EPTF_ExecCtrl_groupFinishNofTimeoutIdx;
}
if(pl_condition.nrOfRangeLoop) {
vl_EPTF_ExecCtrl_GrpFinishConditionTypes[sizeof(vl_EPTF_ExecCtrl_GrpFinishConditionTypes)] := c_EPTF_ExecCtrl_groupFinish_RangeLoops;
}
if(pl_condition.execTime) {
vl_EPTF_ExecCtrl_GrpFinishConditionTypes[sizeof(vl_EPTF_ExecCtrl_GrpFinishConditionTypes)] := c_EPTF_ExecCtrl_groupFinish_ExecTime;
}
if(pl_condition.entitiesFinished) {
vl_EPTF_ExecCtrl_GrpFinishConditionTypes[sizeof(vl_EPTF_ExecCtrl_GrpFinishConditionTypes)] := c_EPTF_ExecCtrl_groupFinish_EntitiesFinished;
}
if(pl_condition.availableEntitiesFinished) {
vl_EPTF_ExecCtrl_GrpFinishConditionTypes[sizeof(vl_EPTF_ExecCtrl_GrpFinishConditionTypes)] := c_EPTF_ExecCtrl_groupFinish_AvailableEntitiesFinished;
}
if(pl_condition.customFinishCondition) {
vl_EPTF_ExecCtrl_GrpFinishConditionTypes[sizeof(vl_EPTF_ExecCtrl_GrpFinishConditionTypes)] := c_EPTF_ExecCtrl_groupFinish_Custom;
}
// ignore anythingFinished:
//if(pl_condition.anythingFinished) {
// vl_EPTF_ExecCtrl_GrpFinishConditionTypes[sizeof(vl_EPTF_ExecCtrl_GrpFinishConditionTypes)] := c_EPTF_ExecCtrl_groupFinishConditionUnknown;
//}
return vl_EPTF_ExecCtrl_GrpFinishConditionTypes;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_registerCPSChangedCallback_TC
//
// Purpose:
// Registers a CPS changed callback for the given traffic case instance
//
// Parameters:
// pl_tcIdx - *in integer* - the id of the traffic case in the instance DB
// pl_cpsChangedCallback - *in* <EPTF_ExecCtrl_TrafficCaseCPSChangedCallbackFn_FT> - the traffic case CPS changed callback
//
// Return Value:
// -
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_registerCPSChangedCallback_TC(in integer pl_tcIdx, in EPTF_ExecCtrl_TrafficCaseCPSChangedCallbackFn_FT pl_cpsChangedCallback) 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&": CPS change callback cannot be set to weighted scenario: "
&f_EPTF_ExecCtrl_getScenarioInstanceName(vl_scIdx),
not f_EPTF_ExecCtrl_isWeightedScenario(vl_scIdx));
v_ExecCtrl_trafficCases[pl_tcIdx].cpsChangedCallbackList[sizeof(v_ExecCtrl_trafficCases[pl_tcIdx].cpsChangedCallbackList)] := pl_cpsChangedCallback;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_deregisterCPSChangedCallback_TC
//
// Purpose:
// DeRegisters a CPS changed callback for the given traffic case instance
//
// Parameters:
// pl_tcIdx - *in integer* - the id of the traffic case in the instance DB
// pl_cpsChangedCallback - *in* <EPTF_ExecCtrl_TrafficCaseCPSChangedCallbackFn_FT> - the traffic case CPS changed callback
//
// Return Value:
// -
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_deregisterCPSChangedCallback_TC(in integer pl_tcIdx, in EPTF_ExecCtrl_TrafficCaseCPSChangedCallbackFn_FT pl_cpsChangedCallback) 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));
for(var integer i:=0; i<sizeof(v_ExecCtrl_trafficCases[pl_tcIdx].cpsChangedCallbackList); i:=i+1) {
if(v_ExecCtrl_trafficCases[pl_tcIdx].cpsChangedCallbackList[i]==pl_cpsChangedCallback) {
v_ExecCtrl_trafficCases[pl_tcIdx].cpsChangedCallbackList[i] := null;
}
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_callCPSChangedCallbacks_TC
//
// Purpose:
// Calls the CPS changed callbacks for the given traffic case instance
//
// Parameters:
// pl_tcIdx - *in integer* - the id of the traffic case in the instance DB
// pl_cps - *in float* - the new CPS value
//
// Return Value:
// -
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_callCPSChangedCallbacks_TC(in float pl_cps, in integer pl_tcIdx) 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));
for (var integer i:=0; i<sizeof(v_ExecCtrl_trafficCases[pl_tcIdx].cpsChangedCallbackList); i:=i+1) {
if (v_ExecCtrl_trafficCases[pl_tcIdx].cpsChangedCallbackList[i]!=null) {
v_ExecCtrl_trafficCases[pl_tcIdx].cpsChangedCallbackList[i].apply(pl_cps,pl_tcIdx);
}
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_registerCPSChangedCallback_SC
//
// Purpose:
// Registers a CPS changed callback for the given scenario instance
//
// Parameters:
// pl_scIdx - *in integer* - the id of the scenario in the instance DB
// pl_cpsChangedCallback - *in* <EPTF_ExecCtrl_ScenarioCPSChangedCallbackFn_FT> - the scenario CPS changed callback
//
// Return Value:
// -
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_registerCPSChangedCallback_SC(in integer pl_scIdx, in EPTF_ExecCtrl_ScenarioCPSChangedCallbackFn_FT pl_cpsChangedCallback) runs on EPTF_ExecCtrl_CT {
f_EPTF_Base_assert(%definitionId&": Invalid index "&int2str(pl_scIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_trafficCases))&").",
pl_scIdx >= 0 and pl_scIdx < sizeof(v_ExecCtrl_trafficCases));
f_EPTF_Base_assert(%definitionId&": CPS change callback cannot be set to non-weighted scenario: "
&f_EPTF_ExecCtrl_getScenarioInstanceName(pl_scIdx),
f_EPTF_ExecCtrl_isWeightedScenario(pl_scIdx));
v_ExecCtrl_scenarios[pl_scIdx].cpsChangedCallbackList[sizeof(v_ExecCtrl_scenarios[pl_scIdx].cpsChangedCallbackList)] := pl_cpsChangedCallback;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_deregisterCPSChangedCallback_SC
//
// Purpose:
// DeRegisters a CPS changed callback for the given scenario instance
//
// Parameters:
// pl_scIdx - *in integer* - the id of the scenario in the instance DB
// pl_cpsChangedCallback - *in* <EPTF_ExecCtrl_ScenarioCPSChangedCallbackFn_FT> - the scenario CPS changed callback
//
// Return Value:
// -
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_deregisterCPSChangedCallback_SC(in integer pl_scIdx, in EPTF_ExecCtrl_ScenarioCPSChangedCallbackFn_FT pl_cpsChangedCallback) runs on EPTF_ExecCtrl_CT {
f_EPTF_Base_assert(%definitionId&": Invalid index "&int2str(pl_scIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_scenarios))&").",
pl_scIdx >= 0 and pl_scIdx < sizeof(v_ExecCtrl_scenarios));
for(var integer i:=0; i<sizeof(v_ExecCtrl_scenarios[pl_scIdx].cpsChangedCallbackList); i:=i+1) {
if(v_ExecCtrl_scenarios[pl_scIdx].cpsChangedCallbackList[i]==pl_cpsChangedCallback) {
v_ExecCtrl_scenarios[pl_scIdx].cpsChangedCallbackList[i] := null;
}
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_callCPSChangedCallbacks_SC
//
// Purpose:
// Calls the CPS changed callbacks for the given scenario instance
//
// Parameters:
// pl_scIdx - *in integer* - the id of the scenario in the instance DB
// pl_cps - *in float* - the new CPS value
//
// Return Value:
// -
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_callCPSChangedCallbacks_SC(in float pl_cps, in integer pl_scIdx) runs on EPTF_ExecCtrl_CT {
f_EPTF_Base_assert(%definitionId&": Invalid index "&int2str(pl_scIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_scenarios))&").",
pl_scIdx >= 0 and pl_scIdx < sizeof(v_ExecCtrl_scenarios));
for (var integer i:=0; i<sizeof(v_ExecCtrl_scenarios[pl_scIdx].cpsChangedCallbackList); i:=i+1) {
if (v_ExecCtrl_scenarios[pl_scIdx].cpsChangedCallbackList[i]!=null) {
v_ExecCtrl_scenarios[pl_scIdx].cpsChangedCallbackList[i].apply(pl_cps,pl_scIdx);
}
}
}
///////////////////////////////
// Scenario DB functions
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_addScenario2EntityGroup
//
// Purpose:
// Adds a scenario to an entity group
//
// Parameters:
// pl_eGrpName - *in charstring* - the name of the entity group
// pl_scTypeName - *in charstring* - the name of the scenario type
// pl_scInstanceName - *in charstring optional* - the name of the scenario instance
// Besides the specified instance name, the following name is also generated
// and can be used to find the scenario instance: pl_eGrpName + "." + pl_scTypeName
//
// Return Value:
// -
//
// Errors:
// if a traffic case in the scenario and the entity group uses different entity types
//
// Detailed Comments:
// This function creates the scenario instance.
// also stores the traffic case instances. The name of the traffic case instance is automatically generated.
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_addScenario2EntityGroup(in charstring pl_eGrpName, in charstring pl_scTypeName, in charstring pl_scInstanceName := "")
runs on EPTF_ExecCtrl_CT
//return integer
{
var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioTypeIdx(pl_scTypeName);
if (vl_scIdx==-1) {
f_EPTF_ExecCtrl_error(%definitionId&": Cannot find scenario type "&pl_scTypeName&" in database.");
}
var integer vl_eGrpIdx := f_EPTF_ExecCtrl_getEntityGroupIdx(pl_eGrpName);
if (vl_eGrpIdx==-1) {
f_EPTF_ExecCtrl_error(%definitionId&": Cannot find entity group "&pl_eGrpName&" in database.");
}
var charstring vl_scGeneratedName := v_ExecCtrl_entityGroups[vl_eGrpIdx].name&"."&v_ExecCtrl_scenarioTypes[vl_scIdx].name;
var charstring vl_scInstanceName := pl_scInstanceName;
if (vl_scInstanceName == "") {
// auto-generated names are used:
// scenarios are stored under the name: eGrpName + "." + scenarioTypeName
vl_scInstanceName := vl_scGeneratedName;
}
// check configuration errors:
if (not f_EPTF_ExecCtrl_scenarioAndEntityGroupCompatible(pl_eGrpName,pl_scTypeName)) {
f_EPTF_ExecCtrl_error(log2str(%definitionId&": Cannot add scenario ",pl_scTypeName," to entity group ",pl_eGrpName,
": The entity types are incompatible"));
f_EPTF_Base_stopAll();
}
var integer vl_temp_idx := 0;
var integer vl_idx := sizeof(v_ExecCtrl_scenarios);
if ( f_EPTF_str2int_HashMap_Find(v_ExecCtrl_scenariosHash, vl_scGeneratedName, vl_temp_idx ) == true) {
f_EPTF_ExecCtrl_error(log2str(%definitionId&": Cannot add scenario ",pl_scTypeName," to entity group ",pl_eGrpName,
": The scenario is already added"));
f_EPTF_Base_stopAll();
} else {
f_EPTF_str2int_HashMap_Insert(v_ExecCtrl_scenariosHash, vl_scGeneratedName, vl_idx); // put generated name in hashmap
if (vl_scGeneratedName != vl_scInstanceName) {
f_EPTF_str2int_HashMap_Insert(v_ExecCtrl_scenariosHash, vl_scInstanceName, vl_idx); // put instance name in hashmap too
}
}
v_ExecCtrl_scenarios[vl_idx] := c_EPTF_ExecCtrl_Scenario_initialValue;
v_ExecCtrl_scenarios[vl_idx].name := vl_scInstanceName;
v_ExecCtrl_scenarios[vl_idx].eGroupIdx := vl_eGrpIdx;
v_ExecCtrl_scenarios[vl_idx].scData := v_ExecCtrl_scenarioTypes[vl_scIdx];
// register scenario into entity group:
var integer vl_scOfEGrpIdx := sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].scenarios);
v_ExecCtrl_entityGroups[vl_eGrpIdx].scenarios[vl_scOfEGrpIdx] := vl_idx;
// store the trafficCases also:
for(var integer i:=0; i<sizeof(v_ExecCtrl_scenarioTypes[vl_scIdx].tcList);i:=i+1) {
var EPTF_ExecCtrl_TrafficCase vl_tc := c_EPTF_ExecCtrl_TrafficCase_initialValue;
// use autogenerated name for the traffic case instance (scInstanceName + "." + tcOfScName):
var charstring vl_tcName := f_EPTF_LGenBase_tcNameOfTcOfSc(v_ExecCtrl_scenarioTypes[vl_scIdx], i)
vl_tc.name := vl_scGeneratedName&"."&vl_tcName; // use generated name
vl_tc.scenarioIdx := vl_idx;
vl_tc.tcOfScenarioIdx := i;
// check configuration errors:
if (-1!=f_EPTF_ExecCtrl_getTrafficCaseIdx(pl_eGrpName,pl_scTypeName,vl_tcName)) {
f_EPTF_ExecCtrl_error(log2str(%definitionId&": Cannot add traffic case ",vl_tcName," to scenario ",pl_scTypeName,
": The traffic case is already added"));
f_EPTF_Base_stopAll();
}
// Update traffic start finish conditions for the oldest declarator:
if ( v_ExecCtrl_scenarios[vl_idx].scData.conditionsFromTC ){
var charstring vl_tcTypeName := f_EPTF_LGenBase_tcTypeNameOfTcOfSc(v_ExecCtrl_scenarioTypes[vl_scIdx],i)
var integer vl_tcTypeIdx := f_EPTF_ExecCtrl_getTcTypeIdx(vl_tcTypeName)
v_ExecCtrl_scenarios[vl_idx].scData.tcList[i].trafficStartFinishConditionsAndActions := v_ExecCtrl_tcTypes[vl_tcTypeIdx].trafficStartFinishConditionsAndFunctions;
}
//Add tc
var integer vl_tcIdx := f_EPTF_ExecCtrl_addTrafficCaseInstance(vl_tc);
// add reference to the traffic case in the scenario instance:
var integer vl_tcNum := sizeof(v_ExecCtrl_scenarios[vl_idx].tcIdxList);
v_ExecCtrl_scenarios[vl_idx].tcIdxList[vl_tcNum] := vl_tcIdx;
}
v_ExecCtrl_scenarios[vl_idx].scData.conditionsFromTC := false; // prevent LGenBase from overwriting trafficStartFinishConditionsAndActions data by data from traffic case
//return vl_idx;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_scenarioAndEntityGroupCompatible
//
// Purpose:
// Checks if the entity type of the entity group and the entity types of the traffic case
// in the scneario type are the same.
//
// Parameters:
// pl_eGrpName - *in charstring* - the name of the entity group
// pl_scTypeName - *in charstring* - the name of the scenario type
//
// Return Value:
// boolean - true if compatible, false otherwise
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_scenarioAndEntityGroupCompatible(in charstring pl_eGrpName, in charstring pl_scTypeName)
runs on EPTF_ExecCtrl_CT
return boolean {
var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioTypeIdx(pl_scTypeName);
f_EPTF_Base_assert(%definitionId&": Cannot find scenario type "&pl_scTypeName&" in database.",vl_scIdx!=-1);
var integer vl_eGrpIdx := f_EPTF_ExecCtrl_getEntityGroupIdx(pl_eGrpName);
var charstring vl_eGrpType := v_ExecCtrl_entityGroups[vl_eGrpIdx].eType;
for(var integer i:=0; i<sizeof(v_ExecCtrl_scenarioTypes[vl_scIdx].tcList);i:=i+1) {
var integer vl_tcTypeIdx := f_EPTF_ExecCtrl_getTcTypeIdx(f_EPTF_LGenBase_tcTypeNameOfTcOfSc(v_ExecCtrl_scenarioTypes[vl_scIdx],i))
if (vl_tcTypeIdx==-1) {
continue;
}
var charstring vl_tcEType := v_ExecCtrl_tcTypes[vl_tcTypeIdx].entityType;
if (vl_tcEType != vl_eGrpType) {
return false;
}
}
return true;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_numScenarios
//
// Purpose:
// returns the number of scenarios in the instance DB
//
// Parameters:
//
// Return Value:
// integer - number of scenarios
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_numScenarios()
runs on EPTF_ExecCtrl_CT
return integer
{
return sizeof(v_ExecCtrl_scenarios);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_scenarios
//
// Purpose:
// returns the scenarios in the instance DB
//
// Parameters:
//
// Return Value:
// EPTF_ExecCtrl_ScenarioList - scenarios
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_scenarios()
runs on EPTF_ExecCtrl_CT
return EPTF_ExecCtrl_ScenarioList
{
return v_ExecCtrl_scenarios;
}
friend function f_EPTF_ExecCtrl_createRefVarForWScCPSToReach(
in charstring pl_name,
in integer pl_scIdx,
out integer pl_idx
) runs on EPTF_ExecCtrl_CT {
f_EPTF_Var_newFloatRef(
pl_name, v_ExecCtrl_scenarios[pl_scIdx].scData.weightedScData.cpsToReach, pl_idx);
}
friend function f_EPTF_ExecCtrl_createRefVarForTcCPSToReach(
in integer pl_scIdx,
in integer pl_tcOfScIdx,
in charstring pl_varName,
out integer pl_idx
) runs on EPTF_ExecCtrl_CT {
if (f_EPTF_ExecCtrl_isWeightedScenario(pl_scIdx)) {
f_EPTF_Var_newFloatRef(
pl_varName,
v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].target.trafficWeight,
pl_idx);
} else {
f_EPTF_Var_newFloatRef(
pl_varName,
v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].target.cpsToReach,
pl_idx);
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_getScenarioIdx
//
// Purpose:
// returns the id of a scenario in the instance DB
//
// Parameters:
// pl_eGrpName - *in charstring* - name of the entity group
// pl_scName - *in charstring* - name of the scenario type
//
// Return Value:
// integer - id of the scenario instance
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_getScenarioIdx(
in charstring pl_eGrpName,
in charstring pl_scName)
runs on EPTF_ExecCtrl_CT
return integer
{
var integer vl_idx := -1;
var charstring vl_scInstanceName := pl_eGrpName&"."&pl_scName;
var boolean vl_found := f_EPTF_str2int_HashMap_Find(
v_ExecCtrl_scenariosHash,
vl_scInstanceName,
vl_idx);
return vl_idx;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_getScenarioIdxByInstanceName
//
// Purpose:
// returns the id of a scenario in the instance DB
//
// Parameters:
// pl_scInstanceName - *in charstring* - name of the scenario instance
// It can be the instance name, or "eGrpName.scName"
//
// Return Value:
// integer - id of the scenario instance, -1 if not found
//
// Errors:
//
// Detailed Comments:
// This function can be used to find scenarios that have a user defined instance name.
// if the instance name was not given use the <f_EPTF_ExecCtrl_getScenarioIdx> function instead,
// or use eGrpName.scName for instance name.
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_getScenarioIdxByInstanceName(
in charstring pl_scInstanceName)
runs on EPTF_ExecCtrl_CT
return integer
{
var integer vl_idx := -1;
var boolean vl_found := f_EPTF_str2int_HashMap_Find(
v_ExecCtrl_scenariosHash,
pl_scInstanceName,
vl_idx);
return vl_idx;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_getScenarioIdxForScOfEGrp
//
// Purpose:
// returns the scenario index in v_ExecCtrl_scenarios for the scenario of the given eGrp with given scTypeName
// returns -1 if not found
//
// Parameters:
// pl_eGrpName - *in charstring* - name of the entity group
// pl_scTypeName - *in charstring* - name of the scenario type
//
// Return Value:
// integer - id of the scenario
//
// Errors:
//
// Detailed Comments:
// // FIXME: Same as f_EPTF_ExecCtrl_getScenarioIdx?
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_getScenarioIdxForScOfEGrp(in charstring pl_eGrpName, in charstring pl_scTypeName)
runs on EPTF_ExecCtrl_CT
return integer
{
// the scenarios are stored in hashmap with scenarioInstanceName. But now we know only the
// eGrpName and the scTypeName
// find the gGrp:
var integer vl_eGrpIdx := f_EPTF_ExecCtrl_getEntityGroupIdx(pl_eGrpName);
if (vl_eGrpIdx==-1) {
f_EPTF_ExecCtrl_debug(log2str(%definitionId&": Cannot find entity group "&pl_eGrpName&" in database."));
return -1;
}
// find the scenario in the eGrp:
for(var integer s:=0; s<sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].scenarios); s:=s+1) {
var integer vl_scIdx := v_ExecCtrl_entityGroups[vl_eGrpIdx].scenarios[s];
if (v_ExecCtrl_scenarios[vl_scIdx].scData.name == pl_scTypeName) {
return vl_scIdx;
}
}
f_EPTF_ExecCtrl_debug(log2str(%definitionId&": Cannot find scenario type "&pl_scTypeName&" in database."));
return -1;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_getScenarioName
//
// Purpose:
// returns the scenario type name for a scenario instance
//
// Parameters:
// pl_scIdx - *in integer* - id of the scenario instance
//
// Return Value:
// charstring - name of the scenario
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_getScenarioName(in integer pl_scIdx)
runs on EPTF_ExecCtrl_CT
return charstring
{
f_EPTF_Base_assert(%definitionId&": Invalid index "&int2str(pl_scIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_scenarios))&").",
pl_scIdx >= 0 and pl_scIdx < sizeof(v_ExecCtrl_scenarios));
return v_ExecCtrl_scenarios[pl_scIdx].scData.name;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_isWeightedScenario
//
// Purpose:
// returns true if the scenario instance is weighted
//
// Parameters:
// pl_scIdx - *in integer* - id of the scenario instance
//
// Return Value:
// boolean - true if the scenario is weighted, false otherwise
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_isWeightedScenario(in integer pl_scIdx)
runs on EPTF_ExecCtrl_CT
return boolean
{
f_EPTF_Base_assert(%definitionId&": Invalid index "&int2str(pl_scIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_scenarios))&").",
pl_scIdx >= 0 and pl_scIdx < sizeof(v_ExecCtrl_scenarios));
return ispresent(v_ExecCtrl_scenarios[pl_scIdx].scData.weightedScData);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_getWeightedScData
//
// Purpose:
// returns the weighted scenario data for a weighted scenario
//
// Parameters:
// pl_scIdx - *in integer* - id of the scenario
//
// Return Value:
// EPTF_ExecCtrl_WeightedScData - weighted scenario data
//
// Errors:
// If the scenario in not weighted
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_ExecCtrl_getWeightedScData(in integer pl_scIdx)
runs on EPTF_ExecCtrl_CT
return EPTF_ExecCtrl_WeightedScData
{
f_EPTF_Base_assert(%definitionId&": Invalid 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&": scenario "&v_ExecCtrl_scenarios[pl_scIdx].scData.name&
" is not weighted.", ispresent(v_ExecCtrl_scenarios[pl_scIdx].scData.weightedScData));
return v_ExecCtrl_scenarios[pl_scIdx].scData.weightedScData;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_numTcOfScenario
//
// Purpose:
// returns the number of traffic cases in the scenario
//
// Parameters:
// pl_scIdx - *in integer* - id of the scenario
//
// Return Value:
// integer - number of traffic cases
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
public function f_EPTF_ExecCtrl_numTcOfScenario(in integer pl_scIdx)
runs on EPTF_ExecCtrl_CT
return integer
{
f_EPTF_Base_assert(%definitionId&": Invalid index "&int2str(pl_scIdx)&
". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_scenarios))&").",
pl_scIdx >= 0 and pl_scIdx < sizeof(v_ExecCtrl_scenarios));
return sizeof(v_ExecCtrl_scenarios[pl_scIdx].scData.tcList);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_Exectrl_getTcOfScenario
//
// Purpose:
// returns the scenario specific traffic case data for a traffic case
//
// Parameters:
// pl_scIdx - *in integer* - id of the scenario
// pl_tcOfScIdx - *in integer* - id of the traffic case inside the scenario
//
// Return Value:
// EPTF_ExecCtrl_TcOfScenario - scenario specific traffic case data
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
private function f_EPTF_Exectrl_getTcOfScenario(in integer pl_scIdx, in integer pl_tcOfScIdx)
runs on EPTF_ExecCtrl_CT
return EPTF_ExecCtrl_TcOfScenario
{
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 TC 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));
return v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx];
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_resetGroupFinishDataForSc
//
// Purpose:
// resets GroupFinishData for the scenario
//
// Parameters:
// pl_scIdx - *in integer* - id of the scenario
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_resetGroupFinishDataForSc(in integer pl_scIdx) runs on EPTF_ExecCtrl_CT {
// reset group finish data for all traffic cases of the scenario
for(var integer tc :=0; tc<sizeof(v_ExecCtrl_scenarios[pl_scIdx].tcIdxList); tc:=tc+1) {
f_EPTF_ExecCtrl_resetGroupFinishDataForTc(v_ExecCtrl_scenarios[pl_scIdx].tcIdxList[tc]);
}
}
///////////////////////////////
// LGen DB functions
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_addLGenInstance
//
// Purpose:
// Adds an LGen to the instance DB
//
// Parameters:
// pl_lgen - *in* <EPTF_ExecCtrl_LGenData> - the lgen data to add
//
// Return Value:
// integer - id of the LGen in the instace DB
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_addLGenInstance(in EPTF_ExecCtrl_LGenData pl_lgen)
runs on EPTF_ExecCtrl_CT
return integer
{
var integer vl_idx := sizeof(v_ExecCtrl_lgens);
f_EPTF_str2int_HashMap_Insert(v_ExecCtrl_lgensHash, pl_lgen.name, vl_idx);
// also insert the compRef as string:
f_EPTF_str2int_HashMap_Insert(v_ExecCtrl_lgensHash, int2str(pl_lgen.lgenCompRef), vl_idx);
v_ExecCtrl_lgens[vl_idx] := pl_lgen;
return vl_idx;
}
friend function f_EPTF_ExecCtrl_setRemoveStatisticsDependencyOfLGenCallback(in f_EPTF_ExecCtrl_removeStatisticsDependencyOfLGen_FT pl_func) runs on EPTF_ExecCtrl_CT {
v_f_EPTF_ExecCtrl_removeStatisticsDependencyOfLGen := pl_func;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_deleteLGenInstance
//
// Purpose:
// Delete an LGen from the instance DB
//
// Parameters:
// pl_lgenIdx - *in* *integer* - the index of lgen to delete
//
// Return Value:
// -
//
// Errors:
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
friend function f_EPTF_ExecCtrl_deleteLGenInstance(in integer pl_lgenIdx)
runs on EPTF_ExecCtrl_CT
{
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));
f_EPTF_ExecCtrl_debug(log2str(%definitionId&": Deleting LGen from database: ",v_ExecCtrl_lgens[pl_lgenIdx]));
// remove status dependency:
f_EPTF_ExecCtrl_removeStatusDependencyOfLGen(pl_lgenIdx);
// remove statistics dependency
if (v_f_EPTF_ExecCtrl_removeStatisticsDependencyOfLGen!= null) {
v_f_EPTF_ExecCtrl_removeStatisticsDependencyOfLGen.apply(pl_lgenIdx);
}
// reset resource data:
f_EPTF_ExecCtrl_deleteLGen2EntityGrps(pl_lgenIdx);
f_EPTF_ExecCtrl_resetLGenResourceList(pl_lgenIdx); // no resources available
// f_EPTF_str2int_HashMap_Erase(v_ExecCtrl_lgensHash, v_ExecCtrl_lgens[pl_lgenIdx].name);
// f_EPTF_str2int_HashMap_Erase(v_ExecCtrl_lgensHash, int2str(v_ExecCtrl_lgens[pl_lgenIdx].lgenCompRef));
// set compRef to 'null'
v_ExecCtrl_lgens[pl_lgenIdx].lgenCompRef := -1;// invalid compref (connection lost)
//v_ExecCtrl_lgens[vl_idx].eGroups := {};// no eGroups
f_EPTF_ExecCtrl_debug(log2str(%definitionId&": LGen deleted from database: ",v_ExecCtrl_lgens[pl_lgenIdx]));
}
// removes the status depency of scenario and traffic case status that
// the LGen was used
private function f_EPTF_ExecCtrl_removeStatusDependencyOfLGen(in integer pl_lgenIdx)
runs on EPTF_ExecCtrl_CT {
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));
// remove its status(LED) dependency from the scenario/traffic case status(LED)s it was running:
// go through the scenarios/traffic cases of this LGen:
for(var integer eg:=0; eg<sizeof(v_ExecCtrl_lgens[pl_lgenIdx].eGroups);eg:=eg+1) {
var integer vl_eGrpIdx := v_ExecCtrl_lgens[pl_lgenIdx].eGroups[eg].eGrpIdx;
var integer vl_lgenIdxInEGrp := v_ExecCtrl_lgens[pl_lgenIdx].eGroups[eg].lgenIdxInEGrp;
if (v_ExecCtrl_entityGroups[vl_eGrpIdx].lgenList[vl_lgenIdxInEGrp].eCount == 0 ) {
continue; // nothing to do
}
// decrease the counter of LGens that run this entity group:
var charstring vl_eGrpName := v_ExecCtrl_entityGroups[vl_eGrpIdx].name;
var charstring vl_currentName := c_EPTF_ExecCtrl_statisticsRoot&".EG."&vl_eGrpName&".nofLGens";
var integer vl_idx := f_EPTF_Var_getId(vl_currentName);
if (vl_idx!=-1) {
var integer vl_currentValue := str2int(f_EPTF_Var_getCharstringValue(vl_idx));
f_EPTF_Var_adjustContent(vl_idx,{charstringVal:=int2str(vl_currentValue-1)});
}
// go through all scenarios:
for(var integer sc:=0; sc<sizeof(v_ExecCtrl_entityGroups[vl_eGrpIdx].scenarios);sc:=sc+1) {
var integer vl_scIdx := v_ExecCtrl_entityGroups[vl_eGrpIdx].scenarios[sc];
var charstring vl_clientVarName;
var charstring vl_varName;
var integer vl_clientVarIdx;
var integer vl_mainVarIdx
// go through the traffic cases of the scenario:
for(var integer tc:=0; tc<sizeof(v_ExecCtrl_scenarios[vl_scIdx].tcIdxList); tc:=tc+1) {
var integer vl_tcOfScenarioIdx := tc;
// remove traffic case status dependency:
vl_clientVarName := "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)
&"."&v_ExecCtrl_lgens[pl_lgenIdx].name;
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)
vl_clientVarIdx := f_EPTF_Var_getId(vl_clientVarName);
vl_mainVarIdx := f_EPTF_Var_getId(vl_varName);
if (vl_mainVarIdx==-1 or vl_clientVarIdx==-1) {
continue;
}
// remove the provider vl_clientVarIdx from vl_mainVarIdx:
f_EPTF_Var_removeLocalProviders(vl_mainVarIdx, {vl_clientVarIdx});
// change client TC status to Off:
f_EPTF_Var_unsubscribe(vl_clientVarIdx);
f_EPTF_Var_adjustContent(vl_clientVarIdx, {charstringVal := "Off"});
f_EPTF_Var_refreshContent(vl_mainVarIdx);
} // for tc
// remove scenario status dependency:
vl_clientVarName := "ExecCtrlClient.scenarioStatus."&
v_ExecCtrl_entityGroups[vl_eGrpIdx].name&"."&v_ExecCtrl_scenarios[vl_scIdx].scData.name
&"."&v_ExecCtrl_lgens[pl_lgenIdx].name;
vl_varName := "ExecCtrl.scenarioStatus."&
v_ExecCtrl_entityGroups[vl_eGrpIdx].name&"."&v_ExecCtrl_scenarios[vl_scIdx].scData.name;
vl_clientVarIdx := f_EPTF_Var_getId(vl_clientVarName);
vl_mainVarIdx := f_EPTF_Var_getId(vl_varName);
if (vl_mainVarIdx==-1 or vl_clientVarIdx==-1) {
continue;
}
// remove the provider vl_clientVarIdx from vl_mainVarIdx:
f_EPTF_Var_removeLocalProviders(vl_mainVarIdx, {vl_clientVarIdx});
// change client SC status to Off:
f_EPTF_Var_unsubscribe(vl_clientVarIdx);
f_EPTF_Var_adjustContent(vl_clientVarIdx, {charstringVal := "Off"});
f_EPTF_Var_refreshContent(vl_mainVarIdx);
} // for sc
} // for eg
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ExecCtrl_updateLGenResourceList
//
// Purpose:
// Updates the LGen resources (<EPTF_ExecCtrl_LGenResourceInfo>) in the instance DB
//
// Parameters:
// pl_lgenIdx - *in integer* - id of the LGen
// pl_lgenResourceList - *in* <EPTF_ExecCtrl_LGenResourceInfoList> - the new resource info
//
// Return Value:
//
// Errors:
//
// Detailed Comments:
// The previous value of resourceList is overwritten by the new value