blob: 3836860a85ae2dd1c2e6facab657fef2d8d1822f [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_Base_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;
import from EPTF_CLL_Common_Definitions all; // EPTF_IntegerList
type component All_CT extends EPTF_Var_CT, EPTF_NS_CT, EPTF_NS_Client_CT {
var boolean v_All_initialized := false;
}
// mandatory functions for A_CT:
function f_All_init_CT(in charstring pl_selfName /* your additional input parameters */) runs on All_CT {
if (v_All_initialized) {
return;
}
// call all the init functions of the components that your component extends _explicitly_:
f_EPTF_Var_init_CT(pl_selfName /*additional parameters*/);
f_EPTF_NS_init_CT(pl_selfName /*additional parameters*/);
f_EPTF_NS_Client_init_CT(pl_selfName, self /*additional parameters*/);
// initialize your component variables here...
v_All_initialized := true;
// register your cleanup function:
f_EPTF_Base_registerCleanup(refers(f_All_cleanup_CT));
log("----All INIT DONE----");
}
function f_All_cleanup_CT() runs on All_CT {
if (v_All_initialized == false) {
return;
}
// reset your variables here if needed...
v_All_initialized := false;
log("----All CLEANUP DONE----");
// additional cleanup functions can be called here, but better if you do not call them. Register them instead.
}
function f_adjustHandler(in integer pl_idx, in EPTF_Var_DirectContent pl_content,in boolean pl_result, in EPTF_IntegerList pl_argList) runs on All_CT {
log("Adjust of variable ",pl_idx," to content: ",pl_content, " succeeded: ", pl_result);
log("Adjust handler args: ", pl_argList);
}
function f_All_Behaviour(in charstring pl_selfName) runs on All_CT {
f_All_init_CT(pl_selfName);
// register my name into the NS server
f_EPTF_NS_RegisterName(f_EPTF_Base_selfName());
// get my compRef by querying my name from the NS server:
var EPTF_Var_CT /*All_CT*/ v_selfComp;
var EPTF_NS_QueryResp v_QueryResp;
f_EPTF_NS_Query(f_EPTF_Base_selfName(),v_QueryResp);
// cast is needed from EPTF_NS_Client_CT->All_CT:
v_selfComp := f_EPTF_Var_downcast(f_EPTF_NS_Client_upcast(v_QueryResp.ownerComp));
log("v_QueryResp.ownerComp: ", v_QueryResp.ownerComp);
log("v_selfComp: ", v_selfComp);
//v_selfComp := self;
// create an integer EPTF variable
var integer vl_intVarIdx;
f_EPTF_Var_newInt("intVar",0,vl_intVarIdx);
// subscribe for my eptf variable remotely in non-buffered mode, using auto name generation:
var integer vl_intVarSubscIdx;
f_EPTF_Var_subscribeRemote(v_selfComp,"intVar",realtime,vl_intVarSubscIdx);
// subscribe for my subscriber eptf variable remotely in buffered mode, using auto name generation:
var integer vl_intVarSubscBuffIdx;
f_EPTF_Var_subscribeRemote(v_selfComp,f_EPTF_Base_selfName() & ".intVar",timeLine,vl_intVarSubscBuffIdx);
f_EPTF_Var_CT_LogAll("---- f_All_Behaviour:subscribe done ----");
// adjust my non-buffered subscriber variable:
f_EPTF_Var_adjustContent(vl_intVarIdx, {intVal := 1},{refers(f_adjustHandler),{0}});
f_EPTF_Var_CT_LogAll("---- f_All_Behaviour:adjustContentWithHandler 0 called ----");
// adjust remote my non-buffered subscriber variable:
f_EPTF_Var_adjustRemoteContent_Blocking(v_selfComp,f_EPTF_Base_selfName() & ".intVar", {intVal := 2});
f_EPTF_Var_CT_LogAll("---- f_All_Behaviour:adjustRemote-nonbuffered done ----");
// wait for sync message:
timer t_wait := 11.0; // > t_sync
t_wait.start;
alt {
[] t_wait.timeout {}
}
var EPTF_Var_DirectContent vl_newValue;
// get my buffered subscribed variable's value:
f_EPTF_Var_getContent(vl_intVarSubscBuffIdx, vl_newValue);
if (vl_newValue != {intVal := 2}) {
setverdict(fail, "Value of the variable should be {intVal := 2}, but it is: ", vl_newValue);
}
f_EPTF_Var_CT_LogAll("---- f_All_Behaviour:DONE ----");
f_EPTF_Base_cleanup_CT();
}
testcase tc_EPTF_Base_all() runs on All_CT {
f_All_Behaviour("All Test");
setverdict(pass);
}
} // end of module