Skip to content
LibItsGeoNetworking_Functions.ttcn 51.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 all;
berge's avatar
berge committed
    // LibIts
    import from LibIts_TestSystem all;
    import from LibIts_Interface all; 
fischer's avatar
fischer committed
    import from LibItsCommon_Functions all;
berge's avatar
berge committed
    import from LibItsGeoNetworking_TypesAndValues all;
berge's avatar
berge committed
    import from LibItsGeoNetworking_Templates all;
fischer's avatar
fischer committed
    import from LibItsGeoNetworking_Pixits all;
    import from LibItsGeoNetworking_Pics 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 {
                f_selfOrClientSyncAndVerdict("error", e_timeout, "*** f_ptcGeoNetworkingDown: Timeout while waiting for component ***");
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 := {};
            var GeoAreaTable v_areaTable := {};
            var LongPosVector v_iutLongPosVector := f_getIutLongPosVector();
            var LongPosVector v_nodeALongPosVector := f_computePosition(v_iutLongPosVector, c_compNodeA_longitudeFactor, c_compNodeA_latitudeFactor);
            var LongPosVector v_nodeBLongPosVector := f_computePosition(v_iutLongPosVector, c_compNodeB_longitudeFactor, c_compNodeB_latitudeFactor);
            var LongPosVector v_nodeDLongPosVector := f_computePosition(v_iutLongPosVector, c_compNodeD_longitudeFactor, c_compNodeD_latitudeFactor);
            
            map(self:utPort, system:utPort);
            map(self:geoNetworkingPort, system:geoNetworkingPort);
            
            // Connect
            f_connect4SelfOrClientSync();
            
            // Propagate GN addresses
            v_nodeALongPosVector.gnAddr := f_getTsGnLocalAddress(c_compNodeA);
            v_nodeBLongPosVector.gnAddr := f_getTsGnLocalAddress(c_compNodeB);
            
            // Position table            
            f_addPosition(v_positionTable, c_compIut, v_iutLongPosVector);
            f_addPosition(v_positionTable, c_compNodeA, v_nodeALongPosVector);
            f_addPosition(v_positionTable, c_compNodeB, v_nodeBLongPosVector);
            // Area table
            f_addArea(v_areaTable, c_area1, 
                f_computeSquareArea(v_nodeDLongPosVector, float2int(1.1 * f_distance(v_nodeBLongPosVector, v_nodeDLongPosVector))));
            f_addArea(v_areaTable, c_area2, 
                f_computeSquareArea(v_nodeBLongPosVector, float2int(1.1 * f_distance(v_nodeBLongPosVector, v_nodeDLongPosVector))));
        
            f_initialiseComponent(v_positionTable, v_areaTable, c_compNodeB);
            
        } // end f_cf01Up

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

            // Unmap
            unmap(self:utPort, system:utPort);
            unmap(self:geoNetworkingPort, system:geoNetworkingPort);
            
            // Disconnect
            f_disconnect4SelfOrClientSync();
            
        } // 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 := {};
            var GeoAreaTable v_areaTable := {};
            var LongPosVector v_iutLongPosVector := f_getIutLongPosVector();            
            var LongPosVector v_nodeBLongPosVector := f_computePosition(v_iutLongPosVector, c_compNodeB_longitudeFactor, c_compNodeB_latitudeFactor);
            var LongPosVector v_nodeCLongPosVector := f_computePosition(v_iutLongPosVector, c_compNodeC_longitudeFactor, c_compNodeC_latitudeFactor);
            var LongPosVector v_nodeDLongPosVector := f_computePosition(v_iutLongPosVector, c_compNodeD_longitudeFactor, c_compNodeD_latitudeFactor);
            
            // Create
            p_nodeB := ItsNt.create(c_compNodeB) alive;
berge's avatar
berge committed
            p_nodeD := ItsNt.create(c_compNodeD) alive;
            map(p_nodeB:utPort, system:utPort);
            map(p_nodeD:utPort, system:utPort);
            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);
            // Propagate GN addresses
            v_nodeBLongPosVector.gnAddr := f_getTsGnLocalAddress(c_compNodeB);
            v_nodeCLongPosVector.gnAddr := f_getTsGnLocalAddress(c_compNodeC);
            v_nodeDLongPosVector.gnAddr := f_getTsGnLocalAddress(c_compNodeD);
            
            // Position table
            f_addPosition(v_positionTable, c_compIut, v_iutLongPosVector);
            f_addPosition(v_positionTable, c_compNodeB, v_nodeBLongPosVector);
            f_addPosition(v_positionTable, c_compNodeD, v_nodeDLongPosVector);

            // Area table
            f_addArea(v_areaTable, c_area1, 
                f_computeSquareArea(v_nodeDLongPosVector, float2int(1.1 * f_distance(v_nodeBLongPosVector, v_nodeDLongPosVector))));
            f_addArea(v_areaTable, c_area2, 
                f_computeSquareArea(v_nodeBLongPosVector, float2int(1.1 * f_distance(v_nodeBLongPosVector, v_nodeDLongPosVector))));
            
            p_nodeB.start(f_initialiseComponent(v_positionTable, v_areaTable, c_compNodeB));
            p_nodeD.start(f_initialiseComponent(v_positionTable, v_areaTable, c_compNodeD));
berge's avatar
berge committed
            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 {
            // Unmap
            unmap(p_nodeB:utPort, system:utPort);
            unmap(p_nodeD:utPort, system:utPort);
            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)
Loading full blame...