blob: 5c58dfaa1a5c6e40933f01a61092ad8a1b8be815 [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_UIHandler_WidgetFunctions
//
// Purpose:
// This module contains widget manipulation functions of EPTF_UIHandler_CT.
//
// Module Parameters:
// charstring tsp_EPTF_GUI_Main_Window_WidgetId := "EPTF_Main_Window"; used in
// <f_EPTF_UIHandler_addWindow> creating a new window
// charstring tsp_EPTF_GUI_Main_Toolbar_WidgetId := "EPTF_Main_Toolbar";
// float tsp_EPTF_GUI_Main_Window_Width := 820.0; used in
// <f_EPTF_UIHandler_addWindow> creating a new window
// float tsp_EPTF_GUI_Main_Window_Height := 386.0; used in
// <f_EPTF_UIHandler_addWindow> creating a new window
// charstring tsp_EPTF_GUI_Main_Window_Title := "TTCN constructed window"; used in
// <f_EPTF_UIHandler_addWindow> creating a new window
// charstring tsp_xtdp_listen_addr := "127.0.0.1";
// integer tsp_xtdp_listen_port := 11420;
// charstring tsp_EPTF_savedGUIPrefix := "GUI"; used to create a snapshot
// config file about the GUI
// charstring tsp_EPTF_GUI_DefaultWindow := ""; If it isn't empty, the
// EPTF_UIHandler_CT tries to create a window by this string. It
// can be created by the <f_EPTF_UIHandler_snapshot> and
// <f_EPTF_UIHandler_saveLayout> functions.
// charstring tsp_EPTF_UIHandler_Authmsg := "Enter password" This is the question
// for XTDP authentication that the user of the RuntimeGUI has to answer.
// If it is empty, no authentication performed
// charstring tsp_EPTF_UIHandler_Authresp := ""; This is the expected
// answer for the question <tsp_EPTF_UIHandler_Authmsg> during XTDP
// authentication. If the answer given on RuntimeGUI does not match this
// parameter, the authentication fails and XTDP session will be closed.
// UIHander will enter into headless mode.
// If it is empty, no authentication performed
// float tsp_EPTF_UIHandler_handshakeMaxTimer := 1.0; This is the max handshake
// time for the XDTP protocol. The handshake response should arrive less than
// this time. (See the XTDP protocol module FS for more details)
// float tsp_EPTF_UIHandler_authMaxTimer := 1.0; This is the max authentication time.
// for the XDTP protocol. The authentication response should arrive less than
// this time. (See the XTDP protocol module FS for more details)
// float tsp_EPTF_UIHandler_byeMaxTimer := 1.0; This is the max bye time.
// for the XDTP protocol. The bye response should arrive less than
// this time. (See the XTDP protocol module FS for more details)
// float tsp_EPTF_UIHandler_maxGUIWaitTime := 30.0; The max wait time in the
// init function of the UIhandler (<f_EPTF_UIHandler_init_CT>) to wait
// until Runtime GUI is connected.
//
// Module depends on:
// <XTDPasp_Types>
// <XTDP_PDU_Defs>
// <XUL_XTDL language>
// <EPTF_CLL_UIHandler_MsgDefinitions>
// <EPTF_CLL_UIHandler_Definitions>
// <EPTF_CLL_UIHandler_PrivateFunctions>
// <EPTF_CLL_Base_Definitions>
// <EPTF_CLL_Base_Functions>
// <EPTF_CLL_UIHandler_XTDPTemplateDefinitions>
// <EPTF_CLL_Variable_Definitions>
// <EPTF_CLL_Variable_Functions>
// <EPTF_CLL_UIHandler_ConvertFunctions>
// <EPTF_CLL_Common_Definitions>
// <EPTF_CLL_HashMapStr2Int_Functions>
// <EPTF_CLL_HashMapInt2Int_Functions>
// <EPTF_CLL_Logging_Definitions>
// <EPTF_CLL_Logging_Functions>
// <TCCFileIO_Functions>
// <TCCDateTime_Functions>
// <EPTF_CLL_TransportIPL4_Functions>
// <EPTF_CLL_Transport_CommonDefinitions>
// <EPTF_CLL_Semaphore_Functions>
// <EPTF_CLL_UIHandler_CLIClientDefinitions>
// <EPTF_CLL_UIHandlerCLI_CommandDefinitions>
// <EPTF_CLL_CLI_Functions>
// <EPTF_CLL_CLI_Definitions>
// <Socket_API_Definitions>
// <EPTF_CLL_HashMap_Functions>
//
// Current Owner:
// EFLOATT
//
// Last Review Date:
// 2010-xx-xx
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////////
module EPTF_CLL_UIHandler_WidgetFunctions
// [.objid{ itu_t(0) identified_organization(4) etsi(0)
// identified_organization(127) ericsson(5) testing(0)
// <put further nodes here if needed>}]
{
//=========================================================================
// Import Part
//=========================================================================
import from EPTF_CLL_UIHandler_MsgDefinitions all;
import from EPTF_CLL_UIHandler_Definitions all;
import from EPTF_CLL_Base_Functions all;
import from EPTF_CLL_UIHandler_XSD_XTDPTemplateDefinitions all;
import from EPTF_CLL_Variable_Definitions all;
import from EPTF_CLL_Variable_Functions all;
import from EPTF_CLL_UIHandler_ConvertFunctions all;
import from EPTF_CLL_Common_Definitions all;
import from EPTF_CLL_Common_Functions all;
import from EPTF_CLL_HashMapStr2Int_Functions all;
import from EPTF_CLL_HashMapInt2Int_Functions all;
import from EPTF_CLL_Logging_Definitions all;
import from EPTF_CLL_Logging_Functions all;
import from TCCFileIO_Functions all;
import from TCCDateTime_Functions all;
import from TCCConversion_Functions all;
import from EPTF_CLL_TransportIPL4_Functions all;
import from EPTF_CLL_Transport_CommonDefinitions all;
import from EPTF_CLL_TransportMessageBufferManager_Functions all;
import from EPTF_CLL_Semaphore_Functions all;
import from EPTF_CLL_UIHandler_CLIClientDefinitions all;
import from EPTF_CLL_CLI_Functions all;
import from EPTF_CLL_CLI_Definitions all;
import from Socket_API_Definitions all
import from XTDP_EncDecFunctions all;
import from ttcn_ericsson_se_protocolModules_xtdp_xtdl all;
import from ttcn_ericsson_se_protocolModules_xtdp_xtdp all;
import from EPTF_CLL_DataSource_Definitions all;
import from EPTF_CLL_DataSource_Functions all;
import from EPTF_CLL_UIHandler_DS_Definitions all;
import from EPTF_CLL_UIHandler_DS_Functions all;
import from EPTF_CLL_DataSourceClient_Functions all;
import from EPTF_CLL_HashMap_Functions all;
import from EPTF_CLL_StatManager_Functions all;
import from EPTF_CLL_UIHandler_BrowserFunctions all;
import from EPTF_CLL_UIHandler_ChartDataTypeRingBuffer_Functions all;
//=========================================================================
// Module Parameters
//=========================================================================
modulepar {
charstring tsp_EPTF_GUI_Main_Window_WidgetId := "EPTF_Main_Window";
charstring tsp_EPTF_GUI_Main_Toolbar_WidgetId := "EPTF_Main_Toolbar";
charstring tsp_EPTF_GUI_Main_Tabbox_WidgetId := "EPTF_Main_Tabbox";
float tsp_EPTF_GUI_Main_Window_Width := 820.0;
float tsp_EPTF_GUI_Main_Window_Height := 386.0;
charstring tsp_EPTF_GUI_Main_Window_Title := "TTCN constructed window";
charstring tsp_xtdp_listen_addr := "127.0.0.1";
integer tsp_xtdp_listen_port := 11420;
integer tsp_EPTF_UIHandler_udp_port := 3333; // remote port number for pinger port
charstring tsp_EPTF_UIHandler_localPingerAddr := c_ipv4AnyAddr;
integer tsp_EPTF_UIHandler_localPingerPort := c_anyPort; // 0-> let the kernel choose a local port number automatically
charstring tsp_EPTF_savedGUIPrefix := "GUI";
charstring tsp_EPTF_GUI_DefaultWindow := ""; // OUTDATED, remove it from any config
charstring tsp_EPTF_GUI_DefaultWindowXTDL := "";
boolean tsp_EPTF_UIHandler_headlessmode := true;
boolean tsp_EPTF_UIHandler_servermode := false;
charstring tsp_EPTF_UIHandler_Authmsg := "Enter password";
charstring tsp_EPTF_UIHandler_Authresp := "";
float tsp_EPTF_UIHandler_handshakeMaxTimer := 1.0;
float tsp_EPTF_UIHandler_authMaxTimer := 1.0;
float tsp_EPTF_UIHandler_byeMaxTimer := 1.0;
float tsp_EPTF_UIHandler_bufferedXTDP := 0.5;
float tsp_EPTF_UIHandler_connecttimer := 5.0;
float tsp_EPTF_UIHandler_maxWaitTimer := 5.0;
integer tsp_EPTF_UIHandler_CommPortIPL4_minBufferSize := 2000;
boolean tsp_debug_EPTF_UIHandler_Functions := false;
float tsp_EPTF_UIHandler_maxGUIWaitTime := 30.0;
boolean tsp_EPTF_UIHandler_enableBrowserGUI := true;
EPTF_Var_SubscriptionMode tsp_EPTF_UIHandler_subscriptionMode := sampled; // sampled is the default for tsp_EPTF_DataSource_subscriptionMode, with pull widgets on RuntimeGUI do not update
}
friend module EPTF_CLL_UIHandlerVariableUI_Functions, EPTF_CLL_UIHandlerCLI_Functions,EPTF_CLL_UIHandler_XULFunctions;
friend module EPTF_UIHandler_Test_Testcases, EPTF_CLL_UIHandler_BrowserFunctions;
friend module EPTF_UIHandler_Test_Functions;
const charstring cg_ExternalVariableSign := "__ExternalValue";
//=========================================================================
// Public functions
//=========================================================================
group PublicFunctions {
public external function f_EPTF_UIHandler_init_XML();
public external function f_EPTF_UIHandler_cleanup_XML();
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_init_CT
//
// Purpose:
// Initialises the EPTF_UIHandler_CT
//
// Parameters:
// pl_selfName - *in* *charstring* - the name used in the initialization
// of the f_EPTF_Base_CT
// pl_CLI_compRef - *in* <EPTF_CLI_CT> - the CLI to use.
// Default: null (== local CLI ports are disabled)
// pl_connectGUI - *in* *boolean* - default: true. If it is true
// UIHandler will try to connect to the RuntimeGUI and will perform
// the XTDP handshake and authentication. The init function will
// exit after the XTDP session is connected. If the transport connection
// failed but the headless mode is true, the init function will exit
// with XTDP session not established and the UIHandler will enter
// into headless mode.
// pl_windowLayout - *in template* *charstring* - This parameter defines the initial
// gui layout in xml format. Must fit the XTDL.xsd. If it is omit (default value),
// UIHandler gets the <tsp_EPTF_GUI_DefaultWindowXTDL> module parameter, which can
// describe the GUI true. If it contains an empty string, there is no initial GUI.
// pl_prefix - *in* *charstring* - (default:tsp_EPTF_UIHandler_CLIPrefix) -
// common prefix for the UIHandler Command-Line Interface commands
// pl_simulationMode - *in* *boolean* - (default:false) -
// If this parameter is true, UIHandler will be initialized in simulation mode
// pl_simulation_buildDB_file - *in* *charstring* - (default:"") -
// The parameter is definies the file, what will be used to save the database
// or load the database in simulation mode
//
// Return Value:
// -
//
// Errors:
// Error occurs in client mode (i.e. if tsp_EPTF_UIHandler_servermode is false)
// if
// - pl_connectGUI true, headless mode is false, and it is not possible
// to connect to the RuntimeGUI.
// - pl_connectGUI false and headless mode is false
// - pl_connectGUI true but XTDP handshake&authentication is not
// performed in time (during tsp_EPTF_UIHandler_maxGUIWaitTime seconds)
//
// Detailed Comments:
// This function should be called before using the EPTF_UIHandler_CT
// component.
// Currently simulation mode is not supported, so do not change the values of
// the following parameters:
// pl_simulationMode
// pl_simulation_buildDB_file
// To get it (simulation mode) working nonblocking version of the f_EPTF_UIHandler_simulation_getData
// function needs to be implemented.
//
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandler_init_CT(
in charstring pl_selfName,
in boolean pl_connectGUI := true,
in template charstring pl_windowLayout := "",
in EPTF_CLI_CT pl_CLI_compRef := null,
in charstring pl_prefix := tsp_EPTF_UIHandler_CLIPrefix,
in boolean pl_simulationMode := false,
in charstring pl_simulation_buildDB_file := "",
in boolean pl_headlessmode := tsp_EPTF_UIHandler_headlessmode,
in boolean pl_servermode := tsp_EPTF_UIHandler_servermode,
in charstring pl_authresp := tsp_EPTF_UIHandler_Authresp )
runs on EPTF_UIHandler_Private_CT {
if (not v_UIHandler_initialized) {
v_EPTF_UIHandler_simulatonMode := pl_simulationMode;
v_EPTF_UIHandler_simulation_buildDB_file := pl_simulation_buildDB_file;
v_UIHandler_simulation_directContentDB := {};
if(isvalue(pl_windowLayout)){
v_UIHandler_windowLayout := valueof(pl_windowLayout);
v_UIHandler_emptyGUI := false;
}else{
v_UIHandler_windowLayout := "";
v_UIHandler_emptyGUI := true;
}
v_EPTF_UIHandler_createLayoutCallback := refers(f_EPTF_UIHandler_newCreateInitialLayout);
f_EPTF_UIHandler_init_XML();
f_EPTF_UIHandler_initComponent(pl_selfName, pl_CLI_compRef, pl_prefix, pl_headlessmode, pl_servermode, pl_authresp);
f_EPTF_UIHandler_connect(pl_connectGUI);
f_EPTF_UIHandler_simulation_Subscribe2saveDBButton_vars();
if(v_EPTF_UIHandler_simulatonMode == true) {
f_EPTF_UIHandler_simulation_createDBFromFile(pl_simulation_buildDB_file, v_UIHandler_simulation_directContentDB);
var integer vl_directContentDBSize := sizeof(v_UIHandler_simulation_directContentDB);
for(var integer vl_i := 0; vl_i < vl_directContentDBSize; vl_i := vl_i + 1) {
f_EPTF_str2int_HashMap_Insert(v_UIHandler_simulation_varsHashMapId, v_UIHandler_simulation_directContentDB[vl_i].key, vl_i);
f_EPTF_Var_newVar(v_UIHandler_simulation_directContentDB[vl_i].key, v_UIHandler_simulation_directContentDB[vl_i].directContent)
}
}
v_EPTF_UIHandler_WidgetFunctions_XTDP_XSD_filepath := "";
}
}
friend function f_EPTF_UIHandler_initComponent(
in charstring pl_selfName,
in EPTF_CLI_CT pl_CLI_compRef := null,
in charstring pl_prefix := tsp_EPTF_UIHandler_CLIPrefix,
in boolean pl_headlessmode := tsp_EPTF_UIHandler_headlessmode,
in boolean pl_servermode := tsp_EPTF_UIHandler_servermode,
in charstring pl_authresp := tsp_EPTF_UIHandler_Authresp)
runs on EPTF_UIHandler_Private_CT {
v_EPTF_UIHandler_headlessmode := pl_headlessmode;
v_EPTF_UIHandler_servermode := pl_servermode;
v_EPTF_UIHandler_Authresp := pl_authresp;
v_UIHandler_initToGUIClient := false;
v_UIHandler_createGUIRunning := false;
t_UIHandler_initGUIToClientTimer.start;
v_UIHandler_cleanupCalled := false;
v_UIHandler_openSubscriptions := {};
v_UIHandler_subscriptions := {};
v_UIHandler_guiLayoutReady := false;
v_UIHandler_guiItemList := {};
v_UIHandler_tracePointers := {};
v_UIHandler_windowIndex := -1;
//KI - 2013.11.04. - ez kimehetne, most kikotom a hasznalatat
v_UIHandler_GUI_DescriptionDB := {};
v_UIHandler_GUI_DescriptionDB_Idx := -1;
v_UIHandler_nofRunning_processExternalData_handlers := 0;
v_UIHandler_GUIFunctions_nofRunning_processExternalData_handlers := {}; // used to wait for all EPTF_CLL_UIHandler_GUIFunctions.cc[expand_current_node] functions to finish
f_EPTF_HashMap_init_CT (pl_selfName);
v_EPTF_UIHandler_Config_ConnectVarToWidgets := {};
v_handshakeMaxTime := tsp_EPTF_UIHandler_handshakeMaxTimer;
v_handshakeErrorMsg := "";
v_authMaxTime := tsp_EPTF_UIHandler_authMaxTimer;
v_byeMaxTime := tsp_EPTF_UIHandler_byeMaxTimer;
v_UIHandler_byeTimer := -1;
f_EPTF_Var_init_CT(pl_selfName);
f_EPTF_Logging_init_CT(pl_selfName);
f_EPTF_DataSource_init_CT(pl_selfName);
f_EPTF_StatManager_init_CT(pl_selfName);
if(self == pl_CLI_compRef) {
// if I am the CLI: initialize it (with telnet ports enabled):
f_EPTF_CLI_init_CT(pl_selfName)
} else {
// if remote or null CLI is used, disable all telnet ports in the CLI:
f_EPTF_CLI_init_CT(pl_selfName,*,*);
}
// NOTE:
// If pl_CLI_compRef is null: the CLI client will be initialized with self as CLI
// and the commands will be registered also.
// This is because if f_EPTF_UIHandler_CLI_init_CT is called later,
// that will enable the telnet ports, so the commands should be there.
if(null == pl_CLI_compRef){pl_CLI_compRef := self}
f_EPTF_CLI_Client_init_CT(pl_selfName, pl_CLI_compRef)
f_EPTF_UIHandler_CLIClient_init_CT(pl_prefix);
f_EPTF_DataSource_CLI_init_CT(pl_selfName, pl_CLI_compRef);
v_UIHandler_loggingMaskId := f_EPTF_Logging_registerComponentMasks(tsp_EPTF_UIHandler_loggingComponentMask, c_EPTF_UIHandler_loggingEventClasses, EPTF_Logging_CLL);
if(tsp_debug_EPTF_UIHandler_Functions) {
f_EPTF_Logging_enableLocalMask(v_UIHandler_loggingMaskId, c_EPTF_UIHandler_loggingClassIdx_Debug);
} else {
f_EPTF_Logging_disableLocalMask(v_UIHandler_loggingMaskId, c_EPTF_UIHandler_loggingClassIdx_Debug);
}
v_UIHandler_widgetHashMapId := f_EPTF_str2int_HashMap_New(c_EPTF_UIHandler_widgetIdHashMapName);
v_UIHandler_tracePointerHashMapId := f_EPTF_int2int_HashMap_New(c_EPTF_UIHandler_tracePointerHashMapName);
v_UIHandler_subscriptionHashMapId := f_EPTF_str2int_HashMap_New(c_EPTF_UIHandler_subscriptionHashMapName);
v_UIHandler_subscriptionHashMapIdVar := f_EPTF_str2int_HashMap_New(c_EPTF_UIHandler_subscriptionHashMapNameVar);
v_UIHandler_simulation_varsHashMapId := f_EPTF_str2int_HashMap_New(c_EPTF_UIHandler_simulation_varsHashMapName);
f_EPTF_Semaphore_init_CT(pl_selfName);
v_UIHandler_xtdpReceivedMessageSemaphore_r := f_EPTF_Semaphore_new();
f_EPTF_Semaphore_unlock(v_UIHandler_xtdpReceivedMessageSemaphore_r);
v_UIHandler_layoutResponseReceivedSemaphore := f_EPTF_Semaphore_new();
v_UIHandler_exitButtonPressedSemaphore := f_EPTF_Semaphore_new();
v_UIHandler_progressEnabled := true;
f_EPTF_UIHandler_initProgressBar();
f_EPTF_Transport_init(IPL4, pl_selfName)
//FIXME use the new API
f_EPTF_Transport_registerMsgLenCallback4LGenType(IPL4, refers(f_EPTF_UIHandler_getMsgLen_XTDP), {}, c_EPTF_UIHandler_XTDPType);
f_EPTF_Transport_registerMsgCallback(IPL4, c_EPTF_UIHandler_XTDPType, refers(f_EPTF_UIHandler_HandleMsgs_XTDP), refers(f_EPTF_UIHandler_HandleEvent_XTDP));
f_EPTF_MessageBufferManager_MaxBufferSize_setMinValue(tsp_EPTF_UIHandler_CommPortIPL4_minBufferSize);
f_EPTF_Base_registerCleanup(refers(f_EPTF_UIHandler_cleanup_CT));
if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){
f_EPTF_UIHandler_debug("----EPTF_UIHandler 0.8610 INIT DONE----");
}
f_EPTF_DataSourceClient_init_CT(f_EPTF_Base_selfName(), self);
f_EPTF_DataSourceClient_registerData(c_UIHandler_DS_sourceId, f_EPTF_Base_selfName(), refers(f_EPTF_UIhandler_DSProcessData), self);
f_EPTF_DataSourceClient_registerDataValue(c_UIHandler_DS_sourceId, f_EPTF_Base_selfName(), refers(f_EPTF_UIHandler_DSProcessDataValue), self);
f_EPTF_DataSourceClient_sendReady(c_UIHandler_DS_sourceId, f_EPTF_Base_selfName());
if(tsp_EPTF_UIHandler_enableBrowserGUI){
f_EPTF_UIHandler_Browser_init_CT( );
}
v_EPTF_UIHandler_Traces_HashmapId := f_EPTF_str2int_HashMap_New("TracesHashMap");
v_UIHandler_initialized := true;
if(f_EPTF_UIHandler_layoutReady()) {
//f_EPTF_UIHandler_createInitialLayout(pl_windowLayout); // initial window is created in internal DB before trying to connect to GUI
if(null != v_EPTF_UIHandler_createLayoutCallback){
v_EPTF_UIHandler_createLayoutCallback.apply();
}
}
f_EPTF_UIHandler_updateOwnProgress("Initializing: Done.");
f_EPTF_Base_waitForCondition(refers(f_EPTF_UIHandler_checkDataSourceReady))
}
private function f_EPTF_UIHandler_checkDataSourceReady()
runs on EPTF_UIHandler_Private_CT return boolean{
var charstring vl_varName := "";
var integer vl_returnVal := f_EPTF_DataSource_checkData(
pl_dataVarName := vl_varName,
pl_source := c_UIHandler_DS_sourceId,
pl_ptcName := "",
pl_element := c_UIHandler_dataElement_progressBar,
pl_params := {});
return vl_returnVal == 0;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_updateProgress
//
// Purpose:
// Update the value of the dataSource containing the progress information
//
// Parameters:
// pl_progressInfo - *in* *charstring* - the new progress information to show
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// The progress history is updated automatically
//
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandler_updateProgress(in charstring pl_progressInfo, in float vl_progressPercent := -1.0) runs on EPTF_UIHandler_Private_CT {
if (not v_UIHandler_initialized){ return }
var charstring vl_progressPercentStr := "";
if (vl_progressPercent>=0.0) {
vl_progressPercentStr := ": "&int2str(float2int(vl_progressPercent))&"%";
}
f_EPTF_Var_adjustContent(f_EPTF_Var_getId(c_UIHandler_DS_var_prefix&c_UIHandler_dataElement_progressBar),{charstringVal := pl_progressInfo&vl_progressPercentStr});
}
private function f_EPTF_UIHandler_initProgressBar() runs on EPTF_UIHandler_Private_CT {
// create progress bar variable:
var integer vl_progressBar_Idx, vl_progressBarHistory_Idx;
f_EPTF_Var_newCharstring(c_UIHandler_DS_var_prefix&c_UIHandler_dataElement_progressBar,"",vl_progressBar_Idx);
f_EPTF_Var_newCharstring(c_UIHandler_DS_var_prefix&c_UIHandler_dataElement_progressBarHistory,"",vl_progressBarHistory_Idx);
f_EPTF_Var_addPostProcFn(vl_progressBar_Idx,{
refers(f_EPTF_UIHandler_progressBarHistory_PostProc),
{vl_progressBarHistory_Idx}
});
f_EPTF_Var_setSubsCanAdjust(vl_progressBarHistory_Idx,false);
f_EPTF_UIHandler_updateOwnProgress("Initializing...");
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_enableOwnProgress
//
// Purpose:
// Enables UIHandler's own progress information updates
//
// Parameters:
// pl_enableOwnProgress - *in* *boolean* - true: enable, false: disable
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandler_enableOwnProgress(in boolean pl_enableOwnProgress) runs on EPTF_UIHandler_Private_CT {
v_UIHandler_progressEnabled := pl_enableOwnProgress;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_updateOwnProgress
//
// Purpose:
// Update the value of the dataSource containing the progress information with the UIHandler's own progress info
//
// Parameters:
// pl_progressInfo - *in* *charstring* - the new progress information to show
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// The progress history is updated automatically
//
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandler_updateOwnProgress(in charstring pl_progressInfo, in float vl_progressPercent := -1.0) runs on EPTF_UIHandler_Private_CT {
if (v_UIHandler_progressEnabled) {
f_EPTF_UIHandler_updateProgress(c_UIHandler_DS_sourceId&": "&pl_progressInfo,vl_progressPercent);
}
}
// appends the progressBar var content to the progressBarHistory var:
private function f_EPTF_UIHandler_progressBarHistory_PostProc(in integer pl_idx, in EPTF_IntegerList pl_argList) runs on EPTF_UIHandler_Private_CT {
// content of the progressBar var:
var integer vl_progressBarHistory_Idx := pl_argList[0];
f_EPTF_Var_adjustContent(
vl_progressBarHistory_Idx,
{
charstringVal := f_EPTF_Var_getCharstringValue(vl_progressBarHistory_Idx)&"\n"&f_EPTF_Var_getCharstringValue(pl_idx)
}
);
}
friend function f_EPTF_UIHandler_connect(in boolean pl_connectGUI)
runs on EPTF_UIHandler_Private_CT {
var ConnectionId vl_connId := -1;
var boolean vl_UIHandler_transportConnectionFailed := false;
if (v_EPTF_UIHandler_servermode){
// server mode
f_EPTF_UIHandler_headlessmode();
} else {
// client mode
f_EPTF_Transport_registerMsgCallback(IPL4, c_EPTF_UIHandler_pingerTransport, refers(f_EPTF_UIHandler_pingerReceive));
var Result vl_result
f_EPTF_Transport_listen(IPL4, { udp := {} }, tsp_EPTF_UIHandler_localPingerAddr, tsp_EPTF_UIHandler_localPingerPort, c_EPTF_UIHandler_pingerTransport, vl_result, false)
if (ispresent(vl_result.errorCode) and (vl_result.errorCode != ERROR_TEMPORARILY_UNAVAILABLE)) {
f_EPTF_UIHandler_error("Could not open pinger port: " & log2str(vl_result));
}
v_UIHandler_pingerConnectionId := vl_result.connId;
v_UIHandler_udp_port := tsp_EPTF_UIHandler_udp_port;
// Checks for GUI address that is set by the user.
// If not use the address from module parameter.
if (v_UIHandler_GUI_Host == c_EPTF_UIHandler_Invalid_GUI_Host or
v_UIHandler_GUI_Port == c_EPTF_UIHandler_Invalid_GUI_Port) {
v_UIHandler_GUI_Host := tsp_xtdp_listen_addr;
v_UIHandler_GUI_Port := tsp_xtdp_listen_port;
}
if(pl_connectGUI){
// try to connect to GUI
var EPTF_UIHandler_connectionResult vl_res := f_EPTF_UIHandler_connectAndInitGui(vl_connId);
if(connected != vl_res){
if (v_EPTF_UIHandler_headlessmode) {
// connect to GUI failed -> switch to headless mode
if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){
f_EPTF_UIHandler_debug("initGUI failed, switch to headless mode");
}
f_EPTF_UIHandler_headlessmode();
vl_UIHandler_transportConnectionFailed := vl_res != temporarilyUnavailable;
} else {
// connecting to GUI failed and headless mode not enabled -> stop running
f_EPTF_UIHandler_error("initGUI failed!");
}
}
} else if (v_EPTF_UIHandler_headlessmode) {
// headless mode enabled -> switch to headless mode
if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){
f_EPTF_UIHandler_debug("UIHandler started in headless mode");
}
f_EPTF_UIHandler_headlessmode();
} else {
// uncorrect starrtup configuration: client mode, not to connect to GUI, headless mode disabled -> stop running
f_EPTF_UIHandler_error("Uncorrect UIHandler configuration for startup: client mode, not to connect to GUI, headless mode disabled");
}
}
if (tsp_EPTF_UIHandler_bufferedXTDP != 0.0){
//v_UIHandler_Requestbuffer.data.noNamespaceSchemaLocation := omit;
v_UIHandler_Requestbuffer.data.transactionID := omit;
v_UIHandler_Requestbuffer.data.choice.xTDP_Requests.ackRequested := omit;
f_EPTF_UIHandler_requestBuffer_clear();
t_UIHandler_bufferedXTDP.start(tsp_EPTF_UIHandler_bufferedXTDP);
}
v_UIHandler_def := activate(as_handle_main_EPTF_UIHandler_MgmtIf());
// wait for gui connect (handshake and authentication) if transport is already connected
if ((pl_connectGUI and not v_EPTF_UIHandler_servermode) and not vl_UIHandler_transportConnectionFailed) {
timer t_wait_for_connectGUI := 0.0;
timer t_max_wait_for_connectGUI := tsp_EPTF_UIHandler_maxGUIWaitTime;
t_max_wait_for_connectGUI.start;
t_wait_for_connectGUI.start;
alt {
[v_UIHandler_guiConnected or (vl_connId != -1 and not f_EPTF_UIHandler_isConnectedClientid(vl_connId))] t_wait_for_connectGUI.timeout {
// connection established, or lost
}
[] t_max_wait_for_connectGUI.timeout {
// bugfix_HR17649 - error => warning
f_EPTF_UIHandler_warning("In client mode connecting to the RuntimeGUI on " & v_UIHandler_GUI_Host & ":" & log2str(v_UIHandler_GUI_Port) & " failed: Timeout during handshake&authentication. RuntimeGUI is not responding. Please correct the tsp_xtdp_listen_addr / tsp_xtdp_listen_port parameter(s) or restart the RuntimeGUI! ");
f_EPTF_UIHandler_headlessmode();
}
}
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_newCreateInitialLayout
//
// Purpose:
// Create initial layout based on settings
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandler_newCreateInitialLayout()
runs on EPTF_UIHandler_Private_CT
{
var boolean vl_ret := false;
if(not v_UIHandler_emptyGUI){
// If no window is given neither from parameter nor from tsp, parameter is not given, or contains the default value ->
// create a simple window and a main tabbox
// This is the backward compatible way
if("" == v_UIHandler_windowLayout and "" == tsp_EPTF_GUI_DefaultWindow){
// no window is given -> create a simple window and a main tabbox
if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){
f_EPTF_UIHandler_debug(%definitionId&": Creating a window and a main tabbox");
}
vl_ret := f_EPTF_UIHandler_addWindow();
vl_ret := vl_ret and f_EPTF_UIHandler_addMainTabbox();
}
else {
if ("" != v_UIHandler_windowLayout) {
// create window given in parameter
if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){
f_EPTF_UIHandler_debug(%definitionId&": Creating window specified by function parameter: "&log2str(v_UIHandler_windowLayout));
}
f_EPTF_UIHandler_createGUIFromWindow(v_UIHandler_windowLayout);
//vl_wndXul := f_EPTF_UIHandler_XSD_decodeXUL(pl_windowLayout);
}
else if ("" != tsp_EPTF_GUI_DefaultWindow) {
// create window from specified in tsp
if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){
f_EPTF_UIHandler_debug(%definitionId&": Creating window specified by tsp_EPTF_GUI_DefaultWindowXTDL: "&log2str(tsp_EPTF_GUI_DefaultWindowXTDL));
}
f_EPTF_UIHandler_createGUIFromWindow(tsp_EPTF_GUI_DefaultWindowXTDL);
//vl_wndXul := f_EPTF_UIHandler_XSD_decodeXUL(tsp_EPTF_GUI_DefaultWindow);
}
if (not vl_ret) {
if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){
f_EPTF_UIHandler_debug(%definitionId&" failed, could not create initial GUI");
}
}
}
}
}
private function f_EPTF_UIHandler_createGUIFromWindow(in charstring pl_window)
runs on EPTF_UIHandler_Private_CT{
var Widgets vl_widgets := f_EPTF_UIHandler_XSD_decodeXUL(pl_window);
if(not ischosen(vl_widgets.window)){
f_EPTF_UIHandler_error(%definitionId&": The received XUL is invalid, not window or it can not be decoded fully.\n"&
"For further detailes see the log file above.")
}
f_EPTF_UIHandler_createGUI(pl_window);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_cleanup_CT
//
// Purpose:
// Destructs the EPTF_UIHandler_CT
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// none
//
// Detailed Comments:
// This function mustn't be called directly. You must call f_EPTF_Base_cleanup_CT instead.
///
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandler_cleanup_CT() runs on EPTF_UIHandler_Private_CT {
// f_EPTF_Logging_debug(true, "v_UIHandler_initialized: "& v_UIHandler_initialized &" v_UIHandler_guiConnected: "& v_UIHandler_guiConnected);
if (v_UIHandler_initialized)
{
v_UIHandler_cleanupCalled := true;
if(t_UIHandler_pingtimer.running) {
t_UIHandler_pingtimer.stop;
}
if(t_UIHandler_initGUIToClientTimer.running) {
t_UIHandler_initGUIToClientTimer.stop;
}
if(v_UIHandler_guiConnected)
{
for (var integer i := 0; i<sizeof(v_UIHandler_GUIClientId); i:= i+1)
{
f_EPTF_UIHandler_closeXTDPSession(v_UIHandler_GUIClientId[i].clientId);
//var Result vl_result
//f_EPTF_Transport_send(IPL4, v_UIHandler_GUIClientId[i], char2oct("bye\r\n"), vl_result, false)
}
}
f_EPTF_Semaphore_delete(v_UIHandler_xtdpReceivedMessageSemaphore_r);
f_EPTF_Semaphore_delete(v_UIHandler_layoutResponseReceivedSemaphore);
f_EPTF_Semaphore_delete(v_UIHandler_exitButtonPressedSemaphore);
v_UIHandler_openSubscriptions := {};
v_UIHandler_subscriptions := {}
f_EPTF_str2int_HashMap_Delete(c_EPTF_UIHandler_subscriptionHashMapName);
f_EPTF_str2int_HashMap_Delete(c_EPTF_UIHandler_subscriptionHashMapNameVar);
f_EPTF_str2int_HashMap_Delete(c_EPTF_UIHandler_simulation_varsHashMapName);
v_UIHandler_subscriptionHashMapId := -1;
v_UIHandler_subscriptionHashMapIdVar := -1;
v_UIHandler_simulation_varsHashMapId := -1;
v_UIHandler_guiItemList := {};
v_UIHandler_windowIndex := -1;
v_UIHandler_initialized := false;
f_EPTF_str2int_HashMap_Delete(c_EPTF_UIHandler_widgetIdHashMapName);
v_UIHandler_widgetHashMapId := -1;
f_EPTF_int2int_HashMap_Delete(c_EPTF_UIHandler_tracePointerHashMapName);
v_UIHandler_tracePointerHashMapId := -1;
v_UIHandler_tracePointers := {};
f_EPTF_str2int_HashMap_DeleteById(v_EPTF_UIHandler_Traces_HashmapId);
v_EPTF_UIHandler_TraceRingBuffers := {};
v_UIHandler_initToGUIClient := false;
v_UIHandler_createGUIRunning := false;
v_EPTF_UIHandler_headlessmode := true;
v_EPTF_UIHandler_servermode := false;
v_EPTF_UIHandler_Authresp := "";
}
// Reset the GUI address because we don't want to affect the
// subsequence UIHandler initializations.
v_UIHandler_GUI_Host := c_EPTF_UIHandler_Invalid_GUI_Host;
v_UIHandler_GUI_Port := c_EPTF_UIHandler_Invalid_GUI_Port;
v_UIHandler_guiConnected := false;
// clearing registered callbacks (also registered callbacks exit if not v_UIHandler_initialized):
//f_EPTF_CommPort_IPL4_setMsgLen4LGenType(null, {}, c_EPTF_UIHandler_XTDPType);
f_EPTF_Transport_registerMsgCallback(IPL4, c_EPTF_UIHandler_XTDPType, null, null);
deactivate(v_UIHandler_def); v_UIHandler_def := null;
// WORKAROUND for some GUI bug, remove it ASAP!
timer t_x := 0.5;t_x.start;t_x.timeout;
if (not v_EPTF_UIHandler_servermode){
var Result vl_result
f_EPTF_Transport_close(IPL4, v_UIHandler_pingerConnectionId, vl_result)
v_UIHandler_pingerConnectionId := -1;
}
f_EPTF_UIHandler_CLIClient_cleanup_CT()
if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){
f_EPTF_UIHandler_debug("----EPTF_UIHandler cleanup DONE----");
}
f_EPTF_UIHandler_cleanup_XML();
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_clearGUI
//
// Purpose:
// Sends a message to user interface via XTDP port to remove
// all the elements and also clears UIHandler's internal DB.
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandler_clearGUI(in boolean pl_clearDb := true) runs on EPTF_UIHandler_Private_CT {
if (not v_UIHandler_initialized){ return }
f_EPTF_UIHandler_waitForLayoutReady();
// remove all
for(var integer clientindex:=0;clientindex<sizeof(v_UIHandler_GUIClientId);clientindex := clientindex+1){
var ASP_XSD_XTDP vl_msg :={
v_UIHandler_GUIClientId[clientindex].clientId,
{
choice := {
xTDP_RemoveRequests:= {
xTDP_RemoveRequest_list := {
{
requestId := 1,
widgetId := omit
}
}
}
}
}
};
f_EPTF_UIHandler_send_XTDP(vl_msg);
}
if (pl_clearDb) {
// make internal widget DB empty
f_EPTF_UIHandler_clearInternalWidgetDB();
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_addWindow
//
// Purpose:
// Tries to add a new window to the RuntimeGUI
//
// Detailed Comments:
// The parameters of the new window can be controlled via
// the tsp_EPTF_GUI_Main_Window_... module parameters
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandler_addWindow()
runs on EPTF_UIHandler_Private_CT
return boolean{
if (not v_UIHandler_initialized){ return false }
f_EPTF_UIHandler_waitForLayoutReady();
var Widgets vl_xul := {
window := {
about := omit,
height := tsp_EPTF_GUI_Main_Window_Height,
help := omit,
id := tsp_EPTF_GUI_Main_Window_WidgetId,
orientation := vertical,
title := tsp_EPTF_GUI_Main_Window_Title,
width := tsp_EPTF_GUI_Main_Window_Width,
image_list := {},
embeddedwidgets := {
/* {tabbox := { */
/* id := tsp_EPTF_GUI_Main_Tabbox_WidgetId, */
/* flex := omit, */
/*customclass := omit, */
/* disabled := omit, */
/*disabledongui := omit, */
/* tabs := {}, */
/* tabpanels := {} */
/* } */
/* }, */
embeddedwidget_list := {
/*{
toolbar := {
customclass := omit,
disabled := false,
disabledongui := omit,
id := tsp_EPTF_GUI_Main_Toolbar_WidgetId,
placement := south,
choice_list := {}
}
}*/
}
}
}
};
var boolean vl_dummy := false;
return f_EPTF_UIHandler_XSD_addElementToGui(vl_xul, "", vl_dummy);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_addMainTabbox
//
// Purpose:
// Tries to add the main tabbox to the RuntimeGUI
//
// Detailed Comments:
// The id of the tabbox is spesified by
// tsp_EPTF_GUI_Main_Tabbox_WidgetId module parameter
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandler_addMainTabbox()
runs on EPTF_UIHandler_Private_CT
return boolean{
if (not v_UIHandler_initialized){ return false }
var boolean vl_succ := f_EPTF_UIHandler_addMainTabpages();
return vl_succ;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_addMainTabpages
//
// Purpose:
// Tries to add the main tabbox to the RuntimeGUI
//
// Detailed Comments:
// The id of the tabbox is spesified by
// tsp_EPTF_GUI_Main_Tabbox_WidgetId module parameter
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandler_addMainTabpages()
runs on EPTF_UIHandler_Private_CT
return boolean{
if (not v_UIHandler_initialized){ return false }
f_EPTF_UIHandler_waitForLayoutReady();
var Widgets vl_xul := {
tabpages := {
//In case of named fields the compiler won't warn if
//there are uninitializad elements
/*customclass :=*/ omit,
/*disabled :=*/ omit,
/*disabledongui :=*/ omit,
/*flex :=*/ omit,
/*id :=*/ tsp_EPTF_GUI_Main_Tabbox_WidgetId,
/*layout :=*/ omit,
/*tabpage :=*/ { { } }
}
};
var boolean vl_dummy:=false;
return f_EPTF_UIHandler_XSD_addElementToGui(vl_xul, tsp_EPTF_GUI_Main_Window_WidgetId, vl_dummy);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_removeElementFromGui
//
// Purpose:
// Remove an element from the GUI.
//
// Parameters:
// pl_widgetId - *in* *EPTF_UIHandler_WidgetIdString* - element to be removed
// pl_sendToRTG - *in* *boolean* - if true: request is sent to runtime GUI, otherwise not
//
// Return Value:
// Returns the result of f_EPTF_UIHandler_removeWidgetRecByIdx.
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandler_removeElementFromGui_old(in EPTF_UIHandler_WidgetIdString pl_widgetId, in boolean pl_sendToRTG := true, in boolean pl_appendTo_GUI_DescriptionDB := true)
runs on EPTF_UIHandler_Private_CT
return boolean{
if (not v_UIHandler_initialized){ return false }
if(pl_appendTo_GUI_DescriptionDB) {
v_UIHandler_GUI_DescriptionDB[sizeof(v_UIHandler_GUI_DescriptionDB)] := {pl_widgetId, "removed"};
}
f_EPTF_UIHandler_waitForLayoutReady();
var integer vl_idx := f_EPTF_UIHandler_widgetRecIndex(pl_widgetId);
if(-1 == vl_idx){
f_EPTF_UIHandler_warning("There is no widget with name "&pl_widgetId&" to remove!");
return false;
}
//remove the element from the GUI
if (pl_sendToRTG) {
f_EPTF_UIHandler_send_XTDP(ts_ASP_XTDP_singleRemoveElementFromGUI(pl_widgetId));
}
if(tsp_EPTF_UIHandler_enableBrowserGUI == true){
f_EPTF_UIHandler_Browser_reportGUIChanged(pl_widgetId);
}
//remove it and its children from the widgetlist and the connectionlist
return f_EPTF_UIHandler_removeWidgetRecByIdx(vl_idx);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_removeElementFromGui
//
// Purpose:
// Remove an element from the GUI.
//
// Parameters:
// pl_widgetId - *in* *EPTF_UIHandler_WidgetIdString* - element to be removed
// pl_sendToRTG - *in* *boolean* - if true: request is sent to runtime GUI, otherwise not
//
// Return Value:
// Returns the result of f_EPTF_UIHandler_removeWidgetRecByIdx.
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandler_removeElementFromGui(in EPTF_UIHandler_WidgetIdString pl_widgetId, in boolean pl_sendToRTG := true, in boolean pl_appendTo_GUI_DescriptionDB := true)
runs on EPTF_UIHandler_Private_CT
return boolean{
if (not v_UIHandler_initialized){ return false }
var boolean vl_ret := true;
if(pl_appendTo_GUI_DescriptionDB) {
v_UIHandler_GUI_DescriptionDB[sizeof(v_UIHandler_GUI_DescriptionDB)] := {pl_widgetId, "removed"};
}
f_EPTF_UIHandler_waitForLayoutReady();
var integer vl_idx := f_EPTF_UIHandler_widgetRecIndex(pl_widgetId);
if(-1 == vl_idx){
f_EPTF_UIHandler_warning("There is no widget with name "&pl_widgetId&" to remove!");
return false;
}
//remove the element from the GUI
if (pl_sendToRTG) {
f_EPTF_UIHandler_send_XTDP(ts_ASP_XTDP_singleRemoveElementFromGUI(pl_widgetId));
}
if(tsp_EPTF_UIHandler_enableBrowserGUI == true){
f_EPTF_UIHandler_Browser_reportGUIChanged(pl_widgetId);
}
//remove it and its children from the widgetlist and the connectionlist
vl_ret := f_EPTF_UIHandler_removeWidgetRecByIdx(vl_idx)
if(vl_ret == true) {
// Remove it from document
vl_ret := f_EPTF_UIHandler_removeXML(pl_widgetId);
}
return vl_ret;
}
public function f_EPTF_UIHandler_printAllXMLfor_Tests( )
runs on EPTF_UIHandler_Private_CT {
if (not v_UIHandler_initialized){ return }
f_EPTF_UIHandler_printAllXML();
return;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_removeElementFromGuiByIdx
//
// Purpose:
// Remove an element from the GUI.
//
// Parameters:
// pl_widgetIdx - *in* *integer* - element to be removed
// pl_sendToRTG - *in* *boolean* - if true: request is sent to runtime GUI, otherwise not
//
// Return Value:
// Returns the result of f_EPTF_UIHandler_removeWidgetRecByIdx.
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandler_removeElementFromGuiByIdx(in integer pl_widgetIdx, in boolean pl_sendToRTG := true, in boolean pl_appendTo_GUI_DescriptionDB := true)
runs on EPTF_UIHandler_Private_CT
return boolean{
var charstring vl_widgetId := v_UIHandler_guiItemList[pl_widgetIdx].id;
if(pl_appendTo_GUI_DescriptionDB) {
v_UIHandler_GUI_DescriptionDB[sizeof(v_UIHandler_GUI_DescriptionDB)] := {vl_widgetId, "removed"};
}
f_EPTF_UIHandler_waitForLayoutReady();
if(-1 == pl_widgetIdx){
f_EPTF_UIHandler_warning("There is no widget with name "&vl_widgetId&" to remove!");
return false;
}
//remove the element from the GUI
if (pl_sendToRTG) {
f_EPTF_UIHandler_send_XTDP(ts_ASP_XTDP_singleRemoveElementFromGUI(vl_widgetId));
}
if(tsp_EPTF_UIHandler_enableBrowserGUI == true){
f_EPTF_UIHandler_Browser_reportGUIChanged(vl_widgetId, pl_widgetIdx);
}
//remove it and its children from the widgetlist and the connectionlist
return f_EPTF_UIHandler_removeWidgetRecByIdx(pl_widgetIdx);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_snapshot
//
// Purpose:
// Makes a snapshot of the GUI as a charstring.
//
// Return Value:
// The returned charstring describes a XUL. It can be saved with
// <f_EPTF_UIHandler_saveLayout> to a config file.
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandler_snapshot()
runs on EPTF_UIHandler_Private_CT
return charstring{
if (not v_UIHandler_initialized){ return "" }
f_EPTF_UIHandler_waitForLayoutReady();
var charstring vl_layout := "";
if(v_UIHandler_guiConnected)
{
f_EPTF_UIHandler_send_XTDP(ts_ASP_XTDP_layoutRequest);
if(f_EPTF_Semaphore_waitForUnlock(v_UIHandler_layoutResponseReceivedSemaphore, tsp_EPTF_UIHandler_maxWaitTimer))
{
f_EPTF_UIHandler_warning("Timer timeout! No layout response received!");
f_EPTF_Semaphore_unlock(v_UIHandler_xtdpReceivedMessageSemaphore_r);
v_UIHandler_layoutResponseReceivedSemaphore := f_EPTF_Semaphore_new();
return vl_layout;
}
v_UIHandler_layoutResponseReceivedSemaphore := f_EPTF_Semaphore_new();
//f_EPTF_Semaphore_lock(v_UIHandler_layoutResponseReceivedSemaphore);
vl_layout := f_EPTF_UIHandler_XSD_encodeXUL(v_UIHandler_receivedMessage.choice.xTDP_LayoutResponse.widgets);
}else{
var Widgets vl_xul;
f_EPTF_UIHandler_buildXUL(vl_xul);
vl_layout := f_EPTF_UIHandler_XSD_encodeXUL(vl_xul)
}
f_EPTF_Semaphore_unlock(v_UIHandler_xtdpReceivedMessageSemaphore_r);
return vl_layout;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_snapshotWindow
//
// Purpose:
// Makes a snapshot of the GUI's root widget (windowelem) as a charstring.
//
// Return Value:
// The returned charstring describes a XUL that can be passed to
// the runtime GUI as a command line parameter if saved as a file.
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandler_snapshotWindow()
runs on EPTF_UIHandler_Private_CT
return charstring{
if (not v_UIHandler_initialized){ return "" }
f_EPTF_UIHandler_waitForLayoutReady();
var charstring vl_layout := "";
if(v_UIHandler_guiConnected)
{
f_EPTF_UIHandler_send_XTDP(ts_ASP_XTDP_layoutRequest);
if(f_EPTF_Semaphore_waitForUnlock(v_UIHandler_layoutResponseReceivedSemaphore, tsp_EPTF_UIHandler_maxWaitTimer))
{
f_EPTF_UIHandler_warning("Timer timeout! No layout response received!");
f_EPTF_Semaphore_unlock(v_UIHandler_xtdpReceivedMessageSemaphore_r);
v_UIHandler_layoutResponseReceivedSemaphore := f_EPTF_Semaphore_new();
return vl_layout;
}
v_UIHandler_layoutResponseReceivedSemaphore := f_EPTF_Semaphore_new();
//f_EPTF_Semaphore_lock(v_UIHandler_layoutResponseReceivedSemaphore);
if(ischosen(v_UIHandler_receivedMessage.choice.xTDP_LayoutResponse.widgets.window)) {
vl_layout := f_EPTF_UIHandler_XSD_encodeWindowXUL(v_UIHandler_receivedMessage.choice.xTDP_LayoutResponse.widgets.window);
} else {
f_EPTF_UIHandler_warning(%definitionId&": Unexpected XTDP LayoutResponse (not window)!");
}
}else{
var Widgets vl_xul;
f_EPTF_UIHandler_buildXUL(vl_xul);
if(ischosen(vl_xul.window)) {
vl_layout := f_EPTF_UIHandler_XSD_encodeWindowXUL(vl_xul.window);
} else {
f_EPTF_UIHandler_warning(%definitionId&": Unexpected layout (not window)!");
}
}
f_EPTF_Semaphore_unlock(v_UIHandler_xtdpReceivedMessageSemaphore_r);
return vl_layout;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_XSD_encodeXUL
//
// Purpose:
// Encodes a XUL record to its charstring representation
//
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandler_XSD_encodeXUL(in Widgets pl_widgets)
return charstring{
var octetstring vl_ret := enc_Widgets(pl_widgets);
return oct2char(vl_ret)
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_XSD_encodeWindowXUL
//
// Purpose:
// Encodes a XUL Window record to its charstring representation
//
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandler_XSD_encodeWindowXUL(in Window pl_windowelem)
return charstring{
var octetstring vl_ret := enc_Window(pl_windowelem);
return oct2char(vl_ret)
}
public external function dec_Widgets (in octetstring p_oct, out Widgets p_widgets) return integer
with {extension "prototype(backtrack) decode (XER:XER_EXTENDED) errorbehavior(ALL:WARNING)"}
public external function enc_Widgets (in Widgets p_widgets) return octetstring
with {extension "prototype(convert) encode (XER:XER_EXTENDED)"}
public external function enc_Window (in Window p_windowelem) return octetstring
with {extension "prototype(convert) encode (XER:XER_EXTENDED)"}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_XSD_encodeXULEm
//
// Purpose:
// Encodes an Embedded XUL record to its charstring representation
//
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandler_XSD_encodeXULEm(in Embeddedwidget pl_widgets)
return charstring{
var octetstring vl_ret := enc_EmbeddedWidget(pl_widgets);
return oct2char(vl_ret)
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_preprocessAliasXUL
//
// Purpose:
// Preprocess alias items in XUL charstring
//
///////////////////////////////////////////////////////////
// 02.04.2012 made for first version of externalvalue
// handling. not dropped becouse it will be useful once.
type record EPTF_UIHandler_alias {
charstring fromStr,
charstring toStr
};
type record of EPTF_UIHandler_alias EPTF_UIHandler_aliasList;
public function f_EPTF_UIHandler_preprocessAliasXUL(in charstring pl_xul)
runs on EPTF_UIHandler_Private_CT return charstring {
var EPTF_UIHandler_aliasList vl_aliasList:= {/*{ fromStr := "externalvalue", toStr := "iterator" }*/};
var charstring vl_preprocessed := pl_xul;
if(0 < sizeof(vl_aliasList)) {
for (var integer vl_idx := 0; vl_idx < sizeof(vl_aliasList); vl_idx := vl_idx + 1) {
var charstring vl_startFromValue := "<"&vl_aliasList[vl_idx].fromStr;
var charstring vl_startToValue := "<"&vl_aliasList[vl_idx].toStr;
var charstring vl_endFromValue := "</"&vl_aliasList[vl_idx].fromStr;
var charstring vl_endToValue := "</"&vl_aliasList[vl_idx].toStr;
// replace start tag
vl_preprocessed := pl_xul;
var charstring vl_tempStr:= pl_xul;
var charstring vl_LoverStr := f_putInLowercase(pl_xul), vl_tempLowerStr:= vl_LoverStr;
var integer vl_i := f_strstr(vl_LoverStr,vl_startFromValue);
while (vl_i!=-1) {
vl_preprocessed :=
substr(vl_tempStr,0,vl_i)&vl_startToValue&
substr(vl_tempStr,vl_i+lengthof(vl_startFromValue),
lengthof(vl_tempStr)-vl_i-lengthof(vl_startFromValue));
vl_LoverStr := substr(vl_tempLowerStr,0,vl_i)&vl_startToValue&
substr(vl_tempLowerStr,vl_i+lengthof(vl_startFromValue),
lengthof(vl_tempLowerStr)-vl_i-lengthof(vl_startFromValue));
//continue from saved pointer offset with the length of replacement string
vl_i := vl_i+lengthof(vl_startToValue);
vl_tempStr := vl_preprocessed;
vl_tempLowerStr := vl_LoverStr;
vl_i := f_strstr(vl_LoverStr,vl_startFromValue,vl_i);
}
// replace end tag
vl_tempStr:= vl_preprocessed;
vl_tempLowerStr:= vl_LoverStr;
vl_i := f_strstr(vl_LoverStr,vl_endFromValue);
while (vl_i!=-1) {
vl_preprocessed :=
substr(vl_tempStr,0,vl_i)&vl_endToValue&
substr(vl_tempStr,vl_i+lengthof(vl_endFromValue),
lengthof(vl_tempStr)-vl_i-lengthof(vl_endFromValue));
vl_LoverStr := substr(vl_tempLowerStr,0,vl_i)&vl_endToValue&
substr(vl_tempLowerStr,vl_i+lengthof(vl_endFromValue),
lengthof(vl_tempLowerStr)-vl_i-lengthof(vl_endFromValue));
//continue from saved pointer offset with the length of replacement string
vl_i := vl_i+lengthof(vl_endToValue);
vl_tempStr := vl_preprocessed;
vl_tempLowerStr := vl_LoverStr;
vl_i := f_strstr(vl_LoverStr,vl_endFromValue,vl_i);
}
}
}
return vl_preprocessed;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_XSD_decodeXULEm
//
// Purpose:
// Decodes a XUL record to its charstring representation
//
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandler_XSD_decodeXULEm(in charstring pl_widgets)
return Embeddedwidget{
var Embeddedwidget vl_ret;
var integer vl_dummy;
vl_dummy := dec_EmbeddedWidget(char2oct(pl_widgets), vl_ret);
return vl_ret;
}
private external function dec_EmbeddedWidget (in octetstring p_oct, out Embeddedwidget p_widgets) return integer
with {extension "prototype(backtrack) decode (XER:XER_EXTENDED) errorbehavior(ALL:WARNING)"}
private external function enc_EmbeddedWidget (in Embeddedwidget p_widgets) return octetstring
with {extension "prototype(convert) encode (XER:XER_EXTENDED)"}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_XSD_decodeXUL
//
// Purpose:
// Decodes a XUL record to its charstring representation
//
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandler_XSD_decodeXUL(in charstring pl_widgets)
runs on EPTF_UIHandler_Private_CT
return Widgets{
var Widgets vl_ret;
var integer vl_retval;
vl_retval := dec_Widgets(char2oct(pl_widgets), vl_ret);
if(0 != vl_retval){
f_EPTF_UIHandler_error(%definitionId&": The received XML is invalid, it can not be decoded fully.\n"&
"For further detailes see the log file above.")
}
return vl_ret;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_saveLayout
//
// Purpose:
// Saves the parameter charstring as a window layout.
//
// Detailed Comments:
// The layout of the window can be retreived with the function
// <f_EPTF_UIHandler_snapshot>.
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandler_saveLayout(in charstring pl_layout)
runs on EPTF_UIHandler_Private_CT{
f_EPTF_UIHandler_waitForLayoutReady();
var charstring vl_currentConfig := "\n// saved by EPTF GUI\n\n[MODULE_PARAMETERS]\n\ntsp_EPTF_GUI_DefaultWindow := """ & f_EPTF_UIHandler_convertLayout(pl_layout) & """";
var charstring vl_FileName := f_getTimeFormatted(f_time(),tsp_EPTF_savedGUIPrefix & "_%d%m%Y_%H_%M.cfg");
var integer vl_file := f_FIO_open_trunc_wronly(vl_FileName);
if(-1 != vl_file){
if(-1 == f_FIO_write_text(vl_file, vl_currentConfig)){
f_EPTF_UIHandler_warning("Couldn't write file "&vl_FileName&".");
var integer int := f_FIO_close(vl_file);
if (int == -1){
f_EPTF_UIHandler_warning("Could not close the file!");
}
// f_EPTF_Base_stop();
}else{
var integer int := f_FIO_close(vl_file);
if (int == -1){
f_EPTF_UIHandler_warning("Could not close the file!");
}
}
}else{
f_EPTF_UIHandler_warning("Couldn't open file "&vl_FileName&" for writing.");
// f_EPTF_Base_stop();
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_logAll
//
// Purpose:
// Logs all internal variables in EPTF_UIHandler_CT.
//
// Detailed Comments:
// -
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandler_logAll() runs on EPTF_UIHandler_Private_CT {
log("------Content of EPTF_UIHandler_CT: -------");
//log("v_UIHandler_CLI_initialized: ", v_UIHandler_CLI_initialized);
log("v_UIHandler_initialized: ", v_UIHandler_initialized);
log("v_UIHandler_lastRequest: ", v_UIHandler_lastRequest);
log("v_UIHandler_guiConnected: ",v_UIHandler_guiConnected);
log("v_UIHandler_windowLayout: ", v_UIHandler_windowLayout);
log("v_UIHandler_guiLayoutReady: ", v_UIHandler_guiLayoutReady);
log("v_UIHandler_guiItemList: ",v_UIHandler_guiItemList);
log("t_UIHandler_pingtimer: ",t_UIHandler_pingtimer);
log("v_UIHandler_succpingcounter: ",v_UIHandler_succpingcounter);
log("v_UIHandler_pingcounter", v_UIHandler_pingcounter);
log("v_UIHandler_prevpingcounter: ", v_UIHandler_prevpingcounter);
log("v_UIHandler_def: ",v_UIHandler_def);
log("v_UIHandler_openSubscriptions: ",v_UIHandler_openSubscriptions);
log("v_UIHandler_subscriptions: ", v_UIHandler_subscriptions);
log("v_UIHandler_windowIndex: ",v_UIHandler_windowIndex);
log("v_UIHandler_GUIClientId: ",v_UIHandler_GUIClientId);
log("v_UIHandler_lastRowId: ",v_UIHandler_lastRowId);
log("v_UIHandler_subscriptInProcess: ", v_UIHandler_subscriptInProcess);
log("t_UIHandler_bufferedXTDP: ",t_UIHandler_bufferedXTDP );
log("t_UIHandler_initGUIToClientTimer: ",t_UIHandler_initGUIToClientTimer );
log("------Finished Content of EPTF_UIHandler_CT -------");
}//f_
public function f_EPTF_UIHandler_logWidgetDB(in boolean pl_verbose := false)
runs on EPTF_UIHandler_Private_CT
return charstring{
if (not v_UIHandler_initialized){ return "" }
var charstring vl_log := ""
for ( var integer i := 0, s := sizeof(v_UIHandler_guiItemList); i < s ; i := i+1 ){
f_EPTF_UIHandler_log2strWidgetRec(i,vl_log, pl_verbose)
vl_log := vl_log & "\n";
}
return vl_log;
}
public function f_EPTF_UIHandler_log2strWidgetRec(
in integer pl_recIdx,
inout charstring pl_ret,
in boolean pl_verbose := false)
runs on EPTF_UIHandler_Private_CT{
if (not v_UIHandler_initialized){ return }
pl_ret := pl_ret&"Idx:\t"&log2str(pl_recIdx)&
"\nID:\t"&v_UIHandler_guiItemList[pl_recIdx].id&
"\nType:\t"&log2str(v_UIHandler_guiItemList[pl_recIdx].widgetType)
if(pl_verbose){
pl_ret := pl_ret & "\nData type\t"&log2str(v_UIHandler_guiItemList[pl_recIdx].widgetDataType)
}
pl_ret := pl_ret & "\nParent:\t"&log2str(v_UIHandler_guiItemList[pl_recIdx].parentIdx)&
"\nChildren:\t";
for ( var integer j:=0, sc := sizeof(v_UIHandler_guiItemList[pl_recIdx].children); j < sc ; j := j+1 ){
pl_ret := pl_ret & int2str(v_UIHandler_guiItemList[pl_recIdx].children[j])&", ";
}
if(pl_verbose){
pl_ret := pl_ret & log2str(v_UIHandler_guiItemList[pl_recIdx].widgetData);
}
//Widgets XULformat optional
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_GUIConnected
//
// Purpose:
// Returns whether the GUI is connected (authenticated)
//
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandler_GUIConnected() runs on EPTF_UIHandler_Private_CT return boolean {
return v_UIHandler_guiConnected
}
public function f_EPTF_UIHandler_initialized() runs on EPTF_UIHandler_Private_CT return boolean {
return v_UIHandler_initialized;
}//f_
friend function f_EPTF_UIHandler_guiItemList() runs on EPTF_UIHandler_Private_CT return EPTF_UIHandler_GuiItemRecList {
return v_UIHandler_guiItemList;
}
friend function f_EPTF_UIHandler_openSubscriptions() runs on EPTF_UIHandler_Private_CT return EPTF_UIHandler_OpenSubscriptions {
return v_UIHandler_openSubscriptions;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_exitButtonPressed
//
// Purpose:
// Handles the pressing of the exit button. Only for TESTING purposes!
//
// Detailed Comments:
// -
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandler_exitButtonPressed(in float pl_timeout := tsp_EPTF_UIHandler_maxWaitTimer) runs on EPTF_UIHandler_Private_CT {
if (not v_UIHandler_initialized){ return }
{
if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){
f_EPTF_UIHandler_debug(%definitionId&": Waiting for the exit button to be pressed.");
}
if(f_EPTF_Semaphore_waitForUnlock(v_UIHandler_exitButtonPressedSemaphore, pl_timeout))
{
f_EPTF_UIHandler_warning(%definitionId&": Timer timeout! Exit button was not pressed!");
}
v_UIHandler_exitButtonPressedSemaphore := f_EPTF_Semaphore_new();
//f_EPTF_Semaphore_lock(v_UIHandler_exitButtonPressedSemaphore);
};
}
} // group PublicFunctions
//=========================================================================
// Private functions
//=========================================================================
group PrivateFunctions {
private function f_EPTF_UIHandler_requestBuffer_clear()
runs on EPTF_UIHandler_Private_CT
{
v_UIHandler_RequestbufferIsEmpty := true;
v_UIHandler_Requestbuffer.data.choice.xTDP_Requests.xTDP_Request_list := { c_UIHandler_XSD_emptyXTDPRequest };
}
private function f_EPTF_UIHandler_requestBuffer_size()
runs on EPTF_UIHandler_Private_CT
return integer
{
if (v_UIHandler_RequestbufferIsEmpty) {
return 0;
} else {
return sizeof(v_UIHandler_Requestbuffer.data.choice.xTDP_Requests.xTDP_Request_list);
}
}
private function f_EPTF_UIHandler_requestBuffer_add(in ttcn_ericsson_se_protocolModules_xtdp_xtdp.XTDP_Request pl_request)
runs on EPTF_UIHandler_Private_CT
{
var integer i := 0;
if (not v_UIHandler_RequestbufferIsEmpty) {
i := sizeof(v_UIHandler_Requestbuffer.data.choice.xTDP_Requests.xTDP_Request_list);
}
v_UIHandler_Requestbuffer.data.choice.xTDP_Requests.xTDP_Request_list[i] := pl_request;
v_UIHandler_RequestbufferIsEmpty := false;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_convertLayout
//
// Purpose:
// Converts the charstring retreived by the <f_EPTF_UIHandler_snapshot>
// function to a storeable format. (Changes the ", \n and \ characters.)
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandler_convertLayout(in charstring pl_layout)
runs on EPTF_UIHandler_Private_CT
return charstring{
var charstring vl_ret := "";
var integer vl_len := lengthof(pl_layout);
for(var integer vl_i := 0; vl_i < vl_len; vl_i := vl_i + 1){
select(substr(pl_layout,vl_i,1)){
case(""""){ vl_ret := vl_ret & "\\""";}
case("\n"){ vl_ret := vl_ret & "\\n";}
case("\\"){ vl_ret := vl_ret & "\\\\";}
case else {vl_ret := vl_ret & pl_layout[vl_i];}
}
}
return vl_ret;
}
// ///////////////////////////////////////////////////////////
// // Function: f_EPTF_UIHandler_saveXul
// //
// // Purpose:
// // Saves the parameter charstring as a window layout.
// //
// // Detailed Comments:
// // The layout of the window can be retreived with the function
// // <f_EPTF_UIHandler_snapshot>.
// ///////////////////////////////////////////////////////////
// private function f_EPTF_UIHandler_saveXul(in Widgets pl_xul)
// runs on EPTF_UIHandler_Private_CT{
// var charstring vl_layout := f_EPTF_UIHandler_XSD_encodeXUL(pl_xul);
//// var charstring vl_currentConfig := f_EPTF_UIHandler_convertLayout(vl_layout);
// var charstring vl_FileName := f_getTimeFormatted(f_time(),tsp_EPTF_savedGUIPrefix & "_%d%m%Y_%H_%M.xml");
// var integer vl_file := f_FIO_open_trunc_wronly(vl_FileName);
// if(-1 != vl_file){
//// if(-1 == f_FIO_write_text(vl_file, vl_currentConfig)){
// if(-1 == f_FIO_write_text(vl_file, vl_layout)){
// f_EPTF_UIHandler_warning("Couldn't write file "&vl_FileName&".");
// var integer vl_dummy := f_FIO_close(vl_file);
// if (vl_dummy == -1){
// f_EPTF_UIHandler_warning("Could not close the file!");
// }
// // f_EPTF_Base_stop();
// }else{
// var integer vl_dummy := f_FIO_close(vl_file);
// if (vl_dummy == -1){
// f_EPTF_UIHandler_warning("Could not close the file!");
// }
// }
// }else{
// f_EPTF_UIHandler_warning("Couldn't open file "&vl_FileName&" for writing.");
// // f_EPTF_Base_stop();
// }
// }
//
// ///////////////////////////////////////////////////////////
// // Function: f_EPTF_UIHandler_saveWidgets
// //
// // Purpose:
// // Saves content of the GUI database.
// //
// // Detailed Comments:
// // -
// ///////////////////////////////////////////////////////////
// private function f_EPTF_UIHandler_saveWidgets()
// runs on EPTF_UIHandler_Private_CT{
//
// var charstring vl_widget_info := "";
// var integer limit := sizeof(v_UIHandler_guiItemList);
// for (var integer i := 0; i < limit ; i := i+1 )
// {
// vl_widget_info := vl_widget_info&"\n"&int2str(i)&" widget= "&log2str(v_UIHandler_guiItemList[i]);
// }
//
// var charstring vl_FileName := f_getTimeFormatted(f_time(),"widgetList" & "_%d%m%Y_%H_%M.xml");
// var integer vl_file := f_FIO_open_trunc_wronly(vl_FileName);
// if(-1 != vl_file){
//// if(-1 == f_FIO_write_text(vl_file, vl_currentConfig)){
// if(-1 == f_FIO_write_text(vl_file, vl_widget_info)){
// f_EPTF_UIHandler_warning("Couldn't write file "&vl_FileName&".");
// var integer vl_dummy := f_FIO_close(vl_file);
// if (vl_dummy == -1){
// f_EPTF_UIHandler_warning("Could not close the file!");
// }
// // f_EPTF_Base_stop();
// }else{
// var integer vl_dummy := f_FIO_close(vl_file);
// if (vl_dummy == -1){
// f_EPTF_UIHandler_warning("Could not close the file!");
// }
// }
// }else{
// f_EPTF_UIHandler_warning("Couldn't open file "&vl_FileName&" for writing.");
// // f_EPTF_Base_stop();
// }
// }
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_revertLayout
//
// Purpose:
// Restores the charstring converted by the <f_EPTF_UIHandler_convertLayout>
// to a charstring that can be given to
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandler_revertLayout(in charstring pl_layout)
runs on EPTF_UIHandler_Private_CT
return charstring{
var charstring vl_ret := "";
var integer vl_len := lengthof(pl_layout);
for(var integer vl_i := 0; vl_i < vl_len; vl_i := vl_i + 1){
if("\\" == substr(pl_layout,vl_i,1) and vl_i < vl_len-1){
select(substr(pl_layout,vl_i+1,1)){
case(""""){
vl_ret := vl_ret & """";
vl_i := vl_i + 1;
}
case("n"){
vl_ret := vl_ret & "\n";
vl_i := vl_i + 1;
}
case("\\"){
vl_ret := vl_ret & "\\";
vl_i := vl_i + 1;
}
case else {
f_EPTF_UIHandler_warning("Invalid \\ character in layout string at "&int2str(vl_i));
}
}
}else{
vl_ret := vl_ret & pl_layout[vl_i];
}
}
return vl_ret;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_send_XTDP
//
// Purpose:
// function to send a message to user interface via XTDP port
//
// Parameters:
// pl_msg - *in* *template ASP_XTDP* - XTDP message template ONLY one message!
//
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandler_send_XTDP(in template ASP_XSD_XTDP pl_msg) runs on EPTF_UIHandler_Private_CT
{
if (v_UIHandler_guiConnected)
{
v_UIHandler_lastRequest := v_UIHandler_lastRequest + 1;
pl_msg.data.transactionID := v_UIHandler_lastRequest;
if(ischosen(pl_msg.data.choice.xTDP_Requests))
{
pl_msg.data.choice.xTDP_Requests.xTDP_Request_list[0].requestId := v_UIHandler_lastRequest;
if (tsp_EPTF_UIHandler_bufferedXTDP != 0.0)
{
v_UIHandler_Requestbuffer.client_id := omit;
for (var integer i := 0; i < sizeof(pl_msg.data.choice.xTDP_Requests.xTDP_Request_list); i := i + 1)
{
// v_UIHandler_Requestbuffer.data.choice.xTDP_Requests.xTDP_Request_list[sizeof(v_UIHandler_Requestbuffer.data.choice.xTDP_Requests.xTDP_Request_list)] :=
// valueof(pl_msg.data.choice.xTDP_Requests.xTDP_Request_list[i]);
f_EPTF_UIHandler_requestBuffer_add(valueof(pl_msg.data.choice.xTDP_Requests.xTDP_Request_list[i]));
}
}
}
else if (ischosen(pl_msg.data.choice.xTDP_Responses))
{
pl_msg.data.choice.xTDP_Responses.xTDP_Response_list[0].requestId := v_UIHandler_lastRequest;
}
else if (ischosen(pl_msg.data.choice.xTDP_AddRequests))
{
pl_msg.data.choice.xTDP_AddRequests.xTDP_AddRequest_list[0].requestId := v_UIHandler_lastRequest;
}
else if (ischosen(pl_msg.data.choice.xTDP_RemoveRequests))
{
pl_msg.data.choice.xTDP_RemoveRequests.xTDP_RemoveRequest_list[0].requestId := v_UIHandler_lastRequest;
}
else if (ischosen(pl_msg.data.choice.xTDP_LayoutRequest))
{
//pl_msg.data.choice.xTDP_LayoutRequest.requestId := v_UIHandler_lastRequest;
}
else if (ischosen(pl_msg.data.choice.xTDP_LayoutResponse))
{
//pl_msg.data.choice.xTDP_LayoutResponse.requestId := v_UIHandler_lastRequest;
}
else if (ischosen(pl_msg.data.choice.xTDP_AuthChallenge) or ischosen(pl_msg.data.choice.xTDP_AuthResponse))
{
}
else
{
f_EPTF_UIHandler_warning("Unknown XTDP message to send!");
return;
}
if(tsp_EPTF_UIHandler_bufferedXTDP == 0.0 or ( tsp_EPTF_UIHandler_bufferedXTDP != 0.0 and not ischosen(pl_msg.data.choice.xTDP_Requests)))
{
for(var integer i := 0; i < sizeof(v_UIHandler_GUIClientId); i := i + 1)
{
var Result vl_result
f_EPTF_Transport_send(
IPL4, v_UIHandler_GUIClientId[i].clientId, f_EPTF_UIHandler_appendLength_XTDP(XTDP_EncDecFunctions.enc_XTDP_Message(valueof(pl_msg.data))), vl_result, false)
}
}
}
}
///////////////////////////////////////////////////////////
// Templates: t_UIHandler_Authmsg
//
// Purpose:
// Send template for authenticating the GUI
//
// Parameters:
// pl_client -- the GUI client
//
///////////////////////////////////////////////////////////
/*private template ASP_XTDP t_UIHandler_Authmsg(in integer pl_clientid) := {
pl_clientid,
{omit,
{xtdp_AuthChallenge := tsp_EPTF_UIHandler_Authmsg}
}
}
///////////////////////////////////////////////////////////
// Templates: t_UIHandler_Authresp
//
// Purpose:
// Receinving template for authenticating the GUI
//
///////////////////////////////////////////////////////////
private template ASP_XTDP t_UIHandler_Authresp := {
*,
{omit,
{xtdp_AuthResponse := ?}
}
}
*/
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_authclient
//
// Purpose:
// Authenticates the client.
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandler_authclient(in integer pl_clientid) runs on EPTF_UIHandler_Private_CT return boolean{
if (tsp_EPTF_UIHandler_Authmsg=="" or v_EPTF_UIHandler_Authresp == "") {
// no authentication needed
f_EPTF_UIHandler_setClientAuthenticationSuccessful(pl_clientid);
return true;
}
v_UIHandler_lastRequest := v_UIHandler_lastRequest +1;
var integer vl_UIHandler_authResponseReceivedSemaphore := f_EPTF_Semaphore_new();
var ttcn_ericsson_se_protocolModules_xtdp_xtdp.XTDP_Message vl_messageToSend :=
{
vl_UIHandler_authResponseReceivedSemaphore+1000*v_UIHandler_lastRequest,
{xTDP_AuthChallenge := tsp_EPTF_UIHandler_Authmsg}
}
var Result vl_result
f_EPTF_Transport_send(IPL4, pl_clientid, f_EPTF_UIHandler_appendLength_XTDP(XTDP_EncDecFunctions.enc_XTDP_Message(vl_messageToSend)), vl_result, false)
if(f_EPTF_Semaphore_waitForUnlock(vl_UIHandler_authResponseReceivedSemaphore, v_authMaxTime))
{
f_EPTF_UIHandler_warning(%definitionId&": Timer timeout! No auth response received!");
f_EPTF_Semaphore_unlock(v_UIHandler_xtdpReceivedMessageSemaphore_r);
return false;
}
//f_EPTF_Semaphore_lock(v_UIHandler_authResponseReceivedSemaphore);
f_EPTF_Semaphore_unlock(v_UIHandler_xtdpReceivedMessageSemaphore_r);
if(v_UIHandler_receivedMessage.choice.xTDP_AuthResponse == v_EPTF_UIHandler_Authresp)
{
if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){
f_EPTF_UIHandler_debug(%definitionId&": Authentication successful for client: "&log2str(pl_clientid));
}
f_EPTF_UIHandler_setClientAuthenticationSuccessful(pl_clientid);
return true;
}
else
{
f_EPTF_UIHandler_warning("Authentication failed for client: "&log2str(pl_clientid));
return false;
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_headlessmode
//
// Purpose:
// Sets the enviroment for the headless mode
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandler_headlessmode() runs on EPTF_UIHandler_Private_CT{
if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){
f_EPTF_UIHandler_debug("******** HeadlessMode*******");
}
if (not v_EPTF_UIHandler_servermode){
v_UIHandler_pingcounter := 0;
v_UIHandler_prevpingcounter := 0;
v_UIHandler_succpingcounter := 0;
if(not t_UIHandler_pingtimer.running) {
t_UIHandler_pingtimer.start;
}
} else {
f_EPTF_UIHandler_startserverxtdp();
}
v_UIHandler_guiConnected := false;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_headlessmodeover
//
// Purpose:
// Restores the enviroment returning back from headless mode
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandler_headlessmodeover() runs on EPTF_UIHandler_Private_CT{
if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){
f_EPTF_UIHandler_debug("*********HeadlessModeOVER********")
}
if (not v_EPTF_UIHandler_servermode){
if (t_UIHandler_pingtimer.running) {
t_UIHandler_pingtimer.stop;
}
v_UIHandler_pingcounter := 0;
v_UIHandler_prevpingcounter := 0;
v_UIHandler_succpingcounter := 0;
var ConnectionId vl_connId;
f_EPTF_UIHandler_connectAndInitGui(vl_connId);
//In case of v_EPTF_UIHandler_servermode, the f_EPTF_UIHandler_connectAndInitGui
//simply returns true
//} else {
// if (not f_EPTF_UIHandler_connectAndInitGui()){
// f_EPTF_UIHandler_error("Failed to initialize the GUI!");
// }
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_sendSubscAck
//
// Purpose:
// Sends acknowladgement message about a succesfully completed subscription note
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandler_sendSubscAck(
in integer pl_requestId,
in integer pl_varIdx,
in EPTF_Var_CT pl_sender,
in boolean pl_ack := true)
runs on EPTF_UIHandler_Private_CT {
v_UIHandler_subscriptInProcess := false;
var EPTF_UIHandler_WidgetMsg vl_EPTF_CLL_UISubscMgmtMsg := {
subscribeAck := {
requestId := pl_requestId,
varIdx := pl_varIdx}};
EPTF_adminPort_CP.send(vl_EPTF_CLL_UISubscMgmtMsg) to pl_sender
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_sendSubscNAck
//
// Purpose:
// Sends an refusion message about a subscription note
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandler_sendSubscNAck(
in integer pl_requestId,
in EPTF_Var_CT pl_sender)
runs on EPTF_UIHandler_Private_CT {
v_UIHandler_subscriptInProcess := false;
var EPTF_UIHandler_WidgetMsg vl_EPTF_CLL_UISubscMgmtMsg := {
subscribeNAck := {
requestId := pl_requestId,
varIdx := -1
}
};
EPTF_adminPort_CP.send(vl_EPTF_CLL_UISubscMgmtMsg) to pl_sender;
}
///////////////////////////////////////////////////////////
// Group: EPTF_SubscriptionAdministrationFunctions
///////////////////////////////////////////////////////////
group EPTF_SubscriptionAdministrationFunctions{
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_newSubscription
//
// Purpose:
// Appends an EPTF_UIHandler_OpenSubscription record to the <EPTF_UIHandler_OpenSubscriptions> list.
//
// Parameters:
// pl_subscription - *in* *EPTF_UIHandler_OpenSubscription* - The record to append.
//
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandler_newSubscription(in EPTF_UIHandler_OpenSubscription pl_subscription)
runs on EPTF_UIHandler_Private_CT
{
var integer vl_newIdx := sizeof(v_UIHandler_openSubscriptions);
v_UIHandler_openSubscriptions[vl_newIdx] := pl_subscription;
f_EPTF_UIHandler_addSubscription(pl_subscription.varIdx, vl_newIdx);
if (pl_subscription.providedParamName != "") {
f_EPTF_str2int_HashMap_Insert(v_UIHandler_subscriptionHashMapIdVar, pl_subscription.providedParamName, pl_subscription.varIdx);
}
if (pl_subscription.widgetId != "") {
f_EPTF_str2int_HashMap_Insert(v_UIHandler_subscriptionHashMapId, pl_subscription.widgetId, vl_newIdx);
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_getSubscriptionsByVarIdx
//
// Purpose:
// Retrieves a list of open subscriptions that are affected by the specified variable.
//
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandler_getSubscriptionsByVarIdx(in integer pl_varIdx, out EPTF_UIHandler_OpenSubscriptions pl_ret)
runs on EPTF_UIHandler_Private_CT
return boolean{
var EPTF_IntegerList vl_subs := f_EPTF_UIHandler_getSubscriptions(pl_varIdx);
pl_ret := {};
for(var integer vl_i := 0; vl_i < sizeof(vl_subs); vl_i := vl_i+1){
pl_ret[sizeof(pl_ret)] := v_UIHandler_openSubscriptions[vl_subs[vl_i]];
}
return sizeof(pl_ret) > 0;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_getSubscriptionIdxByWidgetId
//
// Return Value:
// The index of the open subscription that contains the specified widgetId or -1.
//
///////////////////////////////////////////////////////////
friend function f_EPTF_UIHandler_getSubscriptionIdxByWidgetId(in EPTF_UIHandler_WidgetIdString pl_widgetId)
runs on EPTF_UIHandler_Private_CT
return integer{
if("" == pl_widgetId){
if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){
f_EPTF_UIHandler_debug(%definitionId&": No subscription belongs to empty ID!");
}
return -1;
}
// find id in subscription hashmap
var integer vl_idx;
if (f_EPTF_str2int_HashMap_Find(v_UIHandler_subscriptionHashMapId, pl_widgetId, vl_idx)) {
return vl_idx;
}
return -1;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_getVarIdxByProvidedVarName
//
// Return Value:
// The index of the open subscription that contains the
// specified client variable name.
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandler_getVarIdxByProvidedVarName(in charstring pl_varName)
runs on EPTF_UIHandler_Private_CT
return integer{
if("" == pl_varName){
if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){
f_EPTF_UIHandler_debug(%definitionId&": No subscription belongs to empty variable name!");
}
return -1;
}
// find id in subscription hashmap
var integer vl_idx;
if (f_EPTF_str2int_HashMap_Find(v_UIHandler_subscriptionHashMapIdVar, pl_varName, vl_idx)) {
return vl_idx;
}
return -1;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_addSubscription
//
// Purpose:
// Adds a subscription item to a variable
//
// Parameters:
// pl_idx - *in* *integer* - the idx of the EPTF_Var
// pl_subsIdx - *in* *integer* - subscription identifier index
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandler_addSubscription(in integer pl_idx, in integer pl_subsIdx)
runs on EPTF_UIHandler_Private_CT
{
if(sizeof(v_UIHandler_subscriptions) <= pl_idx or not isbound(v_UIHandler_subscriptions[pl_idx])) {
v_UIHandler_subscriptions[pl_idx] := {};
}
v_UIHandler_subscriptions[pl_idx][sizeof(v_UIHandler_subscriptions[pl_idx])] := pl_subsIdx;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_removeSubscription
//
// Purpose:
// Removes a subscription item from a variable
//
// Parameters:
// pl_idx - *in* *integer* - the idx of the EPTF_Var
// pl_subsIdx - *in* *integer* - subscription identifier index
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandler_removeSubscription(in integer pl_idx, in integer pl_subsIdx)
runs on EPTF_UIHandler_Private_CT
{
f_EPTF_Base_assert(%definitionId&": not a local subscription.",
sizeof(v_UIHandler_subscriptions) > pl_idx and isbound(v_UIHandler_subscriptions[pl_idx]));
var integer vl_subIdx := -1;
for (var integer i := 0; i < sizeof(v_UIHandler_subscriptions[pl_idx]); i := i + 1)
{
if (v_UIHandler_subscriptions[pl_idx][i] == pl_subsIdx)
{
vl_subIdx := i;
break;
}
}
if (vl_subIdx != -1)
{
var EPTF_IntegerList vl_newSubs := {};
for (var integer i := 0; i < sizeof(v_UIHandler_subscriptions[pl_idx]); i := i + 1)
{
if (vl_subIdx != i) { vl_newSubs[sizeof(vl_newSubs)] := v_UIHandler_subscriptions[pl_idx][i]; }
}
v_UIHandler_subscriptions[pl_idx] := vl_newSubs;
return;
}
f_EPTF_UIHandler_warning(log2str("The variable: ", f_EPTF_Var_getName(pl_idx), " has no subscription: ", pl_subsIdx));
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_getSubscriptions
//
// Purpose:
// Gets the subscription indices of a variable
//
// Parameters:
// pl_idx - *in* *integer* - the idx of the EPTF_Var
//
// Return Value:
// <EPTF_IntegerList> - the list of subscripton indices of the variable
//
// Errors:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandler_getSubscriptions(in integer pl_idx)
runs on EPTF_UIHandler_Private_CT return EPTF_IntegerList
{
if (sizeof(v_UIHandler_subscriptions) <= pl_idx or
not isbound(v_UIHandler_subscriptions[pl_idx])) {
return {};
}
return v_UIHandler_subscriptions[pl_idx];
}
} //EPTF_SubscriptionAdministrationFunctions group
///////////////////////////////////////////////////////////
// Group: EPTF_WidgetAdministrationFunctions
///////////////////////////////////////////////////////////
group EPTF_WidgetAdministrationFunctions{
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_widgetTypeFromId
//
// Purpose:
// Gets the type of a widget
// Detailed Comments:
// There are two main cases:
// the widget ID describes a cell of a tree in form "name of the tree".[row].[column], or
// the ID is the widget's own ID
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandler_widgetTypeFromId(
in EPTF_UIHandler_WidgetIdString pl_id,
inout EPTF_UIHandler_OpenSubscription pl_subs)
runs on EPTF_UIHandler_Private_CT
return boolean{
// cehck if id refers a table cell in format "treeId.[row].[col]"
var integer vl_row, vl_col;
var EPTF_UIHandler_WidgetIdString vl_treeId;
if (f_EPTF_UIHandler_isTreeCellIdFormat(pl_id, vl_treeId, vl_row, vl_col)) {
var EPTF_UIHandler_GuiItemRec widgetRec;
if(f_EPTF_UIHandler_getWidgetRec(vl_treeId, widgetRec)){
if(vl_col <= sizeof(widgetRec.widgetData.treeData.columns)){
pl_subs.widgetType := wtTreecell;
pl_subs.widgetDataType := v_UIHandler_guiItemList[widgetRec.widgetData.treeData.columns[vl_col]].widgetDataType;
return true;
}
}
}else{
var EPTF_UIHandler_GuiItemRec widgetRec;
if(f_EPTF_UIHandler_getWidgetRec(pl_id, widgetRec)){
pl_subs.widgetType := widgetRec.widgetType;
//The cell also contains widgetDataType
pl_subs.widgetDataType := widgetRec.widgetDataType;
return true;
}
}
return false;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_checkSubscriptCompatibility
// Purpose:
// Checks whether the subscriptable variable and the widget
// are compatible
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandler_checkSubscriptCompatibility(
in EPTF_UIHandler_WidgetIdString pl_widgetid,
in integer pl_varIdx,
in EPTF_Var_DirectContent pl_currentContent := {unknownVal:={omit}})
runs on EPTF_UIHandler_Private_CT
return boolean{
var integer vl_index := f_EPTF_UIHandler_widgetRecIndex(pl_widgetid);
if (vl_index==-1) {
f_EPTF_UIHandler_error("The specified '"&pl_widgetid&"' widget can not be connected to variable["&f_EPTF_Var_getName(pl_varIdx)&"]: widget not found!");
return false;
}
var EPTF_Var_DirectContent vl_currentContent := pl_currentContent;
var boolean vl_retval;
var boolean vl_checkReverse := false;
if (ischosen(vl_currentContent.unknownVal)) {
f_EPTF_Var_getContent(pl_varIdx,vl_currentContent);
}
select(v_UIHandler_guiItemList[vl_index].widgetType){
case(wtWindow, // nothing to check NOW
wtTabbox,
wtTabs,
wtTab,
wtTabpanels,
wtTabpanel,
wtTabpages,
wtTabpage,
wtTree,
wtTreecols,
wtTreecol,
wtTreechildren,
wtTreeitem,
wtTreerow,
wtHbox,
wtLabel,
wtSpacer,
wtChart,
wtTraceList,
wtToolbar,
wtToolbarbuttons,
wtSeparator,
wtListbox,
wtListitem,
wtNumericalwidget,
wtMenulist,
wtMenuitem,
wtDistributionchart,
wtIntervallimits,
wtValuelist,
wtImage,
wtUnknown){
vl_retval := true;
}
case(wtTreecell){
vl_checkReverse := true;
select(v_UIHandler_guiItemList[vl_index].widgetDataType){
case(checkBox){vl_retval := ischosen(vl_currentContent.boolVal)}
case(toggleButton){vl_retval := ischosen(vl_currentContent.boolVal)}
case(floatField){vl_retval := ischosen(vl_currentContent.floatVal)}
case(pushButton, integerField){vl_retval := ischosen(vl_currentContent.intVal)}
case(string){ vl_retval := ischosen(vl_currentContent.charstringVal)
or ischosen(vl_currentContent.floatVal)
or ischosen(vl_currentContent.intVal)
/* string forever */
or ischosen(vl_currentContent.bitstringVal) or ischosen(vl_currentContent.hexstringVal) or ischosen(vl_currentContent.octetstringVal)
or ischosen(vl_currentContent.boolVal)
or ischosen(vl_currentContent.statusLEDVal)
or ischosen(vl_currentContent.integerlistVal) or ischosen(vl_currentContent.floatlistVal) or ischosen(vl_currentContent.charstringlistVal)
}
case(statusLED){vl_retval := ischosen(vl_currentContent.statusLEDVal)
/* its not equal, because type without are make errror on runtime gui if returned with text,
text but better if this equal this time just no returned text on request
and (ispresent(vl_currentContent.statusLEDVal.text)==false or vl_currentContent.statusLEDVal.text == "") */; }
case(statusLEDWithText){vl_retval := ischosen(vl_currentContent.statusLEDVal)}
case else { }
}
}
case (wtButton){
vl_retval := ischosen(vl_currentContent.intVal);
}
case (wtPushbutton){
vl_retval := ischosen(vl_currentContent.intVal);
}
case(wtTextbox){vl_retval := true; } // string forever
case(wtHtmlcode){vl_retval := true; } // string forever
case(wtTrace){
vl_retval := (ischosen(vl_currentContent.floatVal) or ischosen(vl_currentContent.intVal));
}
case (wtToolbarbutton, wtTogglebutton){
vl_retval := ischosen(vl_currentContent.boolVal);
}
case else {
vl_retval := true; // all other are true now
}
}
if(isbound(vl_retval)==false) {
f_EPTF_UIHandler_error("The specified '"&pl_widgetid&"' widget with data("&log2str(v_UIHandler_guiItemList[vl_index])&") not match to variable["&f_EPTF_Var_getName(pl_varIdx)&"]: type incompatibility!");
} else if(vl_retval == false) {
f_EPTF_UIHandler_error("The specified '"&pl_widgetid&"' widget with data("&log2str(v_UIHandler_guiItemList[vl_index])&") can not be connected to variable["&f_EPTF_Var_getName(pl_varIdx)&"]: type incompatibility!");
}
else {
if(vl_checkReverse == true and ispresent( v_UIHandler_guiItemList[vl_index].widgetDataType)) {
vl_retval := f_EPTF_UIHandler_checkVariableCompatibility(vl_currentContent, v_UIHandler_guiItemList[vl_index].widgetDataType);
}
if(vl_retval == false) {
f_EPTF_UIHandler_error("The specified variable["&f_EPTF_Var_getName(pl_varIdx)&"] can not be connected to specified '"&pl_widgetid&"' widget with data("&log2str(v_UIHandler_guiItemList[vl_index])&"): type incompatibility!");
}
}
return vl_retval;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_checkVariableCompatibility
// Purpose:
// Checks whether the the requeted variable and the widget
// type are compatible
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandler_checkVariableCompatibility(
in EPTF_Var_DirectContent pl_currentContent,
in Widgettype pl_currentwidgetDataType)
runs on EPTF_UIHandler_Private_CT
return boolean{
var boolean vl_retval := false;
if(ischosen(pl_currentContent.intVal)) {
vl_retval := (pl_currentwidgetDataType == integerField)
or (pl_currentwidgetDataType == pushButton)
or (pl_currentwidgetDataType == trace)
or (pl_currentwidgetDataType == string); // string forever
}
else
if(ischosen(pl_currentContent.floatVal)) {
vl_retval := (pl_currentwidgetDataType == floatField)
or (pl_currentwidgetDataType == string); // string forever
}
else
if(ischosen(pl_currentContent.charstringVal)) {
vl_retval := (pl_currentwidgetDataType == string)
or (pl_currentwidgetDataType == image);
}
else
if(ischosen(pl_currentContent.bitstringVal) or ischosen(pl_currentContent.hexstringVal) or ischosen(pl_currentContent.octetstringVal)) {
vl_retval := (pl_currentwidgetDataType == string);
}
else
if(ischosen(pl_currentContent.boolVal)) {
vl_retval := (pl_currentwidgetDataType == checkBox)
or (pl_currentwidgetDataType == toggleButton)
or (pl_currentwidgetDataType == string); // string forever
}
else
if(ischosen(pl_currentContent.statusLEDVal)) {
vl_retval := (pl_currentwidgetDataType == statusLED)
or (pl_currentwidgetDataType == statusLEDWithText)
or (pl_currentwidgetDataType == string); // string forever
}
else
if(ischosen(pl_currentContent.integerlistVal) or ischosen(pl_currentContent.floatlistVal) or ischosen(pl_currentContent.charstringlistVal)) {
vl_retval := (pl_currentwidgetDataType == valueList)
or (pl_currentwidgetDataType == string); // string forever
}
// If not matched
if(vl_retval == false) {
vl_retval := (pl_currentwidgetDataType == image)
or (pl_currentwidgetDataType == none_);
}
return vl_retval;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_handleSubscriptNote
// Purpose:
// Handles te subscription note message
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandler_handleSubscriptNote(
in EPTF_UIHandler_SubscribeNoteMsg pl_msg,
in EPTF_Var_CT pl_sender)
runs on EPTF_UIHandler_Private_CT {
v_UIHandler_subscriptInProcess := true;
var EPTF_UIHandler_OpenSubscription vl_subs := c_UIHandler_defOpenSubscription;
var integer vl_varIdx := -1;
if(ispresent(pl_msg.destParamName) and "" != pl_msg.destParamName){
//we must create a new variable and subscribe it to a provided param
//check if it already exists
if(not f_EPTF_Var_checkName(pl_msg.destParamName,vl_varIdx)) // i.e. vl_varIdx != -1
{
f_EPTF_UIHandler_warning("CLL_UIHandler: the destination variable already exists: " & pl_msg.destParamName);
f_EPTF_UIHandler_sendSubscNAck(pl_msg.messageId, pl_sender);
return;
}
//log("DEBUG: ","------- subscribeRemote ------- ",pl_msg.providedParamName);
//In case of error the remote variable stops the test
f_EPTF_Var_subscribeRemote(
pl_msg.remoteCompRef,
pl_msg.providedParamName,
pl_msg.subsMode,
vl_varIdx,
pl_msg.destParamName,
pl_msg.refreshRate);
f_EPTF_Var_addPostProcFn(vl_varIdx, {refers(f_EPTF_UIHandler_refreshVar),{}});
// FIXME: test
// FIXME: This should be put back if old gui build using SubsCanAdjust is working:
//f_EPTF_Var_addSubsCanAdjustNotifyFn(vl_varIdx, {refers(f_EPTF_UIHandler_updateDisableStateByVarIdx), {}});
}else{
//There is no destParamName, so it's an ealrier subscription
//Get the index of the variable
vl_varIdx := f_EPTF_UIHandler_getVarIdxByProvidedVarName(pl_msg.providedParamName);
if(-1 == vl_varIdx){
f_EPTF_UIHandler_warning("CLL_UIHandler: there is no subscription to the variable: " & pl_msg.providedParamName);
f_EPTF_UIHandler_sendSubscNAck(pl_msg.messageId, pl_sender);
return;
}
}
if(ispresent(pl_msg.widgetId)){
if (f_EPTF_UIHandler_Config_connectToWidget(pl_msg.widgetId,vl_varIdx,pl_msg.remoteCompRef,pl_msg.providedParamName)) {
// FIXME: This should be put back if old gui build using SubsCanAdjust is working:
//f_EPTF_UIHandler_updateDisableStateByVarIdx(vl_varIdx, {});
f_EPTF_UIHandler_sendSubscAck(pl_msg.messageId, vl_varIdx, pl_sender);
} else {
f_EPTF_UIHandler_sendSubscNAck(pl_msg.messageId, pl_sender);
}
return;
} else {
vl_subs.widgetId := "";
}
vl_subs.provider := pl_msg.remoteCompRef;
vl_subs.varIdx := vl_varIdx;
vl_subs.providedParamName:=pl_msg.providedParamName;
//FIXME!!!Check compatibility
f_EPTF_UIHandler_newSubscription(vl_subs);
f_EPTF_UIHandler_sendSubscAck(pl_msg.messageId, vl_varIdx, pl_sender);
if(ispresent(pl_msg.widgetId)){
f_EPTF_UIHandler_refreshWidget(vl_subs, true);
// FIXME: This should be put back if old gui build using SubsCanAdjust is working:
//f_EPTF_UIHandler_updateDisableStateByVarIdx(vl_varIdx, {});
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_refreshVar
//
// Purpose:
// Postproc. The component refreshes the content of the GUI
// when the content of the variable changes
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandler_refreshVar(in integer pl_idx, in EPTF_IntegerList pl_argList)
runs on EPTF_UIHandler_Private_CT {
if (not v_UIHandler_initialized) {
return;
}
var EPTF_UIHandler_OpenSubscriptions vl_subsList;
if (not f_EPTF_UIHandler_getSubscriptionsByVarIdx(pl_idx, vl_subsList)){
f_EPTF_UIHandler_warning("The subscriptionlist is empty for this variable!");
}
for(var integer vl_i := 0; vl_i < sizeof(vl_subsList); vl_i := vl_i+1){
//Put the received value to the screen. It can differ from the typed value.
//log("DEBUG: ","---- postproc - ",vl_subsList[vl_i].widgetId, " - ", v_EPTF_Vars[vl_subsList[vl_i].varIdx].content.direct);
f_EPTF_UIHandler_refreshWidget(vl_subsList[vl_i]);
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_removeWidgetFromSubscription
// Purpose:
// Clears the widgetId member of the open subscription associated
// with the specified widget.
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandler_removeWidgetFromSubscription(in EPTF_UIHandler_WidgetIdString pl_widgetId)
runs on EPTF_UIHandler_Private_CT
return boolean{
var integer vl_idx := f_EPTF_UIHandler_getSubscriptionIdxByWidgetId(pl_widgetId);
if(-1 == vl_idx){
return false;
}
f_EPTF_str2int_HashMap_Erase(v_UIHandler_subscriptionHashMapId, pl_widgetId);
v_UIHandler_openSubscriptions[vl_idx].widgetId := "";
return true;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_removeIdFromIdList
// Purpose:
// Removes an integer from an integer list.
//
// Return Value:
// A new list of integers without gaps and the specified integer.
//
// Detailed Comments:
// The function handles only unique integers.
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandler_removeIdFromIdList(in EPTF_IntegerList pl_in, in integer pl_idx)
return EPTF_IntegerList{
var EPTF_IntegerList vl_ret := {};
var integer vl_i := 0;
while(vl_i < sizeof(pl_in)){
if(pl_in[vl_i] != pl_idx){
vl_ret[sizeof(vl_ret)] := pl_in[vl_i];
}
vl_i := vl_i + 1;
}
return vl_ret;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_addIdx2IdxList
// Purpose:
// Simply append an integer to an integer list.
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandler_addIdx2IdxList(inout EPTF_IntegerList pl_in, in integer pl_idx){
pl_in[sizeof(pl_in)] := pl_idx;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_insertIdx2IdxList
// Purpose:
// Insert a new integer into an integer list in a specific index
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandler_insertIdx2IdxList(inout EPTF_IntegerList pl_in, in integer pl_idx, in integer pl_value){
for ( var integer i := sizeof(pl_in)-1; i >= pl_idx ; i := i-1 ) {
pl_in[i+1] := pl_in[i];
}
pl_in[pl_idx] := pl_value;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_IdxListContains
// Return Value:
// True if the integerlist contains the specified value.
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandler_IdxListContains(in EPTF_IntegerList pl_in, in integer pl_idx)
return boolean{
for(var integer vl_i := 0; vl_i < sizeof(pl_in); vl_i := vl_i + 1){
if(pl_in[vl_i] == pl_idx){return true;}
}
return false;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_parentColOfCell
// Purpose:
// Retrieves the GUI index of the column into which the cell is placed
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandler_parentColOfCell(in integer pl_parent)
runs on EPTF_UIHandler_Private_CT
return integer{
if(-1 == pl_parent){return -1;}
var integer vl_i := pl_parent;
while(vl_i != -1 and v_UIHandler_guiItemList[vl_i].widgetType != wtTreecol){
vl_i := v_UIHandler_guiItemList[vl_i].parentIdx;
}
if(vl_i != -1 and v_UIHandler_guiItemList[vl_i].widgetType == wtTreecol){
return vl_i;
}
return -1;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_addWidgetRec
// Purpose:
// Adds the specified record about a widget to the list
// of the widgets.
//
// Return Value:
// The index of the new record if succes, or -1
//
// Detailed Comments:
// If there is already a widget with the same id with the
// same type under the same parent, the function returns
// the index of the previous widget, and sets the pl_widgetExists to true.
// If pl_indexInParent parameter is given (not -1), widgetrec is placed
// to that position in parents' childrenlist.
// This is needed for tree column insertion.
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandler_addWidgetRec(
in EPTF_UIHandler_GuiItemRec pl_widgetRec,
inout boolean pl_widgetExists/*,
in integer pl_indexInParent := -1*/)
runs on EPTF_UIHandler_Private_CT
return integer{
if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){
f_EPTF_UIHandler_debug(%definitionId&": "&log2str(pl_widgetRec));
}
pl_widgetExists := false;
//Checking the index of the parent item. Less than 0 is valid for the main window.
if(pl_widgetRec.parentIdx> sizeof(v_UIHandler_guiItemList) or
(pl_widgetRec.parentIdx < 0 and (pl_widgetRec.widgetType != wtWindow))){
f_EPTF_UIHandler_warning("Invalid parent index for the widget "&pl_widgetRec.id&".");
return -1;
}
//If the parent widget from the pl_widgetRec.parentIdx is a tabpages, then pl_widgetRec.widgetType can only be a tabpage,
//else warning and return -1
if( ((pl_widgetRec.parentIdx > -1) and pl_widgetRec.widgetType != wtTabpage and pl_widgetRec.widgetType != wtMetaIterator) and v_UIHandler_guiItemList[pl_widgetRec.parentIdx].widgetType == wtTabpages){
f_EPTF_UIHandler_warning("Under a tabpages widget only widgets with type tabpage is allowed: "&pl_widgetRec.id&".");
return -1;
}
var boolean vl_xuldisabled := false;
if(ispresent(pl_widgetRec.xuldisabled)){
vl_xuldisabled := pl_widgetRec.xuldisabled;
}
var EPTF_UIHandler_GuiItemRec vl_newRec := {
id := pl_widgetRec.id,
widgetType := pl_widgetRec.widgetType,
widgetDataType := pl_widgetRec.widgetDataType,
parentIdx := pl_widgetRec.parentIdx,
children := {},
widgetData := pl_widgetRec.widgetData,
XULformat := pl_widgetRec.XULformat,
xuldisabled := vl_xuldisabled
};
//Checking ID
var integer vl_idx;
var boolean vl_isexisting := (pl_widgetRec.id != "" and f_EPTF_str2int_HashMap_Find(v_UIHandler_widgetHashMapId, pl_widgetRec.id, vl_idx));
var integer vl_prevIdx := -1;
if(pl_widgetRec.XULformat != omit and ischosen(pl_widgetRec.XULformat.treecell)){
var Treecell vl_treecell := pl_widgetRec.XULformat.treecell;
vl_treecell.id := omit;
vl_prevIdx := f_EPTF_UIHandler_widgetRecIndex(pl_widgetRec.id, f_EPTF_UIHandler_deleteChildrenFromTreecell(vl_treecell));
} else {
vl_prevIdx := f_EPTF_UIHandler_widgetRecIndex(pl_widgetRec.id);
}
if(vl_isexisting == true){ // old -1 != vl_prevIdx
f_EPTF_UIHandler_setWidgetOriginalDisabled(vl_prevIdx); // Set original [xul] disabled state
if(v_UIHandler_customGUIProcess){
f_EPTF_UIHandler_error(%definitionId&": Duplicate widget ID: "& pl_widgetRec.id&"\nThe GUI descriptor is: "&log2str("v_UIHandler_widgetslist"));
}else{
var integer vl_row, vl_col;
var EPTF_UIHandler_WidgetIdString vl_treeId;
if (not f_EPTF_UIHandler_isTreeCellIdFormat(pl_widgetRec.id, vl_treeId, vl_row, vl_col)){
pl_widgetExists := true;
}
if(v_UIHandler_guiItemList[vl_prevIdx].widgetType != pl_widgetRec.widgetType or
v_UIHandler_guiItemList[vl_prevIdx].parentIdx != pl_widgetRec.parentIdx){
if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){
f_EPTF_UIHandler_debug(%definitionId&": Duplicate widget ID: "& pl_widgetRec.id);
}
return -1;
}else{
//There is a similar widget
return vl_prevIdx;
}
}
}
if(-1 == vl_prevIdx){
var integer vl_newIdx := sizeof(v_UIHandler_guiItemList);
v_UIHandler_guiItemList[vl_newIdx] := vl_newRec;
if(vl_newRec.widgetType != wtMetaIterator) {
if( v_UIHandler_actualParentIdxIsFilled == false) {
//window's parent is -1, but getNonMeta gives 0 back, because window has 0 id
if(vl_newRec.widgetType != wtWindow){
v_UIHandler_actualParentIdx := f_EPTF_UIHAndler_getNotMetaiteratorParentIdx(vl_newIdx);
} else {
v_UIHandler_actualParentIdx := pl_widgetRec.parentIdx;
}
v_UIHandler_actualParentIdxIsFilled := true
v_UIHandler_widgetIdxList[sizeof(v_UIHandler_widgetIdxList)] := vl_newIdx;
} else if( v_UIHandler_actualParentIdx == f_EPTF_UIHAndler_getNotMetaiteratorParentIdx(vl_newIdx) or
/*because tabpagelist: put all tabpagelist element, if same it has parent as the first tabpage element*/
( v_UIHandler_actualParentIdx != -1 and vl_newRec.widgetType == wtTabpage and
f_EPTF_UIHAndler_getNotMetaiteratorParentIdx(v_UIHandler_guiItemList[vl_newIdx].parentIdx) ==
f_EPTF_UIHAndler_getNotMetaiteratorParentIdx(v_UIHandler_guiItemList[v_UIHandler_actualParentIdx].parentIdx)
)
) {
v_UIHandler_widgetIdxList[sizeof(v_UIHandler_widgetIdxList)] := vl_newIdx;
}
}
// add widget id to the widgetId map
if (vl_newRec.id != "") {
f_EPTF_str2int_HashMap_Insert(v_UIHandler_widgetHashMapId, vl_newRec.id, vl_newIdx);
}
//Add to its parent's childrenlist
if(-1 != vl_newRec.parentIdx){
//if (pl_indexInParent <0) {
v_UIHandler_guiItemList[vl_newRec.parentIdx].children[sizeof(v_UIHandler_guiItemList[vl_newRec.parentIdx].children)] := vl_newIdx;
//}
//else {
// f_EPTF_UIHandler_insertIdx2IdxList(v_UIHandler_guiItemList[vl_newRec.parentIdx].children, pl_indexInParent, vl_newIdx);
// }
}
f_EPTF_UIHandler_setWidgetOriginalDisabled(vl_newIdx); // Set original [xul] disabled state
return vl_newIdx;
} else {
return vl_prevIdx;
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_removeWidgetRecByName
// Purpose:
// Removes the specified record about a widget from the list
// of the widgets. See <f_EPTF_UIHandler_removeWidgetRecByIdx>.
//
// Return Value:
// True if succes, false otherwise.
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandler_removeWidgetRecByName(in EPTF_UIHandler_WidgetIdString pl_widgetId)
runs on EPTF_UIHandler_Private_CT
return boolean{
var integer vl_recIdx := f_EPTF_UIHandler_widgetRecIndex(pl_widgetId);
if(-1 == vl_recIdx){
return false;
}
return f_EPTF_UIHandler_removeWidgetRecByIdx(vl_recIdx);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_removeWidgetRecByIdx
// Purpose:
// Removes the specified record about a widget from the list
// of the widgets.
//
// Return Value:
// True if succes, false otherwise.
//
// Detailed Comments:
// Removes also the children of the widget from the list.
// Removes the index of the widget too from the children's list
// of the parent of the specified widget.
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandler_removeWidgetRecByIdx(in integer pl_recIdx)
runs on EPTF_UIHandler_Private_CT
return boolean {
f_EPTF_Base_assert(%definitionId&": Boundary check failed - invalid widget record index",
pl_recIdx >= 0 and pl_recIdx < sizeof(v_UIHandler_guiItemList));
var boolean vl_ret := true;
//Check if there was an open connection
var integer vl_connIdx := f_EPTF_UIHandler_getSubscriptionIdxByWidgetId(v_UIHandler_guiItemList[pl_recIdx].id);
if(-1 != vl_connIdx){
f_EPTF_str2int_HashMap_Erase(v_UIHandler_subscriptionHashMapId, v_UIHandler_openSubscriptions[vl_connIdx].widgetId);
v_UIHandler_openSubscriptions[vl_connIdx].widgetId := "";
}
//parse children
var EPTF_IntegerList vl_children := v_UIHandler_guiItemList[pl_recIdx].children;
for(var integer vl_i := 0; vl_i < sizeof(vl_children); vl_i := vl_i + 1){
if(vl_children[vl_i]> -1){
vl_ret := vl_ret and f_EPTF_UIHandler_removeWidgetRecByIdx(vl_children[vl_i]);
}
}
//remove from the childlist of its parent
if(-1 != v_UIHandler_guiItemList[pl_recIdx].parentIdx){
v_UIHandler_guiItemList[v_UIHandler_guiItemList[pl_recIdx].parentIdx].children :=
f_EPTF_UIHandler_removeIdFromIdList(v_UIHandler_guiItemList[v_UIHandler_guiItemList[pl_recIdx].parentIdx].children,pl_recIdx);
}
// delete widgetId from hashmap
if (v_UIHandler_guiItemList[pl_recIdx].id != "") {
f_EPTF_str2int_HashMap_Erase(v_UIHandler_widgetHashMapId, v_UIHandler_guiItemList[pl_recIdx].id);
}
//clear record
v_UIHandler_guiItemList[pl_recIdx] := c_UIHandler_emptyGUIItem;
return vl_ret;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_widgetRecIndex
// Return Value:
// The index of the <EPTF_UIHandler_GuiItemRec> that describes the
// specified widget, or -1.
///////////////////////////////////////////////////////////
friend function f_EPTF_UIHandler_widgetRecIndex(
in EPTF_UIHandler_WidgetIdString pl_id, //The ID of the widget
in Treecell pl_treecell := {omit, omit, omit, omit, omit, omit, omit, omit}
)
runs on EPTF_UIHandler_Private_CT
return integer{
var integer vl_idx := 0;
// check if empty id
if("" == pl_id){
if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){
f_EPTF_UIHandler_debug(%definitionId&": widgetRecIndex with empty ID!");
}
return -1;
}
// try to find id in internal database
if (f_EPTF_str2int_HashMap_Find(v_UIHandler_widgetHashMapId, pl_id, vl_idx)) {
return vl_idx;
}
// // check if id refers a table cell in format "treeId.[row].[col]"
// var integer vl_row, vl_col;
// var EPTF_UIHandler_WidgetIdString vl_treeId;
// if (f_EPTF_UIHandler_isTreeCellIdFormat(pl_id, vl_treeId, vl_row, vl_col)) {
// if (f_EPTF_str2int_HashMap_Find(v_UIHandler_widgetHashMapId, vl_treeId, vl_idx) and
// v_UIHandler_guiItemList[vl_idx].widgetType == wtTree)
// {
// var integer vl_colNum := sizeof(v_UIHandler_guiItemList[vl_idx].widgetData.treeData.columns);
// if (vl_col < vl_colNum) {
// var EPTF_UIHandler_GuiItemRec vl_newRec := {
// pl_id,
// wtTreecell,
// v_UIHandler_guiItemList[v_UIHandler_guiItemList[vl_idx].widgetData.treeData.columns[vl_col]].widgetDataType,
// vl_idx,
// {},
// {cellData := {v_UIHandler_guiItemList[vl_idx].widgetData.treeData.columns[vl_col], omit}},
// { treecell := pl_treecell}};
// var integer vl_newIdx := sizeof(v_UIHandler_guiItemList);
// v_UIHandler_guiItemList[vl_newIdx] := vl_newRec;
// if (vl_newRec.id != "") {
// f_EPTF_str2int_HashMap_Insert(v_UIHandler_widgetHashMapId, vl_newRec.id, vl_newIdx);
// }
// f_EPTF_UIHandler_setWidgetOriginalDisabled(vl_newIdx); // Set original [xul] disabled state
// //Add to its parent's childrenlist
// if(-1 != vl_newRec.parentIdx){
// v_UIHandler_guiItemList[vl_newRec.parentIdx].children[sizeof(v_UIHandler_guiItemList[vl_newRec.parentIdx].children)] := vl_newIdx;
// }
// return vl_newIdx;
// }
// }
// }
return -1;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_isTreeCellIdFormat
//
// Purpose:
// Private function to check whether a widgetId is given in specail table cell format (treeId.[row].[column]),
// and gives back treeId, row, column if possible
// Parameters:
// pl_widgetRec - *out* EPTF_UIHandler_GuiItemRec - The <EPTF_UIHandler_GuiItemRec> that describes the specified widget
// pl_id - *in* EPTF_UIHandler_WidgetIdString - The input widget Id string
// pl_treeId - *out* EPTF_UIHandler_WidgetIdString - The id of the table
// pl_row - *out* integer pl_row - The row number of the cell
// pl_col - *out* integer - The column number of the cell
// Return Value:
// True if widgetId is in special format, false otherwise
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandler_isTreeCellIdFormat(
in EPTF_UIHandler_WidgetIdString pl_id,
out EPTF_UIHandler_WidgetIdString pl_treeId,
out integer pl_row,
out integer pl_col )
return boolean {
// this function matches pattern "*.[0-9]+.[0-9]+" but without using the unefficient regexp
// reset out parameters
pl_treeId := "";
pl_row := 0;
pl_col := 0;
var integer i := lengthof(pl_id)-1, vl_limiterIdx1 := -1, vl_limiterIdx2 := -1;
// check last char is a number
if ( char2int(pl_id[i])<char2int("0") or char2int(pl_id[i])>char2int("9") ) {
return false;
}
// find first '.' from back in Id
for (i := i-1; pl_id[i] != "." and i>=3; i := i-1) {
if (char2int(pl_id[i])<char2int("0") or char2int(pl_id[i])>char2int("9")) {
return false;
}
}
if (i<3) {
return false;
}
vl_limiterIdx1 := i;
// check next char is a number
i := i-1;
if ( char2int(pl_id[i])<char2int("0") or char2int(pl_id[i])>char2int("9") ) {
return false;
}
// find second '.' from back in Id
for (i := i-1; pl_id[i] != "." and i>=1; i := i-1) {
if (char2int(pl_id[i])<char2int("0") or char2int(pl_id[i])>char2int("9")) {
return false;
}
}
if (i<1) {
return false;
}
vl_limiterIdx2 := i;
// obtain column number
pl_col := str2int(substr(pl_id, vl_limiterIdx1+1, lengthof(pl_id)-vl_limiterIdx1-1));
// obtain row number
pl_row := str2int(substr(pl_id, vl_limiterIdx2 + 1, vl_limiterIdx1 - vl_limiterIdx2 - 1));
// obtain tree id
pl_treeId := substr(pl_id, 0, vl_limiterIdx2);
return true;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_getWidgetRec
// Parameters:
// pl_widgetRec - *out* EPTF_UIHandler_GuiItemRec - The <EPTF_UIHandler_GuiItemRec> that describes the specified widget
//
// Return Value:
// True if success, false otherwise.
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandler_getWidgetRec(
in EPTF_UIHandler_WidgetIdString pl_widgetId,
out EPTF_UIHandler_GuiItemRec pl_widgetRec)
runs on EPTF_UIHandler_Private_CT
return boolean{
var integer vl_idx := f_EPTF_UIHandler_widgetRecIndex(pl_widgetId);
pl_widgetRec := c_UIHandler_emptyGUIItem;
if(-1 < vl_idx){
pl_widgetRec := v_UIHandler_guiItemList[vl_idx];
return true;
}
return false;
}
} //EPTF_WidgetAdministrationFunctions group
///////////////////////////////////////////////////////////
// Group: EPTF_WidgetAddInternalFunctions
///////////////////////////////////////////////////////////
group EPTF_WidgetAddInternalFunctions{
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandler_addElementToTree
//
// Purpose:
// Private function to look through a Tree when adding an column or item or row or cell to it.
//
// Parameters:
// pl_parentWidgetId *integer*
// pl_xul *XTDP_XML_Tag*
// pl_currentTree <Tree>
//
// Return Value:
// *boolean*
//
// Errors:
// none
//
// Detailed Comments:
// Returns true if pl_xul has been added to pl_currentTree.
//
///////////////////////////////////////////////////////////
/*private function f_EPTF_UIHandler_addElementToTree(
in EPTF_UIHandler_WidgetIdString pl_parentWidgetId,
in Widgets pl_xul,
inout ttcn_ericsson_se_protocolModules_xtdp_xtdl.Tree pl_currentTree)
runs on EPTF_UIHandler_Private_CT
return boolean {
if(pl_currentTree.id == pl_parentWidgetId) {
// init the one-and-only treeitem (treechildren[0]):
if(sizeof(pl_currentTree.treechildren.treeitemgroups.treeitemgroup_list) == 0) {
pl_currentTree.treechildren.treeitemgroups.treeitemgroup_list[0].treeitem.treerowgroups.treerowgroup_list := {};
}
select( true )
{
case (ischosen (pl_xul.treecol)) {
pl_currentTree.treecols.treecolgroups.treecolgroup_list[sizeof(pl_currentTree.treecols.treecolgroups.treecolgroup_list)].treecol := pl_xul.treecol;
return true;
}
case (ischosen (pl_xul.treecols)) {
for(var integer col := 0; col < sizeof(pl_xul.treecols.treecolgroups.treecolgroup_list); col := col + 1) {
if(ischosen(pl_xul.treecols.treecolgroups.treecolgroup_list[col].treecol)){
pl_currentTree.treecols.treecolgroups.treecolgroup_list[sizeof(pl_currentTree.treecols.treecolgroups.treecolgroup_list)].treecol := pl_xul.treecols.treecolgroups.treecolgroup_list[col].treecol;
}else{
f_EPTF_UIHandler_warning(%definitionId&": Invalid element to be added: "&log2str(pl_xul.treecols.treecolgroups.treecolgroup_list[col]));
return false;
}
}
return true;
}
case (ischosen (pl_xul.treerow)) {
pl_currentTree.treechildren.treeitemgroups.treeitemgroup_list[0].treeitem.treerowgroups.treerowgroup_list[sizeof(pl_currentTree.treechildren.treeitemgroups.treeitemgroup_list[0].treeitem.treerowgroups.treerowgroup_list)].treerow := pl_xul.treerow;
return true;
}
case (ischosen (pl_xul.treecell)) {
var integer vl_rowCount := 0;