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

    // LibCommon
    import from LibCommon_Sync all;
    import from LibCommon_VerdictControl all;
    
    // LibIts
    import from LibItsCommon_Pixits all;
    import from ITS_Container language "ASN.1:1997" all;
        /** 
         * @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) & " ***");
        } // end function f_random
berge's avatar
berge committed

        /**
         * @desc    Computes the absolute value of an integer 
         * @param   p_number    the number
         * @return  Absolute value of the number
         */
        function f_abs(in integer p_number) 
        return integer {
            
            if(p_number < 0) {
            	return 0 - p_number;
            }
            return p_number;	
        }

berge's avatar
berge committed
        /**
         * @desc    Compares two values and returns the lowest onde  
         * @param   p_a     First value
         * @param   p_b     Second value
         * @return  Lowest value
         */
        function f_min(in integer p_a, in integer p_b) 
        return integer {
            
            if(p_a < p_b) {
                return p_a;
            }
            return p_b;    
        }

berge's avatar
berge committed
        /** 
         * @desc    Removes unsignificant right-most 0 bits of a bitstring
         *            
         * @param     p_bitstring Bitstring to be reduced
         * @return    Reduced bitstring
         *
        */    
        function f_removeUnsignificantBits(in bitstring p_bitstring)
        return bitstring {
        	var integer i, len;
        	
        	len := lengthof(p_bitstring);
        	for(i:=len-1; i >=0 and p_bitstring[i] == '0'B; i:=i-1) {}
        	return substr(p_bitstring, 0, i + 1);
        } 
    
        /**
         * @desc    Gets the current time
         * @return  Timestamp - current time in Epoch format
         */
        function f_getCurrentTime() return TimestampIts {
            var TimestampIts v_timeStamp := 0;
            log("*** f_getCurrentTime: INFO: calling fx_getCurrentTime() ***");
            v_timeStamp := fx_getCurrentTime();
            
            return v_timeStamp;
        }
           
    } // end generalFunctions  
       
    group itsFunctions { 

        /** 
         * @desc    Gets the station identifier of implementation under test (IUT)
         * @return  IUT's station ID
         * @see     PX_IUT_STATION_ID
         */
        function f_getIutStationId()
        return StationID {
            
            return PX_IUT_STATION_ID;
                
        } // end f_getIutStationId
        
        /** 
         * @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 latitude of test system
         * @return  Test system's latitude
         */
        function f_getTsLatitude() return Latitude {
            
            return PX_TS_LATITUDE;
            
        } // end f_getTsLatitude

        /**
         * @desc    Gets the current longitude of test system
         * @return  Test system's latitude
        function f_getTsLongitude() return Longitude {
            return PX_TS_LONGITUDE;
        } // end f_getTsLongitude
                
    } // end itsFunctions       
  
    group externalFunctions {
        
         * @desc    This external function gets the current time
         * @return  Timestamp - current time in Epoch format
        external function fx_getCurrentTime() return TimestampIts;


} // end of module