blob: f4fcb1ad9a67d32b105afa68ee82a85cd845584e [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_ILogString_Functions
//
// Purpose:
// This module contains the function definitions of the EPTF ILogString feature.
//
// Module Parameters:
// -
//
// Module depends on:
// <EPTF_CLL_ILogString_Definitions>
// <EPTF_CLL_ILog_Definitions>
// <EPTF_CLL_ILog_Functions>
// <EPTF_CLL_Common_Definitions>
// <EPTF_CLL_Common_Functions>
// <TCCDateTime_Functions>
//
// Current Owner:
// Ildiko Vancsa (EILDVNC)
//
// Last Review Date:
// 2012-06-05
//
// Detailed Comments:
// Public functions:
// <f_EPTF_ILogString_init_CT>
// <f_EPTF_ILogString_newChain>
// <f_EPTF_ILogString_addToChains>
// <f_EPTF_ILogString_logHeader>
// <f_EPTF_ILogString_logItem>
//
///////////////////////////////////////////////////////////////
module EPTF_CLL_ILogString_Functions {
import from EPTF_CLL_ILogString_Definitions all;
import from EPTF_CLL_ILog_Definitions all;
import from EPTF_CLL_ILog_Functions all;
import from EPTF_CLL_Common_Definitions all;
import from EPTF_CLL_Common_Functions all;
import from TCCDateTime_Functions all;
///////////////////////////////////////////////////////////
// Function: f_EPTF_ILogString_init_CT
//
// Purpose:
// This function initializes the component, creates the empty charstring list and registers the database in the ILogBase feature.
//
// Parameters:
// pl_selfName - *in* *charstring* - EPTF self name
//
///////////////////////////////////////////////////////////
public function f_EPTF_ILogString_init_CT(in charstring pl_selfName)
runs on EPTF_ILogString_CT {
if(v_EPTF_ILogString_initialized == true){
return;
}
f_EPTF_ILog_init_CT(pl_selfName);
v_EPTF_ILogString_logItem_List := {};
v_EPTF_ILogString_logItem_List_dbId := f_EPTF_ILog_register_DB(refers(f_EPTF_ILogString_logItem), {});
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ILogString_newChain
//
// Purpose:
// Registers a new chain with the name given in the pl_name parameter in the ILogBase feature.
//
// Parameters:
// pl_name - *in* *charstring* - the name of the new chain
// pl_logHeaderFn - *in* <EPTF_ILogBase_LogHeader_FT> - callback function reference for generating the log header
// pl_paramList - *in* <EPTF_IntegerList> - user defined parameter list
//
// Return Value:
// *integer* - the id of the new chain
///////////////////////////////////////////////////////////
public function f_EPTF_ILogString_newChain (
in charstring pl_name := "",
in EPTF_ILog_LogHeader_FT pl_logHeaderFn := refers(f_EPTF_ILogString_logHeader),
in EPTF_IntegerList pl_paramList := {})
runs on EPTF_ILogString_CT
return integer {
var integer vl_chainId := f_EPTF_ILog_newChain(pl_name, detailed, pl_logHeaderFn, pl_paramList);
return vl_chainId;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ILogString_addToChains
//
// Purpose:
// This function adds a new element to the chains that were specified in the chainList. The content of the new element is a charstring and a time value.
// The log item is saved in the database of the component that was created in the init function.
//
// Parameters:
// pl_chainIdList - *in* <EPTF_IntegerList> - the list of chains to which the new log element needs to be added
// pl_logElement - *in* *charstring* - the log item that needs to be stored in the database, which was created in the init function
// pl_timeOfLog - *in* *float* - the time value, stored as a float value (needs to be converted before logging out the item)
//
// Return Value:
// *integer* - 0, if the operation was successful, -1 in case of any error occured
///////////////////////////////////////////////////////////
public function f_EPTF_ILogString_addToChains(
in EPTF_IntegerList pl_chainIdList,
in charstring pl_logElement,
in float pl_timeOfLog)
runs on EPTF_ILogString_CT
return integer {
var integer vl_logItemIdInDB := f_EPTF_ILog_addToChains(v_EPTF_ILogString_logItem_List_dbId, pl_chainIdList);
if(vl_logItemIdInDB != -1){
v_EPTF_ILogString_logItem_List[vl_logItemIdInDB].logItem := pl_logElement;
v_EPTF_ILogString_logItem_List[vl_logItemIdInDB].timeOfLog := pl_timeOfLog;
return c_EPTF_ILog_success;
} else {
f_EPTF_Common_warning(%definitionId&" Could not add the log item to any of the chains in the chain list! Save of the log item is failed!");
return c_EPTF_ILog_warning;
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ILogString_logHeader
//
// Purpose:
// This function creates the log header, when a chain is logged out.
//
// Parameters:
// pl_chainId - *in* *integer* - the id of chain, which is logged out
// pl_paramList - *in* <EPTF_IntegerList> - user defined parameter list
//
///////////////////////////////////////////////////////////
public function f_EPTF_ILogString_logHeader(
in integer pl_chainId,
in EPTF_IntegerList pl_paramList)
runs on EPTF_ILogString_CT{
var charstring vl_chainName := f_EPTF_ILog_getName(pl_chainId);
log("It is the log of "&vl_chainName&" chain, with params: ");
for(var integer vl_i := 0, vl_size := sizeof(pl_paramList); vl_i < vl_size; vl_i := vl_i + 1){
log(int2str(pl_paramList[vl_i]));
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_ILogString_logItem
//
// Purpose:
// This function logs out the content of a chain.
//
// Parameters:
// pl_elementIdx - *in* *integer* - the index of the log item in the database
// pl_dbId - *in* *integer* - the id of the database, which contains the element that is logged out
// pl_chainId - *in* *integer* - the id of the chain, which is logged out
// pl_paramList - *in* <EPTF_IntegerList> - user defined parameter list
//
///////////////////////////////////////////////////////////
public function f_EPTF_ILogString_logItem (
in integer pl_elementIdx,
in integer pl_dbId,
in integer pl_chainId,
in EPTF_IntegerList pl_paramList)
runs on EPTF_ILogString_CT {
var integer vl_timeSecs := float2int(v_EPTF_ILogString_logItem_List[pl_elementIdx].timeOfLog);
var integer vl_timeMilliSecs := float2int((v_EPTF_ILogString_logItem_List[pl_elementIdx].timeOfLog - int2float(vl_timeSecs)) * 1000.0);
var charstring vl_time := f_getTimeFormatted(vl_timeSecs, "%a %Y %b %d: %X") & ":" & int2str(vl_timeMilliSecs);
log(vl_time&": The log item of chain"&int2str(pl_chainId)&" is: "&(v_EPTF_ILogString_logItem_List[pl_elementIdx].logItem)&" in db"&int2str(pl_dbId)&" with params:");
for(var integer vl_i := 0, vl_size := sizeof(pl_paramList); vl_i < vl_size; vl_i := vl_i + 1){
log(int2str(pl_paramList[vl_i]));
}
}
}