blob: 708d7ab786458f3b1285018b66a9c0f41c46860c [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_StatReplay_Functions
//
// Purpose:
// This module contains the implementation of generic CLL_StatReplay functions.
//
// Module Parameters:
//
// Module depends on:
// <EPTF_CLL_StatReplay_Definitions>
// <EPTF_CLL_UIHandlerClient_Definitions>
// <EPTF_CLL_UIHandlerClient_Functions>
// <EPTF_CLL_UIHandler_PrivateFunctions>
// <EPTF_CLL_UIHandler_Definitions>
// <EPTF_CLL_UIHandler_WidgetFunctions>
// <EPTF_CLL_Variable_Functions>
// <EPTF_CLL_Semaphore_Functions>
// <EPTF_CLL_Base_Functions>
// <EPTF_CLL_Common_Definitions>
// <XTDP_PDU_Defs>
// <TCCFileIO_Functions>
// <EPTF_CLL_UIXTDP_Templates>
// <XTDPasp_Types>
// <EPTF_CLL_Logging_Definitions>
// <EPTF_CLL_Logging_Functions>
//
// Current Owner:
// Norbert Pint�r (ENORPIN)
//
// Last Review Date:
// 2007-xx-xx
//
// Detailed Comments:
// This module contains the interface functions for the EPTF_CLL_StatReplay_CT.
//
///////////////////////////////////////////////////////////////
module EPTF_CLL_StatReplay_Functions{
//=========================================================================
// Import Part
//=========================================================================
import from EPTF_CLL_StatReplay_Definitions all;
import from EPTF_CLL_UIHandler_WidgetFunctions all;
import from EPTF_CLL_UIHandlerClient_Functions all;
import from EPTF_CLL_Variable_Functions all;
import from EPTF_CLL_Semaphore_Functions all;
import from EPTF_CLL_Base_Functions all;
import from EPTF_CLL_Common_Definitions all;
import from TCCFileIO_Functions all;
import from EPTF_CLL_Logging_Definitions all;
import from EPTF_CLL_Logging_Functions all;
modulepar{
charstring tsp_EPTF_CLL_StatReplay_captureFile := "default";
charstring tsp_EPTF_CLL_StatReplay_groupName := "default";
charstring tsp_EPTF_CLL_StatReplay_variableName := "default";
charstring tsp_EPTF_CLL_StatReplay_startLayout := "";
integer tsp_EPTF_CLL_StatReplay_windowSize := 5;
boolean tsp_EPTF_CLL_StatReplay_debug := false;
}
///////////////////////////////////////////////////////////
// Group: Public
//
// Purpose:
// Public functions. Only these functions can be used by the user of <EPTF_CLL_StatReplay_CT>
//
// Elements:
///////////////////////////////////////////////////////////
group Public {
///////////////////////////////////////////////////////////
// Function: f_EPTF_CLL_StatReplay_init_CT
//
// Purpose:
// Initializes the EPTF_CLL_StatReplay_CT component
//
// Parameters:
// pl_selfName - *in* *charstring* - name of the component
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// This function should be called before using the EPTF StatReplay
// component.
//
///////////////////////////////////////////////////////////
function f_EPTF_CLL_StatReplay_init_CT(
in charstring pl_selfName)
runs on EPTF_CLL_StatReplay_CT{
if (v_EPTF_CLL_StatReplay_initialized != false){
return;
}
f_EPTF_Logging_init_CT(pl_selfName);
v_StatReplay_loggingMaskId := f_EPTF_Logging_registerComponentMasks(tsp_EPTF_StatReplay_loggingComponentMask, c_EPTF_StatReplay_loggingEventClasses, EPTF_Logging_CLL);
if(tsp_EPTF_CLL_StatReplay_debug) {
f_EPTF_Logging_enableLocalMask(v_StatReplay_loggingMaskId, c_EPTF_StatReplay_loggingClassIdx_Debug);
} else {
f_EPTF_Logging_disableLocalMask(v_StatReplay_loggingMaskId, c_EPTF_StatReplay_loggingClassIdx_Debug);
}
f_EPTF_UIHandlerClient_init_CT(pl_selfName, self);
f_EPTF_UIHandler_init_CT(pl_selfName);
f_EPTF_EPTF_StatReplay_CaptureInfoType_RB_init(v_EPTF_CLL_StatReplay_ringBuffer,tsp_EPTF_CLL_StatReplay_windowSize );
f_EPTF_Semaphore_init_CT(pl_selfName);
v_EPTF_CLL_StatReplay_semaphoreIdx := f_EPTF_Semaphore_new();
f_EPTF_Semaphore_unlock(v_EPTF_CLL_StatReplay_semaphoreIdx);
v_EPTF_CLL_StatReplay_headFileDescriptor := f_FIO_open_rdonly(tsp_EPTF_CLL_StatReplay_captureFile);
v_EPTF_CLL_StatReplay_tailFileDescriptor := f_FIO_open_rdonly(tsp_EPTF_CLL_StatReplay_captureFile);
v_EPTF_CLL_StatReplay_capturedVariablePos := f_EPTF_CLL_StatReplay_getVariablePos(tsp_EPTF_CLL_StatReplay_groupName,tsp_EPTF_CLL_StatReplay_variableName,v_EPTF_CLL_StatReplay_headFileDescriptor);
f_EPTF_Base_registerCleanup(refers(f_EPTF_CLL_StatReplay_cleanup_CT));
v_EPTF_CLL_StatReplay_initialized := true;
var charstring vl_logmessage;
if (v_EPTF_CLL_StatReplay_headFileDescriptor < 0){
//log(f_FIO_get_error_string());
f_EPTF_StatReplay_debug(f_FIO_get_error_string());
f_EPTF_Base_cleanup_CT();
}
else if (v_EPTF_CLL_StatReplay_capturedVariablePos == -1){
//log("ERROR: The ",tsp_EPTF_CLL_StatReplay_variableName," variable doesn't exist in the ",tsp_EPTF_CLL_StatReplay_groupName," capture group in the file: ",tsp_EPTF_CLL_StatReplay_captureFile);
f_EPTF_StatReplay_warning(log2str("ERROR: The ",tsp_EPTF_CLL_StatReplay_variableName," variable doesn't exist in the ",tsp_EPTF_CLL_StatReplay_groupName," capture group in the file: ",tsp_EPTF_CLL_StatReplay_captureFile));
f_EPTF_Base_cleanup_CT();
}
else if (tsp_EPTF_CLL_StatReplay_startLayout == "") {
//log("ERROR: There is no defined startLayout!");
f_EPTF_StatReplay_warning("ERROR: There is no defined startLayout!");
f_EPTF_Base_cleanup_CT();
}
else {
/* if (tsp_EPTF_CLL_StatReplay_debug == true) {
log("Captured variable pos:",v_EPTF_CLL_StatReplay_capturedVariablePos);
}*/
f_EPTF_StatReplay_debug(log2str("Captured variable pos:",v_EPTF_CLL_StatReplay_capturedVariablePos));
f_EPTF_CLL_StatReplay_subscribeGUIelements();
// as_EPTF_UIHandler_exitButtonPressed();
f_EPTF_Base_cleanup_CT();
}
}
}//end of public group
///////////////////////////////////////////////////////////
// Group: Private
//
// Purpose:
// Private functions. These functions must not be used by the user of <EPTF_CLL_StatReplay_CT>
//
// Elements:
///////////////////////////////////////////////////////////
group Private {
group ButtonHandling {
///////////////////////////////////////////////////////////
// Function: f_EPTF_CLL_StatReplay_handleButtons
//
// Purpose:
// Function to handle the buttons.
//
// Parameters:
// pl_idx - *in* <integer> - the idx of the assigned Button variable
// pl_argList - *in* <EPTF_IntegerList> - the list of the function arguments
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// This function is added to the button variables as postproc function.
//
///////////////////////////////////////////////////////////
function f_EPTF_CLL_StatReplay_handleButtons(
in integer pl_idx,
in EPTF_IntegerList pl_argList)
runs on EPTF_CLL_StatReplay_CT{
select (pl_idx){
case(v_EPTF_CLL_StatReplay_fastLeftButtonIdx) {
/* if (tsp_EPTF_CLL_StatReplay_debug == true) {
log("Shift Left Fast button pressed");
}*/
f_EPTF_StatReplay_debug("Shift Left Fast button pressed");
f_EPTF_CLL_StatReplay_handleShiftLeftFast();
}
case(v_EPTF_CLL_StatReplay_leftButtonIdx) {
/* if (tsp_EPTF_CLL_StatReplay_debug == true) {
log("Shift Left button pressed");
}*/
f_EPTF_StatReplay_debug("Shift Left button pressed");
f_EPTF_CLL_StatReplay_handleShiftLeft();
}
case(v_EPTF_CLL_StatReplay_rightButtonIdx) {
/*if (tsp_EPTF_CLL_StatReplay_debug == true) {
//log("Shift Right button pressed");
}*/
f_EPTF_StatReplay_debug("Shift Right button pressed");
f_EPTF_CLL_StatReplay_handleShiftRight();
}
case(v_EPTF_CLL_StatReplay_fastRightButtonIdx) {
/*if (tsp_EPTF_CLL_StatReplay_debug == true) {
//log("Shift Right Fast button pressed");
}*/
f_EPTF_StatReplay_debug("Shift Right Fast button pressed");
f_EPTF_CLL_StatReplay_handleShiftRightFast();
}
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_CLL_StatReplay_handleShiftLeftFast
//
// Purpose:
// Function to handle the Shift Left Fast button.
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// This function steps windowsize times the file descriptors (head and tail)
// to the right direction and update the ringbuffer with the new values.
//
///////////////////////////////////////////////////////////
function f_EPTF_CLL_StatReplay_handleShiftLeftFast()
runs on EPTF_CLL_StatReplay_CT {
var EPTF_StatReplay_CaptureInfoType vl_infoTail;
var EPTF_StatReplay_CaptureInfoType vl_infoHead;
var boolean vl_isFileBegin := false;
f_EPTF_Semaphore_waitForUnlock(v_EPTF_CLL_StatReplay_semaphoreIdx);
v_EPTF_CLL_StatReplay_semaphoreIdx := f_EPTF_Semaphore_new();
/*if (tsp_EPTF_CLL_StatReplay_debug == true) {
//log("The ShiftLeftFast button entered into the critical section");
}*/
f_EPTF_StatReplay_debug("The ShiftLeftFast button entered into the critical section");
for (var integer i := 1; i <= tsp_EPTF_CLL_StatReplay_windowSize; i := i + 1) {
if (f_EPTF_CLL_StatReplay_getNextValue(false,v_EPTF_CLL_StatReplay_tailFileDescriptor,tsp_EPTF_CLL_StatReplay_groupName, tsp_EPTF_CLL_StatReplay_variableName,vl_infoTail) == true){
if(not f_EPTF_CLL_StatReplay_getNextValue(false,v_EPTF_CLL_StatReplay_headFileDescriptor,tsp_EPTF_CLL_StatReplay_groupName, tsp_EPTF_CLL_StatReplay_variableName,vl_infoHead)) {
//log("WARNING: ", %definitionId, ": getNextValue failed for head file descriptor.");
f_EPTF_StatReplay_warning(log2str(%definitionId, ": getNextValue failed for head file descriptor."));
}
f_EPTF_EPTF_StatReplay_CaptureInfoType_RB_push_back(v_EPTF_CLL_StatReplay_ringBuffer,vl_infoTail);
/*if (tsp_EPTF_CLL_StatReplay_debug == true) {
//log("Variable_front:",vl_infoHead);
//log("Variable_back:",vl_infoTail);
}*/
f_EPTF_StatReplay_debug(log2str("Variable_front:",vl_infoHead));
f_EPTF_StatReplay_debug(log2str("Variable_back:",vl_infoTail));
}
else {
vl_isFileBegin := true;
}
}
f_EPTF_CLL_StatReplay_refreshTrace();
f_EPTF_Var_sendTimeLine(v_EPTF_CLL_StatReplay_chartTraceIdx);
f_EPTF_Semaphore_unlock(v_EPTF_CLL_StatReplay_semaphoreIdx);
/*if (tsp_EPTF_CLL_StatReplay_debug == true) {
//log("The ShiftLeftFast button left the critical section");
}*/
f_EPTF_StatReplay_debug("The ShiftLeftFast button left the critical section");
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_CLL_StatReplay_handleShiftLeft
//
// Purpose:
// Function to handle the Shift Left button.
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// This function steps one time the file descriptors (head and tail)
// to the left direction and update the ringbuffer with the new value.
//
///////////////////////////////////////////////////////////
function f_EPTF_CLL_StatReplay_handleShiftLeft()
runs on EPTF_CLL_StatReplay_CT {
var EPTF_StatReplay_CaptureInfoType vl_infoTail;
var EPTF_StatReplay_CaptureInfoType vl_infoHead;
f_EPTF_Semaphore_waitForUnlock(v_EPTF_CLL_StatReplay_semaphoreIdx);
v_EPTF_CLL_StatReplay_semaphoreIdx := f_EPTF_Semaphore_new();
/*if (tsp_EPTF_CLL_StatReplay_debug == true) {
//log("The ShiftLeft button entered into the critical section");
}*/
f_EPTF_StatReplay_debug("The ShiftLeft button entered into the critical section");
if (f_EPTF_CLL_StatReplay_getNextValue(false,v_EPTF_CLL_StatReplay_tailFileDescriptor,tsp_EPTF_CLL_StatReplay_groupName, tsp_EPTF_CLL_StatReplay_variableName,vl_infoTail) == true){
if(not f_EPTF_CLL_StatReplay_getNextValue(false,v_EPTF_CLL_StatReplay_headFileDescriptor,tsp_EPTF_CLL_StatReplay_groupName, tsp_EPTF_CLL_StatReplay_variableName,vl_infoHead)) {
//log("WARNING: ", %definitionId, ": getNextValue failed for head file descriptor.");
f_EPTF_StatReplay_warning(log2str(%definitionId, ": getNextValue failed for head file descriptor."));
}
f_EPTF_EPTF_StatReplay_CaptureInfoType_RB_push_back(v_EPTF_CLL_StatReplay_ringBuffer,vl_infoTail);
/*if (tsp_EPTF_CLL_StatReplay_debug == true) {
//log("Variable_front:",vl_infoHead);
//log("Variable_back:",vl_infoTail);
}*/
f_EPTF_StatReplay_debug(log2str("Variable_front:",vl_infoHead));
f_EPTF_StatReplay_debug(log2str("Variable_back:",vl_infoTail));
f_EPTF_CLL_StatReplay_refreshTrace();
f_EPTF_Var_sendTimeLine(v_EPTF_CLL_StatReplay_chartTraceIdx);
}
f_EPTF_Semaphore_unlock(v_EPTF_CLL_StatReplay_semaphoreIdx);
/*if (tsp_EPTF_CLL_StatReplay_debug == true) {
//log("The ShiftLeft button left the critical section");
}*/
f_EPTF_StatReplay_debug("The ShiftLeft button left the critical section");
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_CLL_StatReplay_handleShiftRight
//
// Purpose:
// Function to handle the Shift Right button.
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// This function steps one time the file descriptors (head and tail)
// to the right direction and update the ringbuffer with the new value.
//
///////////////////////////////////////////////////////////
function f_EPTF_CLL_StatReplay_handleShiftRight()
runs on EPTF_CLL_StatReplay_CT {
var EPTF_StatReplay_CaptureInfoType vl_infoHead;
var EPTF_StatReplay_CaptureInfoType vl_infoTail;
f_EPTF_Semaphore_waitForUnlock(v_EPTF_CLL_StatReplay_semaphoreIdx);
v_EPTF_CLL_StatReplay_semaphoreIdx := f_EPTF_Semaphore_new();
/*if (tsp_EPTF_CLL_StatReplay_debug == true) {
//log("The ShiftRight button entered into the critical section");
}*/
f_EPTF_StatReplay_debug("The ShiftRight button entered into the critical section");
if (f_EPTF_CLL_StatReplay_getNextValue(true,v_EPTF_CLL_StatReplay_headFileDescriptor,tsp_EPTF_CLL_StatReplay_groupName, tsp_EPTF_CLL_StatReplay_variableName,vl_infoHead) == true){
if(not f_EPTF_CLL_StatReplay_getNextValue(true,v_EPTF_CLL_StatReplay_tailFileDescriptor,tsp_EPTF_CLL_StatReplay_groupName, tsp_EPTF_CLL_StatReplay_variableName,vl_infoTail)) {
//log("WARNING: ", %definitionId, ": getNextValue failed for tail file descriptor.");
f_EPTF_StatReplay_warning(log2str(%definitionId, ": getNextValue failed for tail file descriptor."));
}
f_EPTF_EPTF_StatReplay_CaptureInfoType_RB_push_front(v_EPTF_CLL_StatReplay_ringBuffer,vl_infoHead);
/*if (tsp_EPTF_CLL_StatReplay_debug == true) {
//log("Variable_front:",vl_infoHead);
//log("Variable_back:",vl_infoTail);
}*/
f_EPTF_StatReplay_debug(log2str("Variable_front:",vl_infoHead));
f_EPTF_StatReplay_debug(log2str("Variable_back:",vl_infoTail));
f_EPTF_CLL_StatReplay_refreshTrace();
f_EPTF_Var_sendTimeLine(v_EPTF_CLL_StatReplay_chartTraceIdx);
}
f_EPTF_Semaphore_unlock(v_EPTF_CLL_StatReplay_semaphoreIdx);
/*if (tsp_EPTF_CLL_StatReplay_debug == true) {
//log("The ShiftRight button left the critical section");
}*/
f_EPTF_StatReplay_debug("The ShiftRight button left the critical section");
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_CLL_StatReplay_handleShiftRightFast
//
// Purpose:
// Function to handle the Shift Right Fast button.
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// This function steps windowsize times the file descriptors (head and tail)
// to the right direction and update the ringbuffer with the new values.
//
///////////////////////////////////////////////////////////
function f_EPTF_CLL_StatReplay_handleShiftRightFast()
runs on EPTF_CLL_StatReplay_CT {
var EPTF_StatReplay_CaptureInfoType vl_infoHead;
var EPTF_StatReplay_CaptureInfoType vl_infoTail;
var boolean vl_isFileEnd := false;
f_EPTF_Semaphore_waitForUnlock(v_EPTF_CLL_StatReplay_semaphoreIdx);
v_EPTF_CLL_StatReplay_semaphoreIdx := f_EPTF_Semaphore_new();
/*if (tsp_EPTF_CLL_StatReplay_debug == true) {
//log("The ShiftRightFast button entered into the critical section");
}*/
f_EPTF_StatReplay_debug("The ShiftRightFast button entered into the critical section");
for (var integer i := 1; i <= tsp_EPTF_CLL_StatReplay_windowSize; i := i + 1) {
if (f_EPTF_CLL_StatReplay_getNextValue(true,v_EPTF_CLL_StatReplay_headFileDescriptor,tsp_EPTF_CLL_StatReplay_groupName, tsp_EPTF_CLL_StatReplay_variableName,vl_infoHead) == true){
if(not f_EPTF_CLL_StatReplay_getNextValue(true,v_EPTF_CLL_StatReplay_tailFileDescriptor,tsp_EPTF_CLL_StatReplay_groupName, tsp_EPTF_CLL_StatReplay_variableName,vl_infoTail)) {
//log("WARNING: ", %definitionId, ": getNextValue failed for tail file descriptor.");
f_EPTF_StatReplay_warning(log2str(%definitionId, ": getNextValue failed for tail file descriptor."));
}
f_EPTF_EPTF_StatReplay_CaptureInfoType_RB_push_front(v_EPTF_CLL_StatReplay_ringBuffer,vl_infoHead);
/*if (tsp_EPTF_CLL_StatReplay_debug == true) {
//log("Variable_front:",vl_infoHead);
//log("Variable_back:",vl_infoTail);
}*/
f_EPTF_StatReplay_debug(log2str("Variable_front:",vl_infoHead));
f_EPTF_StatReplay_debug(log2str("Variable_back:",vl_infoTail));
}
else {
vl_isFileEnd := true;
}
}
f_EPTF_CLL_StatReplay_refreshTrace();
f_EPTF_Var_sendTimeLine(v_EPTF_CLL_StatReplay_chartTraceIdx);
f_EPTF_Semaphore_unlock(v_EPTF_CLL_StatReplay_semaphoreIdx);
/*if (tsp_EPTF_CLL_StatReplay_debug == true) {
//log("The ShiftRightFast button left the critical section");
}*/
f_EPTF_StatReplay_debug("The ShiftRightFast button left the critical section");
}
}//end of ButtonHandle group
group FileParsing{
///////////////////////////////////////////////////////////
// Function: f_EPTF_CLL_StatReplay_checkType
//
// Purpose:
// Function to check the type of the variable
//
// Parameters:
// pl_typeData - *in* <charstring> - value of the variable
//
// Return Value:
// charstring - the type of the given variable
//
// Errors:
// -
//
// Detailed Comments:
// If the value of the variable is "-" (the variable is not captured)
// then the return value will be none.
//
///////////////////////////////////////////////////////////
function f_EPTF_CLL_StatReplay_checkType(
in charstring pl_typeData)
runs on EPTF_CLL_StatReplay_CT
return charstring {
var integer vl_length;
var charstring vl_lastCharacter;
if (pl_typeData == "-") {
return "none";
}
if (pl_typeData=="") {
return "charstring";
}
if ((pl_typeData == "true") or (pl_typeData == "false")) {
return "boolean";
}
vl_length := lengthof(pl_typeData);
vl_lastCharacter := pl_typeData[vl_length-1];
if (vl_lastCharacter=="H") {
return "hexstring";
}
if (vl_lastCharacter=="O") {
return "octetstring";
}
if (vl_lastCharacter=="B") {
return "bitstring";
}
if (vl_lastCharacter=="\"") {
return "charstring";
}
if (vl_lastCharacter=="}") {
return "statusLEDWithText";
}
for (var integer i := 0; i<= vl_length-1; i := i + 1){
if (pl_typeData[i]==".") {return "float";}
}
return "integer";
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_CLL_StatReplay_findVariablePos
//
// Purpose:
// Function to find the position of the variable in the given capture group.
//
// Parameters:
// pl_text - *in* <charstring> - capture group information
// pl_groupName - *in* <charstring> - name
//
// Return Value:
// integer - the position of the variable in the given capture group
//
// Errors:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
function f_EPTF_CLL_StatReplay_findVariablePos(
in charstring pl_text,
in charstring pl_groupName,
in charstring pl_name)
runs on EPTF_CLL_StatReplay_CT
return integer
{
var integer i := 1;
var integer j := 0;
var charstring vl_text_tmp1 := "";
var charstring vl_text_tmp2 := "";
var integer vl_length ;
vl_text_tmp1 := pl_text;
while (lengthof(vl_text_tmp1)>0 and vl_text_tmp1[1] != "\n"){
vl_text_tmp2 := "";
j := 0;
while (vl_text_tmp1[j] != " "){
vl_text_tmp2 := vl_text_tmp2&vl_text_tmp1[j];
j := j + 1;
}
if (vl_text_tmp2 == pl_name) {
return i-1
}
else {
i := i + 1;
vl_length := lengthof(vl_text_tmp2);
vl_text_tmp2 := "";
for(j := vl_length+1; j<=lengthof(vl_text_tmp1)-1; j := j + 1) {
vl_text_tmp2 := vl_text_tmp2&vl_text_tmp1[j];
}
vl_text_tmp1 := vl_text_tmp2;
}
}
return -1
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_CLL_StatReplay_getVariablePos
//
// Purpose:
// Function to find the given variable position in the file group.
//
// Parameters:
// pl_fileDescriptor - *in* <integer> - the file descriptor
// pl_groupName - *in* <charstring> - the group name of the variable
// pl_name - *in* <charstring> - the name of the searched variable
//
// Return Value:
// integer - the position of the variable in the given group.
//
// Errors:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
function f_EPTF_CLL_StatReplay_getVariablePos(
in charstring pl_groupName,
in charstring pl_name,
in integer pl_fileDescriptor)
runs on EPTF_CLL_StatReplay_CT
return integer
{
var charstring vl_text := f_EPTF_CLL_StatReplay_getNextLine(pl_fileDescriptor);
var boolean vl_isFind := false
var charstring vl_template := "ValueHeader[\""&pl_groupName&"\"]:";
var integer vl_templateLength := 16+lengthof(pl_groupName);
var integer i := 0;
while ((i != vl_templateLength) and (i != lengthof(vl_text)) and (vl_template[i] == vl_text[i])) {
i := i + 1;
}
if (i == vl_templateLength) {
return f_EPTF_CLL_StatReplay_findVariablePos(vl_text,pl_groupName,pl_name);
}
else {
while((not vl_isFind) and (vl_text != "") ){
vl_text := f_EPTF_CLL_StatReplay_getNextLine(pl_fileDescriptor);
i := 0;
while((i!=vl_templateLength) and (i != lengthof(vl_text)) and (vl_text[i] == vl_template[i]))
{
i := i + 1;
}
if (i == vl_templateLength) {
vl_isFind := true;
}
}
return f_EPTF_CLL_StatReplay_findVariablePos(vl_text,pl_groupName,pl_name);
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_CLL_StatReplay_getNextLine
//
// Purpose:
// Function to get the next line and modify the position
// of the given file descriptor to the begin of the next line.
//
// Parameters:
// pl_fileDescriptor - *in* <integer> - the file descriptor
//
// Return Value:
// charstring - the previous line
//
// Errors:
// -
//
// Detailed Comments:
// If no more following line exists, then hte return value is
// an empty charstring.
//
///////////////////////////////////////////////////////////
function f_EPTF_CLL_StatReplay_getNextLine(
in integer pl_fileDescriptor)
runs on EPTF_CLL_StatReplay_CT
return charstring
{
var charstring vl_text;
vl_text := "";
if(0 > f_FIO_read_text_until(pl_fileDescriptor,vl_text,"\n")) {
//log("ERROR: ", %definitionId, ": read_text_until failed (", f_FIO_get_error_string(), ").");
f_EPTF_StatReplay_warning(log2str("ERROR: ", %definitionId, ": read_text_until failed (", f_FIO_get_error_string(), ")."));
}
return vl_text;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_CLL_StatReplay_getPrevLine
//
// Purpose:
// Function to get the previous line and modify the position
// of the given file descriptor to the start of the previous line.
//
// Parameters:
// pl_fileDescriptor - *in* <integer> - the file descriptor
//
// Return Value:
// charstring - the previous line
//
// Errors:
// -
//
// Detailed Comments:
// If no more previous line exists, then the return value is
// an empty charstring.
//
///////////////////////////////////////////////////////////
function f_EPTF_CLL_StatReplay_getPrevLine(
in integer pl_fileDescriptor)
runs on EPTF_CLL_StatReplay_CT
return charstring
{
var charstring vl_text;
vl_text := "";
var charstring vl_logmessage;
if (f_FIO_set_filedescriptor_previousline(pl_fileDescriptor)==1) {
if(0 > f_FIO_read_text_until(pl_fileDescriptor,vl_text,"\n")) {
//log("ERROR: ", %definitionId, ": read_text_until failed (", f_FIO_get_error_string(), ").");
f_EPTF_StatReplay_warning(log2str("ERROR: ",%definitionId, ": read_text_until failed (", f_FIO_get_error_string(), ")."));
}
}
if (f_FIO_set_filedescriptor_previousline(pl_fileDescriptor)!=1) {
//log("WARNING: ", %definitionId, ": f_FIO_set_filedescriptor_previousline failed (", f_FIO_get_error_string(), ").");
f_EPTF_StatReplay_warning(log2str(%definitionId, ": f_FIO_set_filedescriptor_previousline failed (", f_FIO_get_error_string(), ")."));
}
/*if (tsp_EPTF_CLL_StatReplay_debug == true) {
//log("The previous line:",vl_text);
}*/
f_EPTF_StatReplay_debug(log2str("The previous line:",vl_text));
return vl_text;
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_CLL_StatReplay_getNextValue
//
// Purpose:
// Function to get a timestamp and value.
//
// Parameters:
// pl_direction - *in* <EPTF_RingBufferStatus> - the direction of the search
// pl_fileDescriptor - *in* <integer> - the file descriptor
// pl_groupName - *in* <charstring> - the group name of the visualized variable
// pl_name - *in* <charstring> - the name of the visualized variable
// pl_nextValue - *out* <CaptureInfoType> - the found timestamp and value of the variable
//
// Return Value:
// boolean - exist new value or not.
//
// Errors:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
function f_EPTF_CLL_StatReplay_getNextValue(
in boolean pl_direction,
in integer pl_fileDescriptor,
in charstring pl_groupName,
in charstring pl_name,
out EPTF_StatReplay_CaptureInfoType pl_nextValue)
runs on EPTF_CLL_StatReplay_CT
return boolean
{
var charstring vl_text_tmp1 := "";
var charstring vl_text_tmp2 := "";
var charstring vl_template := "[\""&pl_groupName&"\",";
var integer vl_templateLength := lengthof(vl_template);
var integer vl_textLength;
var boolean vl_existNewline := true;
var integer i := 0;
var EPTF_StatReplay_CaptureInfoType vl_result;
while (vl_existNewline) {
if (pl_direction == true) {
vl_text_tmp1 := f_EPTF_CLL_StatReplay_getNextLine(pl_fileDescriptor);
}
else {
vl_text_tmp1 := f_EPTF_CLL_StatReplay_getPrevLine(pl_fileDescriptor);
}
vl_textLength := lengthof(vl_text_tmp1);
//log("Newline:",vl_text_tmp1);
f_EPTF_StatReplay_debug(log2str("Newline:",vl_text_tmp1));
//log("Newline length:",vl_textLength);
f_EPTF_StatReplay_debug(log2str("Newline length:",vl_textLength));
if (vl_textLength == 0) {vl_existNewline := false;}
if (vl_existNewline) {
while((i<=vl_templateLength-1) and (i<=vl_textLength-1) and (vl_text_tmp1[i] == vl_template[i]) ){
i := i + 1;
}
if (i == vl_templateLength) {
vl_text_tmp2 := "";
while (vl_text_tmp1[i] != "]")
{
vl_text_tmp2 := vl_text_tmp2&vl_text_tmp1[i];
i := i + 1;
}
vl_result.timestamp := str2float(vl_text_tmp2);
/*if (tsp_EPTF_CLL_StatReplay_debug == true) {
//log("The actual timestamp: ",vl_result.timestamp);
}*/
f_EPTF_StatReplay_debug(log2str("The actual timestamp: ",vl_result.timestamp));
for (var integer j := 1; j<=v_EPTF_CLL_StatReplay_capturedVariablePos+1; j := j + 1) {
vl_text_tmp2 := "";
while (vl_text_tmp1[i] != " ")
{
vl_text_tmp2 := vl_text_tmp2&vl_text_tmp1[i];
i := i + 1;
/*if (tsp_EPTF_CLL_StatReplay_debug == true) {
//log("Value of text:",vl_text_tmp1[i]);
}*/
f_EPTF_StatReplay_debug(log2str("Value of text:",vl_text_tmp1[i]));
}
i := i + 1;
}
var charstring vl_type := f_EPTF_CLL_StatReplay_checkType(vl_text_tmp2);
//log("Variable Type:",vl_type);
f_EPTF_StatReplay_debug(log2str("Variable Type:",vl_type));
if (vl_type == "float") {
vl_result.variableValue := str2float(vl_text_tmp2);
pl_nextValue := vl_result;
return true;
}
else if (vl_type == "integer") {
vl_result.variableValue := int2float(str2int(vl_text_tmp2));
pl_nextValue := vl_result;
return true;
}
else if (vl_type == "none") {
/*if (tsp_EPTF_CLL_StatReplay_debug == true) {
//log("Missing value");
}*/
f_EPTF_StatReplay_debug("Missing value");
i := 0;
}
else {
/*if (tsp_EPTF_CLL_StatReplay_debug == true) {
//log("ERROR: The value of the variable is neither float nor integer!");
}*/
f_EPTF_StatReplay_warning("ERROR: The value of the variable is neither float nor integer!");
i := 0;
}
}
}
}
return false;
}
}//end of FileParsing group
group GuiFunctions {
///////////////////////////////////////////////////////////
// Function: f_EPTF_CLL_StatReplay_refreshTrace
//
// Purpose:
// Function to refresh the variable of the chart trace.
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// This function gets the current informations from the ringbuffer and
// refresh the trace variable with the values.
//
///////////////////////////////////////////////////////////
function f_EPTF_CLL_StatReplay_refreshTrace()
runs on EPTF_CLL_StatReplay_CT{
var EPTF_StatReplay_CaptureInfoTypeList vl_capture;
f_EPTF_EPTF_StatReplay_CaptureInfoType_RB_dump(v_EPTF_CLL_StatReplay_ringBuffer,vl_capture);
/*if (tsp_EPTF_CLL_StatReplay_debug == true) {
//log("Referesh:",vl_capture);
}*/
f_EPTF_StatReplay_debug(log2str("Referesh:",vl_capture));
for (var integer i := 0; i <= sizeof(vl_capture)-1; i := i + 1){
f_EPTF_Var_updateTimeLine(v_EPTF_CLL_StatReplay_chartTraceIdx,{floatVal:=vl_capture[i].variableValue},vl_capture[i].timestamp);
}
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_CLL_StatReplay_subscribeGUIelements
//
// Purpose:
// Function to subscribe the buttons and the chart variable to the GUI and
// initialize the chart with the startvalues.
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
function f_EPTF_CLL_StatReplay_subscribeGUIelements()
runs on EPTF_CLL_StatReplay_CT{
var integer i := 1;
var integer j;
var EPTF_StatReplay_CaptureInfoType vl_infoHead;
var float vl_lastTimestamp;
var boolean vl_isFileEnd := false;
f_EPTF_Var_newInt("fastleft", 1, v_EPTF_CLL_StatReplay_fastLeftButtonIdx);
f_EPTF_Var_addPostProcFn(v_EPTF_CLL_StatReplay_fastLeftButtonIdx, {refers(f_EPTF_CLL_StatReplay_handleButtons),{}});
f_EPTF_UIHandlerClient_subscribeMe("fastleft","fastleft1","shift_left_fast");
f_EPTF_Var_newInt("left", 1, v_EPTF_CLL_StatReplay_leftButtonIdx);
f_EPTF_Var_addPostProcFn(v_EPTF_CLL_StatReplay_leftButtonIdx, {refers(f_EPTF_CLL_StatReplay_handleButtons),{}});
f_EPTF_UIHandlerClient_subscribeMe("left","left1","shift_left");
f_EPTF_Var_newInt("fastright", 1, v_EPTF_CLL_StatReplay_fastRightButtonIdx);
f_EPTF_Var_addPostProcFn(v_EPTF_CLL_StatReplay_fastRightButtonIdx, {refers(f_EPTF_CLL_StatReplay_handleButtons),{}});
f_EPTF_UIHandlerClient_subscribeMe("fastright","fastright1","shift_right_fast");
f_EPTF_Var_newInt("right", 1, v_EPTF_CLL_StatReplay_rightButtonIdx);
f_EPTF_Var_addPostProcFn(v_EPTF_CLL_StatReplay_rightButtonIdx, {refers(f_EPTF_CLL_StatReplay_handleButtons),{}});
f_EPTF_UIHandlerClient_subscribeMe("right","right1","shift_right");
f_EPTF_Var_newFloat("chartTrace", 1.0, v_EPTF_CLL_StatReplay_chartTraceIdx);
f_EPTF_UIHandlerClient_subscribeMe("chartTrace","trace","trace1");
//Set the initial values
while((i<=tsp_EPTF_CLL_StatReplay_windowSize) and (vl_isFileEnd == false)){
if (f_EPTF_CLL_StatReplay_getNextValue(true,v_EPTF_CLL_StatReplay_headFileDescriptor,tsp_EPTF_CLL_StatReplay_groupName, tsp_EPTF_CLL_StatReplay_variableName,vl_infoHead) == true){
f_EPTF_EPTF_StatReplay_CaptureInfoType_RB_push_front(v_EPTF_CLL_StatReplay_ringBuffer,vl_infoHead);
/*if (tsp_EPTF_CLL_StatReplay_debug == true) {
//log("Variable:",vl_infoHead);
}*/
f_EPTF_StatReplay_debug(log2str("Variable:",vl_infoHead));
vl_lastTimestamp := vl_infoHead.timestamp;
}
else {
vl_isFileEnd := true;
}
i := i + 1;
}
if (vl_isFileEnd == true) {
//log("WARNING: The number of the values are fewer than the size of the slider window!");
f_EPTF_StatReplay_warning("The number of the values are fewer than the size of the slider window!");
for (j := i-1; j<=tsp_EPTF_CLL_StatReplay_windowSize;j := j + 1){
vl_lastTimestamp := vl_lastTimestamp + 1.0;
f_EPTF_EPTF_StatReplay_CaptureInfoType_RB_push_front(v_EPTF_CLL_StatReplay_ringBuffer,{vl_lastTimestamp,0.0});
}
}
f_EPTF_CLL_StatReplay_refreshTrace();
//f_EPTF_Var_handle_syncTimeout();
}
}//end of GuiFunctions group
///////////////////////////////////////////////////////////
// Function: f_EPTF_CLL_StatReplay_cleanup_CT
//
// Purpose:
// This function should be called before the EPTF_CLL_StatReplay_CT component shuts down.
//
// Parameters:
// -
//
// Return Value:
// -
//
// Errors:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
function f_EPTF_CLL_StatReplay_cleanup_CT()
runs on EPTF_CLL_StatReplay_CT{
f_EPTF_Semaphore_delete(v_EPTF_CLL_StatReplay_semaphoreIdx);
var charstring vl_logmessage;
if(0 != f_FIO_close(v_EPTF_CLL_StatReplay_headFileDescriptor)) {
//log("ERROR: ", %definitionId, ": close failed (", f_FIO_get_error_string(), ").");
f_EPTF_StatReplay_warning(log2str("ERROR: ", %definitionId, ": close failed (", f_FIO_get_error_string(), ")."));
}
if(0 != f_FIO_close(v_EPTF_CLL_StatReplay_tailFileDescriptor)) {
//log("ERROR: ", %definitionId, ": close failed (", f_FIO_get_error_string(), ").");
f_EPTF_StatReplay_warning(log2str("ERROR: ", %definitionId, ": close failed (", f_FIO_get_error_string(), ")."));
}
v_EPTF_CLL_StatReplay_initialized := false;
}
group Logging {
///////////////////////////////////////////////////////////
// Function: f_EPTF_StatReplay_error
//
// Purpose:
// Function to log an error from StatReplay feature.
//
// Parameters:
// - pl_message - *in* *charstring* - the message to log
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
function f_EPTF_StatReplay_error(in charstring pl_message)
runs on EPTF_CLL_StatReplay_CT
{
f_EPTF_Logging_error(true, tsp_EPTF_StatReplay_loggingComponentMask&": "&pl_message);
f_EPTF_Base_stopAll();
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_StatReplay_warning
//
// Purpose:
// Function to log a warning from StatReplay feature.
//
// Parameters:
// - pl_message - *in* *charstring* - the message to log
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
function f_EPTF_StatReplay_warning(in @lazy charstring pl_message)
runs on EPTF_CLL_StatReplay_CT
{
f_EPTF_Logging_warningV2(pl_message, v_StatReplay_loggingMaskId, {c_EPTF_StatReplay_loggingClassIdx_Warning});
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_StatReplay_debug
//
// Purpose:
// Function to log a debug message from StatReplay feature.
//
// Parameters:
// - pl_message - *in* *charstring* - the message to log
//
// Return Value:
// -
//
// Errors & assertions:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
function f_EPTF_StatReplay_debug(in @lazy charstring pl_message)
runs on EPTF_CLL_StatReplay_CT
{
f_EPTF_Logging_debugV2(pl_message, v_StatReplay_loggingMaskId, {c_EPTF_StatReplay_loggingClassIdx_Debug});
}
///////////////////////////////////////////////////////////
// Function: f_EPTF_StatReplay_debugEnabled
//
// Purpose:
// Function to check if debug is enabled for StatReplay
//
// Parameters:
// -
//
// Return Value:
// *boolean* - true if debug enalbed
//
// Errors & assertions:
// -
//
// Detailed Comments:
// -
//
///////////////////////////////////////////////////////////
function f_EPTF_StatReplay_debugEnabled()
runs on EPTF_CLL_StatReplay_CT
return boolean
{
return f_EPTF_Logging_isEnabled(v_StatReplay_loggingMaskId, c_EPTF_StatReplay_loggingClassIdx_Debug);
}
} // group Logging
}//end of private group
}// end of module