| /////////////////////////////////////////////////////////////////////////////// |
| // // |
| // 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_B_Functions |
| // |
| // Purpose: |
| // Example user module containing functions for Admin type"B" |
| // in EPTF Central Scheduling Demo |
| // |
| // Module Parameters: |
| // - |
| // |
| // Module depends on: |
| // <EPTF_CLL_Common_Definitions> |
| // <EPTF_CLL_Base_Definitions> |
| // <EPTF_CLL_Base_Functions> |
| // <EPTF_CLL_LoggingUI_Definitions> |
| // <EPTF_CLL_CS_Definitions> |
| // <EPTF_CLL_CSUIHandler_Definitions> |
| // <EPTF_CLL_CSUIHandler_Functions> |
| // <EPTF_CLL_CSAdmin_Functions> |
| // <Common_Definitions> |
| // <B_defs> |
| // <CS_B_Definitions> |
| // <EPTF_CLL_ExecCtrl_Definitions> |
| // <EPTF_CLL_ExecCtrl_Functions> |
| // <LGen_B_Functions> |
| // <EPTF_CLL_UIHandler_Definitions> |
| // |
| // Current Owner: |
| // Gabor Tatarka (egbotat) |
| // |
| // Last Review Date: |
| // - |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| |
| |
| module CS_B_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_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 B_defs all; |
| import from CS_B_Definitions all; |
| |
| import from EPTF_CLL_ExecCtrl_Definitions all; |
| import from EPTF_CLL_ExecCtrl_Functions all; |
| |
| import from LGen_B_Functions all; // behavior f. |
| |
| // For creating GUI elements |
| import from EPTF_CLL_UIHandler_Definitions all; |
| //import from XTDP_PDU_Defs language "ASN.1:2002" all; |
| //import from EPTF_CLL_XTDP_Templates all; |
| |
| //========================================================================= |
| // Functions |
| //========================================================================= |
| |
| /////////////////////////////////////////////////////////////// |
| // Function: f_CS_B_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_B_ApplAdminBehavior( |
| in charstring pl_adminName, |
| in integer pl_adminIdx, |
| in EPTF_ExecCtrl_CT pl_execCtrlRef, |
| in boolean pl_useLoadBalancing) |
| runs on CS_ApplAdmin_B_CT |
| { |
| f_EPTF_CS_Admin_behavior( |
| pl_adminName, |
| pl_adminIdx, |
| pl_execCtrlRef, |
| refers(f_CS_B_init), |
| pl_useLoadBalancing); |
| } |
| |
| /////////////////////////////////////////////////////////////// |
| // Function: f_CS_B_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_B_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_B_CT |
| { |
| f_EPTF_CS_Admin_UIHandler_behavior( |
| pl_adminName, |
| pl_adminIdx, |
| pl_execCtrlRef, |
| pl_UIHandlerRef, |
| refers(f_CS_B_init), |
| pl_useLoadBalancing, |
| pl_loggingUi_compRef); |
| } |
| |
| /////////////////////////////////////////////////////////////// |
| // Function: f_CS_B_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_B_CT> - component reference of the created and started component |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| /////////////////////////////////////////////////////////// |
| function f_CS_B_createLGen( |
| in integer pl_LGenIndex, |
| in charstring pl_LGenName, |
| in charstring pl_LGenHostName) |
| runs on CS_ApplAdmin_B_CT |
| return EPTF_Base_CT |
| { |
| var CS_LGen_B_CT vl_lgen; |
| if(pl_LGenHostName == "") { |
| vl_lgen := CS_LGen_B_CT.create(pl_LGenName); |
| } else { |
| vl_lgen := CS_LGen_B_CT.create(pl_LGenHostName, pl_LGenHostName); |
| } |
| connect(self:CS_PCO, vl_lgen:CS_PCO); |
| vl_lgen.start(f_CS_B_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_B_msgHandler |
| // |
| // Purpose: |
| // User-defined altstep for message handling |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| /////////////////////////////////////////////////////////// |
| altstep as_CS_B_msgHandler() runs on CS_ApplAdmin_B_CT |
| { |
| []CS_PCO.receive(CS_B_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_B_updateDB(); |
| } |
| |
| f_EPTF_CS_LGenBurstFinished(vl_LGenIdx); |
| |
| repeat; |
| } |
| []CS_PCO.receive(CS_B_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_B_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_B_addExecBurstElem( |
| in integer pl_trafficCaseSelector, |
| in EPTF_IntegerList pl_currentRangeItems) |
| runs on CS_ApplAdmin_B_CT |
| { |
| v_execBurstIdx := sizeof(v_execBurst_msg); |
| |
| v_trafficCaseIdx := pl_trafficCaseSelector; |
| |
| if(pl_trafficCaseSelector < 0 or |
| pl_trafficCaseSelector > 3) { |
| log(%definitionId& ": unhandled traffic case ", pl_trafficCaseSelector); |
| f_EPTF_Base_stop(); |
| } |
| |
| if(v_trafficCaseIdx == 0) { v_execPhase := execCTRL_PREEXEC; } |
| else if(v_trafficCaseIdx == 3) { v_execPhase := execCTRL_POSTEXEC; } |
| else { v_execPhase := execCTRL_LOADGEN; } |
| |
| v_currentRangeItems := pl_currentRangeItems; |
| |
| log(%definitionId& ": v_execBurstIdx=", v_execBurstIdx, ", v_trafficCaseIdx=", v_trafficCaseIdx, |
| ", v_execPhase=", v_execPhase, ", v_currentRangeItems=", v_currentRangeItems); |
| |
| f_CS_B_queryDB(); |
| } |
| |
| /////////////////////////////////////////////////////////////// |
| // Function: f_CS_B_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_B_sendExecBurst() runs on CS_ApplAdmin_B_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_B_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_B_init( |
| in charstring pl_adminName, |
| in integer pl_adminIdx/*, in boolean pl_loadBalancingAvailable*/) |
| runs on CS_ApplAdmin_B_CT |
| { |
| // Init database and get params... |
| log(%definitionId& " started"); |
| |
| // Initializing traffic type dependent traffic case data |
| /* for (var integer i:=0;i<RV_INTPAR(v_EPTF_CS_nrOf_trafficCases_k);i:=i+1) { |
| // Put your traffic case data initialisation here |
| }*/ |
| |
| // Registering functions for hookpoints |
| v_EPTF_CS_LGenCreate := refers(f_CS_B_createLGen); |
| v_EPTF_CS_addExecBurstElem := refers(f_CS_B_addExecBurstElem); |
| v_EPTF_CS_sendExecBurst := refers(f_CS_B_sendExecBurst); |
| |
| v_msgHandler := activate(as_CS_B_msgHandler()); |
| |
| f_EPTF_CS_Admin_setEntityNameSuffix("_B"); // resulting entity name: CS_Entity_Tc_B |
| |
| // Declaring traffic cases |
| f_EPTF_CS_Admin_declareTrafficCase("TC_B_Pre", 0); |
| f_EPTF_CS_Admin_declareTrafficCase("TC_B2", 1); |
| f_EPTF_CS_Admin_declareTrafficCase("TC_B3", 2); |
| f_EPTF_CS_Admin_declareTrafficCase("TC_B_Post", 3); |
| |
| // 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", 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_B_composeTrafficCaseData |
| // |
| // Purpose: |
| // User-defined function, composes traffic case dependent |
| // input for LGens |
| // |
| // Parameters: |
| // p_tcData - *inout* <B_tcdata> - the data itself given |
| // as reference |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| /////////////////////////////////////////////////////////// |
| function f_CS_B_composeTrafficCaseData(inout B_tcdata p_tcData) runs on CS_ApplAdmin_B_CT |
| { |
| log("f_CS_B_composeTrafficCaseData() started"); |
| |
| p_tcData := {intField := v_trafficCaseIdx, floatField := int2float(v_trafficCaseIdx)} |
| |
| log("f_CS_B_composeTrafficCaseData() finished"); |
| } |
| |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_CS_B_queryDB |
| // |
| // Purpose: |
| // User-defined function, collects data for composing |
| // trigger message for LGen |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| /////////////////////////////////////////////////////////// |
| function f_CS_B_queryDB() runs on CS_ApplAdmin_B_CT |
| { |
| log(">>>>> f_CS_B_queryDB() started"); |
| |
| // LGen selection is already done by the ApplAdminBase |
| // The index of selected LGen is stored in v_EPTF_CS_selectedLGen |
| |
| var B_tcdata vl_tcData; |
| |
| f_CS_B_composeTrafficCaseData(vl_tcData); |
| |
| v_execBurst_msg[v_execBurstIdx] := { |
| trafficCaseSelector := v_trafficCaseIdx, |
| data := { execPhase := v_execPhase, tcData := vl_tcData} |
| } |
| |
| log(">>>>> f_CS_B_queryDB() finished."); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_CS_B_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_B_updateDB() runs on CS_ApplAdmin_B_CT |
| { |
| log(">>>>> f_CS_B_updateDB() started"); |
| |
| // Update DB according to the reply message of the LGen... |
| |
| log(">>>>> f_CS_B_updateDB() finished"); |
| } |
| |
| } // module |