blob: 3b40cbde1ea184d31b3a6c53c422828fa6de37a8 [file] [log] [blame]
///////////////////////////////////////////////////////////////////////////////
// //
// 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_CS_DSFunctions
//
// Purpose:
// This module contains the implementation of EPTF_CLL_CS_DSFunctions functions.
//
// Module depends on:
// <EPTF_CLL_Common_Definitions>
// <EPTF_CLL_DataSource_Definitions>
// <EPTF_CLL_DataSourceClient_Functions>
// <EPTF_CLL_Variable_Functions>
//
// Module Parameters:
//
// Current Owner:
// Mihaly Miko (emihmik)
//
// Last Review Date:
// 2011-08-08
//
// Detailed Comments:
//
// Public functions:
// -
//
// All other functions in this module are private!
//
///////////////////////////////////////////////////////////////
module EPTF_CLL_CS_DSFunctions {
//=========================================================================
// Import Part
//=========================================================================
import from EPTF_CLL_Common_Definitions all;
import from EPTF_CLL_CS_Definitions all;
import from EPTF_CLL_DataSource_Definitions all;
import from EPTF_CLL_Variable_Functions all;
import from EPTF_CLL_Base_Functions all;
import from EPTF_CLL_Logging_Functions all
friend module EPTF_CLL_CSAdmin_Functions;
//=========================================================================
// Functions
//========================================================================
///////////////////////////////////////////////////////////
// Function: f_EPTF_CS_warning
//
// Purpose:
// Function to log a warning from CentralScheduling feature.
//
// Parameters:
// - pl_message - *in* *charstring* - the message to log
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
friend function f_EPTF_CS_warning(in @lazy charstring pl_message)
runs on EPTF_CS_ApplAdminBase_CT
{
f_EPTF_Logging_warningV2(pl_message, v_CS_ApplAdminBase_loggingMaskId, {c_EPTF_CS_loggingClassIdx_Warning});
}
///////////////////////////////////////////////////////////
// Group: DataSourceClient
//
// Purpose:
// Functions related to DataSourceClient feature of the CentralScheduling
//
///////////////////////////////////////////////////////////
group DataSourceClient {
///////////////////////////////////////////////////////////
// Function: f_EPTF_CS_DSProcessData
//
// Purpose:
// Processes the incoming Data requests - iterators and external data elements - and gives back a variable name.
// Type function fcb_EPTF_DataSourceClient_dataHandler
//
// Parameters:
// *out charstring pl_dataVarName* - this variable contains 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_CS_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_CS_ApplAdminBase_CT return integer{
var EPTF_CharstringList pl_result := {}
pl_dataVarName := "";
var charstring vl_prefix := f_EPTF_Base_selfName() & ".";
select(pl_element){
case(c_EPTF_CS_AvgLGenUsage){
if(0 == f_EPTF_CS_getParams(pl_params, {}, pl_result)){
pl_dataVarName := vl_prefix & c_EPTF_CS_AvgLGenUsage;
}
}
case(c_EPTF_CS_MaxLGenUsage){
if(0 == f_EPTF_CS_getParams(pl_params, {}, pl_result)){
pl_dataVarName := vl_prefix & c_EPTF_CS_MaxLGenUsage;
}
}
case else { //error, no rule for that
pl_dataVarName := "";
f_EPTF_CS_warning(%definitionId& ": unhandled element: "& pl_element);
return -1;
}
}
var integer vl_iteratorVarIdx := f_EPTF_Var_getId(pl_dataVarName);
if(vl_iteratorVarIdx == -1){
f_EPTF_CS_warning(%definitionId&": Invalid iterator or externalData or parameter: "&
"\nSource: "&pl_source&
"\nPTC : "&pl_ptcName &
"\nElement Name : " &pl_element&
"\nParams: " & log2str(pl_params));
return -1;
}
return 0;
}
private function f_EPTF_CS_getParams(in EPTF_DataSource_Params pl_params,
in EPTF_CharstringList pl_needed,
out EPTF_CharstringList pl_result,
in boolean pl_noWarning := false)
runs on EPTF_CS_ApplAdminBase_CT return integer {
pl_result := {};
if(sizeof(pl_params) == sizeof(pl_needed)){
for(var integer j := 0; j < sizeof(pl_needed); j := j + 1){
for(var integer i := 0; i < sizeof(pl_params); i:= i + 1){
if(pl_params[i].paramName == pl_needed[j]){
pl_result[sizeof(pl_result)] := pl_params[i].paramValue;
}
}
}
if(sizeof(pl_result) != sizeof(pl_needed)){
if(not pl_noWarning){
var EPTF_CharstringList vl_error := {};
for(var integer i := 0; i < sizeof(pl_params); i:= i + 1){
vl_error[i] := pl_params[i].paramName;
}
f_EPTF_CS_warning(%definitionId& ": Parameters are not correct: "&
"\nReceived: "& log2str(vl_error)&
"\nNeeded : "& log2str(pl_needed) );
}
return -1;
}
return 0;
} else{
if(not pl_noWarning){
var EPTF_CharstringList vl_error := {};
for(var integer i := 0; i < sizeof(pl_params); i:= i + 1){
vl_error[i] := pl_params[i].paramName;
}
if(sizeof(pl_params) < sizeof(pl_needed)){
f_EPTF_CS_warning(%definitionId& ": Too few parameter is given: "&
"\nReceived: "& log2str(vl_error)&
"\nNeeded : "& log2str(pl_needed));
} else {
f_EPTF_CS_warning(%definitionId& ": Too many parameters are given: "&
"\nReceived: "& log2str(vl_error)&
"\nNeeded : "& log2str(pl_needed));
}
}
return -1;
}
}
} // group
} // module