LibItsBtp_Functions.ttcn 6.18 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 {
     
    // LibCommon
    import from LibCommon_Sync all;
fischer's avatar
fischer committed
    import from LibCommon_VerdictControl all;
    
    // LibIts
    import from LibIts_Interface all;
    import from LibItsBtp_TypesAndValues all;    
fischer's avatar
fischer committed
     
    group configurationFunctions {
        
        /**
         * @desc    Setups default configuration   
         */
        function f_cfUp() runs on ItsNt {
            
            map(self:utPort, system:utPort);
            map(self:btpPort, system:btpPort);
            f_connect4SelfOrClientSync();
            
        } // end f_cfUp
        
        /**
         * @desc    Deletes default configuration 
         */
        function f_cfDown() runs on ItsNt {
            
            unmap(self:utPort, system:utPort);
            unmap(self:btpPort, system:btpPort);
            f_disconnect4SelfOrClientSync();
            
        } // end f_cfDown
        
    } // end configurationFunctions
berge's avatar
berge committed
    
tepelmann's avatar
tepelmann committed
    group btpAltsteps {
        
        /**
         * @desc The base default.
         */
        altstep a_default() runs on ItsNt {
            
            [] btpPort.receive {
                f_selfOrClientSyncAndVerdict("error", e_error, "*** a_default: Received an unexpected message ***");
            }
            [] tc_wait.timeout {
                f_selfOrClientSyncAndVerdict("error", e_timeout, "*** a_default: Timeout while awaiting reaction of the IUT prior to Upper Tester action ***");
            }
            [] tc_ac.timeout {
                f_selfOrClientSyncAndVerdict("error", e_timeout, "*** a_default: Timeout while awaiting the reception of a message ***");
            }
            [] a_shutdown() {
                f_poDefault();
                f_cfDown();
                log("*** a_default: INFO: TEST COMPONENT NOW STOPPING ITSELF! ***");
                stop;   
            }
        }
    } //end btpAltsteps

fischer's avatar
fischer committed
    group preambles {
        
tepelmann's avatar
tepelmann committed
        /**
         * @desc The default preamble.
         */
        function f_prDefault() runs on ItsNt {
            activate(a_default());
        }
        
fischer's avatar
fischer committed
        /**
         * @desc Brings the IUT into an initial state.
         */
berge's avatar
berge committed
        function f_prInitialState() runs on ItsNt {
fischer's avatar
fischer committed
            
tepelmann's avatar
tepelmann committed
            f_prDefault();
berge's avatar
berge committed
            f_utInitializeIut();
fischer's avatar
fischer committed
        }
        
    } // end of group preambles    
    

tepelmann's avatar
tepelmann committed
    group postambles {
        
        /**
         * @desc The default postamble.
         */
        function f_poDefault() runs on ItsNt {
            //empty
        }
        
    } // end postambles
    
fischer's avatar
fischer committed
    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:{});
            alt {
                [] utPort.receive(UtBtpResult:true) {
                    log("*** f_utInitializeIut: INFO: IUT initialized ***");
                }
                [] utPort.receive {
                    f_selfOrClientSyncAndVerdict("error", e_error, "*** IUT could not be initialized ***");
                [] tc_wait.timeout {
                    f_selfOrClientSyncAndVerdict("error", e_timeout, "*** 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.
tepelmann's avatar
tepelmann committed
         * @param   p_discard The event should not appear. Default value: FALSE.
tepelmann's avatar
tepelmann committed
        function f_utCheckEvent(template (value) UtBtpEvent p_event, boolean p_discard := false) runs on ItsNt {
            var template (value) UtBtpCheck v_utMsg := { p_event };
            
            utPort.send(v_utMsg);
            alt {
                [] utPort.receive(UtBtpResult:true) {
tepelmann's avatar
tepelmann committed
                    if (p_discard == false) {
                        log("*** f_utCheckEvent: Event correctly indicated at application layer ***");
                    }
                    else {
                        f_selfOrClientSyncAndVerdict("error", e_error, "*** f_utCheckEvent: Event indicated at application layer where it should be discarded ***");
                    }
                }
                [] utPort.receive {
tepelmann's avatar
tepelmann committed
                    if (p_discard == false) {
                        f_selfOrClientSyncAndVerdict("error", e_error, "*** f_utCheckEvent: Event not correctly indicated at application layer ***");
                    }
                    else {
                        log("*** f_utCheckEvent: Another event indicated at application layer, repeating check ***");
                        repeat;
                    }
                [] tc_wait.timeout {
tepelmann's avatar
tepelmann committed
                    if (p_discard == false) {
                        f_selfOrClientSyncAndVerdict("error", e_timeout, "*** f_utCheckEvent: Timeout while waiting for event check result ***");
                    }
                    else {
                        log("*** f_utCheckEvent: Event not indicated at application layer ***");
                    }
fischer's avatar
fischer committed
    } // end of group upper tester    
berge's avatar
berge committed
    
} // end LibItsBtp_Functions