You are on page 1of 7

Graphical Definition of Curves for Expected Values

2016-01-25
SN-IND-021_GraphicalDefinitions_ExpectedCurves.pdf

Author(s) Katranksi, Ute


Restrictions

Table of contents

1 About this Support Note .................................................................................................................. 1


2 Overview .......................................................................................................................................... 1
3 Introduction ...................................................................................................................................... 1
4 Define the Test in vTESTstudio ....................................................................................................... 2
4.1 Graphically Define Expected Value Curve .............................................................................. 2
4.2 Define Test System Variable to Provide Expected Value ....................................................... 3
4.3 CAPL Code to Perform Cyclic Checking ................................................................................. 3
4.4 CAPL Code to Perform Check when Value Changes ............................................................. 4
4.5 CAPL Code to Perform Value Tolerant Checking ................................................................... 5
4.6 CAPL Code to Perform Value and Time Tolerant Checking ................................................... 5
4.7 Execute the Test in Test Table Editor ..................................................................................... 6
5 Example ........................................................................................................................................... 7
6 Contacts ........................................................................................................................................... 7

1 About this Support Note

In the table below you will find the icon conventions used throughout the Support Note.

Symbol Utilization
This icon indicates notes and tips that facilitate your work.

This icon warns of dangers that could lead to damage.

This icon indicates examples.

2 Overview
This document describes a way how to graphically define an expected value curve for checking the
behavior or outputs of an ECU.

3 Introduction
In vTESTstudio the graphical definition of expected curves can be done with the following design
steps:

 Within the Waveform Editor graphically define the expected curve for each ECU output value to be
checked.

SN-IND-021_GraphicalDefinitions_ExpectedCurves.pdf 1
Graphical Definition of Curves for Expected Values

 Define a test system variable for each expected curve. This is needed to provide the expected
value for checking purposes in the test code. The curve’s values are transferred to the test system
variable by a Waveform Stimulus command.
 Define CAPL event handlers to trigger the check of the ECU’s output value against the expected
value. The check can be triggered either
o cyclically with a fixed period or
o when either the value to be checked (ECU output) or the expected value changes
 Define a CAPL function that implements the check of the ECU’s output value against the expected
value defined in the curve.
 Activate the test in the test sequence within a Test Table.

The velocity dependent locking of the door lock function as shown in the
vTESTstudio demo project “DoorControlUnit” shall be tested. The door control
unit is stimulated using a graphical definition of the vehicle’s velocity. The
expected value of the door lock signal is defined in a graphical curve as well.
The door shall be locked when the velocity reaches 50 km/h.

4 Define the Test in vTESTstudio


4.1 Graphically Define Expected Value Curve

Use vTESTstudio’s Waveform Editor to define the velocity over the time. The velocity is used to
stimulate the ECU. Define a curve with the expected value of the signal “LockState” in the same
waveform file (“ExpectedLockState”).

SN-IND-021_GraphicalDefinitions_ExpectedCurves.pdf 2
Graphical Definition of Curves for Expected Values

4.2 Define Test System Variable to Provide Expected Value

To provide the expected value for the check function a test system variable, for example
“LockStateReference”, is needed. The current value at a specific point in time of the expected curve is
available as value of this test system variable.

4.3 CAPL Code to Perform Cyclic Checking

The following CAPL code is used to perform cyclic checking of the ECU’s output value against the
expected value:

variables
{
mstimer gCheckTimer; // cyclic timer
const int gCheckCycleTime = 20; // cycle time
}

// functions to activate and deactivate the check


export void ActivateTest()
{
setTimer(gCheckTimer, gCheckCycleTime);
}

export void DeactivateTest()


{
cancelTimer(gCheckTimer);
}

// timer handler function to perform the check cyclically


on timer gCheckTimer
{
char failText[255];
if ($LockState != @ReferenceValues::LockStateReference)
{
snprintf(failText, elcount(failText),
"CAN Signal 'LockState' == %d (Actual = %d)",
@ReferenceValues::LockStateReference, $LockState);
testStepFail(failText);
}
setTimer(gCheckTimer, gCheckCycleTime);
}

SN-IND-021_GraphicalDefinitions_ExpectedCurves.pdf 3
Graphical Definition of Curves for Expected Values

4.4 CAPL Code to Perform Check when Value Changes

The following CAPL code is used to perform checking of the values when either the ECU’s output
value changes or the value of the expected curve changes:

variables
{
mstimer gCheckTimer; // timer to delay the check
int gTestActive = 0; // flag to indicate that the check is active
}

// functions to activate and deactivate the check


export void ActivateTest()
{
gTestActive = 1;
}

export void DeactivateTest()


{
gTestActive = 0;
}

// event handler function to execute the check when ECU’s


// output value of changes
on signal LockState
{
if (gTestActive)
{
setTimer(gCheckTimer, 0);
}
}

// event handler function to execute the check when value of


// expected value curve changes
on sysvar sysvar::ReferenceValues::LockStateReference
{
if (gTestActive)
{
setTimer(gCheckTimer, 0);
}
}

// timer handler function to perform the check with the shortest


// possible delay
// this delay is needed because both values, the ECU’s output and
// the expected value, may change at the same time
on timer gCheckTimer
{
char failText[255];
if ($LockState != @ReferenceValues::LockStateReference)
{
snprintf(failText, elcount(failText),
"CAN Signal 'LockState' == %d (Actual = %d)",
@ReferenceValues::LockStateReference, $LockState);
testStepFail(failText);
}
}

SN-IND-021_GraphicalDefinitions_ExpectedCurves.pdf 4
Graphical Definition of Curves for Expected Values

4.5 CAPL Code to Perform Value Tolerant Checking

To perform a value tolerant check the tolerance has to be provided and used in the check expression.
The tolerance will be set in the activate function.

on timer gCheckTimer
{
char failText[255];
double minValue, maxValue;
minValue = @ReferenceValues::LockStateReference - gValueTolerance;
maxValue = @ReferenceValues::LockStateReference + gValueTolerance;

if (($LockState < minValue) || ($LockState > maxValue))


{
snprintf(failText, elcount(failText),
"CAN Signal 'LockState' == %d (Actual = %d)",
@ReferenceValues::LockStateReference, $LockState);
testStepFail(failText);
}
}

4.6 CAPL Code to Perform Value and Time Tolerant Checking

To perform a time tolerant check the checking has to be delayed for the tolerance time. To perform a
time and value tolerant check the following global variables are needed:

variables
{
int gTestActive = 0; // global test active flag
mstimer gFailTimer; // timerfor delayed, time tolerant checking
int gFailTimerActive = 0; // flag indicates that a time tolerent check
// is running
double gValueTolerance = 0; // value tolerance
long gTimeTolerance = 0; // time tolerance in ms
}

At activation and deactivation of the test the tolerances have to be provided:

export void ActivateTest(double valueTolerance, long timeTolerance)


{
gValueTolerance = valueTolerance;
gTimeTolerance = timeTolerance;
gTestActive = 1;
}

export void DeactivateTest()


{
gTestActive = 0;
gFailTimerActive = 0;
cancelTimer(gFailTimer);
}

SN-IND-021_GraphicalDefinitions_ExpectedCurves.pdf 5
Graphical Definition of Curves for Expected Values

If either the value to be checked (signal “LockState”) or the expected curve (test system variable
“LockStateReference”) changes, the check will be performed. If they do not match, a delay reporting of
failure will be actived (timer “gFailTimer”), because the value may match within the time tolerance
(time before the timer ellapses). If the value matches and the timer is active (gFailTimerActive), the
value matches within the time tolerance band and the fail timer has to be canceled:

on signal LockState
{
if (gTestActive) {
if (!CheckVelocityAgainstReference())
{
if (!gFailTimerActive)
{
gFailTimerActive = 1;
setTimer(gFailTimer, gTimeTolerance);
}
} else {
gFailTimerActive = 0;
cancelTimer(gFailTimer);
}
}
}

on sysvar sysvar::ReferenceValues::LockStateReference
{
if (gTestActive) {
if (!CheckVelocityAgainstReference())
{
if (!gFailTimerActive)
{
gFailTimerActive = 1;
setTimer(gFailTimer, gTimeTolerance);
}
} else {
gFailTimerActive = 0;
cancelTimer(gFailTimer);
}
}
}

If the fail timer ellapses, the values do not match within the time tolerance band and a failure has to be
reported:

on timer gFailTimer
{
char testFailText[256];
gFailTimerActive = 0;
snprintf(testFailText, elcount(testFailText),
"CAN Signal 'LockState' == %d (Actual = %d)",
@ReferenceValues::LockStateReference, $LockState);
testStepFail(testFailText);
}

int CheckVelocityAgainstReference()
{
double minValue, maxValue;
minValue = @ReferenceValues::LockStateReference - gValueTolerance;
maxValue = @ReferenceValues::LockStateReference + gValueTolerance;
if (($LockState < minValue) || ($LockState > maxValue)) {
return 0;
}
return 1;
}

4.7 Execute the Test in Test Table Editor

SN-IND-021_GraphicalDefinitions_ExpectedCurves.pdf 6
Graphical Definition of Curves for Expected Values

In the Test Table Editor activate the test, use the [Waveform Stimulus] command to replay the
expected curve (“LockState”) on the test system variable (“LockStateReference”) and finally deactivate
the test:

5 Example
The example project “CheckVelocityLocking.vtsoproj” contains the sources for
a test using a graphical curve for an expected value:

 ValueCurves.vwf: Waveform file with expected curve for signal “LockState” and stimulation curve
for “Velocity”
 CAPL code to perform time and value tolerant checking. Configure one of the following CAPL files
in the test project:
o WaveformCheckCyclic.can: Perform cyclic checks
o WaveformCheckEvent.can: Perform checks when values change
o WaveformCheck.can: Perform time and value tolerant checks when values change
 VelocityTest.vtt: Test Table file to activate the stimulation and the test
 Definition of the test system variable “LockStateReference” in the project configuration

The executable test unit “CheckVelocityLocking.vtuexe” can be configured in the CANoe configuration
“CentralLockingSystem.cfg” provided as demo with vTESTstudio.

6 Contacts
Please find the contacts of Vector Informatik GmbH and all subsidiaries worldwide via:
http://www.vector.com/vi_addresses_en.html

SN-IND-021_GraphicalDefinitions_ExpectedCurves.pdf 7

You might also like