blob: 3579963393a51393f0e3f016b2d737cc0ec908cf [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_StatCaptureControl_demo
//
// Purpose:
// This module contains a demo application for the Statistics Capture Control feature.
//
///////////////////////////////////////////////////////////////
module EPTF_StatCaptureControl_demo {
import from EPTF_CLL_StatCaptureControl_Definitions all;
import from EPTF_CLL_StatCaptureControl_Functions all;
import from EPTF_CLL_StatCapture_Functions all;
import from EPTF_CLL_Base_Definitions all;
import from EPTF_CLL_Base_Functions all;
import from EPTF_CLL_Variable_Definitions all;
import from EPTF_CLL_Variable_Functions all;
import from EPTF_CLL_NameService_Definitions all;
import from EPTF_CLL_NameService_Functions all
import from EPTF_CLL_NameServiceClient_Functions all;
modulepar float tsp_StatCaptureControl_demo_user_modify_timer := 10.0;
modulepar float tsp_StatCaptureControl_demo_load_modify_timer := 10.0;
modulepar float tsp_StatCaptureControl_demo_execution_start_timer := 1.0;
modulepar float tsp_StatCaptureControl_demo_execution_stop_timer := 99.0; //relative time from execution start
type component mtc_test_CT extends EPTF_Base_CT {
var boolean v_mtc_test_initialized := false;
}
type component NS_test_CT extends EPTF_NS_CT {
var boolean v_NS_test_initialized := false;
}
type component StatCaptureControl_test_CT extends EPTF_StatCaptureControl_CT, EPTF_NS_Client_CT {
var boolean v_StatCaptureControl_test_initialized := false;
}
type component User_test_CT extends EPTF_Var_CT, EPTF_NS_Client_CT {
var boolean v_User_test_initialized := false;
}
type component Load_test_CT extends EPTF_Var_CT, EPTF_NS_Client_CT {
var boolean v_Load_test_initialized := false;
}
type component Execution_test_CT extends EPTF_Var_CT, EPTF_NS_Client_CT {
var boolean v_Execution_test_initialized := false;
}
function f_init_mtc_test_CT(in charstring pl_selfName) runs on mtc_test_CT {
if (v_mtc_test_initialized) {
return; // already initialized
}
f_EPTF_Base_init_CT(pl_selfName);
v_mtc_test_initialized := true;
log("----mtc test INIT DONE----");
}
function f_init_StatCaptureControl_test_CT(in charstring pl_selfName, in EPTF_NS_CT pl_NSCompRef) runs on StatCaptureControl_test_CT {
if (v_StatCaptureControl_test_initialized) {
return; // already initialized
}
//f_EPTF_StatCaptureControl_init(pl_selfName, pl_NSCompRef, false); //for programmed mode
f_EPTF_StatCaptureControl_init(pl_selfName, pl_NSCompRef);
v_StatCaptureControl_test_initialized := true;
log("----StatCaptureControl test INIT DONE----");
}
function f_init_User_test_CT(in charstring pl_selfName, in EPTF_NS_CT pl_NSCompRef) runs on User_test_CT {
if (v_User_test_initialized) {
return; // already initialized
}
f_EPTF_Var_init_CT(pl_selfName);
f_EPTF_NS_Client_init_CT(pl_selfName, pl_NSCompRef);
v_User_test_initialized := true;
log("----User test INIT DONE----");
}
function f_init_Load_test_CT(in charstring pl_selfName, in EPTF_NS_CT pl_NSCompRef) runs on Load_test_CT {
if (v_Load_test_initialized) {
return; // already initialized
}
f_EPTF_Var_init_CT(pl_selfName);
f_EPTF_NS_Client_init_CT(pl_selfName, pl_NSCompRef);
v_Load_test_initialized := true;
log("----Load test INIT DONE----");
}
function f_init_Execution_test_CT(in charstring pl_selfName, in EPTF_NS_CT pl_NSCompRef) runs on Execution_test_CT {
if (v_Execution_test_initialized) {
return; // already initialized
}
f_EPTF_Var_init_CT(pl_selfName);
f_EPTF_NS_Client_init_CT(pl_selfName, pl_NSCompRef);
v_Execution_test_initialized := true;
log("----Execution test INIT DONE----");
}
function f_EPTF_mtc_test_Behaviour_1(in charstring pl_selfName) runs on mtc_test_CT {
f_init_mtc_test_CT(pl_selfName);
var NS_test_CT vl_NS_Server := NS_test_CT.create;
vl_NS_Server.start(f_EPTF_NS_main_CT("NameServiceServer")); //starts the behaviour of the NS server
var User_test_CT vl_User_test := User_test_CT.create;
vl_User_test.start(f_EPTF_User_test_Behaviour_1("User", vl_NS_Server));
var Load_test_CT vl_Load_test := Load_test_CT.create;
vl_Load_test.start(f_EPTF_Load_test_Behaviour_1("Load", vl_NS_Server));
var Execution_test_CT vl_Execution_test := Execution_test_CT.create;
vl_Execution_test.start(f_EPTF_Execution_test_Behaviour_1("Execution", vl_NS_Server));
var StatCaptureControl_test_CT vl_StatCaptureControl_test := StatCaptureControl_test_CT.create;
vl_StatCaptureControl_test.start(f_EPTF_StatCaptureControl_test_Behaviour_1("StatCaptureControl", vl_NS_Server)); //automatic capture control modes
//vl_StatCaptureControl_test.start(f_EPTF_StatCaptureControl_test_Behaviour_2("StatCaptureControl", vl_NS_Server)); //programmed mode
}
function f_EPTF_StatCaptureControl_test_Behaviour_1(in charstring pl_selfName, in EPTF_NS_CT pl_NSCompRef) runs on StatCaptureControl_test_CT {
f_init_StatCaptureControl_test_CT(pl_selfName,pl_NSCompRef);
f_EPTF_NS_RegisterName(pl_selfName);
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 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_parseConfigGroup(); //this function should be called after local variables are available (created or subscribed for)
// this case, the programmed creation of statistics and capture groups is not necessary.
timer t_adjuststats := 10.0;
t_adjuststats.start;
var integer vl_now := 1;
alt {
[] t_adjuststats.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_adjuststats.start;
repeat;
}
}
f_EPTF_Base_cleanup_CT();
}
// demo behaviour for programmed mode
// the StatCaptureControl Component init function should be called with 3rd parameter set to "false" for programmed mode
function f_EPTF_StatCaptureControl_test_Behaviour_2(in charstring pl_selfName, in EPTF_NS_CT pl_NSCompRef) runs on StatCaptureControl_test_CT {
f_init_StatCaptureControl_test_CT(pl_selfName,pl_NSCompRef);
f_EPTF_NS_RegisterName(pl_selfName);
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 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_parseConfigGroup();
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;
var integer vl_now := 1;
alt {
[] 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_wait.timeout {}
}
setverdict(pass);
f_EPTF_StatCapture_stopCaptureAll();
f_EPTF_Base_cleanup_CT();
}
function f_EPTF_User_test_Behaviour_1(in charstring pl_selfName, in EPTF_NS_CT pl_NSCompRef) runs on User_test_CT {
f_init_User_test_CT(pl_selfName, pl_NSCompRef);
f_EPTF_NS_RegisterName(pl_selfName);
var integer vl_varID;
f_EPTF_Var_newBool("UserVar", false, vl_varID);
timer t_user_modify := tsp_StatCaptureControl_demo_user_modify_timer;
t_user_modify.start;
alt {
[] t_user_modify.timeout {
var EPTF_Var_DirectContent vl_currentValue;
f_EPTF_Var_getContent(vl_varID, vl_currentValue);
f_EPTF_Var_adjustContent(vl_varID, {boolVal := not vl_currentValue.boolVal}); //user button pressed
t_user_modify.start;
repeat;
}
}
f_EPTF_Base_cleanup_CT();
}
function f_EPTF_Load_test_Behaviour_1(in charstring pl_selfName, in EPTF_NS_CT pl_NSCompRef) runs on Load_test_CT {
f_init_Load_test_CT(pl_selfName, pl_NSCompRef);
f_EPTF_NS_RegisterName(pl_selfName);
var integer vl_varID;
f_EPTF_Var_newBool("LoadVar", false, vl_varID);
timer t_loadstable_modify := tsp_StatCaptureControl_demo_load_modify_timer;
t_loadstable_modify.start;
alt {
[] t_loadstable_modify.timeout {
var EPTF_Var_DirectContent vl_currentValue;
f_EPTF_Var_getContent(vl_varID, vl_currentValue);
f_EPTF_Var_adjustContent(vl_varID, {boolVal := not vl_currentValue.boolVal}); //load stable state changed
t_loadstable_modify.start;
repeat;
}
}
f_EPTF_Base_cleanup_CT();
}
function f_EPTF_Execution_test_Behaviour_1(in charstring pl_selfName, in EPTF_NS_CT pl_NSCompRef) runs on Execution_test_CT {
f_init_Execution_test_CT(pl_selfName,pl_NSCompRef);
f_EPTF_NS_RegisterName(pl_selfName);
var integer vl_varID;
f_EPTF_Var_newBool("ExecutionVar", false, vl_varID);
timer t_execution_start := tsp_StatCaptureControl_demo_execution_start_timer;
t_execution_start.start;
timer t_execution_stop := tsp_StatCaptureControl_demo_execution_start_timer + tsp_StatCaptureControl_demo_execution_stop_timer;
t_execution_stop.start;
alt {
[] t_execution_start.timeout {
f_EPTF_Var_adjustContent(vl_varID, {boolVal := true});
repeat;
}
[] t_execution_stop.timeout {
f_EPTF_Var_adjustContent(vl_varID, {boolVal := false});
}
}
timer t_delay;
t_delay.start(1.0);
t_delay.timeout;
f_EPTF_Base_stopRemote(mtc);
}
// Demo test case:
testcase tc_StatCaptureControl_Demo_Manual() runs on mtc_test_CT {
//var mtc_test_CT vl_mtc_test := mtc_test_CT.create;
f_EPTF_mtc_test_Behaviour_1("StatCaptureControlDemo");
log("StatCaptureControlDemo started");
setverdict(pass);
all component.done;
f_EPTF_Base_cleanup_CT();
}
} // end of module