LibItsCam_Functions.ttcn 7.22 KB
Newer Older
 *    @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 LibItsCam_Pixits all;
fischer's avatar
fischer committed
    import from LibItsCam_TypesAndValues 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;    
fischer's avatar
fischer committed
 
fischer's avatar
fischer committed
    // LibCommon
    import from LibCommon_VerdictControl all;

    group defaults {
fischer's avatar
fischer committed
    
        /**
         * @desc    basic default behaviour handling
         * @remark  none
         * @param   none
         */    
        altstep a_basicDefault() runs on ItsFa {
fischer's avatar
fischer committed
    
            [] 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
         */    
        function f_prInitialState() runs on ItsFa {
            
            // basic default altstep
            activate(a_basicDefault());
                      
berge's avatar
berge committed
            f_utInitializeIut();
            
        } // end f_prInitialState
    } // 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 function f_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
    } // end group otherFunctions
    group upperTester {
        /**
         * @desc    Requests to bring the IUT in an initial state
         * @return 
         */
berge's avatar
berge committed
        function f_utInitializeIut() runs on ItsFa {
            
            utPort.send(UtCamInitialize:{});
            tc_ac.start;
            alt {
                [] utPort.receive(UtCamResult:true) {
berge's avatar
berge committed
                    setverdict (pass, "*** f_utInitializeIut: PASS: IUT initialized ***");
                }
                [] utPort.receive {
berge's avatar
berge committed
                    setverdict (inconc, "*** f_utInitializeIut: INCONC: IUT could not be initialized ***");
                    stop;
                }
                [] tc_ac.timeout {
berge's avatar
berge committed
                    setverdict (inconc, "*** f_utInitializeIut: INCONC: IUT could not be initialized in time ***");
        /**
         * @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;
        }
fischer's avatar
fischer committed
        
        /**
         * @desc Checks that the event was indicated at the application layer
         * @param p_event The event to check.
         * @return 
         */
tepelmann's avatar
tepelmann committed
        function f_utCheckEvent(template (value) CamPdu 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) {
berge's avatar
berge committed
                    setverdict (pass, "*** f_utCheckEvent: PASS: Event correctly indicated at application layer ***");
                    v_ret := e_success;
                }
                [] utPort.receive {
berge's avatar
berge committed
                    setverdict (fail, "*** f_utCheckEvent: FAIL: Event not correctly indicated at application layer ***");
                    v_ret := e_error;
                }
                [] tc_ac.timeout {
berge's avatar
berge committed
                    setverdict (inconc, "*** f_utCheckEvent: INCONC: Timeout while waiting for event check result ***");
                    v_ret := e_timeout;
                }
            }
            
            return v_ret;
        }
    } // end group upperTester
berge's avatar
berge committed
    group getIutFunctions {  
        /** 
         * @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_getIutPtLineDescription()
        return PTLineDescription {
berge's avatar
berge committed

            var PTLineDescription v_ptLineDescription := {"", "", ""};
berge's avatar
berge committed
            v_ptLineDescription := {PX_PTLINE_COURSE, PX_PTLINE_REF, PX_PTLINE_ROUTE}; 

            return v_ptLineDescription ;
berge's avatar
berge committed
        } // end function f_getIutPtLineDescription
    
    } // end getIutFunctions
berge's avatar
berge committed
    group getTesterFunctions {
berge's avatar
berge committed
         * @desc    Gets tester's station characteristics
         * @return  Station characteristics
berge's avatar
berge committed
         * @see     PX_TESTER_IS_MOBILE, PX_TESTER_IS_PRIVATE, PX_TESTER_IS_PHYSICAL_RELEVANT    
berge's avatar
berge committed
        function f_getTesterStationCharacteristics()
        return CoopAwareness.stationCharacteristics {
berge's avatar
berge committed

            var CoopAwareness.stationCharacteristics v_stationCharacteristics := { true, true, true };
berge's avatar
berge committed

berge's avatar
berge committed
            v_stationCharacteristics := {PX_TESTER_IS_MOBILE, PX_TESTER_IS_PRIVATE, PX_TESTER_IS_PHYSICAL_RELEVANT};
            
            return v_stationCharacteristics ;
berge's avatar
berge committed
        } // end f_getTesterStationCharacteristics
berge's avatar
berge committed
    } // end getTesterFunctions
fischer's avatar
fischer committed

} // end LibItsCam_Functions