LibItsBtp_Functions.ttcn 3.3 KB
Newer Older
berge's avatar
berge committed
/**
 *  @author     ETSI / STF405
 *  @version    $URL$
 *              $Id$
 *  @desc       Module containing functions for basic Transport Protocol
 *
 */
fischer's avatar
fischer committed
 
 module LibItsBtp_Functions {
     
    import from LibIts_Interface all;
    import from LibItsBtp_TypesAndValues all;
    import from LibCommon_VerdictControl all;
     
berge's avatar
berge committed
    
fischer's avatar
fischer committed
    group preambles {
        
        /**
         * @desc Brings the IUT into an initial state.
         */
berge's avatar
berge committed
        function f_prInitialState() runs on ItsNt {
fischer's avatar
fischer committed
            
berge's avatar
berge committed
            f_utInitializeIut();
fischer's avatar
fischer committed
            
            setverdict(pass);
        }
        
    } // end of group preambles    
    

    group upperTester {
        
        /**
         * @desc    Requests to bring the IUT in an initial state
         */
berge's avatar
berge committed
        function f_utInitializeIut() runs on ItsNt {
            
            utPort.send(UtBtpInitialize:{});
            tc_ac.start;
            alt {
                [] utPort.receive(UtBtpResult: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 
         */
berge's avatar
berge committed
        function f_utTriggerEvent(template (value) UtBtpEvent p_event) runs on ItsNt return FncRetCode {
            var FncRetCode v_ret := e_success;
            var template (value) UtBtpTrigger v_utMsg := { p_event };
fischer's avatar
fischer committed
            
            utPort.send(v_utMsg);
fischer's avatar
fischer committed
            
            return v_ret;
        }
        
        /**
         * @desc Checks that the event was indicated at the application layer
         * @param p_event The event to check.
         * @return 
         */
berge's avatar
berge committed
        function f_utCheckEvent(template (value) UtBtpEvent p_event) runs on ItsNt return FncRetCode {
            var FncRetCode v_ret := e_success;
            var template (value) UtBtpCheck v_utMsg := { p_event };
            
            utPort.send(v_utMsg);
            tc_ac.start;
            alt {
                [] utPort.receive(UtBtpResult: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;
        }
        
fischer's avatar
fischer committed
    } // end of group upper tester    
berge's avatar
berge committed
    
} // end LibItsBtp_Functions