| //////////////////////////////////////////////// |
| // User file for EPTF Central scheduling demo |
| // |
| // Contains user functions for Admin type"A" |
| // |
| //////////////////////////////////////////////// |
| /////////////////////////////////////////////////////////////////////////////// |
| // // |
| // Copyright (c) 2000-2017 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: CS_A_Functions |
| // |
| // Purpose: |
| // Example user module containing functions for Admin type"A" |
| // in EPTF Central Scheduling Demo |
| // |
| // Module Parameters: |
| // - |
| // |
| // Module depends on: |
| // <EPTF_CLL_Common_Definitions> |
| // <EPTF_CLL_Base_Definitions> |
| // <EPTF_CLL_Base_Functions> |
| // <EPTF_CLL_LGenBase_Functions> |
| // <EPTF_CLL_LGenBase_Definitions> |
| // <EPTF_CLL_LoggingUI_Definitions> |
| // <EPTF_CLL_CS_Definitions> |
| // <EPTF_CLL_CSUIHandler_Definitions> |
| // <EPTF_CLL_CSUIHandler_Functions> |
| // <EPTF_CLL_CSAdmin_Functions> |
| // <Common_Definitions> |
| // <A_defs> |
| // <CS_A_Definitions> |
| // <EPTF_CLL_ExecCtrl_Definitions> |
| // <EPTF_CLL_ExecCtrl_Functions> |
| // <LGen_A_Functions> |
| // <EPTF_CLL_UIHandler_Definitions> |
| // |
| // Current Owner: |
| // Gabor Tatarka (egbotat) |
| // |
| // Last Review Date: |
| // - |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| |
| |
| module CS_A_Functions |
| { |
| |
| //========================================================================= |
| // Imports |
| //========================================================================= |
| |
| import from EPTF_CLL_Common_Definitions all; |
| import from EPTF_CLL_Base_Definitions all; |
| import from EPTF_CLL_Base_Functions all; |
| import from EPTF_CLL_LGenBase_Functions all; |
| import from EPTF_CLL_LGenBase_Definitions all; |
| import from EPTF_CLL_LoggingUI_Definitions all; |
| |
| import from EPTF_CLL_CS_Definitions all; |
| import from EPTF_CLL_CSUIHandler_Definitions all; |
| import from EPTF_CLL_CSUIHandler_Functions all; |
| import from EPTF_CLL_CSAdmin_Functions all; |
| |
| import from Common_Definitions all; |
| import from A_defs all; |
| import from CS_A_Definitions all; |
| |
| import from EPTF_CLL_ExecCtrl_Definitions all; |
| import from EPTF_CLL_ExecCtrl_Functions all; |
| |
| import from LGen_A_Functions all; // behavior f. |
| |
| // For creating GUI elements |
| import from EPTF_CLL_UIHandler_Definitions all; |
| //import from EPTF_CLL_UIHandlerClient_Functions all; |
| //import from XTDP_PDU_Defs language "ASN.1:2002" all; |
| //import from EPTF_CLL_XTDP_Templates all; |
| |
| //========================================================================= |
| // Functions |
| //========================================================================= |
| |
| /////////////////////////////////////////////////////////////// |
| // Function: f_CS_A_ApplAdminBehavior |
| // |
| // Purpose: |
| // Wrapper function for hiding function reference parameter with 'runs on self' |
| // for the Admin behavior function. |
| // |
| // Parameters: |
| // pl_adminName - *in* *charstring* |
| // pl_adminIdx - *in* *integer* |
| // pl_execCtrlRef - *in* *EPTF_ExecCtrl_CT* |
| // pl_useLoadBalancing - *in* *boolean* |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| /////////////////////////////////////////////////////////// |
| function f_CS_A_ApplAdminBehavior( |
| in charstring pl_adminName, |
| in integer pl_adminIdx, |
| in EPTF_ExecCtrl_CT pl_execCtrlRef, |
| in boolean pl_useLoadBalancing) |
| runs on CS_ApplAdmin_A_CT |
| { |
| f_EPTF_CS_Admin_behavior( |
| pl_adminName, |
| pl_adminIdx, |
| pl_execCtrlRef, |
| refers(f_CS_A_init), |
| pl_useLoadBalancing); |
| } |
| |
| /////////////////////////////////////////////////////////////// |
| // Function: f_CS_A_ApplAdminUIBehavior |
| // |
| // Purpose: |
| // Wrapper function for hiding function reference parameter with 'runs on self' |
| // for the Admin UIHandler behavior function. |
| // |
| // Parameters: |
| // pl_adminName - *in* *charstring* |
| // pl_adminIdx - *in* *integer* |
| // pl_execCtrlRef - *in* *EPTF_ExecCtrl_CT* |
| // pl_UIHandlerRef - *in* *EPTF_UIHandler_CT* |
| // pl_useLoadBalancing - *in* *boolean* |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| /////////////////////////////////////////////////////////// |
| function f_CS_A_ApplAdminUIBehavior( |
| in charstring pl_adminName, |
| in integer pl_adminIdx, |
| in EPTF_ExecCtrl_CT pl_execCtrlRef, |
| in EPTF_UIHandler_CT pl_UIHandlerRef, |
| in boolean pl_useLoadBalancing, |
| in EPTF_LoggingUI_CT pl_loggingUi_compRef := null) |
| runs on CS_ApplAdmin_A_CT |
| { |
| f_EPTF_CS_Admin_UIHandler_behavior( |
| pl_adminName, |
| pl_adminIdx, |
| pl_execCtrlRef, |
| pl_UIHandlerRef, |
| refers(f_CS_A_init), |
| pl_useLoadBalancing, |
| pl_loggingUi_compRef); |
| } |
| |
| /////////////////////////////////////////////////////////////// |
| // Function: f_CS_A_createLGen |
| // |
| // Purpose: |
| // Creates CS LGen with the appropriate (user-defined) |
| // component type for the library, connects the CS ports and starts its behavior. |
| // |
| // Parameters: |
| // pl_LGenName - *in* *charstring* |
| // pl_LGenHostName - *in* *charstring* |
| // |
| // Return Value: |
| // <CS_LGen_A_CT> - component reference of the created and started component |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| /////////////////////////////////////////////////////////// |
| function f_CS_A_createLGen( |
| in integer pl_LGenIndex, |
| in charstring pl_LGenName, |
| in charstring pl_LGenHostName) |
| runs on CS_ApplAdmin_A_CT |
| return EPTF_Base_CT |
| { |
| var CS_LGen_A_CT vl_lgen; |
| if(pl_LGenHostName == "") { |
| vl_lgen := CS_LGen_A_CT.create; |
| } else { |
| vl_lgen := CS_LGen_A_CT.create(-, pl_LGenHostName); |
| } |
| connect(self:CS_PCO, vl_lgen:CS_PCO); |
| vl_lgen.start(f_CS_A_LGen_behavior(pl_LGenName)); |
| return f_EPTF_Base_downcast(f_EPTF_Base_upcast(vl_lgen)); //convert to integer then to EPTF_Base_CT |
| } |
| |
| |
| /////////////////////////////////////////////////////////////// |
| // Function: as_CS_A_msgHandler |
| // |
| // Purpose: |
| // User-defined altstep for message handling |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| /////////////////////////////////////////////////////////// |
| altstep as_CS_A_msgHandler() runs on CS_ApplAdmin_A_CT |
| { |
| []CS_PCO.receive(CS_A_LGenExecutionResultList:?) -> value v_execBurstResult_msg sender v_lgenCompRef |
| { |
| var integer vl_LGenIdx := f_EPTF_CS_lookupBySenderAddress(v_lgenCompRef); |
| |
| for(v_execBurstIdx := 0; |
| v_execBurstIdx < sizeof(v_execBurstResult_msg); |
| v_execBurstIdx := v_execBurstIdx + 1) { |
| |
| f_EPTF_CS_handleExecResult( |
| v_execBurstResult_msg[v_execBurstIdx].execResult, |
| v_execBurstIdx, |
| vl_LGenIdx); |
| |
| f_CS_A_updateDB(); |
| } |
| |
| f_EPTF_CS_LGenBurstFinished(vl_LGenIdx); |
| |
| repeat; |
| } |
| []CS_PCO.receive(CS_A_LGenStatus:?) -> value v_lgenStatus_msg sender v_lgenCompRef |
| { |
| f_EPTF_CS_handleLGenStatusMsg(v_lgenStatus_msg.LGenEnabled, v_lgenCompRef); |
| repeat; |
| } |
| []CS_PCO.receive |
| { |
| log(%definitionId& ": unexpected message received from LGen."); |
| f_EPTF_Base_stop(); |
| } |
| } |
| |
| /////////////////////////////////////////////////////////////// |
| // Function: f_CS_A_addExecBurstElem |
| // |
| // Purpose: |
| // User-defined exec-burst message composing function |
| // This function should not send the execBurst message |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| /////////////////////////////////////////////////////////// |
| function f_CS_A_addExecBurstElem( |
| in integer pl_trafficCaseSelector, |
| in EPTF_IntegerList pl_currentRangeItems) |
| runs on CS_ApplAdmin_A_CT |
| { |
| v_execBurstIdx := sizeof(v_execBurst_msg); |
| |
| // 0..2: TC 0 PreExec/LoadGen/PostExec |
| // 3..5: TC 1 PreExec/LoadGen/PostExec |
| // 6..8: TC 2 PreExec/LoadGen/PostExec |
| // 9..11: TC 3 PreExec/LoadGen/PostExec |
| |
| if(pl_trafficCaseSelector < 0 or |
| pl_trafficCaseSelector > c_A_numTc * c_CS_TcIdx_TcMultiplierFactor -1 ) { |
| log(%definitionId& ": unhandled traffic case ", pl_trafficCaseSelector); |
| f_EPTF_Base_stop(); |
| } |
| v_trafficCaseIdx := pl_trafficCaseSelector / c_CS_TcIdx_TcMultiplierFactor; |
| |
| if(pl_trafficCaseSelector mod c_CS_TcIdx_TcMultiplierFactor == c_CS_TcIdx_Remainder_PREEXEC) { |
| v_execPhase := execCTRL_PREEXEC; |
| } else if(pl_trafficCaseSelector mod c_CS_TcIdx_TcMultiplierFactor == c_CS_TcIdx_Remainder_LOADGEN) { |
| v_execPhase := execCTRL_LOADGEN; |
| } else if(pl_trafficCaseSelector mod c_CS_TcIdx_TcMultiplierFactor == c_CS_TcIdx_Remainder_POSTEXEC) { |
| v_execPhase := execCTRL_POSTEXEC; |
| } else { |
| f_EPTF_Base_assert(%definitionId& ": unknown execPhase!", false) |
| } |
| |
| v_currentRangeItems := pl_currentRangeItems; |
| |
| log(%definitionId& ": v_execBurstIdx=", v_execBurstIdx, ", v_trafficCaseIdx=", v_trafficCaseIdx, |
| ", v_execPhase=", v_execPhase, ", v_currentRangeItems=", v_currentRangeItems); |
| |
| f_CS_A_queryDB(); |
| } |
| |
| /////////////////////////////////////////////////////////////// |
| // Function: f_CS_A_sendExecBurst |
| // |
| // Purpose: |
| // User-defined exec-burst message sender function |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // Base exec burst message is stored in v_execBurst_msg |
| /////////////////////////////////////////////////////////// |
| function f_CS_A_sendExecBurst() runs on CS_ApplAdmin_A_CT |
| { |
| CS_PCO.send(v_execBurst_msg) to f_EPTF_CS_Admin_getCompRefOfSelectedLGen(); // v_EPTF_CS_db_LGens.loadgens[v_EPTF_CS_selectedLGen].compRef; |
| v_execBurst_msg := {} |
| } |
| |
| /////////////////////////////////////////////////////////////// |
| // Function: f_CS_A_init |
| // |
| // Purpose: |
| // User-defined EPTF parameter initialisation for CS Admin |
| // |
| // Parameters: |
| // pl_adminName - *in* *charstring* |
| // pl_adminIdx - *in* *integer* |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| /////////////////////////////////////////////////////////// |
| function f_CS_A_init( |
| in charstring pl_adminName, |
| in integer pl_adminIdx/*, in boolean pl_loadBalancingAvailable*/) |
| runs on CS_ApplAdmin_A_CT |
| { |
| // Init database and get params... |
| log(%definitionId& " started"); |
| |
| v_adminIdx := pl_adminIdx; |
| |
| // Initializing traffic type dependent traffic case data |
| /* for (var integer i:=0;i<RV_INTPAR(v_EPTF_CS_nrOf_trafficCases_k);i:=i+1) { |
| v_A_trafficCaseData[i].userId_A_k := f_EPTF_addCharstrApplParam(int2str(i) & ".userId_A"); |
| f_EPTF_getParam(v_A_trafficCaseData[i].userId_A_k); |
| }*/ |
| |
| // Registering the functions |
| v_EPTF_CS_LGenCreate := refers(f_CS_A_createLGen); |
| v_EPTF_CS_addExecBurstElem := refers(f_CS_A_addExecBurstElem); |
| v_EPTF_CS_sendExecBurst := refers(f_CS_A_sendExecBurst); |
| |
| v_msgHandler := activate(as_CS_A_msgHandler()); |
| |
| f_EPTF_CS_Admin_setEntityNameSuffix("_A"); // resulting entity name: CS_Entity_Tc_A |
| |
| // Declaring traffic cases |
| // PreExec |
| var EPTF_CharstringList vl_tcNames := {"TC_A0", "TC_A1", "TC_A2", "TC_A3"} |
| for (var integer i:= 0; i<sizeof(vl_tcNames); i:=i+1) { |
| f_EPTF_CS_Admin_declareTrafficCase(vl_tcNames[i]&tsp_CS_preExec_Suffix, (i*c_CS_TcIdx_TcMultiplierFactor)+c_CS_TcIdx_Remainder_PREEXEC); |
| f_EPTF_CS_Admin_declareTrafficCase(vl_tcNames[i]&tsp_CS_loadGen_Suffix, (i*c_CS_TcIdx_TcMultiplierFactor)+c_CS_TcIdx_Remainder_LOADGEN); |
| f_EPTF_CS_Admin_declareTrafficCase(vl_tcNames[i]&tsp_CS_postExec_Suffix, (i*c_CS_TcIdx_TcMultiplierFactor)+c_CS_TcIdx_Remainder_POSTEXEC); |
| } |
| // f_EPTF_CS_Admin_declareTrafficCase("TC_A0_Pre", 0); |
| // f_EPTF_CS_Admin_declareTrafficCase("TC_A1_Pre", 1); |
| // f_EPTF_CS_Admin_declareTrafficCase("TC_A2_Pre", 2); |
| // f_EPTF_CS_Admin_declareTrafficCase("TC_A3_Pre", 3); |
| |
| // LoadGen |
| // f_EPTF_CS_Admin_declareTrafficCase("TC_A0", 4); |
| // f_EPTF_CS_Admin_declareTrafficCase("TC_A1", 5); |
| // f_EPTF_CS_Admin_declareTrafficCase("TC_A2", 6); |
| // f_EPTF_CS_Admin_declareTrafficCase("TC_A3", 7); |
| |
| // PostExec |
| // f_EPTF_CS_Admin_declareTrafficCase("TC_A0_Post", 8); |
| // f_EPTF_CS_Admin_declareTrafficCase("TC_A1_Post", 9); |
| // f_EPTF_CS_Admin_declareTrafficCase("TC_A2_Post", 10); |
| // f_EPTF_CS_Admin_declareTrafficCase("TC_A3_Post", 11); |
| |
| // Customizing the layout of the table ("xtdp tree") containing traffic case related data |
| /* var XTDP_XML_Tag vl_xul; |
| var integer vl_msgId := 56789; |
| var boolean vl_result; |
| var EPTF_CreateParamError vl_createParamResult; |
| |
| // Adding a new column |
| vl_msgId := vl_msgId + 1; |
| vl_xul :={ |
| xtdp_treecols := { |
| {editable := false, flex := 1.0, id := omit, columnlabel := "dummy_1", widgetType := integerField}, |
| {editable := false, flex := 1.0, id := omit, columnlabel := "dummy_2", widgetType := integerField} |
| } |
| } |
| */ |
| // f_EPTF_addElementToGui( {parentWidgetID := v_EPTF_selfName & ".hbox.trafficCases.tree"/* <<<< widgetId of the table we extend*/, xul := vl_xul}, vl_msgId, vl_result); |
| /* if (vl_result == false) { |
| log("WARNING: Unable to add element to gui: ", vl_xul); |
| } |
| */ |
| |
| log(%definitionId& " finished"); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_CS_A_composeTrafficCaseData |
| // |
| // Purpose: |
| // User-defined function, composes traffic case dependent |
| // input for LGens |
| // |
| // Parameters: |
| // p_tcData - *inout* <A_tc_union> - the data itself given |
| // as reference |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| /////////////////////////////////////////////////////////// |
| function f_CS_A_composeTrafficCaseData(inout A_tc_union p_tcData) runs on CS_ApplAdmin_A_CT |
| { |
| log("f_CS_A_composeTrafficCaseData() started"); |
| |
| var charstring vl_tmp := ""; |
| |
| select (v_trafficCaseIdx) |
| { |
| case (0) { |
| // Composing data for execute traffic case "0" |
| vl_tmp := "0: "; |
| for (var integer i:=0;i<sizeof(v_currentRangeItems);i:=i+1) { |
| vl_tmp := vl_tmp & " " & int2str(v_currentRangeItems[i]); |
| } |
| p_tcData := {tc0 := {stringField_0 := vl_tmp}} |
| |
| } |
| case (1) { |
| // Composing data for execute traffic case "1" |
| vl_tmp := "1: "; |
| for (var integer i:=0;i<sizeof(v_currentRangeItems);i:=i+1) { |
| vl_tmp := vl_tmp & " " & int2str(v_currentRangeItems[i]); |
| } |
| p_tcData := {tc1 := {stringField_1 := vl_tmp}} |
| |
| } |
| case (2) { |
| vl_tmp := "2: "; |
| // Composing data for execute traffic case "2" |
| for (var integer i:=0;i<sizeof(v_currentRangeItems);i:=i+1) { |
| vl_tmp := vl_tmp & " " & int2str(v_currentRangeItems[i]); |
| } |
| p_tcData := {tc2 := {stringField_2 := vl_tmp}} |
| |
| } |
| case (3) { |
| // Composing data for execute traffic case "3" |
| vl_tmp := "3: "; |
| for (var integer i:=0;i<sizeof(v_currentRangeItems);i:=i+1) { |
| vl_tmp := vl_tmp & " " & int2str(v_currentRangeItems[i]); |
| } |
| p_tcData := {tc3 := {stringField_3 := vl_tmp}} |
| |
| } |
| case else { |
| log(%definitionId& ": unhandled traffic case ", v_trafficCaseIdx); |
| f_EPTF_Base_stop(); |
| } |
| } |
| |
| log("f_CS_A_composeTrafficCaseData() finished"); |
| } |
| |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_CS_A_queryDB |
| // |
| // Purpose: |
| // - |
| // |
| // Parameters: |
| // - |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| /////////////////////////////////////////////////////////// |
| function f_CS_A_queryDB() runs on CS_ApplAdmin_A_CT return boolean |
| { |
| log(">>>>> f_CS_A_queryDB() started"); |
| |
| // LGen selection is already done by f_CS_A_HandleEvent_Trigger() |
| // The index of selected LGen is stored in v_EPTF_CS_selectedLGen |
| |
| var boolean pl_validTriggerPresent := false; |
| var A_tc_union vl_tcData; |
| |
| select (v_execPhase) |
| { |
| case (execCTRL_LOADGEN) { |
| if (v_trafficCaseIdx>=0) { |
| // Composing data for trigger msg |
| f_CS_A_composeTrafficCaseData(vl_tcData); |
| |
| v_execBurst_msg[v_execBurstIdx] := { |
| trafficCaseSelector := v_trafficCaseIdx, |
| data := { execPhase := v_execPhase, tcData := vl_tcData } |
| } |
| pl_validTriggerPresent := true; |
| // v_execBurst_msg[v_execBurstIdx] already composed, preparing next range param values (if any) and checking exit criteria |
| // f_EPTF_CS_handleCountAndRangeExitCriteria(RV_CHARSTRPAR(v_EPTF_CS_exitCriteria_k)); |
| |
| // f_EPTF_CS_maintainLoadGenElapsedTime(true); |
| } |
| } |
| |
| case (execCTRL_PREEXEC) { |
| // Current traffic case is enabled... |
| // Composing data for trigger msg |
| f_CS_A_composeTrafficCaseData(vl_tcData); |
| v_execBurst_msg[v_execBurstIdx] := { |
| trafficCaseSelector := v_trafficCaseIdx, |
| data := { execPhase := v_execPhase, tcData := vl_tcData } |
| } |
| pl_validTriggerPresent := true; |
| } |
| |
| case (execCTRL_POSTEXEC) { |
| // Current traffic case is enabled... |
| // Composing data for trigger msg |
| f_CS_A_composeTrafficCaseData(vl_tcData); |
| v_execBurst_msg[v_execBurstIdx] := { |
| trafficCaseSelector := v_trafficCaseIdx, |
| data := { execPhase := v_execPhase, tcData := vl_tcData } |
| } |
| pl_validTriggerPresent := true; |
| } |
| case else { |
| log(%definitionId& ": unhandled exec phase"); |
| f_EPTF_Base_stop(); |
| } |
| } // select-case |
| |
| log(">>>>> f_CS_A_queryDB() finished, triggerValid = ", pl_validTriggerPresent); |
| return pl_validTriggerPresent; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_CS_A_updateDB |
| // |
| // Purpose: |
| // User-defined function, stores date in DB according |
| // the reply message received from LGen after a traffic case execution |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| /////////////////////////////////////////////////////////// |
| function f_CS_A_updateDB() runs on CS_ApplAdmin_A_CT |
| { |
| log(">>>>> f_CS_A_updateDB() started"); |
| |
| // Update DB according to the reply message of the LGen... |
| |
| log(">>>>> f_CS_A_updateDB() finished"); |
| } |
| |
| |
| |
| } // module |