LibItsCommon_Functions.ttcn 2.91 KB
Newer Older
/**
 *	@author 	ETSI / STF405
 *  @version 	$URL$
 *				$Id$
 *	@desc		Module containing common functions for ITS
 *
 */
module LibItsCommon_Functions {

    import from DENM_PDU_Descriptions language "ASN.1:1997" all; 
    import from LibItsCommon_Pixits all;
    group generalFunctions {
        
    	/** 
    	 * @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 	random 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;
    
    		log("*** f_random: INFO: OK - random value = " & int2str(v_random) & " ***");
            return v_random;
    
    	} // end function f_random
    
        /**
         * @desc    Gets the current time
         * @return  Timestamp - current time in Epoch format
         */
        function f_getCurrentTime() return TimeStamp {
            var TimeStamp v_timeStamp := 0;
            
            v_timeStamp := fx_getCurrentTime();
            
            return v_timeStamp;
        }
           
    } // end generalFunctions  
       
    group itsFunctions { 

        /** 
         * @desc    Gets the station identifier of test system
         * @return  Test system's station ID
         * @see     PX_TESTER_STATION_ID
         */
        function f_getTsStationId()
        return StationID {
            
            return PX_TESTER_STATION_ID;
                
        } // end f_getTsStationId
        
        /**
         * @desc    Gets the current position of test system
         * @return  Test system's position
         */
        function f_getTsCurrentPosition() return ReferencePosition {
            
            // TODO: correct values required
            var ReferencePosition v_referencePosition := {
                longitude := {hemisphere := east, degree := 0},
                latitude := {hemisphere := north, degree := 0},
                elevation := 0,
                heading := omit,
                streetName := omit,
                positionConfidence := omit,
                elevationConfidence := omit,
                roadSegmentID :=0
            }
            
            return v_referencePosition;
            
        } // end f_getTsCurrentPosition
                
    } // end itsFunctions       
  
    group externalFunctions {
        
        /**
         * @desc    Gets the current time    
         * @return  Timestamp - current time in Epoch format
         */
        external function fx_getCurrentTime() return TimeStamp;
        
    } // end externalFunctions


} // end of module