blob: 18e92e7f95b299b54690f1d3e5e494826c8941d5 [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_StatHandlerUI_Functions
//
// Purpose:
// This module contains the implementation of the StatHandlerUI.
//
// Module depends on:
// <EPTF_CLL_Base_Functions>
// <EPTF_CLL_Common_Definitions>
// <EPTF_CLL_LoggingUI_Definitions>
// <EPTF_CLL_LoggingUIClient_Functions>
// <EPTF_CLL_Semaphore_Functions>
// <EPTF_CLL_StatHandler_Definitions>
// <EPTF_CLL_StatHandler_Functions>
// <EPTF_CLL_StatHandlerClient_Definitions>
// <EPTF_CLL_StatHandlerClient_Functions>
// <EPTF_CLL_StatHandlerLogging_Functions>
// <EPTF_CLL_StatHandlerUI_Definitions>
// <EPTF_CLL_UIHandler_Definitions>
// <EPTF_CLL_UIHandlerClient_Definitions>
// <EPTF_CLL_UIHandlerClient_Functions>
// <EPTF_CLL_Variable_Definitions>
// <EPTF_CLL_Variable_Functions>
// <XTDP_PDU_Defs>
//
// Module Parameters:
// -
//
// Current Owner:
// Gabor Tatarka (EGBOTAT)
//
// Last Review Date:
// -
//
// Detailed Comments:
// This module contains the implementation of the StatHandlerUI.
// Public API:
// - f_EPTF_StatHandlerUI_init_CT
// - f_EPTF_StatHandlerClientUI_init_CT
// - f_EPTF_StatHandlerClientUI_bindStatToWidget
//
///////////////////////////////////////////////////////////////
module EPTF_CLL_StatHandlerUI_Functions {
import from EPTF_CLL_Base_Functions all;
import from EPTF_CLL_Common_Definitions all;
import from EPTF_CLL_LoggingUI_Definitions all;
import from EPTF_CLL_LoggingUIClient_Functions all;
import from EPTF_CLL_StatHandler_Definitions all;
import from EPTF_CLL_StatHandler_Functions all;
import from EPTF_CLL_StatHandlerClient_Functions all;
import from EPTF_CLL_StatHandlerLogging_Functions all;
import from EPTF_CLL_StatHandlerUI_Definitions all;
import from EPTF_CLL_UIHandler_Definitions all;
import from EPTF_CLL_UIHandlerClient_Functions all;
import from EPTF_CLL_Variable_Definitions all;
import from EPTF_CLL_Variable_Functions all;
group StatHandlerUI {
///////////////////////////////////////////////////////////
// Function: f_EPTF_StatHandlerUI_init_CT
//
// Purpose:
// Init function for component type <EPTF_StatHandlerUI_CT>
//
// Parameters:
// pl_selfName - *in* *charstring* - EPTF self name
// pl_uiParentWidgetId - *in* *charstring* - ID of the parent widget where StatHandlerUI shall create the GUI
// pl_uiHandler_compRef - *in* <EPTF_UIHandler_CT> - component reference to the UIHandler
// pl_loggingUi_compRef - *in* <EPTF_LoggingUI_CT> - component reference to the LoggingUI, optional
// pl_localResetButtonUIVarName - *in* *charstring* - variable name of the local reset button, optional
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
// Only one instnace will actually create the tabpanel, etc. on the GUI,
// subsequently initialized instances will only subscribe to the global reset button.
// The local reset button is added to the appropriate tree by each instance if
// pl_localResetButtonUIVarName is an empty string (default). If pl_localResetButtonUIVarName is
// specified, the StatHandlerUI will subscribe to that variable. This variable must be
// on the GUI component, refered by pl_uiHandler_compRef.
//
///////////////////////////////////////////////////////////
public function f_EPTF_StatHandlerUI_init_CT(
in charstring pl_selfName,
in charstring pl_uiParentWidgetId, //TODO not used any more, remove
in EPTF_UIHandler_CT pl_uiHandler_compRef,
in EPTF_LoggingUI_CT pl_loggingUi_compRef := null,
in charstring pl_localResetButtonUIVarName := "")
runs on EPTF_StatHandlerUI_CT
{
if(v_EPTF_StatHandlerUI_initialized) { return; }
v_EPTF_StatHandlerUI_initialized := true;
if(pl_loggingUi_compRef != null) {
f_EPTF_LoggingUIClient_init_CT(pl_selfName, pl_loggingUi_compRef, pl_uiHandler_compRef);
} else {
f_EPTF_UIHandlerClient_init_CT(pl_selfName, pl_uiHandler_compRef);
}
f_EPTF_StatHandlerLogging_init_CT(
pl_selfName,
c_EPTF_StatHandler_loggingComponentMask,
tsp_debug_EPTF_StatHandler);
f_EPTF_StatHandler_registerBindStatToWidgetCallbackFn(refers(f_EPTF_StatHandlerUI_bindStatToWidget));
f_EPTF_StatHandler_init_CT(pl_selfName);
f_EPTF_Base_registerCleanup(refers(f_EPTF_StatHandlerUI_cleanup_CT));
}
} // group StatHandlerUI
group StatHandlerClientUI {
///////////////////////////////////////////////////////////
// Function: f_EPTF_StatHandlerClientUI_init_CT
//
// Purpose:
// Init function for component type <EPTF_StatHandlerClientUI_CT>
//
// Parameters:
// pl_selfName - *in* *charstring* - EPTF self name
// pl_statHandler_compRef - *in* <EPTF_StatHandler_CT> - default StatHandler master component reference, optional
// pl_uiHandler_compRef - *in* <EPTF_UIHandler_CT> - component reference to the UIHandler, optional
// pl_loggingUi_compRef - *in* <EPTF_LoggingUI_CT> - component reference to the LoggingUI, optional
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
public function f_EPTF_StatHandlerClientUI_init_CT(
in charstring pl_selfName,
in EPTF_StatHandler_CT pl_statHandler_compRef := null,
in EPTF_UIHandler_CT pl_uiHandler_compRef:= null,
in EPTF_LoggingUI_CT pl_loggingUi_compRef := null)
runs on EPTF_StatHandlerClientUI_CT
{
if(v_EPTF_StatHandlerClientUI_initialized) { return; }
v_EPTF_StatHandlerClientUI_initialized := true;
if(pl_uiHandler_compRef != null and pl_loggingUi_compRef != null) {
f_EPTF_LoggingUIClient_init_CT(pl_selfName, pl_loggingUi_compRef, pl_uiHandler_compRef);
} else if(pl_uiHandler_compRef != null) {
f_EPTF_UIHandlerClient_init_CT(pl_selfName, pl_uiHandler_compRef);
}
f_EPTF_StatHandlerClient_init_CT(pl_selfName, pl_statHandler_compRef);
f_EPTF_Base_registerCleanup(refers(f_EPTF_StatHandlerClientUI_cleanup_CT));
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_StatHandlerClientUI_bindStatToWidget
//
// Purpose:
// Function for requesting a master component to bind a stat to a widget on the GUI
//
// Parameters:
// pl_statName - *in* *charstring* - name of the stat
// pl_widgetId - *in* *charstring* - widget ID
// pl_statHandler_compRef - *in* <EPTF_StatHandler_CT> - StatHandler master component reference, optional
// pl_wait4response - *in* *boolean* - whether the client shall wait for the response
// pl_additionalWidget - *in* *boolean* - if widget is an additional widget
// pl_subscriptionMode - *in* <EPTF_Var_SubscriptionMode> - the Var subscription mode to use
// pl_refreshRate - *in integer* - the refresh rate to use for the subscription (default: 0 == default syncInterval)
//
// Return Value:
// *boolean* - true on success
//
// Errors & assertions:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
public function f_EPTF_StatHandlerClientUI_bindStatToWidget(
in charstring pl_statName,
in charstring pl_widgetId,
in EPTF_StatHandler_CT pl_statHandler_compRef := null,
in boolean pl_wait4response := true,
in boolean pl_additionalWidget := false,
in EPTF_Var_SubscriptionMode pl_subscriptionMode := sampledAtSync,
in integer pl_refreshRate := 0)
runs on EPTF_StatHandlerClientUI_CT
return boolean
{
var EPTF_StatHandler_CT vl_master := f_EPTF_StatHandlerClient_getDefaultMasterCompRef();
if(pl_statHandler_compRef != null) { vl_master := pl_statHandler_compRef; }
var EPTF_StatHandler_MgmtMsg_Request vl_request := {
sIdx := -1,
request := {
bindStatToWidget := {
statName := pl_statName,
widgetId := pl_widgetId,
additionalWidget := pl_additionalWidget,
subscriptionMode := pl_subscriptionMode,
refreshRate := pl_refreshRate
}
}
}
if(not pl_wait4response) {
f_EPTF_StatHandlerClient_sendRequest(vl_request, vl_master);
return true;
} else {
var EPTF_StatHandler_MgmtMsg_Response vl_response;
f_EPTF_StatHandlerClient_sendReqRecvResp(
vl_master,
vl_request,
vl_response
);
return vl_response.response.statusResp.result;
}
}
} // group StatHandlerClientUI
///////////////////////////////////////////////////////////
// Group: Private
//
// Purpose:
// Private functions used by StatHandlerUI.
//
// Detailed Comments:
// Do not call the functions within this group form outside of StatHandlerUI.
//
///////////////////////////////////////////////////////////
group Private {
// TODO: add naturaldocs comments for private functions
private function f_EPTF_StatHandlerUI_cleanup_CT()
runs on EPTF_StatHandlerUI_CT
{
if(not v_EPTF_StatHandlerUI_initialized) {
f_EPTF_StatHandlerLogging_debug(%definitionId&": not yet initialized");
return;
}
v_EPTF_StatHandlerUI_resetButtonContent := 0;
v_EPTF_StatHandlerUI_initialized := false;
}
private function f_EPTF_StatHandlerClientUI_cleanup_CT()
runs on EPTF_StatHandlerClientUI_CT
{
if(not v_EPTF_StatHandlerClientUI_initialized) {
f_EPTF_StatHandlerLogging_debug(%definitionId&": not yet initialized");
return;
}
v_EPTF_StatHandlerClientUI_initialized := false;
}
private function f_EPTF_StatHandlerUI_resetButtonPressed(in integer pl_idx, in EPTF_IntegerList pl_argList)
runs on EPTF_StatHandlerUI_CT
{
// f_EPTF_StatHandlerLogging_debug(%definitionId&": "&log2str(pl_idx));
var integer vl_resetButtonVarIdx := f_EPTF_Var_getId(f_EPTF_StatHandler_genUniqueName(c_EPTF_StatHandler_ResetVarName));
if(vl_resetButtonVarIdx >= 0) {
v_EPTF_StatHandlerUI_resetButtonContent := v_EPTF_StatHandlerUI_resetButtonContent + 1;
f_EPTF_Var_adjustContent(vl_resetButtonVarIdx,
{intVal := v_EPTF_StatHandlerUI_resetButtonContent});
}
}
private function f_EPTF_StatHandlerUI_bindStatToWidget(
in charstring pl_statName,
in charstring pl_widgetId,
in boolean pl_additionalWidget,
in EPTF_Var_SubscriptionMode pl_subscriptionMode,
in integer pl_refreshRate)
runs on EPTF_StatHandlerUI_CT
return boolean
{
var charstring vl_varName;
if (not f_EPTF_StatHandler_getVarNameByStatName(pl_statName, vl_varName)){
return false;
}
var charstring vl_guiVarName;
if (pl_additionalWidget) {
vl_guiVarName := "";
} else {
vl_guiVarName := f_EPTF_StatHandlerUI_genGuiVarName(vl_varName)
}
f_EPTF_UIHandlerClient_subscribeMe(
vl_varName,
vl_guiVarName,
pl_widgetId,
pl_subscriptionMode,
pl_refreshRate);
return true;
}
private function f_EPTF_StatHandlerUI_genGuiVarName(in charstring pl_name)
runs on EPTF_StatHandlerUI_CT
return charstring
{
return c_EPTF_StatHandlerUI_guiVarNamePrefix &
f_EPTF_StatHandler_getNameSeparator() &
pl_name;
}
} // group Private
} // end of module