blob: feac1dc8e62c408498e1a73e2ce355d7589394a7 [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_StatCapture_demo
//
// Purpose:
// This module contains a demo application for the Statistics Capture Control feature.
//
///////////////////////////////////////////////////////////////
module EPTF_StatCapture_demo {
import from EPTF_CLL_Variable_Functions all;
import from EPTF_CLL_StatMeasure_Functions all;
import from EPTF_CLL_Base_Functions all;
import from EPTF_CLL_StatCapture_Definitions all;
import from EPTF_CLL_StatCapture_Functions all;
import from EPTF_CLL_Common_Definitions all;
type component StatCapture_test_CT extends EPTF_StatCapture_CT {
var EPTF_StatCapture_CaptureGroups v_StatCapture_test_captureGroups := {};
var charstring v_StatCapture_test_selfName;
var boolean v_StatCapture_test_initialized := false;
}
//initializes my component
function f_init_StatCapture_test_CT(in charstring pl_selfName) runs on StatCapture_test_CT {
if (v_StatCapture_test_initialized) {
return; // already initialized
}
f_EPTF_StatCapture_init(pl_selfName);
v_StatCapture_test_initialized := true;
v_StatCapture_test_captureGroups := {};
v_StatCapture_test_selfName := pl_selfName;
log("----StatCapture INIT DONE----");
}
// Demo test case:
testcase tc_StatCapture_Demo() runs on StatCapture_test_CT {
f_init_StatCapture_test_CT("myStatCapture_Demo");
log("StatCapture_Demo");
var integer vl_var1ID, vl_var2ID:= -1; //we are going to have 2 Variables
var integer vl_stat1ID, vl_stat2ID, vl_stat3ID, vl_stat4ID := -1; //and 4 Statistics
f_EPTF_Var_newInt("var1", 10, vl_var1ID);
//f_EPTF_Var_adjustContent(vl_var1ID, {intVal:= 10}); not necessary
vl_stat1ID := f_EPTF_StatMeasure_newStat(vl_var1ID, content);
var EPTF_StatCapture_Statistics stat1 := f_EPTF_StatCapture_createStatforCapture(vl_stat1ID, "content"); //other two parameters are left on default values
vl_stat2ID := f_EPTF_StatMeasure_newStat(vl_var1ID, delta);
var EPTF_StatCapture_Statistics stat2 := f_EPTF_StatCapture_createStatforCapture(vl_stat2ID, "delta"); //other two parameters are left on default values
f_EPTF_Var_newFloat("var2", 10.0, vl_var2ID);
vl_stat3ID := f_EPTF_StatMeasure_newStat(vl_var2ID, deltaSum);
var EPTF_StatCapture_Statistics stat3 := f_EPTF_StatCapture_createStatforCapture(vl_stat3ID, "deltaSumReset", true);//periodicreset:=true,can be added only to 1 group
vl_stat4ID := f_EPTF_StatMeasure_newStat(vl_var2ID, EPS);
var EPTF_StatCapture_Statistics stat4 := f_EPTF_StatCapture_createStatforCapture(vl_stat4ID, "EPS"); //other two parameters are left on default values
var integer vl_stat5ID := f_EPTF_StatMeasure_newStat(vl_var1ID, mean);
var EPTF_StatCapture_Statistics stat5 := f_EPTF_StatCapture_createStatforCapture(vl_stat5ID, "mean with spaces in its name"); //other two parameters are left on default values
var integer v_groupidx1 := -1;
var integer v_groupidx2 := -1;
var integer v_groupstatidx11, v_groupstatidx12, v_groupstatidx21;
var EPTF_IntegerList group1statidxList, group2statidxList;
var integer fd1 := f_EPTF_StatCapture_openNewStatLogFile("FirstFile");
var integer fd2 := f_EPTF_StatCapture_openNewStatLogFile("SecondFile");
f_EPTF_StatCapture_addNewGroup("group1", 1.0,{fd1}, {stat1, stat2}, v_groupidx1, group1statidxList);
//f_EPTF_StatCapture_addListOfStatistics(v_groupidx1, {stat1, stat2}, group1statidxList);
f_EPTF_StatCapture_addNewGroup("group2", 1.0,{fd2}, {stat3, stat4}, v_groupidx2, group2statidxList);
//f_EPTF_StatCapture_addStatistics(v_groupidx2, stat3, v_groupstatidx21);
f_EPTF_StatCapture_startCaptureAll();
/*f_EPTF_StatMeasure_enableStat(vl_stat1ID);
f_EPTF_StatMeasure_enableStat(vl_stat2ID);
f_EPTF_StatMeasure_enableStat(vl_stat3ID); */ //not necessary, as default is enabled ==true
timer t_wait := 10.0;
t_wait.start;
timer t_adjust := 1.0;
t_adjust.start;
timer t_adjust2 := 2.0;
t_adjust2.start;
timer t_addStat := 3.5;
t_addStat.start;
var integer vl_now := 1;
alt {
[] t_adjust2.timeout{
f_EPTF_StatCapture_stopGroupCapture(v_groupidx1);
//f_EPTF_StatCapture_InactivateStatistics(v_groupidx1, group1statidxList[0]); //if inactivated, it prints only "-" instead
//f_EPTF_StatCapture_InactivateStatistics(v_groupidx1, group1statidxList[3]);
f_EPTF_StatCapture_setTimerPeriod(v_groupidx1, 2.0);
f_EPTF_StatCapture_startGroupCapture(v_groupidx1);
//t_adjust2.start;
repeat;
}
[] t_adjust.timeout{
f_EPTF_Var_adjustContent(vl_var1ID, {intVal:= vl_now});
f_EPTF_Var_adjustContent(vl_var2ID, {floatVal:= int2float(vl_now)});
vl_now := vl_now * 2;
t_adjust.start;
repeat;
}
[]t_addStat.timeout {
var integer vl_tmp := -1;
f_EPTF_StatCapture_addStatistics(v_groupidx2, stat5, vl_tmp);
group2statidxList[sizeof(group2statidxList)] := vl_tmp;
repeat;
}
[] t_wait.timeout {}
}
setverdict(pass);
f_EPTF_StatCapture_stopCaptureAll();
f_EPTF_Base_cleanup_CT();
}
} // end of module