Skip to content
LibItsGeoNetworking_Functions.ttcn 89 KiB
Newer Older
berge's avatar
berge committed
/**
 *  @author     ETSI / STF405 / STF449
berge's avatar
berge committed
 *  @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_DataStrings all;
    import from LibCommon_VerdictControl {type FncRetCode;}
    import from LibCommon_Sync all;
berge's avatar
berge committed
    import from LibCommon_Time all;
berge's avatar
berge committed
    // LibIts
fischer's avatar
fischer committed
    import from LibItsCommon_Functions all;
reinaortega's avatar
reinaortega committed
    import from LibItsCommon_TestSystem all;
tepelmann's avatar
tepelmann committed
    import from LibItsCommon_TypesAndValues all;
reinaortega's avatar
reinaortega committed
    import from LibItsGeoNetworking_Functions all;
    import from LibItsGeoNetworking_TestSystem 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;
    import from LibItsExternal_TypesAndValues {type MacAddress};
tepelmann's avatar
tepelmann committed
    
tepelmann's avatar
tepelmann committed
    group utFuntions {
tepelmann's avatar
tepelmann committed
        
reinaortega's avatar
reinaortega committed
        /**
         * @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 ItsBaseGeoNetworking {
tepelmann's avatar
tepelmann committed
            
reinaortega's avatar
reinaortega committed
            utPort.send(p_init);
            tc_wait.start;
            alt {
wattelet's avatar
wattelet committed
                [] utPort.receive(UtInitializeResult:true) {
reinaortega's avatar
reinaortega committed
                    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
tepelmann's avatar
tepelmann committed
                    repeat;
reinaortega's avatar
reinaortega committed
                }
            }
tepelmann's avatar
tepelmann committed
        
tepelmann's avatar
tepelmann committed
         * @desc    Requests to change the position of the IUT
         */
        function f_utChangePosition() runs on ItsBaseGeoNetworking {
tepelmann's avatar
tepelmann committed
            
            utPort.send(m_changePosition);
            tc_wait.start;
            alt {
wattelet's avatar
wattelet committed
                [] utPort.receive(UtChangePositionResult:true) {
                    tc_wait.stop;
wattelet's avatar
wattelet committed
                    log("*** f_utChangePosition: INFO: IUT position changed ***");
                }
                [] utPort.receive {
                    tc_wait.stop;
wattelet's avatar
wattelet committed
                    log("*** f_utChangePosition: INFO: IUT position not changed ***");
                    f_selfOrClientSyncAndVerdict("error", e_error);
                }
                [] tc_wait.timeout {
wattelet's avatar
wattelet committed
                    log("*** f_utChangePosition: INFO: IUT position not changed in time ***");
                    f_selfOrClientSyncAndVerdict("error", e_timeout);
                }
                [else] { // Shortcut defaults
tepelmann's avatar
tepelmann committed
                    repeat;
reinaortega's avatar
reinaortega committed
        }
        
        /**
         * @desc    Triggers event from the application layer
         * @param   p_event The event to trigger.
         */
        function f_utTriggerEvent(template (value) UtGnTrigger p_event) runs on ItsGeoNetworking return boolean {
reinaortega's avatar
reinaortega committed
            
            // Variables
            var boolean v_return := true;

            utPort.send(p_event);
            tc_wait.start;
reinaortega's avatar
reinaortega committed
            alt {
wattelet's avatar
wattelet committed
                [] utPort.receive(UtGnTriggerResult:true) {
reinaortega's avatar
reinaortega committed
                    tc_wait.stop;
                }
                [] utPort.receive {
                    tc_wait.stop;
                }
                [] tc_wait.timeout {
tepelmann's avatar
tepelmann committed
                    v_return := false;
reinaortega's avatar
reinaortega committed
                }
                [else] { // Shortcut defaults
tepelmann's avatar
tepelmann committed
                    repeat;
reinaortega's avatar
reinaortega committed
                }
            }
            return v_return;
reinaortega's avatar
reinaortega committed
        }
        
    } // End of group utFunctions
    group geoConfigurationFunctions {
        
        /**
         * @desc This configuration features:
         *       - one ITS node (IUT)
         *       - two ITS nodes (nodeA, nodeB)
         *       - Area1 which only includes NodeB and IUT
tepelmann's avatar
tepelmann committed
         *       - Area2 which only includes NodeB
tepelmann's avatar
tepelmann committed
         *         NodeB being close to the area center
reinaortega's avatar
reinaortega committed
        function f_cf01Up() runs on ItsGeoNetworking {
            // Variables
            var PositionTable v_positionTable := {};
            var GeoAreaTable v_areaTable := {};
            
            map(self:acPort, system:acPort);
            map(self:utPort, system:utPort);
            map(self:geoNetworkingPort, system:geoNetworkingPort);
            // Connect
            f_connect4SelfOrClientSync();
tepelmann's avatar
tepelmann committed
            activate(a_cf01Down());
            //Initialze the IUT
            f_initialState();
            
            // Positions & Areas
            f_preparePositionsAndAreas(v_positionTable, v_areaTable);
            f_initialiseComponent(v_positionTable, v_areaTable, c_compNodeB);
        } // end f_cf01Up
berge's avatar
berge committed
        /**
         * @desc Deletes configuration cf01
reinaortega's avatar
reinaortega committed
        function f_cf01Down() runs on ItsGeoNetworking {
            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
tepelmann's avatar
tepelmann committed
         *       - Area2 which only includes NodeB and NodeD
         *         NodeB being close to the area center
         *
         * @param p_mainUtComponent Name of the component that will initialize IUT and handle default UT messages
        function f_cf02Up(in charstring p_mainUtComponent := c_compMTC) runs on ItsMtc {
            
            // Variables
            var PositionTable v_positionTable := {};
tepelmann's avatar
tepelmann committed
            var GeoAreaTable v_areaTable := {};
            var ItsGeoNetworking v_component;
            var integer i;
            // Select components
            vc_componentTable := {{c_compNodeB, omit}, {c_compNodeD, omit}};
            // Create components
            for(i:=0; i < lengthof(vc_componentTable); i:=i+1) {
                vc_componentTable[i].gnComponent := ItsGeoNetworking.create(vc_componentTable[i].componentName) alive;
            }
            
            // Map & Connect
berge's avatar
berge committed
            map(self:acPort, system:acPort);
tepelmann's avatar
tepelmann committed
            map(self:utPort, system:utPort);
tepelmann's avatar
tepelmann committed
            connect(self:syncPort, mtc:syncPort);
            for(i:=0; i < lengthof(vc_componentTable); i:=i+1) {
                map(vc_componentTable[i].gnComponent:acPort, system:acPort);
                map(vc_componentTable[i].gnComponent:utPort, system:utPort);
                map(vc_componentTable[i].gnComponent:geoNetworkingPort, system:geoNetworkingPort);
Loading full blame...