Newer
Older
* @author ETSI / STF405
* @version $URL$
* $Id$
* @desc Module containing common functions for ITS
// LibIts
import from LibIts_TestSystem all;
import from LibIts_Interface all;
import from LibItsCam_Templates all;
import from LibItsCam_Pixits all;
import from LibItsCommon_Functions all;
import from CAM_PDU_Descriptions language "ASN.1:1997" all;
import from DENM_PDU_Descriptions language "ASN.1:1997" all;
/**
* @desc basic default behaviour handling
* @remark none
* @param none
*/
altstep a_basicDefault() runs on ItsFa {
[] camPort.receive(mw_camInd ( mw_camMsg_any )){
setverdict(fail, "*** a_basicDefault: FAIL: CAM message received in default ***");
stop;
}
[] camPort.receive {
setverdict(fail, "*** a_basicDefault: FAIL: event received on CAM port in default ***");
stop;
}
[] any timer.timeout {
setverdict(fail, "*** a_basicDefault: FAIL: a timer expired in default ***");
stop;
}
}//end altstep a_basicDefault
} // end of defaults
/**
* @desc Initialize the IUT
* @remark No specific actions specified in the base standard
*/
function f_initialState() runs on ItsFa {
// basic default altstep
activate(a_basicDefault());
} // end f_initialState
/**
* @desc Global postamble - stops the MTC
* @remark No specific actions required so far
* @param none
*/
function f_postamble() runs on ItsFa {
log("*** f_postamble: INFO: postamble ***");
} // end group postambles
group otherFunctions {
/** @desc function to generate a random bitstring value
* corresponding to 1 bit position set to 1 (eg '00010000', '01000000', ...)
*
* @see f_random
* @param p_length bitstring length - max 15<br>
* @return bitstring<br>
*
*/
function f_bitPositionRandom( in integer p_length )
return bitstring {
//Variables
var bitstring v_random := '00000000'B;
v_random := '000000000000001'B << f_random (0, p_length);
log("*** f_bitPositionRandom: INFO: OK - random value = " & bit2str(v_random) & " ***");
return v_random;
} // end function f_bitPositionRandom
/**
* @desc Triggers event from the application layer
* @param p_event The event to trigger.
* @return
*/
function f_utTriggerEvent(template (value) UtCamEvent p_event) runs on ItsFa return FncRetCode {
var FncRetCode v_ret := e_success;
var template (value) UtCamTrigger v_utMsg := { p_event };
utPort.send(v_utMsg);
return v_ret;
}
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/**
* @desc Checks that the event was indicated at the application layer
* @param p_event The event to check.
* @return
*/
function f_utCheckEvent(template (value) UtCamEvent p_event) runs on ItsFa return FncRetCode {
var FncRetCode v_ret := e_success;
var template (value) UtCamCheck v_utMsg := { p_event };
utPort.send(v_utMsg);
tc_ac.start;
alt {
[] utPort.receive(UtCamResult:true) {
setverdict (pass, "Event correctly indicated at application layer");
v_ret := e_success;
}
[] utPort.receive {
setverdict (fail, "Event not correctly indicated at application layer");
v_ret := e_error;
}
[] tc_ac.timeout {
setverdict (inconc, "Timeout while waiting for event check result");
v_ret := e_timeout;
}
}
return v_ret;
}
/**
* @desc Generate a timestamp of the cureent time to be used in a generationTime field
* @return TimeStamp<br>
*/
external function fx_generateTime()
return TimeStamp;
/**
* @desc Wrapper function for fx_generateTime
*
* @see xf_generateTime
*
*/
function f_generateTime()
return TimeStamp {
//Variables
var TimeStamp v_generationTime:=0;
v_generationTime := fx_generateTime();
if (v_generationTime!=0)
{
log("*** f_generateTime: INFO: OK - generationTime = " & int2str(v_generationTime) & " ***");
return v_generationTime ;
}
else {
log("*** f_generateTime: ERROR: timestamp could not be generated ***");
setverdict( inconc ) ;
return v_generationTime ;
}
} // end function f_generateTime
/**
* @desc function to get the PT Line Description
* currently return the PIXIT value
* @see PX_PTLINE_COURSE, PX_PTLINE_REF, PX_PTLINE_ROUTE
*
*/
function f_getPtLineDescription()
return PTLineDescription {
//Variables
var PTLineDescription v_ptLineDescription := { "a", "b", "c" };
v_ptLineDescription := { PX_PTLINE_COURSE, PX_PTLINE_REF, PX_PTLINE_ROUTE }; // PIXIT used!
log("*** f_getPtLineDescription: INFO: OK ***");
return v_ptLineDescription ;
} // end function f_getPtLineDescription
/**
* @desc function to get the stationID
* currently return the PIXIT value
* @see PX_TESTER_STATION_ID
*
*/
function f_getStationId()
return StationID {
//Variables
var StationID v_stationId := 0;
v_stationId := PX_TESTER_STATION_ID; // PIXIT used!
log("*** f_getStationId: INFO: OK - stationId = " & int2str(v_stationId) & " ***");
return v_stationId ;
} // end function fx_getStationId
/**
* @desc get the stationCharacteristics of the tester
* @return CoopAwareness.stationCharacteristics<br>
*/
external function fx_getStationCharacteristics()
return CoopAwareness.stationCharacteristics;
/**
* @desc Wrapper function for fx_getStationCharacteristics
*
* @see fx_getStationCharacteristics
*
*/
function f_getStationCharacteristics()
return CoopAwareness.stationCharacteristics {
//Variables
var CoopAwareness.stationCharacteristics v_stationCharacteristics := { true, true, true };
v_stationCharacteristics := fx_getStationCharacteristics();
log("*** f_getStationCharacteristics: INFO: OK - stationCharacteristics received ***");
return v_stationCharacteristics ;
} // end function f_getStationCharacteristics
/**
* @desc get the ReferencePosition of the tester
* @return ReferencePosition<br>
*/
external function fx_getReferencePosition()
return ReferencePosition;
/**
* @desc Wrapper function for fx_getReferencePosition
*
* @see fx_getReferencePosition
*
*/
function f_getReferencePosition()
return ReferencePosition {
//Variables
var ReferencePosition v_referencePosition;
v_referencePosition := fx_getReferencePosition();
log("*** f_getReferencePosition: INFO: OK - referencePosition received ***");
return v_referencePosition ;
} // end function f_getReferencePosition
} // end group externalFunctions