Skip to content
LibItsGeoNetworking_Functions.ttcn 55.2 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;
    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, v_nodeALongPosVector, v_nodeBLongPosVector, v_nodeDLongPosVector;
            map(self:acPort, system:acPort);
            map(self:utPort, system:utPort);
            map(self:geoNetworkingPort, system:geoNetworkingPort);
            
            // Connect
            f_connect4SelfOrClientSync();
            
            //Initialze the IUT
            f_initialState();
            
            //Get positions
            v_iutLongPosVector := f_getIutLongPosVector();
            v_nodeALongPosVector := f_computePosition(v_iutLongPosVector, c_compNodeA_longitudeFactor, c_compNodeA_latitudeFactor);
            v_nodeBLongPosVector := f_computePosition(v_iutLongPosVector, c_compNodeB_longitudeFactor, c_compNodeB_latitudeFactor);
            v_nodeDLongPosVector := f_computePosition(v_iutLongPosVector, c_compNodeD_longitudeFactor, c_compNodeD_latitudeFactor);
            
            // 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(self:acPort, system:acPort);
            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, v_nodeBLongPosVector, v_nodeCLongPosVector, v_nodeDLongPosVector;
            
            // Create
            p_nodeB := ItsNt.create(c_compNodeB) alive;
berge's avatar
berge committed
            p_nodeD := ItsNt.create(c_compNodeD) alive;
            map(p_nodeB:acPort, system:acPort);
            map(p_nodeD:acPort, system:acPort);
            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);
            //Initialze the IUT
            f_initialState();
            
            //Get positions
            v_iutLongPosVector := f_getIutLongPosVector();
            v_nodeBLongPosVector := f_computePosition(v_iutLongPosVector, c_compNodeB_longitudeFactor, c_compNodeB_latitudeFactor);
            v_nodeCLongPosVector := f_computePosition(v_iutLongPosVector, c_compNodeC_longitudeFactor, c_compNodeC_latitudeFactor);
            v_nodeDLongPosVector := f_computePosition(v_iutLongPosVector, c_compNodeD_longitudeFactor, c_compNodeD_latitudeFactor);
            
            // 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(p_nodeB:acPort, system:acPort);
            unmap(p_nodeD:acPort, system:acPort);
            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)
         *       - 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 := {};
            var GeoAreaTable v_areaTable := {};
            var LongPosVector v_iutLongPosVector, v_nodeALongPosVector, v_nodeBLongPosVector, v_nodeCLongPosVector, v_nodeDLongPosVector;
            // Create
            p_nodeB := ItsNt.create(c_compNodeB) alive;
            p_nodeC := ItsNt.create(c_compNodeC) alive;

Loading full blame...