Commit 4441b867 authored by garciay's avatar garciay
Browse files

Unify STF525 TTCN-3 code

parent 9c7f6e8c
module LibItsBtp_EncdecDeclarations {
// LibItsBtp
import from LibItsBtp_TypesAndValues all;
import from LibItsBtp_TestSystem all;
/* TODO RGy function not implemented! (decvalue() not used by test suite @29-06-2016)
external function fx_dec_BtpPayload (inout bitstring b, out BtpPayload p) return integer
with {extension "prototype(sliding) decode(LibItsBtp)"}
*/
external function fx_enc_BtpReq (BtpReq p) return bitstring
with {extension "prototype(convert) encode(LibIts_Interface)"}
external function fx_enc_BtpInd (BtpInd p) return bitstring
with {extension "prototype(convert) encode(LibIts_Interface)"}
external function fx_dec_BtpInd (inout bitstring b, out BtpInd p) return integer
with {extension "prototype(sliding) decode(LibIts_Interface)"}
external function fx_dec_BtpReq (inout bitstring b, out BtpReq p) return integer
with {extension "prototype(sliding) decode(LibIts_Interface)"}
external function fx_enc_BtpPacket (BtpPacket p) return bitstring
with {extension "prototype(convert) encode(LibIts_Interface)"}
external function fx_dec_BtpPacket (inout bitstring b, out BtpPacket p) return integer
with {extension "prototype(sliding) decode(LibIts_Interface)"}
} // End of module LibItsBtp_EncdecDeclarations
module LibItsBtp_EncdecDeclarations {
// LibItsBtp
import from LibItsBtp_TypesAndValues all;
import from LibItsBtp_TestSystem all;
/* TODO RGy function not implemented! (decvalue() not used by test suite @29-06-2016)
external function fx_dec_BtpPayload (inout bitstring b, out BtpPayload p) return integer
with {extension "prototype(sliding) decode(LibItsBtp)"}
*/
external function fx_enc_BtpReq (BtpReq p) return bitstring
with {extension "prototype(convert) encode(LibIts_Interface)"}
external function fx_enc_BtpInd (BtpInd p) return bitstring
with {extension "prototype(convert) encode(LibIts_Interface)"}
external function fx_dec_BtpInd (inout bitstring b, out BtpInd p) return integer
with {extension "prototype(sliding) decode(LibIts_Interface)"}
external function fx_dec_BtpReq (inout bitstring b, out BtpReq p) return integer
with {extension "prototype(sliding) decode(LibIts_Interface)"}
external function fx_enc_BtpPacket (BtpPacket p) return bitstring
with {extension "prototype(convert) encode(LibIts_Interface)"}
external function fx_dec_BtpPacket (inout bitstring b, out BtpPacket p) return integer
with {extension "prototype(sliding) decode(LibIts_Interface)"}
} // End of module LibItsBtp_EncdecDeclarations
/**
* @author ETSI / STF405
* @version $URL$
* $Id$
* @version $Url: https://oldforge.etsi.org/svn/LibIts/tags/20170222_STF527_Final/ttcn/BTP/LibItsBtp_Functions.ttcn $
* $Id: LibItsBtp_Functions.ttcn 1318 2017-01-26 10:20:53Z filatov $
* @desc Module containing functions for basic Transport Protocol
* @copyright ETSI Copyright Notification
* No part may be reproduced except as authorized by written permission.
......
/**
* @author ETSI / STF405
* @version $URL$
* $Id$
* @version $Url: https://oldforge.etsi.org/svn/LibIts/tags/20170222_STF527_Final/ttcn/BTP/LibItsBtp_Pixits.ttcn $
* $Id: LibItsBtp_Pixits.ttcn 1318 2017-01-26 10:20:53Z filatov $
* @desc Basic Transport Protocol Templates
* @copyright ETSI Copyright Notification
* No part may be reproduced except as authorized by written permission.
......
/**
* @author ETSI / STF405
* @version $URL$
* $Id$
* @version $Url: https://oldforge.etsi.org/svn/LibIts/tags/20170222_STF527_Final/ttcn/BTP/LibItsBtp_Templates.ttcn $
* $Id: LibItsBtp_Templates.ttcn 1318 2017-01-26 10:20:53Z filatov $
* @desc Basic Transport Protocol Templates
* @copyright ETSI Copyright Notification
* No part may be reproduced except as authorized by written permission.
......
/**
* @author ETSI / STF405
* @version $URL$
* $Id$
* @version $Url: https://oldforge.etsi.org/svn/LibIts/tags/20170222_STF527_Final/ttcn/BTP/LibItsBtp_TestSystem.ttcn $
* $Id: LibItsBtp_TestSystem.ttcn 1318 2017-01-26 10:20:53Z filatov $
* @desc Test System module for ITS BTP
* @copyright ETSI Copyright Notification
* No part may be reproduced except as authorized by written permission.
......
/**
* @author ETSI / STF405
* @version $URL$
* $Id$
* @version $Url: https://oldforge.etsi.org/svn/LibIts/tags/20170222_STF527_Final/ttcn/BTP/LibItsBtp_TypesAndValues.ttcn $
* $Id: LibItsBtp_TypesAndValues.ttcn 1318 2017-01-26 10:20:53Z filatov $
* @desc Module containing types and values for Basic Transport Protocol
* @copyright ETSI Copyright Notification
* No part may be reproduced except as authorized by written permission.
......@@ -174,6 +174,6 @@ module LibItsBtp_TypesAndValues {
} with {
variant ""
encode "LibItsGeoNetworking"
encode "LibItsBtp"
}
module LibItsCam_EncdecDeclarations {
// LibIts
import from CAM_PDU_Descriptions language "ASN.1:1997" all;
// LibItsCam
import from LibItsCam_TypesAndValues all;
import from LibItsCam_TestSystem all;
external function fx_enc_CamReq (CamReq p) return bitstring
with {extension "prototype(convert) encode(LibIts_Interface)"}
external function fx_dec_CamReq (inout bitstring b, out CamReq p) return integer
with {extension "prototype(sliding) decode(LibIts_Interface)"}
external function fx_dec_CamInd (inout bitstring b, out CamInd p) return integer
with {extension "prototype(sliding) decode(LibIts_Interface)"}
external function fx_enc_CAM (CAM p) return bitstring
with {extension "prototype(convert) encode(PER)"}
external function fx_dec_CAM (inout bitstring b, out CAM p) return integer
with {extension "prototype(sliding) decode(PER)"}
external function fx_enc_UtCamInitialize (UtCamInitialize p) return bitstring
with {extension "prototype(convert) encode(UpperTester)"}
external function fx_enc_UtCamChangePosition (UtCamChangePosition p) return bitstring
with {extension "prototype(convert) encode(UpperTester)"}
external function fx_enc_UtCamTrigger (UtCamTrigger p) return bitstring
with {extension "prototype(convert) encode(UpperTester)"}
external function fx_dec_UtCamResults (inout bitstring b, out UtCamResults p) return integer
with {extension "prototype(sliding) decode(UpperTester)"}
external function fx_dec_UtCamEventInd (inout bitstring b, out UtCamEventInd p) return integer
with {extension "prototype(sliding) decode(UpperTester)"}
} // End of module LibItsCam_EncdecDeclarations
module LibItsCam_EncdecDeclarations {
// LibIts
import from CAM_PDU_Descriptions language "ASN.1:1997" all;
// LibItsCam
import from LibItsCam_TypesAndValues all;
import from LibItsCam_TestSystem all;
external function fx_enc_CamReq (CamReq p) return bitstring
with {extension "prototype(convert) encode(LibIts_Interface)"}
external function fx_dec_CamReq (inout bitstring b, out CamReq p) return integer
with {extension "prototype(sliding) decode(LibIts_Interface)"}
external function fx_dec_CamInd (inout bitstring b, out CamInd p) return integer
with {extension "prototype(sliding) decode(LibIts_Interface)"}
external function fx_enc_CAM (CAM p) return bitstring
with {extension "prototype(convert) encode(PER)"}
external function fx_dec_CAM (inout bitstring b, out CAM p) return integer
with {extension "prototype(sliding) decode(PER)"}
external function fx_enc_UtCamInitialize (UtCamInitialize p) return bitstring
with {extension "prototype(convert) encode(UpperTester)"}
external function fx_enc_UtCamChangePosition (UtCamChangePosition p) return bitstring
with {extension "prototype(convert) encode(UpperTester)"}
external function fx_enc_UtCamTrigger (UtCamTrigger p) return bitstring
with {extension "prototype(convert) encode(UpperTester)"}
external function fx_dec_UtCamResults (inout bitstring b, out UtCamResults p) return integer
with {extension "prototype(sliding) decode(UpperTester)"}
external function fx_dec_UtCamEventInd (inout bitstring b, out UtCamEventInd p) return integer
with {extension "prototype(sliding) decode(UpperTester)"}
} // End of module LibItsCam_EncdecDeclarations
/**
* @author ETSI / STF405 / STF449 / STF484 / STF517
* @version $URL$
* $Id$
* @version $Url: https://oldforge.etsi.org/svn/LibIts/tags/20170222_STF527_Final/ttcn/CAM/LibItsCam_Functions.ttcn $
* $Id: LibItsCam_Functions.ttcn 1318 2017-01-26 10:20:53Z filatov $
* @desc Module containing common functions for ITS CAM
* @copyright ETSI Copyright Notification
* No part may be reproduced except as authorized by written permission.
......@@ -18,8 +18,6 @@ module LibItsCam_Functions {
// LibIts
import from ITS_Container language "ASN.1:1997" all;
// import from CAM_PDU_Descriptions language "ASN.1:1997" all;
// import from DENM_PDU_Descriptions language "ASN.1:1997" all;
// LibItsCommon
import from LibItsCommon_Pixits all;
......@@ -32,8 +30,7 @@ module LibItsCam_Functions {
import from LibItsCam_Templates all;
import from LibItsCam_TypesAndValues all;
import from LibItsCam_Pics all;
// import from LibItsCam_Pixits all;
// import from LibItsCam_EncdecDeclarations all;
import from LibItsCam_Pixits all;
group utFuntions {
......@@ -110,13 +107,11 @@ module LibItsCam_Functions {
[] utPort.receive(UtCamResults: { utCamChangePositionResult := true}) {
tc_wait.stop;
}
[] utPort.receive(UtCamResults: { utCamChangePositionResult := false }) {
[] utPort.receive(UtCamResults: { utCamChangePositionResult := ? }) {
tc_wait.stop;
log("*** f_utChangePosition: INFO: IUT position change was not successful ***");
f_selfOrClientSyncAndVerdict("error", e_error);
}
[] a_utDefault() {
}
[] tc_wait.timeout {
log("*** " & testcasename() & ": INFO: Could not receive expected UT message from IUT in time ***");
f_selfOrClientSyncAndVerdict("error", e_timeout);
......@@ -136,12 +131,12 @@ module LibItsCam_Functions {
* @desc Initialise secure mode if required
*/
function f_initialiseSecuredMode(
in charstring p_certificate_id := PX_CERT_FOR_TS
in charstring p_certificateId := PX_CERT_FOR_TS
) runs on ItsCam {
if (PICS_IS_IUT_SECURED == true) {
if(e_success != f_acTriggerSecEvent(m_acEnableSecurity(p_certificate_id))) {
if(e_success != f_acTriggerSecEvent(m_acEnableSecurity(p_certificateId))) {
log("*** INFO: TEST CASE NOW STOPPING ITSELF! ***");
stop;
}
......@@ -199,7 +194,7 @@ module LibItsCam_Functions {
[] acPort.receive(m_acGnssResponseSuccess) {
tc_ac.stop;
}
[] acPort.receive {
[] acPort.receive(m_acGnssResponseError) {
tc_ac.stop;
log("*** " & __SCOPE__ & ": ERROR: Received unexpected message ***");
f_selfOrClientSyncAndVerdict("error", e_error);
......@@ -218,7 +213,7 @@ module LibItsCam_Functions {
*
* @param p_scenario The scenario to load.
*/
function f_acLoadScenario(Scenario p_scenario) runs on ItsCam {
function f_acLoadScenario(in Scenario p_scenario) runs on ItsCam {
if (PX_GNSS_SCENARIO_SUPPORT==true) {
f_acTriggerGnssEvent(m_loadScenario(p_scenario));
......@@ -253,12 +248,12 @@ module LibItsCam_Functions {
if (PX_GNSS_SCENARIO_SUPPORT==true and vc_scenarioStarted==true) {
f_acTriggerGnssEvent(m_distanceToCover(p_distanceToCover));
tc_ac.start;
tc_ac.start(PX_T_GNSS_AWAIT_DISTANCE_COVERED);
alt {
[] acPort.receive(m_acGnssDistanceCovered) {
[] acPort.receive(m_acGnssDistanceCoveredSuccess) {
tc_ac.stop;
}
[] acPort.receive {
[] acPort.receive(m_acGnssDistanceCoveredError) {
tc_ac.stop;
log("*** " & __SCOPE__ & ": ERROR: Received unexpected message ***");
f_selfOrClientSyncAndVerdict("error", e_error);
......@@ -273,10 +268,57 @@ module LibItsCam_Functions {
return v_ret;
} // End of function f_acAwaitDistanceCovered
function f_acAwaitSpeed(
float p_speed,
SpeedTrend p_speedTrend := e_accelerate,
boolean p_stopCamPort := true,
boolean p_deactivateCamDefault := false
) runs on ItsCam system ItsCamSystem return FncRetCode {
var FncRetCode v_ret := e_success;
if (PX_GNSS_SCENARIO_SUPPORT==true and vc_scenarioStarted==true) {
if (p_stopCamPort) {
unmap(self:camPort, system:camPort);
}
if (p_deactivateCamDefault) {
vc_camDefaultActive := false;
}
f_acTriggerGnssEvent(m_awaitSpeed(p_speed, p_speedTrend));
tc_ac.start(PX_T_GNSS_AWAIT_SPEED_REACHED);
alt {
[] acPort.receive(m_acGnssSpeedReachedSuccess) {
tc_ac.stop;
}
[] acPort.receive(m_acGnssSpeedReachedError) {
tc_ac.stop;
log("*** " & __SCOPE__ & ": ERROR: Received unexpected message ***");
f_selfOrClientSyncAndVerdict("error", e_error);
}
[] tc_ac.timeout {
log("*** " & __SCOPE__ & ": ERROR: Timeout while waiting for covered distance indication ***");
f_selfOrClientSyncAndVerdict("error", e_timeout);
}
}
if (p_stopCamPort) {
map(self:camPort, system:camPort);
}
if (p_deactivateCamDefault) {
vc_camDefaultActive := true;
}
}
return v_ret;
} // End of function f_acAwaitSpeed
function f_acChangeSpeed(SpeedValue p_deltaSpeedValue) runs on ItsCam {
if (PX_GNSS_SCENARIO_SUPPORT==true and vc_scenarioStarted==true) {
f_acTriggerGnssEvent(m_changeScenarioSpeed(p_deltaSpeedValue));
// f_acTriggerGnssEvent(m_changeScenarioSpeed(p_deltaSpeedValue));
}
} // End of function f_acChangeSpeed
......@@ -287,17 +329,50 @@ module LibItsCam_Functions {
}
} // End of function f_acChangeHeading
function f_acAwaitTimeInRunningScenario(
integer p_time,
boolean p_stopOnCamMessage := true
) runs on ItsCam return FncRetCode {
var FncRetCode v_ret := e_success;
if (PX_GNSS_SCENARIO_SUPPORT==true and vc_scenarioStarted==true) {
f_acTriggerGnssEvent(m_timeInRunningScenario(p_time));
tc_ac.start(int2float(p_time)*1.1);
alt {
[p_stopOnCamMessage] camPort.check(receive(mw_camInd ( mw_camMsg_any ))) {
tc_ac.stop;
}
[] acPort.receive(m_acGnssTimeReachedSuccess) {
tc_ac.stop;
}
[] acPort.receive(m_acGnssTimeReachedError) {
tc_ac.stop;
log("*** " & __SCOPE__ & ": ERROR: Received unexpected message ***");
f_selfOrClientSyncAndVerdict("error", e_error);
}
[] tc_ac.timeout {
log("*** " & __SCOPE__ & ": ERROR: Timeout while waiting for time reached indication ***");
f_selfOrClientSyncAndVerdict("error", e_timeout);
}
}
}
return v_ret;
} // end f_acAwaitTimeInRunningScenario
} // End of group adapterControl
group camConfigurationFunctions {
/**
* @desc Setups default configuration
* @param p_certificate_id The certificate identifier the TA shall use in case of secured IUT
* @param p_certificateId The certificate identifier the TA shall use in case of secured IUT
*/
function f_cfUp(
in charstring p_certificate_id := PX_CERT_FOR_TS
) runs on ItsCam /* TITAN TODO: system ItsCamSystem */ {
in charstring p_certificateId := PX_CERT_FOR_TS
) runs on ItsCam system ItsCamSystem {
map(self:utPort, system:utPort);
map(self:acPort, system:acPort);
......@@ -305,21 +380,23 @@ module LibItsCam_Functions {
f_connect4SelfOrClientSync();
// Initialise secured mode
f_initialiseSecuredMode(p_certificate_id);
f_initialiseSecuredMode(p_certificateId);
} // End of function f_cfUp
/**
* @desc Deletes default configuration
*/
function f_cfDown() runs on ItsCam /* TITAN TODO: system ItsCamSystem */ {
function f_cfDown() runs on ItsCam system ItsCamSystem {
// Initialise secured mode
f_uninitialiseSecuredMode();
unmap(self:camPort, system:camPort);
f_acStopScenario();
unmap(self:utPort, system:utPort);
unmap(self:acPort, system:acPort);
unmap(self:camPort, system:camPort);
f_disconnect4SelfOrClientSync();
} // End of function f_cfDown
......@@ -333,15 +410,32 @@ module LibItsCam_Functions {
*/
altstep a_default() runs on ItsCam {
[] camPort.receive(mw_camInd ( mw_camMsg_any )){
[vc_camDefaultActive] camPort.receive(mw_camInd ( mw_camMsg_any )){
log("*** a_default: INFO: CAM message received in default ***");
vc_camReceived := true;
repeat;
}
[] camPort.receive {
[vc_camDefaultActive] camPort.receive {
log("*** a_default: ERROR: event received on CAM port in default ***");
f_selfOrClientSyncAndVerdict("error", e_error);
}
[] acPort.receive(AdapterControlResults: { acGnssTimeReached := ? }) {
log("*** a_default: INFO: TimeReached event received on AC port in default ***");
repeat;
}
[] acPort.receive(AdapterControlResults: { acGnssSpeedReached := ? }) {
log("*** a_default: INFO: SpeedReached event received on AC port in default ***");
repeat;
}
[] acPort.receive(AdapterControlResults: { acGnssDistanceCovered := ? }) {
log("*** a_default: INFO: DistanceCovered event received on AC port in default ***");
repeat;
}
[] acPort.receive {
tc_ac.stop;
log("*** " & __SCOPE__ & ": ERROR: Received unexpected message ***");
f_selfOrClientSyncAndVerdict("error", e_error);
}
[] any timer.timeout {
log("*** a_default: INCONC: a timer expired in default ***");
f_selfOrClientSyncAndVerdict("error", e_timeout);
......@@ -389,7 +483,8 @@ module LibItsCam_Functions {
function f_prInitialState(
in Scenario p_scenario := e_staticPosition,
in boolean p_awaitInitialCAM := true,
in template (value) UtCamInitialize p_camInitialize := m_camInitialize
in template (value) UtCamInitialize p_camInitialize := m_camInitialize,
in boolean p_awaitTimeInRunningScenario := true
) runs on ItsCam {
f_utInitializeIut(p_camInitialize);
......@@ -404,6 +499,9 @@ module LibItsCam_Functions {
camPort.clear;
f_acStartScenario();
if (p_awaitTimeInRunningScenario) {
f_acAwaitTimeInRunningScenario(f_getTimeForGpsFix());
}
if (p_awaitInitialCAM) {
tc_ac.start;
......@@ -429,10 +527,9 @@ module LibItsCam_Functions {
* @desc The default postamble.
*/
function f_poDefault() runs on ItsCam {
f_acStopScenario();
}
} // End group postambles
} // End of group postambles
group camPositionFunctions {
......@@ -460,7 +557,21 @@ module LibItsCam_Functions {
return v_referencePosition;
}
} // End group camPositionFunctions
/**
* @desc Compute distance between two points
* @param p_pointA First point
* @param p_pointB Second point
* @return Computed distance in meters
* @see fx_computeDistance
*/
function f_distance(
in ReferencePosition p_pointA,
in ReferencePosition p_pointB
) return float {
return fx_computeDistance(p_pointA.latitude, p_pointA.longitude, p_pointB.latitude, p_pointB.longitude);
}
} // end group camPositionFunctions
group camAuxilaryFunctions {
......
/**
* @author ETSI / STF405 / STF449 / STF484 / STF517
* @version $URL$
* $Id$
* @version $Url: https://oldforge.etsi.org/svn/LibIts/tags/20170222_STF527_Final/ttcn/CAM/LibItsCam_Pics.ttcn $
* $Id: LibItsCam_Pics.ttcn 1318 2017-01-26 10:20:53Z filatov $
* @desc CAM PICS
* @copyright ETSI Copyright Notification
* No part may be reproduced except as authorized by written permission.
......
/**
* @author ETSI / STF405 / STF449 / STF484 / STF517
* @version $URL$
* $Id$
* @desc Module containing Pixits for CAM
* @copyright ETSI Copyright Notification
* No part may be reproduced except as authorized by written permission.
* The copyright and the foregoing restriction extend to reproduction in all media.
* All rights reserved.
*
*/
module LibItsCam_Pixits {
// LibCommon
import from LibCommon_BasicTypesAndValues all;
import from LibCommon_DataStrings all;
// LibItsSecurity
import from LibItsSecurity_TypesAndValues all;
/**
* @author ETSI / STF405 / STF449 / STF484 / STF517
* @version $Url: https://oldforge.etsi.org/svn/LibIts/tags/20170222_STF527_Final/ttcn/CAM/LibItsCam_Pixits.ttcn $
* $Id: LibItsCam_Pixits.ttcn 1318 2017-01-26 10:20:53Z filatov $
* @desc Module containing Pixits for CAM
* @copyright ETSI Copyright Notification
* No part may be reproduced except as authorized by written permission.
* The copyright and the foregoing restriction extend to reproduction in all media.
* All rights reserved.
*
*/
module LibItsCam_Pixits {
// LibCommon
import from LibCommon_BasicTypesAndValues all;
import from LibCommon_DataStrings all;
// LibItsSecurity
import from LibItsSecurity_TypesAndValues all;
} // End of module LibItsSecurity_Pixits
\ No newline at end of file
/**
* @author ETSI / STF405 / STF449 / STF484 / STF517
* @version $URL$
* $Id$
* @version $Url: https://oldforge.etsi.org/svn/LibIts/tags/20170222_STF527_Final/ttcn/CAM/LibItsCam_Templates.ttcn $
* $Id: LibItsCam_Templates.ttcn 1318 2017-01-26 10:20:53Z filatov $
* @desc Module containing base template definitions for CAM
* @copyright ETSI Copyright Notification
* No part may be reproduced except as authorized by written permission.
......@@ -218,6 +218,19 @@ module LibItsCam_Templates {
}
}
/**
* @desc Reference position for given latitude and longitude.
*/
template (present) ReferencePosition mw_refPositionWithDelta(
in ReferencePosition p_origRefPos,
in integer p_jitter := 100
) := {
latitude := (p_origRefPos.latitude - p_jitter..p_origRefPos.latitude + p_jitter),
longitude := (p_origRefPos.longitude - p_jitter..p_origRefPos.longitude + p_jitter),
positionConfidenceEllipse := p_origRefPos.positionConfidenceEllipse,
altitude := p_origRefPos.altitude
}
} // end positionTemplates
/**
......
/**
* @author ETSI / STF405 / STF449 / STF484 / STF517
* @version $URL$
* $Id$