| /////////////////////////////////////////////////////////////////////////////// |
| // // |
| // 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_LoggingClient_Functions |
| // |
| // Purpose: |
| // This module contains the implementation of generic EPTF logging functions. |
| // |
| // Module depends on: |
| // |
| // Current Owner: |
| // ELSZSKU |
| // |
| // Last Review Date: |
| // 2010-xx-xx |
| // |
| // Detailed Comments: |
| // This module contains the interface functions for the EPTF_Logging client component. |
| // |
| /////////////////////////////////////////////////////////////// |
| module EPTF_CLL_LoggingClient_Functions |
| // [.objid{ itu_t(0) identified_organization(4) etsi(0) |
| // identified_organization(127) ericsson(5) testing(0) |
| { |
| import from EPTF_CLL_Base_Definitions all; |
| |
| import from EPTF_CLL_LoggingServer_Functions all; |
| import from EPTF_CLL_Common_Definitions all; |
| import from EPTF_CLL_DataSourceClient_Functions all; |
| import from EPTF_CLL_DataSource_Definitions all; |
| import from EPTF_CLL_DataSource_Functions all; |
| import from EPTF_CLL_Common_Functions all; |
| import from EPTF_CLL_Variable_Definitions all; |
| import from EPTF_CLL_Variable_Functions all; |
| import from EPTF_CLL_Logging_Functions all; |
| import from EPTF_CLL_Base_Functions all; |
| import from EPTF_CLL_LoggingServer_Definitions all; |
| |
| |
| ////////////////////////////////////////////////////////// |
| // Function: f_EPTF_LoggingClient_init_CT |
| // |
| // Purpose: |
| // Function to initialize loggingUI Client component. |
| // |
| // Parameters: |
| // pl_selfName - *in* *charstring* - name of LoggingUI client component |
| // pl_loggingServer - *in* <EPTF_LoggingServer_CT> - the main LoggingServer component |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - (none) |
| // |
| // Detailed Comments: |
| // The function initializes LoggingUI client component. Initializes Logging_CT, EPTF_Var_CT, UIHandlerClient_CT. |
| // After this sends out <EPTF_LoggingUI_Msg> type request and waits for the response. If the response arrives, the main |
| // window created and the component checkboxes can be put to the GUI. |
| // |
| /////////////////////////////////////////////////////////// |
| |
| public function f_EPTF_LoggingClient_init_CT( |
| in charstring pl_selfName, |
| in EPTF_LoggingServer_CT pl_loggingServer, |
| in EPTF_DataSource_CT pl_sourceCompRef := null) |
| runs on EPTF_LoggingClient_CT { |
| if (v_LoggingClient_initialized) {return;} |
| v_LoggingClient_initialized := true; |
| v_LoggingClient_main:=pl_loggingServer; |
| f_EPTF_Logging_init_CT(pl_selfName); |
| var charstring vl_selfName := f_EPTF_Base_selfName(); |
| f_EPTF_Var_init_CT(pl_selfName); |
| connect(self:EPTF_LoggingClientPort_CP, pl_loggingServer:EPTF_LoggingServerPort_CP); |
| v_LoggingClient_portConnected := true; |
| //Register client |
| var EPTF_Logging_Msg vl_msg; vl_msg.Logging_Hello.compName := f_EPTF_Base_selfName(); |
| EPTF_LoggingClientPort_CP.send(vl_msg); |
| EPTF_LoggingClientPort_CP.receive( tr_EPTF_Logging_clientAck ) -> value vl_msg; |
| v_LoggingClient_clientIdx := vl_msg.Logging_ClientAck.clientIdx; |
| v_LoggingClient_handleBy := activate(as_EPTF_LoggingClient_handle_Bye()); |
| //Send the selection list |
| for (var integer i:=0, vl_size := sizeof(v_Logging_selectionList); i<vl_size; i:=i+1) { |
| f_EPTF_LoggingClient_loggingUpdateSelections(i); |
| } |
| //Send the list of classes |
| for (var integer i:=0, vl_size := sizeof(v_EPTF_Logging_ComponentMask_List); i<vl_size; i:=i+1) { |
| var EPTF_Logging_Msg vl_req:={ |
| Logging_Req:={ |
| Request:=Init, |
| clientIdx:=v_LoggingClient_clientIdx, |
| compType:=v_EPTF_Logging_ComponentMask_List[i].componentTypeName, |
| selectionInClient:=v_EPTF_Logging_ComponentMask_List[i].selection, |
| eventClassNames:=v_EPTF_Logging_ComponentMask_List[i].eventClassNames |
| } |
| } |
| EPTF_LoggingClientPort_CP.send(vl_req); |
| alt { |
| [] EPTF_LoggingClientPort_CP.receive(c_Logging_resp) {} |
| } |
| f_EPTF_LoggingClient_componentGlobalSubscribeToEPTFVar(i); |
| f_EPTF_LoggingClient_componentLocalBindToEPTFVar(i); |
| } |
| f_EPTF_LoggingClient_allComponentLocalBindToEPTFVar(); |
| f_EPTF_LoggingClient_allComponentGlobalSubscribeToEPTFVar(); |
| f_EPTF_Logging_registerGUICallbacks( |
| refers(f_EPTF_LoggingClient_loggingUpdate), |
| refers(f_EPTF_LoggingClient_refreshVar), |
| refers(f_EPTF_LoggingClient_loggingUpdateSelections)); |
| f_EPTF_DataSourceClient_init_CT(vl_selfName, pl_sourceCompRef); |
| f_EPTF_DataSourceClient_registerData(c_LoggingClient_sourceId, vl_selfName, refers( f_EPTF_LoggingClient_DSProcessData ), pl_sourceCompRef) |
| f_EPTF_DataSourceClient_registerDataValue(c_LoggingClient_sourceId, vl_selfName, refers(f_EPTF_LoggingClient_DSProcessDataValue), pl_sourceCompRef); |
| |
| f_EPTF_Base_registerCleanup(refers(f_EPTF_LoggingClient_cleanup_CT)); |
| //log("----- LoggingUI init END -------"); |
| |
| } |
| |
| ////////////////////////////////////////////////////////// |
| // Function: f_EPTF_LoggingClient_cleanup_CT |
| // |
| // Purpose: |
| // Function to shutdown logging client. |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - (none) |
| // |
| // Detailed Comments: |
| // - |
| // |
| /////////////////////////////////////////////////////////// |
| |
| private function f_EPTF_LoggingClient_cleanup_CT() runs on EPTF_LoggingClient_CT { |
| //log("----- LoggingClient cleanup -------"); |
| if (v_LoggingClient_initialized == false) { |
| return; |
| } |
| if(v_LoggingClient_portConnected){ |
| EPTF_LoggingClientPort_CP.send(c_Logging_bye); |
| f_EPTF_LoggingClient_wait4ByeAck() |
| deactivate(v_LoggingClient_handleBy); |
| disconnect(self:EPTF_LoggingClientPort_CP, v_LoggingClient_main:EPTF_LoggingServerPort_CP); |
| } |
| v_LoggingClient_initialized := false; |
| |
| } |
| |
| modulepar float tsp_LoggingClient_timeout := 2.0; |
| private function f_EPTF_LoggingClient_wait4ByeAck() |
| runs on EPTF_LoggingClient_CT{ |
| v_LoggingClient_byeAckReceived := false; |
| timer t_guard; |
| t_guard.start(tsp_LoggingClient_timeout); |
| alt
|
| {
|
| [] EPTF_LoggingClientPort_CP.receive(c_Logging_byeAck){
|
| t_guard.stop;
|
| }
|
| [] t_guard.timeout{
|
| f_EPTF_Logging_error(true, %definitionId&": Bye response not received in time.");
|
| }
|
| };
|
| |
| } |
| |
| ////////////////////////////////////////////////////////// |
| // Function: f_EPTF_LoggingClient_componentLocalBindToEPTFVar |
| // |
| // Purpose: |
| // Binds boolean parameters to EPTF_variables. |
| // |
| // Parameters: |
| // pl_logMaskIdx - *in* *integer* - ID of the loggingMask |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - (none) |
| // |
| // Detailed Comments: |
| // Binds the boolean parameters to EPTF_variables. Binds <v_EPTF_Logging_ComponentMask_List.componentLocalMask> to EPTF_Var variables. |
| // |
| /////////////////////////////////////////////////////////// |
| private function f_EPTF_LoggingClient_componentLocalBindToEPTFVar( |
| in integer pl_logMaskIdx) runs on EPTF_LoggingClient_CT { |
| |
| //log("***********f_EPTF_LoggingUI_componentLocalBindToEPTFVar***************"); |
| var charstring boolVarRef; |
| //var charstring vl_selection:=f_EPTF_Logging_Selection2Str(v_EPTF_Logging_ComponentMask_List[pl_logMaskIdx].selection); |
| var charstring vl_compTypeName:=v_EPTF_Logging_ComponentMask_List[pl_logMaskIdx].componentTypeName; |
| |
| // mask bindings |
| |
| f_EPTF_Var_newBoolRef( |
| f_EPTF_LoggingClient_componentTypeLogVarName(vl_compTypeName), |
| v_EPTF_Logging_ComponentMask_List[pl_logMaskIdx].componentLocalEnable, |
| v_LoggingClient_componentLocalEnableIdx[pl_logMaskIdx]); |
| |
| for(var integer i:=0; i<sizeof(v_EPTF_Logging_ComponentMask_List[pl_logMaskIdx].eventClassNames); i:=i+1) { |
| |
| //log("EPTF_componentLocalMask: ",v_EPTF_Logging_ComponentMask_List[pl_logMaskIdx].componentLocalMask[i]); |
| |
| boolVarRef := f_EPTF_LoggingClient_componentTypeClassLogVarName(vl_compTypeName,i); |
| f_EPTF_Var_newBoolRef(boolVarRef, v_EPTF_Logging_ComponentMask_List[pl_logMaskIdx].componentLocalMask[i],v_LoggingClient_componentLocalMaskIdx[pl_logMaskIdx][i]); |
| } |
| } |
| |
| private function f_EPTF_LoggingClient_componentTypeLogVarName(in charstring pl_compTypeName) |
| runs on EPTF_Base_CT |
| return charstring{ |
| return "componentLocalEnable."&f_EPTF_Base_selfName()&"."&pl_compTypeName |
| } |
| |
| private function f_EPTF_LoggingClient_componentTypeClassLogVarName( |
| in charstring pl_compTypeName, |
| in integer pl_classIdx) |
| runs on EPTF_Base_CT |
| return charstring{ |
| return "componentLocalMask."&int2str(pl_classIdx)&f_EPTF_Base_selfName()&"."&pl_compTypeName; |
| } |
| ////////////////////////////////////////////////////////// |
| // Function: f_EPTF_LoggingUI_allComponentLocalBindToEPTFVar |
| // |
| // Purpose: |
| // Binds boolean parameters to EPTF_variables |
| // |
| // Parameters: |
| // - |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - (none) |
| // |
| // Detailed Comments: |
| // Binds the boolean parameters to EPTF_variables. Binds <v_EPTF_Logging_allComponentLocalEnable> to EPTF_Var variables. |
| // |
| /////////////////////////////////////////////////////////// |
| |
| private function f_EPTF_LoggingClient_allComponentLocalBindToEPTFVar() runs on EPTF_LoggingClient_CT { |
| |
| //log("***********f_EPTF_LoggingUI_AllComponentLoggingBindToEPTFVar***************"); |
| f_EPTF_Var_newBoolRef( |
| f_EPTF_LoggingClient_componentLogEnabledVarName(), |
| v_EPTF_Logging_allComponentLocalEnable, |
| v_LoggingClient_allComponentLocalEnableIdx); |
| } |
| |
| ////////////////////////////////////////////////////////// |
| // Function: f_EPTF_LoggingUI_allComponentLocalBindToEPTFVar |
| // |
| // Purpose: |
| // Returns the name of the EPTF Var of component log enabled state |
| ////////////////////////////////////////////////////////// |
| private function f_EPTF_LoggingClient_componentLogEnabledVarName() |
| runs on EPTF_LoggingClient_CT |
| return charstring{ |
| return "allcomponentLocalEnable."&f_EPTF_Base_selfName(); |
| } |
| ////////////////////////////////////////////////////////// |
| // Function: f_EPTF_LoggingClient_allComponentGlobalSubscribeToEPTFVar |
| // |
| // Purpose: |
| // Function to subscribe <allComponentGlobalEnable> variable to the global EPTF Variable. |
| // |
| // Parameters: |
| // - |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - (none) |
| // |
| // Detailed Comments: |
| // Main LoggingUI component creates an EPTF_Variable, and a checkbox to the GUI for this boolean variable. |
| // This function subscribes <allComponentGlobalEnable> variable to the EPTF Variable created by the main component. |
| // |
| /////////////////////////////////////////////////////////// |
| |
| private function f_EPTF_LoggingClient_allComponentGlobalSubscribeToEPTFVar() runs on EPTF_LoggingClient_CT { |
| |
| var integer idx; |
| //allComponentGlobalEnable |
| f_EPTF_Var_subscribeRemoteBoolRef(v_EPTF_Logging_allComponentGlobalEnable,v_LoggingClient_main,"allComponentGlobalEnable",realtime,idx); |
| } |
| |
| ////////////////////////////////////////////////////////// |
| // Function: f_EPTF_LoggingClient_componentGlobalSubscribeToEPTFVar |
| // |
| // Purpose: |
| // Function to subscribe <EPTF_Logging_ComponentMask.componentGlobalEnable> , |
| // <EPTF_Logging_ComponentMask.componentGlobalMask> variables to an EPTF Variable. |
| // |
| // Parameters: |
| // pl_logMaskIdx - *in* *integer* - ID of the loggingMask |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - (none) |
| // |
| // Detailed Comments: |
| // Main LoggingUI component creates an EPTF_Variable, and a checkbox to the GUI for this boolean variable. |
| // This function subscribes <EPTF_Logging_ComponentMask.componentGlobalEnable> and |
| // <EPTF_Logging_ComponentMask.componentGlobalMask> variables to the EPTF Variable created by the main component. |
| // |
| /////////////////////////////////////////////////////////// |
| |
| private function f_EPTF_LoggingClient_componentGlobalSubscribeToEPTFVar( |
| in integer pl_logMaskIdx) runs on EPTF_LoggingClient_CT { |
| |
| //var charstring vl_selection:=f_EPTF_Logging_Selection2Str(v_EPTF_Logging_ComponentMask_List[pl_logMaskIdx].selection); |
| var charstring vl_compTypeName:=v_EPTF_Logging_ComponentMask_List[pl_logMaskIdx].componentTypeName; |
| var integer idx; |
| |
| //componentGlobalEnable |
| f_EPTF_Var_subscribeRemoteBoolRef(v_EPTF_Logging_ComponentMask_List[pl_logMaskIdx].componentGlobalEnable, |
| v_LoggingClient_main, |
| f_EPTF_LoggingServer_typeEnabledVarName(vl_compTypeName), |
| realtime,idx, |
| f_EPTF_LoggingClient_componentGlobalVarName(vl_compTypeName)); |
| |
| for(var integer i:=0; i<sizeof(v_EPTF_Logging_ComponentMask_List[pl_logMaskIdx].eventClassNames); i:=i+1) { |
| //componentGlobalMask |
| f_EPTF_Var_subscribeRemoteBoolRef(v_EPTF_Logging_ComponentMask_List[pl_logMaskIdx].componentGlobalMask[i], |
| v_LoggingClient_main, |
| f_EPTF_LoggingServer_typeClassEnabledVarName( |
| vl_compTypeName, |
| v_EPTF_Logging_ComponentMask_List[pl_logMaskIdx].eventClassNames[i]), |
| realtime,idx, |
| f_EPTF_LoggingClient_componentGlobalMaskVarName(i,vl_compTypeName)); |
| } |
| } |
| |
| ////////////////////////////////////////////////////////// |
| // Function: f_EPTF_LoggingClient_loggingUpdate |
| // |
| // Purpose: |
| // Callback function for Logging_CT |
| // |
| // Parameters: |
| // pl_logMaskIdx - *in* *integer* - the the mask ID to be updated |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - (none) |
| // |
| // Detailed Comments: |
| // After calling the function <f_EPTF_Logging_registerComponentMasks> EPTF_Logging_CT uses this callback function |
| // to put the new mask parameters to the GUI. |
| // |
| /////////////////////////////////////////////////////////// |
| |
| private function f_EPTF_LoggingClient_loggingUpdate( |
| in integer pl_logMaskIdx) runs on EPTF_LoggingClient_CT { |
| if(v_LoggingClient_portConnected){ |
| //log("----- f_EPTF_LoggingUIClient_LogUpdate Callback -------"); |
| var EPTF_Logging_Msg vl_req:={ |
| Logging_Req:={ |
| Request:=Init, |
| clientIdx:=v_LoggingClient_clientIdx, |
| compType:=v_EPTF_Logging_ComponentMask_List[pl_logMaskIdx].componentTypeName, |
| selectionInClient:=v_EPTF_Logging_ComponentMask_List[pl_logMaskIdx].selection, |
| eventClassNames:=v_EPTF_Logging_ComponentMask_List[pl_logMaskIdx].eventClassNames |
| } |
| } |
| EPTF_LoggingClientPort_CP.send(vl_req); |
| alt { |
| [] EPTF_LoggingClientPort_CP.receive(c_Logging_resp) {} |
| } |
| f_EPTF_LoggingClient_componentGlobalSubscribeToEPTFVar(pl_logMaskIdx); |
| f_EPTF_LoggingClient_componentLocalBindToEPTFVar(pl_logMaskIdx); |
| |
| f_EPTF_LoggingClient_refreshAllRefs(); |
| } |
| } |
| |
| private function f_EPTF_LoggingClient_loggingUpdateSelections(in integer pl_idx) |
| runs on EPTF_LoggingClient_CT { |
| if(v_LoggingClient_portConnected){ |
| var EPTF_Logging_Msg vl_req:={ |
| Logging_NewSelection := { |
| name := v_Logging_selectionList[pl_idx], |
| selectionInClient := pl_idx, |
| clientIdx := v_LoggingClient_clientIdx |
| } |
| } |
| EPTF_LoggingClientPort_CP.send(vl_req); |
| EPTF_LoggingClientPort_CP.receive(c_Logging_resp); |
| } |
| } |
| |
| |
| ////////////////////////////////////////////////////////// |
| // Function: f_EPTF_LoggingUIClient_refreshAllRefs |
| // |
| // Purpose: |
| // Callback function for Logging_CT. Refreshes component references of all EPTF Variables. |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - (none) |
| // |
| // Detailed Comments: |
| // TITAN dynamically allocates memory for list elements. When the list become full memory reallocated. |
| // The allocated component references to EPTF Variables go wrong, so we need to refresh the component references. |
| // This function refreshes component references of all EPTF Variables. |
| // |
| /////////////////////////////////////////////////////////// |
| |
| private function f_EPTF_LoggingClient_refreshAllRefs() runs on EPTF_LoggingClient_CT { |
| var charstring vl_varName; |
| // do this for all comp variables: |
| //f_EPTF_Var_CT_LogAll("f_EPTF_LoggingUIClient_refreshAllRefs"); |
| |
| for (var integer pl_logMaskIdx:= 0; pl_logMaskIdx<sizeof(v_EPTF_Logging_ComponentMask_List); pl_logMaskIdx:=pl_logMaskIdx+1) { |
| |
| //var charstring vl_selection:=f_EPTF_Logging_Selection2Str(v_EPTF_Logging_ComponentMask_List[pl_logMaskIdx].selection); |
| var charstring vl_compTypeName:=v_EPTF_Logging_ComponentMask_List[pl_logMaskIdx].componentTypeName; |
| |
| |
| //componentGlobalEnable |
| vl_varName := f_EPTF_LoggingClient_componentGlobalVarName(vl_compTypeName); |
| f_EPTF_Var_updateRef(f_EPTF_Var_getId(vl_varName),f_EPTF_Var_getBoolRef(v_EPTF_Logging_ComponentMask_List[pl_logMaskIdx].componentGlobalEnable)); |
| |
| for(var integer i:=0; i<sizeof(v_EPTF_Logging_ComponentMask_List[pl_logMaskIdx].eventClassNames); i:=i+1) { |
| //componentGlobalMask |
| vl_varName := f_EPTF_LoggingClient_componentGlobalMaskVarName(i,vl_compTypeName); |
| f_EPTF_Var_updateRef(f_EPTF_Var_getId(vl_varName),f_EPTF_Var_getBoolRef(v_EPTF_Logging_ComponentMask_List[pl_logMaskIdx].componentGlobalMask[i])); |
| } |
| |
| // mask bindings |
| vl_varName := f_EPTF_LoggingClient_componentTypeLogVarName(vl_compTypeName); |
| f_EPTF_Var_updateRef(f_EPTF_Var_getId(vl_varName),f_EPTF_Var_getBoolRef(v_EPTF_Logging_ComponentMask_List[pl_logMaskIdx].componentLocalEnable)); |
| |
| |
| for(var integer i:=0; i<sizeof(v_EPTF_Logging_ComponentMask_List[pl_logMaskIdx].eventClassNames); i:=i+1) { |
| |
| //log("EPTF_componentLocalMask: ",v_EPTF_Logging_ComponentMask_List[pl_logMaskIdx].componentLocalMask[i]); |
| |
| vl_varName := f_EPTF_LoggingClient_componentTypeClassLogVarName(vl_compTypeName, i); |
| f_EPTF_Var_updateRef(f_EPTF_Var_getId(vl_varName),f_EPTF_Var_getBoolRef(v_EPTF_Logging_ComponentMask_List[pl_logMaskIdx].componentLocalMask[i])); |
| } |
| |
| } // for pl_logMaskIdx |
| |
| //f_EPTF_Var_CT_LogAll("Updated f_EPTF_LoggingUIClient_refreshAllRefs"); |
| } |
| |
| private function f_EPTF_LoggingClient_componentGlobalMaskVarName( |
| in integer pl_classIdx, |
| in charstring pl_compTypeName |
| ) runs on EPTF_LoggingClient_CT |
| return charstring{ |
| return "clientComponentGlobalMask."&int2str(pl_classIdx)&"."&pl_compTypeName |
| } |
| |
| private function f_EPTF_LoggingClient_componentGlobalVarName( |
| in charstring pl_compTypeName |
| ) runs on EPTF_LoggingClient_CT |
| return charstring{ |
| return "clientComponentGlobalEnable."&pl_compTypeName |
| } |
| |
| ////////////////////////////////////////////////////////// |
| // Function: f_EPTF_LoggingClient_refreshVar |
| // |
| // Purpose: |
| // Callback function for Logging_CT. Refreshes a component variable value from the EPTF Variable. |
| // |
| // Parameters: |
| // pl_logVar - *inout* *boolean* - the reference of the component variable |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - (none) |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| |
| private function f_EPTF_LoggingClient_refreshVar( |
| inout boolean pl_logVar) runs on EPTF_Var_CT { |
| if (f_EPTF_Var_boolCompRef2Id(pl_logVar)!=-1) { |
| f_EPTF_Var_adjustContent(f_EPTF_Var_boolCompRef2Id(pl_logVar),{boolVal:=pl_logVar}); |
| } else { |
| f_EPTF_Common_user(log2str(%definitionId&"(",pl_logVar,") returned -1")); |
| } |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: as_EPTF_LoggingClient_handle_Bye |
| // |
| // Purpose: |
| // Handler for Bye message |
| /////////////////////////////////////////////////////////// |
| private altstep as_EPTF_LoggingClient_handle_Bye() runs on EPTF_LoggingClient_CT { |
| //var EPTF_LoggingServer_CT vl_sender; |
| [] EPTF_LoggingClientPort_CP.receive({Logging_Bye:=?}){ |
| EPTF_LoggingClientPort_CP.send(c_Logging_byeAck); |
| disconnect(self:EPTF_LoggingClientPort_CP, v_LoggingClient_main:EPTF_LoggingServerPort_CP); |
| v_LoggingClient_portConnected := false; |
| deactivate(v_LoggingClient_handleBy); |
| repeat; |
| } |
| } |
| |
| private function f_EPTF_LoggingClient_getCTIdx(in charstring pl_cTypeName) |
| runs on EPTF_LoggingClient_CT return integer{ |
| var integer vl_typeIdx := -1; |
| for(var integer i:=0; i<sizeof(v_EPTF_Logging_ComponentMask_List) and -1 == vl_typeIdx; i:=i+1) { |
| if(v_EPTF_Logging_ComponentMask_List[i].componentTypeName==pl_cTypeName){ |
| vl_typeIdx := i; |
| } |
| } |
| if(-1 == vl_typeIdx){ |
| f_EPTF_Logging_warning(true, "Parameter "&c_LoggingClient_paramNameComponentType&"=="&pl_cTypeName&" is invalid for data element "&c_LoggingClient_dataElementLogEnabled& |
| ". There is no registered component type "&pl_cTypeName); |
| return -1; |
| } |
| return vl_typeIdx; |
| } |
| |
| |
| private function f_EPTF_LoggingClient_DSProcessData(out charstring pl_dataVarName, |
| in charstring pl_source, |
| in charstring pl_ptcName, |
| in charstring pl_element, |
| in EPTF_DataSource_Params pl_params) |
| runs on EPTF_LoggingClient_CT return integer{ |
| select( pl_element ){ |
| case ( c_LoggingClient_dataElementLogEnabled ){ |
| const EPTF_CharstringList cl_neededParams := { |
| c_LoggingClient_paramNameComponentType, |
| c_LoggingClient_paramNameClass |
| } |
| var EPTF_CharstringList vl_params |
| if(0 != f_EPTF_DataSourceClient_extractParams(c_LoggingClient_dataElementLogEnabled,pl_params, cl_neededParams, vl_params)){ |
| return -1; |
| } |
| var integer vl_mask := f_EPTF_LoggingServer_DSGetParamsMask(vl_params); |
| select( vl_mask ){
|
| case ( 0 ){ //Client log enabled
|
| pl_dataVarName := f_EPTF_LoggingClient_componentLogEnabledVarName(); |
| return 0;
|
| }
|
| case ( 1 ){ //Component type log on client enabled |
| //Check component type name |
| var integer vl_typeIdx := f_EPTF_LoggingClient_getCTIdx(vl_params[0]); |
| if(0 > vl_typeIdx){ |
| return -1; |
| } |
| pl_dataVarName := f_EPTF_LoggingClient_componentTypeLogVarName(vl_params[0]); |
| return 0; |
| } |
| case ( 3 ){ //LogClass of component type on client log enabled |
| var integer vl_typeIdx := f_EPTF_LoggingClient_getCTIdx(vl_params[0]); |
| if(0 > vl_typeIdx){ |
| return -1; |
| } |
| var integer vl_classIdx := -1; |
| for(var integer i:=0; i<sizeof(v_EPTF_Logging_ComponentMask_List[vl_typeIdx].eventClassNames) and -1 == vl_classIdx; i:=i+1) { |
| if(v_EPTF_Logging_ComponentMask_List[vl_typeIdx].eventClassNames[i]==vl_params[1]){ |
| vl_classIdx := i; |
| } |
| } |
| if(-1 == vl_classIdx){ |
| f_EPTF_Logging_warning(true, "Parameter "&c_LoggingClient_paramNameClass&"=="&vl_params[1]& |
| " for "&c_LoggingClient_dataElementLogEnabled&" is invalid. There is no registered log class "& |
| vl_params[1]&" for component type "&vl_params[0]& |
| ". Available classes: "&log2str(v_EPTF_Logging_ComponentMask_List[vl_typeIdx].eventClassNames)& |
| ". Received parameters: "&log2str(pl_params)); |
| return -1; |
| } |
| if(0 > vl_classIdx){ |
| f_EPTF_Logging_warning(true, "Invalid parameter. There is no log class "&vl_params[1]&" for component type "&vl_params[0]&"."); |
| } |
| pl_dataVarName := f_EPTF_LoggingClient_componentTypeClassLogVarName(vl_params[0], vl_classIdx); |
| return 0; |
| } |
| case ( 2 ){ //Class is set, but type not. Invalid. |
| f_EPTF_Logging_warning(true, "Parameter "&c_LoggingClient_paramNameComponentType&" must be set if you set "&c_LoggingClient_paramNameClass&" for "&c_LoggingClient_dataElementLogEnabled&"."); |
| return -1; |
| } |
| case else{
|
| f_EPTF_Logging_warning(true, "Invalid parameter set. Parametes can not be used in this combination. Received: "&log2str(pl_params)); |
| return -1; |
| }
|
| }
|
| } |
| case else{ |
| f_EPTF_Logging_warning(true, %definitionId&": Invalid external data element: "&pl_element& |
| ". Available element: "&c_LoggingClient_dataElementLogEnabled) |
| //Just to avoid compiler warnings |
| v_LoggingClient_dummyCharstring := pl_source; |
| v_LoggingClient_dummyCharstring := pl_ptcName; |
| } |
| } |
| return -1; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_LoggingClient_DSProcessDataValue |
| // |
| // Purpose: |
| // Processes the incoming DataValue requests - iterators and external data elements - and gives back the value. |
| // It should be registered in the EPTF_LoggingClient_CT. Type function fcb_EPTF_DataSourceClient_dataValueHandler |
| // |
| // Parameters: |
| // *out *<EPTF_Var_DirectContent>* pl_dataValue* - the value of the data or the iterator result |
| // *in charstring pl_source* - the name of the data source 'feature' |
| // *in charstring pl_ptcName* - the name of the ptc (ID of the PTC) |
| // *in charstring pl_element* - the name of the data element |
| // *in* <EPTF_DataSource_Params> *pl_params* - the parameters |
| // of the data for the dataElement |
| // |
| // Return Value: |
| // integer - error code (0 of OK, non zero if unsuccessful: e.g. invalid parameters given in pl_params) |
| // |
| // Detailed Comments: |
| // - |
| // |
| /////////////////////////////////////////////////////////// |
| friend function f_EPTF_LoggingClient_DSProcessDataValue(out EPTF_Var_DirectContent pl_dataValue, |
| in charstring pl_source, |
| in charstring pl_ptcName, |
| in charstring pl_element, |
| in EPTF_DataSource_Params pl_params) |
| runs on EPTF_LoggingClient_CT return integer { |
| var integer vl_errorCode := -1; |
| pl_dataValue := {unknownVal := {omit}}; // set it to invalid |
| select( pl_element ) |
| { |
| case(c_EPTF_DataSource_dataElement_Help) { |
| vl_errorCode := f_EPTF_DataSource_handleHelp(pl_dataValue, pl_source, pl_params, c_EPTF_LoggingClient_help); |
| } |
| case else |
| { |
| } |
| } |
| return vl_errorCode; |
| } |
| |
| } // end of module |