blob: e6c00b07c76377270ccc0bf58a62b20adbd4c629 [file] [log] [blame]
///////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2000-2017 Ericsson Telecom AB
//
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// which accompanies this distribution, and is available at
// http://www.eclipse.org/legal/epl-v10.html
///////////////////////////////////////////////////////////////////////////////
// File: IOT_App_Functions.ttcn
// Description:
// Rev: R1A
// Prodnr: LPA 108 661
// Updated: 2017-09-01
// Contact: http://ttcn.ericsson.se
///////////////////////////////////////////////////////////////////////////////
module IOT_App_Functions
{
import from IOT_App_Definitions all;
import from IOT_LGen_Definitions all;
import from IOT_LGen_Functions all;
import from EPTF_CLL_Base_Functions all;
import from EPTF_CLL_ExecCtrl_Definitions all;
import from EPTF_CLL_ExecCtrl_Functions all;
import from EPTF_CLL_DsRestAPI_Functions all;
import from EPTF_CLL_DataSource_Definitions all;
import from EPTF_CLL_DataSource_Functions all;
modulepar integer tsp_nrOfLGens := 0;
modulepar charstring tsp_LGname_prefix := "IOT_LGen";
testcase TC() runs on IOT_App_CT
{
log(%definitionId,": Creating UI");
//f_EPTF_UIHandler_init_CT("IOT_App", false);
f_EPTF_DsRestAPI_init_CT("IOT_App");
log(%definitionId,": Creating ExecCtrl");
var EPTF_ExecCtrl_CT vc_ExtCtrl := EPTF_ExecCtrl_CT.create;
vc_ExtCtrl.start(f_IOT_App_startExecCtrl("ExecCtrl", tsp_nrOfLGens, self));
f_EPTF_DataSource_registerReadyCallback(refers(f_EPTF_ExecCtrl_Test_DataSourceClientReady));
log(%definitionId,": Creating LGens");
var IOT_LGen_CT vc_LG;
for (var integer i:=0; i<tsp_nrOfLGens; i:=i+1)
{
vc_LG := IOT_LGen_CT.create;
vc_LG.start(f_IOT_LGen_behavior(tsp_LGname_prefix & int2str(i), i, vc_ExtCtrl));
}
timer T_guard, T_alt;
T_alt.start( 0.0 );
T_guard.start( 15.0 );
// wait until ExecCtrl DataSource is registered
alt{
[] T_guard.timeout{
setverdict(fail,"Timeout during config");
f_EPTF_Base_stopAll();
}
[v_ready] T_alt.timeout{}
}
//action(" ExecCtrl ready, starting reading GUI.xml");
//f_EPTF_UIHandler_createGUIFromFile("gui.xml");
var integer vl_Ret := f_EPTF_DsRestAPI_start(
tsp_EPTF_DsRestAPI_HTTPServer_RemoteAddress,
tsp_EPTF_DsRestAPI_HTTPServer_RemotePort,
tsp_EPTF_DsRestAPI_HTTPServer_directory,
tsp_EPTF_DsRestAPI_customizableApp_directory,
tsp_EPTF_DsRestAPI_API_directory
);
/*
timer t;
t.start(tsp_testDuration);
log(%definitionId,": IOT_App: entering main EH...")
alt
{
[] t.timeout
{
log(%definitionId,": IOT_App: main EH: timeout...")
}
} // alt
f_EPTF_Base_cleanup_CT();
log(%definitionId,": finished")
*/
f_EPTF_Base_wait4Shutdown();
}
function f_IOT_App_startExecCtrl(
in charstring pl_selfName,
in integer pl_nrOfClients,
in EPTF_DataSource_CT pl_datasource)
runs on EPTF_ExecCtrl_CT
{
var EPTF_ExecCtrl_LGenFunction_Entry_List vl_functions :=
{
{ name := "RIoT.createLGen", fn := refers(f_IOT_LGen_create) }
}
f_EPTF_ExecCtrl_loadConfig(
pl_EPTF_ExecCtrl_LGenFunction_Entry_List := vl_functions
);
f_EPTF_ExecCtrl_init_CT(pl_selfName, pl_nrOfClients, pl_dataSource_compRef := pl_datasource);
f_EPTF_Base_wait4Shutdown();
}
function f_IOT_LGen_create
(
in charstring pl_hostname,
in charstring pl_componentName
)
runs on EPTF_ExecCtrl_CT
return EPTF_ExecCtrlClient_CT
{
// Create LGen instance
var IOT_LGen_CT vc_lgen := IOT_LGen_CT.create(pl_hostname);
// Connect and Start the LGen
vc_lgen.start(f_IOT_LGen_behavior(tsp_LGname_prefix & pl_componentName, 0, self));
return vc_lgen;
}
function f_EPTF_ExecCtrl_Test_DataSourceClientReady(
in charstring pl_source,
in charstring pl_ptcName)
runs on IOT_App_CT
{
if (pl_source==c_ExecCtrl_DataSource_sourceId)
{
v_ready := true;
}
}
}