| /////////////////////////////////////////////////////////////////////////////// |
| // // |
| // 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_StatHandler_Functions |
| // |
| // Purpose: |
| // This module contains the implementation of the StatHandlerClient. |
| // |
| // Module depends on: |
| // <EPTF_CLL_Base_Functions> |
| // <EPTF_CLL_Common_Definitions> |
| // <EPTF_CLL_FBQ_Functions> |
| // <EPTF_CLL_HashMapStr2Int_Functions> |
| // <EPTF_CLL_StatHandler_Definitions> |
| // <EPTF_CLL_StatHandlerClient_Definitions> |
| // <EPTF_CLL_StatHandlerLogging_Functions> |
| // <EPTF_CLL_Variable_Definitions> |
| // <EPTF_CLL_Variable_Functions> |
| // <EPTF_CLL_HashMap_Functions> |
| // |
| // Module Parameters: |
| // tsp_debug_EPTF_StatHandler - *boolean* - debug flag, default false |
| // |
| // Current Owner: |
| // Gabor Tatarka (EGBOTAT) |
| // |
| // Last Review Date: |
| // 2009-05-22 |
| // |
| // Detailed Comments: |
| // This module contains the implementation of the StatHandler. |
| // Public API: |
| // - <f_EPTF_StatHandler_init_CT> |
| // - <f_EPTF_StatHandler_downcast> |
| // - <f_EPTF_StatHandler_registerStatDeclaredCallbackFn> |
| // - <f_EPTF_StatHandler_deregisterStatDeclaredCallbackFn> |
| // - <f_EPTF_StatHandler_registerStatisticsResetFunction> |
| // - <f_EPTF_StatHandler_deregisterStatisticsResetFunction> |
| // - <f_EPTF_StatHandler_getId> |
| // - <f_EPTF_StatHandler_getNofStats> |
| // - <f_EPTF_StatHandler_getName> |
| // - <f_EPTF_StatHandler_getMethod> |
| // - <f_EPTF_StatHandler_getVarIdx> |
| // - <f_EPTF_StatHandler_getParentIdx> |
| // - <f_EPTF_StatHandler_getAuxStats> |
| // - <f_EPTF_StatHandler_getAuxVars> |
| // - <f_EPTF_StatHandler_getNofSources> |
| // - <f_EPTF_StatHandler_getVarsOfSource> |
| // |
| /////////////////////////////////////////////////////////////// |
| |
| module EPTF_CLL_StatHandler_Functions { |
| |
| import from EPTF_CLL_Base_Definitions all; |
| import from EPTF_CLL_Base_Functions all; |
| import from EPTF_CLL_Common_Definitions all; |
| import from EPTF_CLL_FBQ_Functions all; |
| import from EPTF_CLL_HashMapStr2Int_Functions all; |
| import from EPTF_CLL_StatHandler_Definitions all; |
| import from EPTF_CLL_StatHandlerClient_Definitions all; |
| import from EPTF_CLL_StatHandlerLogging_Functions all; |
| import from EPTF_CLL_Variable_Definitions all; |
| import from EPTF_CLL_Variable_Functions all; |
| import from EPTF_CLL_DataSource_Definitions all; |
| import from EPTF_CLL_DataSourceClient_Functions all; |
| import from EPTF_CLL_StatHandler_DSFunctions all; |
| import from EPTF_CLL_HashMap_Functions all; |
| friend module EPTF_CLL_StatHandlerUI_Functions; |
| friend module EPTF_CLL_StatHandler_DSFunctions; |
| |
| modulepar boolean tsp_debug_EPTF_StatHandler := false; |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_init_CT |
| // |
| // Purpose: |
| // Init function for component type <EPTF_StatHandler_CT> |
| // |
| // Parameters: |
| // pl_selfName - *in* *charstring* - EPTF self name |
| // pl_dataSource_compRef - *in* <EPTF_DataSource_CT> - dataSource component reference |
| // |
| // Return Value: |
| // - |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_StatHandler_init_CT( |
| in charstring pl_selfName, |
| in EPTF_DataSource_CT pl_dataSource_compRef := null) |
| runs on EPTF_StatHandler_CT |
| { |
| if(v_EPTF_StatHandler_initialized) { return; } |
| |
| f_EPTF_StatHandlerLogging_init_CT( |
| pl_selfName, |
| c_EPTF_StatHandler_loggingComponentMask, |
| tsp_debug_EPTF_StatHandler); |
| |
| f_EPTF_Var_init_CT(pl_selfName); |
| |
| f_EPTF_HashMap_init_CT (pl_selfName); |
| |
| f_EPTF_FBQ_init_CT(pl_selfName); |
| |
| v_EPTF_StatHandler_aggregatedStats := c_empty_EPTF_StatHandler_AggregatedStatDatabase; |
| |
| v_EPTF_StatHandler_aggregatedStats.hashmap_name2Idx := |
| f_EPTF_str2int_HashMap_New( |
| f_EPTF_Base_selfName()&v_EPTF_StatHandler_nameSeparator&c_EPTF_StatHandler_HashMapName2Idx) |
| //pl_selfName&v_EPTF_StatHandler_nameSeparator&c_EPTF_StatHandler_HashMapName2Idx); |
| |
| f_EPTF_Var_newInt(f_EPTF_StatHandler_genUniqueName(c_EPTF_StatHandler_ResetVarName), |
| 0, v_EPTF_StatHandler_resetButtonVarIdx); |
| |
| f_EPTF_Var_addPostProcFn(v_EPTF_StatHandler_resetButtonVarIdx, |
| {refers(f_EPTF_StatHandler_resetButtonPressed), {}}); |
| f_EPTF_Var_addGuardFn(v_EPTF_StatHandler_resetButtonVarIdx, |
| {refers(f_EPTF_StatHandler_resetButtonGuard), {}}); |
| |
| v_EPTF_StatHandler_resetComponents := {}; |
| v_EPTF_StatHandler_nofPendingResets := 0; |
| |
| v_EPTF_StatHandler_statDeclaredCallbackFns := {}; |
| // TR HR20548 - Reset All statistics button |
| v_EPTF_StatHandler_resetStatisticsFunctions := {}; |
| |
| vd_EPTF_StatHandler_behavior := activate(as_EPTF_StatHandler_behavior()); |
| var integer vl_resetVarGlobal := f_EPTF_Var_getId(f_EPTF_StatHandler_genUniqueName(c_EPTF_StatHandler_ResetVarNameGlobal)); |
| if(vl_resetVarGlobal == -1 ){ |
| f_EPTF_Var_newInt( |
| f_EPTF_StatHandler_genUniqueName(c_EPTF_StatHandler_ResetVarNameGlobal), |
| 0, |
| vl_resetVarGlobal); |
| } |
| // TR HR20548 - Reset All statistics button |
| f_EPTF_Var_addPostProcFn(vl_resetVarGlobal, {refers(f_EPTF_StatHandler_resetStatisticsButtonPressed),{}} ); |
| |
| |
| var integer vl_resetVarLocal := f_EPTF_Var_getId(f_EPTF_StatHandler_genUniqueName(c_EPTF_StatHandler_ResetVarNameLocal)); |
| if(vl_resetVarLocal == -1 ){ |
| f_EPTF_Var_newInt( |
| f_EPTF_StatHandler_genUniqueName(c_EPTF_StatHandler_ResetVarNameLocal), |
| 0, |
| vl_resetVarLocal); |
| } |
| // TR HR20548 - Reset All statistics button |
| f_EPTF_Var_addPostProcFn(vl_resetVarLocal, {refers(f_EPTF_StatHandler_resetStatisticsButtonPressed),{}}); |
| |
| |
| if(pl_dataSource_compRef != null){ |
| f_EPTF_DataSourceClient_init_CT(f_EPTF_Base_selfName(), pl_dataSource_compRef); |
| f_EPTF_DataSourceClient_registerData(c_StatHandler_DataSource_sourceId, f_EPTF_Base_selfName(), refers(f_EPTF_StatHandler_DSProcessData), pl_dataSource_compRef); |
| f_EPTF_DataSourceClient_registerDataValue(c_StatHandler_DataSource_sourceId, f_EPTF_Base_selfName(), refers(f_EPTF_StatHandler_DSProcessDataValue), pl_dataSource_compRef); |
| f_EPTF_DataSourceClient_sendReady(c_StatHandler_DataSource_sourceId, f_EPTF_Base_selfName()); |
| } |
| |
| f_EPTF_Base_registerCleanup(refers(f_EPTF_StatHandler_cleanup_CT)); |
| v_EPTF_StatHandler_initialized := true; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_downcast |
| // |
| // Purpose: |
| // Cast EPTF_Base_CT to EPTF_StatHandler_CT |
| /////////////////////////////////////////////////////////// |
| public external function f_EPTF_StatHandler_downcast(in EPTF_Base_CT pl_baseCompRef) return EPTF_StatHandler_CT; |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_registerStatDeclaredCallbackFn |
| // |
| // Purpose: |
| // Function for registering a callback function for declare stat |
| // |
| // Parameters: |
| // pl_fn - *in* <EPTF_StatHandler_statDeclared_FT> - callback function reference |
| // |
| // Return Value: |
| // - |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_StatHandler_registerStatDeclaredCallbackFn( |
| in EPTF_StatHandler_statDeclared_FT pl_fn) |
| runs on EPTF_StatHandler_CT |
| { |
| for(var integer i:=0; i<sizeof(v_EPTF_StatHandler_statDeclaredCallbackFns); i:=i+1) { |
| if(v_EPTF_StatHandler_statDeclaredCallbackFns[i] == pl_fn) { return; } |
| } |
| v_EPTF_StatHandler_statDeclaredCallbackFns[sizeof(v_EPTF_StatHandler_statDeclaredCallbackFns)] := pl_fn; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_deregisterStatDeclaredCallbackFn |
| // |
| // Purpose: |
| // Function for deregistering a callback function for declare stat |
| // |
| // Parameters: |
| // pl_fn - *in* <EPTF_StatHandler_statDeclared_FT> - callback function reference |
| // |
| // Return Value: |
| // - |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_StatHandler_deregisterStatDeclaredCallbackFn( |
| in EPTF_StatHandler_statDeclared_FT pl_fn) |
| runs on EPTF_StatHandler_CT |
| { |
| var EPTF_StatHandler_statDeclared_FTList vl_old := v_EPTF_StatHandler_statDeclaredCallbackFns; |
| v_EPTF_StatHandler_statDeclaredCallbackFns := {}; |
| for(var integer i:=0; i<sizeof(vl_old); i:=i+1) { |
| if(vl_old[i] != pl_fn) { |
| v_EPTF_StatHandler_statDeclaredCallbackFns[sizeof(v_EPTF_StatHandler_statDeclaredCallbackFns)] := |
| vl_old[i]; |
| } |
| } |
| } |
| |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_registerStatisticsResetFunction |
| // |
| // Purpose: |
| // Function to register a statistics reset callback function. |
| // |
| // Parameters: |
| // pl_fn - *in* <EPTF_StatHandler_ResetStatisticsCallback_FT> - reset callback function reference |
| // |
| // Return Value: |
| // - |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // The registered function will be called if the reset statistics Variable changes |
| // (i.e. if the reset statistics button is pressed on the UI). |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_StatHandler_registerStatisticsResetFunction( |
| in EPTF_StatHandler_ResetStatisticsCallback_FT pl_fn) |
| runs on EPTF_StatHandler_CT |
| { |
| if(pl_fn == null) { |
| f_EPTF_StatHandlerLogging_warning(%definitionId&": cannot register null function reference."); |
| } else { |
| for(var integer i := 0; i < sizeof(v_EPTF_StatHandler_resetStatisticsFunctions); i := i + 1) { |
| if(v_EPTF_StatHandler_resetStatisticsFunctions[i] == pl_fn) { |
| f_EPTF_StatHandlerLogging_warning(%definitionId&": re-registration of reset function "& |
| log2str(pl_fn)); |
| return; |
| } |
| } |
| v_EPTF_StatHandler_resetStatisticsFunctions[sizeof(v_EPTF_StatHandler_resetStatisticsFunctions)] := pl_fn; |
| } |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_deregisterStatisticsResetFunction |
| // |
| // Purpose: |
| // Function to deregister a reset callback function. |
| // |
| // Parameters: |
| // pl_fn - *in* <EPTF_StatHandler_ResetStatisticsCallback_FT> - reset callback function reference |
| // |
| // Return Value: |
| // - |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_StatHandler_deregisterStatisticsResetFunction( |
| in EPTF_StatHandler_ResetStatisticsCallback_FT pl_fn) |
| runs on EPTF_StatHandler_CT |
| { |
| if(pl_fn == null) { |
| f_EPTF_StatHandlerLogging_warning(%definitionId&": cannot deregister null function reference."); |
| } else { |
| for(var integer i := 0; i < sizeof(v_EPTF_StatHandler_resetStatisticsFunctions); i := i + 1) { |
| if(v_EPTF_StatHandler_resetStatisticsFunctions[i] == pl_fn) { |
| v_EPTF_StatHandler_resetStatisticsFunctions[i] := null; |
| } |
| } |
| } |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_getId |
| // |
| // Purpose: |
| // Function for getting the id/index of a statistic. |
| // |
| // Parameters: |
| // pl_statName - *in* *charstring* - name of the stat |
| // |
| // Return Value: |
| // *integer* - index of the stat, -1 if not found |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_StatHandler_getId(in charstring pl_statName) |
| runs on EPTF_StatHandler_CT |
| return integer |
| { |
| var integer vl_idx := -1; |
| var boolean vl_found := f_EPTF_str2int_HashMap_Find( |
| v_EPTF_StatHandler_aggregatedStats.hashmap_name2Idx, |
| pl_statName, |
| vl_idx); |
| if(vl_found) { |
| return vl_idx; |
| } else { |
| return -1; |
| } |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_getNofStats |
| // |
| // Purpose: |
| // Function for getting the number of declared aggregated statistics. |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // *integer* - number of stats |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_StatHandler_getNofStats(in charstring pl_statName) |
| runs on EPTF_StatHandler_CT |
| return integer |
| { |
| return sizeof(v_EPTF_StatHandler_aggregatedStats.data); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_getName |
| // |
| // Purpose: |
| // Function for getting the name of a statistic by id/index. |
| // |
| // Parameters: |
| // pl_statIdx - *in* *integer* - index of the stat |
| // |
| // Return Value: |
| // *charstring* - name of the stat |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_StatHandler_getName(in integer pl_statIdx) |
| runs on EPTF_StatHandler_CT |
| return charstring |
| { |
| f_EPTF_Base_assert(%definitionId&": invalid stat index", pl_statIdx >= 0 and |
| pl_statIdx < sizeof(v_EPTF_StatHandler_aggregatedStats.data)); |
| return v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statName; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_getMethod |
| // |
| // Purpose: |
| // Function for getting the method of a statistic. |
| // |
| // Parameters: |
| // pl_statIdx - *in* *integer* - index of the stat |
| // |
| // Return Value: |
| // *charstring* - method of the stat |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_StatHandler_getMethod(in integer pl_statIdx) |
| runs on EPTF_StatHandler_CT |
| return charstring |
| { |
| f_EPTF_Base_assert(%definitionId&": invalid stat index", pl_statIdx >= 0 and |
| pl_statIdx < sizeof(v_EPTF_StatHandler_aggregatedStats.data)); |
| return v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statMethod; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_getVarIdx |
| // |
| // Purpose: |
| // Function for getting the Variable index of a statistic. |
| // |
| // Parameters: |
| // pl_statIdx - *in* *integer* - index of the stat |
| // |
| // Return Value: |
| // *integer* - Variable index of the stat |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_StatHandler_getVarIdx(in integer pl_statIdx) |
| runs on EPTF_StatHandler_CT |
| return integer |
| { |
| f_EPTF_Base_assert(%definitionId&": invalid stat index", pl_statIdx >= 0 and |
| pl_statIdx < sizeof(v_EPTF_StatHandler_aggregatedStats.data)); |
| return v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statVarIdx; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_getParentIdx |
| // |
| // Purpose: |
| // Function for getting the parent index of an aux statistic. |
| // |
| // Parameters: |
| // pl_statIdx - *in* *integer* - index of the aux stat |
| // |
| // Return Value: |
| // *integer* - index of the parent stat, -1 if no parent (i.e. not an aux stat) |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_StatHandler_getParentIdx(in integer pl_statIdx) |
| runs on EPTF_StatHandler_CT |
| return integer |
| { |
| f_EPTF_Base_assert(%definitionId&": invalid stat index", pl_statIdx >= 0 and |
| pl_statIdx < sizeof(v_EPTF_StatHandler_aggregatedStats.data)); |
| return v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].parentIdx; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_getAuxStats |
| // |
| // Purpose: |
| // Function for getting the auxiliary stat indices of a statistic. |
| // |
| // Parameters: |
| // pl_statIdx - *in* *integer* - index of the stat |
| // |
| // Return Value: |
| // <EPTF_IntegerList> - list of auxiliary stat indices |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_StatHandler_getAuxStats(in integer pl_statIdx) |
| runs on EPTF_StatHandler_CT |
| return EPTF_IntegerList |
| { |
| f_EPTF_Base_assert(%definitionId&": invalid stat index", pl_statIdx >= 0 and |
| pl_statIdx < sizeof(v_EPTF_StatHandler_aggregatedStats.data)); |
| return v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].auxStats; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_getAuxVars |
| // |
| // Purpose: |
| // Function for getting the auxiliary Variable indices of a statistic. |
| // |
| // Parameters: |
| // pl_statIdx - *in* *integer* - index of the stat |
| // |
| // Return Value: |
| // <EPTF_IntegerList> - list of auxiliary Var indices |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_StatHandler_getAuxVars(in integer pl_statIdx) |
| runs on EPTF_StatHandler_CT |
| return EPTF_IntegerList |
| { |
| f_EPTF_Base_assert(%definitionId&": invalid stat index", pl_statIdx >= 0 and |
| pl_statIdx < sizeof(v_EPTF_StatHandler_aggregatedStats.data)); |
| return v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].auxVars; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_getNofSources |
| // |
| // Purpose: |
| // Function for getting the number of data sources of a statistic. |
| // |
| // Parameters: |
| // pl_statIdx - *in* *integer* - index of the stat |
| // |
| // Return Value: |
| // *integer* - number of data sources |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_StatHandler_getNofSources(in integer pl_statIdx) |
| runs on EPTF_StatHandler_CT |
| return integer |
| { |
| f_EPTF_Base_assert(%definitionId&": invalid stat index", pl_statIdx >= 0 and |
| pl_statIdx < sizeof(v_EPTF_StatHandler_aggregatedStats.data)); |
| return f_EPTF_FBQ_getLengthOfBusyChain(v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].sourceQueue); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_getVarsOfSource |
| // |
| // Purpose: |
| // Function for getting the Variable indices of a source of a statistic. |
| // |
| // Parameters: |
| // pl_statIdx - *in* *integer* - index of the stat |
| // pl_sourceIdx - *in* *integer* - index of the source within the stat |
| // |
| // Return Value: |
| // <EPTF_IntegerList> - list of Variable indices |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_StatHandler_getVarsOfSource(in integer pl_statIdx, in integer pl_sourceIdx) |
| runs on EPTF_StatHandler_CT |
| return EPTF_IntegerList |
| { |
| f_EPTF_Base_assert(%definitionId&": invalid stat index", pl_statIdx >= 0 and |
| pl_statIdx < sizeof(v_EPTF_StatHandler_aggregatedStats.data)); |
| f_EPTF_Base_assert(%definitionId&": invalid source index", pl_sourceIdx >= 0 and |
| pl_sourceIdx < sizeof(v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].sources)); |
| return v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].sources[pl_sourceIdx].varIdxList; |
| } |
| |
| ///////////////////////////////////////////////////////////////////////////// |
| // Function: f_EPTF_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: |
| // - |
| // |
| ///////////////////////////////////////////////////////////////////////////// |
| public function f_EPTF_StatHandler_getVarNameByStatName( |
| in charstring pl_statName, |
| out charstring pl_varName) |
| runs on EPTF_StatHandler_CT |
| return boolean |
| { |
| var integer vl_idx := f_EPTF_StatHandler_getId(pl_statName); |
| if(vl_idx < 0) { return false; } |
| pl_varName := f_EPTF_Var_getName(f_EPTF_StatHandler_getVarIdx(vl_idx)); |
| return true; |
| } |
| |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_resetStatistics |
| // |
| // Purpose: |
| // Function for reset the statistic. |
| // |
| // Parameters: |
| // pl_statIdx - *in* *integer* - index of the stat |
| // |
| // Return Value: |
| // *boolean* - true if success |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_StatHandler_resetStatistics(in charstring pl_statName) |
| runs on EPTF_StatHandler_CT |
| return boolean |
| { |
| var integer vl_idx := f_EPTF_StatHandler_getId(pl_statName); |
| var boolean vl_ret := true; |
| if(0 <= vl_idx and vl_idx < sizeof(v_EPTF_StatHandler_aggregatedStats.data)){ |
| var integer vl_nrOfSources; |
| var EPTF_IntegerList vl_listOfSources; |
| var EPTF_TopProviderType vl_providerType; |
| |
| vl_nrOfSources := f_EPTF_StatHandler_getNofSources(vl_idx); |
| var integer vl_varIdx := f_EPTF_StatHandler_getVarIdx(vl_idx); |
| var EPTF_Var_DirectContent vl_actContent; |
| // K.I. - 2014.01.15. |
| /* |
| ----------------------------------------------------------------------------------------------------------------------------- |
| c_EPTF_StatHandler_Method_Min, // +RESET: Min: single value, integer or float, same as the type of target stat |
| c_EPTF_StatHandler_Method_Max, // +RESET: Max: single value, integer or float, same as the type of target stat |
| c_EPTF_StatHandler_Method_Mean, // Mean: [0]: local mean (float), [1]: number of samples (int) |
| c_EPTF_StatHandler_Method_StandardDev, // StandardDev: [0]: local mean (float), [1]: number of samples (int), [2]: S (float) |
| c_EPTF_StatHandler_Method_Sum, // +RESET: Sum: single value, integer or float, same as the type of target stat |
| c_EPTF_StatHandler_Method_GlobalAverage, // GlobalAverage: [0]: sum (float), [1]: number of elements (int) |
| c_EPTF_StatHandler_Method_Density, // Density: [0]: density distr.bin values (integerList), [1]: distr.bin boundaries (floatList, check only) |
| c_EPTF_StatHandler_Method_Percentile95, // Percentile95: [0]: density distr.bin values (integerList), [1]: distr.bin boundaries (floatList, check only), [2]: max (float) |
| c_EPTF_StatHandler_Method_PercentileP // PercentileP: [0]: density distr.bin values (integerList), [1]: distr.bin boundaries (floatList, check only), [2]: max (float), [3]: pValue (float) |
| ----------------------------------------------------------------------------------------------------------------------------- |
| */ |
| var EPTF_StatHandler_StatMethod vl_statMethod := v_EPTF_StatHandler_aggregatedStats.data[vl_idx].statMethod; |
| |
| var EPTF_Var_DirectContent vl_resetContent := v_EPTF_StatHandler_aggregatedStats.data[vl_idx].statResetValue; |
| f_EPTF_Var_getContent(vl_varIdx, vl_actContent); |
| // Reset base variable |
| if(vl_actContent != vl_resetContent){ |
| f_EPTF_Var_getTopProviderType(vl_varIdx,vl_providerType); |
| if(local != vl_providerType){ |
| f_EPTF_Var_adjustContent(vl_varIdx, pl_newContent := vl_resetContent); |
| } else { |
| f_EPTF_Var_setContent(vl_varIdx, pl_newContent := vl_resetContent); |
| } |
| f_EPTF_Var_refreshContent(vl_varIdx); |
| } |
| // Reset sources |
| for(var integer vl_srcIdx:=0; vl_srcIdx<vl_nrOfSources; vl_srcIdx:=vl_srcIdx+1) { |
| |
| // reset StatMeasureStats: |
| var EPTF_StatHandlerClient_CT vl_statMeasureCompRef := v_EPTF_StatHandler_aggregatedStats.data[vl_idx].sources[vl_srcIdx].statMeasureCompRef; |
| var integer vl_statMeasureStatIdx := v_EPTF_StatHandler_aggregatedStats.data[vl_idx].sources[vl_srcIdx].statMeasureStatIdx; |
| if (vl_statMeasureCompRef!= null and vl_statMeasureStatIdx>=0) { |
| // reset stat measure stat: |
| var EPTF_StatHandler_MgmtMsg_Request vl_req; |
| |
| vl_req := { |
| sIdx := -1, |
| request := {resetStatMeasReq:={ |
| vl_statMeasureStatIdx |
| }} |
| } |
| connect(self:v_EPTF_StatHandler_MgmtPCO,vl_statMeasureCompRef:v_EPTF_StatHandlerClient_MgmtPCO); |
| v_EPTF_StatHandler_MgmtPCO.send(vl_req) to vl_statMeasureCompRef; |
| continue; // source was statMeasure stat |
| } |
| |
| // reset StatHandlerStats: |
| var EPTF_StatHandler_CT vl_sourceStatHandlerCompRef := v_EPTF_StatHandler_aggregatedStats.data[vl_idx].sources[vl_srcIdx].sourceStatHandlerCompRef; |
| var charstring vl_sourceStatName := v_EPTF_StatHandler_aggregatedStats.data[vl_idx].sources[vl_srcIdx].sourceStatName; |
| if (vl_sourceStatHandlerCompRef!= null and vl_sourceStatName!="") { |
| if (vl_sourceStatHandlerCompRef==self) { |
| f_EPTF_StatHandler_resetStatistics(vl_sourceStatName); |
| } else { |
| // reset stat handler stat: |
| var EPTF_StatHandler_MgmtMsg_Request vl_req; |
| |
| vl_req := { |
| sIdx := -1, |
| request := {resetReq:={ |
| statName := vl_sourceStatName |
| }} |
| } |
| connect(self:v_EPTF_StatHandler_MgmtPCO,vl_sourceStatHandlerCompRef:v_EPTF_StatHandler_MgmtPCO); |
| v_EPTF_StatHandler_MgmtPCO.send(vl_req) to vl_sourceStatHandlerCompRef; |
| } |
| continue; // source was statHandler stat |
| } |
| |
| // reset source variables: |
| vl_listOfSources := f_EPTF_StatHandler_getVarsOfSource(vl_idx, vl_srcIdx); |
| for(var integer vl_listIdx:=0; vl_listIdx<sizeof(vl_listOfSources); vl_listIdx:=vl_listIdx+1) { |
| f_EPTF_Var_getTopProviderType(vl_listOfSources[vl_listIdx],vl_providerType); |
| f_EPTF_Var_getContent(vl_listOfSources[vl_listIdx],vl_actContent); |
| var EPTF_Var_DirectContent vl_agregatedResetContent := vl_resetContent; |
| // Set up reset values artifact_287506 |
| if (ischosen(vl_actContent.intVal)) { |
| if(not ischosen(vl_resetContent.intVal)){ |
| vl_agregatedResetContent := { intVal := 0 }; |
| } |
| } else if (ischosen(vl_actContent.floatVal)) { |
| if(not ischosen(vl_resetContent.floatVal)){ |
| vl_agregatedResetContent := { floatVal := 0.0 }; |
| } |
| } else if (ischosen(vl_actContent.boolVal)) { |
| if(not ischosen(vl_resetContent.boolVal)){ |
| vl_agregatedResetContent := { boolVal := false }; |
| } |
| } else if (ischosen(vl_actContent.charstringVal)) { |
| if(not ischosen(vl_resetContent.charstringVal)){ |
| vl_agregatedResetContent := { charstringVal := "" }; |
| } |
| } else if (ischosen(vl_actContent.octetstringVal)) { |
| if(not ischosen(vl_resetContent.charstringVal)){ |
| vl_agregatedResetContent := { charstringVal := "" }; |
| } |
| } else if (ischosen(vl_actContent.hexstringVal)) { |
| if(not ischosen(vl_resetContent.hexstringVal)){ |
| vl_agregatedResetContent := { hexstringVal := str2hex("") }; |
| } |
| } else if (ischosen(vl_actContent.bitstringVal)) { |
| if(not ischosen(vl_resetContent.bitstringVal)){ |
| vl_agregatedResetContent := { bitstringVal := str2bit("") }; |
| } |
| } else if (ischosen(vl_actContent.integerlistVal)) { |
| var EPTF_IntegerList vl_agregatedResetList := {}; |
| var EPTF_Var_DirectContent vl_actAgregatedResetContent := vl_resetContent; |
| if(not ischosen(vl_resetContent.intVal)){ |
| vl_actAgregatedResetContent := { intVal := 0 }; |
| } |
| for (var integer vl_i:=0;vl_i<sizeof(vl_actContent.integerlistVal);vl_i:=vl_i+1) { |
| vl_agregatedResetList[vl_i] := vl_actAgregatedResetContent.intVal; |
| } |
| vl_agregatedResetContent := { integerlistVal := vl_agregatedResetList }; |
| } else if (ischosen(vl_actContent.floatlistVal)) { |
| var EPTF_FloatList vl_agregatedResetList := {}; |
| var EPTF_Var_DirectContent vl_actAgregatedResetContent := vl_resetContent; |
| if(not ischosen(vl_resetContent.floatVal)){ |
| vl_actAgregatedResetContent := { floatVal := 0.0 }; |
| } |
| for (var integer vl_i:=0;vl_i<sizeof(vl_actContent.floatlistVal);vl_i:=vl_i+1) { |
| vl_agregatedResetList[vl_i] := vl_actAgregatedResetContent.floatVal; |
| } |
| vl_agregatedResetContent := { floatlistVal := vl_agregatedResetList }; |
| } else if (ischosen(vl_actContent.charstringlistVal)) { |
| var EPTF_CharstringList vl_agregatedResetList := {}; |
| var EPTF_Var_DirectContent vl_actAgregatedResetContent := vl_resetContent; |
| if(not ischosen(vl_resetContent.charstringVal)){ |
| vl_actAgregatedResetContent := { charstringVal := "" }; |
| } |
| for (var integer vl_i:=0;vl_i<sizeof(vl_actContent.charstringlistVal);vl_i:=vl_i+1) { |
| vl_agregatedResetList[vl_i] := vl_actAgregatedResetContent.charstringVal; |
| } |
| vl_agregatedResetContent := { charstringlistVal := vl_agregatedResetList }; |
| } else if (ischosen(vl_actContent.statusLEDVal)) { |
| if(not ischosen(vl_resetContent.statusLEDVal)){ |
| vl_agregatedResetContent := {statusLEDVal := {color:=led_black,text:=""} }; |
| } |
| } |
| var boolean vl_adjust := f_EPTF_Var_getSubsCanAdjust(vl_listOfSources[vl_listIdx]); |
| |
| if(vl_adjust == true) { |
| // List reset |
| if(local != vl_providerType){ |
| f_EPTF_Var_adjustContent(vl_listOfSources[vl_listIdx], pl_newContent := vl_agregatedResetContent); |
| } else { |
| f_EPTF_Var_setContent(vl_listOfSources[vl_listIdx], pl_newContent := vl_agregatedResetContent); |
| } |
| f_EPTF_Var_refreshContent(vl_listOfSources[vl_listIdx]); |
| } |
| } |
| }/* endFor */ |
| |
| } else { |
| f_EPTF_StatHandlerLogging_debug(%definitionId&": invalid stat index for Stat "&pl_statName&": "&log2str(vl_idx)& |
| " should be less than "&log2str(sizeof(v_EPTF_StatHandler_aggregatedStats.data))); |
| vl_ret := false; |
| } |
| return vl_ret; |
| } |
| |
| |
| /////////////////////////////////////////////////////////// |
| // Group: Private |
| // |
| // Purpose: |
| // Private functions used by StatHandler. |
| // |
| // Detailed Comments: |
| // Do not call the functions within this group form outside of StatHandler. |
| // |
| /////////////////////////////////////////////////////////// |
| group Private { |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_cleanup_CT |
| // |
| // Purpose: |
| // Cleanup function for component type <EPTF_StatHandler_CT> |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // - |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| // |
| /////////////////////////////////////////////////////////// |
| private function f_EPTF_StatHandler_cleanup_CT() |
| runs on EPTF_StatHandler_CT |
| { |
| if(not v_EPTF_StatHandler_initialized) { return; } |
| deactivate(vd_EPTF_StatHandler_behavior); |
| vd_EPTF_StatHandler_behavior := null; |
| if(c_EPTF_Common_debugSwitch and f_EPTF_StatHandlerLogging_debugEnabled()) { |
| f_EPTF_StatHandlerLogging_debug(%definitionId&": aggregated stats database: " |
| &log2str(v_EPTF_StatHandler_aggregatedStats)); |
| f_EPTF_StatHandlerLogging_debug(%definitionId&": resetComponents database: " |
| &log2str(v_EPTF_StatHandler_resetComponents)); |
| } |
| // unsubscribing from *remote* variables is not needed at cleanup, but unsibscribing from |
| // local-provider is needed to prevent the calcFn from running and using unbound values during cleanup |
| for(var integer i:=0; i<sizeof(v_EPTF_StatHandler_aggregatedStats.data); i:=i+1) { |
| f_EPTF_Var_unsubscribe(v_EPTF_StatHandler_aggregatedStats.data[i].statVarIdx); |
| } |
| |
| f_EPTF_str2int_HashMap_Delete(f_EPTF_Base_selfName()&v_EPTF_StatHandler_nameSeparator&c_EPTF_StatHandler_HashMapName2Idx); |
| v_EPTF_StatHandler_aggregatedStats := c_empty_EPTF_StatHandler_AggregatedStatDatabase; |
| |
| v_EPTF_StatHandler_resetButtonVarIdx := -1; |
| v_EPTF_StatHandler_resetComponents := {}; |
| v_EPTF_StatHandler_nofPendingResets := 0; |
| |
| v_EPTF_StatHandler_statDeclaredCallbackFns := {}; |
| |
| // TR HR20548 - Reset All statistics button |
| v_EPTF_StatHandler_resetStatisticsFunctions := {}; |
| |
| v_EPTF_StatHandler_initialized := false; |
| } |
| |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_callStatDeclaredCallbacks |
| // |
| // Purpose: |
| // Function for calling the stat-declared callback functions |
| // |
| // Parameters: |
| // pl_statIdx - *in* *integer* - index of the declared stat |
| // |
| // Return Value: |
| // - |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| // |
| /////////////////////////////////////////////////////////// |
| private function f_EPTF_StatHandler_callStatDeclaredCallbacks(in integer pl_statIdx) |
| runs on EPTF_StatHandler_CT |
| { |
| for(var integer i:=0; i<sizeof(v_EPTF_StatHandler_statDeclaredCallbackFns); i:=i+1) { |
| v_EPTF_StatHandler_statDeclaredCallbackFns[i].apply( |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statName, |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statMethod, |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statVarIdx |
| ) |
| } |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_registerBindStatToWidgetCallbackFn |
| // |
| // Purpose: |
| // Function for registering a callback function for bind-stat-to-widget. |
| // |
| // Parameters: |
| // pl_fn - *in* <EPTF_StatHandler_bindStatToWidget_FT> - callback function reference |
| // |
| // Return Value: |
| // - |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| // |
| /////////////////////////////////////////////////////////// |
| friend function f_EPTF_StatHandler_registerBindStatToWidgetCallbackFn( |
| in EPTF_StatHandler_bindStatToWidget_FT pl_fn) |
| runs on EPTF_StatHandler_CT |
| { |
| v_EPTF_StatHandler_bindStatToWidgetFn := pl_fn |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_setParent |
| // |
| // Purpose: |
| // Function for setting the parent of an aux stat. |
| // |
| // Parameters: |
| // pl_statIdx - *in* *integer* |
| // pl_parentIdx - *in* *integer* |
| // |
| // Return Value: |
| // - |
| // |
| // Errors & assertions: |
| // If stat has a parent already. |
| // |
| // Detailed Comments: |
| // - |
| // |
| /////////////////////////////////////////////////////////// |
| private function f_EPTF_StatHandler_setParent( |
| in integer pl_statIdx, |
| in integer pl_parentIdx) |
| runs on EPTF_StatHandler_CT |
| { |
| f_EPTF_Base_assert(%definitionId&": stat has a parent already.", |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].parentIdx < 0); |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].parentIdx := pl_parentIdx; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_declareStat |
| // |
| // Purpose: |
| // Function for declaring a statistic. |
| // |
| // Parameters: |
| // pl_statName - *in* *charstring* - name of the stat to create |
| // pl_statMethod - *in* *charstring* - statistics method to use |
| // pl_statResetValue - *in* <EPTF_Var_DirectContent>- reset value |
| // |
| // Return Value: |
| // *integer* - index of the declared stat (-1 on error) |
| // |
| // Errors & assertions: |
| // Redeclaration with different method or reset value. |
| // |
| // Detailed Comments: |
| // - |
| // |
| /////////////////////////////////////////////////////////// |
| private function f_EPTF_StatHandler_declareStat( |
| in charstring pl_statName, |
| in charstring pl_statMethod, |
| in EPTF_Var_DirectContent pl_statResetValue) |
| runs on EPTF_StatHandler_CT |
| return integer |
| { |
| var integer vl_idx := f_EPTF_StatHandler_getId(pl_statName); |
| if(vl_idx > -1) { // found |
| if(v_EPTF_StatHandler_aggregatedStats.data[vl_idx].statMethod != pl_statMethod or |
| v_EPTF_StatHandler_aggregatedStats.data[vl_idx].statResetValue != pl_statResetValue) { |
| f_EPTF_StatHandlerLogging_warning(%definitionId&": redeclaration of "& |
| pl_statName&" with different properties."); |
| return -1; |
| } else if(c_EPTF_Common_debugSwitch and f_EPTF_StatHandlerLogging_debugEnabled()) { |
| f_EPTF_StatHandlerLogging_debug(%definitionId&": redeclaration of "& |
| pl_statName&" with same properties."); |
| } |
| } else { |
| vl_idx := sizeof(v_EPTF_StatHandler_aggregatedStats.data); |
| v_EPTF_StatHandler_aggregatedStats.data[vl_idx] := c_empty_EPTF_StatHandler_AggregatedStat; |
| v_EPTF_StatHandler_aggregatedStats.data[vl_idx].statName := pl_statName; |
| v_EPTF_StatHandler_aggregatedStats.data[vl_idx].statMethod := pl_statMethod; |
| v_EPTF_StatHandler_aggregatedStats.data[vl_idx].statResetValue := pl_statResetValue; |
| f_EPTF_str2int_HashMap_Insert( |
| v_EPTF_StatHandler_aggregatedStats.hashmap_name2Idx, |
| pl_statName, |
| vl_idx); |
| v_EPTF_StatHandler_aggregatedStats.data[vl_idx].statVarIdx := |
| f_EPTF_Var_newVar(pl_statName, pl_statResetValue); |
| f_EPTF_StatHandler_setMethodForStat(vl_idx); |
| f_EPTF_FBQ_initFreeBusyQueue(v_EPTF_StatHandler_aggregatedStats.data[vl_idx].sourceQueue); |
| |
| if(c_EPTF_Common_debugSwitch and f_EPTF_StatHandlerLogging_debugEnabled()) { |
| f_EPTF_StatHandlerLogging_debug(%definitionId&": declared stat "&pl_statName |
| &" with stat method "&pl_statMethod&", reset value "&log2str(pl_statResetValue)); |
| f_EPTF_StatHandlerLogging_debug(%definitionId&": aggregated stats database: " |
| &log2str(v_EPTF_StatHandler_aggregatedStats)); |
| } |
| f_EPTF_StatHandler_callStatDeclaredCallbacks(vl_idx); |
| } |
| return vl_idx; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_registerStat |
| // |
| // Purpose: |
| // Function for registering a data source for a statistic. |
| // |
| // Parameters: |
| // pl_sourceCompRef - *in* <EPTF_Var_CT> - component reference that has the source variable |
| // pl_sender - *in* <EPTF_StatHandlerClient_CT> - component reference of the sender of registerStat message |
| // pl_providerVarList - *in* <EPTF_CharstringList> - list of source variable names on the source component |
| // pl_contentList - *in* <EPTF_StatHandler_ContentList> - list of source variable values on the source component |
| // pl_subscriptionMode - *in* <EPTF_Var_SubscriptionMode> - subscription mode |
| // pl_targetStatName - *in* *charstring* - name of the stat to register to |
| // pl_sourceUniqueId - *in* *integer* - unique ID for the source - will be used recursively for aux stats, can be used to deregister |
| // pl_refreshRate - *in* *integer* - refresh rate of the subscription |
| // pl_sourceStatHandler - *in* <EPTF_StatHandler_CT> - component for the statHandler that contains the source statistics, |
| // pl_sourceStatName - *in* *charstring* - name of the stat source stat on pl_sourceStatHandler to register |
| // pl_measuredStatIdx - *in* *integer* - the index of the StatMeasure statistics to register on pl_sender |
| // |
| // Return Value: |
| // *boolean* - true on success |
| // |
| // Errors & assertions: |
| // Nonexistent target stat; empty or invalid provider var list. |
| // |
| // Detailed Comments: |
| // Required provider variables for each stat method: |
| // Min: single value, integer or float, same as the type of target stat |
| // Max: single value, integer or float, same as the type of target stat |
| // Mean: [0]: local mean (float), [1]: number of samples (int) |
| // StandardDev: [0]: local mean (float), [1]: number of samples (int), [2]: S (float) |
| // Sum: single value, integer or float, same as the type of target stat |
| // GlobalAverage: [0]: sum (float), [1]: number of elements (int) |
| // Density: [0]: density distr.bin values (integerList), [1]: distr.bin boundaries (floatList, check only) |
| // Percentile95: [0]: density distr.bin values (integerList), [1]: distr.bin boundaries (floatList, check only), [2]: max (float) |
| // PercentileP: [0]: density distr.bin values (integerList), [1]: distr.bin boundaries (floatList, check only), [2]: max (float), [3]: pValue (float) |
| // |
| /////////////////////////////////////////////////////////// |
| private function f_EPTF_StatHandler_registerStat( |
| in EPTF_Var_CT pl_sourceCompRef, |
| in EPTF_StatHandlerClient_CT pl_sender, |
| in EPTF_CharstringList pl_providerVarList, |
| in EPTF_StatHandler_ContentList pl_contentList, |
| in EPTF_Var_SubscriptionMode pl_subscriptionMode, |
| in charstring pl_targetStatName, |
| in integer pl_sourceUniqueId := -1, |
| in integer pl_refreshRate, |
| in EPTF_StatHandler_CT pl_sourceStatHandler := null, |
| in charstring pl_sourceStatName := "", |
| in integer pl_measuredStatIdx := -1 |
| ) runs on EPTF_StatHandler_CT |
| return boolean |
| { |
| if(v_EPTF_StatHandler_nofPendingResets > 0) { |
| f_EPTF_StatHandlerLogging_warning(%definitionId&" called while reset is in progress"); |
| } |
| if(sizeof(pl_providerVarList) < 1) { |
| f_EPTF_StatHandlerLogging_warning(%definitionId&": provider variable list is empty"); |
| return false; |
| } |
| |
| // step 1: find the target statistic |
| var integer vl_statIdx := f_EPTF_StatHandler_getId(pl_targetStatName); |
| if(vl_statIdx < 0) { // not found |
| f_EPTF_StatHandlerLogging_warning(log2str(%definitionId&": no such statistics: ", pl_targetStatName)); |
| return false; |
| } |
| |
| var EPTF_StatHandler_StatOfComponent vl_source := c_empty_EPTF_StatHandler_StatOfComponent; |
| vl_source.compRef := pl_sourceCompRef; |
| vl_source.varNameList := pl_providerVarList; |
| |
| vl_source.statMeasureCompRef := pl_sender; |
| vl_source.statMeasureStatIdx := pl_measuredStatIdx; |
| |
| vl_source.sourceStatHandlerCompRef := pl_sourceStatHandler; |
| vl_source.sourceStatName := pl_sourceStatName; |
| |
| var integer vl_sourceIdx := f_EPTF_FBQ_getOrCreateFreeSlot(v_EPTF_StatHandler_aggregatedStats.data[vl_statIdx].sourceQueue); |
| if(vl_sourceIdx >= sizeof(v_EPTF_StatHandler_aggregatedStats.data[vl_statIdx].sources)) { |
| // newly created slot |
| v_EPTF_StatHandler_aggregatedStats.data[vl_statIdx].sources[vl_sourceIdx] := c_empty_EPTF_StatHandler_StatOfComponent; |
| } |
| // Note: moving it to the busy queue is needed to prevent race condition arising from working with remote variables in subsequently called functions... |
| // Must be moved back to the free queue on error, before returning with false. |
| f_EPTF_FBQ_moveFromFreeToBusyTail(vl_sourceIdx, v_EPTF_StatHandler_aggregatedStats.data[vl_statIdx].sourceQueue); |
| f_EPTF_FBQ_moveFromBusyToInvalid(vl_sourceIdx, v_EPTF_StatHandler_aggregatedStats.data[vl_statIdx].sourceQueue); |
| // FIXME: no f_EPTF_FBQ_moveFromFreeToInvalid in FreeBusyQueue |
| |
| if(pl_sourceUniqueId < 0) { |
| pl_sourceUniqueId := vl_sourceIdx; |
| } |
| vl_source.uniqueId := pl_sourceUniqueId; |
| //vl_source.lastResetTimestamp := f_EPTF_Base_getAbsTimeInSecs(); |
| |
| // step 2: based on stat method... |
| select(v_EPTF_StatHandler_aggregatedStats.data[vl_statIdx].statMethod) { |
| |
| // step 2a: register for aux stats, if any |
| // step 2b: perform checks and subscribe to providers |
| case(c_EPTF_StatHandler_Method_Min, |
| c_EPTF_StatHandler_Method_Max, |
| c_EPTF_StatHandler_Method_Sum) { |
| if(not f_EPTF_StatHandler_registerStat_Single( |
| pl_sourceCompRef, |
| pl_sender, |
| pl_providerVarList, |
| pl_contentList, |
| pl_subscriptionMode, |
| vl_statIdx, |
| vl_source.varIdxList, |
| pl_sourceUniqueId, |
| pl_refreshRate)) { |
| f_EPTF_FBQ_moveFromInvalidToFreeHead(vl_sourceIdx, v_EPTF_StatHandler_aggregatedStats.data[vl_statIdx].sourceQueue); |
| return false; |
| } |
| } |
| |
| case(c_EPTF_StatHandler_Method_Mean) { |
| if(not f_EPTF_StatHandler_registerStat_Mean( |
| pl_sourceCompRef, |
| pl_sender, |
| pl_providerVarList, |
| pl_contentList, |
| pl_subscriptionMode, |
| vl_statIdx, |
| vl_source.varIdxList, |
| pl_sourceUniqueId, |
| pl_refreshRate)) { |
| f_EPTF_FBQ_moveFromInvalidToFreeHead(vl_sourceIdx, v_EPTF_StatHandler_aggregatedStats.data[vl_statIdx].sourceQueue); |
| return false; |
| } |
| } |
| |
| case(c_EPTF_StatHandler_Method_StandardDev) { |
| if(not f_EPTF_StatHandler_registerStat_StandardDev( |
| pl_sourceCompRef, |
| pl_sender, |
| pl_providerVarList, |
| pl_contentList, |
| pl_subscriptionMode, |
| vl_statIdx, |
| vl_source.varIdxList, |
| pl_sourceUniqueId, |
| pl_refreshRate)) { |
| f_EPTF_FBQ_moveFromInvalidToFreeHead(vl_sourceIdx, v_EPTF_StatHandler_aggregatedStats.data[vl_statIdx].sourceQueue); |
| return false; |
| } |
| } |
| |
| case(c_EPTF_StatHandler_Method_GlobalAverage) { |
| if(not f_EPTF_StatHandler_registerStat_GlobalAverage( |
| pl_sourceCompRef, |
| pl_sender, |
| pl_providerVarList, |
| pl_contentList, |
| pl_subscriptionMode, |
| vl_statIdx, |
| vl_source.varIdxList, |
| pl_sourceUniqueId, |
| pl_refreshRate)) { |
| f_EPTF_FBQ_moveFromInvalidToFreeHead(vl_sourceIdx, v_EPTF_StatHandler_aggregatedStats.data[vl_statIdx].sourceQueue); |
| return false; |
| } |
| } |
| |
| case(c_EPTF_StatHandler_Method_Density) { |
| if(not f_EPTF_StatHandler_registerStat_Density( |
| pl_sourceCompRef, |
| pl_sender, |
| pl_providerVarList, |
| pl_contentList, |
| pl_subscriptionMode, |
| vl_statIdx, |
| vl_source.varIdxList, |
| pl_sourceUniqueId, |
| pl_refreshRate)) { |
| f_EPTF_FBQ_moveFromInvalidToFreeHead(vl_sourceIdx, v_EPTF_StatHandler_aggregatedStats.data[vl_statIdx].sourceQueue); |
| return false; |
| } |
| } |
| |
| case(c_EPTF_StatHandler_Method_Percentile95, |
| c_EPTF_StatHandler_Method_PercentileP) { |
| if(not f_EPTF_StatHandler_registerStat_PercentileP( |
| pl_sourceCompRef, |
| pl_sender, |
| pl_providerVarList, |
| pl_contentList, |
| pl_subscriptionMode, |
| vl_statIdx, |
| vl_source.varIdxList, |
| pl_sourceUniqueId, |
| pl_refreshRate)) { |
| f_EPTF_FBQ_moveFromInvalidToFreeHead(vl_sourceIdx, v_EPTF_StatHandler_aggregatedStats.data[vl_statIdx].sourceQueue); |
| return false; |
| } |
| } |
| } |
| f_EPTF_FBQ_moveFromInvalidToBusyTail(vl_sourceIdx, v_EPTF_StatHandler_aggregatedStats.data[vl_statIdx].sourceQueue); |
| |
| // step 3: add source to stat |
| v_EPTF_StatHandler_aggregatedStats.data[vl_statIdx].sources[vl_sourceIdx] := vl_source; |
| |
| // step 4: add local provider to stat's Var |
| f_EPTF_Var_addLocalProviders( |
| v_EPTF_StatHandler_aggregatedStats.data[vl_statIdx].statVarIdx, |
| vl_source.varIdxList); |
| |
| if (pl_subscriptionMode != pull) { |
| f_EPTF_Var_refreshContent(v_EPTF_StatHandler_aggregatedStats.data[vl_statIdx].statVarIdx); |
| } |
| |
| // step 5: add data sources to reset-component vl_sender |
| var boolean vl_found := false; |
| for(var integer i:=0; i<sizeof(v_EPTF_StatHandler_resetComponents); i:=i+1) { |
| if(pl_sender == v_EPTF_StatHandler_resetComponents[i].compRef) { |
| v_EPTF_StatHandler_resetComponents[i].sources[v_EPTF_StatHandler_resetComponents[i].nofSources] := { |
| statIdx := vl_statIdx, |
| sourceIdx := vl_sourceIdx |
| } |
| vl_found := true; |
| v_EPTF_StatHandler_aggregatedStats.data[vl_statIdx].sources[vl_sourceIdx].resetCompIdx := i; |
| v_EPTF_StatHandler_aggregatedStats.data[vl_statIdx].sources[vl_sourceIdx].resetSourceIdx := |
| v_EPTF_StatHandler_resetComponents[i].nofSources; |
| v_EPTF_StatHandler_resetComponents[i].nofSources := v_EPTF_StatHandler_resetComponents[i].nofSources + 1; |
| break; |
| } |
| } |
| if(not vl_found) { |
| var integer vl_idx := sizeof(v_EPTF_StatHandler_resetComponents); |
| v_EPTF_StatHandler_resetComponents[vl_idx] := { |
| compRef := pl_sender, |
| sources := { |
| { |
| statIdx := vl_statIdx, |
| sourceIdx := vl_sourceIdx |
| } |
| }, |
| nofSources := 1 |
| } |
| v_EPTF_StatHandler_aggregatedStats.data[vl_statIdx].sources[vl_sourceIdx].resetCompIdx := vl_idx; |
| v_EPTF_StatHandler_aggregatedStats.data[vl_statIdx].sources[vl_sourceIdx].resetSourceIdx := 0; |
| } |
| |
| if(c_EPTF_Common_debugSwitch and f_EPTF_StatHandlerLogging_debugEnabled()) { |
| f_EPTF_StatHandlerLogging_debug(log2str(%definitionId, ": finished registering data source of component ", |
| pl_sourceCompRef, ": ", pl_providerVarList, " for stat ", pl_targetStatName)); |
| f_EPTF_StatHandlerLogging_debug(%definitionId&": aggregated stats database: " |
| &log2str(v_EPTF_StatHandler_aggregatedStats)); |
| f_EPTF_StatHandlerLogging_debug(%definitionId&": resetComponents database: " |
| &log2str(v_EPTF_StatHandler_resetComponents)); |
| } |
| |
| return true; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_checkVar |
| // |
| // Purpose: |
| // Function for checking variable type |
| // |
| // Parameters: |
| // pl_idx - *in* *integer* - variable index |
| // pl_template - *template* <EPTF_Var_DirectContent> - template to match to |
| // |
| // Return Value: |
| // *boolean* - true on match |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| // |
| /////////////////////////////////////////////////////////// |
| private function f_EPTF_StatHandler_checkVar(in integer pl_idx, template EPTF_Var_DirectContent pl_template, |
| in EPTF_Var_SubscriptionMode pl_subscriptionMode, in EPTF_StatHandler_ContentList pl_contentList, in integer pl_contentListIdx |
| ) |
| runs on EPTF_StatHandler_CT |
| return boolean |
| { |
| if (pl_subscriptionMode==pull) { |
| return match(pl_contentList[pl_contentListIdx], pl_template); |
| } |
| |
| var EPTF_Var_DirectContent vl_content; |
| f_EPTF_Var_getContent(pl_idx, vl_content); |
| return match(vl_content, pl_template); |
| } |
| |
| |
| // subscribes provider vars |
| private function f_EPTF_StatHandler_subscribeProvider( |
| in EPTF_Var_CT pl_remoteCompRef, |
| in charstring pl_remoteProviderVarName, |
| in EPTF_Var_SubscriptionMode pl_subscriptionMode, |
| out integer pl_idx, |
| in charstring pl_localName := "", |
| in integer pl_refreshRate := -1, |
| in EPTF_StatHandler_ContentList pl_contentList, |
| in integer pl_contentListIdx |
| ) runs on EPTF_StatHandler_CT { |
| if (pl_subscriptionMode==pull) { |
| pl_idx := f_EPTF_Var_newVar( |
| pl_name := pl_localName, |
| pl_initValue := pl_contentList[pl_contentListIdx] |
| ); |
| f_EPTF_Var_resubscribeRemote( |
| pl_remoteCompRef, |
| pl_remoteProviderVarName, |
| pl_subscriptionMode, |
| pl_idx, |
| f_EPTF_Var_getName(pl_idx), |
| pl_refreshRate |
| ); |
| } else { |
| f_EPTF_Var_subscribeRemote( |
| pl_remoteCompRef, |
| pl_remoteProviderVarName, |
| pl_subscriptionMode, |
| pl_idx, |
| pl_localName, |
| pl_refreshRate |
| ); |
| } |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_registerStat_Single |
| // |
| // Purpose: |
| // Function for registering a single data source for a statistic. |
| // |
| // Parameters: |
| // pl_sourceCompRef - *in* <EPTF_Var_CT> - component reference that has the source variable |
| // pl_sender - *in* <EPTF_StatHandlerClient_CT> - component reference of the sender of registerStat message |
| // pl_providerVarList - *in* <EPTF_CharstringList> - list of source variable names |
| // pl_contentList - *in* <EPTF_StatHandler_ContentList> - list of source variable values on the source component |
| // pl_subscriptionMode - *in* <EPTF_Var_SubscriptionMode> - subscription mode |
| // pl_statIdx - *in* *integer* - index of the stat to register to |
| // pl_varIdxList - *inout* <EPTF_IntegerList> - returned variable indexes |
| // pl_sourceUniqueId - *in* *integer* - unique ID for the source - will be used recursively for aux stats, can be used to deregister |
| // pl_refreshRate - *in* *integer* - the refresh rate of the subscription |
| // |
| // Return Value: |
| // *boolean* - true on success |
| // |
| // Errors & assertions: |
| // Invalid provider var list. |
| // |
| // Detailed Comments: |
| // - |
| /////////////////////////////////////////////////////////// |
| private function f_EPTF_StatHandler_registerStat_Single( |
| in EPTF_Var_CT pl_sourceCompRef, |
| in EPTF_StatHandlerClient_CT pl_sender, |
| in EPTF_CharstringList pl_providerVarList, |
| in EPTF_StatHandler_ContentList pl_contentList, |
| in EPTF_Var_SubscriptionMode pl_subscriptionMode, |
| in integer pl_statIdx, |
| out EPTF_IntegerList pl_varIdxList, |
| in integer pl_sourceUniqueId, |
| in integer pl_refreshRate) |
| runs on EPTF_StatHandler_CT |
| return boolean |
| { |
| // source should be single numerical value, same type as the target stat |
| if(sizeof(pl_providerVarList) != 1) { |
| f_EPTF_StatHandlerLogging_warning(%definitionId&": provider variable list for \"" & |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statMethod & |
| "\" statistics \"" & v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statName & |
| "\" has multiple elements, expected single numerical variable."); |
| return false; |
| } |
| |
| if(pl_sourceCompRef == self) { // put the variables directly in the database as source |
| pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_single] := f_EPTF_Var_getId(pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_single]); |
| } else { // subscribe to the remote variables |
| f_EPTF_StatHandler_subscribeProvider( |
| pl_sourceCompRef, |
| pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_single], |
| pl_subscriptionMode, |
| pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_single], |
| // note: Var is given a unique name to prevent "deregisterStat" from unsubscribing ALL stats' source with the same remote Var. |
| f_EPTF_StatHandler_getName(pl_statIdx)&"."&log2str(pl_sourceCompRef)&"."&pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_single], |
| pl_refreshRate, |
| pl_contentList,c_EPTF_StatHandler_providerVarIdx_single); |
| } |
| |
| // check type of provider variables |
| if( ( |
| ischosen(v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statResetValue.intVal) and |
| not f_EPTF_StatHandler_checkVar(pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_single], {intVal:=?}, |
| pl_subscriptionMode,pl_contentList,c_EPTF_StatHandler_providerVarIdx_single) |
| ) or ( |
| ischosen(v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statResetValue.floatVal) and |
| not f_EPTF_StatHandler_checkVar(pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_single], {floatVal:=?}, |
| pl_subscriptionMode,pl_contentList,c_EPTF_StatHandler_providerVarIdx_single) |
| ) ) { |
| f_EPTF_StatHandlerLogging_warning(%definitionId&": invalid source type for stat "& |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statName); |
| f_EPTF_Var_unsubscribe(pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_single]); |
| return false; |
| } |
| |
| return true; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_registerStat_Mean |
| // |
| // Purpose: |
| // Function for registering a data source for a mean statistic. |
| // |
| // Parameters: |
| // pl_sourceCompRef - *in* <EPTF_Var_CT> - component reference that has the source variable |
| // pl_sender - *in* <EPTF_StatHandlerClient_CT> - component reference of the sender of registerStat message |
| // pl_providerVarList - *in* <EPTF_CharstringList> - list of source variable names |
| // pl_contentList - *in* <EPTF_StatHandler_ContentList> - list of source variable values on the source component |
| // pl_subscriptionMode - *in* <EPTF_Var_SubscriptionMode> - subscription mode |
| // pl_statIdx - *in* *integer* - index of the stat to register to |
| // pl_varIdxList - *inout* <EPTF_IntegerList> - returned variable indexes |
| // pl_sourceUniqueId - *in* *integer* - unique ID for the source - will be used recursively for aux stats, can be used to deregister |
| // pl_refreshRate - *in* *integer* - the refresh rate of the subscription |
| // |
| // Return Value: |
| // *boolean* - true on success |
| // |
| // Errors & assertions: |
| // Invalid provider var list. |
| // |
| // Detailed Comments: |
| // - |
| /////////////////////////////////////////////////////////// |
| private function f_EPTF_StatHandler_registerStat_Mean( |
| in EPTF_Var_CT pl_sourceCompRef, |
| in EPTF_StatHandlerClient_CT pl_sender, |
| in EPTF_CharstringList pl_providerVarList, |
| in EPTF_StatHandler_ContentList pl_contentList, |
| in EPTF_Var_SubscriptionMode pl_subscriptionMode, |
| in integer pl_statIdx, |
| inout EPTF_IntegerList pl_varIdxList, |
| in integer pl_sourceUniqueId, |
| in integer pl_refreshRate) |
| runs on EPTF_StatHandler_CT |
| return boolean |
| { |
| //Mean: [0]: local mean (float), [1]: number of samples (int) |
| if(sizeof(pl_providerVarList) != 2) { |
| f_EPTF_StatHandlerLogging_warning(%definitionId&": provider variable list for \"" & |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statMethod & |
| "\" statistics \"" & v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statName & |
| "\" needs two elements: local mean and number of samples."); |
| return false; |
| } |
| |
| if(pl_sourceCompRef == self) { // put the variables directly in the database as source |
| pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_mean] := f_EPTF_Var_getId(pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_mean]); |
| pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_nofSamples] := f_EPTF_Var_getId(pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_nofSamples]); |
| } else { // subscribe to the remote variables |
| f_EPTF_StatHandler_subscribeProvider( |
| pl_sourceCompRef, |
| pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_mean], |
| pl_subscriptionMode, |
| pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_mean], |
| // note: Var is given a unique name to prevent "deregisterStat" from unsubscribing ALL stats' source with the same remote Var. |
| f_EPTF_StatHandler_getName(pl_statIdx)&"."&log2str(pl_sourceCompRef)&"."&pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_mean], |
| pl_refreshRate, |
| pl_contentList,c_EPTF_StatHandler_providerVarIdx_mean); |
| f_EPTF_StatHandler_subscribeProvider( |
| pl_sourceCompRef, |
| pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_nofSamples], |
| pl_subscriptionMode, |
| pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_nofSamples], |
| // note: Var is given a unique name to prevent "deregisterStat" from unsubscribing ALL stats' source with the same remote Var. |
| f_EPTF_StatHandler_getName(pl_statIdx)&"."&log2str(pl_sourceCompRef)&"."&pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_nofSamples], |
| pl_refreshRate, |
| pl_contentList,c_EPTF_StatHandler_providerVarIdx_nofSamples); |
| } |
| |
| // check type of provider variables |
| if( ( |
| not f_EPTF_StatHandler_checkVar(pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_mean], {floatVal:=?}, |
| pl_subscriptionMode,pl_contentList,c_EPTF_StatHandler_providerVarIdx_mean) |
| ) or ( |
| not f_EPTF_StatHandler_checkVar(pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_nofSamples], {intVal:=?}, |
| pl_subscriptionMode,pl_contentList,c_EPTF_StatHandler_providerVarIdx_nofSamples) |
| ) ) { |
| f_EPTF_StatHandlerLogging_warning(%definitionId&": invalid source types for stat " & |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statName); |
| f_EPTF_Var_unsubscribe(pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_mean]); |
| f_EPTF_Var_unsubscribe(pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_nofSamples]); |
| return false; |
| } |
| |
| return true; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_registerStat_StandardDev |
| // |
| // Purpose: |
| // Function for registering a data source for a standard deviation statistic. |
| // |
| // Parameters: |
| // pl_sourceCompRef - *in* <EPTF_Var_CT> - component reference that has the source variable |
| // pl_sender - *in* <EPTF_StatHandlerClient_CT> - component reference of the sender of registerStat message |
| // pl_providerVarList - *in* <EPTF_CharstringList> - list of source variable names |
| // pl_contentList - *in* <EPTF_StatHandler_ContentList> - list of source variable values on the source component |
| // pl_subscriptionMode - *in* <EPTF_Var_SubscriptionMode> - subscription mode |
| // pl_statIdx - *in* *integer* - index of the stat to register to |
| // pl_varIdxList - *inout* <EPTF_IntegerList> - returned variable indexes |
| // pl_sourceUniqueId - *in* *integer* - unique ID for the source - will be used recursively for aux stats, can be used to deregister |
| // pl_refreshRate - *in* *integer* - the refresh rate of the subscription |
| // |
| // Return Value: |
| // *boolean* - true on success |
| // |
| // Errors & assertions: |
| // Invalid provider var list. |
| // |
| // Detailed Comments: |
| // - |
| /////////////////////////////////////////////////////////// |
| private function f_EPTF_StatHandler_registerStat_StandardDev( |
| in EPTF_Var_CT pl_sourceCompRef, |
| in EPTF_StatHandlerClient_CT pl_sender, |
| in EPTF_CharstringList pl_providerVarList, |
| in EPTF_StatHandler_ContentList pl_contentList, |
| in EPTF_Var_SubscriptionMode pl_subscriptionMode, |
| in integer pl_statIdx, |
| inout EPTF_IntegerList pl_varIdxList, |
| in integer pl_sourceUniqueId, |
| in integer pl_refreshRate) |
| runs on EPTF_StatHandler_CT |
| return boolean |
| { |
| //StandardDev: [0]: local mean (float), [1]: number of samples (int), [2]: S |
| if(sizeof(pl_providerVarList) != 3) { |
| f_EPTF_StatHandlerLogging_warning(%definitionId&": provider variable list for \"" & |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statMethod & |
| "\" statistics \"" & v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statName & |
| "\" needs three elements: local mean, number of samples and S."); |
| return false; |
| } |
| |
| if(pl_sourceCompRef == self) { // put the variables directly in the database as source |
| pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_mean] := f_EPTF_Var_getId(pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_mean]); |
| pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_nofSamples] := f_EPTF_Var_getId(pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_nofSamples]); |
| pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_S] := f_EPTF_Var_getId(pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_S]); |
| } else { // subscribe to the remote variables |
| f_EPTF_StatHandler_subscribeProvider( |
| pl_sourceCompRef, |
| pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_mean], |
| pl_subscriptionMode, |
| pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_mean], |
| // note: Var is given a unique name to prevent "deregisterStat" from unsubscribing ALL stats' source with the same remote Var. |
| f_EPTF_StatHandler_getName(pl_statIdx)&"."&log2str(pl_sourceCompRef)&"."&pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_mean], |
| pl_refreshRate, |
| pl_contentList,c_EPTF_StatHandler_providerVarIdx_mean); |
| f_EPTF_StatHandler_subscribeProvider( |
| pl_sourceCompRef, |
| pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_nofSamples], |
| pl_subscriptionMode, |
| pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_nofSamples], |
| // note: Var is given a unique name to prevent "deregisterStat" from unsubscribing ALL stats' source with the same remote Var. |
| f_EPTF_StatHandler_getName(pl_statIdx)&"."&log2str(pl_sourceCompRef)&"."&pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_nofSamples], |
| pl_refreshRate, |
| pl_contentList,c_EPTF_StatHandler_providerVarIdx_nofSamples); |
| f_EPTF_StatHandler_subscribeProvider( |
| pl_sourceCompRef, |
| pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_S], |
| pl_subscriptionMode, |
| pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_S], |
| // note: Var is given a unique name to prevent "deregisterStat" from unsubscribing ALL stats' source with the same remote Var. |
| f_EPTF_StatHandler_getName(pl_statIdx)&"."&log2str(pl_sourceCompRef)&"."&pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_S], |
| pl_refreshRate, |
| pl_contentList,c_EPTF_StatHandler_providerVarIdx_S); |
| } |
| |
| // check type of provider variables |
| if( ( |
| not f_EPTF_StatHandler_checkVar(pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_mean], {floatVal:=?}, |
| pl_subscriptionMode,pl_contentList,c_EPTF_StatHandler_providerVarIdx_mean) |
| ) or ( |
| not f_EPTF_StatHandler_checkVar(pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_nofSamples], {intVal:=?}, |
| pl_subscriptionMode,pl_contentList,c_EPTF_StatHandler_providerVarIdx_nofSamples) |
| ) or ( |
| not f_EPTF_StatHandler_checkVar(pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_S], {floatVal:=?}, |
| pl_subscriptionMode,pl_contentList,c_EPTF_StatHandler_providerVarIdx_S) |
| ) ) { |
| f_EPTF_StatHandlerLogging_warning(%definitionId&": invalid source types for stat " & |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statName); |
| f_EPTF_Var_unsubscribe(pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_mean]); |
| f_EPTF_Var_unsubscribe(pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_nofSamples]); |
| f_EPTF_Var_unsubscribe(pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_S]); |
| return false; |
| } |
| |
| return true; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_registerStat_GlobalAverage |
| // |
| // Purpose: |
| // Function for registering a data source for a global average statistic. |
| // |
| // Parameters: |
| // pl_sourceCompRef - *in* <EPTF_Var_CT> - component reference that has the source variable |
| // pl_sender - *in* <EPTF_StatHandlerClient_CT> - component reference of the sender of registerStat message |
| // pl_providerVarList - *in* <EPTF_CharstringList> - list of source variable names |
| // pl_contentList - *in* <EPTF_StatHandler_ContentList> - list of source variable values on the source component |
| // pl_subscriptionMode - *in* <EPTF_Var_SubscriptionMode> - subscription mode |
| // pl_statIdx - *in* *integer* - index of the stat to register to |
| // pl_varIdxList - *inout* <EPTF_IntegerList> - returned variable indexes |
| // pl_sourceUniqueId - *in* *integer* - unique ID for the source - will be used recursively for aux stats, can be used to deregister |
| // pl_refreshRate - *in* *integer* - the refresh rate of the subscription |
| // |
| // Return Value: |
| // *boolean* - true on success |
| // |
| // Errors & assertions: |
| // Invalid provider var list. |
| // |
| // Detailed Comments: |
| // - |
| /////////////////////////////////////////////////////////// |
| private function f_EPTF_StatHandler_registerStat_GlobalAverage( |
| in EPTF_Var_CT pl_sourceCompRef, |
| in EPTF_StatHandlerClient_CT pl_sender, |
| in EPTF_CharstringList pl_providerVarList, |
| in EPTF_StatHandler_ContentList pl_contentList, |
| in EPTF_Var_SubscriptionMode pl_subscriptionMode, |
| in integer pl_statIdx, |
| inout EPTF_IntegerList pl_varIdxList, |
| in integer pl_sourceUniqueId, |
| in integer pl_refreshRate) |
| runs on EPTF_StatHandler_CT |
| return boolean |
| { |
| //GlobalAverage: [0]: sum (float), [1]: number of elements (int) |
| if(sizeof(pl_providerVarList) != 2) { |
| f_EPTF_StatHandlerLogging_warning(%definitionId&": provider variable list for \"" & |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statMethod & |
| "\" statistics \"" & v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statName & |
| "\" needs two elements: sum and element number."); |
| return false; |
| } |
| |
| if(pl_sourceCompRef == self) { // put the variables directly in the database as source |
| pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_sum] := f_EPTF_Var_getId(pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_sum]); |
| pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_elementNumber] := f_EPTF_Var_getId(pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_elementNumber]); |
| } else { // subscribe to the remote variables |
| f_EPTF_StatHandler_subscribeProvider( |
| pl_sourceCompRef, |
| pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_sum], |
| pl_subscriptionMode, |
| pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_sum], |
| // note: Var is given a unique name to prevent "deregisterStat" from unsubscribing ALL stats' source with the same remote Var. |
| f_EPTF_StatHandler_getName(pl_statIdx)&"."&log2str(pl_sourceCompRef)&"."&pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_sum], |
| pl_refreshRate, |
| pl_contentList,c_EPTF_StatHandler_providerVarIdx_sum); |
| f_EPTF_StatHandler_subscribeProvider( |
| pl_sourceCompRef, |
| pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_elementNumber], |
| pl_subscriptionMode, |
| pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_elementNumber], |
| // note: Var is given a unique name to prevent "deregisterStat" from unsubscribing ALL stats' source with the same remote Var. |
| f_EPTF_StatHandler_getName(pl_statIdx)&"."&log2str(pl_sourceCompRef)&"."&pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_elementNumber], |
| pl_refreshRate, |
| pl_contentList,c_EPTF_StatHandler_providerVarIdx_elementNumber); |
| } |
| |
| // check type of provider variables |
| if( ( |
| not f_EPTF_StatHandler_checkVar(pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_sum], {floatVal:=?}, |
| pl_subscriptionMode,pl_contentList,c_EPTF_StatHandler_providerVarIdx_sum) |
| ) or ( |
| not f_EPTF_StatHandler_checkVar(pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_elementNumber], {intVal:=?}, |
| pl_subscriptionMode,pl_contentList,c_EPTF_StatHandler_providerVarIdx_elementNumber) |
| ) ) { |
| f_EPTF_StatHandlerLogging_warning(%definitionId&": invalid source types for stat " & |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statName); |
| f_EPTF_Var_unsubscribe(pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_sum]); |
| f_EPTF_Var_unsubscribe(pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_elementNumber]); |
| return false; |
| } |
| |
| return true; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_registerStat_Density |
| // |
| // Purpose: |
| // Function for registering a data source for a density statistic. |
| // |
| // Parameters: |
| // pl_sourceCompRef - *in* <EPTF_Var_CT> - component reference that has the source variable |
| // pl_sender - *in* <EPTF_StatHandlerClient_CT> - component reference of the sender of registerStat message |
| // pl_providerVarList - *in* <EPTF_CharstringList> - list of source variable names |
| // pl_contentList - *in* <EPTF_StatHandler_ContentList> - list of source variable values on the source component |
| // pl_subscriptionMode - *in* <EPTF_Var_SubscriptionMode> - subscription mode |
| // pl_statIdx - *in* *integer* - index of the stat to register to |
| // pl_varIdxList - *inout* <EPTF_IntegerList> - returned variable indexes |
| // pl_sourceUniqueId - *in* *integer* - unique ID for the source - will be used recursively for aux stats, can be used to deregister |
| // pl_refreshRate - *in* *integer* - the refresh rate of the subscription |
| // |
| // Return Value: |
| // *boolean* - true on success |
| // |
| // Errors & assertions: |
| // Invalid provider var list. |
| // |
| // Detailed Comments: |
| // - |
| /////////////////////////////////////////////////////////// |
| private function f_EPTF_StatHandler_registerStat_Density( |
| in EPTF_Var_CT pl_sourceCompRef, |
| in EPTF_StatHandlerClient_CT pl_sender, |
| in EPTF_CharstringList pl_providerVarList, |
| in EPTF_StatHandler_ContentList pl_contentList, |
| in EPTF_Var_SubscriptionMode pl_subscriptionMode, |
| in integer pl_statIdx, |
| inout EPTF_IntegerList pl_varIdxList, |
| in integer pl_sourceUniqueId, |
| in integer pl_refreshRate) |
| runs on EPTF_StatHandler_CT |
| return boolean |
| { |
| //Density: [0]: density distr.bin values (integerList), [1]: distr.bin boundaries (floatList) |
| if(sizeof(pl_providerVarList) != 2) { |
| f_EPTF_StatHandlerLogging_warning(%definitionId&": provider variable list for \"" & |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statMethod & |
| "\" statistics \"" & v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statName & |
| "\" needs two elements: density and boundaries."); |
| return false; |
| } |
| |
| var EPTF_Var_DirectContent vl_boundaries; |
| |
| if(pl_sourceCompRef == self) { // put the variables directly in the database as source |
| pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_density] := f_EPTF_Var_getId(pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_density]); |
| pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_boundaries] := f_EPTF_Var_getId(pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_boundaries]); |
| } else { // subscribe to the remote variables |
| f_EPTF_StatHandler_subscribeProvider( |
| pl_sourceCompRef, |
| pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_density], |
| pl_subscriptionMode, |
| pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_density], |
| // note: Var is given a unique name to prevent "deregisterStat" from unsubscribing ALL stats' source with the same remote Var. |
| f_EPTF_StatHandler_getName(pl_statIdx)&"."&log2str(pl_sourceCompRef)&"."&pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_density], |
| pl_refreshRate, |
| pl_contentList,c_EPTF_StatHandler_providerVarIdx_density); |
| f_EPTF_StatHandler_subscribeProvider( |
| pl_sourceCompRef, |
| pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_boundaries], |
| pl_subscriptionMode, |
| pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_boundaries], |
| // note: Var is given a unique name to prevent "deregisterStat" from unsubscribing ALL stats' source with the same remote Var. |
| f_EPTF_StatHandler_getName(pl_statIdx)&"."&log2str(pl_sourceCompRef)&"."&pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_boundaries], |
| pl_refreshRate, |
| pl_contentList,c_EPTF_StatHandler_providerVarIdx_boundaries); |
| } |
| |
| if (pl_subscriptionMode!=pull) { |
| f_EPTF_Var_getContent(pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_boundaries], vl_boundaries); |
| } else { |
| vl_boundaries := pl_contentList[c_EPTF_StatHandler_providerVarIdx_boundaries]; |
| } |
| |
| // check type of provider variables |
| if( ( |
| not f_EPTF_StatHandler_checkVar(pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_density], {integerlistVal:=?}, |
| pl_subscriptionMode,pl_contentList,c_EPTF_StatHandler_providerVarIdx_density) |
| ) or ( |
| not ischosen(vl_boundaries.floatlistVal) |
| ) ) { |
| f_EPTF_StatHandlerLogging_warning(%definitionId&": invalid source types for stat " & |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statName); |
| f_EPTF_Var_unsubscribe(pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_density]); |
| f_EPTF_Var_unsubscribe(pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_boundaries]); |
| return false; |
| } |
| |
| // if first source, setup aux `boundaries' variable of the stat |
| if(f_EPTF_FBQ_getLengthOfBusyChain(v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].sourceQueue) == 0) { |
| f_EPTF_Var_adjustContent(v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].auxVars[c_EPTF_StatHandler_auxVarIdx_boundaries], |
| vl_boundaries); |
| if(v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].parentIdx >= 0) { |
| // setting the reset value for aux density stat of percentile95 (and percentileP) |
| f_EPTF_Var_getContent( |
| pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_density], |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statResetValue); |
| //FIXME: use this instead of getContent? : v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statResetValue := pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_density]; |
| for(var integer i:=0; i<sizeof(v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statResetValue.integerlistVal); i:=i+1) { |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statResetValue.integerlistVal[i] := 0; |
| } |
| f_EPTF_StatHandlerLogging_debug(%definitionId&": changed reset value of stat " & |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statName & " to " & |
| log2str(v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statResetValue)); |
| } |
| } |
| |
| // otherwise, check if the boundaries are the same as stored in the aux var |
| else { |
| var EPTF_Var_DirectContent vl_storedBoundaries; |
| f_EPTF_Var_getContent(v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].auxVars[c_EPTF_StatHandler_auxVarIdx_boundaries], |
| vl_storedBoundaries); |
| if(vl_boundaries != vl_storedBoundaries) { |
| f_EPTF_StatHandlerLogging_warning(log2str(%definitionId&": boundaries ", vl_boundaries, |
| " of source differs from boundaries", vl_storedBoundaries, " stored for the stat ", |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statName)); |
| f_EPTF_Var_unsubscribe(pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_density]); |
| f_EPTF_Var_unsubscribe(pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_boundaries]); |
| return false; |
| } |
| } |
| |
| f_EPTF_Var_addPostProcFn(pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_boundaries], |
| {refers(f_EPTF_StatHandler_boundariesPostproc), {pl_statIdx}}); |
| |
| return true; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_registerStat_PercentileP |
| // |
| // Purpose: |
| // Function for registering a data source for a PercentileP (and Percentile95) statistic. |
| // |
| // Parameters: |
| // pl_sourceCompRef - *in* <EPTF_Var_CT> - component reference that has the source variable |
| // pl_sender - *in* <EPTF_StatHandlerClient_CT> - component reference of the sender of registerStat message |
| // pl_providerVarList - *in* <EPTF_CharstringList> - list of source variable names |
| // pl_contentList - *in* <EPTF_StatHandler_ContentList> - list of source variable values on the source component |
| // pl_subscriptionMode - *in* <EPTF_Var_SubscriptionMode> - subscription mode |
| // pl_statIdx - *in* *integer* - index of the stat to register to |
| // pl_varIdxList - *inout* <EPTF_IntegerList> - returned variable indexes |
| // pl_sourceUniqueId - *in* *integer* - unique ID for the source - will be used recursively for aux stats, can be used to deregister |
| // pl_refreshRate - *in* *integer* - the refresh rate of the subscription |
| // |
| // Return Value: |
| // *boolean* - true on success |
| // |
| // Errors & assertions: |
| // Invalid provider var list. |
| // |
| // Detailed Comments: |
| // - |
| /////////////////////////////////////////////////////////// |
| private function f_EPTF_StatHandler_registerStat_PercentileP( |
| in EPTF_Var_CT pl_sourceCompRef, |
| in EPTF_StatHandlerClient_CT pl_sender, |
| in EPTF_CharstringList pl_providerVarList, |
| in EPTF_StatHandler_ContentList pl_contentList, |
| in EPTF_Var_SubscriptionMode pl_subscriptionMode, |
| in integer pl_statIdx, |
| inout EPTF_IntegerList pl_varIdxList, |
| in integer pl_sourceUniqueId, |
| in integer pl_refreshRate) |
| runs on EPTF_StatHandler_CT |
| return boolean |
| { |
| if(sizeof(pl_providerVarList) != 4) { |
| f_EPTF_StatHandlerLogging_warning(%definitionId&": provider variable list for \"" & |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statMethod & |
| "\" statistics \"" & v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statName & |
| "\" needs four elements: density, boundaries, max and pValue."); |
| return false; |
| } |
| |
| // density aux stat |
| var EPTF_CharstringList vl_auxProviderVarList := {}; |
| var EPTF_StatHandler_ContentList vl_auxProviderContentList := {}; |
| vl_auxProviderVarList[c_EPTF_StatHandler_providerVarIdx_density] := pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_density]; |
| vl_auxProviderVarList[c_EPTF_StatHandler_providerVarIdx_boundaries] := pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_boundaries]; |
| if (pl_subscriptionMode==pull) { |
| vl_auxProviderContentList[c_EPTF_StatHandler_providerVarIdx_density] := pl_contentList[c_EPTF_StatHandler_providerVarIdx_density]; |
| vl_auxProviderContentList[c_EPTF_StatHandler_providerVarIdx_boundaries] := pl_contentList[c_EPTF_StatHandler_providerVarIdx_boundaries]; |
| } |
| var integer vl_auxIdx := v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].auxStats[c_EPTF_StatHandler_auxStatIdx_density]; |
| var charstring vl_auxName := v_EPTF_StatHandler_aggregatedStats.data[vl_auxIdx].statName; |
| if(not f_EPTF_StatHandler_registerStat( |
| pl_sourceCompRef, |
| pl_sender, |
| vl_auxProviderVarList, |
| vl_auxProviderContentList, |
| pl_subscriptionMode, |
| vl_auxName, |
| pl_sourceUniqueId, |
| pl_refreshRate)) { |
| f_EPTF_StatHandlerLogging_warning(log2str(%definitionId&": could not register source for aux stat ", vl_auxName)); |
| return false; |
| } |
| |
| // max aux stat |
| vl_auxProviderVarList := {}; |
| vl_auxProviderContentList := {}; |
| vl_auxProviderVarList[c_EPTF_StatHandler_providerVarIdx_single] := pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_max]; |
| if (pl_subscriptionMode==pull) { |
| vl_auxProviderContentList[c_EPTF_StatHandler_providerVarIdx_single] := pl_contentList[c_EPTF_StatHandler_providerVarIdx_max]; |
| } |
| vl_auxIdx := v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].auxStats[c_EPTF_StatHandler_auxStatIdx_max]; |
| vl_auxName := v_EPTF_StatHandler_aggregatedStats.data[vl_auxIdx].statName; |
| if(not f_EPTF_StatHandler_registerStat( |
| pl_sourceCompRef, |
| pl_sender, |
| vl_auxProviderVarList, |
| vl_auxProviderContentList, |
| pl_subscriptionMode, |
| vl_auxName, |
| pl_sourceUniqueId, |
| pl_refreshRate)) { |
| f_EPTF_StatHandlerLogging_warning(log2str(%definitionId&": could not register source for aux stat ", vl_auxName)); |
| return false; |
| } |
| |
| //PercentileP: [0]: density distr.bin values (integerList), [1]: distr.bin boundaries (floatList, check only), [2]: max (float) [3]: pValue (float) |
| |
| if(pl_sourceCompRef == self) { // put the variables directly in the database as source |
| pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_density] := f_EPTF_Var_getId(pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_density]); |
| pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_boundaries] := f_EPTF_Var_getId(pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_boundaries]); |
| pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_max] := f_EPTF_Var_getId(pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_max]); |
| } else { // subscribe to the remote variables |
| f_EPTF_StatHandler_subscribeProvider( |
| pl_sourceCompRef, |
| pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_density], |
| pl_subscriptionMode, |
| pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_density], |
| // note: Var is given a unique name to prevent "deregisterStat" from unsubscribing ALL stats' source with the same remote Var. |
| f_EPTF_StatHandler_getName(pl_statIdx)&"."&log2str(pl_sourceCompRef)&"."&pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_density], |
| pl_refreshRate, |
| pl_contentList,c_EPTF_StatHandler_providerVarIdx_density); |
| f_EPTF_StatHandler_subscribeProvider( |
| pl_sourceCompRef, |
| pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_boundaries], |
| pl_subscriptionMode, |
| pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_boundaries], |
| // note: Var is given a unique name to prevent "deregisterStat" from unsubscribing ALL stats' source with the same remote Var. |
| f_EPTF_StatHandler_getName(pl_statIdx)&"."&log2str(pl_sourceCompRef)&"."&pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_boundaries], |
| pl_refreshRate, |
| pl_contentList,c_EPTF_StatHandler_providerVarIdx_boundaries); |
| f_EPTF_StatHandler_subscribeProvider( |
| pl_sourceCompRef, |
| pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_max], |
| pl_subscriptionMode, |
| pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_max], |
| // note: Var is given a unique name to prevent "deregisterStat" from unsubscribing ALL stats' source with the same remote Var. |
| f_EPTF_StatHandler_getName(pl_statIdx)&"."&log2str(pl_sourceCompRef)&"."&pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_max], |
| pl_refreshRate, |
| pl_contentList,c_EPTF_StatHandler_providerVarIdx_max); |
| } |
| |
| // Var types already checked when registering for aux stats |
| |
| if(pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_pValue]=="") { |
| //Percentile95 statistics arrived, pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_pValue] is empty |
| return true; |
| } |
| |
| // pValue aux |
| if(pl_sourceCompRef == self) { // put the variables directly in the database as source |
| |
| pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_pValue] := f_EPTF_Var_getId(pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_pValue]); |
| } else { // subscribe to the remote variables |
| f_EPTF_StatHandler_subscribeProvider( |
| pl_sourceCompRef, |
| pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_pValue], |
| pl_subscriptionMode, |
| pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_pValue], |
| // note: Var is given a unique name to prevent "deregisterStat" from unsubscribing ALL stats' source with the same remote Var. |
| f_EPTF_StatHandler_getName(pl_statIdx)&"."&log2str(pl_sourceCompRef)&"."&pl_providerVarList[c_EPTF_StatHandler_providerVarIdx_pValue], |
| pl_refreshRate, |
| pl_contentList,c_EPTF_StatHandler_providerVarIdx_pValue); |
| } |
| |
| // Var types already checked when registering for aux stats |
| |
| var EPTF_Var_DirectContent vl_pValue; |
| if (pl_subscriptionMode!=pull) { |
| f_EPTF_Var_getContent(pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_pValue], vl_pValue); |
| } else { |
| vl_pValue := pl_contentList[c_EPTF_StatHandler_providerVarIdx_pValue]; |
| } |
| |
| // if first source, setup aux `pValue' variable of the stat |
| if(f_EPTF_FBQ_getLengthOfBusyChain(v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].sourceQueue) == 0) { |
| f_EPTF_Var_adjustContent(v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].auxVars[c_EPTF_StatHandler_auxVarIdx_pValue], |
| vl_pValue); |
| } |
| // otherwise, check if the boundaries are the same as stored in the aux var |
| else { |
| var EPTF_Var_DirectContent vl_storedPValue; |
| f_EPTF_Var_getContent(v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].auxVars[c_EPTF_StatHandler_auxVarIdx_pValue], |
| vl_storedPValue); |
| if(vl_pValue != vl_storedPValue) { |
| f_EPTF_StatHandlerLogging_warning(log2str(%definitionId&": pValue ", vl_pValue, |
| " of source differs from pValue", vl_storedPValue, " stored for the stat ", |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statName&", Could not register source.")); |
| f_EPTF_Var_unsubscribe(pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_density]); |
| f_EPTF_Var_unsubscribe(pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_boundaries]); |
| f_EPTF_Var_unsubscribe(pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_max]); |
| f_EPTF_Var_unsubscribe(pl_varIdxList[c_EPTF_StatHandler_sourceVarIdx_pValue]); |
| return false; |
| } |
| } |
| |
| return true; |
| } |
| |
| // returns true if the two floatlists are equal (prevents 15.0000 not equals 15.0000) |
| private function f_EPTF_StatHandler_compareFloatLists(in EPTF_FloatList pl_arg1, in EPTF_FloatList pl_arg2) return boolean { |
| if (sizeof(pl_arg1)!=sizeof(pl_arg2)) { |
| return false; |
| } |
| for(var integer i:=0, size:=sizeof(pl_arg1); i<size; i:=i+1) { |
| if ((pl_arg1[i]-pl_arg2[i])*(pl_arg1[i]-pl_arg2[i])>pl_arg1[i]*pl_arg1[i]*0.000000001) { |
| return false; |
| } |
| } |
| return true; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Type: f_EPTF_StatHandler_boundariesPostproc |
| // |
| // Purpose: |
| // Postproc function for boundaries Var |
| // |
| // Parameters: |
| // pl_idx - *integer* - index of the EPTF Variable, |
| // pl_argList - <EPTF_IntegerList> - the arguments |
| // |
| // Detailed Comments: |
| // Cancels registration of source if boundaries change. |
| // Used for density, Percentile95 and PercentileP stats. |
| // Arguments in pl_argList: [0]: statIdx |
| // Source index determined by searching for provider Var pl_idx |
| /////////////////////////////////////////////////////////// |
| private function f_EPTF_StatHandler_boundariesPostproc( |
| in integer pl_idx, |
| in EPTF_IntegerList pl_argList) |
| runs on EPTF_StatHandler_CT |
| { |
| var EPTF_Var_DirectContent vl_new, vl_old; |
| f_EPTF_Var_getContent(pl_idx, vl_new); |
| f_EPTF_Var_getContent(v_EPTF_StatHandler_aggregatedStats.data[pl_argList[0]].auxVars[c_EPTF_StatHandler_auxVarIdx_boundaries], vl_old); |
| |
| if (ischosen(vl_old.floatlistVal) and ischosen(vl_new.floatlistVal)) { |
| if(f_EPTF_StatHandler_compareFloatLists(vl_old.floatlistVal,vl_new.floatlistVal)) { return; } // Fixes sampledAtSync subscription refreshing the value even if no change (use sampled instead). |
| } else { |
| if(vl_old == vl_new) { return; } // Fixes sampledAtSync subscription refreshing the value even if no change (use sampled instead). |
| } |
| |
| var integer vl_sourceIdx := -1; |
| var integer vl_idx := -1; |
| if(not f_EPTF_FBQ_getBusyHeadIdx(vl_idx, v_EPTF_StatHandler_aggregatedStats.data[pl_argList[0]].sourceQueue)) { |
| f_EPTF_Base_assert(%definitionId&": f_EPTF_FBQ_getBusyHeadIdx failed", false); |
| } |
| for(var integer i:=0; i<f_EPTF_FBQ_getLengthOfBusyChain(v_EPTF_StatHandler_aggregatedStats.data[pl_argList[0]].sourceQueue); i:=i+1) { |
| for(var integer j:=0; j<sizeof(v_EPTF_StatHandler_aggregatedStats.data[pl_argList[0]].sources[vl_idx].varIdxList); j:=j+1) { |
| if(pl_idx == v_EPTF_StatHandler_aggregatedStats.data[pl_argList[0]].sources[vl_idx].varIdxList[j]) { |
| vl_sourceIdx := vl_idx; // source with idx 'vl_idx' provides Variable pl_idx at index 'j' |
| break; |
| } |
| } |
| if(vl_sourceIdx >= 0) { break; } |
| if(not f_EPTF_FBQ_getFwdBusyItemIdx(vl_idx, v_EPTF_StatHandler_aggregatedStats.data[pl_argList[0]].sourceQueue)) { |
| /*do nothing*/ |
| } |
| } |
| if(vl_sourceIdx >= 0) { |
| f_EPTF_StatHandlerLogging_warning(%definitionId&": \"boundaries\" part of source "&int2str(vl_sourceIdx)& |
| " changed for stat "&v_EPTF_StatHandler_aggregatedStats.data[pl_argList[0]].statName& |
| " from "&log2str(vl_old)&" to "&log2str(vl_new)); |
| f_EPTF_StatHandler_cancelRegister(pl_argList[0], vl_sourceIdx); |
| if(v_EPTF_StatHandler_aggregatedStats.data[pl_argList[0]].parentIdx >= 0) { |
| f_EPTF_StatHandler_cancelRegister(v_EPTF_StatHandler_aggregatedStats.data[pl_argList[0]].parentIdx, vl_sourceIdx); |
| } |
| } else { |
| f_EPTF_StatHandlerLogging_warning(%definitionId&": source providing Variable with index "&int2str(pl_idx)& |
| " not found in stat "&v_EPTF_StatHandler_aggregatedStats.data[pl_argList[0]].statName); |
| } |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_deregisterStat |
| // |
| // Purpose: |
| // Function for de-registering data sources of a stat provided by a client |
| // |
| // Parameters: |
| // pl_sourceCompRef - *in* <EPTF_Var_CT> - component reference that has the source variable |
| // pl_providerVarList - *in* <EPTF_CharstringList> - name of one of the provider Vars |
| // pl_targetStatName - *in* *charstring* - name of the stat to de-register from |
| // |
| // Return Value: |
| // *boolean* - true on success |
| // |
| // Errors & assertions: |
| // Nonexistent statistic. |
| // |
| // Detailed Comments: |
| // If pl_providerVar is empty string, *all* sources provided by the component is deregistered. |
| /////////////////////////////////////////////////////////// |
| private function f_EPTF_StatHandler_deregisterStat( |
| in EPTF_Var_CT pl_sourceCompRef, |
| in charstring pl_targetStatName, |
| in EPTF_CharstringList pl_providerVarList) |
| runs on EPTF_StatHandler_CT |
| return boolean |
| { |
| var integer vl_targetStatIdx := f_EPTF_StatHandler_getId(pl_targetStatName); |
| if(vl_targetStatIdx < 0) { |
| return false; |
| } |
| if(lengthof(pl_providerVarList) == 0) { |
| var integer vl_idx := -1; |
| if(not f_EPTF_FBQ_getBusyHeadIdx(vl_idx, v_EPTF_StatHandler_aggregatedStats.data[vl_targetStatIdx].sourceQueue)) { |
| f_EPTF_Base_assert(%definitionId&": f_EPTF_FBQ_getBusyHeadIdx failed", false); |
| } |
| for(var integer i:=0; |
| i<f_EPTF_FBQ_getLengthOfBusyChain(v_EPTF_StatHandler_aggregatedStats.data[vl_targetStatIdx].sourceQueue); |
| i:=i+1) { |
| if(v_EPTF_StatHandler_aggregatedStats.data[vl_targetStatIdx].sources[vl_idx].compRef == pl_sourceCompRef) { |
| f_EPTF_StatHandler_deregisterStatByIdx(vl_idx, vl_targetStatIdx); |
| } |
| if(not f_EPTF_FBQ_getFwdBusyItemIdx(vl_idx, v_EPTF_StatHandler_aggregatedStats.data[vl_targetStatIdx].sourceQueue)) { |
| /*do nothing*/ |
| } |
| } |
| } else { |
| var integer vl_idx := -1; |
| if(not f_EPTF_FBQ_getBusyHeadIdx(vl_idx, v_EPTF_StatHandler_aggregatedStats.data[vl_targetStatIdx].sourceQueue)) { |
| f_EPTF_Base_assert(%definitionId&": f_EPTF_FBQ_getBusyHeadIdx failed", false); |
| } |
| for(var integer i:=0; |
| i<f_EPTF_FBQ_getLengthOfBusyChain(v_EPTF_StatHandler_aggregatedStats.data[vl_targetStatIdx].sourceQueue); |
| i:=i+1) { |
| if(v_EPTF_StatHandler_aggregatedStats.data[vl_targetStatIdx].sources[vl_idx].compRef == pl_sourceCompRef and |
| v_EPTF_StatHandler_aggregatedStats.data[vl_targetStatIdx].sources[vl_idx].varNameList == pl_providerVarList) { |
| f_EPTF_StatHandler_deregisterStatByIdx(vl_idx, vl_targetStatIdx); |
| break; |
| } |
| if(not f_EPTF_FBQ_getFwdBusyItemIdx(vl_idx, v_EPTF_StatHandler_aggregatedStats.data[vl_targetStatIdx].sourceQueue)) { |
| /*do nothing*/ |
| } |
| } |
| } |
| |
| if(c_EPTF_Common_debugSwitch and f_EPTF_StatHandlerLogging_debugEnabled()) { |
| f_EPTF_StatHandlerLogging_debug(log2str(%definitionId, ": finished deregistering data source of component ", |
| pl_sourceCompRef, ": ", pl_providerVarList, " from stat ", pl_targetStatName)); |
| f_EPTF_StatHandlerLogging_debug(%definitionId&": aggregated stats database: " |
| &log2str(v_EPTF_StatHandler_aggregatedStats)); |
| f_EPTF_StatHandlerLogging_debug(%definitionId&": resetComponents database: " |
| &log2str(v_EPTF_StatHandler_resetComponents)); |
| } |
| return true; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_deregisterStatByIdx |
| // |
| // Purpose: |
| // Function for de-registering a data source of a stat and its aux stats |
| // |
| // Parameters: |
| // pl_sourceUniqueId - *in* *integer* - name of one of the provider Vars |
| // pl_targetStatIdx - *in* *integer* - index of the stat to de-register from |
| // |
| // Return Value: |
| // - |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| /////////////////////////////////////////////////////////// |
| private function f_EPTF_StatHandler_deregisterStatByIdx( |
| in integer pl_sourceUniqueId, |
| in integer pl_targetStatIdx) |
| runs on EPTF_StatHandler_CT |
| { |
| // note there's a high chance that the unique ID is the index of the source, so check that first |
| // the only exception could be if an aux stat has some extra data sources (more than the original stat has) |
| f_EPTF_Base_assert(%definitionId&": source unique ID is negative.", pl_sourceUniqueId >= 0); |
| if(pl_sourceUniqueId < sizeof(v_EPTF_StatHandler_aggregatedStats.data[pl_targetStatIdx].sources) and |
| pl_sourceUniqueId == v_EPTF_StatHandler_aggregatedStats.data[pl_targetStatIdx].sources[pl_sourceUniqueId].uniqueId) { |
| f_EPTF_StatHandler_removeSource(pl_targetStatIdx, pl_sourceUniqueId); |
| } else { |
| var integer vl_idx := -1; |
| if(not f_EPTF_FBQ_getBusyHeadIdx(vl_idx, v_EPTF_StatHandler_aggregatedStats.data[pl_targetStatIdx].sourceQueue)) { |
| f_EPTF_Base_assert(%definitionId&": f_EPTF_FBQ_getBusyHeadIdx failed", false); |
| } |
| for(var integer i:=0; |
| i<f_EPTF_FBQ_getLengthOfBusyChain(v_EPTF_StatHandler_aggregatedStats.data[pl_targetStatIdx].sourceQueue); |
| i:=i+1) { |
| if(pl_sourceUniqueId == v_EPTF_StatHandler_aggregatedStats.data[pl_targetStatIdx].sources[vl_idx].uniqueId) { |
| f_EPTF_StatHandler_removeSource(pl_targetStatIdx, vl_idx); |
| break; |
| } |
| if(not f_EPTF_FBQ_getFwdBusyItemIdx(vl_idx, v_EPTF_StatHandler_aggregatedStats.data[pl_targetStatIdx].sourceQueue)) { |
| /*do nothing*/ |
| } |
| } |
| } |
| if(c_EPTF_Common_debugSwitch and f_EPTF_StatHandlerLogging_debugEnabled()) { |
| f_EPTF_StatHandlerLogging_debug(%definitionId&": deregistered sources with unique ID " |
| &int2str(pl_sourceUniqueId)&" from stat "&f_EPTF_StatHandler_getName(pl_targetStatIdx)); |
| f_EPTF_StatHandlerLogging_debug(%definitionId&": sources: "&log2str(v_EPTF_StatHandler_aggregatedStats.data[pl_targetStatIdx].sources)); |
| } |
| |
| for(var integer vl_aux:=0; vl_aux<sizeof(v_EPTF_StatHandler_aggregatedStats.data[pl_targetStatIdx].auxStats); vl_aux:=vl_aux+1) { |
| var integer vl_auxIdx := v_EPTF_StatHandler_aggregatedStats.data[pl_targetStatIdx].auxStats[vl_aux]; |
| f_EPTF_StatHandlerLogging_debug(%definitionId&": deregistering data sources from aux stat " |
| &v_EPTF_StatHandler_aggregatedStats.data[vl_auxIdx].statName); |
| f_EPTF_StatHandler_deregisterStatByIdx( |
| pl_sourceUniqueId, |
| vl_auxIdx); |
| } |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_removeSource |
| // |
| // Purpose: |
| // Function for removing a data source of a stat |
| // |
| // Parameters: |
| // pl_statIdx - *in* *integer* - statistics index |
| // pl_sourceIdx - *in* *integer* - source index of the stat |
| // |
| // Return Value: |
| // - |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // Deregisters a single source from a statistics and its aux stats |
| /////////////////////////////////////////////////////////// |
| private function f_EPTF_StatHandler_removeSource( |
| in integer pl_statIdx, |
| in integer pl_sourceIdx) |
| runs on EPTF_StatHandler_CT |
| { |
| f_EPTF_Var_removeLocalProviders( |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statVarIdx, |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].sources[pl_sourceIdx].varIdxList); |
| f_EPTF_Var_refreshContent(v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statVarIdx); |
| |
| if(v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].sources[pl_sourceIdx].compRef != self) { |
| for(var integer vl_varIdx := 0; |
| vl_varIdx < sizeof(v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].sources[pl_sourceIdx].varIdxList); |
| vl_varIdx := vl_varIdx + 1) { |
| // f_EPTF_Var_unsubscribe(v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].sources[pl_sourceIdx].varIdxList[vl_varIdx]); |
| } |
| } |
| var integer vl_cIdx := v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].sources[pl_sourceIdx].resetCompIdx; |
| var integer vl_sIdx := v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].sources[pl_sourceIdx].resetSourceIdx; |
| var integer vl_nofS := v_EPTF_StatHandler_resetComponents[vl_cIdx].nofSources; |
| v_EPTF_StatHandler_resetComponents[vl_cIdx].sources[vl_sIdx] := |
| v_EPTF_StatHandler_resetComponents[vl_cIdx].sources[vl_nofS - 1]; |
| v_EPTF_StatHandler_resetComponents[vl_cIdx].nofSources := |
| v_EPTF_StatHandler_resetComponents[vl_cIdx].nofSources - 1; |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].sources[pl_sourceIdx] := c_empty_EPTF_StatHandler_StatOfComponent; |
| f_EPTF_FBQ_moveFromBusyToFreeTail(pl_sourceIdx, v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].sourceQueue); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_cancelRegister |
| // |
| // Purpose: |
| // Function for cancelling the registeration of a data source of a stat |
| // |
| // Parameters: |
| // pl_statIdx - *in* *integer* - statistics index |
| // pl_sourceIdx - *in* *integer* - source index of the stat |
| // |
| // Return Value: |
| // - |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // Deregisters a single source from a statistics and its aux stats |
| /////////////////////////////////////////////////////////// |
| private function f_EPTF_StatHandler_cancelRegister( |
| in integer pl_statIdx, |
| in integer pl_sourceIdx) |
| runs on EPTF_StatHandler_CT |
| { |
| f_EPTF_StatHandlerLogging_debug(%definitionId&": cancelling registration of source "&int2str(pl_sourceIdx)& |
| " of stat "&v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statName); |
| if(sizeof(v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].auxStats) == 0) { |
| f_EPTF_StatHandler_removeSource(pl_statIdx, pl_sourceIdx); |
| } else { |
| f_EPTF_StatHandler_deregisterStatByIdx( |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].sources[pl_sourceIdx].uniqueId, |
| pl_statIdx |
| ); |
| } |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_getVarNamesForStatAsSource |
| // |
| // Purpose: |
| // Returns names of EPTF Variables that can be used to register a stat to another stat as source. |
| // |
| // Parameters: |
| // pl_statIdx - *in* *integer* - the index of the stat |
| // |
| // Return Value: |
| // EPTF_CharstringList - list of EPTF Variable names |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| /////////////////////////////////////////////////////////// |
| private function f_EPTF_StatHandler_getVarNamesForStatAsSource( |
| in integer pl_statIdx) |
| runs on EPTF_StatHandler_CT |
| return EPTF_CharstringList |
| { |
| var EPTF_CharstringList vl_names := {}; |
| if(sizeof(v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].providerVars) == 0) { |
| select(v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statMethod) { |
| case (c_EPTF_StatHandler_Method_Min, c_EPTF_StatHandler_Method_Max, c_EPTF_StatHandler_Method_Sum) { |
| // v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].providerVars[c_EPTF_StatHandler_providerVarIdx_single] := |
| // v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statVarIdx; |
| return {f_EPTF_Var_getName(v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statVarIdx)}; |
| } |
| case (c_EPTF_StatHandler_Method_Mean) { |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].providerVars[c_EPTF_StatHandler_providerVarIdx_mean] := |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statVarIdx; |
| f_EPTF_Var_newInt( |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statName |
| & v_EPTF_StatHandler_nameSeparator & "provider_nofSamples", |
| 0, |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].providerVars[c_EPTF_StatHandler_providerVarIdx_nofSamples]); |
| f_EPTF_Var_refreshContent(v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statVarIdx); // calcFn updates the newly created variable |
| } |
| case (c_EPTF_StatHandler_Method_StandardDev) { |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].providerVars[c_EPTF_StatHandler_providerVarIdx_mean] := |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].auxVars[c_EPTF_StatHandler_auxVarIdx_mean]; |
| f_EPTF_Var_newInt( |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statName |
| & v_EPTF_StatHandler_nameSeparator & "provider_nofSamples", |
| 0, |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].providerVars[c_EPTF_StatHandler_providerVarIdx_nofSamples]); |
| f_EPTF_Var_refreshContent(v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statVarIdx); // calcFn updates the newly created variables |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].providerVars[c_EPTF_StatHandler_providerVarIdx_S] := |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statVarIdx; |
| } |
| case (c_EPTF_StatHandler_Method_GlobalAverage) { |
| f_EPTF_Var_newFloat( |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statName |
| & v_EPTF_StatHandler_nameSeparator & "provider_sum", |
| 0.0, |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].providerVars[c_EPTF_StatHandler_providerVarIdx_sum]); |
| f_EPTF_Var_newInt( |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statName |
| & v_EPTF_StatHandler_nameSeparator & "provider_elementNumber", |
| 0, |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].providerVars[c_EPTF_StatHandler_providerVarIdx_elementNumber]); |
| f_EPTF_Var_refreshContent(v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statVarIdx); // calcFn updates the newly created variables |
| } |
| case (c_EPTF_StatHandler_Method_Density) { |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].providerVars[c_EPTF_StatHandler_providerVarIdx_density] := |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statVarIdx; |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].providerVars[c_EPTF_StatHandler_providerVarIdx_boundaries] := |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].auxVars[c_EPTF_StatHandler_auxVarIdx_boundaries]; |
| } |
| case (c_EPTF_StatHandler_Method_Percentile95, |
| c_EPTF_StatHandler_Method_PercentileP) { |
| var integer vl_densityStat := v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].auxStats[c_EPTF_StatHandler_auxStatIdx_density]; |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].providerVars[c_EPTF_StatHandler_providerVarIdx_density] := |
| f_EPTF_StatHandler_getVarIdx(vl_densityStat); |
| |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].providerVars[c_EPTF_StatHandler_providerVarIdx_boundaries] := |
| v_EPTF_StatHandler_aggregatedStats.data[vl_densityStat].auxVars[c_EPTF_StatHandler_auxVarIdx_boundaries]; |
| |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].providerVars[c_EPTF_StatHandler_providerVarIdx_max] := |
| f_EPTF_StatHandler_getVarIdx( |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].auxStats[c_EPTF_StatHandler_auxStatIdx_max] |
| ); |
| |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].providerVars[c_EPTF_StatHandler_providerVarIdx_pValue] := |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].auxVars[c_EPTF_StatHandler_auxVarIdx_pValue]; |
| } |
| case else { |
| f_EPTF_Base_assert(%definitionId&": Unknown stat method", false); |
| } |
| } //select |
| } |
| |
| for(var integer i:=0; i<sizeof(v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].providerVars); i:=i+1) { |
| vl_names[i] := f_EPTF_Var_getName(v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].providerVars[i]); |
| } |
| return vl_names; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Altstep: as_EPTF_StatHandler_behavior |
| // |
| // Purpose: |
| // StatHandler behavior altstep |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // - |
| // |
| // Errors & assertions: |
| // Unhandled union field in request from client or unexpected message received. |
| // |
| // Detailed Comments: |
| // - |
| /////////////////////////////////////////////////////////// |
| private altstep as_EPTF_StatHandler_behavior() |
| runs on EPTF_StatHandler_CT |
| { |
| var EPTF_StatHandler_MgmtMsg_Request vl_req; |
| var EPTF_StatHandler_MgmtMsg_Response vl_resp; |
| var EPTF_StatHandlerClient_CT vl_client; |
| []v_EPTF_StatHandler_MgmtPCO.receive(EPTF_StatHandler_MgmtMsg_Request:?) |
| -> value vl_req sender vl_client |
| { |
| if(ischosen(vl_req.request.getResetVarNameReq)) { |
| vl_resp := { |
| sIdx := vl_req.sIdx, |
| response := { |
| resetVarNameResp := { |
| resetVarName := f_EPTF_StatHandler_genUniqueName(c_EPTF_StatHandler_ResetVarName), |
| resetVarComp := self |
| } |
| } |
| } |
| v_EPTF_StatHandler_MgmtPCO.send(vl_resp) to vl_client; |
| } else if(ischosen(vl_req.request.declareReq)) { |
| var integer vl_idx := f_EPTF_StatHandler_declareStat( |
| vl_req.request.declareReq.statName, |
| vl_req.request.declareReq.statMethod, |
| vl_req.request.declareReq.statResetValue); |
| if (vl_req.sIdx >= 0) { |
| vl_resp := { |
| sIdx := vl_req.sIdx, |
| response := { |
| statusResp := { |
| result := (vl_idx >= 0) |
| } |
| } |
| } |
| v_EPTF_StatHandler_MgmtPCO.send(vl_resp) to vl_client; |
| } |
| } else if(ischosen(vl_req.request.registerReq)) { |
| var boolean vl_res := f_EPTF_StatHandler_registerStat( |
| vl_req.request.registerReq.sourceCompRef, |
| vl_client, |
| vl_req.request.registerReq.providerVarList, |
| vl_req.request.registerReq.contentList, |
| vl_req.request.registerReq.subscriptionMode, |
| vl_req.request.registerReq.targetStatName, |
| -, |
| vl_req.request.registerReq.refreshRate, |
| pl_sourceStatHandler := vl_req.request.registerReq.sourceStatHandler, |
| pl_sourceStatName := vl_req.request.registerReq.sourceStatName, |
| pl_measuredStatIdx := vl_req.request.registerReq.measuredStatIdx |
| ); |
| if(vl_req.sIdx >= 0) { |
| vl_resp := { |
| sIdx := vl_req.sIdx, |
| response := { |
| statusResp := { |
| result := vl_res |
| } |
| } |
| } |
| v_EPTF_StatHandler_MgmtPCO.send(vl_resp) to vl_client; |
| } |
| } else if(ischosen(vl_req.request.deregisterReq)) { |
| var boolean vl_res := f_EPTF_StatHandler_deregisterStat( |
| vl_req.request.deregisterReq.sourceCompRef, |
| vl_req.request.deregisterReq.targetStatName, |
| vl_req.request.deregisterReq.providerVarList); |
| if(vl_req.sIdx >= 0) { |
| vl_resp := { |
| sIdx := vl_req.sIdx, |
| response := { |
| statusResp := { |
| result := vl_res |
| } |
| } |
| } |
| v_EPTF_StatHandler_MgmtPCO.send(vl_resp) to vl_client; |
| } |
| } else if(ischosen(vl_req.request.getProviderVars)) { |
| var integer vl_idx := f_EPTF_StatHandler_getId(vl_req.request.getProviderVars.statName); |
| vl_resp := { |
| sIdx := vl_req.sIdx, |
| response := { |
| providerVarsResp := { |
| providerVars := f_EPTF_StatHandler_getVarNamesForStatAsSource(vl_idx) |
| } |
| } |
| } |
| v_EPTF_StatHandler_MgmtPCO.send(vl_resp) to vl_client; |
| } else if(ischosen(vl_req.request.getVarReq)) { |
| var integer vl_idx := f_EPTF_StatHandler_getId(vl_req.request.getVarReq.statName); |
| if(vl_idx >= 0) { // found |
| vl_resp := { |
| sIdx := vl_req.sIdx, |
| response := { |
| getVarResp := { |
| statVarName := vl_req.request.getVarReq.statName // FIXME: may change later? |
| } |
| } |
| } |
| } else { |
| vl_resp := { |
| sIdx := vl_req.sIdx, |
| response := { |
| getVarResp := { |
| statVarName := "" |
| } |
| } |
| } |
| } |
| v_EPTF_StatHandler_MgmtPCO.send(vl_resp) to vl_client; |
| } else if(ischosen(vl_req.request.getAuxVars)) { |
| var integer vl_idx := f_EPTF_StatHandler_getId(vl_req.request.getAuxVars.statName); |
| var EPTF_IntegerList vl_auxVars := f_EPTF_StatHandler_getAuxVars(vl_idx); |
| var EPTF_CharstringList vl_auxVarNames := {}; |
| for(var integer i:=0, size := sizeof(vl_auxVars); i<size; i:=i+1) { |
| vl_auxVarNames[i]:=f_EPTF_Var_getName(vl_auxVars[i]); |
| } |
| vl_resp := { |
| sIdx := vl_req.sIdx, |
| response := { |
| getAuxVarsResp := { |
| auxVars := vl_auxVarNames |
| } |
| } |
| } |
| v_EPTF_StatHandler_MgmtPCO.send(vl_resp) to vl_client; |
| } else if(ischosen(vl_req.request.resetAck)) { |
| // update those sources' reset status that are reset by vl_client |
| for(var integer i:=0; i<sizeof(v_EPTF_StatHandler_resetComponents); i:=i+1) { |
| if(v_EPTF_StatHandler_resetComponents[i].compRef == vl_client) { |
| for(var integer s:=0; s<v_EPTF_StatHandler_resetComponents[i].nofSources; s:=s+1) { |
| v_EPTF_StatHandler_aggregatedStats.data |
| [v_EPTF_StatHandler_resetComponents[i].sources[s].statIdx].sources |
| [v_EPTF_StatHandler_resetComponents[i].sources[s].sourceIdx].resetPending := false; |
| v_EPTF_StatHandler_aggregatedStats.data |
| [v_EPTF_StatHandler_resetComponents[i].sources[s].statIdx].sources |
| [v_EPTF_StatHandler_resetComponents[i].sources[s].sourceIdx].lastResetTimestamp := vl_req.request.resetAck.resetTimestamp; |
| } |
| v_EPTF_StatHandler_nofPendingResets := v_EPTF_StatHandler_nofPendingResets - 1; |
| if(v_EPTF_StatHandler_nofPendingResets < 0) { v_EPTF_StatHandler_nofPendingResets := 0; } |
| break; |
| } |
| } |
| // note: needs no response |
| } else if(ischosen(vl_req.request.bindStatToWidget)) { |
| var boolean vl_res := false; |
| if(v_EPTF_StatHandler_bindStatToWidgetFn != null) { |
| vl_res := v_EPTF_StatHandler_bindStatToWidgetFn.apply( |
| vl_req.request.bindStatToWidget.statName, |
| vl_req.request.bindStatToWidget.widgetId, |
| vl_req.request.bindStatToWidget.additionalWidget, |
| vl_req.request.bindStatToWidget.subscriptionMode, |
| vl_req.request.bindStatToWidget.refreshRate); |
| } else { |
| f_EPTF_StatHandlerLogging_warning(%definitionId&": bindStatToWidget received, handler function not set."); |
| } |
| if(vl_req.sIdx >= 0) { |
| vl_resp := { |
| sIdx := vl_req.sIdx, |
| response := { |
| statusResp := { |
| result := vl_res |
| } |
| } |
| } |
| v_EPTF_StatHandler_MgmtPCO.send(vl_resp) to vl_client; |
| } |
| } else if(ischosen(vl_req.request.resetReq)) { |
| var boolean vl_result := f_EPTF_StatHandler_resetStatistics(vl_req.request.resetReq.statName); |
| if(vl_req.sIdx >= 0) { |
| vl_resp := { |
| sIdx := vl_req.sIdx, |
| response := { |
| statusResp := { |
| result := vl_result |
| } |
| } |
| } |
| v_EPTF_StatHandler_MgmtPCO.send(vl_resp) to vl_client; |
| } |
| } else { |
| f_EPTF_Base_assert(%definitionId&": Unhandled union field in request: "&log2str(vl_req), false); |
| } |
| repeat; |
| } |
| []v_EPTF_StatHandler_MgmtPCO.receive -> sender vl_client |
| { |
| f_EPTF_StatHandlerLogging_warning(%definitionId&": unexpected message received from "&log2str(vl_client)); |
| repeat; |
| } |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_resetButtonPressed |
| // |
| // Purpose: |
| // Postproc function for reset button variable. |
| // |
| // Parameters: |
| // pl_idx - *in* *integer* - index of the reset button EPTF Variable |
| // pl_argList - *in* <EPTF_IntegerList> - the arguments |
| // |
| // Return Value: |
| // - |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| /////////////////////////////////////////////////////////// |
| private function f_EPTF_StatHandler_resetButtonPressed(in integer pl_idx, in EPTF_IntegerList pl_argList) |
| runs on EPTF_StatHandler_CT |
| { |
| // set resetPending for all sources and aggregated stats |
| for(var integer vl_statIdx:=0; vl_statIdx<sizeof(v_EPTF_StatHandler_aggregatedStats.data); vl_statIdx:=vl_statIdx+1) { |
| v_EPTF_StatHandler_aggregatedStats.data[vl_statIdx].resetPending := true; |
| for(var integer vl_sourceIdx:=0; vl_sourceIdx<sizeof(v_EPTF_StatHandler_aggregatedStats.data[vl_statIdx].sources); vl_sourceIdx := vl_sourceIdx+1) { |
| if(f_EPTF_FBQ_itemIsBusy(vl_sourceIdx, v_EPTF_StatHandler_aggregatedStats.data[vl_statIdx].sourceQueue)) { |
| v_EPTF_StatHandler_aggregatedStats.data[vl_statIdx].sources[vl_sourceIdx].resetPending := true; |
| } |
| } |
| } |
| v_EPTF_StatHandler_nofPendingResets := sizeof(v_EPTF_StatHandler_resetComponents); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_resetButtonGuard |
| // |
| // Purpose: |
| // Guard function for reset button variable. |
| // |
| // Parameters: |
| // pl_idx - *in* *integer* - index of the reset button EPTF Variable, |
| // pl_argList - *in* <EPTF_IntegerList> - the arguments |
| // pl_newContent - *in* <EPTF_Var_DirectContent> - the new value to be checked |
| // |
| // Return Value: |
| // *boolean* - true if new value is allowed, false if not. |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| /////////////////////////////////////////////////////////// |
| private function f_EPTF_StatHandler_resetButtonGuard(in integer pl_idx, in EPTF_IntegerList pl_argList, in EPTF_Var_DirectContent pl_newContent) |
| runs on EPTF_StatHandler_CT |
| return boolean |
| { |
| if(v_EPTF_StatHandler_nofPendingResets > 0) { return false; } |
| return true; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_resetStatisticsButtonPressed |
| // |
| // Purpose: |
| // Postproc function for reset statistics button variable. |
| // |
| // Parameters: |
| // pl_idx - *in* *integer* - index of the reset button EPTF Variable |
| // pl_argList - *in* <EPTF_IntegerList> - the arguments |
| // |
| // Return Value: |
| // - |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| /////////////////////////////////////////////////////////// |
| // TR HR20548 - Reset All statistics button |
| private function f_EPTF_StatHandler_resetStatisticsButtonPressed(in integer pl_idx, in EPTF_IntegerList pl_argList) |
| runs on EPTF_StatHandler_CT |
| { |
| f_EPTF_StatHandlerLogging_debug(%definitionId&": reset statistics button pressed"); |
| for(var integer i := 0; i < sizeof(v_EPTF_StatHandler_resetStatisticsFunctions); i := i + 1) { |
| if(v_EPTF_StatHandler_resetStatisticsFunctions[i] != null) { |
| v_EPTF_StatHandler_resetStatisticsFunctions[i].apply(); |
| } |
| } |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_genUniqueName |
| // |
| // Purpose: |
| // Function for getting a globally unique name for the reset button variable. |
| // |
| // Parameters: |
| // pl_name - *in* *chastring* - input name |
| // |
| // Return Value: |
| // *charstring* - the unique name generated from pl_name |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| /////////////////////////////////////////////////////////// |
| friend function f_EPTF_StatHandler_genUniqueName(in charstring pl_name) |
| runs on EPTF_StatHandler_CT |
| return charstring |
| { |
| return pl_name & v_EPTF_StatHandler_nameSeparator & int2str(f_EPTF_Base_upcast(self)); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_getNameSeparator |
| // |
| // Purpose: |
| // Function for getting the name separator. |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // *charstring* - the name separator |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| /////////////////////////////////////////////////////////// |
| friend function f_EPTF_StatHandler_getNameSeparator() |
| runs on EPTF_StatHandler_CT |
| return charstring |
| { |
| return v_EPTF_StatHandler_nameSeparator; |
| } |
| |
| |
| /////////////////////////////////////////////////////////// |
| // Group: StatHandler_Methods |
| // |
| // Purpose: |
| // Stat aggregation methods supported by StatHandler. |
| // |
| // Detailed Comments: |
| // - |
| // |
| /////////////////////////////////////////////////////////// |
| group StatHandler_Methods { |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_setMethodForStat |
| // |
| // Purpose: |
| // Function for setting the aggregation method for a stat. |
| // |
| // Parameters: |
| // pl_statIdx - *in* *integer* - the index of the stat |
| // |
| // Return Value: |
| // - |
| // |
| // Errors & assertions: |
| // Unsupported method |
| // |
| // Detailed Comments: |
| // - |
| /////////////////////////////////////////////////////////// |
| private function f_EPTF_StatHandler_setMethodForStat(in integer pl_statIdx) |
| runs on EPTF_StatHandler_CT |
| { |
| var integer vl_varIdx := v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statVarIdx; |
| var EPTF_Var_ProviderLocal vl_provider := { |
| calcFn := { |
| funcRef := null, |
| argList := {}, // updated when registering data sources |
| nonVarArgList := {pl_statIdx} |
| } |
| }; |
| |
| if(ischosen(v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statResetValue.intVal)) { |
| select(v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statMethod) { |
| case (c_EPTF_StatHandler_Method_Min) { |
| vl_provider.calcFn.funcRef := refers(f_EPTF_StatHandler_intMinMethod); |
| } |
| case (c_EPTF_StatHandler_Method_Max) { |
| vl_provider.calcFn.funcRef := refers(f_EPTF_StatHandler_intMaxMethod); |
| } |
| case(c_EPTF_StatHandler_Method_Sum) { |
| vl_provider.calcFn.funcRef := refers(f_EPTF_StatHandler_intSumMethod); |
| } |
| case ( |
| c_EPTF_StatHandler_Method_Mean, |
| c_EPTF_StatHandler_Method_StandardDev, |
| c_EPTF_StatHandler_Method_GlobalAverage, |
| c_EPTF_StatHandler_Method_Density, |
| c_EPTF_StatHandler_Method_Percentile95, |
| c_EPTF_StatHandler_Method_PercentileP) { |
| f_EPTF_StatHandlerLogging_error(%definitionId&": Stat method \"" |
| &v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statMethod |
| &"\" for integer stat \""&v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statName |
| &"\" is not supported."); |
| } |
| case else { |
| f_EPTF_StatHandlerLogging_warning(%definitionId&": Stat method \"" |
| &v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statMethod |
| &"\" for integer stat \""&v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statName |
| &"\" is unsupported or not yet supported."); |
| } |
| } |
| |
| } else if(ischosen(v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statResetValue.floatVal)) { |
| select(v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statMethod) { |
| case (c_EPTF_StatHandler_Method_Min) { |
| vl_provider.calcFn.funcRef := refers(f_EPTF_StatHandler_floatMinMethod); |
| } |
| case (c_EPTF_StatHandler_Method_Max) { |
| vl_provider.calcFn.funcRef := refers(f_EPTF_StatHandler_floatMaxMethod); |
| } |
| case (c_EPTF_StatHandler_Method_Mean) { |
| vl_provider.calcFn.funcRef := refers(f_EPTF_StatHandler_floatMeanMethod); |
| } |
| case (c_EPTF_StatHandler_Method_StandardDev) { |
| vl_provider.calcFn.funcRef := refers(f_EPTF_StatHandler_floatStandardDevMethod); |
| f_EPTF_StatHandler_createAuxData_StandardDev(pl_statIdx); |
| } |
| case(c_EPTF_StatHandler_Method_Sum) { |
| vl_provider.calcFn.funcRef := refers(f_EPTF_StatHandler_floatSumMethod); |
| } |
| case (c_EPTF_StatHandler_Method_GlobalAverage) { |
| vl_provider.calcFn.funcRef := refers(f_EPTF_StatHandler_floatGlobalAverageMethod); |
| } |
| case (c_EPTF_StatHandler_Method_Percentile95) { |
| vl_provider.calcFn.funcRef := refers(f_EPTF_StatHandler_floatPercentilePMethod); |
| f_EPTF_StatHandler_createAuxData_PercentileP(pl_statIdx, 0.95); |
| |
| // set Var calcFn dependency: |
| var integer vl_idxAuxDensity := v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].auxStats[c_EPTF_StatHandler_auxStatIdx_density]; |
| var integer vl_idxAuxMax := v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].auxStats[c_EPTF_StatHandler_auxStatIdx_max]; |
| vl_provider.calcFn.argList := { |
| v_EPTF_StatHandler_aggregatedStats.data[vl_idxAuxDensity].statVarIdx, |
| v_EPTF_StatHandler_aggregatedStats.data[vl_idxAuxMax].statVarIdx |
| } |
| if(c_EPTF_Common_debugSwitch) { |
| f_EPTF_StatHandlerLogging_debug(%definitionId&": dependency of stat "& v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statName &": " |
| & log2str(vl_provider.calcFn.argList)); |
| } |
| |
| } |
| case (c_EPTF_StatHandler_Method_PercentileP) { |
| vl_provider.calcFn.funcRef := refers(f_EPTF_StatHandler_floatPercentilePMethod); |
| f_EPTF_StatHandler_createAuxData_PercentileP(pl_statIdx, 0.5); |
| |
| // set Var calcFn dependency: |
| var integer vl_idxAuxDensity := v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].auxStats[c_EPTF_StatHandler_auxStatIdx_density]; |
| var integer vl_idxAuxMax := v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].auxStats[c_EPTF_StatHandler_auxStatIdx_max]; |
| var integer vl_idxAuxP := v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].auxVars[c_EPTF_StatHandler_auxVarIdx_pValue]; |
| vl_provider.calcFn.argList := { |
| v_EPTF_StatHandler_aggregatedStats.data[vl_idxAuxDensity].statVarIdx, |
| v_EPTF_StatHandler_aggregatedStats.data[vl_idxAuxMax].statVarIdx, |
| vl_idxAuxP |
| } |
| if(c_EPTF_Common_debugSwitch) { |
| f_EPTF_StatHandlerLogging_debug(%definitionId&": dependency of stat "& v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statName &": " |
| & log2str(vl_provider.calcFn.argList)); |
| } |
| |
| } |
| case else { |
| f_EPTF_StatHandlerLogging_warning(%definitionId&": Stat method \"" |
| &v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statMethod |
| &"\" for float stat \""&v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statName |
| &"\" is unsupported or not yet supported."); |
| } |
| } |
| |
| } else if(ischosen(v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statResetValue.integerlistVal)) { |
| select(v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statMethod) { |
| case (c_EPTF_StatHandler_Method_Density) { |
| vl_provider.calcFn.funcRef := refers(f_EPTF_StatHandler_intlistDensityMethod); |
| f_EPTF_StatHandler_createAuxData_Density(pl_statIdx); |
| } |
| case else { |
| f_EPTF_StatHandlerLogging_warning(%definitionId&": Stat method \"" |
| &v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statMethod |
| &"\" for float-list stat \""&v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statName |
| &"\" is unsupported or not yet supported."); |
| } |
| } |
| |
| } else { |
| f_EPTF_StatHandlerLogging_error(%definitionId&": Cannot set \"" |
| &v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statMethod |
| &"\" stat method for stat " |
| &v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statName&" := " |
| &log2str(v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statResetValue)); |
| } |
| |
| f_EPTF_Var_subscribeLocal(vl_varIdx, vl_provider); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_updateResetState |
| // |
| // Purpose: |
| // Function for updating the reset stat for a stat. |
| // |
| // Parameters: |
| // pl_statIdx - *in* *integer* - the index of the stat |
| // |
| // Return Value: |
| // *boolean* - true if reset is pending |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| /////////////////////////////////////////////////////////// |
| private function f_EPTF_StatHandler_updateResetState(in integer pl_statIdx) |
| runs on EPTF_StatHandler_CT |
| return boolean |
| { |
| var boolean vl_resetPending := false; |
| for(var integer i:=0; i<sizeof(v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].sources); i:=i+1) { |
| if(f_EPTF_FBQ_itemIsBusy(i, v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].sourceQueue)) { |
| vl_resetPending := vl_resetPending or v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].sources[i].resetPending; |
| } |
| } |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].resetPending := vl_resetPending; |
| if(c_EPTF_Common_debugSwitch and (not vl_resetPending)) { |
| f_EPTF_StatHandlerLogging_debug(%definitionId&": reset process finished for stat " |
| &v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].statName); |
| } |
| return vl_resetPending; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_isSourceValid |
| // |
| // Purpose: |
| // Function for checking if a source has valid data. |
| // |
| // Parameters: |
| // pl_statIdx - *in* *integer* - the index of the stat |
| // pl_sourceIdx - *in* *integer* - the index of the source within the stat data |
| // |
| // Return Value: |
| // *boolean* - true if source is valid, |
| // false if reset is pending for source or timestamp of the last value is less than the last reset timestamp |
| // |
| // Errors & assertions: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| /////////////////////////////////////////////////////////// |
| private function f_EPTF_StatHandler_isSourceValid(in integer pl_statIdx, in integer pl_sourceIdx) |
| runs on EPTF_StatHandler_CT |
| return boolean |
| { |
| if(v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].sources[pl_sourceIdx].resetPending) { return false; } |
| for(var integer i:=0; i<sizeof(v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].sources[pl_sourceIdx].varIdxList); i:=i+1) { |
| var EPTF_Var_TimeLine vl_timeline; |
| f_EPTF_Var_getTimeLine(v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].sources[pl_sourceIdx].varIdxList[i], vl_timeline); |
| if(sizeof(vl_timeline.timeLineData) != 0) { |
| if(vl_timeline.timeLineData[sizeof(vl_timeline.timeLineData) - 1].timestamp < |
| v_EPTF_StatHandler_aggregatedStats.data[pl_statIdx].sources[pl_sourceIdx].lastResetTimestamp) { |
| return false; |
| } |
| } |
| } |
| return true; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_StatHandler_intMinMethod |
| // |
| // Purpose: |
| // Min statistics method for integer stat. |
| // |
| // Parameters: |
| // pl_idx - *in* *integer* - index of the EPTF Variable |
| // pl_argList - *in* <EPTF_IntegerList> - the arguments: list of integers that should be EPTF Variable indexes (these Variables are set to the local providers) |
| // pl_nonVarArgList - *in* <EPTF_IntegerList> - list of any other indexes used by the CalcFn function. They do not have to be EPTF Variable indexes. |
|
|