blob: 096abb325116731ad8ab50a6207603a507e4c7d1 [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 v2.0 //
// which accompanies this distribution, and is available at //
// https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html //
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// Module: MainModule
//
// Purpose:
// Example MainModule for EPTF Central Scheduling demo
//
// Module Parameters:
// tsp_use_RuntimeGUI
// tsp_use_LoggingUI
// tsp_nof_A_CS_Admins
// tsp_nof_B_CS_Admins
// tsp_CS_Admin_A_HostList
// tsp_CS_Admin_B_HostList
// tsp_demoInterval
// tsp_useLoadBalancing_A
// tsp_useLoadBalancing_B
//
// Module depends on:
// <EPTF_CLL_Common_Definitions>
// <EPTF_CLL_Base_Functions>
// <EPTF_CLL_ExecCtrlUIHandler_Definitions>
// <EPTF_CLL_ExecCtrlUIHandler_Functions>
// <EPTF_CLL_ExecCtrl_Functions>
// <LoadRegulator_Definitions>
// <LoadRegulator_Functions>
// <EPTF_CLL_UIHandler_Definitions>
// <EPTF_CLL_UIHandler_WidgetFunctions>
// <XTDPasp_Types>
// <XTDPasp_PortType>
// <XTDP_PDU_Defs>
// <EPTF_CLL_UIHandler_XTDPTemplateDefinitions>
// <EPTF_CLL_CS_Definitions>
// <EPTF_CLL_CSAdmin_Functions>
// <Common_Definitions>
// <CS_A_Definitions>
// <CS_B_Definitions>
// <CS_A_Functions>
// <CS_B_Functions>
// <EPTF_CLL_LoggingUI_Definitions>
// <EPTF_CLL_LoggingUI_Functions>
//
// Current Owner:
// Gabor Tatarka (egbotat)
//
// Last Review Date:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
module MainModule
{
//=========================================================================
// Import Part
//=========================================================================
import from EPTF_CLL_Common_Definitions all;
import from EPTF_CLL_Base_Functions all;
// Execution Control defs and behavior
import from EPTF_CLL_ExecCtrlUIHandler_Definitions all;
import from EPTF_CLL_ExecCtrlUIHandler_Functions all;
import from EPTF_CLL_ExecCtrl_Functions all;
// Load Regulator
import from LoadRegulator_Definitions all;
import from LoadRegulator_Functions all;
import from EPTF_CLL_UIHandler_Definitions all;
import from EPTF_CLL_UIHandler_WidgetFunctions all;
import from XTDPasp_Types all;
import from XTDPasp_PortType all;
import from XTDP_PDU_Defs all;
import from EPTF_CLL_UIHandler_XTDPTemplateDefinitions all;
import from EPTF_CLL_UIHandler_XULFunctions all;
// Central scheduling behavior
import from EPTF_CLL_CS_Definitions all;
import from EPTF_CLL_CSAdmin_Functions all;
// Central scheduling protocol dependent defs and behavior
import from Common_Definitions all;
import from CS_A_Definitions all;
import from CS_B_Definitions all;
import from CS_A_Functions all;
import from CS_B_Functions all;
//LoggingUI
import from EPTF_CLL_LoggingUI_Definitions all;
import from EPTF_CLL_LoggingUI_Functions all;
//=========================================================================
// Module Parameters
//=========================================================================
modulepar boolean tsp_use_RuntimeGUI := true; // Set it to false for GUI-less operation
modulepar boolean tsp_use_LoggingUI := true;
//modulepar boolean tsp_use_HostAdmins := true;
//modulepar boolean tsp_use_LoadRegulator := true;
modulepar integer tsp_nof_A_CS_Admins := 1; // set to 0 to disable Stack A
modulepar integer tsp_nof_B_CS_Admins := 1; // set to 0 to disable Stack B
modulepar EPTF_CharstringList tsp_CS_Admin_A_HostList := {}
modulepar EPTF_CharstringList tsp_CS_Admin_B_HostList := {}
modulepar float tsp_demoInterval := 60.0; // Max running time
modulepar boolean tsp_useLoadBalancing_A := false;
modulepar boolean tsp_useLoadBalancing_B := false;
//=========================================================================
// Data Types
//=========================================================================
// Insert data type defintions here if applicable!
// You can use the data_type skeleton!
//=========================================================================
// Signatures
//=========================================================================
// Insert signature definitions here if applicable!
// You can use the signature skeleton!
//=========================================================================
//Port Types
//=========================================================================
// Insert port type defintions here if applicable!
// You can use the port_type skeleton!
//=========================================================================
//Component Types
//=========================================================================
type component demo_CT extends EPTF_UIHandler_CT, EPTF_LoggingUI_CT
{
}
type component System_CT { port XTDPasp_PT EPTF_guiPortIf;}
//=========================================================================
// Constants
//=========================================================================
// Insert constants here if applicable!
// You can use the constant skeleton!
//=========================================================================
// Templates
//=========================================================================
// Insert templates here if applicable!
// You can use the template skeleton!
//=========================================================================
// Altsteps
//=========================================================================
// Insert altsteps here if applicable!
// You can use the altstep skeleton!
//=========================================================================
// Functions
//=========================================================================
// Insert functions here if applicable!
// You can use the function skeleton!
//=========================================================================
// Testcases
//=========================================================================
testcase tc_mainTestcase() runs on demo_CT system System_CT
{
timer T_watchdog := tsp_demoInterval;
var LoadRegulator_CT v_LoadRegulator;
var EPTF_ExecCtrl_UIHandler_CT v_CS_ExecCtrl;
var CS_ApplAdmin_A_CT v_CS_Admin_A;
var CS_ApplAdmin_B_CT v_CS_Admin_B;
//f_EPTF_Base_init_CT("MTC");
if(tsp_use_RuntimeGUI) {
f_EPTF_UIHandler_init_CT("MTC", true);
f_EPTF_UIHandler_clearGUI();
f_EPTF_UIHandler_addWindow();
f_CS_Demo_initGui();
}
// Start CS execution control
if(tsp_nof_A_CS_Admins < 0 or tsp_nof_B_CS_Admins < 0) {
log(%definitionId& ": ERROR: tsp_nof_A_CS_Admins or tsp_nof_B_CS_Admins is lower than 0");
f_EPTF_Base_stop();
}
var integer vl_nof_CS_Admins := tsp_nof_A_CS_Admins + tsp_nof_B_CS_Admins;
if(vl_nof_CS_Admins == 0) {
log(%definitionId& ": number of configured Central Sceduling Admins is 0");
f_EPTF_Base_stop();
}
if(sizeof(tsp_CS_Admin_A_HostList) > 0) {
v_CS_ExecCtrl := EPTF_ExecCtrl_UIHandler_CT.create("ExecCtrl("&tsp_CS_Admin_A_HostList[0]&")", tsp_CS_Admin_A_HostList[0]);
} else {
v_CS_ExecCtrl := EPTF_ExecCtrl_UIHandler_CT.create("ExecCtrl");
}
if(tsp_use_RuntimeGUI) {
if(tsp_use_LoggingUI) {
f_EPTF_LoggingUI_init_CT("MTC", self, tsp_EPTF_GUI_Main_Tabbox_WidgetId);
v_CS_ExecCtrl.start(f_EPTF_ExecCtrl_UIHandler_behavior("ExecCtrl",
vl_nof_CS_Admins, mtc, tsp_EPTF_GUI_Main_Tabbox_WidgetId, mtc));
} else {
v_CS_ExecCtrl.start(f_EPTF_ExecCtrl_UIHandler_behavior("ExecCtrl",
vl_nof_CS_Admins, mtc, tsp_EPTF_GUI_Main_Tabbox_WidgetId));
}
} else {
v_CS_ExecCtrl.start(f_EPTF_ExecCtrl_behavior("ExecCtrl",
vl_nof_CS_Admins));
}
// Load Regulator
for(var integer i := 0; i < sizeof(tsp_LoadRegulators); i := i + 1) {
if(tsp_LoadRegulators[i].host == "") {
v_LoadRegulator := LoadRegulator_CT.create(tsp_LoadRegulators[i].name);
} else {
v_LoadRegulator := LoadRegulator_CT.create(tsp_LoadRegulators[i].name,
tsp_LoadRegulators[i].host);
}
v_LoadRegulator.start(f_LoadRegulator_behavior(tsp_LoadRegulators[i].name,
v_CS_ExecCtrl, tsp_LoadRegulators[i].loadToReach));
}
// Start admin component(s) for protocol "A"
for(var integer i := 0; i < tsp_nof_A_CS_Admins; i := i + 1) {
if(sizeof(tsp_CS_Admin_A_HostList) == 0) {
v_CS_Admin_A := CS_ApplAdmin_A_CT.create;
} else {
v_CS_Admin_A := CS_ApplAdmin_A_CT.create("CS_Admin_A."& int2str(i)&"("&tsp_CS_Admin_A_HostList[0]&")",
tsp_CS_Admin_A_HostList[i mod sizeof(tsp_CS_Admin_A_HostList)]);
}
if(tsp_use_RuntimeGUI) {
if(tsp_use_LoggingUI) {
v_CS_Admin_A.start(f_CS_A_ApplAdminUIBehavior("CS_Admin_A." & int2str(i), i, v_CS_ExecCtrl, mtc, tsp_useLoadBalancing_A, mtc));
} else {
v_CS_Admin_A.start(f_CS_A_ApplAdminUIBehavior("CS_Admin_A." & int2str(i), i, v_CS_ExecCtrl, mtc, tsp_useLoadBalancing_A));
}
} else {
v_CS_Admin_A.start(f_CS_A_ApplAdminBehavior("CS_Admin_A." & int2str(i), i, v_CS_ExecCtrl, tsp_useLoadBalancing_A));
}
}
// Start admin component(s) for protocol "B"
for(var integer i := 0; i < tsp_nof_B_CS_Admins; i := i + 1) {
if(sizeof(tsp_CS_Admin_B_HostList) == 0) {
v_CS_Admin_B := CS_ApplAdmin_B_CT.create;
} else {
v_CS_Admin_B := CS_ApplAdmin_B_CT.create("CS_Admin_B."& int2str(i)&"("&tsp_CS_Admin_B_HostList[i mod sizeof(tsp_CS_Admin_B_HostList)]&")", tsp_CS_Admin_B_HostList[i mod sizeof(tsp_CS_Admin_B_HostList)]);
}
if(tsp_use_RuntimeGUI) {
if(tsp_use_LoggingUI) {
v_CS_Admin_B.start(f_CS_B_ApplAdminUIBehavior("CS_Admin_B." & int2str(i), i, v_CS_ExecCtrl, mtc, tsp_useLoadBalancing_B, mtc));
} else {
v_CS_Admin_B.start(f_CS_B_ApplAdminUIBehavior("CS_Admin_B." & int2str(i), i, v_CS_ExecCtrl, mtc, tsp_useLoadBalancing_B));
}
} else {
v_CS_Admin_B.start(f_CS_B_ApplAdminBehavior("CS_Admin_B." & int2str(i), i, v_CS_ExecCtrl, tsp_useLoadBalancing_B));
}
}
// Wait for execution finish
T_watchdog.start;
alt {
[] any component.done { setverdict(fail); }
[] T_watchdog.timeout { setverdict(pass); }
// [] as_EPTF_UIHandler_exitButtonPressed() { }
}
f_EPTF_Base_cleanup_CT();
}
function f_CS_Demo_initGui() runs on EPTF_UIHandler_CT{
var XTDP_XML_Tag mainWindow := {
xtdp_tabpanel := {
id := omit,
maxheight := omit,
orient := "vertical",
widgets := {
{
hbox := {
id := omit,
flex := omit,
disabled := omit,
orient := "horizontal",
widgets := {
{
hbox := {
id := omit,
flex := omit,
disabled := omit,
orient := "vertical",
widgets := {
{
tabbox := {
id := tsp_EPTF_GUI_Main_Tabbox_WidgetId,
flex := omit,
disabled := omit,
layout := omit,
tabs := {
/* {
id := "Execution_Control.tab2",
tablabel := "USER Execution Control"
}*/
},
tabpanels := {
}
}
}
}
}
}
}
}
}
}
}
};
var boolean widgetExist := false;
// log("mainWindow: ", mainWindow);
f_EPTF_UIHandler_addElementToGui(
mainWindow,
"",
widgetExist);
}
//=========================================================================
// Control
//=========================================================================
control
{
execute(tc_mainTestcase());
}
} // end of module