Skip to content
LibItsGeoNetworking_Functions.ttcn 40.4 KiB
Newer Older
berge's avatar
berge committed
/**
berge's avatar
berge committed
 *  @author     ETSI / STF405
 *  @version    $URL$
 *              $Id$
 *  @desc       Module containing functions for GeoNetworking
berge's avatar
berge committed
 *
 */
module LibItsGeoNetworking_Functions {
    
berge's avatar
berge committed
    // Libcommon
    import from LibCommon_BasicTypesAndValues all;
    import from LibCommon_VerdictControl {type FncRetCode;}
    import from LibCommon_Sync {altstep 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
    /**
berge's avatar
berge committed
     * @desc    Create Facility component and connects GeoNetworking port
     * @remark  Only used when ItsFa is a PTC
     * @param   p_ptcDenm returned Facility component variable
berge's avatar
berge committed
     */    
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
    
    /**
berge's avatar
berge committed
     * @desc    Wait for component to finish and unmap GeoNetworking ports
     * @remark  Only used when ItsFa is a PTC
     * @param   p_camPtc Facility component variable
berge's avatar
berge committed
     */    
berge's avatar
berge committed
    function f_ptcGeoNetworkingDown(in ItsNt p_ptcGeoNetworking) runs on ItsMtc {    
berge's avatar
berge committed
        tc_guard.start;
berge's avatar
berge committed
        alt {
berge's avatar
berge committed
            [] p_ptcGeoNetworking.done {
                tc_guard.stop;
berge's avatar
berge committed
            }
            
            [] tc_guard.timeout {
berge's avatar
berge committed
                log("*** f_ptcGeoNetworkingDown: ERROR: Timeout while waiting for component ***");
                setverdict(inconc);   
berge's avatar
berge committed
            }
        }
        unmap(p_ptcGeoNetworking:geoNetworkingPort);
        
berge's avatar
berge committed
    } // end f_ptcGeoNetworkingDown
berge's avatar
berge committed
    
    group geoConfigurationFunctions {
        
        /**
         * @desc This configuration features:
         *       - one ITS node (IUT)
         *       - two ITS nodes (nodeA, nodeB)
         *       - Area1 which only includes NodeB and IUT
         *       - Area2 which only includes NodeB 
         *         NodeB being close to the area center    
         */
        function f_cf01Up() runs on ItsNt {

            // Variables
            var PositionTable v_positionTable := {};
 
            // Map
            map(self:geoNetworkingPort, system:geoNetworkingPort);
            
            // Position table
            f_addPosition(v_positionTable, c_compIut, f_getIutLongPosVector());
            f_addPosition(v_positionTable, c_compNodeA, f_computePosition());
            f_addPosition(v_positionTable, c_compNodeB, f_computePosition());
        
            f_initialiseComponent(v_positionTable, c_compNodeB);
            
        } // end f_cf01Up

berge's avatar
berge committed
        /**
         * @desc Deletes configuration cf01
         */
        function f_cf01Down() runs on ItsNt {

            // Map
            unmap(self:geoNetworkingPort, system:geoNetworkingPort);
            
        } // end f_cf01Down
        
        /**
         * @desc This configuration features:
         *       - one ITS node (IUT)
         *       - one ITS node (NodeB)
berge's avatar
berge committed
         *       - one ITS node (NodeD)
         *       - Area1 which only includes NodeB, NodeD and IUT
         *       - Area2 which only includes NodeB and NodeD 
         *         NodeB being close to the area center          
berge's avatar
berge committed
         * @param p_nodeB
berge's avatar
berge committed
         * @param p_nodeD
berge's avatar
berge committed
        function f_cf02Up(out ItsNt p_nodeB, out ItsNt p_nodeD) runs on ItsMtc {
            
            // Variables
            var PositionTable v_positionTable := {};
            
            // Create
            p_nodeB := ItsNt.create(c_compNodeB) alive;
berge's avatar
berge committed
            p_nodeD := ItsNt.create(c_compNodeD) alive;

            // Map            
            map(p_nodeB:geoNetworkingPort, system:geoNetworkingPort);
berge's avatar
berge committed
            map(p_nodeD:geoNetworkingPort, system:geoNetworkingPort);
            
            // Connect            
            connect(p_nodeB:syncPort, self:syncPort);
berge's avatar
berge committed
            connect(p_nodeD:syncPort, self:syncPort);
        
            // Position table
            f_addPosition(v_positionTable, c_compIut, f_getIutLongPosVector());
            f_addPosition(v_positionTable, c_compNodeB, f_computePosition());
berge's avatar
berge committed
            f_addPosition(v_positionTable, c_compNodeD, f_computePosition());
            
            p_nodeB.start(f_initialiseComponent(v_positionTable, c_compNodeB));
berge's avatar
berge committed
            p_nodeD.start(f_initialiseComponent(v_positionTable, c_compNodeD));
            p_nodeD.done;
            p_nodeD.done;
        
        } // end f_cf02Up

berge's avatar
berge committed
        /**
         * @desc Deletes configuration cf02
         * @param p_nodeB
berge's avatar
berge committed
         * @param p_nodeD
berge's avatar
berge committed
        function f_cf02Down(in ItsNt p_nodeB, in ItsNt p_nodeD) runs on ItsMtc {
            
            // Map
            unmap(p_nodeB:geoNetworkingPort, system:geoNetworkingPort);
berge's avatar
berge committed
            unmap(p_nodeD:geoNetworkingPort, system:geoNetworkingPort);
            
            // Connect
            disconnect(p_nodeB:syncPort, self:syncPort);
berge's avatar
berge committed
            disconnect(p_nodeD:syncPort, self:syncPort);
        
        } // end f_cf02Down
        
        /**
         * @desc This configuration features:
         *       - one ITS node (IUT)
         *       - one ITS node (NodeA)
         *       - one ITS node in direction of NodeA (NodeB)
         *       - one ITS node not in direction of NodeA (NodeC)       
         *       - Area1 which only includes NodeB and IUT
         *       - Area2 which only includes NodeB 
         *         NodeB being close to the area center   
berge's avatar
berge committed
        function f_cf03Up(out ItsNt p_nodeB, out ItsNt p_nodeC) runs on ItsMtc {

            // Variables
            var PositionTable v_positionTable := {};
 
            // Create
            p_nodeB := ItsNt.create(c_compNodeB) alive;
            p_nodeC := ItsNt.create(c_compNodeC) alive;

            // Map
            map(p_nodeB:geoNetworkingPort, system:geoNetworkingPort);
            map(p_nodeC:geoNetworkingPort, system:geoNetworkingPort);
            
            // Connect
            connect(p_nodeB:syncPort, self:syncPort);
            connect(p_nodeC:syncPort, self:syncPort);

            // Position table
            f_addPosition(v_positionTable, c_compIut, f_getIutLongPosVector());
            f_addPosition(v_positionTable, c_compNodeA, f_computePosition());
            f_addPosition(v_positionTable, c_compNodeB, f_computePosition());
            f_addPosition(v_positionTable, c_compNodeC, f_computePosition());
            
            p_nodeB.start(f_initialiseComponent(v_positionTable, c_compNodeB));
            p_nodeC.start(f_initialiseComponent(v_positionTable, c_compNodeC));
            p_nodeB.done;
            p_nodeC.done;
                    
        } // end f_cf03Up

        /**
         * @desc Deletes configuration cf03
         * @param p_nodeA
         * @param p_nodeB
         * @param p_nodeC
         */
berge's avatar
berge committed
        function f_cf03Down(in ItsNt p_nodeB, in ItsNt p_nodeC) runs on ItsMtc {
Loading full blame...