| /////////////////////////////////////////////////////////////////////////////// |
| // // |
| // Copyright (c) 2000-2018 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_StatHandler_Demo |
| // |
| // Purpose: |
| // This module contains the demo for the EPTF StatHandler feature. |
| // |
| // Module depends on: |
| // <EPTF_CLL_StatHandler_Definitions> |
| // <EPTF_CLL_StatHandler_Functions> |
| // <EPTF_CLL_StatHandlerClient_Definitions> |
| // <EPTF_CLL_StatHandlerClient_Functions> |
| // <EPTF_CLL_StatHandlerLogging_Definitions> |
| // <EPTF_CLL_StatHandlerLogging_Functions> |
| // <EPTF_CLL_StatHandlerUI_Definitions> |
| // <EPTF_CLL_StatHandlerUI_Functions> |
| // <EPTF_CLL_Base_Functions> |
| // <EPTF_CLL_Common_Definitions> |
| // <EPTF_CLL_UIHandler_Definitions> |
| // <EPTF_CLL_UIHandler_WidgetFunctions> |
| // <EPTF_CLL_UIHandlerClient_Definitions> |
| // <EPTF_CLL_UIHandlerClient_Functions> |
| // <EPTF_CLL_LoggingUI_Definitions> |
| // <EPTF_CLL_LoggingUI_Functions> |
| // <EPTF_CLL_Variable_Definitions> |
| // <EPTF_CLL_Variable_Functions> |
| // <XTDP_PDU_Defs> |
| // |
| // Module Parameters: |
| // tsp_demo_nofClients - *integer* - number of client components, default 2 |
| // tsp_use_LoggingUI - *boolean* - whether to use LoggingUI, default true |
| // |
| // Current Owner: |
| // Gabor Tatarka (EGBOTAT) |
| // |
| // Last Review Date: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| // |
| /////////////////////////////////////////////////////////////// |
| |
| module EPTF_StatHandler_Demo { |
| |
| import from EPTF_CLL_StatHandler_Definitions all; |
| import from EPTF_CLL_StatHandler_Functions all; |
| import from EPTF_CLL_StatHandlerClient_Definitions all; |
| import from EPTF_CLL_StatHandlerClient_Functions all; |
| import from EPTF_CLL_StatHandlerLogging_Definitions all; |
| import from EPTF_CLL_StatHandlerLogging_Functions all; |
| import from EPTF_CLL_StatHandlerUI_Definitions all; |
| import from EPTF_CLL_StatHandlerUI_Functions all; |
| |
| import from EPTF_CLL_Base_Functions all; |
| import from EPTF_CLL_Common_Definitions all; |
| import from EPTF_CLL_UIHandler_Definitions all; |
| import from EPTF_CLL_UIHandler_WidgetFunctions all; |
| import from EPTF_CLL_UIHandlerClient_Definitions all; |
| import from EPTF_CLL_UIHandlerClient_Functions all; |
| import from EPTF_CLL_LoggingUI_Definitions all; |
| import from EPTF_CLL_LoggingUI_Functions all; |
| import from EPTF_CLL_Variable_Definitions all; |
| import from EPTF_CLL_Variable_Functions all; |
| import from XTDP_PDU_Defs all; |
| |
| modulepar integer tsp_demo_nofClients := 2; |
| modulepar boolean tsp_use_LoggingUI := true; |
| |
| group DemoDefinitions { |
| |
| type component SYSTEM_CT extends EPTF_UIHandler_CT, EPTF_UIHandlerClient_CT, EPTF_LoggingUI_CT, EPTF_LoggingUIClient_CT |
| { |
| } |
| |
| type component StatHandlerClientUI_TestCT extends EPTF_StatHandlerClientUI_CT |
| { |
| var integer v_intStat := 0; |
| var integer v_varIdx := -1; |
| } |
| |
| // widget IDs |
| const charstring c_ExitButtonWidgetId := "exitButton"; |
| const charstring c_ResetButtonWidgetId := "resetButton"; |
| const charstring c_DemoTabWidgetId := "demoTab"; |
| const charstring c_MiscHboxWidgetId := "miscHbox"; |
| const charstring c_OuterHboxWidgetId := "outerHbox"; |
| const charstring c_MainHboxWidgetId := "mainHbox"; |
| const charstring c_ClientTreeWidgetId := "clientTree"; |
| const charstring c_ClientValueWidgetId := "clientValue"; |
| const charstring c_ClientDecrementWidgetId := "clientDecrement"; |
| const charstring c_ClientIncrementWidgetId := "clientIncrement"; |
| |
| // var and stat names |
| const charstring c_ClientStat := "clientStat"; |
| const charstring c_AggregateStat_Sum := "MySumStat"; |
| const charstring c_AggregateStat_Min := "MyMinStat"; |
| const charstring c_AggregateStat_Max := "MyMaxStat"; |
| |
| // prefixes |
| const charstring c_VarPrefix := "Var."; |
| const charstring c_GuiVarPrefix := "Gui."; |
| |
| } // group DemoDefinitions |
| |
| group Client { |
| |
| function f_StatHandlerDemo_clientResetCallback() |
| runs on StatHandlerClientUI_TestCT |
| { |
| v_intStat := 0; |
| f_EPTF_Var_adjustContent(v_varIdx, {intVal:=v_intStat}); |
| } |
| |
| function f_StatHandlerDemo_clientBehavior( |
| in charstring pl_selfName, |
| in EPTF_StatHandler_CT pl_statHandler_compRef, |
| in EPTF_UIHandler_CT pl_uiHandler_compRef, |
| in EPTF_LoggingUI_CT pl_loggingUi_compRef := null) |
| runs on StatHandlerClientUI_TestCT |
| { |
| f_EPTF_StatHandlerClientUI_init_CT(pl_selfName, pl_statHandler_compRef, pl_uiHandler_compRef, pl_loggingUi_compRef); |
| f_EPTF_Var_newInt(c_ClientStat, v_intStat, v_varIdx); |
| f_StatHandlerDemo_clientInitGui(); |
| v_intStat := 0; |
| f_EPTF_StatHandlerClient_registerResetFunction(refers(f_StatHandlerDemo_clientResetCallback)); |
| f_EPTF_StatHandlerClient_declareStat(c_AggregateStat_Sum, c_EPTF_StatHandler_Method_Sum, {intVal:=0}); |
| f_EPTF_StatHandlerClient_registerStat_IntSum(c_ClientStat,c_AggregateStat_Sum); |
| f_EPTF_StatHandlerClient_declareStat(c_AggregateStat_Min, c_EPTF_StatHandler_Method_Min, {intVal:=0}); |
| f_EPTF_StatHandlerClient_registerStat_IntMin(c_ClientStat,c_AggregateStat_Min); |
| f_EPTF_StatHandlerClient_declareStat(c_AggregateStat_Max, c_EPTF_StatHandler_Method_Max, {intVal:=0}); |
| f_EPTF_StatHandlerClient_registerStat_IntMax(c_ClientStat,c_AggregateStat_Max); |
| |
| /* if(log2str(self)=="4") { |
| timer T:=5.0; |
| T.start;T.timeout; |
| f_EPTF_StatHandlerClient_deregisterStat(c_AggregateStat_Sum, -, -, {c_ClientStat}); |
| }*/ |
| |
| f_EPTF_Base_wait4Shutdown(); |
| } |
| |
| function f_StatHandlerDemo_clientInitGui() |
| runs on StatHandlerClientUI_TestCT |
| { |
| var XTDP_XML_Tag vl_xul := { |
| xtdp_treeitem := { |
| { |
| { |
| id := omit, |
| textlabel := f_EPTF_Base_selfName(), |
| tooltiptext := "Name of the component" |
| }, |
| { |
| id := c_ClientValueWidgetId&"."&log2str(self), |
| textlabel := "", |
| tooltiptext := "Stat value" |
| }, |
| { |
| id := c_ClientDecrementWidgetId&"."&log2str(self), |
| textlabel := "-1", |
| tooltiptext := "Decrement" |
| }, |
| { |
| id := c_ClientIncrementWidgetId&"."&log2str(self), |
| textlabel := "+1", |
| tooltiptext := "Increment" |
| } |
| } |
| } |
| } |
| |
| if(sr_Fail == f_EPTF_UIHandlerClient_addElementToGUI(vl_xul, c_ClientTreeWidgetId)) { |
| log(%definitionId, ": cannot add element to gui: ", vl_xul); |
| } |
| |
| var integer vl_idx := f_StatHandlerDemo_createVarForButton(c_ClientDecrementWidgetId&"."&log2str(self)); |
| f_EPTF_Var_addPostProcFn(vl_idx, {refers(f_StatHandlerDemo_clientDec),{}}); |
| |
| vl_idx := f_StatHandlerDemo_createVarForButton(c_ClientIncrementWidgetId&"."&log2str(self)); |
| f_EPTF_Var_addPostProcFn(vl_idx, {refers(f_StatHandlerDemo_clientInc),{}}); |
| |
| f_EPTF_UIHandlerClient_subscribeMe( |
| c_ClientStat, |
| c_GuiVarPrefix&c_ClientValueWidgetId&"."&log2str(self), |
| c_ClientValueWidgetId&"."&log2str(self), |
| realtime); |
| } |
| |
| function f_StatHandlerDemo_clientDec(in integer pl_idx, in EPTF_IntegerList pl_argList) |
| runs on StatHandlerClientUI_TestCT |
| { |
| v_intStat := v_intStat - 1; |
| f_EPTF_Var_adjustContent(v_varIdx, {intVal:=v_intStat}); |
| } |
| |
| function f_StatHandlerDemo_clientInc(in integer pl_idx, in EPTF_IntegerList pl_argList) |
| runs on StatHandlerClientUI_TestCT |
| { |
| v_intStat := v_intStat + 1; |
| f_EPTF_Var_adjustContent(v_varIdx, {intVal:=v_intStat}); |
| } |
| |
| } // group Client |
| |
| group Server { |
| |
| function f_StatHandlerDemo_statDeclared( |
| in charstring pl_statName, |
| in charstring pl_statMethod, |
| in integer pl_statVarIdx) |
| runs on EPTF_StatHandlerUI_CT |
| { |
| var charstring vl_widgetId := f_EPTF_Base_selfName()&"."&pl_statName; |
| var XTDP_XML_Tag vl_xul := { |
| xtdp_treeitem := { |
| { |
| { |
| id := omit, |
| textlabel := pl_statName, |
| tooltiptext := "Name of the statistics" |
| }, |
| { |
| id := omit, |
| textlabel := pl_statMethod, |
| tooltiptext := "Methof of the statistics" |
| }, |
| { |
| id := vl_widgetId, |
| textlabel := "", |
| tooltiptext := "Value of the statistics" |
| } |
| } |
| } |
| } |
| |
| if(sr_Fail == f_EPTF_UIHandlerClient_addElementToGUI(vl_xul, f_EPTF_Base_selfName()&"_tree")) { |
| log(%definitionId, ": cannot add element to gui: ", vl_xul); |
| } |
| |
| f_EPTF_UIHandlerClient_subscribeMe( |
| f_EPTF_Var_getName(pl_statVarIdx), |
| c_GuiVarPrefix&f_EPTF_Base_selfName()&"."&f_EPTF_Var_getName(pl_statVarIdx),// gui var name |
| vl_widgetId, // widget name |
| realtime); |
| } |
| |
| function f_StatHandlerDemo_initStatsGuiForServer( |
| in charstring pl_selfName, in charstring pl_parentWidgetId) |
| runs on EPTF_StatHandlerUI_CT |
| { |
| var EPTF_UIHandlerClient_SubsRet vl_addRet := sr_Fail; |
| var charstring vl_tree_id := pl_selfName&"_tree"; |
| var XTDP_XML_Tag vl_xul :={ |
| xtdp_tree :={ |
| hidecolumnpicker := false, |
| id := vl_tree_id, |
| flex := omit, |
| disabled := omit, |
| rows := 0.0, |
| treecols := { |
| { |
| editable := false, |
| flex := 4.0, |
| id := omit, |
| columnlabel := "Statistics name", |
| widgetType := string |
| }, |
| { |
| editable := false, |
| flex := 1.0, |
| id := omit, |
| columnlabel := "Method", |
| widgetType := string |
| }, |
| { |
| editable := false, |
| flex := 1.0, |
| id := omit, |
| columnlabel := "Value", |
| widgetType := string//checkBox |
| } |
| }, |
| treechildren := {} |
| } |
| } |
| |
| vl_addRet := f_EPTF_UIHandlerClient_addElementToGUI(vl_xul, pl_parentWidgetId); |
| |
| if(sr_Success != vl_addRet) { |
| log(%definitionId, ": cannot add element to gui (", vl_addRet, "): ", vl_xul); |
| f_EPTF_Base_stop(); |
| } |
| |
| f_StatHandlerDemo_addSpacer(1.0, pl_parentWidgetId); |
| |
| f_EPTF_StatHandler_registerStatDeclaredCallbackFn(refers(f_StatHandlerDemo_statDeclared)); |
| } |
| |
| |
| function f_StatHandlerDemo_serverBehavior( |
| in charstring pl_selfName, |
| in charstring pl_uiParentWidgetId, |
| in EPTF_UIHandler_CT pl_uiHandler_compRef, |
| in EPTF_LoggingUI_CT pl_loggingUi_compRef := null, |
| in charstring pl_localResetButtonUIVarName := "") |
| runs on EPTF_StatHandlerUI_CT |
| { |
| f_EPTF_StatHandlerUI_init_CT(pl_selfName, pl_uiParentWidgetId, pl_uiHandler_compRef, pl_loggingUi_compRef, pl_localResetButtonUIVarName); |
| f_StatHandlerDemo_initStatsGuiForServer(pl_selfName,c_DemoTabWidgetId) |
| f_EPTF_Base_wait4Shutdown(); |
| } |
| |
| } // group Server |
| |
| group Demo { |
| |
| testcase tc_StatHandlerDemo() |
| runs on SYSTEM_CT |
| { |
| if(tsp_demo_nofClients < 1 or tsp_demo_nofClients > 10) { |
| log("tsp_demo_nofClients shall be between 1 and 10."); |
| stop; |
| } |
| |
| f_EPTF_UIHandler_init_CT("MTC", true); |
| f_EPTF_UIHandler_clearGUI(); |
| f_EPTF_UIHandler_addWindow(); |
| |
| f_EPTF_UIHandlerClient_init_CT("MTC", self); |
| |
| f_StatHandlerDemo_initGui(); |
| |
| if(tsp_use_LoggingUI) { |
| f_EPTF_LoggingUI_init_CT("MTC", self, tsp_EPTF_GUI_Main_Tabbox_WidgetId); |
| } |
| //f_EPTF_LoggingUIClient_init_CT("MTC", self, self); |
| |
| var EPTF_StatHandlerUI_CT vl_statHandler := EPTF_StatHandlerUI_CT.create; |
| if(tsp_use_LoggingUI) { |
| vl_statHandler.start(f_StatHandlerDemo_serverBehavior( |
| "StatHandlerUI_testGUI_Server1", |
| "", //tsp_EPTF_GUI_Main_Tabbox_WidgetId, |
| self, |
| self, |
| c_GuiVarPrefix&c_ResetButtonWidgetId |
| )); |
| } else { |
| vl_statHandler.start(f_StatHandlerDemo_serverBehavior( |
| "StatHandlerUI_testGUI_Server1", |
| "", //tsp_EPTF_GUI_Main_Tabbox_WidgetId, |
| self, |
| null, |
| c_GuiVarPrefix&c_ResetButtonWidgetId |
| )); |
| } |
| |
| for(var integer i:=0; i<tsp_demo_nofClients; i:=i+1) { |
| var StatHandlerClientUI_TestCT vl_client := StatHandlerClientUI_TestCT.create; |
| if(tsp_use_LoggingUI) { |
| vl_client.start(f_StatHandlerDemo_clientBehavior("StatHandlerUI_testGUI_Client"&int2str(i+1), vl_statHandler, self, self)); |
| } else { |
| vl_client.start(f_StatHandlerDemo_clientBehavior("StatHandlerUI_testGUI_Client"&int2str(i+1), vl_statHandler, self)); |
| } |
| } |
| |
| f_EPTF_Base_wait4Shutdown(); |
| |
| f_EPTF_Base_cleanup_CT(); |
| setverdict(pass); |
| } |
| |
| function f_StatHandlerDemo_initGui() |
| runs on SYSTEM_CT{ |
| |
| f_StatHandlerDemo_addEmptyHbox(c_OuterHboxWidgetId, -1.0, false, tsp_EPTF_GUI_Main_Window_WidgetId); |
| f_StatHandlerDemo_addEmptyHbox(c_MainHboxWidgetId, -1.0, false, c_OuterHboxWidgetId); |
| f_StatHandlerDemo_addEmptyTabbox(tsp_EPTF_GUI_Main_Tabbox_WidgetId,-1.0,true,c_MainHboxWidgetId); |
| f_StatHandlerDemo_addEmptyHbox(c_MiscHboxWidgetId, 0.0, true, c_OuterHboxWidgetId); |
| f_StatHandlerDemo_addSpacer(1.0, c_MiscHboxWidgetId); |
| f_StatHandlerDemo_addButton(c_ResetButtonWidgetId, "Reset stats", c_MiscHboxWidgetId); |
| f_StatHandlerDemo_addSpacer(0.0, c_MiscHboxWidgetId); |
| f_StatHandlerDemo_addButton(c_ExitButtonWidgetId, "Exit", c_MiscHboxWidgetId); |
| |
| var integer vl_idx := f_StatHandlerDemo_createVarForButton(c_ExitButtonWidgetId); |
| f_EPTF_Var_addPostProcFn(vl_idx, {refers(f_StatHandlerDemo_exitButtonPressed),{}}); |
| |
| vl_idx := f_StatHandlerDemo_createVarForButton(c_ResetButtonWidgetId); |
| // the above Variable will be used as local reset button Var for the StatHandler |
| |
| f_StatHandlerDemo_initDemoTab(); |
| } |
| |
| function f_StatHandlerDemo_initDemoTab() |
| runs on SYSTEM_CT |
| { |
| f_StatHandlerDemo_addTab(c_DemoTabWidgetId, "StatHandlerDemo", tsp_EPTF_GUI_Main_Tabbox_WidgetId); |
| |
| f_StatHandlerDemo_addLabel("Client stats:", c_DemoTabWidgetId); |
| |
| var XTDP_XML_Tag vl_xul :={ |
| xtdp_tree :={ |
| hidecolumnpicker := false, |
| id := c_ClientTreeWidgetId, |
| flex := omit, |
| disabled := omit, |
| rows := 0.0, |
| treecols := { |
| { |
| editable := false, |
| flex := 4.0, |
| id := omit, |
| columnlabel := "Client component", |
| widgetType := string |
| }, |
| { |
| editable := false, |
| flex := 1.0, |
| id := omit, |
| columnlabel := "Stat value", |
| widgetType := integerField |
| }, |
| { |
| editable := true, |
| flex := 1.0, |
| id := omit, |
| columnlabel := "Decrement", |
| widgetType := pushButton |
| }, |
| { |
| editable := true, |
| flex := 1.0, |
| id := omit, |
| columnlabel := "Increment", |
| widgetType := pushButton |
| } |
| }, |
| treechildren := {} |
| } |
| } |
| |
| if(sr_Success != f_EPTF_UIHandlerClient_addElementToGUI(vl_xul, c_DemoTabWidgetId)) { |
| log("Error: could not add element to GUI: ", vl_xul); |
| f_EPTF_Base_stop(); |
| } |
| |
| f_StatHandlerDemo_addSpacer(0.0, c_DemoTabWidgetId); |
| |
| f_StatHandlerDemo_addLabel("Aggregated server stats:", c_DemoTabWidgetId); |
| |
| // f_StatHandlerDemo_addSpacer(1.0, c_DemoTabWidgetId); |
| } |
| |
| function f_StatHandlerDemo_exitButtonPressed(in integer pl_idx, in EPTF_IntegerList pl_argList) |
| runs on SYSTEM_CT |
| { |
| log("Exit button pressed. Stopping all components..."); |
| |
| f_EPTF_UIHandlerClient_disableGUIElement(c_ExitButtonWidgetId); |
| f_EPTF_UIHandlerClient_disableGUIElement(c_ResetButtonWidgetId); |
| f_StatHandlerDemo_wait(1.0); |
| |
| f_EPTF_Base_stopAll(pass); |
| } |
| |
| function f_StatHandlerDemo_wait(in float pl_sec) |
| { |
| timer Tl_wait := pl_sec; |
| Tl_wait.start; |
| Tl_wait.timeout; |
| } |
| |
| } // group Demo |
| |
| group GUIConvenienceFunctions { |
| |
| function f_StatHandlerDemo_addSpacer(in float pl_flex, in charstring pl_parentWidgetId) |
| runs on EPTF_UIHandlerClient_CT |
| { |
| var XTDP_XML_Tag vl_xul := { |
| xtdp_spacer := { |
| flex := pl_flex, |
| id := omit |
| } |
| } |
| if(sr_Success != f_EPTF_UIHandlerClient_addElementToGUI(vl_xul, pl_parentWidgetId)) { |
| log("Warning: could not add element to GUI: ", vl_xul); |
| // f_EPTF_Base_stop(); |
| } |
| } |
| |
| function f_StatHandlerDemo_addLabel(in charstring pl_text, in charstring pl_parentWidgetId) |
| runs on EPTF_UIHandlerClient_CT |
| { |
| var XTDP_XML_Tag vl_xul := { |
| xtdp_labeltype := { |
| id:= omit, |
| flex := omit, |
| disabled := omit, |
| style:= omit, |
| textvalue := pl_text |
| } |
| } |
| if(sr_Success != f_EPTF_UIHandlerClient_addElementToGUI(vl_xul, pl_parentWidgetId)) { |
| log("Warning: could not add element to GUI: ", vl_xul); |
| // f_EPTF_Base_stop(); |
| } |
| } |
| |
| function f_StatHandlerDemo_addEmptyHbox( |
| in charstring pl_widgetId, // "" -> omit |
| in float pl_flex, // <0.0 -> omit |
| in boolean pl_horisontal, |
| in charstring pl_parentWidgetId) |
| runs on EPTF_UIHandlerClient_CT |
| { |
| var XTDP_XML_Tag vl_xul := { |
| xtdp_hbox := { |
| id := pl_widgetId, |
| flex := pl_flex, |
| disabled := omit, |
| orient := "vertical", |
| widgets := { |
| } |
| } |
| } |
| if(pl_widgetId == "") { vl_xul.xtdp_hbox.id := omit; } |
| if(pl_flex < 0.0) { vl_xul.xtdp_hbox.flex := omit; } |
| if(pl_horisontal) { vl_xul.xtdp_hbox.orient := "horisontal"; } |
| if(sr_Success != f_EPTF_UIHandlerClient_addElementToGUI(vl_xul, pl_parentWidgetId)) { |
| log("Error: could not add element to GUI: ", vl_xul); |
| f_EPTF_Base_stop(); |
| } |
| } |
| |
| function f_StatHandlerDemo_addEmptyTabbox( |
| in charstring pl_widgetId, |
| in float pl_flex, // <0.0 -> omit |
| in boolean pl_listcard, |
| in charstring pl_parentWidgetId) |
| runs on EPTF_UIHandlerClient_CT |
| { |
| var XTDP_XML_Tag vl_xul := { |
| xtdp_tabbox := { |
| id := pl_widgetId, |
| flex := pl_flex, |
| disabled := omit, |
| layout := omit, |
| tabs := {}, |
| tabpanels := {} |
| } |
| } |
| if(pl_flex < 0.0) { vl_xul.xtdp_tabbox.flex := omit; } |
| if(pl_listcard) { vl_xul.xtdp_tabbox.layout := listcard; } |
| if(sr_Success != f_EPTF_UIHandlerClient_addElementToGUI(vl_xul, pl_parentWidgetId)) { |
| log("Error: could not add element to GUI: ", vl_xul); |
| f_EPTF_Base_stop(); |
| } |
| } |
| |
| function f_StatHandlerDemo_addTabpanel( |
| in charstring pl_widgetId, |
| in float pl_maxheight, // <0.0 -> omit |
| in boolean pl_horisontal, |
| in charstring pl_parentWidgetId) |
| runs on EPTF_UIHandlerClient_CT |
| { |
| var XTDP_XML_Tag vl_xul := { |
| xtdp_tabpanel := { |
| id := pl_widgetId, |
| maxheight := pl_maxheight, |
| orient := "vertical", |
| widgets := {} |
| } |
| } |
| if(pl_maxheight < 0.0) { vl_xul.xtdp_tabpanel.maxheight := omit; } |
| if(pl_horisontal) { vl_xul.xtdp_tabpanel.orient := "vertical"; } |
| if(sr_Success != f_EPTF_UIHandlerClient_addElementToGUI(vl_xul, pl_parentWidgetId)) { |
| log("Error: could not add element to GUI: ", vl_xul); |
| f_EPTF_Base_stop(); |
| } |
| } |
| |
| function f_StatHandlerDemo_addTab( |
| in charstring pl_widgetId, |
| in charstring pl_label, |
| in charstring pl_parentWidgetId) |
| runs on EPTF_UIHandlerClient_CT |
| { |
| var XTDP_XML_Tag vl_xul := { |
| xtdp_tab := { |
| id := pl_widgetId, |
| tablabel := pl_label |
| } |
| } |
| if(sr_Success != f_EPTF_UIHandlerClient_addElementToGUI(vl_xul, pl_parentWidgetId)) { |
| log("Error: could not add element to GUI: ", vl_xul); |
| f_EPTF_Base_stop(); |
| } |
| } |
| |
| function f_StatHandlerDemo_addButton( |
| in charstring pl_widgetId, |
| in charstring pl_label, |
| in charstring pl_parentWidgetId, |
| in float pl_flex := 0.0, // <0.0 -> omit |
| in boolean pl_checked := false, |
| in boolean pl_disabled := false, |
| in charstring pl_type := "", // "" -> omit |
| in charstring pl_imageId := "") // "" -> omit |
| runs on EPTF_UIHandlerClient_CT |
| { |
| var XTDP_XML_Tag vl_xul := { |
| xtdp_button := { |
| checked := pl_checked, |
| disabled := pl_disabled, |
| id := pl_widgetId, |
| flex := pl_flex, |
| buttonlabel := pl_label, |
| buttontype := pl_type, |
| imageId := pl_imageId |
| } |
| } |
| if(pl_flex < 0.0) { vl_xul.xtdp_button.flex := omit; } |
| if(pl_type == "") { vl_xul.xtdp_button.buttontype := omit; } |
| if(pl_imageId == "") { vl_xul.xtdp_button.imageId := omit; } |
| if(sr_Success != f_EPTF_UIHandlerClient_addElementToGUI(vl_xul, pl_parentWidgetId)) { |
| log("Error: could not add element to GUI: ", vl_xul); |
| f_EPTF_Base_stop(); |
| } |
| } |
| |
| function f_StatHandlerDemo_createVarForButton( |
| in charstring pl_widgetId) |
| runs on EPTF_UIHandlerClient_CT |
| return integer // variable index |
| { |
| var integer vl_idx := 0; |
| |
| f_EPTF_Var_newInt( |
| c_VarPrefix&pl_widgetId, |
| 0, |
| vl_idx); |
| |
| f_EPTF_UIHandlerClient_subscribeMe( |
| c_VarPrefix&pl_widgetId, |
| c_GuiVarPrefix&pl_widgetId, |
| pl_widgetId, |
| realtime); |
| |
| return vl_idx; |
| } |
| |
| } // group GUIConvenienceFunctions |
| |
| control |
| { |
| execute(tc_StatHandlerDemo()); |
| } |
| |
| } // end of module |