| /////////////////////////////////////////////////////////////////////////////// |
| // // |
| // Copyright (c) 2000-2019 Ericsson Telecom AB // |
| // // |
| // All rights reserved. This program and the accompanying materials // |
| // are made available under the terms of the Eclipse Public License v2.0 // |
| // which accompanies this distribution, and is available at // |
| // https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html // |
| /////////////////////////////////////////////////////////////////////////////// |
| |
| /////////////////////////////////////////////////////////// |
| // Module: EPTF_CLL_ExecCtrl_Functions |
| // |
| // Purpose: |
| // This module contains the implementation of EPTF_CLL_ExecCtrl functions. |
| // |
| // Module depends on: |
| // <EPTF_CLL_Common_Definitions> |
| // <EPTF_CLL_Base_Functions> |
| // <EPTF_CLL_FBQ_Definitions> |
| // <EPTF_CLL_LGenBase_Definitions> |
| // <EPTF_CLL_LGenBase_ConfigDefinitions> |
| // <EPTF_CLL_LGenBase_ConfigFunctions> |
| // <EPTF_CLL_LGenBase_PhaseDefinitions> |
| // <EPTF_CLL_ExecCtrl_Definitions> |
| // <EPTF_CLL_ExecCtrlTimeProfile_Definitions> |
| // <EPTF_CLL_ExecCtrl_ScenarioFunctions> |
| // <EPTF_CLL_ExecCtrl_LoggingFunctions> |
| // <EPTF_CLL_HashMapStr2Int_Functions> |
| // <EPTF_CLL_HashMapInt2Int_Functions> |
| // <EPTF_CLL_Scheduler_Definitions> |
| // <EPTF_CLL_RBTScheduler_Functions> |
| // <EPTF_CLL_Variable_Definitions> |
| // <EPTF_CLL_Variable_Functions> |
| // <EPTF_CLL_LGenBaseStats_Definitions> |
| // <EPTF_CLL_LGenBaseStats_Functions> |
| // <EPTF_CLL_Logging_Definitions> |
| // <EPTF_CLL_Logging_Functions> |
| // <EPTF_CLL_ExecCtrl_ScenarioDefinitions> |
| // <EPTF_CLL_ExecCtrlClient_Functions> |
| // <EPTF_CLL_ExecCtrl_PhaseFunctions> |
| // <EPTF_CLL_StatMeasure_Functions> |
| // <EPTF_CLL_StatHandler_Functions> |
| // <EPTF_CLL_StatHandlerClient_Functions> |
| // <EPTF_CLL_StatHandlerClient_Definitions> |
| // <TCCFileIO_Functions> |
| // <TCCDateTime_Functions> |
| // <EPTF_CLL_HashMap_Functions> |
| // |
| // Module Parameters: |
| // tsp_debug_EPTF_ExecCtrl_Functions - boolean - enable/disable debug logs |
| // tsp_EPTF_ExecCtrl_maxKillTime - float - max time to wait for all LGens to stop |
| // tsp_EPTF_ExecCtrl_finalTestReportFile - charstring - name of the file where the final test report is saved. Default: EPTF_ExecCtrl_FinalTestReport_%Y-%m-%d_%H.%M.%S.txt |
| // tsp_EPTF_ExecCtrl_UIHandler_disableAutoEnablingOfManualControlModeWhenStopButtonIsPressed - *boolean* - Disable to return to manual control mode when stop button is pressed |
| // |
| // Current Owner: |
| // Jozsef Gyurusi (ethjgi) |
| // |
| // Last Review Date: |
| // 2009-02-03 |
| // |
| // Detailed Comments: |
| // This module contains the interface functions for the EPTF_CLL_ExecCtrl. |
| // |
| // Public functions: |
| // <f_EPTF_ExecCtrl_init_CT> |
| // <f_EPTF_ExecCtrl_checkManualLGenStarted> *new |
| // <f_EPTF_ExecCtrl_start> |
| // <f_EPTF_ExecCtrl_getManualControl> |
| // <f_EPTF_ExecCtrl_setManualControl> |
| // <f_EPTF_ExecCtrl_getTimePeriodForTcDeltaStats> |
| // <f_EPTF_ExecCtrl_setTimePeriodForTcDeltaStats> |
| // <f_EPTF_ExecCtrl_loadConfig> |
| // <f_EPTF_ExecCtrl_checkReadyToRun> |
| // <f_EPTF_ExecCtrl_waitForCondition> |
| // <f_EPTF_ExecCtrl_setTimeFormat> |
| // <f_EPTF_ExecCtrl_startTimeProfiles> |
| // <f_EPTF_ExecCtrl_stopTimeProfiles> |
| // <f_EPTF_ExecCtrl_startAllScenarios> |
| // <f_EPTF_ExecCtrl_startAllScenarioGroups> |
| // <f_EPTF_ExecCtrl_stopAllScenarioGroups> |
| // <f_EPTF_ExecCtrl_terminateAllScenarioGroups> *new |
| // <f_EPTF_ExecCtrl_stopCurrentPhaseForAllScenarioGroups> |
| // <f_EPTF_ExecCtrl_stopAllScenarios> |
| // <f_EPTF_ExecCtrl_terminateAllScenarios> *new |
| // <f_EPTF_ExecCtrl_checkAllScenarios> *new |
| // <f_EPTF_ExecCtrl_setCps_TC> |
| // <f_EPTF_ExecCtrl_setCps_SC> |
| // <f_EPTF_ExecCtrl_getCPSToReach_TC> |
| // <f_EPTF_ExecCtrl_setCPSToReach_TC> |
| // <f_EPTF_ExecCtrl_getCPSToReach_SC> |
| // <f_EPTF_ExecCtrl_setCPSToReach_SC> |
| // <f_EPTF_ExecCtrl_getTCWeight> |
| // <f_EPTF_ExecCtrl_setTCWeight> |
| // <f_EPTF_ExecCtrl_Regulator_addRegulator> |
| // <f_EPTF_ExecCtrl_Regulator_getRegulatorId> |
| // <f_EPTF_ExecCtrl_Regulator_setTotalCps> |
| // <f_EPTF_ExecCtrl_Regulator_getTotalCps> |
| // <f_EPTF_ExecCtrl_Regulator_getRegulatedItemId> |
| // <f_EPTF_ExecCtrl_Regulator_getRegulatorName> |
| // <f_EPTF_ExecCtrl_Regulator_setRegulatorName> |
| // <f_EPTF_ExecCtrl_Regulator_logAll> |
| // <f_EPTF_ExecCtrl_registerScenarioStateChangedCallback> |
| // <f_EPTF_ExecCtrl_registerTrafficCaseStateChangedCallback> |
| // <f_EPTF_ExecCtrl_enableStartStopScenario> |
| // <f_EPTF_ExecCtrl_disableStartStopScenario> |
| // <f_EPTF_ExecCtrl_scenarioIsNotInScenarioGroup> |
| // <f_EPTF_ExecCtrl_isDisabledStartStopScenario> |
| // <f_EPTF_ExecCtrl_getStartStopScenarioIdx> |
| // <f_EPTF_ExecCtrl_enableStartStopTC> |
| // <f_EPTF_ExecCtrl_disableStartStopTC> |
| // <f_EPTF_ExecCtrl_isDisabledStartStopTC> |
| // <f_EPTF_ExecCtrl_getStartStopTCIdx> |
| // <f_EPTF_ExecCtrl_startScenarioOnLGens> |
| // <f_EPTF_ExecCtrl_stopScenarioOnLGens> |
| // <f_EPTF_ExecCtrl_resetScenarioOnLGens> |
| // <f_EPTF_ExecCtrl_stopScenarioGroupOnLGens> |
| // <f_EPTF_ExecCtrl_startTCOnLGens> |
| // <f_EPTF_ExecCtrl_stopTCOnLGens> |
| // <f_EPTF_ExecCtrl_singleShotTc> |
| // <f_EPTF_ExecCtrl_scenarioEnabled> |
| // <f_EPTF_ExecCtrl_behavior> |
| // <f_EPTF_ExecCtrl_exit> |
| // <f_EPTF_ExeCtrl_enableUIHandlerProgress> |
| // <f_EPTF_ExecCtrl_resetFSMStat> |
| // <f_EPTF_ExecCtrl_LGenPool_createLGens> |
| // <f_EPTF_ExecCtrl_nrOfClients> |
| // <f_EPTF_ExecCtrl_LGenPool_dumpInstanceDB> |
| // <f_EPTF_ExecCtrl_addLGenFunctionsFromDeclarators> |
| // <f_EPTF_ExecCtrl_getLGenCompRefsOfPool> |
| // <f_EPTF_ExecCtrl_checkCreatorFnNameOfPool> |
| // <f_EPTF_ExecCtrl_registerFinalTestReportGeneratorFn> |
| // <f_EPTF_ExecCtrl_deregisterFinalTestReportGeneratorFn> |
| // <f_EPTF_ExecCtrl_generateFinalTestReport> |
| // <f_EPTF_ExecCtrl_registerFSMStatsCreatedCallback> |
| // <f_EPTF_ExecCtrl_deregisterFSMStatsCreatedCallback> |
| // <f_EPTF_ExecCtrl_getFSMStatisticsOfTcs> |
| // <f_EPTF_ExecCtrl_setStartDelay_TC> |
| // <f_EPTF_ExecCtrl_startScenarioOnLGensByName> |
| // <f_EPTF_ExecCtrl_stopScenarioOnLGensByName> |
| // <f_EPTF_ExecCtrl_Regulator_findRegulatorsForScenario> |
| // <f_EPTF_ExecCtrl_StatHandler_getVarIdx> |
| // <f_EPTF_ExecCtrl_StatHandler_getVarNameByStatName> |
| // <f_EPTF_ExecCtrl_StatHandler_getAuxVars> |
| // |
| // All other functions in this module are private! |
| // |
| /////////////////////////////////////////////////////////////// |
| |
| |
| module EPTF_CLL_ExecCtrl_Functions { |
| |
| //========================================================================= |
| // Import Part |
| //========================================================================= |
| |
| import from EPTF_CLL_Common_Definitions all; |
| |
| import from EPTF_CLL_Base_Functions all; |
| |
| import from EPTF_CLL_LGenBase_Definitions all; |
| import from EPTF_CLL_LGenBase_ConfigDefinitions all; |
| import from EPTF_CLL_LGenBase_ConfigFunctions all; |
| import from EPTF_CLL_LGenBase_PhaseDefinitions all; |
| |
| import from EPTF_CLL_ExecCtrl_Definitions all; |
| import from EPTF_CLL_ExecCtrlTimeProfile_Definitions all; |
| import from EPTF_CLL_ExecCtrl_ScenarioFunctions all; |
| import from EPTF_CLL_ExecCtrl_LoggingFunctions all; |
| import from EPTF_CLL_HashMapStr2Int_Functions all; |
| import from EPTF_CLL_HashMapInt2Int_Functions all; |
| |
| import from EPTF_CLL_Scheduler_Definitions all; |
| import from EPTF_CLL_RBTScheduler_Functions all; |
| |
| import from EPTF_CLL_Variable_Definitions all; |
| import from EPTF_CLL_Variable_Functions all; |
| |
| import from EPTF_CLL_LGenBaseStats_Definitions all; |
| import from EPTF_CLL_LGenBaseStats_Functions all; |
| |
| import from EPTF_CLL_Logging_Definitions all; |
| import from EPTF_CLL_Logging_Functions all; |
| |
| import from EPTF_CLL_ExecCtrl_ScenarioDefinitions all; |
| import from EPTF_CLL_ExecCtrl_PhaseDefinitions all; |
| import from EPTF_CLL_ExecCtrl_PhaseFunctions all; |
| import from EPTF_CLL_ExecCtrl_DSFunctions all; |
| import from EPTF_CLL_StatMeasure_Functions all; |
| import from EPTF_CLL_StatHandler_Definitions all; |
| import from EPTF_CLL_StatHandler_Functions all; |
| import from EPTF_CLL_StatHandlerClient_Functions all; |
| import from EPTF_CLL_StatHandlerClient_Definitions all; |
| |
| import from EPTF_CLL_StatManager_Functions all; |
| |
| import from TCCFileIO_Functions all; |
| import from TCCDateTime_Functions all; |
| |
| import from EPTF_CLL_DataSource_Definitions all; |
| import from EPTF_CLL_DataSourceClient_Functions all; |
| |
| import from EPTF_CLL_HashMap_Functions all; |
| |
| import from EPTF_CLL_FBQ_Functions all; |
| |
| friend module EPTF_CLL_ExecCtrlUIHandler_Functions, EPTF_CLL_ExecCtrl_DSFunctions; |
| friend module EPTF_CLL_ExecCtrlClient_Functions; |
| |
| |
| //modulepar boolean tsp_EPTF_ExecCtrl_StatHandler_wait4response := true; // sets the StatHandler Wait4Resp flag |
| |
| //========================================================================= |
| // Functions |
| //======================================================================== |
| |
| /////////////////////////////////////////////////////////// |
| // Group: EPTF_ExecCtrl |
| // |
| // Purpose: |
| // Functions related to EPTF_ExecCtrl feature |
| // |
| /////////////////////////////////////////////////////////// |
| group EPTF_ExecCtrl { |
| |
| modulepar boolean tsp_debug_EPTF_ExecCtrl_Functions := false; |
| modulepar float tsp_EPTF_ExecCtrl_maxKillTime := 30.0; // max time to wait for all LGens to stop |
| modulepar charstring tsp_EPTF_ExecCtrl_finalTestReportFile := "EPTF_ExecCtrl_FinalTestReport_%Y-%m-%d_%H.%M.%S.txt"; // name of the file where the final test report is saved. Default: EPTF_ExecCtrl_FinalTestReport_%Y-%m-%d_%H.%M.%S.txt |
| // Set it to empty string to disable final test report generation |
| modulepar boolean tsp_EPTF_ExecCtrl_generateOwnReport := true; // If enabled ExecCtrl will write the traffic case statistics into the final test report. Default: true |
| |
| const charstring c_EPTF_ExecCtrl_Regulator_totalValue := "Regulator.totalValue"; // name of the variable that indicates the regulator targetLoad |
| const charstring c_EPTF_ExecCtrl_Regulator_targetLoad := "Regulator.targetLoad"; // name of the variable that indicates the regulator targetLoad |
| const charstring c_EPTF_ExecCtrl_Regulator_currentLoad := "Regulator.currentLoad"; // name of the variable that indicates the regulator currentLoad |
| const charstring c_EPTF_ExecCtrl_Regulator_status := "Regulator.status"; // name of the variable that indicates the regulator status |
| const charstring c_EPTF_ExecCtrl_Regulator_enable := "Regulator.enable"; // name of the variable that indicates the regulator enable flag |
| |
| modulepar boolean tsp_EPTF_ExecCtrl_UIHandler_disableAutoEnablingOfManualControlModeWhenStopButtonIsPressed := false; |
| |
| const EPTF_StatusLED c_EPTF_ExecCtrl_UIVars_StatusLED_init := { color := led_black, text := "NA" }; |
| const EPTF_StatusLED c_EPTF_ExecCtrl_UIVars_GroupFinishCondStatusLED_init := { color := led_black, text := " -- " }; |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_init_CT |
| // |
| // Purpose: |
| // Init EPTF_ExecCtrl feature |
| // |
| // Parameters: |
| // - pl_selfName - *in charstring* - the name of the component |
| // - pl_nrOfClients - *in integer* - the number of the <EPTF_ExecCtrlClient_CT> components created by the user |
| // (this is the size of the default pool) |
| // - pl_createLGenPools - *in boolean - if true, LGens in LGens pools are created automatically during init, otherwise |
| // the function <f_EPTF_ExecCtrl_LGenPool_createLGens> has to be called after the init function. Default: true |
| // - pl_loadModulepars - *in boolean - if true, module parameters are automatically loaded. Default: true |
| // - pl_autoStart - *in boolean - if true, ExecCtrl is started automatically by calling <f_EPTF_ExecCtrl_start>. Default: true |
| // - pl_dataSource_compRef - *in* <EPTF_DataSource_CT> - DataSource component reference. Optional, if given, ExecCtrl will be able to behave |
| // as a DataSource Client. It means that datas can be requested from it and it will provide them in variables. This component can |
| // be for example the UIHandler component. |
| // - pl_nofExternalStatHandlers - *in integer* - if >0: ExecCtrl TC and FSM statistics will be calculated on a separate StatHandler component, |
| // for 0: ExecCtrl will calculate the stats |
| // Note, that using external StatHandler component increases the internal traffic on the Variable interface (between ExecCtrl and StatHandler) |
| // Default: 0, which means that ExecCtrl will use its internal StatHandler (No extra internal traffic) |
| // - pl_usePullModeForStats - *in* *boolean* - If true pull mode is used for StatHandler statistics (default: false) |
| // |
| // Return Value: |
| // - |
| // |
| // Errors & assertions: |
| // - pl_nrOfClients shall be non-negative. |
| // |
| // Detailed Comments: |
| // The pl_nrOfClients parameter shall specify the number of LGens in the default LGen pool. |
| // The default LGen pool is the collection of LGens created by the user. |
| // All other LGens are created automatically by the LGenPool functionality, and |
| // the number of those LGens should not be added to this parameter. |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_ExecCtrl_init_CT |
| ( |
| in charstring pl_selfName, |
| in integer pl_nrOfClients, |
| in boolean pl_createLGenPools := true, |
| in boolean pl_loadModulepars := true, |
| in boolean pl_autoStart := true, |
| in EPTF_DataSource_CT pl_dataSource_compRef := null, |
| in integer pl_nofExternalStatHandlers := 0, |
| in boolean pl_usePullModeForStats := false |
| ) runs on EPTF_ExecCtrl_CT { |
| if (v_ExecCtrl_initialized) { |
| return; // already initialized |
| } |
| v_ExecCtrl_initialized := true; // should be here to prevent cleanup from not being called |
| v_ExecCtrl_readyToRun := false; |
| v_ExecCtrl_allLGensCreated := false; |
| v_EPTF_ExecCtrl_startTime := -1.0; |
| v_EPTF_ExecCtrl_timeFormat := tsp_EPTF_ExecCtrl_timeFormat; |
| |
| v_EPTF_ExecCtrl_ScenarioGroupPhaseChangedCallbackFns := {}; |
| v_EPTF_ExecCtrl_ScenarioStateChangedCallbackFns := {}; |
| v_EPTF_ExecCtrl_TrafficCaseStateChangedCallbackFns := {}; |
| v_EPTF_ExecCtrl_onGroupFinishCallbackFns := {}; |
| v_EPTF_ExecCtrl_finalTestReportGeneratorFns := {}; |
| v_EPTF_ExecCtrl_finalTestReport := ""; |
| |
| if (tsp_EPTF_ExecCtrl_generateOwnReport) { |
| f_EPTF_ExecCtrl_setGenerateOwnReport(true); |
| } |
| |
| v_ExecCtrl_endOfTest := false; |
| |
| v_ExecCtrl_pendingMsgCounter := 0; |
| v_ExecCtrl_pendingByeCounter := 0; |
| |
| v_ExecCtrl_FSMStats := {}; |
| v_EPTF_ExecCtrl_fsmStatsCreatedCallbackFns := {}; |
| v_ExecCtrl_processingCreateFSMStats := false; |
| |
| v_ExecCtrl_progressBarUIHandler_Idx := -1; |
| v_ExecCtrl_progressEnabled := true; |
| v_ExecCtrl_progressBarUIHandler_updateSent := false; |
| |
| f_EPTF_Base_init_CT(pl_selfName); |
| f_EPTF_FBQ_init_CT(pl_selfName); |
| f_EPTF_Var_init_CT(pl_selfName); |
| f_EPTF_StatMeasure_init_CT(pl_selfName); |
| |
| v_ExecCtrl_dataSourceCompRef := pl_dataSource_compRef; |
| v_EPTF_ExecCtrl_nofExternalStatHandlers := pl_nofExternalStatHandlers; |
| v_EPTF_ExecCtrl_statHandler_comprefList := {}; |
| v_EPTF_ExecCtrl_statHandler_autoSelector := 0; |
| v_ExecCtrl_statHandlerHash := f_EPTF_str2int_HashMap_New(c_ExecCtrl_statHandlerHashMapName); |
| v_ExecCtrl_usePullModeForStats := pl_usePullModeForStats; |
| f_ExecCtrl_ExternalStatHandler_startNew(); |
| |
| f_EPTF_StatHandlerClient_init_CT(pl_selfName); |
| f_EPTF_Scheduler_init_CT(pl_selfName); |
| f_EPTF_Logging_init_CT(pl_selfName); |
| f_EPTF_HashMap_init_CT (pl_selfName); |
| f_EPTF_DataSourceClient_init_CT(pl_selfName, pl_dataSource_compRef); |
| |
| v_ExecCtrl_regulatedItemsHash := f_EPTF_str2int_HashMap_New(c_ExecCtrl_regulatedItemsHashMapName); |
| |
| if(pl_dataSource_compRef != null){ |
| v_ExecCtrl_dataSourceCompRef := pl_dataSource_compRef; |
| f_EPTF_DataSourceClient_registerSetDataValue(c_ExecCtrl_DataSource_sourceId, f_EPTF_Base_selfName(), refers(f_EPTF_ExecCtrl_DSProcessSetDataValue)); |
| f_EPTF_DataSourceClient_registerData(c_ExecCtrl_DataSource_sourceId, f_EPTF_Base_selfName(), refers(f_EPTF_ExecCtrl_DSProcessData)); |
| f_EPTF_DataSourceClient_registerDataValue(c_ExecCtrl_DataSource_sourceId, f_EPTF_Base_selfName(), refers(f_EPTF_ExecCtrl_DSProcessDataValue), pl_dataSource_compRef); |
| f_EPTF_DataSourceClient_registerCondition(c_ExecCtrl_DataSource_sourceId, f_EPTF_Base_selfName(), refers(f_EPTF_ExecCtrl_conditionHandler_isWeightedSc),c_ExecCtrl_conditionIsWeightedSc); |
| f_EPTF_DataSourceClient_registerCondition(c_ExecCtrl_DataSource_sourceId, f_EPTF_Base_selfName(), refers(f_EPTF_ExecCtrl_conditionHandler_isInScGroup), c_ExecCtrl_conditionIsInScGroup); |
| } |
| |
| v_ExecCtrl_loggingMaskId := f_EPTF_Logging_registerComponentMasks(tsp_EPTF_ExecCtrl_loggingComponentMask, c_EPTF_ExecCtrl_loggingEventClasses, EPTF_Logging_CLL); |
| if(tsp_debug_EPTF_ExecCtrl_Functions) { |
| f_EPTF_Logging_enableLocalMask(v_ExecCtrl_loggingMaskId, c_EPTF_ExecCtrl_loggingClassIdx_Debug); |
| } else { |
| f_EPTF_Logging_disableLocalMask(v_ExecCtrl_loggingMaskId, c_EPTF_ExecCtrl_loggingClassIdx_Debug); |
| } |
| |
| if (pl_loadModulepars) { |
| f_EPTF_ExecCtrl_loadConfigFromModulepars(); |
| } |
| |
| // add vars for automated GUI elements |
| f_EPTF_ExecCtrl_UIVars_InitGUILayout_vars(); |
| |
| f_EPTF_ExecCtrl_initEventStatus(); |
| |
| f_EPTF_Base_assert(%definitionId&": Checking number of ExecCtrlClients", pl_nrOfClients>=0); |
| |
| v_ExecCtrl_nrOfClients := pl_nrOfClients; |
| v_ExecCtrl_started := false; |
| v_EPTF_ExecCtrl_EntityResourceInfo_Buffer := {}; |
| f_EPTF_Base_registerCleanup(refers(f_EPTF_ExecCtrl_cleanup_CT)); |
| |
| f_EPTF_ExecCtrl_registerOnGroupFinishCallbackFn(refers(f_EPTF_ExecCtrl_setLEDForOnGroupFinishCallBack)); |
| |
| v_EPTF_ExecCtrl_defaultAltstep := activate(as_EPTF_ExecCtrl_MgmtIf()); |
| |
| if (pl_autoStart) { |
| f_EPTF_ExecCtrl_start(pl_createLGenPools); |
| } else { |
| if (pl_createLGenPools) { |
| f_EPTF_ExecCtrl_warning(%definitionId& ": LGen pools are not created: Auto-start is disabled!"); |
| } |
| } |
| f_EPTF_ExecCtrl_Subscribe2ExitButton_vars(); |
| v_EPTF_ExecCtrl_SampledAtSync_vars := {}; // TR HQ88308 - Sampled & sync variables on old GUI for refresh |
| // TR HR20548 - Reset All statistics button |
| f_EPTF_StatHandler_registerStatisticsResetFunction(refers(f_EPTF_ExecCtrl_resetStatFunctions)); |
| f_EPTF_StatHandlerClient_registerResetFunction(refers(f_EPTF_ExecCtrl_resetStatFunctions)); |
| |
| } |
| |
| // this StatHandlert will process all ExecCtrl statistics (TC, FSM) |
| // Using External StatHandler will increase internal traffic on Variable interface |
| private function f_ExecCtrl_ExternalStatHandler_behaviour( |
| in EPTF_DataSource_CT pl_dataSource_compRef, |
| in integer pl_statHandlerId |
| ) runs on EPTF_ExecCtrl_StatHandler_CT { |
| f_EPTF_StatHandler_init_CT("ExecCtrl_ExternalStatHandler_Comp_"&log2str(pl_statHandlerId),pl_dataSource_compRef); |
| f_EPTF_StatManager_init_CT(f_EPTF_Base_selfName(),pl_dataSource_compRef); |
| f_EPTF_Base_wait4Shutdown(); |
| } |
| |
| // starts new StatHandlera or initializes the local |
| private function f_ExecCtrl_ExternalStatHandler_startNew() runs on EPTF_ExecCtrl_CT { |
| if (v_EPTF_ExecCtrl_nofExternalStatHandlers==0) { |
| // use local |
| f_EPTF_StatHandler_init_CT(f_EPTF_Base_selfName(), v_ExecCtrl_dataSourceCompRef); // Set pl_dataSource_compRef |
| f_EPTF_StatManager_init_CT(f_EPTF_Base_selfName(), v_ExecCtrl_dataSourceCompRef); |
| v_EPTF_ExecCtrl_statHandler_comprefList := {self}; |
| return; |
| } |
| for(var integer i:=0; i<v_EPTF_ExecCtrl_nofExternalStatHandlers; i:=i+1) { |
| var EPTF_ExecCtrl_StatHandler_CT vl_externalStatHandler := EPTF_ExecCtrl_StatHandler_CT.create; |
| vl_externalStatHandler.start(f_ExecCtrl_ExternalStatHandler_behaviour(v_ExecCtrl_dataSourceCompRef,i)); |
| v_EPTF_ExecCtrl_statHandler_comprefList[i] := vl_externalStatHandler; |
| } |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_StatHandler_getVarIdx |
| // |
| // Purpose: |
| // Function for getting the id/index of the variable of a statistic. |
| // |
| // Parameters: |
| // pl_statName - *in* *charstring* - name of the stat |
| // |
| // Return Value: |
| // *integer* - index of variable for the stat |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // override function <f_EPTF_StatHandler_getVarIdx> |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_ExecCtrl_StatHandler_getVarIdx( |
| in charstring pl_statName |
| ) runs on EPTF_ExecCtrl_CT return integer { |
| |
| var integer vl_statVarIdx; |
| var EPTF_StatHandler_CT vl_statHandler := f_EPTF_ExecCtrl_findStatHandler(pl_statName); |
| if (vl_statHandler==self) { |
| var integer vl_statId := f_EPTF_StatHandler_getId(pl_statName); |
| vl_statVarIdx := f_EPTF_StatHandler_getVarIdx(vl_statId); |
| } else { |
| // get var idx from remote statHandler |
| // the stat variable name and the stat name is the same; |
| var EPTF_Var_SubscriptionMode vl_subscriptionModeForVars := sampled; |
| if (v_ExecCtrl_usePullModeForStats) { |
| vl_subscriptionModeForVars := pull; |
| } |
| f_EPTF_Var_subscribeRemote( |
| pl_remoteCompRef := vl_statHandler, |
| pl_remoteProviderVarName := pl_statName, |
| pl_subscriptionMode := vl_subscriptionModeForVars, |
| pl_idx := vl_statVarIdx, |
| pl_localName := pl_statName&"_Local" |
| ); |
| } |
| return vl_statVarIdx; |
| } |
| |
| ///////////////////////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_StatHandler_getVarNameByStatName |
| // |
| // Purpose: |
| // Function for getting the variable name for a statistic name. |
| // |
| // Parameters: |
| // pl_statName - *in* *charstring* - name of statistic |
| // pl_varName - *out* *charstring* - the variable name for a statistic name |
| // |
| // Return Value: |
| // *boolean* - true if success |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // override function <f_EPTF_StatHandler_getVarNameByStatName> |
| // |
| ///////////////////////////////////////////////////////////////////////////// |
| public function f_EPTF_ExecCtrl_StatHandler_getVarNameByStatName( |
| in charstring pl_statName, |
| out charstring pl_varName) |
| runs on EPTF_ExecCtrl_CT |
| return boolean |
| { |
| var integer vl_varIdx := f_EPTF_ExecCtrl_StatHandler_getVarIdx(pl_statName); |
| if(vl_varIdx < 0) { return false; } |
| pl_varName := f_EPTF_Var_getName(vl_varIdx); |
| return true; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_StatHandler_getAuxVars |
| // |
| // Purpose: |
| // Function for getting the auxiliary Variable indices of a statistic. |
| // |
| // Parameters: |
| // pl_statName - *in* *charstring* - name of the stat |
| // |
| // Return Value: |
| // <EPTF_IntegerList> - list of auxiliary Var indices |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // override function f_EPTF_StatHandler_getAuxVars |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_ExecCtrl_StatHandler_getAuxVars( |
| in charstring pl_statName |
| ) runs on EPTF_ExecCtrl_CT return EPTF_IntegerList { |
| |
| var EPTF_IntegerList vl_auxVars; |
| var EPTF_StatHandler_CT vl_statHandler := f_EPTF_ExecCtrl_findStatHandler(pl_statName); |
| if (vl_statHandler==self) { |
| var integer vl_statId := f_EPTF_StatHandler_getId(pl_statName); |
| vl_auxVars := f_EPTF_StatHandler_getAuxVars(vl_statId); |
| } else { |
| // get aux var idxs from remote statHandler and subscribe to them |
| var EPTF_CharstringList vl_auxVarNames := f_EPTF_StatHandlerClient_getAuxVariables(pl_statName,vl_statHandler); |
| var EPTF_Var_SubscriptionMode vl_subscriptionModeForVars := sampled; |
| if (v_ExecCtrl_usePullModeForStats) { |
| vl_subscriptionModeForVars := pull; |
| } |
| for(var integer i:=0, size:=sizeof(vl_auxVarNames); i<size; i:=i+1) { |
| f_EPTF_Var_subscribeRemote( |
| pl_remoteCompRef := vl_statHandler, |
| pl_remoteProviderVarName := vl_auxVarNames[i], |
| pl_subscriptionMode := vl_subscriptionModeForVars, |
| pl_idx := vl_auxVars[i] |
| ) |
| } |
| } |
| return vl_auxVars; |
| } |
| |
| // override function f_EPTF_StatHandlerClient_declareStat |
| private function f_EPTF_ExecCtrl_StatHandlerClient_declareStat( |
| in charstring pl_statName, |
| in EPTF_StatHandler_StatMethod pl_statMethod, |
| in EPTF_Var_DirectContent pl_statResetValue |
| ) runs on EPTF_ExecCtrl_CT return boolean { |
| |
| var EPTF_StatHandler_CT vl_statHandler := f_EPTF_ExecCtrl_findStatHandler(pl_statName); |
| |
| var integer vl_statHandlerCompIdx := -1; |
| if (vl_statHandler==null) { |
| if (v_EPTF_ExecCtrl_nofExternalStatHandlers==0) { |
| vl_statHandlerCompIdx := 0; |
| } else { |
| vl_statHandlerCompIdx := v_EPTF_ExecCtrl_statHandler_autoSelector mod v_EPTF_ExecCtrl_nofExternalStatHandlers; |
| } |
| vl_statHandler := v_EPTF_ExecCtrl_statHandler_comprefList[vl_statHandlerCompIdx]; |
| } else { |
| // stat already declared |
| return true; |
| } |
| |
| var boolean vl_success := f_EPTF_StatHandlerClient_declareStat( |
| pl_statName := pl_statName, |
| pl_statMethod := pl_statMethod, |
| pl_statResetValue := pl_statResetValue, |
| pl_statHandler := vl_statHandler, |
| pl_wait4response := true |
| ); |
| |
| if (vl_success) { |
| // subscribe statVar so that DS handler does not need f_EPTF_Var_subscribeRemote which would cause long call stack there |
| var EPTF_Var_SubscriptionMode vl_subscriptionModeForVars := sampled; |
| if (v_ExecCtrl_usePullModeForStats) { |
| vl_subscriptionModeForVars := pull; |
| } |
| var integer vl_idx; |
| f_EPTF_Var_subscribeRemote( |
| pl_remoteCompRef := vl_statHandler, |
| pl_remoteProviderVarName := pl_statName, |
| pl_subscriptionMode := vl_subscriptionModeForVars, |
| pl_idx := vl_idx, |
| pl_localName := pl_statName&"_Local" |
| ); |
| |
| // store statHandler compRef for the statName: |
| f_EPTF_str2int_HashMap_Insert(v_ExecCtrl_statHandlerHash, pl_statName, vl_statHandlerCompIdx); |
| |
| if (v_EPTF_ExecCtrl_nofExternalStatHandlers>0) { |
| |
| v_EPTF_ExecCtrl_statHandler_autoSelector := v_EPTF_ExecCtrl_statHandler_autoSelector + 1; |
| |
| } |
| } |
| |
| return vl_success; |
| } |
| |
| // override function f_EPTF_StatHandlerClient_registerAggregatedStat |
| private function f_EPTF_ExecCtrl_StatHandlerClient_registerAggregatedStat( |
| in EPTF_StatHandler_CT pl_sourceStatHandler, |
| in charstring pl_sourceStatName, |
| in charstring pl_targetStatName, |
| in EPTF_Var_SubscriptionMode pl_subscriptionMode := sampledAtSync, |
| in boolean pl_wait4response := true//tsp_EPTF_ExecCtrl_StatHandler_wait4response |
| ) runs on EPTF_ExecCtrl_CT return boolean { |
| var EPTF_StatHandler_CT vl_statHandler := self; |
| |
| if (v_EPTF_ExecCtrl_nofExternalStatHandlers>0) { |
| vl_statHandler := f_EPTF_ExecCtrl_findStatHandler(pl_targetStatName); |
| if (vl_statHandler==null) { |
| return false; |
| } |
| } |
| |
| return f_EPTF_StatHandlerClient_registerAggregatedStat( |
| pl_sourceStatHandler := pl_sourceStatHandler, |
| pl_sourceStatName := pl_sourceStatName, |
| pl_targetStatName := pl_targetStatName, |
| pl_subscriptionMode := pl_subscriptionMode, |
| pl_wait4response := pl_wait4response, |
| pl_statHandler := vl_statHandler |
| ); |
| } |
| |
| // override function f_EPTF_StatHandlerClient_getStatVariableRef |
| private function f_EPTF_ExecCtrl_StatHandlerClient_getStatVariableRef( |
| in charstring pl_statName |
| ) runs on EPTF_ExecCtrl_CT return charstring { |
| var EPTF_StatHandler_CT vl_statHandler := self; |
| |
| if (v_EPTF_ExecCtrl_nofExternalStatHandlers>0) { |
| vl_statHandler := f_EPTF_ExecCtrl_findStatHandler(pl_statName); |
| if (vl_statHandler==null) { |
| return ""; |
| } |
| } |
| |
| return f_EPTF_StatHandlerClient_getStatVariableRef( |
| pl_statName := pl_statName, |
| pl_statHandler := vl_statHandler |
| ); |
| } |
| |
| //override function f_EPTF_StatHandlerClient_registerStat |
| private function f_EPTF_ExecCtrl_StatHandlerClient_registerStat( |
| in EPTF_CharstringList pl_providerVarList, |
| in charstring pl_statName, |
| in EPTF_Var_SubscriptionMode pl_subscriptionMode := sampledAtSync, |
| in boolean pl_wait4response := true,//tsp_EPTF_ExecCtrl_StatHandler_wait4response, |
| in EPTF_Var_CT pl_sourceCompRef := null, |
| in integer pl_refreshRate := 0 |
| ) runs on EPTF_ExecCtrl_CT return boolean { |
| var EPTF_StatHandler_CT vl_statHandler := self; |
| |
| if (v_EPTF_ExecCtrl_nofExternalStatHandlers>0) { |
| vl_statHandler := f_EPTF_ExecCtrl_findStatHandler(pl_statName); |
| if (vl_statHandler==null) { |
| return false; |
| } |
| } |
| |
| return f_EPTF_StatHandlerClient_registerStat( |
| pl_providerVarList := pl_providerVarList, |
| pl_statName := pl_statName, |
| pl_subscriptionMode := pl_subscriptionMode, |
| pl_wait4response := pl_wait4response, |
| pl_sourceCompRef := pl_sourceCompRef, |
| pl_statHandler := vl_statHandler, |
| pl_refreshRate := pl_refreshRate |
| ); |
| } |
| |
| friend function f_EPTF_ExecCtrl_findStatHandler( |
| in charstring pl_statName |
| ) runs on EPTF_ExecCtrl_CT return EPTF_StatHandler_CT { |
| var integer vl_idx; |
| if (not f_EPTF_str2int_HashMap_Find( |
| v_ExecCtrl_statHandlerHash, |
| pl_statName, |
| vl_idx |
| )) { |
| return null; |
| } |
| return v_EPTF_ExecCtrl_statHandler_comprefList[vl_idx]; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_checkManualLGenStarted |
| // |
| // Purpose: |
| // Checks if LGens that are created manually (not in LGenPool) have started |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // boolean - true if all manual LGens have started, false if not |
| // |
| // Errors & assertions: |
| // |
| // Detailed Comments: |
| // After this function is called, no more user created LGen will start. |
| // If LGen pools are created before user created LGens i.e. when start was called |
| // before the manual LGens are created, this function will return true when all |
| // LGens have been created. |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_ExecCtrl_checkManualLGenStarted() runs on EPTF_ExecCtrl_CT return boolean { |
| return ((not v_ExecCtrl_started) and sizeof(v_EPTF_ExecCtrl_EntityResourceInfo_Buffer) == v_ExecCtrl_nrOfClients) or v_ExecCtrl_allLGensCreated; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_start |
| // |
| // Purpose: |
| // Start the ExecCtrl operation |
| // |
| // Parameters: |
| // - pl_createLGenPools - *in boolean - if true, LGens in LGens pools are created automatically, otherwise |
| // the function <f_EPTF_ExecCtrl_LGenPool_createLGens> has to be called later. Default: true |
| // |
| // Return Value: |
| // - |
| // |
| // Errors & assertions: |
| // |
| // Detailed Comments: |
| // After this function is called, configuration data cannot be loaded i.e. |
| // config loaded by f_EPTF_ExecCtrl_loadConfig will be ignored. |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_ExecCtrl_start(in boolean pl_createLGenPools := true) runs on EPTF_ExecCtrl_CT { |
| // Init R3 DB: |
| f_EPTF_ExecCtrl_initTypeDB(); |
| f_EPTF_ExecCtrl_loadTypeDB( |
| v_ExecCtrl_ScenarioDeclarators, |
| v_ExecCtrl_tcTypeDeclarators, |
| v_ExecCtrl_ScenarioDeclarators2, |
| v_ExecCtrl_tcTypeDeclarators2, |
| v_ExecCtrl_ScenarioDeclarators3, |
| v_ExecCtrl_ScenarioDeclaratorsR3 |
| ); |
| |
| f_EPTF_ExecCtrl_initInstanceDB(); |
| f_EPTF_ExecCtrl_loadInstanceDB( |
| v_ExecCtrl_EntityGrpDeclarators, |
| v_ExecCtrl_Scenarios2Grps, |
| v_ExecCtrl_scenario2EntityGroups |
| ); |
| // R3 end |
| |
| f_EPTF_ExecCtrl_initSc2grp(); |
| |
| f_EPTF_ExecCtrl_initScTimeProfileListDB(); |
| |
| f_EPTF_ExecCtrl_Phase_init(); |
| |
| //create scenario groups |
| f_EPTF_ExecCtrl_Phase_createScenarioGroups(); |
| |
| f_EPTF_ExecCtrl_Regulator_init(v_EPTF_ExecCtrl_RegulatorNames,v_EPTF_ExecCtrl_RegulatedItemsCFG); // this should be done at last |
| |
| f_EPTF_ExecCtrl_EntityGroupDistribution_init(v_EPTF_ExecCtrl_entityGroupDistributionCFG); |
| |
| f_EPTF_ExecCtrl_debug(log2str("value of v_ExecCtrl_tcTypeDeclarators = ", v_ExecCtrl_tcTypeDeclarators)); |
| |
| f_EPTF_ExecCtrl_LGenPool_initInstanceDB(); |
| f_EPTF_ExecCtrl_LGenPool_loadInstanceDB( |
| v_EPTF_ExecCtrl_LGenPool_Declarators, |
| v_EPTF_ExecCtrl_EntityGroup2LGenPools |
| ); |
| f_EPTF_ExecCtrl_LGenFunctions_initInstanceDB(); |
| f_EPTF_ExecCtrl_addLGenFunctionsFromDeclarators(v_EPTF_ExecCtrl_lgenCreatorFn_list); |
| |
| v_ExecCtrl_started := true; |
| f_EPTF_ExecCtrl_loadBuffered_EntityResourceInfo(); |
| |
| if (pl_createLGenPools) { |
| f_EPTF_ExecCtrl_LGenPool_createLGens(); |
| } |
| |
| if(v_ExecCtrl_nrOfClients==0 and v_ExecCtrl_allLGensCreated) { |
| if (pl_createLGenPools) { |
| t_ExecCtrl_allLGensCreated.stop; |
| } |
| f_EPTF_ExecCtrl_readyToRun(); |
| } |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_getManualControl |
| // |
| // Purpose: |
| // Gets the manual control mode |
| // |
| // Parameters: |
| // |
| // Return Value: |
| // boolean - manual control mode |
| // |
| // Errors & assertions: |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_ExecCtrl_getManualControl() runs on EPTF_ExecCtrl_CT return boolean |
| { |
| return v_ExecCtrl_manualControl; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_setManualControl |
| // |
| // Purpose: |
| // Sets the manual control mode (overwrites config setting) |
| // |
| // Parameters: |
| // pl_manualControl - *in boolean* - true to enable manual control mode, false to disable (automatic start of scenarios) |
| // |
| // Return Value: |
| // - |
| // |
| // Errors & assertions: |
| // |
| // Detailed Comments: |
| // It is not called in <f_EPTF_ExecCtrl_init_CT>. |
| // This function should be called before initializing the ExecCtrl component with its init function <f_EPTF_ExecCtrl_init_CT>. |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_ExecCtrl_setManualControl(in boolean pl_manualControl) runs on EPTF_ExecCtrl_CT |
| { |
| v_ExecCtrl_manualControl := pl_manualControl; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_getTimePeriodForTcDeltaStats |
| // |
| // Purpose: |
| // Gets The time period when delta stats are refreshed |
| // |
| // Parameters: |
| // |
| // Return Value: |
| // float - Time period when delta stats are refreshed. |
| // |
| // Errors & assertions: |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_ExecCtrl_getTimePeriodForTcDeltaStats() runs on EPTF_ExecCtrl_CT return float |
| { |
| return v_EPTF_ExecCtrl_timePeriodForTcDeltaStats; |
| } |
| |
| /////////////////////////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_setTimePeriodForTcDeltaStats |
| // |
| // Purpose: |
| // Tells that the ExecCtrl's Time period when delta stats are refreshed. |
| // |
| // Parameters: |
| // pl_gtimePeriodForTcDeltaStats - *float* - Time period when delta stats are refreshed. |
| // |
| // Return Value: |
| // - |
| // |
| /////////////////////////////////////////////////////////////////////////////// |
| public function f_EPTF_ExecCtrl_setTimePeriodForTcDeltaStats(in float pl_gtimePeriodForTcDeltaStats) runs on EPTF_ExecCtrl_CT |
| { |
| v_EPTF_ExecCtrl_timePeriodForTcDeltaStats := pl_gtimePeriodForTcDeltaStats; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_loadConfig |
| // |
| // Purpose: |
| // Loads additional config data and appends them to existing data |
| // |
| // Parameters: |
| // pl_EPTF_LGenBase_TcMgmt_EntityGrpDeclaratorList - *in* <EPTF_LGenBase_TcMgmt_EntityGrpDeclaratorList> |
| // pl_EPTF_LGenBase_TcMgmt_Scenarios2GrpList - *in* <EPTF_LGenBase_TcMgmt_Scenarios2GrpList> |
| // |
| // pl_EPTF_LGenBase_ScenarioDeclaratorList - *in* <EPTF_LGenBase_ScenarioDeclaratorList> |
| // pl_EPTF_LGenBase_tcTypeDeclaratorList - *in* <EPTF_LGenBase_tcTypeDeclaratorList> |
| // |
| // pl_EPTF_LGenBase_TcMgmt_tcTypeDeclaratorList - *in* <EPTF_LGenBase_TcMgmt_tcTypeDeclaratorList> |
| // pl_EPTF_LGenBase_TcMgmt_ScenarioDeclaratorList - *in* <EPTF_LGenBase_TcMgmt_ScenarioDeclaratorList> |
| // |
| // pl_EPTF_LGenBase_TcMgmt_WeightedScenarioDeclaratorList - *in* <EPTF_LGenBase_TcMgmt_WeightedScenarioDeclaratorList> |
| // |
| // pl_EPTF_ExecCtrl_TimeProfileDescrList - *in* <EPTF_ExecCtrl_TimeProfileDescrList> |
| // pl_EPTF_ExecCtrl_TimeProfileList - *in* <EPTF_ExecCtrl_TimeProfileList> |
| // pl_EPTF_ExecCtrl_TimeProfile2TcList - *in* <EPTF_ExecCtrl_TimeProfile2TcList> |
| // |
| // pl_EPTF_LGenBase_ScenarioTypeDeclaratorList - *in* <EPTF_LGenBase_ScenarioTypeDeclaratorList> *optional* - Scenario Declator appeared in R3 |
| // pl_EPTF_ExecCtrl_ScenarioInstanceTypeList - *in* <EPTF_ExecCtrl_ScenarioInstanceTypeList> - scenario instance decl |
| // |
| // pl_EPTF_ExecCtrl_LGenPool_Declarators - *in* <EPTF_ExecCtrl_LGenPool_Declarators> - LGen Pool declarators |
| // pl_EPTF_ExecCtrl_EntityGroup2LGenPool_List - *in* <EPTF_ExecCtrl_EntityGroup2LGenPool_List> - Entity group to LGen Pool declarators |
| // |
| // pl_EPTF_ExecCtrl_LGenFunction_Entry_List - *in* <EPTF_ExecCtrl_LGenFunction_Entry_List> - the LGen creator functions to register |
| // |
| // pl_EPTF_ExecCtrl_PhaseList_Declarators - *in* <EPTF_LGenBase_PhaseList_Declarators> - list of phaseLists |
| // pl_EPTF_ExecCtrl_ScenarioGroup_Declarators - *in* <EPTF_ExecCtrl_ScenarioGroup_Declarators> - list of scenario groups |
| // |
| // pl_EPTF_ExecCtrl_RegulatorNames - *in* <EPTF_ExecCtrl_RegulatorNames> - list of regulator names |
| // pl_EPTF_ExecCtrl_RegulatedItems - *in* <EPTF_ExecCtrl_RegulatedItems> - list of regulated items |
| // |
| // pl_EPTF_ExecCtrl_EntityGroupDistributionTypeList - *in* <EPTF_ExecCtrl_EntityGroupDistributionTypeList> - list of entity group distributions |
| // |
| // Return Value: |
| // - |
| // |
| // Errors & assertions: |
| // |
| // Detailed Comments: |
| // All parameters are optional. If specified, the value of that parameter is appended to the corresponding data already loaded. |
| // This function can be called more than once with different arguments. It is not called in <f_EPTF_ExecCtrl_init_CT>. |
| // If you have your own tsp-s, this function can be used to load them into the ExecCtrl database. The ExecCtr |
| // should know about all declarators in the system. |
| // This function should be called before the <f_EPTF_ExecCtrl_start> function is called on the ExecCtrl component. |
| // This function can be called before the ExecCtrl is initialized with its init function <f_EPTF_ExecCtrl_init_CT>. |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_ExecCtrl_loadConfig( |
| in EPTF_LGenBase_TcMgmt_EntityGrpDeclaratorList pl_EPTF_LGenBase_TcMgmt_EntityGrpDeclaratorList :={}, |
| in EPTF_LGenBase_TcMgmt_Scenarios2GrpList pl_EPTF_LGenBase_TcMgmt_Scenarios2GrpList :={}, |
| |
| in EPTF_LGenBase_ScenarioDeclaratorList pl_EPTF_LGenBase_ScenarioDeclaratorList :={}, |
| in EPTF_LGenBase_tcTypeDeclaratorList pl_EPTF_LGenBase_tcTypeDeclaratorList :={}, |
| |
| in EPTF_LGenBase_TcMgmt_tcTypeDeclaratorList pl_EPTF_LGenBase_TcMgmt_tcTypeDeclaratorList :={}, |
| in EPTF_LGenBase_TcMgmt_ScenarioDeclaratorList pl_EPTF_LGenBase_TcMgmt_ScenarioDeclaratorList :={}, |
| |
| in EPTF_LGenBase_TcMgmt_WeightedScenarioDeclaratorList pl_EPTF_LGenBase_TcMgmt_WeightedScenarioDeclaratorList :={}, |
| |
| in EPTF_ExecCtrl_TimeProfileDescrList pl_EPTF_ExecCtrl_TimeProfileDescrList := {}, |
| in EPTF_ExecCtrl_TimeProfileList pl_EPTF_ExecCtrl_TimeProfileList := {}, |
| in EPTF_ExecCtrl_TimeProfile2TcList pl_EPTF_ExecCtrl_TimeProfile2TcList := {}, |
| |
| in EPTF_LGenBase_ScenarioTypeDeclaratorList pl_EPTF_LGenBase_ScenarioTypeDeclaratorList := {}, |
| in EPTF_ExecCtrl_ScenarioInstanceTypeList pl_EPTF_ExecCtrl_ScenarioInstanceTypeList := {}, |
| |
| in EPTF_ExecCtrl_LGenPool_Declarators pl_EPTF_ExecCtrl_LGenPool_Declarators := {}, |
| in EPTF_ExecCtrl_EntityGroup2LGenPool_List pl_EPTF_ExecCtrl_EntityGroup2LGenPool_List := {}, |
| |
| in EPTF_ExecCtrl_LGenFunction_Entry_List pl_EPTF_ExecCtrl_LGenFunction_Entry_List := {}, |
| |
| in EPTF_LGenBase_PhaseList_Declarators pl_EPTF_ExecCtrl_PhaseList_Declarators := {}, |
| in EPTF_ExecCtrl_ScenarioGroup_Declarators pl_EPTF_ExecCtrl_ScenarioGroup_Declarators := {}, |
| |
| in EPTF_ExecCtrl_RegulatorNames pl_EPTF_ExecCtrl_RegulatorNames := {}, |
| in EPTF_ExecCtrl_RegulatedItems pl_EPTF_ExecCtrl_RegulatedItems := {}, |
| |
| in EPTF_ExecCtrl_EntityGroupDistributionTypeList pl_EPTF_ExecCtrl_EntityGroupDistributionTypeList := {} |
| |
| ) runs on EPTF_ExecCtrl_CT { |
| if (v_ExecCtrl_started) { |
| f_EPTF_ExecCtrl_warning(log2str(%definitionId&": Config not loaded: ExecCtrl was already started")); |
| return; |
| } |
| // load pl_EPTF_LGenBase_TcMgmt_EntityGrpDeclaratorList: |
| for(var integer i:=0, size := sizeof(pl_EPTF_LGenBase_TcMgmt_EntityGrpDeclaratorList); i<size; i:=i+1) { |
| var integer vl_currentSize := sizeof(v_ExecCtrl_EntityGrpDeclarators); |
| v_ExecCtrl_EntityGrpDeclarators[vl_currentSize] := pl_EPTF_LGenBase_TcMgmt_EntityGrpDeclaratorList[i]; |
| } |
| // load pl_EPTF_LGenBase_TcMgmt_Scenarios2GrpList: |
| for(var integer i:=0, size := sizeof(pl_EPTF_LGenBase_TcMgmt_Scenarios2GrpList); i<size; i:=i+1) { |
| var integer vl_currentSize := sizeof(v_ExecCtrl_Scenarios2Grps); |
| v_ExecCtrl_Scenarios2Grps[vl_currentSize] := pl_EPTF_LGenBase_TcMgmt_Scenarios2GrpList[i]; |
| } |
| |
| |
| // load pl_EPTF_LGenBase_ScenarioDeclaratorList: |
| for(var integer i:=0, size := sizeof(pl_EPTF_LGenBase_ScenarioDeclaratorList); i<size; i:=i+1) { |
| var integer vl_currentSize := sizeof(v_ExecCtrl_ScenarioDeclarators); |
| v_ExecCtrl_ScenarioDeclarators[vl_currentSize] := pl_EPTF_LGenBase_ScenarioDeclaratorList[i]; |
| } |
| // load pl_EPTF_LGenBase_tcTypeDeclaratorList: |
| for(var integer i:=0, size := sizeof(pl_EPTF_LGenBase_tcTypeDeclaratorList); i<size; i:=i+1) { |
| var integer vl_currentSize := sizeof(v_ExecCtrl_tcTypeDeclarators); |
| v_ExecCtrl_tcTypeDeclarators[vl_currentSize] := pl_EPTF_LGenBase_tcTypeDeclaratorList[i]; |
| } |
| |
| |
| // load pl_EPTF_LGenBase_TcMgmt_tcTypeDeclaratorList: |
| for(var integer i:=0, size := sizeof(pl_EPTF_LGenBase_TcMgmt_tcTypeDeclaratorList); i<size; i:=i+1) { |
| var integer vl_currentSize := sizeof(v_ExecCtrl_tcTypeDeclarators2); |
| v_ExecCtrl_tcTypeDeclarators2[vl_currentSize] := pl_EPTF_LGenBase_TcMgmt_tcTypeDeclaratorList[i]; |
| } |
| // load pl_EPTF_LGenBase_TcMgmt_ScenarioDeclaratorList: |
| for(var integer i:=0, size := sizeof(pl_EPTF_LGenBase_TcMgmt_ScenarioDeclaratorList); i<size; i:=i+1) { |
| var integer vl_currentSize := sizeof(v_ExecCtrl_ScenarioDeclarators2); |
| v_ExecCtrl_ScenarioDeclarators2[vl_currentSize] := pl_EPTF_LGenBase_TcMgmt_ScenarioDeclaratorList[i]; |
| } |
| |
| |
| // load pl_EPTF_LGenBase_TcMgmt_WeightedScenarioDeclaratorList: |
| for(var integer i:=0, size := sizeof(pl_EPTF_LGenBase_TcMgmt_WeightedScenarioDeclaratorList); i<size; i:=i+1) { |
| var integer vl_currentSize := sizeof(v_ExecCtrl_ScenarioDeclarators3); |
| v_ExecCtrl_ScenarioDeclarators3[vl_currentSize] := pl_EPTF_LGenBase_TcMgmt_WeightedScenarioDeclaratorList[i]; |
| } |
| |
| // load pl_EPTF_ExecCtrl_TimeProfileDescrList: |
| for(var integer i:=0, size := sizeof(pl_EPTF_ExecCtrl_TimeProfileDescrList); i<size; i:=i+1) { |
| var integer vl_currentSize := sizeof(v_EPTF_ExecCtrl_TimeProfileDescrList); |
| v_EPTF_ExecCtrl_TimeProfileDescrList[vl_currentSize] := pl_EPTF_ExecCtrl_TimeProfileDescrList[i]; |
| } |
| // load pl_EPTF_ExecCtrl_TimeProfileList: |
| for(var integer i:=0, size := sizeof(pl_EPTF_ExecCtrl_TimeProfileList); i<size; i:=i+1) { |
| var integer vl_currentSize := sizeof(v_EPTF_ExecCtrl_TimeProfileList); |
| v_EPTF_ExecCtrl_TimeProfileList[vl_currentSize] := pl_EPTF_ExecCtrl_TimeProfileList[i]; |
| } |
| // load pl_EPTF_ExecCtrl_TimeProfile2TcList: |
| for(var integer i:=0, size := sizeof(pl_EPTF_ExecCtrl_TimeProfile2TcList); i<size; i:=i+1) { |
| var integer vl_currentSize := sizeof(v_EPTF_ExecCtrl_TimeProfile2TcList); |
| v_EPTF_ExecCtrl_TimeProfile2TcList[vl_currentSize] := pl_EPTF_ExecCtrl_TimeProfile2TcList[i]; |
| } |
| |
| // load pl_EPTF_LGenBase_ScenarioTypeDeclaratorList: |
| for(var integer i:=0, size := sizeof(pl_EPTF_LGenBase_ScenarioTypeDeclaratorList); i<size; i:=i+1) { |
| var integer vl_currentSize := sizeof(v_ExecCtrl_ScenarioDeclaratorsR3); |
| v_ExecCtrl_ScenarioDeclaratorsR3[vl_currentSize] := pl_EPTF_LGenBase_ScenarioTypeDeclaratorList[i]; |
| } |
| // load pl_EPTF_ExecCtrl_ScenarioInstanceTypeList: |
| for(var integer i:=0, size := sizeof(pl_EPTF_ExecCtrl_ScenarioInstanceTypeList); i<size; i:=i+1) { |
| var integer vl_currentSize := sizeof(v_ExecCtrl_scenario2EntityGroups); |
| v_ExecCtrl_scenario2EntityGroups[vl_currentSize] := pl_EPTF_ExecCtrl_ScenarioInstanceTypeList[i]; |
| } |
| |
| // load pl_EPTF_ExecCtrl_LGenPool_Declarators: |
| for(var integer i:=0, size := sizeof(pl_EPTF_ExecCtrl_LGenPool_Declarators); i<size; i:=i+1) { |
| var integer vl_currentSize := sizeof(v_EPTF_ExecCtrl_LGenPool_Declarators); |
| v_EPTF_ExecCtrl_LGenPool_Declarators[vl_currentSize] := pl_EPTF_ExecCtrl_LGenPool_Declarators[i]; |
| } |
| // load pl_EPTF_ExecCtrl_EntityGroup2LGenPool_List: |
| for(var integer i:=0, size := sizeof(pl_EPTF_ExecCtrl_EntityGroup2LGenPool_List); i<size; i:=i+1) { |
| var integer vl_currentSize := sizeof(v_EPTF_ExecCtrl_EntityGroup2LGenPools); |
| v_EPTF_ExecCtrl_EntityGroup2LGenPools[vl_currentSize] := pl_EPTF_ExecCtrl_EntityGroup2LGenPool_List[i]; |
| } |
| |
| // load pl_EPTF_ExecCtrl_LGenFunction_Entry_List: |
| for(var integer i:=0, size := sizeof(pl_EPTF_ExecCtrl_LGenFunction_Entry_List); i<size; i:=i+1) { |
| var integer vl_currentSize := sizeof(v_EPTF_ExecCtrl_lgenCreatorFn_list); |
| v_EPTF_ExecCtrl_lgenCreatorFn_list[vl_currentSize] := pl_EPTF_ExecCtrl_LGenFunction_Entry_List[i]; |
| } |
| |
| // load pl_EPTF_ExecCtrl_PhaseList_Declarators: |
| for(var integer i:=0, size := sizeof(pl_EPTF_ExecCtrl_PhaseList_Declarators); i<size; i:=i+1) { |
| var integer vl_currentSize := sizeof(v_EPTF_ExecCtrl_PhaseList_Declarators); |
| v_EPTF_ExecCtrl_PhaseList_Declarators[vl_currentSize] := pl_EPTF_ExecCtrl_PhaseList_Declarators[i]; |
| } |
| // load pl_EPTF_ExecCtrl_PhaseList_Declarators: |
| for(var integer i:=0, size := sizeof(pl_EPTF_ExecCtrl_ScenarioGroup_Declarators); i<size; i:=i+1) { |
| var integer vl_currentSize := sizeof(v_EPTF_ExecCtrl_ScenarioGroup_Declarators); |
| v_EPTF_ExecCtrl_ScenarioGroup_Declarators[vl_currentSize] := pl_EPTF_ExecCtrl_ScenarioGroup_Declarators[i]; |
| } |
| |
| // load pl_EPTF_ExecCtrl_RegulatorNames: |
| for(var integer i:=0, size := sizeof(pl_EPTF_ExecCtrl_RegulatorNames); i<size; i:=i+1) { |
| var integer vl_currentSize := sizeof(v_EPTF_ExecCtrl_RegulatorNames); |
| v_EPTF_ExecCtrl_RegulatorNames[vl_currentSize] := pl_EPTF_ExecCtrl_RegulatorNames[i]; |
| } |
| // load pl_EPTF_ExecCtrl_RegulatedItems: |
| for(var integer i:=0, size := sizeof(pl_EPTF_ExecCtrl_RegulatedItems); i<size; i:=i+1) { |
| var integer vl_currentSize := sizeof(v_EPTF_ExecCtrl_RegulatedItemsCFG); |
| v_EPTF_ExecCtrl_RegulatedItemsCFG[vl_currentSize] := pl_EPTF_ExecCtrl_RegulatedItems[i]; |
| } |
| |
| // load pl_EPTF_ExecCtrl_EntityGroupDistributionTypeList: |
| for(var integer i:=0, size := sizeof(pl_EPTF_ExecCtrl_EntityGroupDistributionTypeList); i<size; i:=i+1) { |
| var integer vl_currentSize := sizeof(v_EPTF_ExecCtrl_entityGroupDistributionCFG); |
| v_EPTF_ExecCtrl_entityGroupDistributionCFG[vl_currentSize] := pl_EPTF_ExecCtrl_EntityGroupDistributionTypeList[i]; |
| } |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_setTimeFormat |
| // |
| // Purpose: |
| // Sets the timeformat for the timeElapsed variable |
| // |
| // Parameters: |
| // in <EPTF_ExecCtrl_timeFormat> pl_timeFormat : the new timeformat to set |
| // |
| // Return Value: |
| // |
| // Errors & assertions: |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_ExecCtrl_setTimeFormat(in EPTF_ExecCtrl_timeFormat pl_timeFormat) runs on EPTF_ExecCtrl_CT { |
| v_EPTF_ExecCtrl_timeFormat := pl_timeFormat; |
| } |
| |
| private function f_EPTF_ExecCtrl_handleLoadConfig(in EPTF_ExecCtrlClient_CT pl_client, in EPTF_ExecCtrlClient_LoadConfig pl_config) runs on EPTF_ExecCtrl_CT { |
| if (v_ExecCtrl_started) { |
| f_EPTF_ExecCtrl_warning(log2str(%definitionId&": Config received from ",pl_client," not loaded: ExecCtrl was already started. Config ignored: ", pl_config)); |
| return; |
| } |
| f_EPTF_ExecCtrl_loadConfig( |
| pl_config.pl_EPTF_LGenBase_TcMgmt_EntityGrpDeclaratorList, |
| pl_config.pl_EPTF_LGenBase_TcMgmt_Scenarios2GrpList, |
| |
| pl_config.pl_EPTF_LGenBase_ScenarioDeclaratorList, |
| pl_config.pl_EPTF_LGenBase_tcTypeDeclaratorList, |
| |
| pl_config.pl_EPTF_LGenBase_TcMgmt_tcTypeDeclaratorList, |
| pl_config.pl_EPTF_LGenBase_TcMgmt_ScenarioDeclaratorList, |
| |
| pl_config.pl_EPTF_LGenBase_TcMgmt_WeightedScenarioDeclaratorList, |
| |
| pl_config.pl_EPTF_ExecCtrl_TimeProfileDescrList, |
| pl_config.pl_EPTF_ExecCtrl_TimeProfileList, |
| pl_config.pl_EPTF_ExecCtrl_TimeProfile2TcList, |
| |
| pl_config.pl_EPTF_LGenBase_ScenarioTypeDeclaratorList, |
| pl_config.pl_EPTF_ExecCtrl_ScenarioInstanceTypeList, |
| |
| pl_config.pl_EPTF_ExecCtrl_LGenPool_Declarators, |
| pl_config.pl_EPTF_ExecCtrl_EntityGroup2LGenPool_List, |
| |
| {},//pl_config.pl_EPTF_ExecCtrl_LGenFunction_Entry_List, |
| |
| pl_config.pl_EPTF_ExecCtrl_PhaseList_Declarators, |
| pl_config.pl_EPTF_ExecCtrl_ScenarioGroup_Declarators, |
| |
| pl_config.pl_EPTF_ExecCtrl_RegulatorNames, |
| pl_config.pl_EPTF_ExecCtrl_RegulatedItems, |
| |
| pl_config.pl_EPTF_ExecCtrl_EntityGroupDistributionTypeList |
| ); |
| } |
| |
| private altstep as_EPTF_ExecCtrl_MgmtIf_handleLoadConfig() runs on EPTF_ExecCtrl_CT { |
| var EPTF_ExecCtrlClient_CT vl_client; |
| var EPTF_ExecCtrlClient_LoadConfig v_msg; |
| [] ExecCtrl_MgmtIf_CP.receive(EPTF_ExecCtrlClient_LoadConfig:?) -> value v_msg sender vl_client { |
| f_EPTF_ExecCtrl_debug("DEBUG: EPTF_ExecCtrlClient_LoadConfig received..."); |
| f_EPTF_ExecCtrl_handleLoadConfig(vl_client,v_msg); |
| repeat; |
| } |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_initSc2grp |
| // |
| // Purpose: |
| // Preprocess <v_ExecCtrl_Scenarios2Grps> -> Only one scenario will be associated to each entityGrp |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // - |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // |
| // |
| /////////////////////////////////////////////////////////// |
| private function f_EPTF_ExecCtrl_initSc2grp()runs on EPTF_ExecCtrl_CT { |
| var EPTF_LGenBase_TcMgmt_Scenarios2GrpList v_ExecCtrl_Scenarios2Grps_orig := v_ExecCtrl_Scenarios2Grps; |
| v_ExecCtrl_Scenarios2Grps := {}; |
| var integer vl_grp := 0; |
| for(var integer i:=0, size := sizeof(v_ExecCtrl_Scenarios2Grps_orig); i<size; i:=i+1) { |
| for(var integer j:=0, sizej := sizeof(v_ExecCtrl_Scenarios2Grps_orig[i].scenarioNames); j<sizej; j:=j+1) { |
| v_ExecCtrl_Scenarios2Grps[vl_grp] := { |
| v_ExecCtrl_Scenarios2Grps_orig[i].eGrpName, |
| { v_ExecCtrl_Scenarios2Grps_orig[i].scenarioNames[j] } |
| }; |
| vl_grp := vl_grp + 1; |
| } |
| } |
| } |
| |
| group TimeProfile { |
| |
| |
| // uses modulepar EPTF_ExecCtrl_TimeProfileDescrList tsp_EPTF_ExecCtrl_TimeProfileDescrList := {}; |
| // and modulepar EPTF_ExecCtrl_TimeProfile2TcList tsp_EPTF_ExecCtrl_TimeProfile2TcList := {}; |
| // to initialize the v_EPTF_ExecCtrl_ScTimeProfileListDB database |
| // only declarator2 is supported |
| private function f_EPTF_ExecCtrl_initScTimeProfileListDB() runs on EPTF_ExecCtrl_CT { |
| v_EPTF_ExecCtrl_ScTimeProfileDB := {}; |
| // going through the scenario instances: |
| for (var integer sidx := 0, size := sizeof(v_ExecCtrl_scenarios); sidx < size; sidx := sidx + 1) |
| { |
| var integer vl_sizeTCs := sizeof(v_ExecCtrl_scenarios[sidx].scData.tcList); |
| if (f_EPTF_ExecCtrl_isWeightedScenario(sidx)) { |
| vl_sizeTCs := 1; |
| } |
| for (var integer tcidx := 0; tcidx < vl_sizeTCs; tcidx := tcidx + 1) |
| { |
| if (f_EPTF_ExecCtrl_isWeightedScenario(sidx)) { |
| f_EPTF_ExecCtrl_initProfileForSc(/*grp,*/sidx); |
| } else { |
| f_EPTF_ExecCtrl_initProfileForTc(/*grp,*/sidx,tcidx); |
| } |
| |
| } |
| } |
| |
| f_EPTF_ExecCtrl_debug(log2str("v_EPTF_ExecCtrl_TimeProfile2TcList: ", v_EPTF_ExecCtrl_TimeProfile2TcList)); |
| f_EPTF_ExecCtrl_debug(log2str("v_EPTF_ExecCtrl_TimeProfileDescrList: ", v_EPTF_ExecCtrl_TimeProfileDescrList)); |
| f_EPTF_ExecCtrl_debug(log2str("v_EPTF_ExecCtrl_ScTimeProfileDB: ", v_EPTF_ExecCtrl_ScTimeProfileDB)); |
| } |
| |
| // initializes the time profile database for a traffic case |
| private function f_EPTF_ExecCtrl_initProfileForTc( |
| // in integer grp, |
| in integer sidx, |
| in integer tcidx |
| ) runs on EPTF_ExecCtrl_CT { |
| |
| v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx] := { |
| timeProfileIdList := {}, |
| timeProfileIdx := -1, |
| eventIdList := {} |
| }; // time prof not defined for this TC |
| |
| var charstring vl_tcName := f_EPTF_LGenBase_tcNameOfTcOfSc(v_ExecCtrl_scenarios[sidx].scData,tcidx) |
| var EPTF_ExecCtrl_TCName tcId := { |
| eGrpName := v_ExecCtrl_entityGroups[v_ExecCtrl_scenarios[sidx].eGroupIdx].name, |
| scName := v_ExecCtrl_scenarios[sidx].scData.name, |
| tcName := vl_tcName |
| } |
| |
| // find time profile for this tc: |
| for (var integer i:=0, size := sizeof(v_EPTF_ExecCtrl_TimeProfile2TcList); i<size; i:=i+1) { |
| // if (v_EPTF_ExecCtrl_TimeProfile2TcList[i].tcId == tcId) { // this is syntactically erroneous |
| if (v_EPTF_ExecCtrl_TimeProfile2TcList[i].tcId.eGrpName == tcId.eGrpName |
| and v_EPTF_ExecCtrl_TimeProfile2TcList[i].tcId.scName == tcId.scName |
| and v_EPTF_ExecCtrl_TimeProfile2TcList[i].tcId.tcName == tcId.tcName) { |
| // time prof found |
| // find the time profile data: |
| var integer vl_timeProfileIdx := -1; |
| for (var integer tpIdx := 0, sizet := sizeof(v_EPTF_ExecCtrl_TimeProfileList); tpIdx<sizet; tpIdx:=tpIdx+1) { |
| if (v_EPTF_ExecCtrl_TimeProfileList[tpIdx].name == v_EPTF_ExecCtrl_TimeProfile2TcList[i].timeProfileName) { |
| vl_timeProfileIdx := tpIdx; |
| break; |
| } |
| } |
| |
| if(vl_timeProfileIdx == -1){ |
| f_EPTF_ExecCtrl_error(%definitionId&": Unable to find the time profile " &v_EPTF_ExecCtrl_TimeProfile2TcList[i].timeProfileName&" in v_EPTF_ExecCtrl_TimeProfileList"); |
| } |
| |
| v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].timeProfileIdx := vl_timeProfileIdx; |
| |
| // search time profile data for each profile in the list: |
| for(var integer k:=0, sizek := sizeof(v_EPTF_ExecCtrl_TimeProfileList[vl_timeProfileIdx].timeProfileList); k<sizek; k:=k+1) { |
| for(var integer j:=0, sizej := sizeof(v_EPTF_ExecCtrl_TimeProfileDescrList); j<sizej; j:=j+1) { |
| if (v_EPTF_ExecCtrl_TimeProfileDescrList[j].name == v_EPTF_ExecCtrl_TimeProfileList[vl_timeProfileIdx].timeProfileList[k].timeProfileDescrName) { |
| // time profile found: |
| // append data into DB: |
| var integer vl_currentSize := sizeof(v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].timeProfileIdList); |
| v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].timeProfileIdList[vl_currentSize] := j; |
| v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].eventIdList[vl_currentSize] := -1; // no event yet |
| break; |
| } |
| } |
| } |
| break; |
| } |
| } |
| |
| } |
| |
| // initializes the time profile database for a weighted scenario |
| private function f_EPTF_ExecCtrl_initProfileForSc( |
| // in integer grp, |
| in integer sidx |
| ) runs on EPTF_ExecCtrl_CT { |
| |
| var integer tcidx := 0; // tc 0 will contain the time profile data for the scenario CPS |
| v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx] := { |
| timeProfileIdList := {}, |
| timeProfileIdx := -1, |
| eventIdList := {} |
| }; // time prof not defined for this TC |
| |
| var EPTF_ExecCtrl_SCName tcId := { |
| eGrpName := v_ExecCtrl_entityGroups[v_ExecCtrl_scenarios[sidx].eGroupIdx].name, |
| scName := v_ExecCtrl_scenarios[sidx].scData.name |
| } |
| |
| // find time profile for this tc: |
| for (var integer i:=0, size := sizeof(v_EPTF_ExecCtrl_TimeProfile2TcList); i<size; i:=i+1) { |
| // if (v_EPTF_ExecCtrl_TimeProfile2TcList[i].tcId == tcId) { // this is syntactically erroneous |
| // TCName ignored in timeProfile data, because it is a weighted scenario! |
| if (v_EPTF_ExecCtrl_TimeProfile2TcList[i].tcId.eGrpName == tcId.eGrpName |
| and v_EPTF_ExecCtrl_TimeProfile2TcList[i].tcId.scName == tcId.scName) { |
| // time prof found |
| // find the time profile data: |
| var integer vl_timeProfileIdx := -1; |
| for (var integer tpIdx :=0, sizet := sizeof(v_EPTF_ExecCtrl_TimeProfileList); tpIdx<sizet; tpIdx:=tpIdx+1) { |
| if (v_EPTF_ExecCtrl_TimeProfileList[tpIdx].name == v_EPTF_ExecCtrl_TimeProfile2TcList[i].timeProfileName) { |
| vl_timeProfileIdx := tpIdx; |
| break; |
| } |
| } |
| |
| f_EPTF_Base_assert(%definitionId&": Unable to find the time profile " &v_EPTF_ExecCtrl_TimeProfile2TcList[i].timeProfileName&" in v_EPTF_ExecCtrl_TimeProfileList", vl_timeProfileIdx!=-1); |
| |
| v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].timeProfileIdx := vl_timeProfileIdx; |
| |
| // search time profile data for each profile in the list: |
| for(var integer k:=0, sizek := sizeof(v_EPTF_ExecCtrl_TimeProfileList[vl_timeProfileIdx].timeProfileList); k<sizek; k:=k+1) { |
| for(var integer j:=0, sizej := sizeof(v_EPTF_ExecCtrl_TimeProfileDescrList); j<sizej; j:=j+1) { |
| if (v_EPTF_ExecCtrl_TimeProfileDescrList[j].name == v_EPTF_ExecCtrl_TimeProfileList[vl_timeProfileIdx].timeProfileList[k].timeProfileDescrName) { |
| // time profile found: |
| // append data into DB: |
| var integer vl_currentSize := sizeof(v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].timeProfileIdList); |
| v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].timeProfileIdList[vl_currentSize] := j; |
| v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].eventIdList[vl_currentSize] := -1; // no event yet |
| break; |
| } |
| } |
| } |
| break; |
| } |
| } |
| |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_getTimeProfileNameForTC |
| // |
| // Purpose: |
| // Returns the time profile name for a traffic case instance |
| // |
| // Parameters: |
| // pl_scIdx - *in integer* - the scenario instance idx |
| // pl_tcOfScIdx - *in integer* - the traffic case index in the scenario |
| // |
| // Return Value: |
| // charstring - name of the time profile ("" if no time profile is set) |
| // |
| // Errors & assertions: |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| friend function f_EPTF_ExecCtrl_getTimeProfileNameForTC( |
| in integer pl_scIdx, |
| in integer pl_tcOfScIdx |
| ) runs on EPTF_ExecCtrl_CT return charstring { |
| var charstring vl_timeProfileName := "" |
| if (v_EPTF_ExecCtrl_ScTimeProfileDB[pl_scIdx].tcTimeProfile[pl_tcOfScIdx].timeProfileIdx != -1) { |
| vl_timeProfileName := v_EPTF_ExecCtrl_TimeProfileList[v_EPTF_ExecCtrl_ScTimeProfileDB[pl_scIdx].tcTimeProfile[pl_tcOfScIdx].timeProfileIdx].name; |
| } |
| return vl_timeProfileName; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_startTimeProfiles |
| // |
| // Purpose: |
| // Starts all time profiles by scheduling their first event |
| // |
| // Parameters: |
| // |
| // Return Value: |
| // |
| // Errors & assertions: |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_ExecCtrl_startTimeProfiles() runs on EPTF_ExecCtrl_CT { |
| |
| v_EPTF_ExecCtrl_startTime := T_EPTF_componentClock.read; // read the scheduler clock to store the time of start |
| for (var integer sidx := 0, size := sizeof(v_EPTF_ExecCtrl_ScTimeProfileDB); sidx < size; sidx := sidx + 1) |
| { |
| for (var integer tcidx := 0, tsize := sizeof(v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile); tcidx < tsize; tcidx := tcidx + 1) |
| { |
| f_EPTF_ExecCtrl_startProfileForTc(/*grp,*/sidx,tcidx); |
| |
| } |
| } |
| |
| f_EPTF_ExecCtrl_debug("**********TIMEPROF STARTED*************"); |
| f_EPTF_ExecCtrl_debug(log2str("v_EPTF_ExecCtrl_ScTimeProfileDB after start: ", v_EPTF_ExecCtrl_ScTimeProfileDB)); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_stopTimeProfiles |
| // |
| // Purpose: |
| // stops the time profile execution |
| // |
| // Parameters: |
| // |
| // Return Value: |
| // |
| // Errors & assertions: |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_ExecCtrl_stopTimeProfiles() runs on EPTF_ExecCtrl_CT { |
| v_EPTF_ExecCtrl_startTime := -1.0; // this value is used to ignore additional time profile events |
| |
| for (var integer sidx := 0, size := sizeof(v_EPTF_ExecCtrl_ScTimeProfileDB); sidx < size; sidx := sidx + 1) |
| { |
| for (var integer tcidx := 0, tsize := sizeof(v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile); tcidx < tsize; tcidx := tcidx + 1) |
| { |
| // here you should include your code: |
| |
| for (var integer i:=0, lsize := sizeof(v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].timeProfileIdList); i<lsize; i:=i+1) { |
| var integer vl_eventIndex := v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].eventIdList[i]; |
| // Cancel the event: |
| if (vl_eventIndex !=-1) { |
| if(not f_EPTF_SchedulerComp_CancelEvent(vl_eventIndex)) { |
| f_EPTF_ExecCtrl_warning(%definitionId& ": could not cancel event."); |
| } |
| v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].eventIdList[i] := -1; |
| } |
| } // end of for i |
| } |
| } |
| f_EPTF_ExecCtrl_debug("**********TIMEPROF STOPPED*************"); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_startTime |
| // |
| // Purpose: |
| // Returns the start time of the test execution |
| // |
| // Parameters: |
| // |
| // Return Value: |
| // float - the start time (-1.0 if not running) |
| // |
| // Errors & assertions: |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| friend function f_EPTF_ExecCtrl_startTime() runs on EPTF_ExecCtrl_CT return float { |
| return v_EPTF_ExecCtrl_startTime; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_startAllScenarios |
| // |
| // Purpose: |
| // Starts all scenarios in ExecCtrl |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // - |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // Starts all enabled scenarios. Also starts scenario groups |
| // and time profiles |
| // |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_ExecCtrl_startAllScenarios() runs on EPTF_ExecCtrl_CT |
| { |
| for(var integer sc:=0, size := sizeof(v_ExecCtrl_scenarios); sc<size; sc:=sc+1) { |
| f_EPTF_ExecCtrl_debug(%definitionId&": Checking scenario status"); |
| var integer vl_eGrpIdx := v_ExecCtrl_scenarios[sc].eGroupIdx; |
| var charstring eGrpName := v_ExecCtrl_entityGroups[vl_eGrpIdx].name; |
| var charstring scenName := v_ExecCtrl_scenarios[sc].scData.name; |
| |
| if (f_EPTF_ExecCtrl_checkScenarioStatus({ |
| eGrpName := eGrpName, |
| scName := scenName |
| }, |
| t_ExecCtrl_scenarioReadyToStart)) |
| { |
| f_EPTF_ExecCtrl_debug(log2str( |
| "Scenario: {", eGrpName, |
| ", ", scenName, |
| " is ready to start")); |
| |
| // Start scenario on LGens |
| if (f_EPTF_ExecCtrl_scenarioEnabled(sc) |
| and f_EPTF_ExecCtrl_scenarioIsNotInScenarioGroup(sc)) { |
| f_EPTF_ExecCtrl_startScenarioOnLGens(sc); |
| } |
| } |
| else { |
| f_EPTF_ExecCtrl_debug(log2str( |
| "Scenario: {", eGrpName, |
| ", ", scenName, |
| " is NOT ready to start")); |
| |
| //return |
| } |
| } |
| |
| f_EPTF_ExecCtrl_startAllScenarioGroups(); |
| |
| // f_EPTF_Logging_debug(tsp_debug_EPTF_ExecCtrl_UIVars, |
| // "All scenarios are ready to run"); |
| |
| // start the time profiles: |
| f_EPTF_ExecCtrl_startTimeProfiles(); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_startAllScenarioGroups |
| // |
| // Purpose: |
| // Starts all scenarios in ExecCtrl that are in scenario groups |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // - |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_ExecCtrl_startAllScenarioGroups() runs on EPTF_ExecCtrl_CT { |
| for(var integer scGroupIdx :=0, size := sizeof(v_ExecCtrl_ScenarioGroupInstanceDB.data); scGroupIdx<size; scGroupIdx:=scGroupIdx+1) { |
| f_EPTF_ExecCtrl_ScenarioGroup_start(scGroupIdx); |
| } |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_stopCurrentPhaseForAllScenarioGroups |
| // |
| // Purpose: |
| // Starts all scenarios in ExecCtrl that are in scenario groups |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // - |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_ExecCtrl_stopCurrentPhaseForAllScenarioGroups() runs on EPTF_ExecCtrl_CT { |
| for(var integer scGroupIdx :=0, size := sizeof(v_ExecCtrl_ScenarioGroupInstanceDB.data); scGroupIdx<size; scGroupIdx:=scGroupIdx+1) { |
| f_EPTF_ExecCtrl_ScenarioGroup_stop(scGroupIdx); |
| } |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_stopAllScenarioGroups |
| // |
| // Purpose: |
| // Stops all scenario groups |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // - |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_ExecCtrl_stopAllScenarioGroups() runs on EPTF_ExecCtrl_CT { |
| for(var integer scGroupIdx :=0, size := sizeof(v_ExecCtrl_ScenarioGroupInstanceDB.data); scGroupIdx<size; scGroupIdx:=scGroupIdx+1) { |
| f_EPTF_ExecCtrl_ScenarioGroup_stop(scGroupIdx); |
| } |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_terminateAllScenarioGroups |
| // |
| // Purpose: |
| // Terminates all scenario groups |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // - |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // Stops all scenario groups so that the phase actions |
| // are not executed, all scenarios in the scenario groups |
| // are stopped. |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_ExecCtrl_terminateAllScenarioGroups() runs on EPTF_ExecCtrl_CT { |
| for(var integer scGroupIdx :=0, size := sizeof(v_ExecCtrl_ScenarioGroupInstanceDB.data); scGroupIdx<size; scGroupIdx:=scGroupIdx+1) { |
| f_EPTF_ExecCtrl_stopScenarioGroupOnLGens(scGroupIdx); |
| } |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_stopAllScenarios |
| // |
| // Purpose: |
| // Stops all scenarios in ExecCtrl |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // - |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // Also stops time profiles and scenario groups. |
| // |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_ExecCtrl_stopAllScenarios() runs on EPTF_ExecCtrl_CT { |
| // stop the time profiles: |
| f_EPTF_ExecCtrl_stopTimeProfiles(); |
| |
| // stop scenario groups |
| f_EPTF_ExecCtrl_stopAllScenarioGroups(); |
| |
| // Stop scenarios |
| for(var integer sc:=0, size := sizeof(v_ExecCtrl_scenarios); sc<size; sc:=sc+1) { |
| f_EPTF_ExecCtrl_debug(%definitionId&": Checking scenario status"); |
| var integer vl_eGrpIdx := v_ExecCtrl_scenarios[sc].eGroupIdx; |
| var charstring eGrpName := v_ExecCtrl_entityGroups[vl_eGrpIdx].name; |
| var charstring scenName := v_ExecCtrl_scenarios[sc].scData.name; |
| |
| if (f_EPTF_ExecCtrl_checkScenarioStatus({ |
| eGrpName := eGrpName, |
| scName := scenName |
| }, |
| t_ExecCtrl_scenarioReadyToStop)) |
| { |
| f_EPTF_ExecCtrl_debug(log2str( |
| "Scenario: {", eGrpName, |
| ", ", scenName, |
| " is ready to stop")); |
| |
| if (f_EPTF_ExecCtrl_scenarioIsNotInScenarioGroup(sc)) { |
| f_EPTF_ExecCtrl_stopScenarioOnLGens(sc); |
| } |
| |
| } |
| else { |
| f_EPTF_ExecCtrl_debug(log2str( |
| "Scenario: {", eGrpName, |
| ", ", scenName, |
| " is NOT ready to stop")); |
| |
| //return |
| } |
| } |
| |
| |
| // f_EPTF_Logging_debug(tsp_debug_EPTF_ExecCtrl_UIVars, |
| // "DEBUG: all scenarios are ready to stop"); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_terminateAllScenarios |
| // |
| // Purpose: |
| // Terminates all scenarios in ExecCtrl |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // - |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // Also stops time profiles and terminates scenario groups. |
| // Normal scenarios are stopped the same way as in |
| // <f_EPTF_ExecCtrl_stopAllScenarios> |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_ExecCtrl_terminateAllScenarios() runs on EPTF_ExecCtrl_CT { |
| // stop the time profiles: |
| f_EPTF_ExecCtrl_stopTimeProfiles(); |
| |
| // terminate scenario groups |
| f_EPTF_ExecCtrl_terminateAllScenarioGroups(); |
| |
| // Stop scenarios |
| for(var integer sc:=0, size := sizeof(v_ExecCtrl_scenarios); sc<size; sc:=sc+1) { |
| f_EPTF_ExecCtrl_debug(%definitionId&": Checking scenario status"); |
| var integer vl_eGrpIdx := v_ExecCtrl_scenarios[sc].eGroupIdx; |
| var charstring eGrpName := v_ExecCtrl_entityGroups[vl_eGrpIdx].name; |
| var charstring scenName := v_ExecCtrl_scenarios[sc].scData.name; |
| |
| if (f_EPTF_ExecCtrl_checkScenarioStatus({ |
| eGrpName := eGrpName, |
| scName := scenName |
| }, |
| t_ExecCtrl_scenarioReadyToStop)) |
| { |
| f_EPTF_ExecCtrl_debug(log2str( |
| "Scenario: {", eGrpName, |
| ", ", scenName, |
| " is ready to stop")); |
| |
| if (f_EPTF_ExecCtrl_scenarioIsNotInScenarioGroup(sc)) { |
| f_EPTF_ExecCtrl_stopScenarioOnLGens(sc); |
| } |
| |
| } |
| else { |
| f_EPTF_ExecCtrl_debug(log2str( |
| "Scenario: {", eGrpName, |
| ", ", scenName, |
| " is NOT ready to stop")); |
| |
| //return |
| } |
| } |
| |
| |
| // f_EPTF_Logging_debug(tsp_debug_EPTF_ExecCtrl_UIVars, |
| // "DEBUG: all scenarios are ready to stop"); |
| } |
| |
| // starts a time profile by scheduling its first event |
| // only one event is running for each profile at a time. counters and data are passed in the eventId |
| private function f_EPTF_ExecCtrl_startProfileForTc( |
| // in integer grp, |
| in integer sidx, |
| in integer tcidx |
| ) runs on EPTF_ExecCtrl_CT { |
| |
| var integer timeProfileDataPos := 0; // current position in timeProfileData |
| var integer nofRepetition := 0; // current nofRepetition |
| |
| // go through in the list of time profiles for this Tc: |
| for (var integer i:=0, size := sizeof(v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].timeProfileIdList); i<size; i:=i+1) { |
| // schedule the first event: |
| f_EPTF_ExecCtrl_TimeProfile_ScheduleEvent(sidx,tcidx,i,timeProfileDataPos,nofRepetition); |
| } // end of for i |
| |
| } |
| |
| // handles the time profile event |
| private function f_EPTF_ExecCtrl_TimeProfileEventHandler( |
| in EPTF_ScheduledAction pl_action, in integer pl_eventIndex |
| ) runs on EPTF_ExecCtrl_CT return boolean { |
| f_EPTF_ExecCtrl_debug(log2str(%definitionId&": pl_action being handled: ", pl_action)); |
| |
| if (v_EPTF_ExecCtrl_startTime == -1.0) { |
| f_EPTF_ExecCtrl_debug("TimeProfile execution was stopped, event ignored."); |
| return true; // do not handle the event |
| } |
| |
| var integer sidx := pl_action.actionId[0]; |
| var integer tcidx := pl_action.actionId[1]; |
| var integer i := pl_action.actionId[2]; |
| var integer timeProfileDataPos := pl_action.actionId[3]; |
| var integer nofRepetition := pl_action.actionId[4]; |
| |
| |
| var integer vl_timeProfileIdx := v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].timeProfileIdx; |
| var integer vl_timeProfileId := v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].timeProfileIdList[i]; |
| |
| // set CPS: |
| var float targetValue := f_EPTF_ExecCtrl_getTimeProfileTargetValue(sidx,tcidx,i,timeProfileDataPos); |
| if (f_EPTF_ExecCtrl_isWeightedScenario(sidx)) { |
| f_EPTF_ExecCtrl_setCps_SC(sidx,targetValue); |
| } else { |
| f_EPTF_ExecCtrl_setCps_TC(sidx,tcidx,targetValue); |
| } |
| |
| //reschedule event: |
| timeProfileDataPos := timeProfileDataPos + 1; |
| // end of time profile reached: |
| if (timeProfileDataPos==sizeof(v_EPTF_ExecCtrl_TimeProfileDescrList[vl_timeProfileId].timeProfileData)) { |
| // increase repetition: |
| nofRepetition := nofRepetition + 1; |
| // restore position to the beginning: |
| timeProfileDataPos := 0; |
| } |
| |
| // max repetition reached (-1: will continue to infty): |
| // (repetition reaches maxRepetition+1: the profile executed maxRepetition times + the first execution) |
| if (v_EPTF_ExecCtrl_TimeProfileList[vl_timeProfileIdx].timeProfileList[i].nofRepetition != -1 |
| and nofRepetition == v_EPTF_ExecCtrl_TimeProfileList[vl_timeProfileIdx].timeProfileList[i].nofRepetition + 1) { |
| v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].eventIdList[i] := -1; // reset the event id |
| return true; // no more event scheduled |
| } |
| |
| // schedule the new event: |
| f_EPTF_ExecCtrl_TimeProfile_ScheduleEvent(sidx,tcidx,i,timeProfileDataPos,nofRepetition); |
| |
| return true; |
| } |
| |
| // schedules the time profile event |
| private function f_EPTF_ExecCtrl_TimeProfile_ScheduleEvent( |
| // in integer grp, |
| in integer sidx, |
| in integer tcidx, |
| in integer tpidx, // index in v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].timeProfileIdList |
| in integer timeProfileDataPos, |
| in integer nofRepetition |
| ) runs on EPTF_ExecCtrl_CT { |
| var integer vl_timeProfileIdx := v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].timeProfileIdx; |
| var integer vl_timeProfileId := v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].timeProfileIdList[tpidx]; |
| |
| // f_EPTF_ExecCtrl_debug(log2str("vl_timeProfileIdx: ", vl_timeProfileIdx)); |
| // f_EPTF_ExecCtrl_debug(log2str("v_EPTF_ExecCtrl_TimeProfileList[vl_timeProfileIdx]: ", v_EPTF_ExecCtrl_TimeProfileList[vl_timeProfileIdx])); |
| // f_EPTF_ExecCtrl_debug(log2str("vl_timeProfileId: ", vl_timeProfileId)); |
| // f_EPTF_ExecCtrl_debug(log2str("v_EPTF_ExecCtrl_TimeProfileDescrList[vl_timeProfileId]: ", v_EPTF_ExecCtrl_TimeProfileDescrList[vl_timeProfileId])); |
| |
| var float vl_when := v_EPTF_ExecCtrl_startTime + |
| v_EPTF_ExecCtrl_TimeProfileList[vl_timeProfileIdx].timeProfileList[tpidx].startTime |
| + v_EPTF_ExecCtrl_TimeProfileDescrList[vl_timeProfileId].timeProfileData[timeProfileDataPos].time |
| + int2float(nofRepetition)*v_EPTF_ExecCtrl_TimeProfileList[vl_timeProfileIdx].timeProfileList[tpidx].periodOfRepetition; |
| var EPTF_Scheduler_ActionHandler vl_actionHandler := refers(f_EPTF_ExecCtrl_TimeProfileEventHandler); |
| var EPTF_ActionId vl_action := { |
| //grp, |
| sidx, |
| tcidx, |
| tpidx, // index in v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].timeProfileIdList |
| timeProfileDataPos, // index in v_EPTF_ExecCtrl_TimeProfileDescrList[vl_timeProfileId].timeProfileData |
| nofRepetition // current nofRepetition |
| }; |
| |
| f_EPTF_ExecCtrl_debug(log2str("scheduling action: ", vl_action, " to: ", vl_when)); |
| |
| var integer vl_eventIndex; |
| if (f_EPTF_SchedulerComp_scheduleAction( |
| vl_when, |
| vl_actionHandler, |
| vl_action, |
| vl_eventIndex |
| )) {}; // to remove the warning |
| |
| // store event idx: |
| v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].eventIdList[tpidx] := vl_eventIndex; |
| |
| f_EPTF_ExecCtrl_debug(log2str("v_EPTF_ExecCtrl_ScTimeProfileDB[",sidx,"].tcTimeProfile[",tcidx,"] after schedule: ", v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx])); |
| } |
| |
| // gets the target value from time profile data for a Traffic Case |
| private function f_EPTF_ExecCtrl_getTimeProfileTargetValue ( |
| // in integer grp, |
| in integer sidx, |
| in integer tcidx, |
| in integer i, |
| in integer timeProfileDataPos |
| ) runs on EPTF_ExecCtrl_CT return float { |
| var integer vl_timeProfileId := v_EPTF_ExecCtrl_ScTimeProfileDB[sidx].tcTimeProfile[tcidx].timeProfileIdList[i]; |
| return v_EPTF_ExecCtrl_TimeProfileDescrList[vl_timeProfileId].timeProfileData[timeProfileDataPos].targetValue; |
| } |
| |
| } // group TimeProfile |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_setCps_TC |
| // |
| // Purpose: |
| // sets the Traffic case CPS in all related LGens |
| // |
| // Parameters: |
| // pl_scIdx - *in integer* - the scenario instace idx |
| // pl_tcOfScIdx - *in integer* - the tc of scenario idx |
| // cps - *in float* - CPS to set |
| // |
| // Return Value: |
| // |
| // Errors & assertions: |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_ExecCtrl_setCps_TC ( |
| // in integer grp, |
| in integer pl_scIdx, |
| in integer pl_tcOfScIdx, |
| in float cps |
| ) runs on EPTF_ExecCtrl_CT { |
| f_EPTF_Base_assert(%definitionId&": Invalid SC index "&int2str(pl_scIdx)& |
| ". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_scenarios))&").", |
| pl_scIdx >= 0 and pl_scIdx < sizeof(v_ExecCtrl_scenarios)); |
| f_EPTF_Base_assert(%definitionId&": Invalid tcOfScenario index "&int2str(pl_tcOfScIdx)& |
| ". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_scenarios[pl_scIdx].scData.tcList))&").", |
| pl_tcOfScIdx >= 0 and pl_tcOfScIdx < sizeof(v_ExecCtrl_scenarios[pl_scIdx].scData.tcList)); |
| f_EPTF_Base_assert(%definitionId&": Cannot set traffic case CPS in the weighted scenario "& |
| v_ExecCtrl_scenarios[pl_scIdx].name, |
| not f_EPTF_ExecCtrl_isWeightedScenario(pl_scIdx)); |
| |
| var integer vl_tcIdx :=v_ExecCtrl_scenarios[pl_scIdx].tcIdxList[pl_tcOfScIdx]; |
| f_EPTF_ExecCtrl_setCPSToReach_TC(vl_tcIdx,cps); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_setCps_SC |
| // |
| // Purpose: |
| // sets the Scenario CPS in all related LGens |
| // |
| // Parameters: |
| // pl_scIdx - *in integer* - the scenario instace idx |
| // cps - *in float* - CPS to set |
| // |
| // Return Value: |
| // |
| // Errors & assertions: |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_ExecCtrl_setCps_SC ( |
| // in integer grp, |
| in integer pl_scIdx, |
| in float cps |
| ) runs on EPTF_ExecCtrl_CT { |
| f_EPTF_ExecCtrl_setCPSToReach_SC(pl_scIdx,cps); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_setStartDelay_TC |
| // |
| // Purpose: |
| // sets the Traffic case startDelay in all related LGens |
| // |
| // Parameters: |
| // pl_scIdx - *in integer* - the scenario instace idx |
| // pl_tcOfScIdx - *in integer* - the tc of scenario idx |
| // startDelay - *in float* - startDelay to set |
| // |
| // Return Value: |
| // |
| // Errors & assertions: |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_ExecCtrl_setStartDelay_TC ( |
| // in integer grp, |
| in integer pl_scIdx, |
| in integer pl_tcOfScIdx, |
| in float pl_startDelay |
| ) runs on EPTF_ExecCtrl_CT { |
| f_EPTF_Base_assert(%definitionId&": Invalid SC index "&int2str(pl_scIdx)& |
| ". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_scenarios))&").", |
| pl_scIdx >= 0 and pl_scIdx < sizeof(v_ExecCtrl_scenarios)); |
| f_EPTF_Base_assert(%definitionId&": Invalid tcOfScenario index "&int2str(pl_tcOfScIdx)& |
| ". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_scenarios[pl_scIdx].scData.tcList))&").", |
| pl_tcOfScIdx >= 0 and pl_tcOfScIdx < sizeof(v_ExecCtrl_scenarios[pl_scIdx].scData.tcList)); |
| f_EPTF_Base_assert(%definitionId&": Cannot set traffic case StartDelay in the weighted scenario "& |
| v_ExecCtrl_scenarios[pl_scIdx].name, |
| not f_EPTF_ExecCtrl_isWeightedScenario(pl_scIdx)); |
| |
| v_ExecCtrl_scenarios[pl_scIdx].scData.tcList[pl_tcOfScIdx].startDelay := pl_startDelay; |
| f_EPTF_ExecCtrl_debug(log2str("updated v_ExecCtrl_scenarios[",pl_scIdx,"].scData.tcList[",pl_tcOfScIdx,"].startDelay: ", pl_startDelay)); |
| |
| f_EPTF_ExecCtrl_sendUpdatedStartDelay(pl_scIdx,pl_tcOfScIdx); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_getCPSToReach_TC |
| // |
| // Purpose: |
| // returns the target CPS of a traffic case instance |
| // |
| // Parameters: |
| // pl_tcIdx - *in integer* - id of the traffic case instance |
| // |
| // Return Value: |
| // float - the targetCPS (i.e. the cpsToReach) of the traffic case |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_ExecCtrl_getCPSToReach_TC( |
| in integer pl_tcIdx |
| ) runs on EPTF_ExecCtrl_CT return float { |
| f_EPTF_Base_assert(%definitionId&": Invalid TC index "&int2str(pl_tcIdx)& |
| ". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_trafficCases))&").", |
| pl_tcIdx >= 0 and pl_tcIdx < sizeof(v_ExecCtrl_trafficCases)); |
| var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioIdxForTc(pl_tcIdx); |
| f_EPTF_Base_assert(%definitionId&": cpsToReach is not available for the traffic case "& |
| f_EPTF_ExecCtrl_getTrafficCaseName(pl_tcIdx)&": traffic case is in a weighted scenario: " |
| &f_EPTF_ExecCtrl_getScenarioInstanceName(vl_scIdx), |
| not f_EPTF_ExecCtrl_isWeightedScenario(vl_scIdx)); |
| var integer vl_tcOfScIdx := v_ExecCtrl_trafficCases[pl_tcIdx].tcOfScenarioIdx; |
| return v_ExecCtrl_scenarios[vl_scIdx].scData.tcList[vl_tcOfScIdx].target.cpsToReach; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_setCPSToReach_TC |
| // |
| // Purpose: |
| // Sets the target CPS of a traffic case instance |
| // |
| // Parameters: |
| // pl_tcIdx - *in integer* - id of the traffic case instance |
| // pl_cpsToReach - *in float* - the targetCPS (i.e. the cpsToReach) to set |
| // |
| // Return Value: |
| // - |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_ExecCtrl_setCPSToReach_TC( |
| in integer pl_tcIdx, |
| in float pl_cpsToReach |
| ) runs on EPTF_ExecCtrl_CT { |
| f_EPTF_Base_assert(%definitionId&": Invalid TC index "&int2str(pl_tcIdx)& |
| ". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_trafficCases))&").", |
| pl_tcIdx >= 0 and pl_tcIdx < sizeof(v_ExecCtrl_trafficCases)); |
| var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioIdxForTc(pl_tcIdx); |
| f_EPTF_Base_assert(%definitionId&": Cannot set cpsToReach for the traffic case "& |
| f_EPTF_ExecCtrl_getTrafficCaseName(pl_tcIdx)&": traffic case is in a weighted scenario: " |
| &f_EPTF_ExecCtrl_getScenarioInstanceName(vl_scIdx), |
| not f_EPTF_ExecCtrl_isWeightedScenario(vl_scIdx)); |
| |
| var integer vl_tcOfScIdx := v_ExecCtrl_trafficCases[pl_tcIdx].tcOfScenarioIdx; |
| v_ExecCtrl_scenarios[vl_scIdx].scData.tcList[vl_tcOfScIdx].target.cpsToReach := pl_cpsToReach; |
| |
| f_EPTF_ExecCtrl_debug(log2str("updated v_ExecCtrl_scenarios[",vl_scIdx,"].scData.tcList[",vl_tcOfScIdx,"].target.cpsToReach: ", v_ExecCtrl_scenarios[vl_scIdx].scData.tcList[vl_tcOfScIdx].target.cpsToReach)); |
| f_EPTF_ExecCtrl_sendUpdatedCps(vl_scIdx,vl_tcOfScIdx); |
| f_EPTF_ExecCtrl_callCPSChangedCallbacks_TC(pl_cpsToReach,v_ExecCtrl_scenarios[vl_scIdx].tcIdxList[vl_tcOfScIdx]); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_getCPSToReach_SC |
| // |
| // Purpose: |
| // returns the target CPS of a scenario instance |
| // |
| // Parameters: |
| // pl_scIdx - *in integer* - id of the scenario instance |
| // |
| // Return Value: |
| // float - the targetCPS (i.e. the cpsToReach) of the scenario |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_ExecCtrl_getCPSToReach_SC( |
| in integer pl_scIdx |
| ) runs on EPTF_ExecCtrl_CT return float { |
| f_EPTF_Base_assert(%definitionId&": Invalid SC index "&int2str(pl_scIdx)& |
| ". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_scenarios))&").", |
| pl_scIdx >= 0 and pl_scIdx < sizeof(v_ExecCtrl_scenarios)); |
| f_EPTF_Base_assert(%definitionId&": CPSToReach is not available for non-weighted scenario: " |
| &f_EPTF_ExecCtrl_getScenarioInstanceName(pl_scIdx), |
| f_EPTF_ExecCtrl_isWeightedScenario(pl_scIdx)); |
| return v_ExecCtrl_scenarios[pl_scIdx].scData.weightedScData.cpsToReach; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_setCPSToReach_SC |
| // |
| // Purpose: |
| // Sets the target CPS of a scenario instance |
| // |
| // Parameters: |
| // pl_scIdx - *in integer* - id of the scenario instance |
| // pl_cpsToReach - *in float* - the targetCPS (i.e. the cpsToReach) to set |
| // |
| // Return Value: |
| // float - the targetCPS (i.e. the cpsToReach) of the scenario |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_ExecCtrl_setCPSToReach_SC( |
| in integer pl_scIdx, |
| in float pl_cpsToReach |
| ) runs on EPTF_ExecCtrl_CT { |
| f_EPTF_Base_assert(%definitionId&": Invalid SC index "&int2str(pl_scIdx)& |
| ". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_scenarios))&").", |
| pl_scIdx >= 0 and pl_scIdx < sizeof(v_ExecCtrl_scenarios)); |
| f_EPTF_Base_assert(%definitionId&": Cannot set scenario CPS in the non-weighted scenario "& |
| v_ExecCtrl_scenarios[pl_scIdx].name, |
| f_EPTF_ExecCtrl_isWeightedScenario(pl_scIdx)); |
| |
| v_ExecCtrl_scenarios[pl_scIdx].scData.weightedScData.cpsToReach := pl_cpsToReach; |
| |
| f_EPTF_ExecCtrl_debug(log2str("updated v_ExecCtrl_scenarios[",pl_scIdx,"].scData.weightedScData.cpsToReach: ", v_ExecCtrl_scenarios[pl_scIdx].scData.weightedScData.cpsToReach)); |
| f_EPTF_ExecCtrl_sendUpdatedScenarioCps(pl_scIdx); |
| f_EPTF_ExecCtrl_callCPSChangedCallbacks_SC(pl_cpsToReach,pl_scIdx); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_getTCWeight |
| // |
| // Purpose: |
| // returns the weight of the traffic case instance in the weighted scenario |
| // |
| // Parameters: |
| // pl_tcIdx - *in integer* - id of the traffic case instance |
| // |
| // Return Value: |
| // float - the tcWeight of the traffic case |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_ExecCtrl_getTCWeight( |
| in integer pl_tcIdx |
| ) runs on EPTF_ExecCtrl_CT return float { |
| f_EPTF_Base_assert(%definitionId&": Invalid index "&int2str(pl_tcIdx)& |
| ". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_trafficCases))&").", |
| pl_tcIdx >= 0 and pl_tcIdx < sizeof(v_ExecCtrl_trafficCases)); |
| var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioIdxForTc(pl_tcIdx); |
| f_EPTF_Base_assert(%definitionId&": Traffic case weight is not available for the traffic case "& |
| f_EPTF_ExecCtrl_getTrafficCaseName(pl_tcIdx)&": traffic case is not in a weighted scenario: " |
| &f_EPTF_ExecCtrl_getScenarioInstanceName(vl_scIdx), |
| f_EPTF_ExecCtrl_isWeightedScenario(vl_scIdx)); |
| var integer vl_tcOfScIdx := v_ExecCtrl_trafficCases[pl_tcIdx].tcOfScenarioIdx; |
| return v_ExecCtrl_scenarios[vl_scIdx].scData.tcList[vl_tcOfScIdx].target.trafficWeight; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_setTCWeight |
| // |
| // Purpose: |
| // Sets the weight of the traffic case instance in the weighted scenario |
| // |
| // Parameters: |
| // pl_tcIdx - *in integer* - id of the traffic case instance |
| // pl_tcWeight - *in float* - the weight of the traffic case |
| // |
| // Return Value: |
| // - |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_ExecCtrl_setTCWeight( |
| in integer pl_tcIdx, |
| in float pl_tcWeight |
| ) runs on EPTF_ExecCtrl_CT { |
| f_EPTF_Base_assert(%definitionId&": Invalid index "&int2str(pl_tcIdx)& |
| ". Valid index range: (0.."&int2str(sizeof(v_ExecCtrl_trafficCases))&").", |
| pl_tcIdx >= 0 and pl_tcIdx < sizeof(v_ExecCtrl_trafficCases)); |
| var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioIdxForTc(pl_tcIdx); |
| f_EPTF_Base_assert(%definitionId&": Traffic case weight is not available for the traffic case "& |
| f_EPTF_ExecCtrl_getTrafficCaseName(pl_tcIdx)&": traffic case is not in a weighted scenario: " |
| &f_EPTF_ExecCtrl_getScenarioInstanceName(vl_scIdx), |
| f_EPTF_ExecCtrl_isWeightedScenario(vl_scIdx)); |
| var integer vl_tcOfScIdx := v_ExecCtrl_trafficCases[pl_tcIdx].tcOfScenarioIdx; |
| v_ExecCtrl_scenarios[vl_scIdx].scData.tcList[vl_tcOfScIdx].target.trafficWeight := pl_tcWeight; |
| f_EPTF_ExecCtrl_sendUpdatedCps(vl_scIdx,vl_tcOfScIdx); |
| } |
| |
| group EPTF_ExecCtrl_Regulator { |
| |
| /////////////////////////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_getRegulatorNameVarName |
| // |
| // Purpose: |
| // Gives back the RegulatorName Variable Name from the idName and the regulatedItemData in hash. |
| // |
| // Parameters: |
| // pl_idName - *in* <EPTF_ExecCtrl_RegulatedItemName> - Regulated Item Name |
| // pl_regulatedItemDataIdInHash - *in* *integer* - regulatedItemData hash id |
| // |
| // Return Value: |
| // *charstring* - Variable name of RegulatorName |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| // |
| /////////////////////////////////////////////////////////////////////////////// |
| friend function f_EPTF_ExecCtrl_getRegulatorNameVarName(in EPTF_ExecCtrl_RegulatedItemName pl_idName, |
| in integer pl_regulatedItemDataIdInHash) |
| runs on EPTF_ExecCtrl_CT |
| return charstring{ |
| var EPTF_ExecCtrl_RegulatedItemId vl_regulatedItemData := f_EPTF_ExecCtrl_Regulator_getRegulatedItemDataById(pl_regulatedItemDataIdInHash); |
| // Regulator name |
| if (ischosen(pl_idName.cps_TC)) { |
| // "SC2." & "Traffic.Regulator." & grpName&"."& int2str(sidx) & "." & int2str(tcidx); |
| return "Traffic.Regulator." & |
| pl_idName.cps_TC.eGrpName |
| &"."&int2str(vl_regulatedItemData.cps_TC.scenidx) |
| &"."&int2str(vl_regulatedItemData.cps_TC.tcidx); |
| } |
| if (ischosen(pl_idName.cps_SC)) { |
| // "Traffic.Regulator." & grpName&"."& int2str(sidx); |
| return "Traffic.Regulator." & |
| pl_idName.cps_SC.eGrpName |
| &"."&int2str(vl_regulatedItemData.cps_SC.scenidx); |
| } |
| if (ischosen(pl_idName.cps_TCInPhase)) { |
| // "SC2." & "Traffic.Regulator." & grpName&"."& int2str(sidx) & "." & int2str(tcidx); |
| return "Traffic.Regulator." & |
| pl_idName.cps_TCInPhase.eGrpName |
| &"."&int2str(vl_regulatedItemData.cps_TCInPhase.scenidx) |
| &"."&int2str(vl_regulatedItemData.cps_TCInPhase.tcidx) |
| &".InPhase."&vl_regulatedItemData.cps_TCInPhase.phase; |
| } |
| if (ischosen(pl_idName.cps_SCInPhase)) { |
| // "Traffic.Regulator." & grpName&"."& int2str(sidx); |
| return "Traffic.Regulator." & |
| pl_idName.cps_SCInPhase.eGrpName |
| &"."&int2str(vl_regulatedItemData.cps_SCInPhase.scenidx) |
| &".InPhase."&vl_regulatedItemData.cps_SCInPhase.phase; |
| } |
| return ""; |
| } |
| |
| |
| // initializes the EPTF_ExecCtrl_Regulator, this is the main init function |
| private function f_EPTF_ExecCtrl_Regulator_init(in EPTF_CharstringList pl_regulatorNames, in EPTF_ExecCtrl_RegulatedItems pl_EPTF_ExecCtrl_RegulatedItems) runs on EPTF_ExecCtrl_CT { |
| f_EPTF_ExecCtrl_Regulator_initRegulators(pl_regulatorNames); |
| f_EPTF_ExecCtrl_Regulator_initRegulateditems(pl_EPTF_ExecCtrl_RegulatedItems); |
| f_EPTF_ExecCtrl_registerScenarioStateChangedCallback(refers(f_EPTF_ExecCtrl_Regulator_scenarioStateChangedCallback)); |
| f_EPTF_ExecCtrl_registerScenarioGroupPhaseChangedCallback(refers(f_EPTF_ExecCtrl_Regulator_scenarioGroupPhaseChangedCallback)); |
| f_EPTF_ExecCtrl_registerTrafficCaseStateChangedCallback(refers(f_EPTF_ExecCtrl_Regulator_trafficCaseStateChangedCallback)); |
| } |
| |
| // initializes v_EPTF_ExecCtrl_Regulators |
| private function f_EPTF_ExecCtrl_Regulator_initRegulators(in EPTF_CharstringList pl_regulatorNames) runs on EPTF_ExecCtrl_CT { |
| v_EPTF_ExecCtrl_Regulators := {}; |
| for(var integer i:=0, size := sizeof(pl_regulatorNames); i<size; i:=i+1) { |
| var integer vl_regulatorId := f_EPTF_ExecCtrl_Regulator_addRegulator(pl_regulatorNames[i]); |
| } |
| f_EPTF_ExecCtrl_debug(log2str("v_EPTF_ExecCtrl_Regulators: ", v_EPTF_ExecCtrl_Regulators)); |
| } |
| |
| // initializes the regulator database by adding the new regulated items |
| private function f_EPTF_ExecCtrl_Regulator_initRegulateditems(in EPTF_ExecCtrl_RegulatedItems pl_EPTF_ExecCtrl_RegulatedItems) runs on EPTF_ExecCtrl_CT { |
| v_EPTF_ExecCtrl_RegulatedItems := {}; |
| v_EPTF_ExecCtrl_RegulatedItemIdsDB := {}; |
| for(var integer i:=0, size := sizeof(pl_EPTF_ExecCtrl_RegulatedItems); i<size; i:=i+1) { |
| if (-1==f_EPTF_ExecCtrl_Regulator_addRegulatedItem( |
| pl_EPTF_ExecCtrl_RegulatedItems[i].idName, |
| pl_EPTF_ExecCtrl_RegulatedItems[i].regulatorName, |
| pl_EPTF_ExecCtrl_RegulatedItems[i].weight, |
| pl_EPTF_ExecCtrl_RegulatedItems[i].enabled |
| )) {/*to remove the warning*/}; |
| } |
| |
| var integer vl_sizeScen := f_EPTF_ExecCtrl_numScenarios(); |
| var integer vl_sizeTCs; |
| |
| for (var integer sidx := 0; sidx < vl_sizeScen; sidx := sidx + 1) |
| { |
| var integer vl_eGrpIdx := f_EPTF_ExecCtrl_getScenarioEGroupIdx(sidx); |
| var charstring grpName := f_EPTF_ExecCtrl_eGrp_name(vl_eGrpIdx); |
| var charstring scenName := f_EPTF_ExecCtrl_getScenarioName(sidx); |
| vl_sizeTCs := f_EPTF_ExecCtrl_numTcOfScenario(sidx); |
| for (var integer tcidx := 0; tcidx < vl_sizeTCs; tcidx := tcidx + 1) |
| { |
| var charstring tcName := f_EPTF_ExecCtrl_tcNameOfTcOfSc(sidx,tcidx) |
| var charstring vl_regulatorName := ""; |
| var EPTF_ExecCtrl_RegulatedItemName vl_idName; |
| var integer vl_scGrpidx := f_EPTF_ExecCtrl_ScenarioGroup_get_byScIndex(sidx); |
| if (vl_scGrpidx==-1) { |
| if (f_EPTF_ExecCtrl_isWeightedScenario(sidx)) { |
| vl_idName := {cps_SC := {grpName,scenName}}; |
| } else { |
| vl_idName := {cps_TC := {grpName,scenName,tcName}}; |
| } |
| } else { |
| // for scenarios in scenario groups: it shows the regulator in the current phase |
| var EPTF_ExecCtrl_PhaseList_Instance phaseList := f_EPTF_ExecCtrl_getScenarioGroupInstanceGroupPhaseList(vl_scGrpidx); |
| |
| // create variables for all phases: |
| for(var integer ph:=0; ph<f_EPTF_ExecCtrl_getScenarioGroupInstanceGroupPhaseListPhasesNum(vl_scGrpidx); ph:=ph+1) { |
| var charstring vl_phaseName := f_EPTF_ExecCtrl_getScenarioGroupInstanceGroupPhaseListPhaseName(vl_scGrpidx,ph); |
| if (f_EPTF_ExecCtrl_isWeightedScenario(sidx)) { |
| vl_idName := {cps_SCInPhase := {grpName,scenName, vl_phaseName}}; |
| } else { |
| vl_idName := {cps_TCInPhase := {grpName,scenName,tcName, vl_phaseName}}; |
| } |
| var integer vl_regulatedItemId := f_EPTF_ExecCtrl_Regulator_getRegulatedItemId(vl_idName); |
| if (vl_regulatedItemId==-1) { |
| // add new regulated item: |
| vl_regulatedItemId := f_EPTF_ExecCtrl_Regulator_addRegulatedItem(vl_idName,""); |
| } |
| } |
| // put regulator in CURRENT PHASE to the GUI: |
| var charstring vl_phaseName := f_EPTF_ExecCtrl_getScenarioGroupInstanceActualPhaseName(vl_scGrpidx); |
| if (f_EPTF_ExecCtrl_isWeightedScenario(sidx)) { |
| vl_idName := {cps_SCInPhase := {grpName,scenName, vl_phaseName}}; |
| } else { |
| vl_idName := {cps_TCInPhase := {grpName,scenName,tcName, vl_phaseName}}; |
| } |
| } |
| var integer vl_regulatedItemId := f_EPTF_ExecCtrl_Regulator_getRegulatedItemId(vl_idName); |
| if (vl_regulatedItemId==-1) { |
| // add new regulated item: |
| vl_regulatedItemId := f_EPTF_ExecCtrl_Regulator_addRegulatedItem(vl_idName,""); |
| } |
| } |
| } |
| |
| if(c_EPTF_Common_debugSwitch and f_EPTF_ExecCtrl_debugEnabled()) { |
| f_EPTF_ExecCtrl_debug("Regulator database initialized."); |
| f_EPTF_ExecCtrl_Regulator_logAll(); |
| } |
| } |
| |
| // start/stop relevant regulators if phase of the scenario group changes |
| private function f_EPTF_ExecCtrl_Regulator_scenarioGroupPhaseChangedCallback(in charstring pl_sgName, in integer pl_actualPhaseIdx) runs on EPTF_ExecCtrl_CT { |
| var integer vl_sgIdx := f_EPTF_ExecCtrl_ScenarioGroup_getIdx(pl_sgName); |
| |
| // start/stop regulators for all scenarios and traffic cases in the scenario group: |
| for (var integer i:=0, size := sizeof(v_ExecCtrl_ScenarioGroupInstanceDB.data[vl_sgIdx].scenarios); i<size; i:=i+1) { |
| var integer vl_scIdx := v_ExecCtrl_ScenarioGroupInstanceDB.data[vl_sgIdx].scenarios[i].idx; |
| |
| var integer vl_eGrpIdx := v_ExecCtrl_scenarios[vl_scIdx].eGroupIdx; |
| |
| var charstring vl_eGrpName := v_ExecCtrl_entityGroups[vl_eGrpIdx].name; |
| var charstring vl_scenName := v_ExecCtrl_scenarios[vl_scIdx].scData.name; |
| f_EPTF_ExecCtrl_Regulator_scenarioStateChangedCallback(vl_eGrpName,vl_scenName, ""); |
| // go through all traffic cases |
| for (var integer tcOfSc:=0; tcOfSc<f_EPTF_ExecCtrl_numTcOfScenario(vl_scIdx); tcOfSc:=tcOfSc+1) { |
| var charstring vl_tcName := f_EPTF_LGenBase_tcNameOfTcOfSc(v_ExecCtrl_scenarios[vl_scIdx].scData,tcOfSc); |
| f_EPTF_ExecCtrl_Regulator_trafficCaseStateChangedCallback(vl_eGrpName,vl_scenName,vl_tcName,""); |
| } |
| } |
| } |
| |
| // check if the regulators belonging this scenario should be enabled/disabled and enable/disable them |
| private function f_EPTF_ExecCtrl_Regulator_scenarioStateChangedCallback(in charstring pl_eGrpName, in charstring pl_scName, in charstring pl_state) runs on EPTF_ExecCtrl_CT { |
| // find the regulators that regulate items in the current scenario: |
| var EPTF_IntegerList vl_regulatorIdxList := {}; |
| f_EPTF_ExecCtrl_Regulator_findRegulatorsForScenario(pl_eGrpName,pl_scName,vl_regulatorIdxList); |
| |
| for(var integer i:=0, size := sizeof(vl_regulatorIdxList); i<size; i:=i+1) { |
| f_EPTF_ExecCtrl_Regulator_startStop(vl_regulatorIdxList[i]); |
| } |
| } |
| |
| // check if the regulators belonging this traffic case should be enabled/disabled and enable/disable them |
| private function f_EPTF_ExecCtrl_Regulator_trafficCaseStateChangedCallback(in charstring pl_eGrpName, in charstring pl_scName, in charstring pl_tcName, in charstring pl_state) runs on EPTF_ExecCtrl_CT { |
| // find the regulators that regulate items in the current scenario: |
| var EPTF_IntegerList vl_regulatorIdxList := {}; |
| f_EPTF_ExecCtrl_Regulator_findRegulatorsForTrafficCase(pl_eGrpName,pl_scName,pl_tcName,vl_regulatorIdxList); |
| |
| for(var integer i:=0, size := sizeof(vl_regulatorIdxList); i<size; i:=i+1) { |
| f_EPTF_ExecCtrl_Regulator_startStop(vl_regulatorIdxList[i]); |
| } |
| } |
| |
| // if the status of the regulator changes to connected, check if the regulator should be enabled/disabled and enable/disable it |
| private function f_EPTF_ExecCtrl_Regulator_statusChangePostProc( |
| in integer pl_idx, |
| in EPTF_IntegerList pl_argList) |
| runs on EPTF_ExecCtrl_CT { |
| if (not v_ExecCtrl_initialized) { |
| return; |
| } |
| var integer vl_regulatorId := pl_argList[0]; |
| |
| var integer vl_regulatorStatusIdx := f_EPTF_ExecCtrl_Regulator_getRegulatorStatusIdxByRegulatorId(vl_regulatorId); |
| if (vl_regulatorStatusIdx!=-1) { |
| var EPTF_StatusLED vl_regulatorStatus := f_EPTF_Var_getStatusLEDValue(vl_regulatorStatusIdx); |
| if (vl_regulatorStatus == {led_yellow, "Registering..."}) { |
| var integer vl_regulatorCompRefInt := float2int(f_EPTF_Var_getFloatValue(v_EPTF_ExecCtrl_Regulators[vl_regulatorId].currentLoadIdx)+0.1); |
| if (vl_regulatorCompRefInt!=0) { |
| var charstring vl_regulatorName := f_EPTF_ExecCtrl_Regulator_getRegulatorNameByRegulatorId(vl_regulatorId); |
| var EPTF_Var_CT vl_regulatorCompRef := f_EPTF_Var_downcast(f_EPTF_Base_downcast(vl_regulatorCompRefInt)); |
| f_EPTF_ExecCtrl_debug(%definitionId&"Regulator """&vl_regulatorName&""" is connected, initializing variables..."); |
| |
| f_EPTF_Var_setSubsCanAdjust(v_EPTF_ExecCtrl_Regulators[vl_regulatorId].totalValueIdx,false); |
| f_EPTF_Var_setSubsCanAdjust(v_EPTF_ExecCtrl_Regulators[vl_regulatorId].targetLoadIdx,true); |
| |
| var charstring vl_currentName := "EPTF_LoadRegulator."&c_EPTF_ExecCtrl_Regulator_totalValue&"."&vl_regulatorName; |
| f_EPTF_Var_resubscribeRemote(vl_regulatorCompRef,vl_currentName,realtime,v_EPTF_ExecCtrl_Regulators[vl_regulatorId].totalValueIdx); |
| vl_currentName := "EPTF_LoadRegulator."&c_EPTF_ExecCtrl_Regulator_targetLoad&"."&vl_regulatorName; |
| f_EPTF_Var_resubscribeRemote(vl_regulatorCompRef,vl_currentName,realtime,v_EPTF_ExecCtrl_Regulators[vl_regulatorId].targetLoadIdx); |
| vl_currentName := "EPTF_LoadRegulator."&c_EPTF_ExecCtrl_Regulator_currentLoad&"."&vl_regulatorName; |
| f_EPTF_Var_resubscribeRemote(vl_regulatorCompRef,vl_currentName,realtime,v_EPTF_ExecCtrl_Regulators[vl_regulatorId].currentLoadIdx); |
| vl_currentName := "EPTF_LoadRegulator."&c_EPTF_ExecCtrl_Regulator_status&"."&vl_regulatorName; |
| f_EPTF_Var_resubscribeRemote(vl_regulatorCompRef,vl_currentName,realtime,v_EPTF_ExecCtrl_Regulators[vl_regulatorId].statusIdx); |
| vl_currentName := "EPTF_LoadRegulator."&c_EPTF_ExecCtrl_Regulator_enable&"."&vl_regulatorName; |
| f_EPTF_Var_resubscribeRemote(vl_regulatorCompRef,vl_currentName,realtime,v_EPTF_ExecCtrl_Regulators[vl_regulatorId].enableIdx); |
| } |
| } |
| else if (vl_regulatorStatus == {led_green, "Connected"}) { |
| f_EPTF_ExecCtrl_debug(%definitionId&"Regulator is connected, checking if it should be started"); |
| f_EPTF_ExecCtrl_Regulator_startStop(vl_regulatorId); |
| |
| } else if (vl_regulatorStatus == {led_red, "Disconnected"}) { |
| f_EPTF_ExecCtrl_debug(%definitionId&"Regulator is disconnected"); |
| |
| f_EPTF_Var_unsubscribe(v_EPTF_ExecCtrl_Regulators[vl_regulatorId].totalValueIdx); |
| f_EPTF_Var_unsubscribe(v_EPTF_ExecCtrl_Regulators[vl_regulatorId].targetLoadIdx); |
| f_EPTF_Var_unsubscribe(v_EPTF_ExecCtrl_Regulators[vl_regulatorId].currentLoadIdx); |
| f_EPTF_Var_unsubscribe(v_EPTF_ExecCtrl_Regulators[vl_regulatorId].statusIdx); |
| f_EPTF_Var_unsubscribe(v_EPTF_ExecCtrl_Regulators[vl_regulatorId].enableIdx); |
| f_EPTF_Var_setSubsCanAdjust(v_EPTF_ExecCtrl_Regulators[vl_regulatorId].totalValueIdx,true); |
| f_EPTF_Var_setSubsCanAdjust(v_EPTF_ExecCtrl_Regulators[vl_regulatorId].targetLoadIdx,false); |
| } |
| } |
| } |
| |
| // the the regulated item to v_EPTF_ExecCtrl_RegulatedItemIdsDB for fast access |
| private function f_EPTF_ExecCtrl_Regulator_addToRegulatedItemIdsDB(in integer pl_regulatedItemId) runs on EPTF_ExecCtrl_CT { |
| // determinde egrpidx,scenidx,tcidx: |
| // currently egrpIdx is not used!!! |
| v_EPTF_ExecCtrl_RegulatedItemIdsDB[pl_regulatedItemId] := f_EPTF_ExecCtrl_Regulator_itemName2ItemId(v_EPTF_ExecCtrl_RegulatedItems[pl_regulatedItemId].idName); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_Regulator_addRegulator |
| // |
| // Purpose: |
| // creates a regulator and returns the id of the regulator, |
| // if the regulator exists already, it returns its idx |
| // |
| // Parameters: |
| // pl_regulatorName - *in charstring* - the name of the regulator |
| // |
| // Return Value: |
| // integer - id of the regulator |
| // |
| // Errors & assertions: |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_ExecCtrl_Regulator_addRegulator(in charstring pl_regulatorName) runs on EPTF_ExecCtrl_CT return integer { |
| if (pl_regulatorName == "") { |
| return -1; // empty name is not allowed |
| } |
| var integer vl_regulatorId := f_EPTF_ExecCtrl_Regulator_getRegulatorId(pl_regulatorName); |
| if (vl_regulatorId != -1) { |
| return vl_regulatorId; // regulator already registered |
| } |
| // add to regulator database: |
| vl_regulatorId := sizeof(v_EPTF_ExecCtrl_Regulators); |
| v_EPTF_ExecCtrl_Regulators[vl_regulatorId] := {pl_regulatorName, {}, 0,0,0,0,0}; |
| |
| // create an EPTF Variable that holds the targetValue: |
| var charstring vl_currentName := "EPTF_ExecCtrl."&c_EPTF_ExecCtrl_Regulator_totalValue&"."&pl_regulatorName; |
| f_EPTF_Var_newFloat( |
| vl_currentName, |
| 0.0, |
| v_EPTF_ExecCtrl_Regulators[vl_regulatorId].totalValueIdx |
| ); |
| f_EPTF_Var_addPostProcFn( |
| v_EPTF_ExecCtrl_Regulators[vl_regulatorId].totalValueIdx, { refers(f_EPTF_ExecCtrl_Regulator_updateTotalValue), {vl_regulatorId}} |
| ); |
| f_EPTF_ExecCtrl_debug(log2str("Variable created to set totalValue for regulator ",pl_regulatorName, " : ",vl_currentName)); |
| |
| // create an EPTF Variable that holds the targetLoad: |
| vl_currentName := "EPTF_ExecCtrl."&c_EPTF_ExecCtrl_Regulator_targetLoad&"."&pl_regulatorName; |
| f_EPTF_Var_newFloat( |
| vl_currentName, |
| 0.0, |
| v_EPTF_ExecCtrl_Regulators[vl_regulatorId].targetLoadIdx |
| ); |
| f_EPTF_Var_setSubsCanAdjust(v_EPTF_ExecCtrl_Regulators[vl_regulatorId].targetLoadIdx,false); |
| f_EPTF_ExecCtrl_debug(log2str("Variable created to set targetLoad for regulator ",pl_regulatorName, " : ",vl_currentName)); |
| |
| // create an EPTF Variable that holds the currentLoad: |
| vl_currentName := "EPTF_ExecCtrl."&c_EPTF_ExecCtrl_Regulator_currentLoad&"."&pl_regulatorName; |
| f_EPTF_Var_newFloat( |
| vl_currentName, |
| 0.0, |
| v_EPTF_ExecCtrl_Regulators[vl_regulatorId].currentLoadIdx |
| ); |
| f_EPTF_Var_setSubsCanAdjust(v_EPTF_ExecCtrl_Regulators[vl_regulatorId].currentLoadIdx,false); |
| f_EPTF_ExecCtrl_debug(log2str("Variable created to set currentLoad for regulator ",pl_regulatorName, " : ",vl_currentName)); |
| |
| // create an EPTF Variable that holds the status: |
| vl_currentName := "EPTF_ExecCtrl."&c_EPTF_ExecCtrl_Regulator_status&"."&pl_regulatorName; |
| f_EPTF_Var_newStatusLED( |
| vl_currentName, |
| {led_red, "Disconnected"}, |
| v_EPTF_ExecCtrl_Regulators[vl_regulatorId].statusIdx |
| ); |
| f_EPTF_Var_setSubsCanAdjust(v_EPTF_ExecCtrl_Regulators[vl_regulatorId].statusIdx,false); |
| f_EPTF_Var_addPostProcFn( |
| v_EPTF_ExecCtrl_Regulators[vl_regulatorId].statusIdx, { refers(f_EPTF_ExecCtrl_Regulator_statusChangePostProc), {vl_regulatorId}} |
| ); |
| // FIXME: refactor needed to be able to disable var here |
| //f_EPTF_Var_setSubsCanAdjust(v_EPTF_ExecCtrl_Regulators[vl_regulatorId].statusIdx,false); |
| f_EPTF_ExecCtrl_debug(log2str("Variable created to set status for regulator ",pl_regulatorName, " : ",vl_currentName)); |
| |
| // create an EPTF Variable that holds the enable: |
| vl_currentName := "EPTF_ExecCtrl."&c_EPTF_ExecCtrl_Regulator_enable&"."&pl_regulatorName; |
| f_EPTF_Var_newBool( |
| vl_currentName, |
| false, |
| v_EPTF_ExecCtrl_Regulators[vl_regulatorId].enableIdx |
| ); |
| f_EPTF_ExecCtrl_debug(log2str("Variable created to set the enable flag for regulator ",pl_regulatorName, " : ",vl_currentName)); |
| |
| return vl_regulatorId; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_Regulator_getRegulatorId |
| // |
| // Purpose: |
| // returns the id of the regulator in v_EPTF_ExecCtrl_Regulators (same as in v_EPTF_ExecCtrl_RegulatorNames) |
| // |
| // Parameters: |
| // pl_regulatorName - *in charstring* - the name of the regulator |
| // |
| // Return Value: |
| // integer - id of the regulator |
| // |
| // Errors & assertions: |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_ExecCtrl_Regulator_getRegulatorId(in charstring pl_regulatorName) runs on EPTF_ExecCtrl_CT return integer { |
| for(var integer i:=0, size := sizeof(v_EPTF_ExecCtrl_Regulators); i<size; i:=i+1) { |
| if (v_EPTF_ExecCtrl_Regulators[i].name == pl_regulatorName) { |
| return i; |
| } |
| } |
| return -1; // not found |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_Regulator_regulatorName |
| // |
| // Purpose: |
| // returns the name of the regulator from the index in v_EPTF_ExecCtrl_Regulators (same as in v_EPTF_ExecCtrl_RegulatorNames) |
| // |
| // Parameters: |
| // pl_regulatorId - *in integer* - the id of the regulator |
| // |
| // Return Value: |
| // charstring - name of the regulator ("" if not available) |
| // |
| // Errors & assertions: |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| friend function f_EPTF_ExecCtrl_Regulator_regulatorName(in integer pl_regulatorId) runs on EPTF_ExecCtrl_CT return charstring { |
| var charstring vl_regulatorName := ""; |
| if (0<=pl_regulatorId and pl_regulatorId<sizeof(v_EPTF_ExecCtrl_RegulatorNames)) { |
| vl_regulatorName := v_EPTF_ExecCtrl_RegulatorNames[pl_regulatorId]; |
| } |
| return vl_regulatorName; |
| } |
| |
| |
| friend function f_EPTF_ExecCtrl_Regulator_getNofRegulators() runs on EPTF_ExecCtrl_CT return integer { |
| return sizeof(v_EPTF_ExecCtrl_Regulators); |
| } |
| |
| friend function f_EPTF_ExecCtrl_Regulator_getRegulatorNameByRegulatorId(in integer pl_regulatorId) runs on EPTF_ExecCtrl_CT return charstring { |
| return v_EPTF_ExecCtrl_Regulators[pl_regulatorId].name; |
| } |
| |
| friend function f_EPTF_ExecCtrl_Regulator_getRegulatorTotalValueIdxByRegulatorId(in integer pl_regulatorId) runs on EPTF_ExecCtrl_CT return integer { |
| return v_EPTF_ExecCtrl_Regulators[pl_regulatorId].totalValueIdx; |
| } |
| |
| friend function f_EPTF_ExecCtrl_Regulator_getRegulatorTargetLoadIdxByRegulatorId(in integer pl_regulatorId) runs on EPTF_ExecCtrl_CT return integer { |
| return v_EPTF_ExecCtrl_Regulators[pl_regulatorId].targetLoadIdx; |
| } |
| |
| friend function f_EPTF_ExecCtrl_Regulator_getRegulatorCurrentLoadIdxByRegulatorId(in integer pl_regulatorId) runs on EPTF_ExecCtrl_CT return integer { |
| return v_EPTF_ExecCtrl_Regulators[pl_regulatorId].currentLoadIdx; |
| } |
| |
| friend function f_EPTF_ExecCtrl_Regulator_getRegulatorStatusIdxByRegulatorId(in integer pl_regulatorId) runs on EPTF_ExecCtrl_CT return integer { |
| return v_EPTF_ExecCtrl_Regulators[pl_regulatorId].statusIdx; |
| } |
| |
| // add a regulated item into the database, |
| // creates the regulator data if needed and registers the regulated item into the regulator, |
| // updates v_EPTF_ExecCtrl_RegulatedItemIdsDB also |
| friend function f_EPTF_ExecCtrl_Regulator_addRegulatedItem( |
| in EPTF_ExecCtrl_RegulatedItemName pl_idName, |
| in charstring pl_regulatorName, // name in EPTF_ExecCtrl_Regulators: this regulator regulates this item |
| in float pl_weight := 1.0, // used to determine part of the total value |
| in boolean pl_enabled := true // regulation enabled |
| ) runs on EPTF_ExecCtrl_CT |
| return integer |
| { |
| // if (pl_idName == "") { |
| // return -1; // empty name is not allowed |
| // } |
| // check if the regulated item exists: |
| var boolean vl_regulatedItemIsWeighted := false; |
| var charstring vl_errorMsg := "Cannot regulate the CPS of the traffic case in a weighted scenario."; |
| var charstring vl_eGrpName, vl_scName, vl_tcName; |
| var boolean vl_inPhase := false; // all phases |
| var charstring vl_phase; // unbound for all phases! |
| if (ischosen(pl_idName.cps_TC)) { |
| vl_eGrpName := pl_idName.cps_TC.eGrpName; |
| vl_scName := pl_idName.cps_TC.scName; |
| vl_tcName := pl_idName.cps_TC.tcName; |
| } else if (ischosen(pl_idName.cps_SC)) { |
| vl_regulatedItemIsWeighted := true; |
| vl_errorMsg := "Cannot regulate the CPS of a non-weighted scenario."; |
| vl_eGrpName := pl_idName.cps_SC.eGrpName; |
| vl_scName := pl_idName.cps_SC.scName; |
| } else if (ischosen(pl_idName.cps_TCInPhase)) { |
| vl_eGrpName := pl_idName.cps_TCInPhase.eGrpName; |
| vl_scName := pl_idName.cps_TCInPhase.scName; |
| vl_tcName := pl_idName.cps_TCInPhase.tcName; |
| vl_phase := pl_idName.cps_TCInPhase.phase; |
| vl_inPhase := true; |
| if (vl_phase=="") { |
| f_EPTF_ExecCtrl_error(%definitionId&": Invalid configuration data: Regulated item "&log2str(pl_idName)&" has no phase."); |
| } |
| } else if (ischosen(pl_idName.cps_SCInPhase)) { |
| vl_regulatedItemIsWeighted := true; |
| vl_errorMsg := "Cannot regulate the CPS of a non-weighted scenario."; |
| vl_eGrpName := pl_idName.cps_SCInPhase.eGrpName; |
| vl_scName := pl_idName.cps_SCInPhase.scName; |
| vl_phase := pl_idName.cps_SCInPhase.phase; |
| vl_inPhase := true; |
| if (vl_phase=="") { |
| f_EPTF_ExecCtrl_error(%definitionId&": Invalid configuration data: Regulated item "&log2str(pl_idName)&" has no phases."); |
| } |
| } |
| var integer vl_scIdx := f_EPTF_ExecCtrl_getScenarioIdxForScOfEGrp(vl_eGrpName,vl_scName); |
| if (vl_scIdx==-1) { |
| f_EPTF_ExecCtrl_error(%definitionId&": Invalid configuration data: Regulated item "&log2str(pl_idName)&" is not found in database." |
| &" Check the entity group- and scenario names."); |
| } |
| if (f_EPTF_ExecCtrl_isWeightedScenario(vl_scIdx)!=vl_regulatedItemIsWeighted) { |
| f_EPTF_ExecCtrl_error(%definitionId&": Invalid configuration data for the regulated item "&log2str(pl_idName)&": "&vl_errorMsg); |
| } |
| // The scenario groups are initialized by f_EPTF_ExecCtrl_Phase_createScenarioGroups, |
| // check if the phase regulation is consistent with scenario groups: |
| if (f_EPTF_ExecCtrl_scenarioIsNotInScenarioGroup(vl_scIdx) == vl_inPhase) { |
| vl_errorMsg := "Phase setting is not consistent with scenario: The scenario is not in a scenario group but phase is specified or vice versa." |
| f_EPTF_ExecCtrl_error(%definitionId&": Invalid configuration data for the regulated item "&log2str(pl_idName)&": "&vl_errorMsg); |
| } |
| if (not vl_regulatedItemIsWeighted) { |
| var integer vl_tcIdx := f_EPTF_ExecCtrl_getTrafficCaseIdx(vl_eGrpName,vl_scName,vl_tcName); |
| if ( vl_tcIdx==-1) { |
| f_EPTF_ExecCtrl_error(%definitionId&": Invalid configuration data: Regulated item "&log2str(pl_idName)&" is not found in database." |
| &" Check the traffic case name."); |
| } |
| } |
| |
| |
| // check if it is already there: |
| var integer vl_regulatedItemId := f_EPTF_ExecCtrl_Regulator_getRegulatedItemId(pl_idName); |
| if (vl_regulatedItemId == -1) { |
| // if not found: append to regulatedItems database: |
| vl_regulatedItemId := sizeof(v_EPTF_ExecCtrl_RegulatedItems); |
| // set the values: |
| v_EPTF_ExecCtrl_RegulatedItems[vl_regulatedItemId] := {pl_idName,pl_weight,pl_enabled,pl_regulatorName}; |
| } else { |
| f_EPTF_ExecCtrl_warning(%definitionId&": Cannot add regulated item to database: regulated item is already added: "&log2str(pl_idName)); |
| // regulated item is already in the database |
| // do not overwrite the existing values |
| } |
| |
| // also: add to the v_EPTF_ExecCtrl_RegulatedItemIdsDB: |
| f_EPTF_ExecCtrl_Regulator_addToRegulatedItemIdsDB(vl_regulatedItemId); |
| |
| // also: add the regulator: |
| var integer vl_regulatorIdx := f_EPTF_ExecCtrl_Regulator_addRegulator(pl_regulatorName); |
| |
| // register the regulated item into the regulator: |
| // if regulated, add to regulator data: |
| f_EPTF_ExecCtrl_Regulator_registerItem(vl_regulatorIdx,vl_regulatedItemId); |
| |
| return vl_regulatedItemId; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_Regulator_getRegulatedItemId |
| // |
| // Purpose: |
| // returns the id of the regulatedItem |
| // |
| // Parameters: |
| // pl_idName - *in* <EPTF_ExecCtrl_RegulatedItemName> - the name of the regulated item |
| // |
| // Return Value: |
| // integer - the id of the regulated item |
| // |
| // Errors & assertions: |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_ExecCtrl_Regulator_getRegulatedItemId(in EPTF_ExecCtrl_RegulatedItemName pl_idName) runs on EPTF_ExecCtrl_CT return integer { |
| for(var integer i:=0, size := sizeof(v_EPTF_ExecCtrl_RegulatedItems); i<size; i:=i+1) { |
| if (v_EPTF_ExecCtrl_RegulatedItems[i].idName == pl_idName) { |
| return i; |
| } |
| } |
| return -1; // not found |
| } |
| |
| // returns the id of the regulatedItem |
| private function f_EPTF_ExecCtrl_Regulator_getRegulatedItemIdById(in EPTF_ExecCtrl_RegulatedItemId pl_id) runs on EPTF_ExecCtrl_CT return integer { |
| for(var integer i:=0, size := sizeof(v_EPTF_ExecCtrl_RegulatedItemIdsDB); i<size; i:=i+1) { |
| if (v_EPTF_ExecCtrl_RegulatedItemIdsDB[i] == pl_id) { |
| return i; |
| } |
| } |
| return -1; // not found |
| } |
| |
| // returns the id of the regulatedItem |
| friend function f_EPTF_ExecCtrl_Regulator_getRegulatedItemDataById(in integer pl_id) runs on EPTF_ExecCtrl_CT return EPTF_ExecCtrl_RegulatedItemId { |
| return v_EPTF_ExecCtrl_RegulatedItemIdsDB[pl_id]; |
| } |
| |
| // append regulated item idx to regulatedItems of regulator pl_regulatorIdx |
| // checks also if the regulated item is regulated by some regulator |
| private function f_EPTF_ExecCtrl_Regulator_registerItem(in integer pl_regulatorIdx, in integer pl_itemIdx) runs on EPTF_ExecCtrl_CT { |
| if (pl_regulatorIdx==-1) { |
| return; // no regulator given |
| } |
| |
| // check if it is already in a regulator or not: |
| if ( v_EPTF_ExecCtrl_RegulatedItems[pl_itemIdx].regulatorName != "" |
| and v_EPTF_ExecCtrl_RegulatedItems[pl_itemIdx].regulatorName != v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].name) |
| { |
| f_EPTF_ExecCtrl_error(%definitionId&": Cannot set regulator name "&v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].name& |
| " to the item "&log2str(v_EPTF_ExecCtrl_RegulatedItems[pl_itemIdx].idName)& |
| ": it is already regulated by " & v_EPTF_ExecCtrl_RegulatedItems[pl_itemIdx].regulatorName); |
| } |
| |
| // register it into regulated items: |
| v_EPTF_ExecCtrl_RegulatedItems[pl_itemIdx].regulatorName := v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].name; |
| |
| // register it into the regulator: |
| f_EPTF_ExecCtrl_Regulator_addItem(pl_regulatorIdx,pl_itemIdx); |
| } |
| |
| // remove regulated item idx from regulatedItems of regulator pl_regulatorIdx |
| // removes also the regulated item from the regulator |
| private function f_EPTF_ExecCtrl_Regulator_deregisterItem(in integer pl_regulatorIdx, in integer pl_itemIdx) runs on EPTF_ExecCtrl_CT { |
| // check if it is already in a regulator or not: |
| |
| // deregister it from the regulated items: |
| v_EPTF_ExecCtrl_RegulatedItems[pl_itemIdx].regulatorName := ""; |
| |
| // deregister it from the regulator: |
| f_EPTF_ExecCtrl_Regulator_removeItem(pl_regulatorIdx,pl_itemIdx); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_Regulator_setTotalCps |
| // |
| // Purpose: |
| // sets the total CPS into the regulated items for this regulator. The total CPS is distributed according to the weights, only the enabled items are processed |
| // |
| // Parameters: |
| // pl_regulatorIdx - *in integer* - the id of the regulator |
| // pl_totalCps - *in float* - the total CPS to set |
| // |
| // Return Value: |
| // |
| // Errors & assertions: |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_ExecCtrl_Regulator_setTotalCps(in integer pl_regulatorIdx, in float pl_totalCps) runs on EPTF_ExecCtrl_CT { |
| if (pl_regulatorIdx == -1) { |
| return; // no regulator |
| } |
| if (not v_ExecCtrl_initialized) { |
| return; |
| } |
| |
| var float vl_sumWeight := 0.0; |
| |
| // sum the CPS-es: |
| for(var integer i:=0, size := sizeof(v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].regulatedItemIds); i<size; i:=i+1) { |
| var integer vl_regulatedItemIdx := v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].regulatedItemIds[i]; |
| |
| // check if the regulator regulates in the current phase: |
| if (not f_EPTF_ExecCtrl_currentPhaseIsRegulated(vl_regulatedItemIdx)) { |
| continue; |
| } |
| |
| // grpidx is not used currently! |
| //var integer grpidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_TC.grpidx; |
| if (v_EPTF_ExecCtrl_RegulatedItems[vl_regulatedItemIdx].enabled and f_EPTF_ExecCtrl_Regulator_itemIsRunning(vl_regulatedItemIdx)) { |
| vl_sumWeight := vl_sumWeight + v_EPTF_ExecCtrl_RegulatedItems[vl_regulatedItemIdx].weight; |
| } |
| } |
| |
| // set the CPS-es: |
| for(var integer i:=0, size := sizeof(v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].regulatedItemIds); i<size; i:=i+1) { |
| var integer vl_regulatedItemIdx := v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].regulatedItemIds[i]; |
| |
| // check if the regulator regulates in the current phase: |
| if (not f_EPTF_ExecCtrl_currentPhaseIsRegulated(vl_regulatedItemIdx)) { |
| continue; |
| } |
| |
| if (not v_EPTF_ExecCtrl_RegulatedItems[vl_regulatedItemIdx].enabled |
| or not f_EPTF_ExecCtrl_Regulator_itemIsRunning(vl_regulatedItemIdx)) { |
| continue; |
| } |
| if (ischosen(v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_TC)) { |
| var integer scenidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_TC.scenidx; |
| var integer tcidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_TC.tcidx; |
| // grpidx is not used currently! |
| var integer grpidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_TC.grpidx; |
| v_ExecCtrl_scenarios[scenidx].scData.tcList[tcidx].target.cpsToReach := pl_totalCps * v_EPTF_ExecCtrl_RegulatedItems[vl_regulatedItemIdx].weight/vl_sumWeight; |
| f_EPTF_ExecCtrl_setCps_TC(scenidx,tcidx, v_ExecCtrl_scenarios[scenidx].scData.tcList[tcidx].target.cpsToReach); |
| } else if (ischosen(v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_SC)) { |
| var integer scenidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_SC.scenidx; |
| // grpidx is not used currently! |
| var integer grpidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_SC.grpidx; |
| v_ExecCtrl_scenarios[scenidx].scData.weightedScData.cpsToReach := pl_totalCps * v_EPTF_ExecCtrl_RegulatedItems[vl_regulatedItemIdx].weight/vl_sumWeight; |
| f_EPTF_ExecCtrl_setCps_SC(scenidx,v_ExecCtrl_scenarios[scenidx].scData.weightedScData.cpsToReach); |
| } else if (ischosen(v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_TCInPhase)) { |
| var integer scenidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_TCInPhase.scenidx; |
| var integer tcidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_TCInPhase.tcidx; |
| // grpidx is not used currently! |
| var integer grpidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_TCInPhase.grpidx; |
| v_ExecCtrl_scenarios[scenidx].scData.tcList[tcidx].target.cpsToReach := pl_totalCps * v_EPTF_ExecCtrl_RegulatedItems[vl_regulatedItemIdx].weight/vl_sumWeight; |
| f_EPTF_ExecCtrl_setCps_TC(scenidx,tcidx, v_ExecCtrl_scenarios[scenidx].scData.tcList[tcidx].target.cpsToReach); |
| } else if (ischosen(v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_SCInPhase)) { |
| var integer scenidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_SCInPhase.scenidx; |
| // grpidx is not used currently! |
| var integer grpidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_SCInPhase.grpidx; |
| v_ExecCtrl_scenarios[scenidx].scData.weightedScData.cpsToReach := pl_totalCps * v_EPTF_ExecCtrl_RegulatedItems[vl_regulatedItemIdx].weight/vl_sumWeight; |
| f_EPTF_ExecCtrl_setCps_SC(scenidx,v_ExecCtrl_scenarios[scenidx].scData.weightedScData.cpsToReach); |
| } |
| } |
| } |
| |
| private function f_EPTF_ExecCtrl_currentPhaseIsRegulated(in integer pl_regulatedItemIdx) runs on EPTF_ExecCtrl_CT return boolean { |
| if (ischosen(v_EPTF_ExecCtrl_RegulatedItemIdsDB[pl_regulatedItemIdx].cps_TC)) { |
| return true;// this item is regulated in all phases |
| } else if (ischosen(v_EPTF_ExecCtrl_RegulatedItemIdsDB[pl_regulatedItemIdx].cps_SC)) { |
| return true;// this item is regulated in all phases |
| } |
| var integer sidx; |
| var charstring vl_phase; |
| if (ischosen(v_EPTF_ExecCtrl_RegulatedItemIdsDB[pl_regulatedItemIdx].cps_TCInPhase)) { |
| sidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[pl_regulatedItemIdx].cps_TCInPhase.scenidx; |
| vl_phase := v_EPTF_ExecCtrl_RegulatedItemIdsDB[pl_regulatedItemIdx].cps_TCInPhase.phase; |
| } else if (ischosen(v_EPTF_ExecCtrl_RegulatedItemIdsDB[pl_regulatedItemIdx].cps_SCInPhase)) { |
| sidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[pl_regulatedItemIdx].cps_SCInPhase.scenidx; |
| vl_phase := v_EPTF_ExecCtrl_RegulatedItemIdsDB[pl_regulatedItemIdx].cps_SCInPhase.phase; |
| } |
| |
| // check if current phase is the same as the regulated item's phase |
| var integer vl_scGrpidx := f_EPTF_ExecCtrl_ScenarioGroup_get_byScIndex(sidx); |
| if (vl_scGrpidx==-1) { |
| //f_EPTF_ExecCtrl_error(%definitionId&": Invalid configuration data for the regulated item "&log2str(v_EPTF_ExecCtrl_RegulatedItems[pl_regulatedItemIdx])&": " |
| // &"Phase setting is not consistent with scenario: The scenario is not in a scenario group but phase is specified or vice versa."); |
| return false; // this is not reached |
| } |
| |
| var integer vl_currentPhaseIdx := v_ExecCtrl_ScenarioGroupInstanceDB.data[vl_scGrpidx].groupPhaseList.actualPhaseIndex; |
| var charstring vl_currentPhaseName := v_ExecCtrl_ScenarioGroupInstanceDB.data[vl_scGrpidx].groupPhaseList.phases[vl_currentPhaseIdx].name; |
| if (vl_phase == vl_currentPhaseName) { |
| return true; |
| } |
| return false; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_checkTrafficCaseStatus |
| // |
| // Purpose: |
| // Check if the execution state of a specified traffic case is consistent |
| // in all LGens |
| // |
| // Parameters: |
| // - pl_idName - *in* <EPTF_ExecCtrl_TCName> - the regulated item ID |
| // - pl_status - *in template charstring* - the desired state |
| // |
| // Return Value: |
| // *boolean* - true, if the execution state of a scenario matches the specifid state |
| // |
| // Errors & assertions: |
| // |
| // Detailed Comments: |
| // |
| // |
| /////////////////////////////////////////////////////////// |
| private function f_EPTF_ExecCtrl_checkTrafficCaseStatus(in EPTF_ExecCtrl_TCName pl_idName, in template charstring pl_status) runs on EPTF_ExecCtrl_CT return boolean |
| { |
| f_EPTF_ExecCtrl_debug(%definitionId&": started"); |
| |
| var charstring vl_currentName := "ExecCtrl.trafficCaseStatus."&pl_idName.eGrpName&"."&pl_idName.scName&"."&pl_idName.tcName; |
| var integer vl_idx := f_EPTF_Var_getId(vl_currentName); |
| if (vl_idx == -1) { |
| return false; |
| } |
| var EPTF_StatusLED vl_statusLED := f_EPTF_Var_getStatusLEDValue(vl_idx); |
| var charstring vl_status := vl_statusLED.text; |
| if (not match(vl_status, pl_status)) { |
| return false; |
| } |
| |
| f_EPTF_ExecCtrl_debug(%definitionId&": finish"); |
| return true; |
| } |
| |
| private function f_EPTF_ExecCtrl_Regulator_itemIsRunning(in integer pl_regulatedItemIdx) runs on EPTF_ExecCtrl_CT return boolean { |
| var charstring vl_varName; |
| |
| if (ischosen(v_EPTF_ExecCtrl_RegulatedItems[pl_regulatedItemIdx].idName.cps_TC)) { |
| return f_EPTF_ExecCtrl_checkTrafficCaseStatus( |
| v_EPTF_ExecCtrl_RegulatedItems[pl_regulatedItemIdx].idName.cps_TC, |
| c_EPTF_LGenBase_stateNames[c_EPTF_LGenBase_tcStateRunning] |
| ); |
| } else if (ischosen(v_EPTF_ExecCtrl_RegulatedItems[pl_regulatedItemIdx].idName.cps_SC)) { |
| return f_EPTF_ExecCtrl_checkScenarioStatus( |
| v_EPTF_ExecCtrl_RegulatedItems[pl_regulatedItemIdx].idName.cps_SC, |
| c_EPTF_LGenBase_stateNames[c_EPTF_LGenBase_tcStateRunning] |
| ); |
| }else if (ischosen(v_EPTF_ExecCtrl_RegulatedItems[pl_regulatedItemIdx].idName.cps_TCInPhase)) { |
| return f_EPTF_ExecCtrl_checkTrafficCaseStatus( |
| { |
| v_EPTF_ExecCtrl_RegulatedItems[pl_regulatedItemIdx].idName.cps_TCInPhase.eGrpName, |
| v_EPTF_ExecCtrl_RegulatedItems[pl_regulatedItemIdx].idName.cps_TCInPhase.scName, |
| v_EPTF_ExecCtrl_RegulatedItems[pl_regulatedItemIdx].idName.cps_TCInPhase.tcName |
| }, |
| c_EPTF_LGenBase_stateNames[c_EPTF_LGenBase_tcStateRunning] |
| ); |
| } else if (ischosen(v_EPTF_ExecCtrl_RegulatedItems[pl_regulatedItemIdx].idName.cps_SCInPhase)) { |
| return f_EPTF_ExecCtrl_checkScenarioStatus( |
| {v_EPTF_ExecCtrl_RegulatedItems[pl_regulatedItemIdx].idName.cps_SCInPhase.eGrpName,v_EPTF_ExecCtrl_RegulatedItems[pl_regulatedItemIdx].idName.cps_SCInPhase.scName}, |
| c_EPTF_LGenBase_stateNames[c_EPTF_LGenBase_tcStateRunning] |
| ); |
| } |
| return false;// never reached |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_ExecCtrl_Regulator_getTotalCps |
| // |
| // Purpose: |
| // returns the total CPS of the regulated items belonging to the given regulator, only the enabled items are processed |
| // |
| // Parameters: |
| // pl_regulatorIdx - *in integer* - the id of the regulator |
| // |
| // Return Value: |
| // float - the total CPS |
| // |
| // Errors & assertions: |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_ExecCtrl_Regulator_getTotalCps(in integer pl_regulatorIdx) runs on EPTF_ExecCtrl_CT return float { |
| if (pl_regulatorIdx == -1) { |
| return 0.0; // no regulator |
| } |
| |
| var float vl_sumCps := 0.0; |
| |
| // sum the CPS-es: |
| for(var integer i:=0, size := sizeof(v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].regulatedItemIds); i<size; i:=i+1) { |
| var integer vl_regulatedItemIdx := v_EPTF_ExecCtrl_Regulators[pl_regulatorIdx].regulatedItemIds[i]; |
| // check if the regulator regulates in the current phase: |
| if (not f_EPTF_ExecCtrl_currentPhaseIsRegulated(vl_regulatedItemIdx)) { |
| continue; |
| } |
| if (v_EPTF_ExecCtrl_RegulatedItems[vl_regulatedItemIdx].enabled |
| and f_EPTF_ExecCtrl_Regulator_itemIsRunning(vl_regulatedItemIdx) |
| ) { |
| if (ischosen(v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_TC)) { |
| var integer scenidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_TC.scenidx; |
| var integer tcidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_TC.tcidx; |
| // grpidx is not used currently! |
| //var integer grpidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_TC.grpidx; |
| vl_sumCps := vl_sumCps + v_ExecCtrl_scenarios[scenidx].scData.tcList[tcidx].target.cpsToReach; |
| } else if (ischosen(v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_SC)) { |
| var integer scenidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_SC.scenidx; |
| // grpidx is not used currently! |
| //var integer grpidx := v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_SC.grpidx; |
| vl_sumCps := vl_sumCps + v_ExecCtrl_scenarios[scenidx].scData.weightedScData.cpsToReach; |
| } else if (ischosen(v_EPTF_ExecCtrl_RegulatedItemIdsDB[vl_regulatedItemIdx].cps_TCInPhase)) { |
|