| /////////////////////////////////////////////////////////////////////////////// |
| // // |
| // 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 v1.0 // |
| // which accompanies this distribution, and is available at // |
| // http://www.eclipse.org/legal/epl-v10.html // |
| /////////////////////////////////////////////////////////////////////////////// |
| |
| /////////////////////////////////////////////////////////// |
| // Module: LGen_A_Functions |
| // |
| // Purpose: |
| // Example user module containing functions for LGen type"A" |
| // in EPTF Central Scheduling Demo |
| // |
| // Module Parameters: |
| // - |
| // |
| // Module depends on: |
| // <EPTF_CLL_Base_Functions> |
| // <EPTF_CLL_CS_Definitions> |
| // <EPTF_CLL_CSAdmin_Functions> |
| // <EPTF_CLL_UIHandlerClient_Definitions> |
| // <EPTF_CLL_UIHandlerClient_Functions> |
| // <Common_Definitions> |
| // <A_defs> |
| // <CS_A_Definitions> |
| // |
| // Current Owner: |
| // Gabor Tatarka (egbotat) |
| // |
| // Last Review Date: |
| // - |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| |
| module LGen_A_Functions |
| { |
| |
| //========================================================================= |
| // Imports |
| //========================================================================= |
| |
| // EPTF imports |
| import from EPTF_CLL_Base_Functions all; |
| import from EPTF_CLL_CS_Definitions all; |
| import from EPTF_CLL_CSAdmin_Functions all; |
| import from EPTF_CLL_UIHandlerClient_Definitions all; |
| import from EPTF_CLL_UIHandlerClient_Functions all; |
| |
| // User specific imports |
| import from Common_Definitions all; |
| import from A_defs all; |
| import from CS_A_Definitions all; |
| //import from <definitions_for_port_A> all; |
| |
| |
| //========================================================================= |
| // Functions |
| //========================================================================= |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_CS_A_LGen_behavior |
| // |
| // Purpose: |
| // CS_LGen behavior function |
| // |
| // Parameters: |
| // pl_selfName - *in* *charstring* |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| /////////////////////////////////////////////////////////// |
| function f_CS_A_LGen_behavior(in charstring pl_selfName) |
| runs on CS_LGen_A_CT |
| { |
| log(%definitionId& ": started"); |
| |
| f_LGen_A_init(pl_selfName); |
| |
| CS_PCO.send(CS_A_LGenStatus:{LGenEnabled:=true}); |
| |
| log(%definitionId& ": entering main alt loop"); |
| alt { |
| []as_LGen_A_msgHandler(); |
| } |
| log(%definitionId& ": leaving main alt loop"); |
| |
| f_EPTF_Base_cleanup_CT(); |
| |
| log(%definitionId& ": finished"); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Altstep: as_LGen_A_msgHandler |
| // |
| // Purpose: |
| // LGen message handler altstep. |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| /////////////////////////////////////////////////////////// |
| altstep as_LGen_A_msgHandler() runs on CS_LGen_A_CT |
| { |
| []CS_PCO.receive(CS_A_LGenExecuteTrafficCaseList:?) -> value v_execBurst_msg |
| { |
| v_execBurstResult_msg := {} |
| for(v_execBurstIdx := 0; |
| v_execBurstIdx < sizeof(v_execBurst_msg); |
| v_execBurstIdx := v_execBurstIdx + 1) { |
| |
| f_LGen_A_trafficCaseSelector(); |
| } |
| CS_PCO.send(v_execBurstResult_msg); |
| repeat; |
| } |
| []CS_PCO.receive |
| { |
| log(%definitionId& ": unexpected message received from admin."); |
| f_EPTF_Base_stop(); |
| } |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_LGen_A_init |
| // |
| // Purpose: |
| // CS_LGen initialisation |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| /////////////////////////////////////////////////////////// |
| function f_LGen_A_init(in charstring pl_selfName) runs on CS_LGen_A_CT |
| { |
| log("f_LGen_A_init() started"); |
| f_EPTF_CS_LGenBase_init_CT(pl_selfName); |
| f_EPTF_UIHandlerClient_init_CT( |
| pl_selfName, |
| mtc) |
| |
| map(self:PIPEasp_PCO, system:PIPEasp_PCO); |
| |
| f_EPTF_Base_registerCleanup(refers(f_LGen_A_cleanup)); |
| |
| log("f_LGen_A_init() finished"); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_LGen_A_cleanup |
| // |
| // Purpose: |
| // CS_LGen cleanup (executed after leaving the main EH) |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| /////////////////////////////////////////////////////////// |
| function f_LGen_A_cleanup() runs on CS_LGen_A_CT |
| { |
| log("f_LGen_A_cleanup() started"); |
| |
| CS_PCO.send(CS_A_LGenStatus:{LGenEnabled:=false}); |
| |
| unmap(self:PIPEasp_PCO, system:PIPEasp_PCO); |
| |
| log("f_LGen_A_cleanup() finished"); |
| } |
| |
| |
| function f_LGen_A_trafficCaseSelector() runs on CS_LGen_A_CT |
| { |
| // Select and execute traffic case |
| select (v_execBurst_msg[v_execBurstIdx].trafficCaseSelector) |
| { |
| case (0) {f_LGen_A_trafficCase_0();} |
| case (1) {f_LGen_A_trafficCase_1();} |
| case (2) {f_LGen_A_trafficCase_2();} |
| case (3) {f_LGen_A_trafficCase_3();} |
| |
| case else { |
| log(%definitionId& ": unhandled traffic case: ", v_execBurst_msg[v_execBurstIdx].trafficCaseSelector); |
| f_EPTF_Base_stop(); |
| } |
| } |
| } |
| |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_LGen_A_PreExec |
| // |
| // Purpose: |
| // Implementation of preexec function on LGen |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // Note that this is an example only |
| /////////////////////////////////////////////////////////// |
| function f_LGen_A_PreExec() runs on CS_LGen_A_CT |
| { |
| // Do something... |
| timer T_rnd := 3.0*rnd() + 0.1; |
| T_rnd.start; |
| T_rnd.timeout; |
| |
| log("f_LGen_A_PreExec() for traffic case ", v_execBurst_msg[v_execBurstIdx].trafficCaseSelector, " executed"); |
| |
| // Compose the result... |
| v_execBurstResult_msg[v_execBurstIdx] := { |
| trafficCaseSelector := v_execBurst_msg[v_execBurstIdx].trafficCaseSelector, |
| execResult := pass, |
| data := {tcData := v_execBurst_msg[v_execBurstIdx].data.tcData} // echoing back... |
| } |
| } |
| |
| function f_LGen_A_trafficCase_0_pre() runs on CS_LGen_A_CT |
| { |
| log("f_LGen_A_trafficCase_0_pre() started"); |
| f_LGen_A_PreExec(); // Wrapper only |
| log("f_LGen_A_trafficCase_0_pre() finished"); |
| } |
| |
| function f_LGen_A_trafficCase_1_pre() runs on CS_LGen_A_CT |
| { |
| log("f_LGen_A_trafficCase_1_pre() started"); |
| f_LGen_A_PreExec(); // Wrapper only |
| log("f_LGen_A_trafficCase_1_pre() finished"); |
| } |
| |
| function f_LGen_A_trafficCase_2_pre() runs on CS_LGen_A_CT |
| { |
| log("f_LGen_A_trafficCase_2_pre() started"); |
| f_LGen_A_PreExec(); // Wrapper only |
| log("f_LGen_A_trafficCase_2_pre() finished"); |
| } |
| |
| function f_LGen_A_trafficCase_3_pre() runs on CS_LGen_A_CT |
| { |
| log("f_LGen_A_trafficCase_3_pre() started"); |
| f_LGen_A_PreExec(); // Wrapper only |
| log("f_LGen_A_trafficCase_3_pre() finished"); |
| } |
| |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_LGen_A_PostExec |
| // |
| // Purpose: |
| // Implementation of postexec function on LGen |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // Note that this is an example only |
| /////////////////////////////////////////////////////////// |
| function f_LGen_A_PostExec() runs on CS_LGen_A_CT |
| { |
| // Do something... |
| timer T_rnd := 5.0*rnd() + 0.1; |
| T_rnd.start; |
| T_rnd.timeout; |
| |
| log("f_LGen_A_PostExec() for traffic case ", v_execBurst_msg[v_execBurstIdx].trafficCaseSelector, " executed"); |
| |
| // Compose the result... |
| v_execBurstResult_msg[v_execBurstIdx] := { |
| trafficCaseSelector := v_execBurst_msg[v_execBurstIdx].trafficCaseSelector, |
| execResult := pass, |
| data := {tcData := v_execBurst_msg[v_execBurstIdx].data.tcData} // echoing back... |
| } |
| } |
| |
| function f_LGen_A_trafficCase_0_post() runs on CS_LGen_A_CT |
| { |
| log("f_LGen_A_trafficCase_0_post() started"); |
| f_LGen_A_PostExec(); // Wrapper only |
| log("f_LGen_A_trafficCase_0_post() finished"); |
| } |
| |
| function f_LGen_A_trafficCase_1_post() runs on CS_LGen_A_CT |
| { |
| log("f_LGen_A_trafficCase_1_post() started"); |
| f_LGen_A_PostExec(); // Wrapper only |
| log("f_LGen_A_trafficCase_1_post() finished"); |
| } |
| |
| function f_LGen_A_trafficCase_2_post() runs on CS_LGen_A_CT |
| { |
| log("f_LGen_A_trafficCase_2_post() started"); |
| f_LGen_A_PostExec(); // Wrapper only |
| log("f_LGen_A_trafficCase_2_post() finished"); |
| } |
| |
| function f_LGen_A_trafficCase_3_post() runs on CS_LGen_A_CT |
| { |
| log("f_LGen_A_trafficCase_3_post() started"); |
| f_LGen_A_PostExec(); // Wrapper only |
| log("f_LGen_A_trafficCase_3_post() finished"); |
| } |
| |
| |
| function f_LGen_A_trafficCase_0() runs on CS_LGen_A_CT |
| { |
| log("f_LGen_A_trafficCase_0() started"); |
| |
| select (v_execBurst_msg[v_execBurstIdx].data.execPhase) |
| { |
| case (execCTRL_PREEXEC) { |
| log("f_LGen_A_trafficCase_0(): executing preexec..."); |
| f_LGen_A_trafficCase_0_pre(); |
| } |
| |
| case (execCTRL_LOADGEN) { |
| log("f_LGen_A_trafficCase_0(): executing the traffic case..."); |
| // put the tc logic/function calls here... |
| |
| timer T; |
| T.start(1.0); |
| T.timeout; |
| // Compose the result... |
| v_execBurstResult_msg[v_execBurstIdx] := { |
| trafficCaseSelector := v_execBurst_msg[v_execBurstIdx].trafficCaseSelector, |
| execResult := pass, |
| data := {tcData := v_execBurst_msg[v_execBurstIdx].data.tcData} // echoing back... |
| } |
| } |
| |
| case (execCTRL_POSTEXEC) { |
| log("f_LGen_A_trafficCase_0(): executing postexec..."); |
| f_LGen_A_trafficCase_0_post(); |
| } |
| |
| case else { |
| log(%definitionId& ": unhandled exec phase case: ", v_execBurst_msg[v_execBurstIdx].data.execPhase); |
| f_EPTF_Base_stop(); |
| } |
| } |
| |
| log("f_LGen_A_trafficCase_0() finished"); |
| } |
| |
| function f_LGen_A_trafficCase_1() runs on CS_LGen_A_CT |
| { |
| log("f_LGen_A_trafficCase_1() started"); |
| |
| select (v_execBurst_msg[v_execBurstIdx].data.execPhase) |
| { |
| case (execCTRL_PREEXEC) { |
| log("f_LGen_A_trafficCase_1(): executing preexec..."); |
| f_LGen_A_trafficCase_1_pre(); |
| } |
| |
| case (execCTRL_LOADGEN) { |
| log("f_LGen_A_trafficCase_1(): executing the traffic case..."); |
| // put the tc logic/function calls here... |
| |
| timer T; |
| T.start(1.0); |
| T.timeout; |
| |
| // Compose the result... |
| v_execBurstResult_msg[v_execBurstIdx] := { |
| trafficCaseSelector := v_execBurst_msg[v_execBurstIdx].trafficCaseSelector, |
| execResult := pass, |
| data := {tcData := v_execBurst_msg[v_execBurstIdx].data.tcData} // echoing back... |
| } |
| } |
| |
| case (execCTRL_POSTEXEC) { |
| log("f_LGen_A_trafficCase_1(): executing postexec..."); |
| f_LGen_A_trafficCase_1_post(); |
| } |
| |
| case else { |
| log(%definitionId& ": unhandled exec phase case: ", v_execBurst_msg[v_execBurstIdx].data.execPhase); |
| f_EPTF_Base_stop(); |
| } |
| } |
| |
| log("f_LGen_A_trafficCase_1() finished"); |
| } |
| |
| function f_LGen_A_trafficCase_2() runs on CS_LGen_A_CT |
| { |
| log("f_LGen_A_trafficCase_2() started"); |
| |
| select (v_execBurst_msg[v_execBurstIdx].data.execPhase) |
| { |
| case (execCTRL_PREEXEC) { |
| log("f_LGen_A_trafficCase_2(): executing preexec..."); |
| f_LGen_A_trafficCase_2_pre(); |
| } |
| |
| case (execCTRL_LOADGEN) { |
| log("f_LGen_A_trafficCase_2(): executing the traffic case..."); |
| |
| // "Burn" CPU... |
| timer t := 0.05; |
| t.start; |
| alt |
| { |
| [] t.timeout {} |
| [else] { var integer i := 0; repeat } |
| } // alt |
| |
| |
| // Compose the result... |
| v_execBurstResult_msg[v_execBurstIdx] := { |
| trafficCaseSelector := v_execBurst_msg[v_execBurstIdx].trafficCaseSelector, |
| execResult := pass, |
| data := {tcData := v_execBurst_msg[v_execBurstIdx].data.tcData} // echoing back... |
| } |
| } |
| |
| case (execCTRL_POSTEXEC) { |
| log("f_LGen_A_trafficCase_2(): executing postexec..."); |
| f_LGen_A_trafficCase_2_post(); |
| } |
| |
| case else { |
| log(%definitionId& ": unhandled exec phase case: ", v_execBurst_msg[v_execBurstIdx].data.execPhase); |
| f_EPTF_Base_stop(); |
| } |
| } |
| |
| log("f_LGen_A_trafficCase_2() finished"); |
| } |
| |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_LGen_A_trafficCase_3 |
| // |
| // Purpose: |
| // Implementation a traffic case on LGen |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // Note that this is an example only. |
| // WARNING! This functions generates high CPU load for demostration purposes |
| // on the tester machine using a classic design anti-pattern. |
| // Do not use this code in normal LGens! |
| /////////////////////////////////////////////////////////// |
| function f_LGen_A_trafficCase_3() runs on CS_LGen_A_CT |
| { |
| log("f_LGen_A_trafficCase_3() started"); |
| |
| select (v_execBurst_msg[v_execBurstIdx].data.execPhase) |
| { |
| case (execCTRL_PREEXEC) { |
| log("f_LGen_A_trafficCase_3(): executing preexec..."); |
| f_LGen_A_trafficCase_3_pre(); |
| } |
| |
| case (execCTRL_LOADGEN) { |
| log("f_LGen_A_trafficCase_3(): executing the traffic case..."); |
| |
| // "Burn" CPU... |
| timer t := 0.08; |
| t.start; |
| alt |
| { |
| [] t.timeout {} |
| [else] { var integer i := 0; repeat } |
| } // alt |
| |
| |
| // Compose the result... |
| v_execBurstResult_msg[v_execBurstIdx] := { |
| trafficCaseSelector := v_execBurst_msg[v_execBurstIdx].trafficCaseSelector, |
| execResult := pass, |
| data := {tcData := v_execBurst_msg[v_execBurstIdx].data.tcData} // echoing back... |
| } |
| } |
| |
| case (execCTRL_POSTEXEC) { |
| log("f_LGen_A_trafficCase_3(): executing postexec..."); |
| f_LGen_A_trafficCase_3_post(); |
| } |
| |
| case else { |
| log(%definitionId& ": unhandled exec phase case: ", v_execBurst_msg[v_execBurstIdx].data.execPhase); |
| f_EPTF_Base_stop(); |
| } |
| } |
| |
| log("f_LGen_A_trafficCase_3() finished"); |
| } |
| |
| |
| |
| } // module |
| |
| |