/**
* @author ETSI / STF405
* @version $URL$
* $Id$
* @desc Module containing common functions for ITS
*
*/
module LibItsCam_Functions {
// LibIts
import from LibIts_TestSystem all;
import from LibIts_Interface all;
import from LibItsCam_Templates all;
import from CAM_PDU_Descriptions language "ASN.1:1997" all;
// LibCommon
import from LibCommon_VerdictControl all;
group defaults {
/**
* @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
group preambles {
/**
* @desc Initialize the IUT
* @remark No specific actions specified in the base standard
* @param none
*/
function f_initialState() runs on ItsFa {
// basic default altstep
activate(a_basicDefault());
} // end f_initialState
} // end of preambles
group postambles {
/**
* @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 of function
} // end of upperTester
group upperTester {
function f_upperTester () {
// crash signal activated
// crash signal deactivated
} // end of function
} // end of upperTester
group configuration {
/**
* @desc Create Facility component and map CAM port
* @remark Only used when ItsFa is a PTC
* @param p_camPtc returned Facility component variable
*/
function f_ptcCamUp(out ItsFa p_ptcCam) {
// Create Facility component
p_ptcCam := ItsFa.create("CAM Tester");
// map ports
map(p_ptcCam:camPort, system:camPort);
} // end f_ptcCamUp
/**
* @desc Wait for component to finish and unmap CAM ports
* @remark Only used when ItsFa is a PTC
* @param p_camPtc Facility component variable
*/
function f_ptcCamDown(in ItsFa p_ptcCam) runs on ItsMtc {
tc_guard.start;
alt {
[] p_ptcCam.done {
tc_guard.stop;
}
[] tc_guard.timeout {
log("*** f_ptcCamDown: ERROR: Timeout while waiting for component ***");
setverdict(inconc);
}
}
unmap(p_ptcCam:camPort);
} // end f_ptcCamDown
} // end of configuration
group otherFunctions {
/** @desc function to generate integer random values
*
* @see ttcn-3 - rnd()
* @param p_lowerbound lowest number in range
* @param p_upperbound highest number in range
* @return integer
*
*/
function f_random( in integer p_lowerbound,
in integer p_upperbound )
return integer {
//Variables
var integer v_random := 0;
v_random := float2int(int2float(p_upperbound - p_lowerbound +1)*rnd()) + p_lowerbound;
// Here, upperbound and lowerbound denote highest and lowest number in range.
log("**** f_random: INFO: OK - random value = " & int2str(v_random) & " ****");
return v_random;
} // end function f_random
/** @desc function to generate a random bitstring value
* corrzesponding to 1 bit position set to 1 (eg '00010000', '01000000', ...)
*
* @see f_random
* @param p_length bitstring length - max 15
* @return bitstring
*
*/
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_random: INFO: OK - random value = " & bit2str(v_random) & " ****");
return v_random;
} // end function f_random
} // end of otherFunctions
group externalFunctions {
/**
* @desc Generate a timestamp of the cureent time to be used in a generationTime field
* @return TimeStamp
*/
external function fx_generateTime()
return TimeStamp;
/** @desc Wrapper function for fx_generateTime
*
* @see xf_generateTime
* @see FncRetCode
*
*/
function f_generateTime()
return TimeStamp {
//Variables
var TimeStamp v_generationTime:=0;
v_generationTime := fx_generateTime();
if (v_generationTime!=0)
{
return v_generationTime ;
log("**** f_generateTime: INFO: OK - generationTime = " & int2str(v_generationTime) & " ****");
}
else {
log("**** f_generateTime: ERROR: timestamp could not be generated ****");
setverdict( inconc ) ;
return v_generationTime ;
stop;
}
} // end function f_generateTime
} // end of externalFunctions
} // end LibItsCam_Functions