blob: 676d927508aece67fab08e88c5c859f2c8462562 [file] [log] [blame]
///////////////////////////////////////////////////////////////////////////////
// //
// 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_B_Functions
//
// Purpose:
// Example user module containing functions for LGen type"B"
// in EPTF Central Scheduling Demo
//
// Module Parameters:
// -
//
// Module depends on:
// <EPTF_CLL_Base_Functions>
// <EPTF_CLL_CS_Definitions>
// <B_defs>
// <CS_B_Definitions>
//
// Current Owner:
// Gabor Tatarka (egbotat)
//
// Last Review Date:
// -
//
// Detailed Comments:
//
///////////////////////////////////////////////////////////
module LGen_B_Functions
{
//=========================================================================
// Imports
//=========================================================================
// EPTF imports
import from EPTF_CLL_Base_Functions all;
import from EPTF_CLL_CS_Definitions all;
// User specific imports
import from B_defs all;
import from CS_B_Definitions all;
//import from <definitions_for_port_B> all;
//=========================================================================
// Functions
//=========================================================================
///////////////////////////////////////////////////////////
// Function: f_CS_B_LGen_behavior
//
// Purpose:
// CS_LGen behavior function
//
// Parameters:
// pl_selfName - *in* *charstring*
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// -
///////////////////////////////////////////////////////////
function f_CS_B_LGen_behavior(in charstring pl_selfName)
runs on CS_LGen_B_CT
{
log(%definitionId& ": started");
f_EPTF_Base_init_CT(pl_selfName);
f_LGen_B_init();
CS_PCO.send(CS_B_LGenStatus:{LGenEnabled:=true});
log(%definitionId& ": entering main alt loop");
alt {
[]as_LGen_B_msgHandler();
}
log(%definitionId& ": leaving main alt loop");
f_EPTF_Base_cleanup_CT();
log(%definitionId& ": finished");
}
///////////////////////////////////////////////////////////
// Altstep: as_LGen_B_msgHandler
//
// Purpose:
// LGen message handler altstep.
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// -
///////////////////////////////////////////////////////////
altstep as_LGen_B_msgHandler() runs on CS_LGen_B_CT
{
[]CS_PCO.receive(CS_B_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_B_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_B_init
//
// Purpose:
// CS_LGen initialisation
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// -
///////////////////////////////////////////////////////////
function f_LGen_B_init() runs on CS_LGen_B_CT
{
log("f_LGen_B_init() started");
map(self:PIPEasp_PCO, system:PIPEasp_PCO);
log("f_LGen_B_init() finished");
}
///////////////////////////////////////////////////////////
// Function: f_LGen_B_cleanup
//
// Purpose:
// CS_LGen cleanup (executed after leaving the main EH)
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// -
///////////////////////////////////////////////////////////
function f_LGen_B_cleanup() runs on CS_LGen_B_CT
{
log("f_LGen_B_cleanup() started");
unmap(self:PIPEasp_PCO, system:PIPEasp_PCO);
log("f_LGen_B_cleanup() finished");
}
function f_LGen_B_trafficCaseSelector() runs on CS_LGen_B_CT
{
// Select and execute traffic case
select (v_execBurst_msg[v_execBurstIdx].trafficCaseSelector)
{
case (0) {f_LGen_B_PreExec();}
case (1) {f_LGen_B_trafficCase_2();}
case (2) {f_LGen_B_trafficCase_3();}
case (3) {f_LGen_B_PostExec();}
case else {
log("f_LGen_B_trafficCaseSelector(): unhandled traffic case: ",
v_execBurst_msg[v_execBurstIdx].trafficCaseSelector);
f_EPTF_Base_stop();
}
}
}
///////////////////////////////////////////////////////////
// Function: f_LGen_B_PreExec
//
// Purpose:
// Implementation of preexec function on LGen
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// Note that this is an example only
///////////////////////////////////////////////////////////
function f_LGen_B_PreExec() runs on CS_LGen_B_CT
{
// Do something...
timer T_rnd := 3.0*rnd() + 0.1;
T_rnd.start;
T_rnd.timeout;
log("f_LGen_B_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 := {
v_execBurst_msg[v_execBurstIdx].data.tcData // echoing back...
}
}
}
///////////////////////////////////////////////////////////
// Function: f_LGen_B_PostExec
//
// Purpose:
// Implementation of postexec function on LGen
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// Note that this is an example only
///////////////////////////////////////////////////////////
function f_LGen_B_PostExec() runs on CS_LGen_B_CT
{
// Do something...
timer T_rnd := 5.0*rnd() + 0.1;
T_rnd.start;
T_rnd.timeout;
log("f_LGen_B_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 := {
v_execBurst_msg[v_execBurstIdx].data.tcData // echoing back...
}
}
}
function f_LGen_B_trafficCase_2() runs on CS_LGen_B_CT
{
log("f_LGen_B_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 := {
v_execBurst_msg[v_execBurstIdx].data.tcData // echoing back...
}
}
log("f_LGen_B_trafficCase_2() finished");
}
///////////////////////////////////////////////////////////
// Function: f_LGen_B_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_B_trafficCase_3() runs on CS_LGen_B_CT
{
log("f_LGen_B_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 := {
v_execBurst_msg[v_execBurstIdx].data.tcData // echoing back...
}
}
log("f_LGen_B_trafficCase_3() finished");
}
} // module