Skip to content
LibItsGeoNetworking_Functions.ttcn 8.02 KiB
Newer Older
berge's avatar
berge committed
/**
 *	@author 	ETSI / STF405
 *  @version 	$URL$
 *				$Id$
 *	@desc		Module containing functions for GeoNetworking
 *
 */
module LibItsGeoNetworking_Functions {
    
berge's avatar
berge committed
    // Libcommon
    import from LibCommon_BasicTypesAndValues all;
    
berge's avatar
berge committed
    // LibIts
    import from LibIts_TestSystem all;
    import from LibIts_Interface all; 
berge's avatar
berge committed
    import from LibItsGeoNetworking_TypesAndValues all;
berge's avatar
berge committed
    import from LibItsGeoNetworking_Templates all;
	    
berge's avatar
berge committed
    /**
     * @desc 	Create Facility component and connects GeoNetworking port
berge's avatar
berge committed
     * @remark	Only used when ItsFa is a PTC
berge's avatar
berge committed
     * @param	p_ptcDenm returned Facility component variable
     */    
berge's avatar
berge committed
    function f_ptcGeoNetworkingUp(out ItsNt p_ptcGeoNetworking) {
berge's avatar
berge committed
        
        // Create Facility component
        p_ptcGeoNetworking := ItsNt.create("GeoNetworking Tester");
berge's avatar
berge committed
        
        // map ports
        map(p_ptcGeoNetworking:geoNetworkingPort, system:geoNetworkingPort);
        
berge's avatar
berge committed
    } // end f_ptcGeoNetworkingUp       
berge's avatar
berge committed
    
    /**
     * @desc 	Wait for component to finish and unmap GeoNetworking ports
berge's avatar
berge committed
     * @remark	Only used when ItsFa is a PTC
berge's avatar
berge committed
     * @param	p_camPtc Facility component variable
     */    
berge's avatar
berge committed
    function f_ptcGeoNetworkingDown(in ItsNt p_ptcGeoNetworking) runs on ItsMtc {    
berge's avatar
berge committed
    	tc_guard.start;
        alt {
        	[] p_ptcGeoNetworking.done {
            	tc_guard.stop;
            }
            
            [] tc_guard.timeout {
berge's avatar
berge committed
             	log("*** f_ptcGeoNetworkingDown: ERROR: Timeout while waiting for component ***");
berge's avatar
berge committed
             	setverdict(inconc);   
            }
        }
        unmap(p_ptcGeoNetworking:geoNetworkingPort);
        
berge's avatar
berge committed
    } // end f_ptcGeoNetworkingDown
berge's avatar
berge committed
    
berge's avatar
berge committed
    group geoAltsteps {
berge's avatar
berge committed
       	/**
         * @desc The base default.
         */
        altstep a_default() runs on ItsNt {
            [] geoNetworkingPort.receive {
                setverdict (inconc, "Received an unexpected message");
                //TODO shall stop be called here?
                stop;
            }
            [] tc_wait.timeout {
                setverdict (inconc, "Timeout while awaiting reaction of the IUT prior to Upper Tester action");
                //TODO shall stop be called here?
                stop;
            }
            [] tc_ac.timeout {
                setverdict (inconc, "Timeout while awaiting the reception of a message");
                //TODO shall stop be called here?
                stop;
            }
        }        
berge's avatar
berge committed
        
        group geoGeoUnicastAltsteps {
            
            /**
             * @desc Receive GeoUnicast packet
             */
        	altstep a_receiveGeoUnicast(
        	   	in template (present) LongPosVector p_senderLongPosVec,
    	    	in template (present) ShortPosVector p_destinationLongPosVec,
    			in template (present) StationTypeIdentifier p_stationType,
    	    	in template (present) UInt16 p_seqNumber
        	) runs on ItsNt {
        	    
        	    [] geoNetworkingPort.receive(mw_geoNwInd(mw_geoNwPdu(mw_geoUnicastHeader(
        	    	p_senderLongPosVec,
    	    		p_destinationLongPosVec,
    				p_stationType,
    	    		p_seqNumber)))) {}
        	}     
        	
        	/**
             * @desc Receive GeoUnicast packet for specific destination
             */
        	altstep a_receiveGeoUnicastWithDestination(in template (present) ShortPosVector p_destinationLongPosVec) runs on ItsNt {
        	    
        	    [] a_receiveGeoUnicast(?, p_destinationLongPosVec, ?, ?) {}
        	}     
            
            /**
             * @desc Receive any GeoUnicast packet
             */
        	altstep a_receiveAnyGeoUnicast() runs on ItsNt {
        	    
        	    [] a_receiveGeoUnicast(?, ?, ?, ?) {}
        	}  
            
        } // end geoGeoUnicastAltsteps
        
        group geoLocationServiceAltsteps {

            /**
             * @desc Receive Location Service Request
             */
            altstep a_receiveLsRequest(
             	in template (present) StationTypeIdentifier p_stationType,
    			in template (present) UInt16 p_seqNumber,
            	in template (present) GN_Address p_gnAddress
            ) runs on ItsNt {
                 
                [] geoNetworkingPort.receive(mw_geoNwInd(mw_geoNwPdu(
                   	mw_lsRequestHeader(
     					p_stationType,
    					p_seqNumber,
            			p_gnAddress)))) {}
            }
            
            /**
             * @desc Receive any Location Service Request
             */
            altstep a_receiveAnyLsRequest() runs on ItsNt {
                 
                [] a_receiveLsRequest(?, ?, ?) {}
            }
            
            /**
             * @desc Receive Location Service Request and send Location Service Reply  
             */
            altstep a_receiveLsRequestAndReply(
            	in template (present) StationTypeIdentifier p_reqStationType,
    			in template (present) UInt16 p_reqSeqNumber,
            	in template (value) GN_Address p_gnAddress,
            	in template (value)	LongPosVector p_repSrcPosVector,
            	in template (value)	LongPosVector p_repSenderPosVector,
            	in template (value) StationTypeIdentifier p_repStationType,
            	in template (value)	UInt16 p_repSeqNumber
            ) runs on ItsNt {
                
                [] a_receiveLsRequest(p_reqStationType, p_reqSeqNumber, p_gnAddress) {
                    geoNetworkingPort.send(m_geoNwReq(m_geoNwPdu(
                    	m_lsRequestHeader(
                    	p_repSrcPosVector,
                    	p_repSenderPosVector,
            			p_repStationType,
            			p_repSeqNumber,
                    	p_gnAddress      
                    )))) 
                }
            }
          
        } // end geoLocationServiceAltsteps
        
        
    } // end geoAltsteps
    
    group preambles {
        
        /**
         * @desc The default preamble.
         */
        function f_prDefault() runs on ItsNt {
            activate(a_default());
        }
        
        /**
         * @desc Brings the IUT into an initial state.
         * @return 
         */
        function f_prInitialState() runs on ItsNt {
            
            f_prDefault();
            
            // TODO: any specific action ?
            
            setverdict(pass);
        }
        
    } // end preambles
    
    group postambles {
        
        /**
         * @desc The default postamble.
         */
        function f_poDefault() runs on ItsNt {
            setverdict(pass);           
        }
    } // end postambles
    
    group upperTester {
        
        function f_utGenerateIpv6Message() runs on ItsNt {
            
        }
        
    } // end upperTester
    
berge's avatar
berge committed
    group testAdapter {
        
        function f_taStartBeaconing(in template (value) Header p_beaconHeader) {
            
        }
        
        function f_taStopBeaconing() {
            
        }
berge's avatar
berge committed
    } // end testAdapter
    
berge's avatar
berge committed
    group testerFunctions {
     	
     	function f_getTesterLongPosVector() return LongPosVector {
berge's avatar
berge committed
            var LongPosVector v_longPosVector;
            
            return v_longPosVector; 
        }
        
berge's avatar
berge committed
     	function f_getTesterGnAddress() return GN_Address {
     	 	var GN_Address v_gnAddress;
     	 	
			return v_gnAddress;
     	}
        
    } // end testerFunctions
    
    group posVectorFunctions {
        
berge's avatar
berge committed
        function f_longPosVector2ShortPosVector(in LongPosVector p_longPosVector) return ShortPosVector {
            var ShortPosVector v_shortPosVector;
            
            return v_shortPosVector; 
        }
        
berge's avatar
berge committed
        function f_getIutShortPosVector() return ShortPosVector {
            var ShortPosVector v_shortPosVector;
            
            return v_shortPosVector; 
        }
        
berge's avatar
berge committed
    } // end posVectorFunctions
    
berge's avatar
berge committed
} // end LibItsGeoNetworking_Functions