blob: a54b950fa9fcfaab14ce577c2ed0dc4c956a1802 [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_UIHandlerClient_Functions
//
// Purpose:
// This module contains the implementation of generic CLL_UIHandlerClient functions.
//
// Module depends on:
// <EPTF_CLL_UIHandler_MsgDefinitions>
// <EPTF_CLL_UIHandlerClient_Definitions>
// <EPTF_CLL_UIHandler_Definitions>
// <EPTF_CLL_Variable_Functions>
// <EPTF_CLL_Base_Functions>
// <EPTF_CLL_Semaphore_Functions>
// <EPTF_CLL_Logging_Definitions>
// <EPTF_CLL_Logging_Functions>
//
// Current Owner:
// Laszlo Skumat (ELSZSKU)
//
// Last Review Date:
// 2007-xx-xx
//
// Detailed Comments:
// This module contains the interface functions for the EPTF_UIHandlerClient_CT.
//
///////////////////////////////////////////////////////////////
module EPTF_CLL_UIHandlerClient_Functions
// [.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_UIHandlerClient_Definitions all;
import from EPTF_CLL_UIHandler_Definitions all;
import from EPTF_CLL_Variable_Definitions all;
import from EPTF_CLL_Variable_Functions all;
import from EPTF_CLL_Base_Functions all;
import from EPTF_CLL_Semaphore_Functions all;
import from EPTF_CLL_Logging_Definitions all;
import from EPTF_CLL_Logging_Functions all;
import from ttcn_ericsson_se_protocolModules_xtdp_xtdl all;
import from EPTF_CLL_UIHandler_ConvertFunctions all;
//=========================================================================
// Module Parameters
//=========================================================================
modulepar boolean tsp_debug_EPTF_UIHandlerClient_Functions := false;
modulepar float tsp_EPTF_UIHandlerClient_MaxWaitTime := 3.0;
//=========================================================================
// Functions
//=========================================================================
group Public_Functions{
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_init_CT
//
// Purpose:
// Initialises the EPTF_UIHandlerClient_CT component
//
// Parameters:
// pl_selfName - *in* *charstring* - The name of the component.
// pl_DefaultUIHandler - *in* <EPTF_UIHandler_CT> - The default UIHandler
//
// Detailed Comments:
// This function should be called before using the EPTF_UIHandlerClient_CT
// component. It initializes the extended EPTF_Var_CT component.
// If you use only one UIHandler, you can use the version of
// subscription functions where there are no subscriber in the parameter list. That
// functions will use the default UIHandler as subscriber.
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandlerClient_init_CT(
in charstring pl_selfName,
in EPTF_UIHandler_CT pl_DefaultUIHandler) runs on EPTF_UIHandlerClient_CT {
if (v_UIHandlerClient_initialized) {
return;
}
f_EPTF_Var_init_CT(pl_selfName);
f_EPTF_Semaphore_init_CT(pl_selfName);
f_EPTF_Logging_init_CT(pl_selfName);
v_UIHandlerClient_loggingMaskId := f_EPTF_Logging_registerComponentMasks(
tsp_EPTF_UIHandlerClient_loggingComponentMask,
c_EPTF_UIHandler_loggingEventClasses,
EPTF_Logging_CLL);
if(tsp_debug_EPTF_UIHandlerClient_Functions) {
f_EPTF_Logging_enableLocalMask(v_UIHandlerClient_loggingMaskId, c_EPTF_UIHandler_loggingClassIdx_Debug);
} else {
f_EPTF_Logging_disableLocalMask(v_UIHandlerClient_loggingMaskId, c_EPTF_UIHandler_loggingClassIdx_Debug);
}
v_UIHandlerClient_pendingMsgCounter := 0;
v_UIHandlerClient_hangingConnections := {};
v_UIHandlerClient_openUIConnections := {};
v_UIHandlerClient_subsRetList := {};
v_UIHandlerClient_widgetExistsRespList := {};
v_UIHandlerClient_DefaultUIHandler := pl_DefaultUIHandler;
v_UIHandlerClient_def := activate(as_handle_main_EPTF_UIHandlerClient_MgmtIf());
v_UIHandlerClient_initialized := true;
// register cleanup function
f_EPTF_Base_registerCleanup(refers(f_EPTF_UIHandlerClient_cleanup_CT));
// log("DEBUG: ","----CLL_UIHandlerClient INIT DONE----");
f_EPTF_UIHandlerClient_debug("----CLL_UIHandlerClient INIT DONE----");
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_defaultUIHandler
// Purpose:
// Returns the default UIHandler component
//
// Detailed Comments:
// See <f_SendSubscribeNoteTo>
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandlerClient_defaultUIHandler()
runs on EPTF_UIHandlerClient_CT return EPTF_UIHandler_CT {
return v_UIHandlerClient_DefaultUIHandler;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_subscribeMe
// Purpose:
// Orders the default UIHandler to subscribe to a specified variable
// on this component and optionally connect to a widget
//
// Detailed Comments:
// See <f_SendSubscribeNoteTo>
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandlerClient_subscribeMe (
in charstring pl_providedParamName,
in charstring pl_destParamName := "",
in EPTF_UIHandler_WidgetIdString pl_widgetId := "",
in EPTF_Var_SubscriptionMode pl_subsMode := timeLine,
in integer pl_refreshRate := -1)
runs on EPTF_UIHandlerClient_CT{
f_EPTF_UIHandlerClient_subscribeMeTo(
v_UIHandlerClient_DefaultUIHandler,
pl_providedParamName,
pl_destParamName,
pl_widgetId,
pl_subsMode,
pl_refreshRate);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_subscribeMeTo
// Purpose:
// Orders an UIHandler to subscribe to a specified variable
// on this component and optionally connect to a widget
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandlerClient_subscribeMeTo (
in EPTF_UIHandler_CT pl_subscriber,
in charstring pl_providedParamName,
in charstring pl_destParamName := "",
in EPTF_UIHandler_WidgetIdString pl_widgetId := "",
in EPTF_Var_SubscriptionMode pl_subsMode := timeLine,
in integer pl_refreshRate := -1)
runs on EPTF_UIHandlerClient_CT{
f_EPTF_UIHandlerClient_subscribeTo(
v_UIHandlerClient_DefaultUIHandler,
self,
pl_providedParamName,
pl_destParamName,
pl_widgetId,
pl_subsMode,
pl_refreshRate);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_subscribe
// Purpose:
// Orders the default UIHandler to subscribe to a specified variable
// on a specified component and optionally connect to a widget
//
// Detailed Comments:
// See <f_SendSubscribeNoteTo>
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandlerClient_subscribe (
in EPTF_Var_CT pl_remoteCompRef,
in charstring pl_providedParamName,
in charstring pl_destParamName := "",
in EPTF_UIHandler_WidgetIdString pl_widgetId := "",
in EPTF_Var_SubscriptionMode pl_subsMode := timeLine,
in integer pl_refreshRate := -1)
runs on EPTF_UIHandlerClient_CT{
f_EPTF_UIHandlerClient_subscribeTo(
v_UIHandlerClient_DefaultUIHandler,
pl_remoteCompRef,
pl_providedParamName,
pl_destParamName,
pl_widgetId,
pl_subsMode,
pl_refreshRate);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_subscribeTo
// Purpose:
// Orders an UIHandler to subscribe to a specified variable
// on a specified component and optionally connect to a widget
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandlerClient_subscribeTo (
in EPTF_UIHandler_CT pl_subscriber,
in EPTF_Var_CT pl_remoteCompRef,
in charstring pl_providedParamName,
in charstring pl_destParamName := "",
in EPTF_UIHandler_WidgetIdString pl_widgetId := "",
in EPTF_Var_SubscriptionMode pl_subsMode := timeLine,
in integer pl_refreshRate := -1)
runs on EPTF_UIHandlerClient_CT{
if (v_UIHandlerClient_maxTimeoutReached) {
return;
}
var integer vl_semaphoreId := f_EPTF_Semaphore_new();
var integer vl_msgId := vl_semaphoreId;//f_EPTF_UIHandlerClient_getMsgId();
f_EPTF_UIHandlerClient_addVarConnection(
pl_subscriber,
pl_providedParamName,
vl_msgId);
v_UIHandlerClient_pendingMsgCounter := v_UIHandlerClient_pendingMsgCounter + 1;
v_UIHandlerClient_adminPortIf.send({
subscribeNoteMsg := {
remoteCompRef := pl_remoteCompRef,
providedParamName := pl_providedParamName,
destParamName := pl_destParamName,
widgetId := pl_widgetId,
subsMode := pl_subsMode,
messageId := vl_msgId,
refreshRate := pl_refreshRate
}
}) to pl_subscriber;
// wait until subscribe finishes
if(f_EPTF_Semaphore_waitForUnlock(vl_semaphoreId,tsp_EPTF_UIHandlerClient_MaxWaitTime)) {
f_EPTF_UIHandlerClient_debug(log2str(%definitionId&
": MaxWaitTime expired. No reponse received for subscribeNoteMsg with Id ",vl_semaphoreId, ". Going on..."));
v_UIHandlerClient_maxTimeoutReached := true;
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_subscribeVariable
// Purpose:
// Orders the default UIHandler to subscribe to a specified variable
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandlerClient_subscribeVariable(
in charstring pl_providedParamName,
in charstring pl_destParamName,
in EPTF_Var_SubscriptionMode pl_subsMode := timeLine,
in integer pl_refreshRate := -1)
runs on EPTF_UIHandlerClient_CT{
f_EPTF_UIHandlerClient_subscribeVariableTo(
v_UIHandlerClient_DefaultUIHandler,
pl_providedParamName,
pl_destParamName,
pl_subsMode,
pl_refreshRate);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_subscribeVariableTo
// Purpose:
// Orders an UIHandler to subscribe to a specified variable
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandlerClient_subscribeVariableTo (
in EPTF_UIHandler_CT pl_subscriber,
in charstring pl_providedParamName,
in charstring pl_destParamName,
in EPTF_Var_SubscriptionMode pl_subsMode := timeLine,
in integer pl_refreshRate := -1)
runs on EPTF_UIHandlerClient_CT{
if (v_UIHandlerClient_maxTimeoutReached) {
return;
}
var integer vl_semaphoreId := f_EPTF_Semaphore_new();
var integer vl_msgId := vl_semaphoreId;//f_EPTF_UIHandlerClient_getMsgId();
f_EPTF_UIHandlerClient_addVarConnection(pl_subscriber, pl_providedParamName, vl_msgId);
v_UIHandlerClient_pendingMsgCounter := v_UIHandlerClient_pendingMsgCounter + 1;
v_UIHandlerClient_adminPortIf.send({
subscribeNoteMsg := {
remoteCompRef := self,
providedParamName := pl_providedParamName,
destParamName := pl_destParamName,
widgetId := omit,
subsMode := pl_subsMode,
messageId := vl_semaphoreId,
refreshRate := pl_refreshRate
}
}) to pl_subscriber;
// wait until subscribe finishes
if (f_EPTF_Semaphore_waitForUnlock(vl_semaphoreId,tsp_EPTF_UIHandlerClient_MaxWaitTime)) {
// max wait time expired, no response received
f_EPTF_UIHandlerClient_debug(log2str(%definitionId&
": MaxWaitTime expired. No reponse received for subscribeNoteMsg with Id ",vl_semaphoreId, ". Going on..."));
v_UIHandlerClient_maxTimeoutReached := true;
}
}
// XSD begin
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_XSD_addElementToGUI
// Purpose:
// Orders the default UIHandler to add a widget to the runtime GUI
// connected to the UIHandler
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandlerClient_XSD_addElementToGUI(
in Widgets pl_xul,
in EPTF_UIHandler_WidgetIdString pl_parentWidgetId)
runs on EPTF_UIHandlerClient_CT
return EPTF_UIHandlerClient_SubsRet{
return f_EPTF_UIHandlerClient_XSD_addElementToGUITo( pl_xul, pl_parentWidgetId, v_UIHandlerClient_DefaultUIHandler );
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_XSD_addElementToGUITo
// Purpose:
// Orders an UIHandler to add a widget to the runtime GUI
// connected to the UIHandler
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandlerClient_XSD_addElementToGUITo(
in Widgets pl_xul,
in EPTF_UIHandler_WidgetIdString pl_parentWidgetId,
in EPTF_UIHandler_CT pl_UIHandler)
runs on EPTF_UIHandlerClient_CT
return EPTF_UIHandlerClient_SubsRet{
if (v_UIHandlerClient_maxTimeoutReached) {
return sr_Fail;
}
var integer vl_semaphoreId := f_EPTF_Semaphore_new();
f_EPTF_UIHandlerClient_connectUIHandler(pl_UIHandler);
v_UIHandlerClient_pendingMsgCounter := v_UIHandlerClient_pendingMsgCounter + 1;
v_UIHandlerClient_adminPortIf.send(
t_UIHandler_AdminAddElementToGUI(
pl_parentWidgetId,
vl_semaphoreId,
pl_xul)) to pl_UIHandler;
// wait until reponse is received:
if (f_EPTF_Semaphore_waitForUnlock(vl_semaphoreId,tsp_EPTF_UIHandlerClient_MaxWaitTime)) {
f_EPTF_UIHandlerClient_debug(log2str(%definitionId&
": MaxWaitTime expired. No reponse received for AddElementToGUI with Id ",vl_semaphoreId, ". Going on..."));
v_UIHandlerClient_maxTimeoutReached := true;
return sr_Fail; // max wait timer expired, no response received in time
}
return v_UIHandlerClient_subsRetList[vl_semaphoreId];
}
// XSD end
///////////////////////////////////////////////////////////
// Altstep: as_EPTF_UIHandlerClient_handleAddElementToGUIResp
// Purpose:
// Handles the responses to AddElementToGUI
///////////////////////////////////////////////////////////
private altstep as_EPTF_UIHandlerClient_handleAddElementToGUIResp() runs on EPTF_UIHandlerClient_CT {
var EPTF_UIHandler_WidgetMsg vl_msg;
[] v_UIHandlerClient_adminPortIf.receive(t_UIHandler_AdminAddElementToGUIAck(?,?))-> value vl_msg{
v_UIHandlerClient_pendingMsgCounter := v_UIHandlerClient_pendingMsgCounter - 1;
if(vl_msg.addElementToGUIAck.widgetExists){
v_UIHandlerClient_subsRetList[vl_msg.addElementToGUIAck.messageID] := sr_Exists;
}else{
v_UIHandlerClient_subsRetList[vl_msg.addElementToGUIAck.messageID] := sr_Success;
}
f_EPTF_Semaphore_unlock(vl_msg.addElementToGUIAck.messageID);
repeat;
};
[] v_UIHandlerClient_adminPortIf.receive(t_UIHandler_AdminAddElementToGUINAck(?))-> value vl_msg{
v_UIHandlerClient_pendingMsgCounter := v_UIHandlerClient_pendingMsgCounter - 1;
v_UIHandlerClient_subsRetList[vl_msg.addElementToGUINAck.messageID] := sr_Fail;
f_EPTF_Semaphore_unlock(vl_msg.addElementToGUINAck.messageID);
repeat;
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_removeElementFromGUI
// Purpose:
// Orders the default UIHandler to remove a widget from the runtime GUI
// connected to the UIHandler
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandlerClient_removeElementFromGUI(
in EPTF_UIHandler_WidgetIdString pl_Widget2Remove)
runs on EPTF_UIHandlerClient_CT{
f_EPTF_UIHandlerClient_removeElementFromGUITo( pl_Widget2Remove, v_UIHandlerClient_DefaultUIHandler );
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_removeElementFromGUITo
// Purpose:
// Orders an UIHandler to remove a widget from the runtime GUI
// connected to the UIHandler
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandlerClient_removeElementFromGUITo(
in EPTF_UIHandler_WidgetIdString pl_Widget2Remove,
in EPTF_UIHandler_CT pl_UIHandler)
runs on EPTF_UIHandlerClient_CT{
if (v_UIHandlerClient_maxTimeoutReached) {
return;
}
f_EPTF_UIHandlerClient_connectUIHandler(pl_UIHandler);
v_UIHandlerClient_pendingMsgCounter := v_UIHandlerClient_pendingMsgCounter + 1;
v_UIHandlerClient_adminPortIf.send(t_UIHandler_AdminRemoveElementFromGUI(pl_Widget2Remove,f_EPTF_UIHandlerClient_getMsgId())) to pl_UIHandler;
/* alt{ */
/* [] v_UIHandlerClient_adminPortIf.receive(t_UIHandler_AdminRemoveElementFromGUIAck(?)){}; */
/* [] v_UIHandlerClient_adminPortIf.receive(t_UIHandler_AdminRemoveElementFromGUINAck(?)){ */
/* } */
/* } */
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_enableGUIElement
// Purpose:
// Orders the default UIHandler to enable a widget on the runtime GUI
// connected to the UIHandler
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandlerClient_enableGUIElement(
in EPTF_UIHandler_WidgetIdString pl_WidgetID)
runs on EPTF_UIHandlerClient_CT{
f_EPTF_UIHandlerClient_enableGUIElementTo( pl_WidgetID, v_UIHandlerClient_DefaultUIHandler );
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_enableGUIElementTo
// Purpose:
// Orders an UIHandler to enable a widget on the runtime GUI
// connected to the UIHandler
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandlerClient_enableGUIElementTo(
in EPTF_UIHandler_WidgetIdString pl_WidgetID,
in EPTF_UIHandler_CT pl_UIHandler)
runs on EPTF_UIHandlerClient_CT{
if (v_UIHandlerClient_maxTimeoutReached) {
return;
}
f_EPTF_UIHandlerClient_connectUIHandler(pl_UIHandler);
v_UIHandlerClient_pendingMsgCounter := v_UIHandlerClient_pendingMsgCounter + 1;
v_UIHandlerClient_adminPortIf.send(t_UIHandler_AdminEnableWidgetByWidgetName(pl_WidgetID,f_EPTF_UIHandlerClient_getMsgId())) to pl_UIHandler;
/* alt{ */
/* [] v_UIHandlerClient_adminPortIf.receive(t_UIHandler_AdminEnableWidgetAck(?)){}; */
/* [] v_UIHandlerClient_adminPortIf.receive(t_UIHandler_AdminEnableWidgetNAck(?)){ */
/* } */
/* } */
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_disableGUIElement
// Purpose:
// Orders the defalut UIHandler to disable a widget on the runtime GUI
// connected to the UIHandler
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandlerClient_disableGUIElement(
in EPTF_UIHandler_WidgetIdString pl_WidgetID)
runs on EPTF_UIHandlerClient_CT{
f_EPTF_UIHandlerClient_disableGUIElementTo( pl_WidgetID, v_UIHandlerClient_DefaultUIHandler );
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_disableGUIElementTo
// Purpose:
// Orders an UIHandler to disable a widget on the runtime GUI
// connected to the UIHandler
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandlerClient_disableGUIElementTo(
in EPTF_UIHandler_WidgetIdString pl_WidgetID,
in EPTF_UIHandler_CT pl_UIHandler)
runs on EPTF_UIHandlerClient_CT{
if (v_UIHandlerClient_maxTimeoutReached) {
return;
}
f_EPTF_UIHandlerClient_connectUIHandler(pl_UIHandler);
v_UIHandlerClient_pendingMsgCounter := v_UIHandlerClient_pendingMsgCounter + 1;
v_UIHandlerClient_adminPortIf.send(t_UIHandler_AdminDisableWidgetByWidgetName(pl_WidgetID,f_EPTF_UIHandlerClient_getMsgId())) to pl_UIHandler;
/* alt{ */
/* [] v_UIHandlerClient_adminPortIf.receive(t_UIHandler_AdminDisableWidgetAck(*)){}; */
/* [] v_UIHandlerClient_adminPortIf.receive(t_UIHandler_AdminDisableWidgetNAck(*)){ */
/* } */
/* } */
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_setFocusToGUIElement
// Purpose:
// Orders the default UIHandler to set a widget being focused on the runtime GUI
// connected to the UIHandler
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandlerClient_setFocusToGUIElement(
in EPTF_UIHandler_WidgetIdString pl_WidgetID)
runs on EPTF_UIHandlerClient_CT{
f_EPTF_UIHandlerClient_setFocusToGUIElementTo( pl_WidgetID, v_UIHandlerClient_DefaultUIHandler );
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_setFocusToGUIElementTo
// Purpose:
// Orders an UIHandler to set a widget being focused on the runtime GUI
// connected to the UIHandler
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandlerClient_setFocusToGUIElementTo(
in EPTF_UIHandler_WidgetIdString pl_WidgetID,
in EPTF_UIHandler_CT pl_UIHandler)
runs on EPTF_UIHandlerClient_CT{
if (v_UIHandlerClient_maxTimeoutReached) {
return;
}
f_EPTF_UIHandlerClient_connectUIHandler(pl_UIHandler);
v_UIHandlerClient_pendingMsgCounter := v_UIHandlerClient_pendingMsgCounter + 1;
v_UIHandlerClient_adminPortIf.send(t_UIHandler_AdminSetFocusToWidget(pl_WidgetID,f_EPTF_UIHandlerClient_getMsgId())) to pl_UIHandler;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_setFocusToTab
// Purpose:
// Orders the default UIHandler to select a particular tab
// of a tabbox on the runtime GUI connected to the UIHandler
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandlerClient_setFocusToTab(
in EPTF_UIHandler_WidgetIdString pl_TabboxID,
in integer pl_TabIndex)
runs on EPTF_UIHandlerClient_CT{
f_EPTF_UIHandlerClient_setFocusToTabTo( pl_TabboxID, pl_TabIndex, v_UIHandlerClient_DefaultUIHandler );
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_setFocusToTabTo
// Purpose:
// Orders an UIHandler to select a particular tab of a tabbox
// of a tabbox on the runtime GUI connected to the UIHandler
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandlerClient_setFocusToTabTo(
in EPTF_UIHandler_WidgetIdString pl_TabboxID,
in integer pl_TabIndex,
in EPTF_UIHandler_CT pl_UIHandler)
runs on EPTF_UIHandlerClient_CT{
if (v_UIHandlerClient_maxTimeoutReached) {
return;
}
f_EPTF_UIHandlerClient_connectUIHandler(pl_UIHandler);
v_UIHandlerClient_pendingMsgCounter := v_UIHandlerClient_pendingMsgCounter + 1;
v_UIHandlerClient_adminPortIf.send(t_UIHandler_AdminSetFocusToWidget(
pl_TabboxID,f_EPTF_UIHandlerClient_getMsgId(), pl_TabIndex)) to pl_UIHandler;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_widgetExists
// Purpose:
// Checks whether the widget exists on the runtime GUI
// connected to the default UIHandler
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandlerClient_widgetExists(
in EPTF_UIHandler_WidgetIdString pl_WidgetID)
runs on EPTF_UIHandlerClient_CT
return EPTF_UIHandler_HandledWidgetType{
return f_EPTF_UIHandlerClient_widgetExistsOn(pl_WidgetID,v_UIHandlerClient_DefaultUIHandler );
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_widgetExistsOn
// Purpose:
// Checks whether the widget exists on the runtime GUI
// connected to the specified UIHandler
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandlerClient_widgetExistsOn(
in EPTF_UIHandler_WidgetIdString pl_WidgetID,
in EPTF_UIHandler_CT pl_UIHandler)
runs on EPTF_UIHandlerClient_CT
return EPTF_UIHandler_HandledWidgetType{
if (v_UIHandlerClient_maxTimeoutReached) {
return wtUnknown;
}
var integer vl_semaphoreId := f_EPTF_Semaphore_new();
var EPTF_UIHandler_WidgetMsg vl_msg;
f_EPTF_UIHandlerClient_connectUIHandler(pl_UIHandler);
v_UIHandlerClient_pendingMsgCounter := v_UIHandlerClient_pendingMsgCounter + 1;
v_UIHandlerClient_adminPortIf.send(t_UIHandler_AdminWidgetExists(pl_WidgetID,vl_semaphoreId)) to pl_UIHandler;
// wait until reponse is received:
if (f_EPTF_Semaphore_waitForUnlock(vl_semaphoreId,tsp_EPTF_UIHandlerClient_MaxWaitTime)) {
f_EPTF_UIHandlerClient_debug(log2str(%definitionId&
": MaxWaitTime expired. No reponse received for WidgetExists with Id ",vl_semaphoreId, ". Going on..."));
v_UIHandlerClient_maxTimeoutReached := true;
return wtUnknown; // max wait timer expired, no response received in time
}
return v_UIHandlerClient_widgetExistsRespList[vl_semaphoreId];
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_createGUI
// Purpose:
// Handles the responses to createGUI
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandlerClient_createGUI(
in charstring pl_xul,
in charstring pl_parentWidgetId := "" )
runs on EPTF_UIHandlerClient_CT
return EPTF_UIHandlerClient_SubsRet {
if (v_UIHandlerClient_maxTimeoutReached) {
return sr_Fail;
}
var integer vl_semaphoreId := f_EPTF_Semaphore_new();
f_EPTF_UIHandlerClient_connectUIHandler(v_UIHandlerClient_DefaultUIHandler);
v_UIHandlerClient_pendingMsgCounter := v_UIHandlerClient_pendingMsgCounter + 1;
v_UIHandlerClient_adminPortIf.send(
t_UIHandler_AdminCreateGUI( pl_xul, pl_parentWidgetId, vl_semaphoreId )) to v_UIHandlerClient_DefaultUIHandler;
// wait until reponse is received:
if (f_EPTF_Semaphore_waitForUnlock(vl_semaphoreId,tsp_EPTF_UIHandlerClient_MaxWaitTime)) {
f_EPTF_UIHandlerClient_debug(log2str(%definitionId&
": MaxWaitTime expired. No reponse received for createGUI with Id ",vl_semaphoreId, ". Going on..."));
v_UIHandlerClient_maxTimeoutReached := true;
return sr_Fail; // max wait timer expired, no response received in time
}
return v_UIHandlerClient_subsRetList[vl_semaphoreId];
}
///////////////////////////////////////////////////////////
// Altstep: as_EPTF_UIHandlerClient_handleCreateGUIResp
// Purpose:
// Handles the responses to createGUI
///////////////////////////////////////////////////////////
private altstep as_EPTF_UIHandlerClient_handleCreateGUIResp() runs on EPTF_UIHandlerClient_CT {
var EPTF_UIHandler_WidgetMsg vl_msg;
[] v_UIHandlerClient_adminPortIf.receive(t_UIHandler_AdminCreateGUIAck(?))-> value vl_msg{
v_UIHandlerClient_pendingMsgCounter := v_UIHandlerClient_pendingMsgCounter - 1;
v_UIHandlerClient_subsRetList[vl_msg.createGUIAck.messageID] := sr_Success;
f_EPTF_Semaphore_unlock(vl_msg.createGUIAck.messageID);
repeat;
};
[] v_UIHandlerClient_adminPortIf.receive(t_UIHandler_AdminCreateGUINAck(?))-> value vl_msg{
v_UIHandlerClient_pendingMsgCounter := v_UIHandlerClient_pendingMsgCounter - 1;
v_UIHandlerClient_subsRetList[vl_msg.createGUINAck.messageID] := sr_Fail;
f_EPTF_Semaphore_unlock(vl_msg.createGUINAck.messageID);
repeat;
}
}
///////////////////////////////////////////////////////////
// Altstep: as_EPTF_UIHandlerClient_handleWidgetExistsResp
// Purpose:
// Handles the response to the WidgetExists message
///////////////////////////////////////////////////////////
private altstep as_EPTF_UIHandlerClient_handleWidgetExistsResp() runs on EPTF_UIHandlerClient_CT {
var EPTF_UIHandler_WidgetMsg vl_msg;
[] v_UIHandlerClient_adminPortIf.receive(t_UIHandler_AdminWidgetExistsResp(*, *, *))-> value vl_msg{
v_UIHandlerClient_widgetExistsRespList[vl_msg.widgetExistsResp.messageID] := vl_msg.widgetExistsResp.widgetType;
v_UIHandlerClient_pendingMsgCounter := v_UIHandlerClient_pendingMsgCounter - 1;
f_EPTF_Semaphore_unlock(vl_msg.widgetExistsResp.messageID);
repeat;
}
}
///////////////////////////////////////////////////////////
// Group: GUIConvenienceFunctions
// Purpose:
// This group of functions allows adding different kind of
// widgets to the GUI easely
///////////////////////////////////////////////////////////
group GUIConvenienceFunctions {
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_XUL_addButton
// Purpose:
// Adds a new button to the GUI
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandlerClient_XUL_addButton(
in charstring pl_parentWidgetId,
in charstring pl_widgetId,
in charstring pl_label,
in template float pl_flex := omit,
in boolean pl_checked := false,
in boolean pl_disabled := false,
in template charstring pl_type := omit,
in template charstring pl_imageId := omit)
runs on EPTF_UIHandlerClient_CT
return boolean
{
var Widgets vl_xul := {
button := {
/*checked :=*/ pl_checked,
/*customclass := */ omit,
/*disabled :=*/ pl_disabled,
/*disabledongui := */ omit,
/*flex :=*/ valueof(pl_flex),
/*id :=*/ pl_widgetId,
/*imageid :=*/ valueof(pl_imageId),
/*label_ :=*/ pl_label,
/*tooltiptext :=*/ omit,
/*type_ :=*/ valueof(pl_type),
/*externaldata :=*/ omit
}
}
return f_EPTF_UIHandlerClient_XUL_XSD_addWidget(vl_xul, pl_parentWidgetId);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_XUL_addSpacer
// Purpose:
// Adds a new spacer to the GUI
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandlerClient_XUL_addSpacer(in charstring pl_parentWidgetId, in float pl_flex)
runs on EPTF_UIHandlerClient_CT
return boolean
{
var Widgets vl_xul := {
spacer := {
/*flex :=*/ pl_flex,
/*id :=*/ omit
}
}
return f_EPTF_UIHandlerClient_XUL_XSD_addWidget(vl_xul, pl_parentWidgetId);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_XUL_addLabel
// Purpose:
// Adds a new taxt label to the GUI
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandlerClient_XUL_addLabel(in charstring pl_parentWidgetId, in charstring pl_text)
runs on EPTF_UIHandlerClient_CT
return boolean
{
var Widgets vl_xul := {
label_ := {
/*customclass := */ omit,
/*disabled :=*/ omit,
/*disabledongui := */ omit,
/*flex :=*/ omit,
/*id:=*/ omit,
/*style:=*/ omit,
/*tooltiptext :=*/ omit,
/*value_ :=*/ pl_text,
/*externaldata :=*/ omit
}
}
return f_EPTF_UIHandlerClient_XUL_XSD_addWidget(vl_xul, pl_parentWidgetId);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_XUL_addEmptyHbox
// Purpose:
// Adds a new empty HBox to the GUI
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandlerClient_XUL_addEmptyHbox(
in charstring pl_parentWidgetId,
in template charstring pl_widgetId,
in template float pl_flex := omit,
in boolean pl_horizontal := true,
in template boolean pl_disabled := omit,
in template boolean pl_scrollable := omit,
in template Fixedpositions pl_fixedPosition := omit)
runs on EPTF_UIHandlerClient_CT
return boolean
{
var template Widgets vl_xul := {
hbox := {
/*customclass := */ omit,
/*disabled :=*/ pl_disabled,
/*disabledongui := */ omit,
/*fixedposition :=*/ pl_fixedPosition,
/*flex :=*/ pl_flex,
/*id :=*/ pl_widgetId,
/*orientation :=*/ vertical,
/*scrollable :=*/ pl_scrollable,
/*embeddedwidgets :=*/ {{}}
}
}
if(pl_horizontal) { vl_xul.hbox.orientation := horizontal; }
return f_EPTF_UIHandlerClient_XUL_XSD_addWidget(valueof(vl_xul), pl_parentWidgetId);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_XUL_addEmptyTabbox
// Purpose:
// Adds a new TabBox to the GUI
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandlerClient_XUL_XSD_addEmptyTabbox(
in charstring pl_parentWidgetId,
in charstring pl_widgetId,
in template float pl_flex:=omit,
in template Tablayout pl_listcard:=omit,
in template boolean pl_disabled := omit)
runs on EPTF_UIHandlerClient_CT
return boolean
{
template Widgets vl_xul := {
tabpages := {
/*customclass := */ omit,
/*disabled :=*/ omit,
/*disabledongui := */ omit,
/*flex :=*/ pl_flex,
/*id :=*/ pl_widgetId,
/*layout :=*/ pl_listcard,
/*tabpages :=*/ {{}}
}
}
return f_EPTF_UIHandlerClient_XUL_XSD_addWidget(valueof(vl_xul), pl_parentWidgetId);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_XUL_addEmptyTabpages
// Purpose:
// Adds a new TabBox to the GUI
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandlerClient_XUL_XSD_addEmptyTabpages(
in charstring pl_parentWidgetId,
in charstring pl_widgetId,
in template float pl_flex:=omit,
in template Tablayout pl_listcard:=omit,
in template boolean pl_disabled := omit)
runs on EPTF_UIHandlerClient_CT
return boolean
{
template Widgets vl_xul := {
tabpages := {
/*customclass := */ omit,
/*disabled :=*/ omit,
/*disabledongui := */ omit,
/*flex :=*/ pl_flex,
/*id :=*/ pl_widgetId,
/*layout :=*/ pl_listcard,
/*tabpages :=*/ {{}}
}
}
return f_EPTF_UIHandlerClient_XUL_XSD_addWidget(valueof(vl_xul), pl_parentWidgetId);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_XUL_addTabpanel
// Purpose:
// Adds a new TabPanel to the GUI
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandlerClient_XUL_addTabpanel(
in charstring pl_parentWidgetId,
in charstring pl_widgetId,
in template float pl_maxheight:=omit,
in boolean pl_horizontal := true)
runs on EPTF_UIHandlerClient_CT
return boolean
{
template Widgets vl_xul := {
tabpage := {
/*customclass := */ omit,
/*disabledongui := */ omit,
/*id :=*/ pl_widgetId,
/* label := */ "",
/*maxheight :=*/ pl_maxheight,
/*orientation :=*/ vertical,
/*tooltiptext :=*/ omit,
/*embeddedwidgets :=*/ {{}}
}
}
if(pl_horizontal) {
//vl_xul.xtdp_tabpanel.orient := "horizontal";
f_EPTF_UIHandlerClient_warning(log2str(%definitionId&
": horizontal tabpanel is not allowed"));
}
return f_EPTF_UIHandlerClient_XUL_XSD_addWidget(valueof(vl_xul), pl_parentWidgetId);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_XUL_addTab
// Purpose:
// Adds a new Tab to the GUI
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandlerClient_XUL_addTab(
in charstring pl_parentWidgetId,
in charstring pl_widgetId,
in charstring pl_label)
runs on EPTF_UIHandlerClient_CT
return boolean
{
var Widgets vl_xul := { tabpage := c_EPTF_UIHandler_emptyTabpage };
vl_xul.tabpage.id := pl_widgetId;
vl_xul.tabpage.label_ := pl_label;
vl_xul.tabpage.orientation := vertical;
/*
XSD.String customclass optional,
XSD.Boolean disabledongui optional,
+ XSD.String id optional,
+ XSD.String label_,
XSD.Decimal maxheight optional,
+ Orientation orientation optional,
XSD.String tooltiptext optional,
Embeddedwidgets embeddedwidgets
*/
vl_xul.tabpage.customclass := omit;
vl_xul.tabpage.disabledongui := omit;
vl_xul.tabpage.maxheight := omit;
vl_xul.tabpage.tooltiptext := omit;
vl_xul.tabpage.embeddedwidgets := {};
return f_EPTF_UIHandlerClient_XUL_XSD_addWidget(vl_xul, pl_parentWidgetId);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_XUL_addEmptyChart
// Purpose:
// Adds a new chart to the GUI
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandlerClient_XUL_addEmptyChart(
in charstring pl_parentWidgetId,
in charstring pl_chartWidgetId,
in template float pl_flex := omit,
in charstring pl_title := "Zoomable History chart (click to zoom out)",
in boolean pl_zoomable := true,
in template charstring pl_axisXType := omit,
in template charstring pl_axisYType := omit,
in template charstring pl_fgColor := omit,
in template charstring pl_bgColor := omit,
in template charstring pl_gridColor := omit
)
runs on EPTF_UIHandlerClient_CT
return boolean
{
var template Widgets vl_xul := {
chart := {
/*axisXType :=*/ omit,
/*axisYType :=*/ omit,
/*backgroundColor :=*/ pl_fgColor,
/*customclass := */ omit,
/*disabled :=*/ omit,
/*disabledongui := */ omit,
/*flex :=*/ pl_flex,
/*foregroundColor :=*/ pl_fgColor,
/*gridColor :=*/ pl_gridColor,
/*gridX :=*/ true,
/*gridY :=*/ true,
/*id :=*/ pl_chartWidgetId,
/*title :=*/ pl_title,
/*tooltiptext :=*/ omit,
/*zoomable :=*/ pl_zoomable ,
/*choice_list :=*/ {{}}
}
}
var AxisType vl_axisXType;
// Gigahack with ethjgi's recommendation was log2str!= omit
if ( isvalue(pl_axisXType)) {
f_EPTF_UIHandler_convertAxisType(valueof(pl_axisXType), vl_axisXType);
vl_xul.chart.axisXType := vl_axisXType
}
var AxisType vl_axisYType;
// Gigahack with ethjgi's recommendation was log2str!= omit
if ( isvalue(pl_axisYType)) {
f_EPTF_UIHandler_convertAxisType(valueof(pl_axisYType), vl_axisYType);
vl_xul.chart.axisYType := vl_axisYType
}
return f_EPTF_UIHandlerClient_XUL_XSD_addWidget(valueof(vl_xul), pl_parentWidgetId);
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_XUL_addTrace2Chart
// Purpose:
// Adds a new trace to a chart on the GUI
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandlerClient_XUL_addTrace2Chart(
in charstring pl_parentWidgetId,
in charstring pl_traceWidgetId,
in charstring pl_name,
in template charstring pl_unitX := "Time",
in template charstring pl_unitY := "Value",
in template integer pl_maxpoints:=omit,
in template charstring pl_color := omit,
in template boolean pl_fill := false
)
runs on EPTF_UIHandlerClient_CT
return boolean
{
var template Widgets vl_xul := {
trace := {
/*color :=*/ pl_color,
/*fill :=*/ pl_fill,
/*id :=*/ pl_traceWidgetId,
/*maxPoints :=*/ omit,
/*name :=*/ pl_name,
/*physicalUnitX :=*/ pl_unitX,
/*physicalUnitY :=*/ pl_unitY,
/*tooltiptext :=*/ omit,
/*externaldata :=*/ omit,
/*choice_list :=*/ {}
}
}
// Gigahack with ethjgi's recommendation was log2str!= omit
if ( isvalue(pl_maxpoints)) {
vl_xul.trace.maxPoints := valueof(pl_maxpoints);
}
return f_EPTF_UIHandlerClient_XUL_XSD_addWidget(valueof(vl_xul), pl_parentWidgetId);
}
} // end of convenience functions group
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_logAll
// Purpose:
// Logs all internal variable in EPTF_UIHandlerClient_CT
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandlerClient_logAll() runs on EPTF_UIHandlerClient_CT {
log("------Content of EPTF_UIHandlerClient_CT: -------");
log("v_UIHandlerClient_initialized: ", v_UIHandlerClient_initialized);
log("f_EPTF_Base_selfName(): ",f_EPTF_Base_selfName());
log("v_UIHandlerClient_hangingConnections: ", v_UIHandlerClient_hangingConnections);
log("v_UIHandlerClient_openUIConnections: ",v_UIHandlerClient_openUIConnections);
log("v_UIHandlerClient_def: ",v_UIHandlerClient_def);
log("v_UIHandlerClient_DefaultUIHandler: ",v_UIHandlerClient_DefaultUIHandler);
log("v_UIHandlerClient_lastRequest: ",v_UIHandlerClient_lastRequest);
log("------Finished Content of EPTF_UIHandlerClient_CT -------");
}//f_
} // end of public functions group
//------------------------------------------------------------------------------
// private
//------------------------------------------------------------------------------
group EPTF_UIHandlerClient_Private_Functions{
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_getMsgId
// Purpose:
// Increases the message counter and retrieves the new value
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandlerClient_getMsgId()
runs on EPTF_UIHandlerClient_CT
return integer{
v_UIHandlerClient_lastRequest := v_UIHandlerClient_lastRequest + 1;
return v_UIHandlerClient_lastRequest;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_handleSubsNoteAck
//
// Purpose:
// Handles the acceptance response for a sent subscription note.
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandlerClient_handleSubsNoteAck(
in integer pl_msgId,
in EPTF_UIHandler_CT pl_EPTF_CLL_UISubscMgmtMsg_sender)
runs on EPTF_UIHandlerClient_CT {
if( not f_EPTF_UIHandlerClient_removeHangingVarConnection(pl_msgId)){
// log("ERROR: "",Invalid hanging connection response!");
f_EPTF_UIHandlerClient_error("Invalid hanging connection response!");
//f_EPTF_Base_stop();
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_handleSubsNoteNAck
//
// Purpose:
// Handles the refusion response for a sent subscription note.
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandlerClient_handleSubsNoteNAck(
in integer pl_messageId,
in EPTF_UIHandler_CT pl_EPTF_CLL_UISubscMgmtMsg_sender)
runs on EPTF_UIHandlerClient_CT {
var EPTF_UIHandlerClient_HangingConnection vl_conn;
if(f_EPTF_UIHandlerClient_getVarConnection(pl_messageId, vl_conn)){
// log("ERROR: ","Subscription note to variable ",vl_conn.varName," has been refused.");
f_EPTF_UIHandlerClient_error("Subscription note to the variable has been refused.");
}else{
// log("ERROR: "",Invalid hanging connection response!");
f_EPTF_UIHandlerClient_error( "Invalid hanging connection response!");
//f_EPTF_Base_stop();
}
}
///////////////////////////////////////////////////////////
// Altstep: as_UIHandlerClient_handleSubsNoteResp
//
// Purpose:
// Handles the responses for a sent subscription note.
///////////////////////////////////////////////////////////
private altstep as_UIHandlerClient_handleSubsNoteResp()
runs on EPTF_UIHandlerClient_CT{
var EPTF_UIHandler_WidgetMsg vl_EPTF_CLL_UISubscMgmtMsg;
var EPTF_UIHandler_CT vl_EPTF_CLL_UISubscMgmtMsg_sender;
//There is no NAck, then it simple stops
[] v_UIHandlerClient_adminPortIf.receive( {subscribeAck := ?} ) ->
value vl_EPTF_CLL_UISubscMgmtMsg
sender vl_EPTF_CLL_UISubscMgmtMsg_sender {
v_UIHandlerClient_pendingMsgCounter := v_UIHandlerClient_pendingMsgCounter - 1;
f_EPTF_UIHandlerClient_handleSubsNoteAck(
vl_EPTF_CLL_UISubscMgmtMsg.subscribeAck.requestId,
vl_EPTF_CLL_UISubscMgmtMsg_sender);
f_EPTF_Semaphore_unlock(vl_EPTF_CLL_UISubscMgmtMsg.subscribeAck.requestId);
repeat;
}
[] v_UIHandlerClient_adminPortIf.receive( {subscribeNAck := ?} ) ->
value vl_EPTF_CLL_UISubscMgmtMsg
sender vl_EPTF_CLL_UISubscMgmtMsg_sender {
v_UIHandlerClient_pendingMsgCounter := v_UIHandlerClient_pendingMsgCounter - 1;
f_EPTF_UIHandlerClient_handleSubsNoteNAck(
vl_EPTF_CLL_UISubscMgmtMsg.subscribeNAck.requestId,
vl_EPTF_CLL_UISubscMgmtMsg_sender);
f_EPTF_Semaphore_unlock(vl_EPTF_CLL_UISubscMgmtMsg.subscribeNAck.requestId);
repeat;
}
}
///////////////////////////////////////////////////////////
// Altstep: as_handle_main_EPTF_UIHandlerClient_MgmtIf
//
// Purpose:
// The main altstep of the UIHandlerClient.
///////////////////////////////////////////////////////////
private altstep as_handle_main_EPTF_UIHandlerClient_MgmtIf() runs on EPTF_UIHandlerClient_CT {
[] as_UIHandlerClient_handleSubsNoteResp();
[] as_EPTF_UIHandlerClient_handleAddElementToGUIResp();
[] as_EPTF_UIHandlerClient_handleCreateGUIResp();
[] as_EPTF_UIHandlerClient_handleWidgetExistsResp();
[] v_UIHandlerClient_adminPortIf.receive(t_UIHandler_AdminEnableWidgetAck(?)){
v_UIHandlerClient_pendingMsgCounter := v_UIHandlerClient_pendingMsgCounter - 1;
repeat;
};
[] v_UIHandlerClient_adminPortIf.receive(t_UIHandler_AdminEnableWidgetNAck(?)){
v_UIHandlerClient_pendingMsgCounter := v_UIHandlerClient_pendingMsgCounter - 1;
repeat;
};
[] v_UIHandlerClient_adminPortIf.receive(t_UIHandler_AdminDisableWidgetAck(*)){
v_UIHandlerClient_pendingMsgCounter := v_UIHandlerClient_pendingMsgCounter - 1;
repeat;
};
[] v_UIHandlerClient_adminPortIf.receive(t_UIHandler_AdminDisableWidgetNAck(*)){
v_UIHandlerClient_pendingMsgCounter := v_UIHandlerClient_pendingMsgCounter - 1;
repeat;
};
[] v_UIHandlerClient_adminPortIf.receive(t_UIHandler_AdminSetFocusToWidgetAck(*)){
v_UIHandlerClient_pendingMsgCounter := v_UIHandlerClient_pendingMsgCounter - 1;
repeat;
};
[] v_UIHandlerClient_adminPortIf.receive(t_UIHandler_AdminSetFocusToWidgetNAck(*)){
v_UIHandlerClient_pendingMsgCounter := v_UIHandlerClient_pendingMsgCounter - 1;
repeat;
};
[] v_UIHandlerClient_adminPortIf.receive(t_UIHandler_AdminRemoveElementFromGUIAck(?)){
v_UIHandlerClient_pendingMsgCounter := v_UIHandlerClient_pendingMsgCounter - 1;
repeat;
};
[] v_UIHandlerClient_adminPortIf.receive(t_UIHandler_AdminRemoveElementFromGUINAck(?)){
v_UIHandlerClient_pendingMsgCounter := v_UIHandlerClient_pendingMsgCounter - 1;
repeat;
};
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_cleanup_CT
// Purpose:
// Closes the open management ports
// Detailed Comments:
// This function mustn't be called directly. You must call f_EPTF_Base_cleanup_CT instead.
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandlerClient_cleanup_CT() runs on EPTF_UIHandlerClient_CT {
if (v_UIHandlerClient_initialized) {
// wait for receiving all pending messages
timer t_wait := 0.0;
t_wait.start;
timer t_maxWait := tsp_EPTF_UIHandlerClient_maxKillTime;
t_maxWait.start;
f_EPTF_UIHandlerClient_debug(log2str(%definitionId&": Waiting for all UIHandler Clients to stop..."));
var EPTF_UIHandler_WidgetMsg vl_msg;
alt {
[v_UIHandlerClient_pendingMsgCounter == 0 or v_UIHandlerClient_maxTimeoutReached] t_wait.timeout;
[] t_maxWait.timeout {
f_EPTF_UIHandlerClient_warning(log2str(%definitionId&
": MaxWaitTime expired. Not all the pending messages received (still pending:",v_UIHandlerClient_pendingMsgCounter,"). Exiting anyway..."));
}
// drop all messages to prevent deadlock (cleanup blocks the function in the alt that calls TP.receive to wait for answer e.g: subscribeMe):
[] v_UIHandlerClient_adminPortIf.receive(?) -> value vl_msg{
v_UIHandlerClient_pendingMsgCounter := v_UIHandlerClient_pendingMsgCounter - 1;
f_EPTF_UIHandlerClient_debug(log2str(
": Unexpected message received during cleanup. Message dropped: ",vl_msg));
repeat;
};
}
// iterate through the connected UIHandlers and disconnect them
for( var integer i := 0; i < sizeof(v_UIHandlerClient_openUIConnections); i := i + 1 ){
if(v_UIHandlerClient_openUIConnections[i] != null) {
f_EPTF_UIHandlerClient_closeUIPortToIdx(i);
}
}
}
v_UIHandlerClient_pendingMsgCounter := 0;
v_UIHandlerClient_hangingConnections := {};
//v_openConnections := {};
v_UIHandlerClient_openUIConnections := {};
v_UIHandlerClient_initialized := false;
deactivate(v_UIHandlerClient_def)
// log("DEBUG: ","----CLL_UIHandlerClient cleanup DONE----");
f_EPTF_UIHandlerClient_debug("----CLL_UIHandlerClient cleanup DONE----");
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_XUL_addWidget
// Purpose:
// Adds a widget to the GUI
// Detailed Comments:
// This function is used by the convenience functions.
///////////////////////////////////////////////////////////
public function f_EPTF_UIHandlerClient_XUL_XSD_addWidget(in Widgets pl_xul, in charstring pl_parentWidgetId)
runs on EPTF_UIHandlerClient_CT
return boolean
{
if(sr_Success != f_EPTF_UIHandlerClient_XSD_addElementToGUI(pl_xul, pl_parentWidgetId)) {
f_EPTF_UIHandlerClient_debug(log2str("Could not add element to GUI: ", pl_xul, ", parent:", pl_parentWidgetId));
return false;
}
return true;
}
///////////////////////////////////////////////////////////
// Group: UIHandlerClient_SubscriptionAdministration
// Purpose:
// Administers the hanging subscriptions from sending to
// the arrival of the ACK or the NACK
///////////////////////////////////////////////////////////
group UIHandlerClient_SubscriptionAdministration{
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_removeHangingVarConnection
// Purpose:
// Clears the record about the given subscription
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandlerClient_removeHangingVarConnection(in integer pl_messageId)
runs on EPTF_UIHandlerClient_CT
return boolean{
var integer vl_i := f_EPTF_UIHandlerClient_varConnectionIndex(pl_messageId);
if(-1 == vl_i){ return false;};
v_UIHandlerClient_hangingConnections[vl_i] := {null,"",-1};
return true;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_varConnectionIndex
// Purpose:
// Returns the index of the hanging subscription note record
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandlerClient_varConnectionIndex(in integer pl_messageId)
runs on EPTF_UIHandlerClient_CT
return integer {
for( var integer i := 0; i < sizeof(v_UIHandlerClient_hangingConnections); i := i + 1 ){
if(v_UIHandlerClient_hangingConnections[i].messagId == pl_messageId) { return i; }
}
return -1;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_getVarConnection
// Purpose:
// Returns the hanging subscription note record
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandlerClient_getVarConnection(
in integer pl_messageId,
out EPTF_UIHandlerClient_HangingConnection pl_hangingConnection)
runs on EPTF_UIHandlerClient_CT
return boolean{
var integer vl_connIdx := f_EPTF_UIHandlerClient_varConnectionIndex(pl_messageId);
if(-1 == vl_connIdx){
pl_hangingConnection := v_UIHandlerClient_hangingConnections[vl_connIdx];
}
return -1 != vl_connIdx;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_addVarConnection
// Purpose:
// Adds a record about the subscription note to the list
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandlerClient_addVarConnection(
in EPTF_UIHandler_CT pl_RemoteCompRef,
in charstring pl_ProvidedParamName,
in integer pl_messageId)
runs on EPTF_UIHandlerClient_CT {
var EPTF_UIHandlerClient_HangingConnection vl_hangingConnection := {pl_RemoteCompRef,pl_ProvidedParamName,pl_messageId};
if( -1 == f_EPTF_UIHandlerClient_varConnectionIndex(pl_messageId) ) {
v_UIHandlerClient_hangingConnections[sizeof(v_UIHandlerClient_hangingConnections)] := vl_hangingConnection;
};
f_EPTF_UIHandlerClient_connectUIHandler(pl_RemoteCompRef);
}
} // end of subscription admin group
///////////////////////////////////////////////////////////
// Group: UIHandlerClient_PortAdministration
// Purpose:
// Administers the connected <v_UIHandlerClient_adminPortIf> ports
///////////////////////////////////////////////////////////
group UIHandlerClient_PortAdministration{
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_connectUIHandler
// Purpose:
// Connects the v_UIHandlerClient_adminPortIf port to the specified
// UIHandler and registers the connection
///////////////////////////////////////////////////////////
//UI connection handling
private function f_EPTF_UIHandlerClient_connectUIHandler(
in EPTF_UIHandler_CT pl_RemoteCompRef)
runs on EPTF_UIHandlerClient_CT {
if( -1 == f_EPTF_UIHandlerClient_connectionIndex(pl_RemoteCompRef) ) {
connect(self:v_UIHandlerClient_adminPortIf,pl_RemoteCompRef:EPTF_adminPort_CP);
v_UIHandlerClient_openUIConnections[sizeof(v_UIHandlerClient_openUIConnections)] := pl_RemoteCompRef;
};
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_connectionIndex
// Purpose:
// Returns the index of the open connection record
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandlerClient_connectionIndex(in EPTF_UIHandler_CT pl_handler)
runs on EPTF_UIHandlerClient_CT
return integer {
for( var integer i := 0; i < sizeof(v_UIHandlerClient_openUIConnections); i := i + 1 ){
if(v_UIHandlerClient_openUIConnections[i] == pl_handler) { return i; }
}
return -1;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_closeUIPortToIdx
// Purpose:
// Closes the specified connection
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandlerClient_closeUIPortToIdx(in integer pl_handlerIdx)
runs on EPTF_UIHandlerClient_CT{
disconnect(self:v_UIHandlerClient_adminPortIf, v_UIHandlerClient_openUIConnections[pl_handlerIdx]:EPTF_adminPort_CP);
v_UIHandlerClient_openUIConnections[pl_handlerIdx] := null;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_closeUIPortToUIHandler
// Purpose:
// Closes the specified connection
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandlerClient_closeUIPortToUIHandler(in EPTF_UIHandler_CT pl_handler)
runs on EPTF_UIHandlerClient_CT
return boolean{
var integer i := f_EPTF_UIHandlerClient_connectionIndex(pl_handler);
if(-1 == i){ return false;};
f_EPTF_UIHandlerClient_closeUIPortToIdx(i);
return true;
}
} // end of port administration group
group Logging {
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_error
//
// Purpose:
// Function to log an error from UIHandlerClient feature.
//
// Parameters:
// - pl_message - *in* *charstring* - the message to log
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandlerClient_error(in charstring pl_message)
runs on EPTF_UIHandlerClient_CT
{
f_EPTF_Logging_error(true, tsp_EPTF_UIHandlerClient_loggingComponentMask&": "&pl_message);
f_EPTF_Base_stopAll();
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_warning
//
// Purpose:
// Function to log a warning from UIHandlerClient feature.
//
// Parameters:
// - pl_message - *in* *charstring* - the message to log
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandlerClient_warning(in @lazy charstring pl_message)
runs on EPTF_UIHandlerClient_CT
{
f_EPTF_Logging_warningV2(pl_message, v_UIHandlerClient_loggingMaskId, {c_EPTF_UIHandler_loggingClassIdx_Warning});
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_debug
//
// Purpose:
// Function to log a debug message from UIHandlerClient feature.
//
// Parameters:
// - pl_message - *in* *charstring* - the message to log
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandlerClient_debug(in @lazy charstring pl_message)
runs on EPTF_UIHandlerClient_CT
{
f_EPTF_Logging_debugV2(pl_message, v_UIHandlerClient_loggingMaskId, {c_EPTF_UIHandler_loggingClassIdx_Debug});
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_UIHandlerClient_debugEnabled
//
// Purpose:
// Function to check if debug is enabled for UIHandlerClient
//
// Parameters:
// -
//
// Return Value:
// *boolean* - true if debug enalbed
//
// Errors & assertions:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
private function f_EPTF_UIHandlerClient_debugEnabled()
runs on EPTF_UIHandlerClient_CT
return boolean
{
return f_EPTF_Logging_isEnabled(v_UIHandlerClient_loggingMaskId, c_EPTF_UIHandler_loggingClassIdx_Debug);
}
} // end of logging group
} // end of private group
} // end of module