Commit 641a5f04 authored by reinaortega's avatar reinaortega
Browse files

ITS lib refactoring

parent 29d65b03
Loading
Loading
Loading
Loading
+105 −8
Original line number Diff line number Diff line
@@ -13,18 +13,115 @@
    import from LibCommon_VerdictControl all;
    
    // LibIts
    import from LibIts_Interface all;
    import from LibItsCommon_Functions all;
    import from LibItsBtp_TestSystem all;
    import from LibItsBtp_TypesAndValues all;
    import from LibItsBtp_Templates all;
    import from LibItsBtp_Pixits all;
    import from LibItsCommon_Functions all;

    group utFuntions { 
            
        /**
         * @desc    Requests to bring the IUT in an initial state
         * @param   p_init The initialisation to trigger.
         */
        function f_utInitializeIut(template (value) UtInitialize p_init) runs on ItsBtp {
            
            utPort.send(p_init);
            tc_wait.start;
            alt {
                [] utPort.receive(UtResult:true) {
                    tc_wait.stop;
                    log("*** f_utInitializeIut: INFO: IUT initialized ***");
                }
                [] utPort.receive {
                    tc_wait.stop;
                    log("*** f_utInitializeIut: INFO: IUT could not be initialized ***");
                    f_selfOrClientSyncAndVerdict("error", e_error);
                }
                [] tc_wait.timeout {
                    log("*** f_utInitializeIut: INFO: IUT could not be initialized in time ***");
                    f_selfOrClientSyncAndVerdict("error", e_timeout);
                }
                [else] { // Shortcut defaults
                    repeat; 
                }
            }
            
        }
        
        /**
         * @desc    Triggers event from the application layer
         * @param   p_event The event to trigger.
         */
        function f_utTriggerEvent(template (value) UtEvent p_event) runs on ItsBtp {
            var template (value) UtTrigger v_utMsg := { p_event };
            
            utPort.send(v_utMsg);
            alt {
                [] utPort.receive(UtResult:true) {
                    tc_wait.stop;
                }
                [] utPort.receive {
                    tc_wait.stop;
                }
                [] tc_wait.timeout {
                }
                [else] { // Shortcut defaults
                    repeat; 
                }
            }
        }
        
        /**
         * @desc Checks that the event was indicated at the application layer
         * @param p_event The event to check.
         * @param   p_discard The event should not appear. Default value: FALSE.
         */
        function f_utCheckEvent(template (value) UtEvent p_event, boolean p_discard) runs on ItsBtp {
            var template (value) UtCheck v_utMsg := { p_event };
            
            utPort.send(v_utMsg);
            tc_wait.start;
            alt {
                [] utPort.receive(UtResult:true) {
                    tc_wait.stop;
                    if (p_discard == false) {
                        log("*** f_utCheckEvent: INFO: Event correctly indicated at application layer ***");
                    }
                    else {
                        log("*** f_utCheckEvent: ERROR: Event indicated at application layer where it should be discarded ***");
                        f_selfOrClientSyncAndVerdict("error", e_error);
                    }
                }
                [] utPort.receive(UtResult:false) {
                    tc_wait.stop;
                    if (p_discard == false) {
                        log("*** f_utCheckEvent: ERROR: Event not correctly indicated at application layer ***");
                        f_selfOrClientSyncAndVerdict("error", e_error);
                    }
                    else {
                        log("*** f_utCheckEvent: INFO: Event not indicated at application layer***");
                    }
                }
                [] tc_wait.timeout {
                    log("*** f_utCheckEvent: ERROR: Timeout while waiting for event check result ***");
                    f_selfOrClientSyncAndVerdict("error", e_timeout);                    
                }
                [else] { // Shortcut defaults
                    repeat; 
                }
            }
        }
                    
    } // End of group utFunctions
     
    group configurationFunctions {
        
        /**
         * @desc    Setups default configuration   
         */
        function f_cfUp() runs on ItsNt {
        function f_cfUp() runs on ItsBtp {
            
            map(self:utPort, system:utPort);
            map(self:btpPort, system:btpPort);
@@ -35,7 +132,7 @@
        /**
         * @desc    Deletes default configuration 
         */
        function f_cfDown() runs on ItsNt {
        function f_cfDown() runs on ItsBtp {
            
            unmap(self:utPort, system:utPort);
            unmap(self:btpPort, system:btpPort);
@@ -50,7 +147,7 @@
        /**
         * @desc The base default.
         */
        altstep a_default() runs on ItsNt {
        altstep a_default() runs on ItsBtp {
            
            [] btpPort.receive {
                log("*** a_default: ERROR: Received an unexpected message ***");
@@ -78,14 +175,14 @@
        /**
         * @desc The default preamble.
         */
        function f_prDefault() runs on ItsNt {
        function f_prDefault() runs on ItsBtp {
            activate(a_default());
        }
        
        /**
         * @desc Brings the IUT into an initial state.
         */
        function f_prInitialState() runs on ItsNt {
        function f_prInitialState() runs on ItsBtp {
            
            f_utInitializeIut(m_btpInitialize);
			f_prDefault();
@@ -100,7 +197,7 @@
        /**
         * @desc The default postamble.
         */
        function f_poDefault() runs on ItsNt {
        function f_poDefault() runs on ItsBtp {
            //empty
        }
        
+0 −1
Original line number Diff line number Diff line
@@ -8,7 +8,6 @@
module LibItsBtp_Pixits {
    
    // LibIts
    import from LibIts_Interface all;
    import from LibItsBtp_TypesAndValues all;
    

+1 −2
Original line number Diff line number Diff line
@@ -8,10 +8,9 @@
module LibItsBtp_Templates {
    
    // LibIts
    import from LibIts_Interface all;
    import from LibItsBtp_TestSystem all;
    import from LibItsBtp_TypesAndValues all;
    import from LibItsBtp_Pixits all;
    import from LibItsCommon_TypesAndValues all;
        
    group btpPrimitivesTemplates {

+107 −0
Original line number Diff line number Diff line
/**
 *    @author     ETSI / STF405
 *  @version     $URL: svn+ssh://vcs.etsi.org/TTCN3/LIB/LibIts/trunk/ttcn/LibIts_TestSystem.ttcn $
 *                $Id: LibIts_TestSystem.ttcn 408 2012-02-28 13:49:56Z garciay $
 *    @desc        Test System module for ITS BTP
 *
 */
module LibItsBtp_TestSystem {
    
    // LibCommon
    import from LibCommon_Time {modulepar all};
    import from LibCommon_Sync all;
    
    // LibIts
    import from LibItsCommon_TestSystem all;
    import from LibItsBtp_TypesAndValues all;
    
    group portDefinitions {
    
        /**
         * @desc Upper Tester port
         */
        type port UpperTesterPort message {
            out 
                UtInitialize, UtTrigger, UtCheck;
            in 
                UtResult;
        } // end UpperTesterPort
        
    } // end portDefinitions

    group interfacePorts {

        group networkAndTransportPorts {
            
            group nt1Ports {

                /**
                 * @desc NT1 BTP Port (BTP/GeoNet/G5) 
                 */
                type port BtpPort message {
                    in BtpInd;
                    out BtpReq;
                } // end BtpPort
                                
            } // End of group nt1Ports
            
        } // End of group networkAndTransportPorts
    
    } // End of group interfacePorts
    
    group componentDefinitions {

        /**
         * @desc ITS System Adapter
         */
        type component ItsBtpSystem {
            
            port UpperTesterPort utPort;
            
            // NT1 ports 
            port BtpPort btpPort;
            
        } // end component ItsAdapter
        
    } // End of group componentDefinitions
    
    /**
     * @desc Test component for ITS Network and Transport layer 
     */
    type component ItsBtp extends ItsBaseComponent {
        
        port UpperTesterPort utPort;
        
        // NT1 ports 
        port BtpPort btpPort;
                
        // timers
                
    } // End of component ItsBtp
        
    group networkAndTransportPrimitives { 
            
        group nt1Primitives {

            /**
             * @desc NT1 BTP Indication Primitive 
             */
            type record BtpInd {
                BtpPacket msgIn
            }
        
            /**
             * @desc NT1 BTP Request Primitive 
             */
            type record BtpReq {
                BtpPacket msgOut
            }
                        
        } // end nt1Primitives
        
    } // End of group networkAndTransportPrimitives    
    with {
        encode "LibIts_Interface"
    } // end interfacePrimitives    
     
} // End of module LibItsBtp_TestSystem
+40 −1
Original line number Diff line number Diff line
@@ -98,6 +98,45 @@ module LibItsBtp_TypesAndValues {

    group utPrimitives {
    	
    	group utCommonPrimitives {
    		
	        /**
	         * @desc Upper Tester message to initialize IUT 
	         */
	        type union UtInitialize {
	            UtBtpInitialize utBtpInitialize
	        }
	
	        /**
	         * @desc Upper Tester message describing an action/event 
	         */
	        type union UtEvent {
	            UtBtpEvent utBtpEvent
	        }
	                
	        /**
	         * @desc Upper Tester message to trigger an action on IUT 
	         */
	        type record UtTrigger {
	            UtEvent utEvent
	        }
	        
	        /**
	         * @desc Upper Tester message to check event/status on IUT 
	         */    
	        type record UtCheck {
	            UtEvent utEvent
	        }
	        
	        /**
	         * @desc Upper Tester response message  
	         */    
	        type boolean UtResult;
        }
        with {
            encode "LibItsCommon_TypesAndValues"
        }
                
        /**
         * @desc Upper Tester message to initialize BTP IUT 
         */
Loading