Skip to content
LibItsCam_Functions.ttcn 15.9 KiB
Newer Older
/**
 *	@author 	ETSI / STF405
berge's avatar
berge committed
 *  @version 	$URL$
 *				$Id$
berge's avatar
berge committed
 *	@desc		Module containing common functions for ITS
module LibItsCam_Functions {
    // LibIts
    import from LibIts_TestSystem all;
    import from LibIts_Interface all; 
fischer's avatar
fischer committed
	import from LibItsCam_Templates all;
fischer's avatar
fischer committed
	import from LibItsCam_Pixits all;
    import from LibItsCam_TypesAndValues all;
fischer's avatar
fischer committed
	import from CAM_PDU_Descriptions language "ASN.1:1997" all;
berge's avatar
berge committed
	import from DENM_PDU_Descriptions language "ASN.1:1997" all;	
fischer's avatar
fischer committed
 
fischer's avatar
fischer committed
    // LibCommon
    import from LibCommon_VerdictControl all;

fischer's avatar
fischer committed
 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 ***");
fischer's avatar
fischer committed
			stop;
		}
		[] camPort.receive {
			setverdict(fail, "*** a_basicDefault: FAIL: event received on CAM port in default ***");
fischer's avatar
fischer committed
			stop;
		}
       [] any timer.timeout { 
			setverdict(fail, "*** a_basicDefault: FAIL: a timer expired in default ***");
fischer's avatar
fischer committed
			stop;
		}
	}//end altstep a_basicDefault
     
     
     
 } // end of defaults  
 
 group preambles {
        
fischer's avatar
fischer committed
    /**
     * @desc 	Initialize the IUT
     * @remark	No specific actions specified in the base standard
     * @param	none
     */    
fischer's avatar
fischer committed
    function f_initialState() runs on ItsFa {
fischer's avatar
fischer committed
        
fischer's avatar
fischer committed
        // basic default altstep
        activate(a_basicDefault());
                  
fischer's avatar
fischer committed
    } // end f_initialState
fischer's avatar
fischer committed
 
 } // end of preambles
fischer's avatar
fischer committed

fischer's avatar
fischer committed
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 function f_postamble
fischer's avatar
fischer committed
    
} // end group postambles
fischer's avatar
fischer committed

fischer's avatar
fischer committed
group otherFunctions {
        
	/** @desc	function to generate integer random values
	 *			
	 * @see		ttcn-3 - rnd()
	 *  @param 	p_lowerbound lowest number in range<br>
	 *  @param 	p_upperbound highest number in range<br>
	 *  @return 	integer<br>
	 *
	*/
	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.
berge's avatar
berge committed
		log("*** f_random: INFO: OK - random value = " & int2str(v_random) & " ***");
fischer's avatar
fischer committed
        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<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);
berge's avatar
berge committed
		log("*** f_random: INFO: OK - random value = " & bit2str(v_random) & " ***");
fischer's avatar
fischer committed
        return v_random;

	} // end function f_random

} // end group otherFunctions
fischer's avatar
fischer committed

fischer's avatar
fischer committed
group upperTester {
    
	/** @desc	upper tester function to change current heading (absolute)
	*
	* @param 	p_heading<br>
	* @return 	FncRetCode<br>
	*/
	function f_changeHeading( Direction p_heading ) runs on ItsFa return FncRetCode {

		//Variables
        var FncRetCode v_ret := e_success;
            
        //TODO define external function
berge's avatar
berge committed
		log("*** f_changeHeading: INFO: OK  ***");
fischer's avatar
fischer committed
            
        return v_ret;
        
    } // end function f_changeHeading
    
	/** @desc	upper tester function to change current position (meter)
	*
	* @param 	p_position<br>
	* @return 	FncRetCode<br>
	*/
	function f_changePosition( integer p_position ) runs on ItsFa return FncRetCode {

		//Variables
        var FncRetCode v_ret := e_success;
            
        //TODO define external function
berge's avatar
berge committed
		log("*** f_changePosition: INFO: OK  ***");
fischer's avatar
fischer committed
            
        return v_ret;
        
    } // end function f_changePosition
    
	/** @desc	upper tester function to change speed (m/S)
	*
	* @param 	p_speed<br>
	* @return 	FncRetCode<br>
	*/
	function f_changeSpeed( Speed p_speed ) runs on ItsFa return FncRetCode {

		//Variables
        var FncRetCode v_ret := e_success;
            
        //TODO define external function
berge's avatar
berge committed
		log("*** f_changeSpeed: INFO: OK  ***");
fischer's avatar
fischer committed
            
        return v_ret;
        
    } // end function f_changeSpeed
    
	/** @desc	upper tester function to set the crash signal (activated/deactivated)
	*
	* @param 	p_crashStatus<br>
	* @return 	FncRetCode<br>
	*/
	function f_setCrashSignal( CrashStatus p_crashStatus ) runs on ItsFa return FncRetCode {

		//Variables
        var FncRetCode v_ret := e_success;
            
        //TODO define external function
berge's avatar
berge committed
		log("*** f_setCrashSignal: INFO: OK  ***");
fischer's avatar
fischer committed
            
        return v_ret;
        
    } // end function f_setCrashSignal
    
	/** @desc	upper tester function to set the dangerous goods status (Good type)
	*			p_goodType = 0 if no dangerous goods are transported
	* @param 	p_goodType<br>
	* @return 	FncRetCode<br>
	*/
	function f_setDangerousGoodsStatus( DangerousGoods p_goodType ) runs on ItsFa return FncRetCode {

		//Variables
        var FncRetCode v_ret := e_success;
            
        //TODO define external function
berge's avatar
berge committed
		log("*** f_setDangerousGoodsStatus: INFO: OK  ***");
fischer's avatar
fischer committed
            
        return v_ret;
        
    } // end function f_setDangerousGoodsStatus
    
fischer's avatar
fischer committed
	/** 
	* @desc	upper tester function to set if the Length/Width is precisely determined
	*			p_precision = true if the Length/Width is precisely determined
	* @param 	p_precision<br>
	* @return 	FncRetCode<br>
	*/
	function f_setLengthWidthPrecision( boolean p_precision ) runs on ItsFa return FncRetCode {

		//Variables
        var FncRetCode v_ret := e_success;
            
        //TODO define external function
berge's avatar
berge committed
		log("*** f_setLengthWidthPrecision: INFO: OK  ***");
fischer's avatar
fischer committed
            
        return v_ret;
        
    } // end function f_setLengthWidthPrecision
    
fischer's avatar
fischer committed
	/** 
	*	@desc	upper tester function to set the doors status			
	* 	@param 	p_doorStatus<br>
	* 	@return 	FncRetCode<br>
	*/
	function f_setDoorStatus( DoorOpen p_doorStatus ) runs on ItsFa return FncRetCode {

		//Variables
        var FncRetCode v_ret := e_success;
            
        //TODO define external function
berge's avatar
berge committed
		log("*** f_setDoorStatus: INFO: OK  ***");
fischer's avatar
fischer committed
            
        return v_ret;
        
    } // end function f_setDoorStatus
    
	/** @desc	upper tester function to set the distance to stop line
	*			
	* @param 	p_distance<br>
	* @return 	FncRetCode<br>
	*/
	function f_setDistanceToStopLine( Distance p_distance ) runs on ItsFa return FncRetCode {

		//Variables
        var FncRetCode v_ret := e_success;
            
        //TODO define external function
berge's avatar
berge committed
		log("*** f_setDistanceToStopLine: INFO: OK  ***");
fischer's avatar
fischer committed
            
        return v_ret;
        
    } // end function f_setDistanceToStopLine
    
	/** @desc	upper tester function to set the turn advice
	*			
	* @param 	p_turnAdvice<br>
	* @return 	FncRetCode<br>
	*/
	function f_setTurnAdvice( TurnAdvice p_turnAdvice ) runs on ItsFa return FncRetCode {

		//Variables
        var FncRetCode v_ret := e_success;
            
        //TODO define external function
berge's avatar
berge committed
		log("*** f_setTurnAdvice: INFO: OK  ***");
fischer's avatar
fischer committed
            
        return v_ret;
        
    } // end function f_setTurnAdvice
    
	/** @desc	upper tester function to set the curvature change
	*			
	* @param 	p_curvature<br>
	* @return 	FncRetCode<br>
	*/
	function f_setCurvatureChange( Curvature p_curvature ) runs on ItsFa return FncRetCode {

		//Variables
        var FncRetCode v_ret := e_success;
            
        //TODO define external function
berge's avatar
berge committed
		log("*** f_setCurvatureChange: INFO: OK  ***");
fischer's avatar
fischer committed
            
        return v_ret;
        
    } // end function f_setCurvatureChange
    
	/** @desc	upper tester function to set the Occupancy
	*			
	* @param 	p_occupancy<br>
	* @return 	FncRetCode<br>
	*/
	function f_setOccupancy( Occupancy p_occupancy ) runs on ItsFa return FncRetCode {

		//Variables
        var FncRetCode v_ret := e_success;
            
        //TODO define external function
berge's avatar
berge committed
		log("*** f_setOccupancy: INFO: OK  ***");
fischer's avatar
fischer committed
            
        return v_ret;
        
    } // end function f_setOccupancy
    
	/** @desc	upper tester function to set the light bar status
	*			
	* @param 	p_status<br>
	* @return 	FncRetCode<br>
	*/
	function f_setLightBarStatus( SimpleSystemState p_status ) runs on ItsFa return FncRetCode {

		//Variables
        var FncRetCode v_ret := e_success;
            
        //TODO define external function
berge's avatar
berge committed
		log("*** f_setLightBarStatus: INFO: OK  ***");
fischer's avatar
fischer committed
            
        return v_ret;
        
    } // end function f_setLightBarStatus
    
	/** @desc	upper tester function to set the sirene status
	*			
	* @param 	p_status<br>
	* @return 	FncRetCode<br>
	*/
	function f_setSireneStatus( SimpleSystemState p_status ) runs on ItsFa return FncRetCode {

		//Variables
        var FncRetCode v_ret := e_success;
            
        //TODO define external function
berge's avatar
berge committed
		log("*** f_setSireneStatus: INFO: OK  ***");
fischer's avatar
fischer committed
            
        return v_ret;
        
    } // end function f_setSireneStatus
    
	/** @desc	upper tester function to set the traffic light priority
	*			
	* @param 	p_priority<br>
	* @return 	FncRetCode<br>
	*/
	function f_setTrafficLightPriority( Priority p_priority ) runs on ItsFa return FncRetCode {

		//Variables
        var FncRetCode v_ret := e_success;
            
        //TODO define external function
berge's avatar
berge committed
		log("*** f_setTrafficLightPriority: INFO: OK  ***");
fischer's avatar
fischer committed
            
        return v_ret;
        
    } // end function f_setTrafficLightPriority
    
    
	/** 
	*	@desc	upper tester function to set the Schedule Deviation			
	* 	@param 	p_scheduleDeviation<br>
	* 	@return 	FncRetCode<br>
	*/
	function f_setScheduleDeviation( ScheduleDeviation p_scheduleDeviation ) runs on ItsFa return FncRetCode {

		//Variables
        var FncRetCode v_ret := e_success;
            
        //TODO define external function
berge's avatar
berge committed
		log("*** f_setScheduleDeviation: INFO: OK  ***");
fischer's avatar
fischer committed
            
        return v_ret;
        
    } // end function f_setScheduleDeviation
    
	/** 
	*	@desc	upper tester function to set the PT Line Description			
berge's avatar
berge committed
	* 	@param 	p_ptLineDescription<br>
fischer's avatar
fischer committed
	* 	@return 	FncRetCode<br>
	*/
berge's avatar
berge committed
	function f_setPtLineDescription( PTLineDescription p_ptLineDescription ) runs on ItsFa return FncRetCode {
fischer's avatar
fischer committed

		//Variables
        var FncRetCode v_ret := e_success;
            
        //TODO define external function
berge's avatar
berge committed
		log("*** f_setPtLineDescription: INFO: OK  ***");
fischer's avatar
fischer committed
            
        return v_ret;
        
berge's avatar
berge committed
    } // end function f_setPtLineDescription
fischer's avatar
fischer committed
    
	/** 
	*	@desc	upper tester function to set the exterior lights status			
	* 	@param 	p_exteriorLightsStatus<br>
	* 	@return 	FncRetCode<br>
	*/
	function f_setExteriorLightsStatus( ExteriorLights p_exteriorLightsStatus ) runs on ItsFa return FncRetCode {

		//Variables
        var FncRetCode v_ret := e_success;
            
        //TODO define external function
berge's avatar
berge committed
		log("*** f_setExteriorLightsStatus: INFO: OK  ***");
fischer's avatar
fischer committed
            
        return v_ret;
        
    } // end function f_setExteriorLightsStatus
    
	/** 
	*	@desc	upper tester function to change the reference position (moving)			
fischer's avatar
fischer committed
	* 	@param 	none<br>
	* 	@return 	FncRetCode<br>
	*/
	function f_changeReferencePosition() runs on ItsFa return FncRetCode {

		//Variables
        var FncRetCode v_ret := e_success;
            
        //TODO define external function
berge's avatar
berge committed
		log("*** f_changeReferencePosition: INFO: OK  ***");
fischer's avatar
fischer committed
            
        return v_ret;
        
    } // end function f_changeReferencePosition
    
	/** 
	*	@desc	upper tester function to check that the CAM was received on LDM			
	* 	@param 	p_camMsg<br>
	* 			p_received<br>
	* 	@return FncRetCode<br>
	*/
	function f_checkLdmReceipt( in CamReq p_camMsg, out boolean p_received) runs on ItsFa return FncRetCode {

		//Variables
        var FncRetCode v_ret := e_success;
            
        //TODO define external function
berge's avatar
berge committed
		log("*** f_checkLdmReceipt: INFO: OK  ***");
            
        return v_ret;
        
    } // end function f_checkLdmReceipt

} // end group upperTester
fischer's avatar
fischer committed
group externalFunctions {
    
	/**
	*	@desc 	Generate a timestamp of the cureent time to be used in a generationTime field
	* @return 	TimeStamp<br>
	*/
	external function fx_generateTime()
	return TimeStamp;

fischer's avatar
fischer committed
	/** @desc	Wrapper function for fx_generateTime
fischer's avatar
fischer committed
	 *			
	 * @see		xf_generateTime
	 *
	*/
	function f_generateTime()
	return TimeStamp {
		//Variables
		var TimeStamp v_generationTime:=0;
		
        v_generationTime := fx_generateTime();
        if (v_generationTime!=0)
        {
berge's avatar
berge committed
			log("*** f_generateTime: INFO: OK - generationTime = " & int2str(v_generationTime) & " ***");
berge's avatar
berge committed
            return v_generationTime ;			
fischer's avatar
fischer committed
		}
		else {
berge's avatar
berge committed
			log("*** f_generateTime: ERROR: timestamp could not be generated ***");
fischer's avatar
fischer committed
			setverdict( inconc ) ;
fischer's avatar
fischer committed
            return v_generationTime ;
fischer's avatar
fischer committed
		} 
fischer's avatar
fischer committed
	} // end function f_generateTime
fischer's avatar
fischer committed
	

	/** @desc	function to get the PT Line Description
	 *			currently return the PIXIT value
	 * @see		PX_PTLINE_COURSE, PX_PTLINE_REF, PX_PTLINE_ROUTE
	 *
	*/
berge's avatar
berge committed
	function f_getPtLineDescription()
fischer's avatar
fischer committed
	return PTLineDescription {
		//Variables
berge's avatar
berge committed
		var PTLineDescription v_ptLineDescription := { "a", "b", "c" };
berge's avatar
berge committed
        v_ptLineDescription :=  { PX_PTLINE_COURSE, PX_PTLINE_REF, PX_PTLINE_ROUTE };   // PIXIT used!
		log("*** f_getPtLineDescription: INFO: OK  ***");
        return v_ptLineDescription ;
berge's avatar
berge committed
	} // end function f_getPtLineDescription
fischer's avatar
fischer committed
	
	/** @desc	function to get the stationID
	 *			currently return the PIXIT value
	 * @see		PX_TESTER_STATION_ID
	 *
	*/
berge's avatar
berge committed
	function f_getStationId()
fischer's avatar
fischer committed
	return StationID {
		//Variables
berge's avatar
berge committed
		var StationID v_stationId := 0;
berge's avatar
berge committed
        v_stationId :=  PX_TESTER_STATION_ID;   // PIXIT used!
		log("*** f_getStationId: INFO: OK - stationId = " & int2str(v_stationId) & " ***");
        return v_stationId ;
berge's avatar
berge committed
	} // end function fx_getStationId
fischer's avatar
fischer committed
	
	/**
	*	@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();
berge's avatar
berge committed
		log("*** f_getStationCharacteristics: INFO: OK - stationCharacteristics received ***");
fischer's avatar
fischer committed
        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();
berge's avatar
berge committed
		log("*** f_getReferencePosition: INFO: OK - referencePosition received ***");
fischer's avatar
fischer committed
        return v_referencePosition ;

	} // end function f_getReferencePosition
	
	
fischer's avatar
fischer committed

} // end group externalFunctions
fischer's avatar
fischer committed

} // end LibItsCam_Functions