blob: d38f6a6b04bca51cb3d7cd7987cc567007f69a9c [file] [log] [blame]
///////////////////////////////////////////////////////////////////////////////
// //
// Copyright (c) 2000-2019 Ericsson Telecom AB //
// //
// All rights reserved. This program and the accompanying materials //
// are made available under the terms of the Eclipse Public License v2.0 //
// which accompanies this distribution, and is available at //
// https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html //
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Module: EPTF_CLL_StatMeasure_Functions
//
// Purpose:
// This module contains function definitions for TTCN-3 EPTF StatMeasure
// implementation.
//
// Module Parameters:
// tsp_debug_EPTF_StatMeasure_Functions - boolean - enable/disable debugging
//
// Module depends on:
// <EPTF_CLL_StatMeasure_Definitions>
// <EPTF_CLL_Variable_Definitions>
// <EPTF_CLL_Variable_Functions>
// <EPTF_CLL_Base_Definitions>
// <EPTF_CLL_Base_Functions>
// <EPTF_CLL_Common_Definitions>
// <EPTF_CLL_Logging_Definitions>
// <EPTF_CLL_Logging_Functions>
//
// Public functions:
// <f_EPTF_StatMeasure_init_CT>
// <f_EPTF_StatMeasure_LogAll>
// <f_EPTF_StatMeasure_LogStat>
// <f_EPTF_StatMeasure_newStat>
// <f_EPTF_StatMeasure_newStatWithParams>
// <f_EPTF_StatMeasure_createAllStats>
// <f_EPTF_StatMeasure_resetStats>
// <f_EPTF_StatMeasure_getVarIdx>
// <f_EPTF_StatMeasure_getCreatedVarIdx>
// <f_EPTF_StatMeasure_isEnabled>
// <f_EPTF_StatMeasure_isReset>
// <f_EPTF_StatMeasure_getStatType>
// <f_EPTF_StatMeasure_resetStat>
// <f_EPTF_StatMeasure_initStatValue>
// <f_EPTF_StatMeasure_enableStat>
// <f_EPTF_StatMeasure_disableStat>
// <f_EPTF_StatMeasure_value2str>
// <f_EPTF_StatMeasure_createVarFromStat>
// <f_EPTF_StatMeasure_newStat_content>
// <f_EPTF_StatMeasure_resetStat_content>
// <f_EPTF_StatMeasure_initStatValue_content>
// <f_EPTF_StatMeasure_enableStat_content>
// <f_EPTF_StatMeasure_disableStat_content>
// <f_EPTF_StatMeasure_getStat_content>
// <f_EPTF_StatMeasure_content2str>
// <f_EPTF_StatMeasure_newStat_delta>
// <f_EPTF_StatMeasure_resetStat_delta>
// <f_EPTF_StatMeasure_initStatValue_delta>
// <f_EPTF_StatMeasure_changeToFloat_delta>
// <f_EPTF_StatMeasure_addData_delta>
// <f_EPTF_StatMeasure_enableStat_delta>
// <f_EPTF_StatMeasure_disableStat_delta>
// <f_EPTF_StatMeasure_getStat_delta>
// <f_EPTF_StatMeasure_delta2str>
// <f_EPTF_StatMeasure_newStat_deltaSum>
// <f_EPTF_StatMeasure_resetStat_deltaSum>
// <f_EPTF_StatMeasure_initStatValue_deltaSum>
// <f_EPTF_StatMeasure_changeToFloat_deltaSum>
// <f_EPTF_StatMeasure_addData_deltaSum>
// <f_EPTF_StatMeasure_enableStat_deltaSum>
// <f_EPTF_StatMeasure_disableStat_deltaSum>
// <f_EPTF_StatMeasure_getStat_deltaSum>
// <f_EPTF_StatMeasure_deltaSum2str>
// <f_EPTF_StatMeasure_newStat_min>
// <f_EPTF_StatMeasure_resetStat_min>
// <f_EPTF_StatMeasure_initStatValue_min>
// <f_EPTF_StatMeasure_changeToFloat_min>
// <f_EPTF_StatMeasure_addData_min>
// <f_EPTF_StatMeasure_enableStat_min>
// <f_EPTF_StatMeasure_disableStat_min>
// <f_EPTF_StatMeasure_getStat_min>
// <f_EPTF_StatMeasure_min2str>
// <f_EPTF_StatMeasure_newStat_max>
// <f_EPTF_StatMeasure_changeToFloat_max>
// <f_EPTF_StatMeasure_resetStat_max>
// <f_EPTF_StatMeasure_initStatValue_max>
// <f_EPTF_StatMeasure_addData_max>
// <f_EPTF_StatMeasure_enableStat_max>
// <f_EPTF_StatMeasure_disableStat_max>
// <f_EPTF_StatMeasure_getStat_max>
// <f_EPTF_StatMeasure_max2str>
// <f_EPTF_StatMeasure_newStat_mean>
// <f_EPTF_StatMeasure_resetStat_mean>
// <f_EPTF_StatMeasure_initStatValue_mean>
// <f_EPTF_StatMeasure_addData_mean>
// <f_EPTF_StatMeasure_enableStat_mean>
// <f_EPTF_StatMeasure_disableStat_mean>
// <f_EPTF_StatMeasure_getStat_mean>
// <f_EPTF_StatMeasure_mean2str>
// <f_EPTF_StatMeasure_createVarFromStat_N_mean>
// <f_EPTF_StatMeasure_newStat_standardDev>
// <f_EPTF_StatMeasure_resetStat_standardDev>
// <f_EPTF_StatMeasure_initStatValue_standardDev>
// <f_EPTF_StatMeasure_addData_standardDev>
// <f_EPTF_StatMeasure_enableStat_standardDev>
// <f_EPTF_StatMeasure_disableStat_standardDev>
// <f_EPTF_StatMeasure_getStat_standardDev>
// <f_EPTF_StatMeasure_getStat_standardDev_mean>
// <f_EPTF_StatMeasure_getStatIdx_standardDev_mean>
// <f_EPTF_StatMeasure_standardDev2str>
// <f_EPTF_StatMeasure_standardDev_mean2str>
// <f_EPTF_StatMeasure_createVarFromStat_Mean_standardDev>
// <f_EPTF_StatMeasure_createVarFromStat_N_standardDev>
// <f_EPTF_StatMeasure_createVarFromStat_S_standardDev>
// <f_EPTF_StatMeasure_newStat_EPS>
// <f_EPTF_StatMeasure_resetStat_EPS>
// <f_EPTF_StatMeasure_initStatValue_EPS>
// <f_EPTF_StatMeasure_startMeasurement_EPS>
// <f_EPTF_StatMeasure_addData_EPS>
// <f_EPTF_StatMeasure_enableStat_EPS>
// <f_EPTF_StatMeasure_disableStat_EPS>
// <f_EPTF_StatMeasure_getStat_EPS>
// <f_EPTF_StatMeasure_EPS2str>
// <f_EPTF_StatMeasure_getMeasurementLength_EPS>
// <f_EPTF_StatMeasure_getTime_EPS>
// <f_EPTF_StatMeasure_update_EPS>
// <f_EPTF_StatMeasure_newStat_chrono>
// <f_EPTF_StatMeasure_resetStat_chrono>
// <f_EPTF_StatMeasure_initStatValue_chrono>
// <f_EPTF_StatMeasure_start_chrono>
// <f_EPTF_StatMeasure_stop_chrono>
// <f_EPTF_StatMeasure_addData_chrono>
// <f_EPTF_StatMeasure_enableStat_chrono>
// <f_EPTF_StatMeasure_disableStat_chrono>
// <f_EPTF_StatMeasure_getStat_chrono>
// <f_EPTF_StatMeasure_chrono2str>
// <f_EPTF_StatMeasure_getMeasurementLength_chrono>
// <f_EPTF_StatMeasure_getTime_chrono>
// <f_EPTF_StatMeasure_update_chrono>
// <f_EPTF_StatMeasure_newStat_density>
// <f_EPTF_StatMeasure_setBoundaries_density>
// <f_EPTF_StatMeasure_getBoundaries_density>
// <f_EPTF_StatMeasure_setScale_density>
// <f_EPTF_StatMeasure_resetStat_density>
// <f_EPTF_StatMeasure_initStatValue_density>
// <f_EPTF_StatMeasure_addData_density>
// <f_EPTF_StatMeasure_enableStat_density>
// <f_EPTF_StatMeasure_disableStat_density>
// <f_EPTF_StatMeasure_getStat_density>
// <f_EPTF_StatMeasure_getStat_normalized_density>
// <f_EPTF_StatMeasure_density2str>
// <f_EPTF_StatMeasure_createVarFromStat_boundaries_density>
// <f_EPTF_StatMeasure_newStat_percentileP>
// <f_EPTF_StatMeasure_setBoundaries_percentileP>
// <f_EPTF_StatMeasure_setScale_percentileP>
// <f_EPTF_StatMeasure_setValueP_percentileP>
// <f_EPTF_StatMeasure_resetStat_percentileP>
// <f_EPTF_StatMeasure_initStatValue_percentileP>
// <f_EPTF_StatMeasure_addData_percentileP>
// <f_EPTF_StatMeasure_enableStat_percentileP>
// <f_EPTF_StatMeasure_disableStat_percentileP>
// <f_EPTF_StatMeasure_getStat_percentileP>
// <f_EPTF_StatMeasure_getStatIdx_density_percentileP>
// <f_EPTF_StatMeasure_getStatIdx_max_percentileP>
// <f_EPTF_StatMeasure_percentileP2str>
// <f_EPTF_StatMeasure_createVarFromStat_max_percentileP>
// <f_EPTF_StatMeasure_createVarFromStat_density_percentileP>
// <f_EPTF_StatMeasure_createVarFromStat_boundaries_density_percentileP>
// <f_EPTF_StatMeasure_createVarFromStat_valueP_percentileP>
// <f_EPTF_StatMeasure_newStat_percentile95>
// <f_EPTF_StatMeasure_setBoundaries_percentile95>
// <f_EPTF_StatMeasure_setScale_percentile95>
// <f_EPTF_StatMeasure_resetStat_percentile95>
// <f_EPTF_StatMeasure_initStatValue_percentile95>
// <f_EPTF_StatMeasure_addData_percentile95>
// <f_EPTF_StatMeasure_enableStat_percentile95>
// <f_EPTF_StatMeasure_disableStat_percentile95>
// <f_EPTF_StatMeasure_getStat_percentile95>
// <f_EPTF_StatMeasure_getStatIdx_density_percentile95>
// <f_EPTF_StatMeasure_getStatIdx_max_percentile95>
// <f_EPTF_StatMeasure_percentile952str>
// <f_EPTF_StatMeasure_createVarFromStat_max_percentile95>
// <f_EPTF_StatMeasure_createVarFromStat_density_percentile95>
// <f_EPTF_StatMeasure_createVarFromStat_boundaries_density_percentile95>
// <f_EPTF_StatMeasure_newStat_limits>
// <f_EPTF_StatMeasure_setLimits_limits>
// <f_EPTF_StatMeasure_getLimits_limits>
// <f_EPTF_StatMeasure_resetStat_limits>
// <f_EPTF_StatMeasure_initStatValue_limits>
// <f_EPTF_StatMeasure_addData_limits>
// <f_EPTF_StatMeasure_calculateValue_limits>
// <f_EPTF_StatMeasure_enableStat_limits>
// <f_EPTF_StatMeasure_disableStat_limits>
// <f_EPTF_StatMeasure_getStat_limits>
// <f_EPTF_StatMeasure_limits2str>
// <f_EPTF_StatMeasure_newStat_custom>
// <f_EPTF_StatMeasure_setProperties_custom>
// <f_EPTF_StatMeasure_resetStat_custom>
// <f_EPTF_StatMeasure_addData_custom>
// <f_EPTF_StatMeasure_enableStat_custom>
// <f_EPTF_StatMeasure_disableStat_custom>
// <f_EPTF_StatMeasure_getStat_custom>
// <f_EPTF_StatMeasure_custom2str>
// <f_EPTF_StatMeasure_createVarFromStat_custom>
//
// <f_EPTF_StatMeasure_bubblesort>
// <f_EPTF_StatMeasure_getStatName>
// <f_EPTF_StatMeasure_registerDefaultUpdate_EPS>
// <f_EPTF_StatMeasure_stat2Var>
//
// Current Owner:
// Jozsef Gyurusi (ETHJGI)
//
// Last Review Date:
// 2009-05-22
//
// Detailed Comments:
// This module contains function definitions for TTCN-3 EPTF StatMeasure
// implementation.
//
///////////////////////////////////////////////////////////////////////////////
module EPTF_CLL_StatMeasure_Functions {
import from EPTF_CLL_StatMeasure_Definitions all;
import from EPTF_CLL_Variable_Definitions all;
import from EPTF_CLL_Variable_Functions all;
import from EPTF_CLL_Base_Functions all;
import from EPTF_CLL_Common_Definitions all; // EPTF_IntegerList
import from TCCMaths_Functions all; // sqrt, etc.
import from EPTF_CLL_Logging_Definitions all;
import from EPTF_CLL_Logging_Functions all;
modulepar boolean tsp_debug_EPTF_StatMeasure_Functions := false;
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_init_CT
//
// Purpose:
// Initializes the EPTF_StatMeasure_CT component
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// This function should be called before using the <EPTF_StatMeasure_CT>
// component.
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_init_CT(
in charstring pl_selfName)
runs on EPTF_StatMeasure_CT
{
if (v_EPTF_StatMeasure_initialized) {
return; // already initialized
}
f_EPTF_Logging_init_CT(pl_selfName);
v_StatMeasure_loggingMaskId := f_EPTF_Logging_registerComponentMasks(tsp_EPTF_StatMeasure_loggingComponentMask, c_EPTF_StatMeasure_loggingEventClasses, EPTF_Logging_CLL);
if(tsp_debug_EPTF_StatMeasure_Functions) {
f_EPTF_Logging_enableLocalMask(v_StatMeasure_loggingMaskId, c_EPTF_StatMeasure_loggingClassIdx_Debug);
} else {
f_EPTF_Logging_disableLocalMask(v_StatMeasure_loggingMaskId, c_EPTF_StatMeasure_loggingClassIdx_Debug);
}
f_EPTF_Var_init_CT(pl_selfName);
statList := {};
v_EPTF_StatMeasure_initialized := true;
f_EPTF_Base_registerCleanup(refers(f_EPTF_StatMeasure_cleanup_CT));
//log("----STATMEASURE INIT DONE----");
f_EPTF_StatMeasure_debug(
"---- EPTF_StatMeasure INIT "&pl_selfName&" DONE ----");
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_LogAll
//
// Purpose:
// Log everything (important) in <EPTF_StatMeasure_CT> component
//
// Parameters:
// pl_msg - *in* *charstring* - message to log. It is printed before and
// after the component data
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_LogAll(
in charstring pl_msg)
runs on EPTF_StatMeasure_CT
{
if (pl_msg!="") { f_EPTF_StatMeasure_debug(pl_msg); }
f_EPTF_StatMeasure_debug(
log2str("EPTF_StatMeasure_CT.statList: ", statList));
if (pl_msg!="") {f_EPTF_StatMeasure_debug(pl_msg);}
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_LogAll
//
// Purpose:
// Log everything about the given stat
//
// Parameters:
// pl_msg - *in* *charstring* - message to log. It is printed before and
// after the component data
// pl_statIdx - *in* *integer* - the idx of the statistics
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_LogStat(
in charstring pl_msg,
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT
{
f_EPTF_StatMeasure_debug(
log2str(pl_msg&": EPTF_StatMeasure_CT.statList[",pl_statIdx,"]: ", statList[pl_statIdx]));
}
///////////////////////////////////////////////////////////////////////////////
// Group: General
//
// Purpose:
// General functions for all statistics
//
// Elements:
///////////////////////////////////////////////////////////////////////////////
group General {
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_newStat
//
// Purpose:
// Creates a new statistics for the EPTF Variable and returns its idx.
//
// Parameters:
// pl_idx - *in* *integer* - the idx of the EPTF_Var (-1 for standalone)
// pl_statType - *in* <EPTF_StatMeasure_statType> - type of stat
//
// Return Value:
// *integer* - index of the new statistics
//
// Errors:
// -
//
// Detailed Comments:
// If the pl_varIdx is set to -1 then a standalone statistics will be
// created. It is not allowed to create standalone content type statistics.
// The created statistics is enabled and created with default settings.
// Note, that the type of the stats 'delta', 'deltaSum', 'min' and 'max' is
// set to integer by default. It should be modified if needed before creating
// variable from the stat!
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_newStat(
in integer pl_varIdx,
in EPTF_StatMeasure_statType pl_statType)
runs on EPTF_StatMeasure_CT return integer
{
if (pl_statType == content) {
return f_EPTF_StatMeasure_newStat_content(pl_varIdx);
}
if (pl_statType == delta) {
return f_EPTF_StatMeasure_newStat_delta(pl_varIdx);
}
if (pl_statType == deltaSum) {
return f_EPTF_StatMeasure_newStat_deltaSum(pl_varIdx);
}
if (pl_statType == min) {
return f_EPTF_StatMeasure_newStat_min(pl_varIdx);
}
if (pl_statType == max) {
return f_EPTF_StatMeasure_newStat_max(pl_varIdx);
}
if (pl_statType == mean) {
return f_EPTF_StatMeasure_newStat_mean(pl_varIdx);
}
if (pl_statType == standardDev) {
return f_EPTF_StatMeasure_newStat_standardDev(pl_varIdx);
}
if (pl_statType == EPS) {
return f_EPTF_StatMeasure_newStat_EPS(pl_varIdx);
}
if (pl_statType == chrono) {
return f_EPTF_StatMeasure_newStat_chrono(pl_varIdx);
}
if (pl_statType == density) {
return f_EPTF_StatMeasure_newStat_density({},pl_varIdx);
}
if (pl_statType == percentileP) {
return f_EPTF_StatMeasure_newStat_percentileP({}, 0.5, pl_varIdx);
}
if (pl_statType == percentile95) {
return f_EPTF_StatMeasure_newStat_percentile95({}, pl_varIdx);
}
if (pl_statType == limits) {
return f_EPTF_StatMeasure_newStat_limits(pl_varIdx);
}
if (pl_statType == custom) {
return f_EPTF_StatMeasure_newStat_custom(pl_varIdx);
}
//...
return -1; // never reached
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_newStatWithParams
//
// Purpose:
// Creates a new statistics for the EPTF Variable and returns its idx.
// Additional parameters can be specified
//
// Parameters:
// pl_idx - *in* *integer* - the idx of the EPTF_Var (-1 for standalone)
// pl_statParams - *in* <EPTF_StatMeasure_StatParams> - type and parameter of the stat
//
// Return Value:
// *integer* - index of the new statistics
//
// Errors:
// -
//
// Detailed Comments:
// If the pl_varIdx is set to -1 then a standalone statistics will be
// created. It is not allowed to create standalone content type statistics.
// The created statistics is enabled and created with default settings.
// Note, that the type of the stats 'delta', 'deltaSum', 'min' and 'max' is
// set to integer by default. It should be modified if needed before creating
// variable from the stat!
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_newStatWithParams(
in integer pl_varIdx,
in EPTF_StatMeasure_StatParams pl_statParams)
runs on EPTF_StatMeasure_CT return integer
{
if (ischosen(pl_statParams.content)) {
return f_EPTF_StatMeasure_newStat_content(pl_varIdx);
}
if (ischosen(pl_statParams.delta)) {
return f_EPTF_StatMeasure_newStat_delta(pl_varIdx);
}
if (ischosen(pl_statParams.deltaSum)) {
return f_EPTF_StatMeasure_newStat_deltaSum(pl_varIdx);
}
if (ischosen(pl_statParams.min)) {
return f_EPTF_StatMeasure_newStat_min(pl_varIdx);
}
if (ischosen(pl_statParams.max)) {
return f_EPTF_StatMeasure_newStat_max(pl_varIdx);
}
if (ischosen(pl_statParams.mean)) {
return f_EPTF_StatMeasure_newStat_mean(pl_varIdx);
}
if (ischosen(pl_statParams.standardDev)) {
return f_EPTF_StatMeasure_newStat_standardDev(pl_varIdx);
}
if (ischosen(pl_statParams.EPS)) {
var integer vl_statId := f_EPTF_StatMeasure_newStat_EPS(pl_varIdx);
if(lengthof(pl_statParams.EPS) != 0) {
if(lengthof(pl_statParams.EPS) > 1) {
f_EPTF_StatMeasure_warning(%definitionId&": more than one parameter "&
"not currently supported for EPS statistics. The first parameter will be used.");
}
if (ischosen(pl_statParams.EPS[0].registerDefaultUpdate) and
pl_statParams.EPS[0].registerDefaultUpdate) {
f_EPTF_StatMeasure_registerDefaultUpdate_EPS(vl_statId);
}
}
return vl_statId;
}
if (ischosen(pl_statParams.chrono)) {
return f_EPTF_StatMeasure_newStat_chrono(pl_varIdx);
}
if (ischosen(pl_statParams.density)) {
var integer vl_statId := f_EPTF_StatMeasure_newStat_density({},pl_varIdx);
if (ischosen(pl_statParams.density.boundaries)) {
f_EPTF_StatMeasure_setBoundaries_density(vl_statId,pl_statParams.density.boundaries);
}
if (ischosen(pl_statParams.density.scale)) {
f_EPTF_StatMeasure_setScale_density(vl_statId,
pl_statParams.density.scale.min,
pl_statParams.density.scale.max,
pl_statParams.density.scale.n,
pl_statParams.density.scale.scale
);
}
return vl_statId;
}
if (ischosen(pl_statParams.percentileP)) {
var integer vl_statId := f_EPTF_StatMeasure_newStat_percentileP({}, 0.5, pl_varIdx);
f_EPTF_StatMeasure_setValueP_percentileP(vl_statId,pl_statParams.percentileP.valueP);
if (ischosen(pl_statParams.percentileP.density.boundaries)) {
f_EPTF_StatMeasure_setBoundaries_percentileP(vl_statId,pl_statParams.percentileP.density.boundaries);
}
if (ischosen(pl_statParams.percentileP.density.scale)) {
f_EPTF_StatMeasure_setScale_percentileP(vl_statId,
pl_statParams.percentileP.density.scale.min,
pl_statParams.percentileP.density.scale.max,
pl_statParams.percentileP.density.scale.n,
pl_statParams.percentileP.density.scale.scale
);
}
return vl_statId;
}
if (ischosen(pl_statParams.percentile95)) {
var integer vl_statId := f_EPTF_StatMeasure_newStat_percentile95({}, pl_varIdx);
if (ischosen(pl_statParams.percentile95.boundaries)) {
f_EPTF_StatMeasure_setBoundaries_percentile95(vl_statId,pl_statParams.percentile95.boundaries);
}
if (ischosen(pl_statParams.percentile95.scale)) {
f_EPTF_StatMeasure_setScale_percentile95(vl_statId,
pl_statParams.percentile95.scale.min,
pl_statParams.percentile95.scale.max,
pl_statParams.percentile95.scale.n,
pl_statParams.percentile95.scale.scale
);
}
return vl_statId;
}
if (ischosen(pl_statParams.limits)) {
return f_EPTF_StatMeasure_newStat_limits(
pl_varIdx,
pl_statParams.limits.limits,
pl_statParams.limits.referenceVarId,
pl_statParams.limits.defaultColor,
pl_statParams.limits.enableValueInLEDText
);
}
if (ischosen(pl_statParams.custom)) {
return f_EPTF_StatMeasure_newStat_custom(pl_varIdx);
}
//...
return -1; // never reached
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_createAllStats
//
// Purpose:
// Creates all available statistics for the EPTF Variable and returns
// their indexes.
//
// Parameters:
// pl_idx - *in* *integer* - the idx of the EPTF_Var (-1 for standalone stat)
//
// Return Value:
// *EPTF_IntegerList* - list of the indexes of the new statistics
//
// Errors:
// -
//
// Detailed Comments:
// The created statistics are enabled and created with default settings.
// Note, that the type of the stats 'delta', 'deltaSum', 'min' and 'max' is
// set to integer by default. It should be modified if needed before creating
// variable from the stat!
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_createAllStats(
in integer pl_varIdx)
runs on EPTF_StatMeasure_CT return EPTF_IntegerList
{
var EPTF_IntegerList vl_idxList := {};
vl_idxList[sizeof(vl_idxList)] := f_EPTF_StatMeasure_newStat_content(pl_varIdx);
vl_idxList[sizeof(vl_idxList)] := f_EPTF_StatMeasure_newStat_delta(pl_varIdx);
vl_idxList[sizeof(vl_idxList)] := f_EPTF_StatMeasure_newStat_deltaSum(pl_varIdx);
vl_idxList[sizeof(vl_idxList)] := f_EPTF_StatMeasure_newStat_min(pl_varIdx);
vl_idxList[sizeof(vl_idxList)] := f_EPTF_StatMeasure_newStat_max(pl_varIdx);
vl_idxList[sizeof(vl_idxList)] := f_EPTF_StatMeasure_newStat_mean(pl_varIdx);
vl_idxList[sizeof(vl_idxList)] := f_EPTF_StatMeasure_newStat_standardDev(pl_varIdx);
vl_idxList[sizeof(vl_idxList)] := f_EPTF_StatMeasure_newStat_EPS(pl_varIdx);
vl_idxList[sizeof(vl_idxList)] := f_EPTF_StatMeasure_newStat_chrono(pl_varIdx);
vl_idxList[sizeof(vl_idxList)] := f_EPTF_StatMeasure_newStat_density({},pl_varIdx);
vl_idxList[sizeof(vl_idxList)] := f_EPTF_StatMeasure_newStat_percentile95({}, pl_varIdx);
vl_idxList[sizeof(vl_idxList)] := f_EPTF_StatMeasure_newStat_percentileP({}, 0.5, pl_varIdx);
vl_idxList[sizeof(vl_idxList)] := f_EPTF_StatMeasure_newStat_limits(pl_varIdx);
vl_idxList[sizeof(vl_idxList)] := f_EPTF_StatMeasure_newStat_custom(pl_varIdx);
/*
for (var integer i := 0; i < sizeof(customStatFNs); i := i + 1)
{
vl_idxList[sizeof(vl_idxList)] := f_EPTF_StatMeasure_newStat_custom(pl_varIdx, i);
}
*/
//...
return vl_idxList;
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_resetStats
//
// Purpose:
// Resets the given statistics list
//
// Parameters:
// pl_idx - *in* <EPTF_IntegerList> - list of the idx of the statistics
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_resetStats(
in EPTF_IntegerList pl_statIdxList)
runs on EPTF_StatMeasure_CT
{
for(var integer i:=0; i<sizeof(pl_statIdxList); i:=i+1) {
f_EPTF_StatMeasure_resetStat(pl_statIdxList[i]);
}
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_getVarIdx
//
// Purpose:
// Returns the idx of the EPTF Variable the given statistics calculated
// from.
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_getVarIdx(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT return integer
{
return statList[pl_statIdx].varIdx;
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_getCreatedVarIdx
//
// Purpose:
// Returns the idx of the EPTF Variable created from the given statistics.
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_getCreatedVarIdx(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT return integer
{
return statList[pl_statIdx].createdVarIdx;
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_isEnabled
//
// Purpose:
// Returns true if the stat is enabled.
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
//
// Return Value:
// *boolean* - enabled state (true: enabled / false: disabled)
//
// Errors:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_isEnabled(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT return boolean
{
return statList[pl_statIdx].enabled;
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_isReset
//
// Purpose:
// Returns true if the stat was reset.
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
//
// Return Value:
// *boolean* - reset state (true: need reset / false: don!t need reset)
//
// Errors:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_isReset(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT return boolean
{
return statList[pl_statIdx].reset;
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_getStatType
//
// Purpose:
// Returns the type of the statistics.
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
//
// Return Value:
// EPTF_StatMeasure_statType - type of the statistics
//
// Errors:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_getStatType(
in integer pl_statIdx
) runs on EPTF_StatMeasure_CT return EPTF_StatMeasure_statType
{
if (ischosen(statList[pl_statIdx].statData.content)) {
return content;
}
if (ischosen(statList[pl_statIdx].statData.delta)) {
return delta;
}
if (ischosen(statList[pl_statIdx].statData.deltaSum)) {
return deltaSum;
}
if (ischosen(statList[pl_statIdx].statData.min)) {
return min;
}
if (ischosen(statList[pl_statIdx].statData.max)) {
return max;
}
if (ischosen(statList[pl_statIdx].statData.mean)) {
return mean;
}
if (ischosen(statList[pl_statIdx].statData.standardDev)) {
return standardDev;
}
if (ischosen(statList[pl_statIdx].statData.EPS)) {
return EPS;
}
if (ischosen(statList[pl_statIdx].statData.chrono)) {
return chrono;
}
if (ischosen(statList[pl_statIdx].statData.density)) {
return density;
}
if (ischosen(statList[pl_statIdx].statData.percentileP)) {
return percentileP;
}
if (ischosen(statList[pl_statIdx].statData.percentile95)) {
return percentile95;
}
if (ischosen(statList[pl_statIdx].statData.limits)) {
return limits;
}
if (ischosen(statList[pl_statIdx].statData.custom)) {
return custom;
}
//...
return content; // just to remove the warning, never executed
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_resetStat
//
// Purpose:
// Reset a given statistics
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_resetStat(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT
{
if (ischosen(statList[pl_statIdx].statData.content)) {
f_EPTF_StatMeasure_resetStat_content(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.delta)) {
f_EPTF_StatMeasure_resetStat_delta(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.deltaSum)) {
f_EPTF_StatMeasure_resetStat_deltaSum(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.min)) {
f_EPTF_StatMeasure_resetStat_min(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.max)) {
f_EPTF_StatMeasure_resetStat_max(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.mean)) {
f_EPTF_StatMeasure_resetStat_mean(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.standardDev)) {
f_EPTF_StatMeasure_resetStat_standardDev(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.EPS)) {
f_EPTF_StatMeasure_resetStat_EPS(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.chrono)) {
f_EPTF_StatMeasure_resetStat_chrono(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.density)) {
f_EPTF_StatMeasure_resetStat_density(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.percentileP)) {
f_EPTF_StatMeasure_resetStat_percentileP(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.percentile95)) {
f_EPTF_StatMeasure_resetStat_percentile95(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.limits)) {
f_EPTF_StatMeasure_resetStat_limits(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.custom)) {
f_EPTF_StatMeasure_resetStat_custom(pl_statIdx);
return;
}
//...
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_initStatValue
//
// Purpose:
// Initializes the value of a given statistics
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// Stat is initialized with zero.
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_initStatValue(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT
{
if (ischosen(statList[pl_statIdx].statData.content)) {
f_EPTF_StatMeasure_initStatValue_content(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.delta)) {
f_EPTF_StatMeasure_initStatValue_delta(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.deltaSum)) {
f_EPTF_StatMeasure_initStatValue_deltaSum(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.min)) {
f_EPTF_StatMeasure_initStatValue_min(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.max)) {
f_EPTF_StatMeasure_initStatValue_max(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.mean)) {
f_EPTF_StatMeasure_initStatValue_mean(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.standardDev)) {
f_EPTF_StatMeasure_initStatValue_standardDev(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.EPS)) {
f_EPTF_StatMeasure_initStatValue_EPS(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.chrono)) {
f_EPTF_StatMeasure_initStatValue_chrono(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.density)) {
f_EPTF_StatMeasure_initStatValue_density(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.percentileP)) {
f_EPTF_StatMeasure_initStatValue_percentileP(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.percentile95)) {
f_EPTF_StatMeasure_initStatValue_percentile95(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.limits)) {
f_EPTF_StatMeasure_initStatValue_limits(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.custom)) {
//f_EPTF_StatMeasure_initStatValue_custom(pl_statIdx);
return;
}
//...
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_enableStat
//
// Purpose:
// Enable a given statistics
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// The statistics will be updated only after enabled.
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_enableStat(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT
{
if (ischosen(statList[pl_statIdx].statData.content)) {
f_EPTF_StatMeasure_enableStat_content(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.delta)) {
f_EPTF_StatMeasure_enableStat_delta(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.deltaSum)) {
f_EPTF_StatMeasure_enableStat_deltaSum(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.min)) {
f_EPTF_StatMeasure_enableStat_min(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.max)) {
f_EPTF_StatMeasure_enableStat_max(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.mean)) {
f_EPTF_StatMeasure_enableStat_mean(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.standardDev)) {
f_EPTF_StatMeasure_enableStat_standardDev(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.EPS)) {
f_EPTF_StatMeasure_enableStat_EPS(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.chrono)) {
f_EPTF_StatMeasure_enableStat_chrono(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.density)) {
f_EPTF_StatMeasure_enableStat_density(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.percentileP)) {
f_EPTF_StatMeasure_enableStat_percentileP(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.percentile95)) {
f_EPTF_StatMeasure_enableStat_percentile95(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.limits)) {
f_EPTF_StatMeasure_enableStat_limits(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.custom)) {
f_EPTF_StatMeasure_enableStat_custom(pl_statIdx);
return;
}
//...
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_disableStat
//
// Purpose:
// Disable a given statistics
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// The statistics will not be updated only after disabled.
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_disableStat(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT
{
if (ischosen(statList[pl_statIdx].statData.content)) {
f_EPTF_StatMeasure_disableStat_content(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.delta)) {
f_EPTF_StatMeasure_disableStat_delta(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.deltaSum)) {
f_EPTF_StatMeasure_disableStat_deltaSum(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.min)) {
f_EPTF_StatMeasure_disableStat_min(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.max)) {
f_EPTF_StatMeasure_disableStat_max(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.mean)) {
f_EPTF_StatMeasure_disableStat_mean(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.standardDev)) {
f_EPTF_StatMeasure_disableStat_standardDev(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.EPS)) {
f_EPTF_StatMeasure_disableStat_EPS(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.chrono)) {
f_EPTF_StatMeasure_disableStat_chrono(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.density)) {
f_EPTF_StatMeasure_disableStat_density(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.percentileP)) {
f_EPTF_StatMeasure_disableStat_percentileP(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.percentile95)) {
f_EPTF_StatMeasure_disableStat_percentile95(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.limits)) {
f_EPTF_StatMeasure_disableStat_limits(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.custom)) {
f_EPTF_StatMeasure_disableStat_custom(pl_statIdx);
return;
}
//...
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_value2str
//
// Purpose:
// Converts the value of the statistics to charstring
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
//
// Return Value:
// *charstring* - the value of the statistics as a charstring
//
// Errors:
// -
//
// Detailed Comments:
// The statistics will not be updated only after disabled.
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_value2str(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT return charstring
{
if (ischosen(statList[pl_statIdx].statData.content)) {
var charstring vl_stringvalue := f_EPTF_StatMeasure_content2str(pl_statIdx);
var EPTF_Var_DirectContent vl_content;
f_EPTF_StatMeasure_getStat_content(pl_statIdx, vl_content);
if (ischosen(vl_content.charstringVal)){
vl_stringvalue := "\"" & vl_stringvalue & "\"";
}
return vl_stringvalue;
}
if (ischosen(statList[pl_statIdx].statData.delta)) {
return f_EPTF_StatMeasure_delta2str(pl_statIdx);
}
if (ischosen(statList[pl_statIdx].statData.deltaSum)) {
return f_EPTF_StatMeasure_deltaSum2str(pl_statIdx);
}
if (ischosen(statList[pl_statIdx].statData.min)) {
return f_EPTF_StatMeasure_min2str(pl_statIdx);
}
if (ischosen(statList[pl_statIdx].statData.max)) {
return f_EPTF_StatMeasure_max2str(pl_statIdx);
}
if (ischosen(statList[pl_statIdx].statData.mean)) {
return f_EPTF_StatMeasure_mean2str(pl_statIdx);
}
if (ischosen(statList[pl_statIdx].statData.standardDev)) {
return f_EPTF_StatMeasure_standardDev2str(pl_statIdx);
}
if (ischosen(statList[pl_statIdx].statData.EPS)) {
return f_EPTF_StatMeasure_EPS2str(pl_statIdx);
}
if (ischosen(statList[pl_statIdx].statData.chrono)) {
return f_EPTF_StatMeasure_chrono2str(pl_statIdx);
}
if (ischosen(statList[pl_statIdx].statData.density)) {
return f_EPTF_StatMeasure_density2str(pl_statIdx);
}
if (ischosen(statList[pl_statIdx].statData.percentileP)) {
return f_EPTF_StatMeasure_percentileP2str(pl_statIdx);
}
if (ischosen(statList[pl_statIdx].statData.percentile95)) {
return f_EPTF_StatMeasure_percentile952str(pl_statIdx);
}
if (ischosen(statList[pl_statIdx].statData.limits)) {
return f_EPTF_StatMeasure_limits2str(pl_statIdx);
}
if (ischosen(statList[pl_statIdx].statData.custom)) {
return f_EPTF_StatMeasure_custom2str(pl_statIdx);
}
//...
return "N/A"
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_createVarFromStat
//
// Purpose:
// Creates an EPTF Variable from the given statistics
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
// pl_varName - *in* *charstring* - the name of the created variable
// (if empty: name is auto-generated). Default: empty
//
// Return Value:
// *integer* - idx of the new variable
//
// Errors:
// -
//
// Detailed Comments:
// The type of the variable is auto-generated according to the type of
// the statistics.
// For auto-generated names the name will be the name generated for
// the statistics by the function <f_EPTF_StatMeasure_getStatName>.
//
// HK52719:
// If the variable already exits, the variable is reused to store the value of the statistics.
// The type of the variable should correspond to the type of the statistics in this case!
// It is not checked in this function.
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_createVarFromStat(
in integer pl_statIdx,
in charstring pl_varName := "")
runs on EPTF_StatMeasure_CT return integer
{
if (statList[pl_statIdx].createdVarIdx != -1)
{
f_EPTF_StatMeasure_warning(
log2str("Variable for the value of stat ", pl_statIdx, " (",
statList[pl_statIdx],") already exists: ",
f_EPTF_Var_getName(statList[pl_statIdx].createdVarIdx)));
return statList[pl_statIdx].createdVarIdx; // var already created
}
var EPTF_StatMeasure_statType vl_statType :=
f_EPTF_StatMeasure_getStatType(pl_statIdx);
var integer vl_varIdx := f_EPTF_StatMeasure_getVarIdx(pl_statIdx);
var integer vl_newVarIdx;
if (vl_statType == content) {
return vl_varIdx;
}
// assign auto-name:
var charstring vl_statName := pl_varName;
if (vl_statName == "") {
vl_statName := f_EPTF_StatMeasure_getStatName(pl_statIdx);
}
vl_varIdx := f_EPTF_Var_getId(vl_statName);
if (vl_varIdx!=-1) {
f_EPTF_StatMeasure_debug(%definitionId&": Variable to create already exist: "&vl_statName&". Reused for storing the value of the stat (HK52719).");
f_EPTF_StatMeasure_registerCreatedVar(pl_statIdx,vl_varIdx);
// disable adjust of created variables (calcFn is null: prostProc will
// do the update, stat will notify the variable):
f_EPTF_Var_unsubscribe(vl_varIdx);
f_EPTF_Var_subscribeLocal(vl_varIdx, {calcFn := { null, {}, {} }});
return vl_varIdx;
}
//log("vl_statName: ",vl_statName);
f_EPTF_StatMeasure_debug("vl_statName: "&vl_statName);
if (vl_statType == delta) {
if (ischosen(statList[pl_statIdx].statData.delta.statValue.intVal)){
f_EPTF_Var_newInt(vl_statName,
statList[pl_statIdx].statData.delta.statValue.intVal,vl_newVarIdx);
} else {
f_EPTF_Var_newFloat(vl_statName,
statList[pl_statIdx].statData.delta.statValue.floatVal,vl_newVarIdx);
}
} else if (vl_statType == deltaSum) {
if (ischosen(statList[pl_statIdx].statData.deltaSum.statValue.intVal)){
f_EPTF_Var_newInt(vl_statName,
statList[pl_statIdx].statData.deltaSum.statValue.intVal,vl_newVarIdx);
} else {
f_EPTF_Var_newFloat(vl_statName,
statList[pl_statIdx].statData.deltaSum.statValue.floatVal,vl_newVarIdx);
}
} else if (vl_statType == min) {
if (ischosen(statList[pl_statIdx].statData.min.statValue.intVal)){
f_EPTF_Var_newInt(vl_statName,
statList[pl_statIdx].statData.min.statValue.intVal,vl_newVarIdx);
} else {
f_EPTF_Var_newFloat(vl_statName,
statList[pl_statIdx].statData.min.statValue.floatVal,vl_newVarIdx);
}
} else if (vl_statType == max) {
if (ischosen(statList[pl_statIdx].statData.max.statValue.intVal)){
f_EPTF_Var_newInt(vl_statName,
statList[pl_statIdx].statData.max.statValue.intVal,vl_newVarIdx);
} else {
f_EPTF_Var_newFloat(vl_statName,
statList[pl_statIdx].statData.max.statValue.floatVal,vl_newVarIdx);
}
} else if (vl_statType == mean) {
f_EPTF_Var_newFloat(vl_statName,
statList[pl_statIdx].statData.mean.statValue,vl_newVarIdx);
} else if (vl_statType == standardDev) {
f_EPTF_Var_newFloat(vl_statName,
statList[pl_statIdx].statData.standardDev.statValue,vl_newVarIdx);
} else if (vl_statType == EPS) {
f_EPTF_Var_newFloat(vl_statName,
statList[pl_statIdx].statData.EPS.statValue,vl_newVarIdx);
} else if (vl_statType == chrono) {
f_EPTF_Var_newFloat(vl_statName,
statList[pl_statIdx].statData.chrono.statValue,vl_newVarIdx);
} else if (vl_statType == density) {
f_EPTF_Var_newIntegerlist(vl_statName,
statList[pl_statIdx].statData.density.statValue,vl_newVarIdx);
} else if (vl_statType == percentileP) {
f_EPTF_Var_newFloat(vl_statName,
statList[pl_statIdx].statData.percentileP.statValue,vl_newVarIdx);
} else if (vl_statType == percentile95) {
f_EPTF_Var_newFloat(vl_statName,
statList[ statList[pl_statIdx].statData.percentile95.percentilePIdx ].statData.percentileP.statValue,vl_newVarIdx);
} else if (vl_statType == limits) {
f_EPTF_Var_newStatusLED(vl_statName,
statList[pl_statIdx].statData.limits.statValue,vl_newVarIdx);
} else if (vl_statType == custom) {
vl_newVarIdx :=
f_EPTF_StatMeasure_createVarFromStat_custom(
pl_statIdx, vl_statName);
}
//...
// create notification:
f_EPTF_StatMeasure_registerCreatedVar(pl_statIdx,vl_newVarIdx);
// disable adjust of created variables (calcFn is null: prostProc will
// do the update, stat will notify the variable):
if (vl_newVarIdx!=-1) {
f_EPTF_Var_subscribeLocal(vl_newVarIdx, {calcFn := { null, {}, {} }});
}
return vl_newVarIdx;
}
} // group General
///////////////////////////////////////////////////////////////////////////////
// Group: contentStat
//
// Purpose:
// Functions for the content stat
//
// Description:
// The aim of this statistics is to interpret an EPTF_Var as a statistics
///////////////////////////////////////////////////////////////////////////////
group contentStat {
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_newStat_content
//
// Purpose:
// Creates a new 'content' statistics for the EPTF Variable.
//
// Parameters:
// pl_varIdx - *in* *integer* - the idx of the EPTF variable (-1 is not allowed)
//
// Return Value:
// *integer* - the idx of the new statistics (-1 if statistics cannot be created)
//
// Errors:
// -
//
// Detailed Comments:
// A standalone content statistics cannot be created!
// This function can be called for any type of var
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_newStat_content(
in integer pl_varIdx)
runs on EPTF_StatMeasure_CT return integer
{
if (pl_varIdx==-1)
{
f_EPTF_StatMeasure_warning(
"It is not allowed to create standalone content statistics!");
return -1;
}
var integer vl_newStatIdx := sizeof(statList);
statList[vl_newStatIdx] := { pl_varIdx, -1, {content := {}}, true, true }; // always enabled
return vl_newStatIdx;
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_resetStat_content
//
// Purpose:
// Reset 'content' statistics for the EPTF Variable.
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// This function can be called for any type of stats
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_resetStat_content(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT
{
// nothing to do (cannot reset)
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_initStatValue_content
//
// Purpose:
// Initializes the value of 'content' statistics for the EPTF Variable.
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// This function can be called for any type of stats
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_initStatValue_content(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT
{
// nothing to do (cannot init)
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_enableStat_content
//
// Purpose:
// Enable 'content' statistics for the EPTF Variable.
//
// Parameters:
// pl_idx - *in* *integer* - the idx of the EPTF_Var
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// This function can be called for any type of stats
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_enableStat_content(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT
{
// nothing to do: stat is always enabled
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_disableStat_content
//
// Purpose:
// Disable 'content' statistics for the EPTF Variable.
//
// Parameters:
// pl_idx - *in* *integer* - the idx of the EPTF_Var
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// This function can be called for any type of stats
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_disableStat_content(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT
{
// nothing to do: cannot disable stat
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_getStat_content
//
// Purpose:
// Returns the value of the 'content' statistics
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
// pl_statValue - *out* <EPTF_Var_DirectContent> - the value of the stat
//
// Return Value:
// *boolean* - true if stat is available, false if no
//
// Errors:
// -
//
// Detailed Comments:
// This function can be called for any type of stats
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_getStat_content(
in integer pl_statIdx,
out EPTF_Var_DirectContent pl_statValue)
runs on EPTF_StatMeasure_CT
{
//f_EPTF_Base_assert(ischosen(statList[pl_statIdx].statData.content));
f_EPTF_Var_getContent(f_EPTF_StatMeasure_getVarIdx(pl_statIdx),pl_statValue);
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_content2str
//
// Purpose:
// Returns the value of the 'content' statistics as a charstring
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the stat
//
// Return Value:
// *charstring* - the value of the statistics as a charstring
//
// Errors:
// -
//
// Detailed Comments:
// This function can be called for any type of stats
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_content2str(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT return charstring
{
return f_EPTF_Var_content2str(f_EPTF_StatMeasure_getVarIdx(pl_statIdx));
}
} // group contentStat
///////////////////////////////////////////////////////////////////////////////
// Group: deltaStat
//
// Purpose:
// Functions for the delta stat
//
// Description:
// The aim of this statistics is to measure the difference between two
// subsequent data values
///////////////////////////////////////////////////////////////////////////////
group deltaStat {
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_newStat_delta
//
// Purpose:
// Creates a new 'delta' statistics for the EPTF Variable.
//
// Parameters:
// pl_varIdx - *in* *integer* - the idx of the EPTF variable (its type should be integer or float)
// (-1 to create stat without a variable). Default: -1
//
// Return Value:
// *integer* - the idx of the new statistics
//
// Errors:
// -
//
// Detailed Comments:
// The type of the statistics is set to integer by default!
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_newStat_delta(
in integer pl_varIdx := -1)
runs on EPTF_StatMeasure_CT return integer
{
var integer vl_newStatIdx := sizeof(statList);
statList[vl_newStatIdx] := {
pl_varIdx, -1, {delta := { {intVal := 0}, {intVal := 0}}}, false, true
};
// change content to float if source variable is float
if (pl_varIdx!=-1) {
var EPTF_Var_DirectContent vl_contentNew;
f_EPTF_Var_getContent(pl_varIdx,vl_contentNew);
if (ischosen(vl_contentNew.floatVal)) {
statList[vl_newStatIdx].statData.delta := { {floatVal := 0.0}, {floatVal := 0.0} };
}
}
f_EPTF_StatMeasure_resetStat_delta(vl_newStatIdx);
// enable the stat:
f_EPTF_StatMeasure_enableStat_delta(vl_newStatIdx);
return vl_newStatIdx;
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_resetStat_delta
//
// Purpose:
// Reset 'delta' statistics for the EPTF Variable.
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_resetStat_delta(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT
{
statList[pl_statIdx].reset := true;
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_initStatValue_delta
//
// Purpose:
// Initializes the value of 'delta' statistics for the EPTF Variable.
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// Stat is initialized with zero.
// The created variable is also updated.
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_initStatValue_delta(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT
{
f_EPTF_StatMeasure_resetStat_delta(pl_statIdx)
if (ischosen(statList[pl_statIdx].statData.delta.statValue.intVal)) {
statList[pl_statIdx].statData.delta := { {intVal := 0}, {intVal := 0} };
}
else if (ischosen(statList[pl_statIdx].statData.delta.statValue.floatVal)) {
statList[pl_statIdx].statData.delta := { {floatVal := 0.0}, {floatVal := 0.0} };
}
f_EPTF_StatMeasure_updateCreatedVar(pl_statIdx);
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_changeToFloat_delta
//
// Purpose:
// Changes the type of a new 'delta' statistics to float.
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
//
// Return Value:
//
// Errors:
// If addData was already called, this function stops with an error.
//
// Detailed Comments:
// The type of a statistics created form a variable (i.e. not standalone)
// cannot be changed.
// This function should be called right after the statistics was created,
// if the type of the statistics should be float. Note, that the type is
// changed to float automatically if needed when the first data is added.
// However, if a variable should be created from the statistics, but no
// data was added, this function has to be called!
// After a variable was created form the statistics, or a statistics was
// created from a variable (i.e. not standalone), this function cannot
// be called!
// This function can be called only after the statistics was reset.
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_changeToFloat_delta(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT
{
if(f_EPTF_StatMeasure_getVarIdx(pl_statIdx) != -1) {
f_EPTF_StatMeasure_error(log2str("Cannot change the type to float of the stat ", pl_statIdx,
": The statistics is not a standalone stat"));
f_EPTF_Base_stop();
}
if(f_EPTF_StatMeasure_getCreatedVarIdx(pl_statIdx) != -1) {
f_EPTF_StatMeasure_error(log2str("Cannot change the type to float of the stat ", pl_statIdx,
": A variable was created from the statistics"));
f_EPTF_Base_stop();
}
if (not statList[pl_statIdx].reset) {
f_EPTF_StatMeasure_error(log2str("Cannot change the type to float of the stat ", pl_statIdx,
": The statistics was not reset"));
f_EPTF_Base_stop();
}
statList[pl_statIdx].statData.delta := { {floatVal := 0.0}, {floatVal := 0.0} };
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_addData_delta
//
// Purpose:
// Add new data for the 'delta' statistics.
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// If no variable was given when the statistics was created,
// this function can be used to add new data.
// If the statistics was created for an existing EPTF Variable data will be
// automatically added when the value of the variable is refreshed. But
// this function can be used to add additional data also.
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_addData_delta(
in integer pl_statIdx,
in EPTF_Var_DirectContent pl_newData)
runs on EPTF_StatMeasure_CT
{
if (not statList[pl_statIdx].enabled) {
return;
}
f_EPTF_Base_assert("Invalid stat type.",
ischosen(statList[pl_statIdx].statData.delta));
if (statList[pl_statIdx].reset) {
statList[pl_statIdx].reset := false;
// first value:
if (ischosen(pl_newData.intVal)) {
statList[pl_statIdx].statData.delta := {pl_newData, {intVal := 0}};
} else if (ischosen(pl_newData.floatVal)) {
statList[pl_statIdx].statData.delta := {pl_newData, {floatVal := 0.0}};
}
statList[pl_statIdx].statData.delta.prevContent := pl_newData;
f_EPTF_StatMeasure_updateCreatedVar(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.delta.statValue.intVal))
{
statList[pl_statIdx].statData.delta.statValue.intVal :=
pl_newData.intVal - statList[pl_statIdx].statData.delta.prevContent.intVal;
} else if (ischosen(statList[pl_statIdx].statData.delta.statValue.floatVal))
{
statList[pl_statIdx].statData.delta.statValue.floatVal :=
pl_newData.floatVal - statList[pl_statIdx].statData.delta.prevContent.floatVal;
}
statList[pl_statIdx].statData.delta.prevContent := pl_newData;
f_EPTF_StatMeasure_updateCreatedVar(pl_statIdx);
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_enableStat_delta
//
// Purpose:
// Enable 'delta' statistics for the EPTF Variable.
//
// Parameters:
// pl_idx - *in* *integer* - the idx of the EPTF_Var
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_enableStat_delta(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT
{
if (statList[pl_statIdx].enabled) {
return;
}
statList[pl_statIdx].enabled := true;
var integer vl_varIdx := f_EPTF_StatMeasure_getVarIdx(pl_statIdx);
if (vl_varIdx==-1) {
return;
}
f_EPTF_Base_assert("Invalid stat type.",
ischosen(statList[pl_statIdx].statData.delta));
f_EPTF_Var_addPostProcFn(vl_varIdx,
{refers(f_EPTF_StatMeasure_update_delta_PostProc), {pl_statIdx}});
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_disableStat_delta
//
// Purpose:
// Disable 'delta' statistics for the EPTF Variable.
//
// Parameters:
// pl_idx - *in* *integer* - the idx of the EPTF_Var
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_disableStat_delta(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT
{
if (not statList[pl_statIdx].enabled) {
return;
}
statList[pl_statIdx].enabled := false;
var integer vl_varIdx := f_EPTF_StatMeasure_getVarIdx(pl_statIdx);
if (vl_varIdx==-1) {
return;
}
f_EPTF_Var_removePostProcFn(vl_varIdx,
{refers(f_EPTF_StatMeasure_update_delta_PostProc), {pl_statIdx}});
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_getStat_delta
//
// Purpose:
// Returns the value of the 'delta' statistics
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
// pl_statValue - *out* <EPTF_Var_DirectContent> - the value of the stat
//
// Return Value:
// *boolean* - true if stat is available, false if no
//
// Errors:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_getStat_delta(
in integer pl_statIdx,
out EPTF_Var_DirectContent pl_statValue)
runs on EPTF_StatMeasure_CT return boolean
{
f_EPTF_Base_assert("Invalid stat type.",
ischosen(statList[pl_statIdx].statData.delta));
pl_statValue := statList[pl_statIdx].statData.delta.statValue;
return f_EPTF_StatMeasure_valueIsAvailable(pl_statIdx);
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_delta2str
//
// Purpose:
// Returns the value of the 'delta' statistics as a charstring
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the stat
//
// Return Value:
// *charstring* - the value of the statistics as a charstring
//
// Errors:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_delta2str(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT return charstring
{
var EPTF_Var_DirectContent vl_currentContent;
if (f_EPTF_StatMeasure_getStat_delta(pl_statIdx, vl_currentContent)) {
return f_EPTF_Var_directContent2str(vl_currentContent);
} else {
return "N/A";
}
}
} // group deltaStat
///////////////////////////////////////////////////////////////////////////////
// Group: deltaSumStat
//
// Purpose:
// Functions for the deltaSum stat
//
// Description:
// The aim of this statistics is to measure the difference between the initial
// and the current data values
///////////////////////////////////////////////////////////////////////////////
group deltaSumStat {
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_newStat_deltaSum
//
// Purpose:
// Creates a new 'deltaSum' statistics for the EPTF Variable.
//
// Parameters:
// pl_varIdx - *in* *integer* - the idx of the EPTF variable (its type should be integer or float)
// (-1 to create stat without a variable). Default: -1
//
// Return Value:
// *integer* - the idx of the new statistics
//
// Errors:
// -
//
// Detailed Comments:
// The type of the statistics is set to integer by default!
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_newStat_deltaSum(
in integer pl_varIdx := -1)
runs on EPTF_StatMeasure_CT return integer
{
var integer vl_newStatIdx := sizeof(statList);
statList[vl_newStatIdx] := { pl_varIdx, -1,
{deltaSum := { {intVal := 0}, {intVal := 0}}}, false, true };
// change content to float if source variable is float
if (pl_varIdx!=-1) {
var EPTF_Var_DirectContent vl_contentNew;
f_EPTF_Var_getContent(pl_varIdx,vl_contentNew);
if (ischosen(vl_contentNew.floatVal)) {
statList[vl_newStatIdx].statData.deltaSum := { {floatVal := 0.0}, {floatVal := 0.0} };
}
}
f_EPTF_StatMeasure_resetStat_deltaSum(vl_newStatIdx);
// enable the stat:
f_EPTF_StatMeasure_enableStat_deltaSum(vl_newStatIdx);
return vl_newStatIdx;
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_resetStat_deltaSum
//
// Purpose:
// Reset 'deltaSum' statistics for the EPTF Variable.
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_resetStat_deltaSum(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT
{
statList[pl_statIdx].reset := true;
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_initStatValue_deltaSum
//
// Purpose:
// Initializes the value of 'deltaSum' statistics for the EPTF Variable.
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// Stat is initialized with zero.
// The created variable is also updated.
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_initStatValue_deltaSum(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT
{
f_EPTF_StatMeasure_resetStat_deltaSum(pl_statIdx);
if (ischosen(statList[pl_statIdx].statData.deltaSum.statValue.intVal)) {
statList[pl_statIdx].statData.deltaSum := { {intVal := 0}, {intVal := 0} };
}
else if (ischosen(statList[pl_statIdx].statData.deltaSum.statValue.floatVal)) {
statList[pl_statIdx].statData.deltaSum := { {floatVal := 0.0}, {floatVal := 0.0} };
}
f_EPTF_StatMeasure_updateCreatedVar(pl_statIdx);
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_changeToFloat_deltaSum
//
// Purpose:
// Changes the type of a new 'deltaSum' statistics to float.
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
//
// Return Value:
//
// Errors:
// If addData was already called, this function stops with an error.
//
// Detailed Comments:
// The type of a statistics created form a variable (i.e. not standalone)
// cannot be changed.
// This function should be called right after the statistics was created,
// if the type of the statistics should be float. Note, that the type is
// changed to float automatically if needed when the first data is added.
// However, if a variable should be created from the statistics, but no
// data was added, this function has to be called!
// After a variable was created form the statistics, or a statistics was
// created from a variable (i.e. not standalone), this function cannot
// be called!
// This function can be called only after the statistics was reset.
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_changeToFloat_deltaSum(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT
{
if(f_EPTF_StatMeasure_getVarIdx(pl_statIdx) != -1) {
f_EPTF_StatMeasure_error(log2str("Cannot change the type to float of the stat ", pl_statIdx,
": The statistics is not a standalone stat"));
f_EPTF_Base_stop();
}
if(f_EPTF_StatMeasure_getCreatedVarIdx(pl_statIdx) != -1) {
f_EPTF_StatMeasure_error(log2str("Cannot change the type to float of the stat ", pl_statIdx,
": A variable was created from the statistics"));
f_EPTF_Base_stop();
}
if (not statList[pl_statIdx].reset) {
f_EPTF_StatMeasure_error(log2str("Cannot change the type to float of the stat ", pl_statIdx,
": The statistics was not reset"));
f_EPTF_Base_stop();
}
statList[pl_statIdx].statData.deltaSum := { {floatVal := 0.0}, {floatVal := 0.0} };
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_addData_deltaSum
//
// Purpose:
// Add new data for the 'deltaSum' statistics.
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// If no variable was given when the statistics was created, this function
// can be used to add new data.
// If the statistics was created for an existing EPTF Variable data will be
// automatically added when the value of the variable is refreshed.
// But this function can be used to add additional data also.
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_addData_deltaSum(
in integer pl_statIdx,
in EPTF_Var_DirectContent pl_newData)
runs on EPTF_StatMeasure_CT
{
if (not statList[pl_statIdx].enabled) {
return;
}
f_EPTF_Base_assert("Invalid stat type.",
ischosen(statList[pl_statIdx].statData.deltaSum));
if (statList[pl_statIdx].reset) {
statList[pl_statIdx].reset:=false;
// first value:
if (ischosen(pl_newData.intVal)) {
statList[pl_statIdx].statData.deltaSum := {pl_newData, {intVal := 0}};
} else if (ischosen(pl_newData.floatVal)) {
statList[pl_statIdx].statData.deltaSum := {pl_newData, {floatVal := 0.0}};
}
statList[pl_statIdx].statData.deltaSum.iniContent := pl_newData;
f_EPTF_StatMeasure_updateCreatedVar(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.deltaSum.statValue.intVal))
{
statList[pl_statIdx].statData.deltaSum.statValue.intVal :=
pl_newData.intVal - statList[pl_statIdx].statData.deltaSum.iniContent.intVal;
} else if (ischosen(statList[pl_statIdx].statData.deltaSum.statValue.floatVal))
{
statList[pl_statIdx].statData.deltaSum.statValue.floatVal :=
pl_newData.floatVal - statList[pl_statIdx].statData.deltaSum.iniContent.floatVal;
}
f_EPTF_StatMeasure_updateCreatedVar(pl_statIdx);
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_enableStat_deltaSum
//
// Purpose:
// Enable 'deltaSum' statistics for the EPTF Variable.
//
// Parameters:
// pl_idx - *in* *integer* - the idx of the EPTF_Var
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_enableStat_deltaSum(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT
{
if (statList[pl_statIdx].enabled) {
return;
}
statList[pl_statIdx].enabled := true;
var integer vl_varIdx := f_EPTF_StatMeasure_getVarIdx(pl_statIdx);
if (vl_varIdx==-1) {
return;
}
f_EPTF_Base_assert("Invalid stat type.",
ischosen(statList[pl_statIdx].statData.deltaSum));
f_EPTF_Var_addPostProcFn(vl_varIdx,
{refers(f_EPTF_StatMeasure_update_deltaSum_PostProc), {pl_statIdx}});
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_disableStat_deltaSum
//
// Purpose:
// Disable 'deltaSum' statistics for the EPTF Variable.
//
// Parameters:
// pl_idx - *in* *integer* - the idx of the EPTF_Var
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_disableStat_deltaSum(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT
{
if (not statList[pl_statIdx].enabled) {
return;
}
statList[pl_statIdx].enabled := false;
var integer vl_varIdx := f_EPTF_StatMeasure_getVarIdx(pl_statIdx);
if (vl_varIdx==-1) {
return;
}
f_EPTF_Var_removePostProcFn(vl_varIdx,
{refers(f_EPTF_StatMeasure_update_deltaSum_PostProc), {pl_statIdx}});
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_getStat_deltaSum
//
// Purpose:
// Returns the value of the 'deltaSum' statistics
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
// pl_statValue - *out* <EPTF_Var_DirectContent> - the value of the stat
//
// Return Value:
// *boolean* - true if stat is available, false if no
//
// Errors:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_getStat_deltaSum(
in integer pl_statIdx,
out EPTF_Var_DirectContent pl_statValue)
runs on EPTF_StatMeasure_CT return boolean
{
f_EPTF_Base_assert("Invalid stat type.",
ischosen(statList[pl_statIdx].statData.deltaSum));
pl_statValue := statList[pl_statIdx].statData.deltaSum.statValue;
return f_EPTF_StatMeasure_valueIsAvailable(pl_statIdx);
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_deltaSum2str
//
// Purpose:
// Returns the value of the 'deltasum' statistics as a charstring
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the stat
//
// Return Value:
// *charstring* - the value of the statistics as a charstring
//
// Errors:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_deltaSum2str(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT return charstring
{
var EPTF_Var_DirectContent vl_currentContent;
if (f_EPTF_StatMeasure_getStat_deltaSum(pl_statIdx, vl_currentContent)) {
return f_EPTF_Var_directContent2str(vl_currentContent);
} else {
return "N/A";
}
}
} // group deltaSumStat
///////////////////////////////////////////////////////////////////////////////
// Group: minStat
//
// Purpose:
// Functions for the min stat
//
// Description:
// The aim of this statistics is to measure the minimum of the data values
///////////////////////////////////////////////////////////////////////////////
group minStat {
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_newStat_min
//
// Purpose:
// Creates a new 'min' statistics for the EPTF Variable.
//
// Parameters:
// pl_varIdx - *in* *integer* - the idx of the EPTF variable (its type should be integer or float)
// (-1 to create stat without a variable). Default: -1
//
// Return Value:
// *integer* - the idx of the new statistics
//
// Errors:
// -
//
// Detailed Comments:
// The type of the statistics is set to integer by default!
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_newStat_min(
in integer pl_varIdx := -1)
runs on EPTF_StatMeasure_CT return integer
{
var integer vl_newStatIdx := sizeof(statList);
statList[vl_newStatIdx] := { pl_varIdx, -1,
{min := { {intVal := 0}}}, false, true };
// change content to float if source variable is float
if (pl_varIdx!=-1) {
var EPTF_Var_DirectContent vl_contentNew;
f_EPTF_Var_getContent(pl_varIdx,vl_contentNew);
if (ischosen(vl_contentNew.floatVal)) {
statList[vl_newStatIdx].statData.min := {{floatVal := 0.0}};
}
}
f_EPTF_StatMeasure_resetStat_min(vl_newStatIdx);
// enable the stat:
f_EPTF_StatMeasure_enableStat_min(vl_newStatIdx);
return vl_newStatIdx;
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_resetStat_min
//
// Purpose:
// Reset 'min' statistics for the EPTF Variable.
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_resetStat_min(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT
{
statList[pl_statIdx].reset := true;
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_initStatValue_min
//
// Purpose:
// Initializes the value of 'min' statistics for the EPTF Variable.
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// Stat is initialized with zero.
// The created variable is also updated.
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_initStatValue_min(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT
{
f_EPTF_StatMeasure_resetStat_min(pl_statIdx);
if (ischosen(statList[pl_statIdx].statData.min.statValue.intVal)) {
statList[pl_statIdx].statData.min := { { intVal := 0 } };
}
else if (ischosen(statList[pl_statIdx].statData.min.statValue.floatVal)) {
statList[pl_statIdx].statData.min := { { floatVal := 0.0 } };
}
f_EPTF_StatMeasure_updateCreatedVar(pl_statIdx);
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_changeToFloat_min
//
// Purpose:
// Changes the type of a new 'min' statistics to float.
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
//
// Return Value:
//
// Errors:
// If addData was already called, this function stops with an error.
//
// Detailed Comments:
// The type of a statistics created form a variable (i.e. not standalone)
// cannot be changed.
// This function should be called right after the statistics was created,
// if the type of the statistics should be float. Note, that the type is
// changed to float automatically if needed when the first data is added.
// However, if a variable should be created from the statistics, but no
// data was added, this function has to be called!
// After a variable was created form the statistics, or a statistics was
// created from a variable (i.e. not standalone), this function cannot
// be called!
// This function can be called only after the statistics was reset.
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_changeToFloat_min(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT
{
if(f_EPTF_StatMeasure_getVarIdx(pl_statIdx) != -1) {
f_EPTF_StatMeasure_error(log2str("Cannot change the type to float of the stat ", pl_statIdx,
": The statistics is not a standalone stat"));
f_EPTF_Base_stop();
}
if(f_EPTF_StatMeasure_getCreatedVarIdx(pl_statIdx) != -1) {
f_EPTF_StatMeasure_error(log2str("Cannot change the type to float of the stat ", pl_statIdx,
": A variable was created from the statistics"));
f_EPTF_Base_stop();
}
if (not statList[pl_statIdx].reset) {
f_EPTF_StatMeasure_error(log2str("Cannot change the type to float of the stat ", pl_statIdx,
": The statistics was not reset"));
f_EPTF_Base_stop();
}
statList[pl_statIdx].statData.min := {{floatVal := 0.0}};
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_addData_min
//
// Purpose:
// Add new data for the 'min' statistics.
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// If no variable was given when the statistics was created,
// this function can be used to add new data.
// If the statistics was created for an existing EPTF Variable data will be
// automatically added when the value of the variable is refreshed.
// But this function can be used to add additional data also.
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_addData_min(
in integer pl_statIdx,
in EPTF_Var_DirectContent pl_newData)
runs on EPTF_StatMeasure_CT
{
if (not statList[pl_statIdx].enabled) {
return;
}
f_EPTF_Base_assert("Invalid stat type.",
ischosen(statList[pl_statIdx].statData.min));
if (statList[pl_statIdx].reset) {
statList[pl_statIdx].reset := false;
statList[pl_statIdx].statData.min := {pl_newData};
f_EPTF_StatMeasure_updateCreatedVar(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.min.statValue.intVal)) {
if (pl_newData.intVal<statList[pl_statIdx].statData.min.statValue.intVal) {
statList[pl_statIdx].statData.min.statValue.intVal := pl_newData.intVal;
}
} else if (ischosen(statList[pl_statIdx].statData.min.statValue.floatVal)) {
if (pl_newData.floatVal<statList[pl_statIdx].statData.min.statValue.floatVal) {
statList[pl_statIdx].statData.min.statValue.floatVal := pl_newData.floatVal;
}
}
f_EPTF_StatMeasure_updateCreatedVar(pl_statIdx);
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_enableStat_min
//
// Purpose:
// Enable 'min' statistics for the EPTF Variable.
//
// Parameters:
// pl_idx - *in* *integer* - the idx of the EPTF_Var
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_enableStat_min(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT
{
if (statList[pl_statIdx].enabled) {
return;
}
statList[pl_statIdx].enabled := true;
var integer vl_varIdx := f_EPTF_StatMeasure_getVarIdx(pl_statIdx);
if (vl_varIdx==-1) {
return;
}
f_EPTF_Base_assert("Invalid stat type.",
ischosen(statList[pl_statIdx].statData.min));
f_EPTF_Var_addPostProcFn(vl_varIdx,
{refers(f_EPTF_StatMeasure_update_min_PostProc), {pl_statIdx}});
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_disableStat_min
//
// Purpose:
// Disable 'min' statistics for the EPTF Variable.
//
// Parameters:
// pl_idx - *in* *integer* - the idx of the EPTF_Var
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_disableStat_min(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT
{
if (not statList[pl_statIdx].enabled) {
return;
}
statList[pl_statIdx].enabled := false;
var integer vl_varIdx := f_EPTF_StatMeasure_getVarIdx(pl_statIdx);
if (vl_varIdx==-1) {
return;
}
f_EPTF_Var_removePostProcFn(vl_varIdx,
{refers(f_EPTF_StatMeasure_update_min_PostProc), {pl_statIdx}});
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_getStat_min
//
// Purpose:
// Returns the value of the 'min' statistics
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
// pl_statValue - *out* <EPTF_Var_DirectContent> - the value of the stat
//
// Return Value:
// *boolean* - true if stat is available, false if no
//
// Errors:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_getStat_min(
in integer pl_statIdx,
out EPTF_Var_DirectContent pl_statValue)
runs on EPTF_StatMeasure_CT return boolean
{
f_EPTF_Base_assert("Invalid stat type.",
ischosen(statList[pl_statIdx].statData.min));
pl_statValue := statList[pl_statIdx].statData.min.statValue;
return f_EPTF_StatMeasure_valueIsAvailable(pl_statIdx);
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_min2str
//
// Purpose:
// Returns the value of the 'min' statistics as a charstring
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the stat
//
// Return Value:
// *charstring* - the value of the statistics as a charstring
//
// Errors:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_min2str(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT return charstring
{
var EPTF_Var_DirectContent vl_currentContent;
if (f_EPTF_StatMeasure_getStat_min(pl_statIdx, vl_currentContent)) {
return f_EPTF_Var_directContent2str(vl_currentContent);
} else {
return "N/A";
}
}
} // group minStat
///////////////////////////////////////////////////////////////////////////////
// Group: maxStat
//
// Purpose:
// Functions for the max stat
//
// Description:
// The aim of this statistics is to measure the maximum of the data values
///////////////////////////////////////////////////////////////////////////////
group maxStat {
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_newStat_max
//
// Purpose:
// Creates a new 'max' statistics for the EPTF Variable.
//
// Parameters:
// pl_varIdx - *in* *integer* - the idx of the EPTF variable (its type should be integer or float)
// (-1 to create stat without a variable). Default: -1
//
// Return Value:
// *integer* - the idx of the new statistics
//
// Errors:
// -
//
// Detailed Comments:
// The type of the statistics is set to integer by default!
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_newStat_max(
in integer pl_varIdx := -1)
runs on EPTF_StatMeasure_CT return integer
{
var integer vl_newStatIdx := sizeof(statList);
statList[vl_newStatIdx] :=
{ pl_varIdx, -1, {max := { {intVal := 0}}}, false, true };
// change content to float if source variable is float
if (pl_varIdx!=-1) {
var EPTF_Var_DirectContent vl_contentNew;
f_EPTF_Var_getContent(pl_varIdx,vl_contentNew);
if (ischosen(vl_contentNew.floatVal)) {
statList[vl_newStatIdx].statData.max := {{floatVal := 0.0}};
}
}
f_EPTF_StatMeasure_resetStat_max(vl_newStatIdx);
// enable the stat:
f_EPTF_StatMeasure_enableStat_max(vl_newStatIdx);
return vl_newStatIdx;
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_changeToFloat_max
//
// Purpose:
// Changes the type of a new 'max' statistics to float.
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
//
// Return Value:
//
// Errors:
// If addData was already called, this function stops with an error.
//
// Detailed Comments:
// The type of a statistics created form a variable (i.e. not standalone)
// cannot be changed.
// This function should be called right after the statistics was created,
// if the type of the statistics should be float. Note, that the type is
// changed to float automatically if needed when the first data is added.
// However, if a variable should be created from the statistics, but no
// data was added, this function has to be called!
// After a variable was created form the statistics, or a statistics was
// created from a variable (i.e. not standalone), this function cannot
// be called!
// This function can be called only after the statistics was reset.
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_changeToFloat_max(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT
{
if(f_EPTF_StatMeasure_getVarIdx(pl_statIdx) != -1) {
f_EPTF_StatMeasure_error(log2str("Cannot change the type to float of the stat ", pl_statIdx,
": The statistics is not a standalone stat"));
f_EPTF_Base_stop();
}
if(f_EPTF_StatMeasure_getCreatedVarIdx(pl_statIdx) != -1) {
f_EPTF_StatMeasure_error(log2str("Cannot change the type to float of the stat ", pl_statIdx,
": A variable was created from the statistics"));
f_EPTF_Base_stop();
}
if (not statList[pl_statIdx].reset) {
f_EPTF_StatMeasure_error(log2str("Cannot change the type to float of the stat ", pl_statIdx,
": The statistics was not reset"));
f_EPTF_Base_stop();
}
statList[pl_statIdx].statData.max := {{floatVal := 0.0}};
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_resetStat_max
//
// Purpose:
// Reset 'max' statistics for the EPTF Variable.
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_resetStat_max(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT
{
statList[pl_statIdx].reset := true;
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_initStatValue_max
//
// Purpose:
// Initializes the value of 'max' statistics for the EPTF Variable.
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// Stat is initialized with zero.
// The created variable is also updated.
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_initStatValue_max(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT
{
f_EPTF_StatMeasure_resetStat_max(pl_statIdx);
if (ischosen(statList[pl_statIdx].statData.max.statValue.intVal)) {
statList[pl_statIdx].statData.max := { {intVal := 0} };
}
else if (ischosen(statList[pl_statIdx].statData.max.statValue.floatVal)) {
statList[pl_statIdx].statData.max := { {floatVal := 0.0} };
}
f_EPTF_StatMeasure_updateCreatedVar(pl_statIdx);
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_addData_max
//
// Purpose:
// Add new data for the 'max' statistics.
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// If no variable was given when the statistics was created,
// this function can be used to add new data.
// If the statistics was created for an existing EPTF Variable data will be
// automatically added when the value of the variable is refreshed.
// But this function can be used to add additional data also.
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_addData_max(
in integer pl_statIdx,
in EPTF_Var_DirectContent pl_newData)
runs on EPTF_StatMeasure_CT
{
if (not statList[pl_statIdx].enabled) {
return;
}
f_EPTF_Base_assert("Invalid stat type.",
ischosen(statList[pl_statIdx].statData.max));
if (statList[pl_statIdx].reset) {
statList[pl_statIdx].reset:=false;
statList[pl_statIdx].statData.max := {pl_newData};
f_EPTF_StatMeasure_updateCreatedVar(pl_statIdx);
return;
}
if (ischosen(statList[pl_statIdx].statData.max.statValue.intVal)) {
if (pl_newData.intVal>statList[pl_statIdx].statData.max.statValue.intVal) {
statList[pl_statIdx].statData.max.statValue.intVal := pl_newData.intVal;
}
} else if (ischosen(statList[pl_statIdx].statData.max.statValue.floatVal)) {
if (pl_newData.floatVal>statList[pl_statIdx].statData.max.statValue.floatVal) {
statList[pl_statIdx].statData.max.statValue.floatVal := pl_newData.floatVal;
}
}
f_EPTF_StatMeasure_updateCreatedVar(pl_statIdx);
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_enableStat_max
//
// Purpose:
// Enable 'max' statistics for the EPTF Variable.
//
// Parameters:
// pl_idx - *in* *integer* - the idx of the EPTF_Var
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_enableStat_max(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT
{
if (statList[pl_statIdx].enabled) {
return;
}
statList[pl_statIdx].enabled := true;
var integer vl_varIdx := f_EPTF_StatMeasure_getVarIdx(pl_statIdx);
if (vl_varIdx==-1) {
return;
}
f_EPTF_Base_assert("Invalid stat type.",
ischosen(statList[pl_statIdx].statData.max));
f_EPTF_Var_addPostProcFn(vl_varIdx,
{refers(f_EPTF_StatMeasure_update_max_PostProc), {pl_statIdx}});
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_disableStat_max
//
// Purpose:
// Disable 'max' statistics for the EPTF Variable.
//
// Parameters:
// pl_idx - *in* *integer* - the idx of the EPTF_Var
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_disableStat_max(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT
{
if (not statList[pl_statIdx].enabled) {
return;
}
statList[pl_statIdx].enabled := false;
var integer vl_varIdx := f_EPTF_StatMeasure_getVarIdx(pl_statIdx);
if (vl_varIdx==-1) {
return;
}
f_EPTF_Var_removePostProcFn(vl_varIdx,
{refers(f_EPTF_StatMeasure_update_max_PostProc), {pl_statIdx}});
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_getStat_max
//
// Purpose:
// Returns the value of the 'max' statistics
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
// pl_statValue - *out* <EPTF_Var_DirectContent> - the value of the stat
//
// Return Value:
// *boolean* - true if stat is available, false if no
//
// Errors:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_getStat_max(
in integer pl_statIdx,
out EPTF_Var_DirectContent pl_statValue)
runs on EPTF_StatMeasure_CT return boolean
{
f_EPTF_Base_assert("Invalid stat type.",
ischosen(statList[pl_statIdx].statData.max));
pl_statValue := statList[pl_statIdx].statData.max.statValue;
return f_EPTF_StatMeasure_valueIsAvailable(pl_statIdx);
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_max2str
//
// Purpose:
// Returns the value of the 'max' statistics as a charstring
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the stat
//
// Return Value:
// *charstring* - the value of the statistics as a charstring
//
// Errors:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_max2str(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT return charstring
{
var EPTF_Var_DirectContent vl_currentContent;
if (f_EPTF_StatMeasure_getStat_max(pl_statIdx, vl_currentContent)) {
return f_EPTF_Var_directContent2str(vl_currentContent);
} else {
return "N/A";
}
}
} // group maxStat
///////////////////////////////////////////////////////////////////////////////
// Group: meanStat
//
// Purpose:
// Functions for the mean stat
//
// Description:
// The aim of this statistics is to measure the mean of the data values
///////////////////////////////////////////////////////////////////////////////
group meanStat {
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_newStat_mean
//
// Purpose:
// Creates a new 'mean' statistics for the EPTF Variable.
//
// Parameters:
// pl_varIdx - *in* *integer* - the idx of the EPTF variable (its type should be integer or float)
// (-1 to create stat without a variable). Default: -1
//
// Return Value:
// *integer* - the idx of the new statistics
//
// Errors:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_newStat_mean(
in integer pl_varIdx := -1)
runs on EPTF_StatMeasure_CT return integer
{
var integer vl_newStatIdx := sizeof(statList);
statList[vl_newStatIdx] := { pl_varIdx, -1,
{mean := { 0, 0.0, 0.0, 0.0 }}, false, true };
f_EPTF_StatMeasure_resetStat_mean(vl_newStatIdx);
// enable the stat:
f_EPTF_StatMeasure_enableStat_mean(vl_newStatIdx);
return vl_newStatIdx;
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_resetStat_mean
//
// Purpose:
// Reset 'mean' statistics for the EPTF Variable.
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_resetStat_mean(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT
{
statList[pl_statIdx].reset := true;
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_initStatValue_mean
//
// Purpose:
// Initializes the value of 'mean' statistics for the EPTF Variable.
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// Stat is initialized with zero.
// The created variable is also updated.
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_initStatValue_mean(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT
{
f_EPTF_StatMeasure_resetStat_mean(pl_statIdx);
statList[pl_statIdx].statData.mean := { 0, 0.0, 0.0, 0.0 };
f_EPTF_StatMeasure_updateCreatedVar(pl_statIdx);
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_addData_mean
//
// Purpose:
// Add new data for the 'mean' statistics.
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// If no variable was given when the statistics was created,
// this function can be used to add new data.
// If the statistics was created for an existing EPTF Variable data will be
// automatically added when the value of the variable is refreshed.
// But this function can be used to add additional data also.
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_addData_mean(
in integer pl_statIdx,
in float pl_newData)
runs on EPTF_StatMeasure_CT
{
if (not statList[pl_statIdx].enabled) {
return;
}
f_EPTF_Base_assert("Invalid stat type.",
ischosen(statList[pl_statIdx].statData.mean));
if (statList[pl_statIdx].reset) {
statList[pl_statIdx].reset := false;
statList[pl_statIdx].statData.mean := {0, 0.0, 0.0, 0.0};
f_EPTF_StatMeasure_addData_mean(pl_statIdx,pl_newData);
return;
}
var float x, delta;
x := pl_newData;
delta := x - statList[pl_statIdx].statData.mean.statValue;
statList[pl_statIdx].statData.mean.x := x;
statList[pl_statIdx].statData.mean.delta := delta;
statList[pl_statIdx].statData.mean.n := statList[pl_statIdx].statData.mean.n + 1;
statList[pl_statIdx].statData.mean.statValue :=
statList[pl_statIdx].statData.mean.statValue +
delta/int2float(statList[pl_statIdx].statData.mean.n);
f_EPTF_StatMeasure_updateCreatedVar(pl_statIdx);
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_enableStat_mean
//
// Purpose:
// Enable 'mean' statistics for the EPTF Variable.
//
// Parameters:
// pl_idx - *in* *integer* - the idx of the EPTF_Var
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_enableStat_mean(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT
{
if (statList[pl_statIdx].enabled) {
return;
}
statList[pl_statIdx].enabled := true;
var integer vl_varIdx := f_EPTF_StatMeasure_getVarIdx(pl_statIdx);
if (vl_varIdx==-1) {
return;
}
f_EPTF_Base_assert("Invalid stat type.",
ischosen(statList[pl_statIdx].statData.mean));
f_EPTF_Var_addPostProcFn(vl_varIdx,
{refers(f_EPTF_StatMeasure_update_mean_PostProc), {pl_statIdx}});
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_disableStat_mean
//
// Purpose:
// Disable 'mean' statistics for the EPTF Variable.
//
// Parameters:
// pl_idx - *in* *integer* - the idx of the EPTF_Var
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_disableStat_mean(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT
{
if (not statList[pl_statIdx].enabled) {
return;
}
statList[pl_statIdx].enabled := false;
var integer vl_varIdx := f_EPTF_StatMeasure_getVarIdx(pl_statIdx);
if (vl_varIdx==-1) {
return;
}
f_EPTF_Var_removePostProcFn(vl_varIdx,
{refers(f_EPTF_StatMeasure_update_mean_PostProc), {pl_statIdx}});
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_getStat_mean
//
// Purpose:
// Returns the value of the 'mean' statistics
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the statistics
// pl_statValue - *out* <EPTF_Var_DirectContent> - the value of the stat
//
// Return Value:
// *boolean* - true if stat is available, false if no
//
// Errors:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_getStat_mean(
in integer pl_statIdx,
out float pl_statValue)
runs on EPTF_StatMeasure_CT return boolean
{
f_EPTF_Base_assert("Invalid stat type.",
ischosen(statList[pl_statIdx].statData.mean));
pl_statValue := statList[pl_statIdx].statData.mean.statValue;
return f_EPTF_StatMeasure_valueIsAvailable(pl_statIdx);
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_mean2str
//
// Purpose:
// Returns the value of the 'mean' statistics as a charstring
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the stat
//
// Return Value:
// *charstring* - the value of the statistics as a charstring
//
// Errors:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_mean2str(
in integer pl_statIdx)
runs on EPTF_StatMeasure_CT return charstring
{
var float vl_currentContent;
if (f_EPTF_StatMeasure_getStat_mean(pl_statIdx, vl_currentContent)) {
return float2str(vl_currentContent);
} else {
return "N/A";
}
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_createVarFromStat_N_mean
//
// Purpose:
// Creates EPTF variable from auxuliary data N (i.e. the number of data samples) of the 'mean' statistics
//
// Parameters:
// pl_statIdx - *in* *integer* - the idx of the mean stat
// pl_varName - *in* *charstring* - the name of the created variable
// (if empty: name is auto-generated). Default: empty
//
// Return Value:
// *integer* - the idx of the EPTF Variable that contains the number of data samples
//
// Errors:
// -
//
// Detailed Comments:
// If no variable was created from the statistics, it creates that variable also.
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_createVarFromStat_N_mean(
in integer pl_statIdx,
in charstring pl_varName := ""
) runs on EPTF_StatMeasure_CT return integer
{
// check type of stat:
f_EPTF_Base_assert(%definitionId&": Invalid stat type: mean expected",
ischosen(statList[pl_statIdx].statData.mean));
var integer vl_nDataVarIdx;
var integer vl_statVarIdx := f_EPTF_StatMeasure_getCreatedVarIdx(pl_statIdx);
if (vl_statVarIdx==-1) {
f_EPTF_StatMeasure_warning(%definitionId&": No variable was created from the mean stat. Creating var automatically");
vl_statVarIdx := f_EPTF_StatMeasure_createVarFromStat(pl_statIdx);
}
// creating aux variable:
var charstring vl_statName := f_EPTF_StatMeasure_getStatName(pl_statIdx);
var charstring vl_varName := pl_varName;
if (vl_varName=="") {
vl_varName := "StatAux.n."&vl_statName;
}
vl_nDataVarIdx := f_EPTF_Var_getId(vl_varName);
if (vl_nDataVarIdx!=-1) {
return vl_nDataVarIdx; // var already created
}
f_EPTF_Var_newInt(vl_varName,0, vl_nDataVarIdx); // aux var for N
// add calcFn to calculate its value:
f_EPTF_Var_subscribeLocal(
vl_nDataVarIdx,
{
calcFn := {
funcRef := refers(f_EPTF_StatMeasure_getN_MeanStat_CalcFn),
argList := {vl_statVarIdx}, // the varible created from the mean stat
nonVarArgList := {pl_statIdx} // index of the mean statistics
}
}
);
return vl_nDataVarIdx;
//f_EPTF_Var_newFloat("StatAux.sum."&vl_statName,0.0,pl_sumDataVarIdx); // aux var for sum
//f_EPTF_Var_subscribeLocal(
// pl_sumDataVarIdx,
// {
// calcFn := {
// funcRef := refers(f_EPTF_StatMeasure_getSum_MeanStat_CalcFn),
// argList := {vl_statVarIdx}, // the varible created from the mean stat
// nonVarArgList := {pl_statIdx} // index of the mean statistics
// }
// }
//);
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_getN_MeanStat_CalcFn
//
// Purpose:
// calcFn that calculates the number of Data for mean stat
//
// Parameters:
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// mean stat Id : pl_nonVarArgList[0]
//
///////////////////////////////////////////////////////////////////////////////
private function f_EPTF_StatMeasure_getN_MeanStat_CalcFn(
in integer pl_idx,
in EPTF_IntegerList pl_argList,
in EPTF_IntegerList pl_nonVarArgList,
inout EPTF_Var_DirectContent pl_retVal
) runs on EPTF_StatMeasure_CT {
var integer vl_statId := pl_nonVarArgList[0];
pl_retVal := { intVal := statList[vl_statId].statData.mean.n };
}
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_getSum_MeanStat_CalcFn
//
// Purpose:
// calcFn that calculates the sum of Data for mean stat
//
// Parameters:
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// mean stat Id : pl_nonVarArgList[0]
//
///////////////////////////////////////////////////////////////////////////////
private function f_EPTF_StatMeasure_getSum_MeanStat_CalcFn(
in integer pl_idx,
in EPTF_IntegerList pl_argList,
in EPTF_IntegerList pl_nonVarArgList,
inout EPTF_Var_DirectContent pl_retVal
) runs on EPTF_StatMeasure_CT {
var integer vl_statId := pl_nonVarArgList[0];
pl_retVal := { floatVal := int2float(statList[vl_statId].statData.mean.n) * statList[vl_statId].statData.mean.statValue};
}
} // group meanStat
///////////////////////////////////////////////////////////////////////////////
// Group: standardDevStat
//
// Purpose:
// Functions for the standardDev stat
//
// Description:
// The aim of this statistics is to measure the standard deviation of the data values
///////////////////////////////////////////////////////////////////////////////
group standardDevStat {
///////////////////////////////////////////////////////////////////////////////
// Function: f_EPTF_StatMeasure_newStat_standardDev
//
// Purpose:
// Creates a new 'standardDev' statistics for the EPTF Variable.
//
// Parameters:
// pl_varIdx - *in* *integer* - the idx of the EPTF variable
// (-1 to create stat without a variable). Default: -1
//
// Return Value:
// *integer* - the idx of the new statistics
//
// Errors:
// -
//
// Detailed Comments:
// Creates a mean stat also. It can be accessed by
// <f_EPTF_StatMeasure_getStat_standardDev_mean>.
//
///////////////////////////////////////////////////////////////////////////////
public function f_EPTF_StatMeasure_newStat_standardDev(
in integer pl_varIdx := -1)
runs on EPTF_StatMeasure_CT return integer
{
// create the mean stat also for standardDev:
var integer vl_meanIdx := f_EPTF_StatMeasure_newStat_mean(pl_varIdx);
f_EPTF_StatMeasure_disableStat_mean(vl_meanIdx); // disable mean: the standardDev's updateFunction will update it
var integer vl_newStatIdx :=