Skip to content
LibItsGeoNetworking_Functions.ttcn 118 KiB
Newer Older
berge's avatar
berge committed
/**
filatov's avatar
filatov committed
 *  @author     ETSI / STF405 / STF449 / STF484 / STF517 / STF525
berge's avatar
berge committed
 *  @version    $URL$
 *              $Id$
 *  @desc       Module containing functions for GeoNetworking
garciay's avatar
garciay committed
 *  @copyright   ETSI Copyright Notification
 *               No part may be reproduced except as authorized by written permission.
 *               The copyright and the foregoing restriction extend to reproduction in all media.
 *               All rights reserved.
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;
garciay's avatar
garciay committed
    // LibItsCommon
    import from LibItsCommon_TypesAndValues all;
    import from LibItsExternal_TypesAndValues all;
    import from LibItsCommon_Templates all;
fischer's avatar
fischer committed
    import from LibItsCommon_Functions all;
    import from LibItsCommon_Pixits all;
reinaortega's avatar
reinaortega committed
    import from LibItsCommon_TestSystem all;
garciay's avatar
garciay committed
    
    // LibItsSecurity
    import from LibItsSecurity_TypesAndValues all;
    import from LibItsSecurity_Templates all;
    import from LibItsSecurity_Functions all;
    import from LibItsSecurity_Pixits all;
garciay's avatar
garciay committed
    
    // LibItsGeoNetworking
reinaortega's avatar
reinaortega committed
    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 LibItsGeoNetworking_EncdecDeclarations all;
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
            
garciay's avatar
garciay committed
            //deactivate gnPort default alts
            vc_gnDefaultActive := false;
            
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);
                }
            }
garciay's avatar
garciay committed
            
            //activate gnPort default alts
            vc_gnDefaultActive := true;
            
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 {
garciay's avatar
garciay committed
            //deactivate gnPort default alts
            vc_gnDefaultActive := false;
            
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(UtChangePositionResult:false) {
                    tc_wait.stop;
                    log("*** f_utChangePosition: INFO: IUT position change was not successful ***");
                    f_selfOrClientSyncAndVerdict("error", e_error);
                }
                [] a_utDefault() {
                }
                [] tc_wait.timeout {
wattelet's avatar
wattelet committed
                    log("*** f_utChangePosition: INFO: IUT position not changed in time ***");
                    f_selfOrClientSyncAndVerdict("error", e_timeout);
                }
            }
garciay's avatar
garciay committed
            
            //activate gnPort default alts
            vc_gnDefaultActive := true;
            
reinaortega's avatar
reinaortega committed
        }
        
        /**
         * @desc    Triggers event from the application layer
         * @param   p_event The event to trigger.
         */
garciay's avatar
garciay committed
        function f_utTriggerEvent(template (value) UtGnTrigger p_event) runs on ItsBaseGeoNetworking return boolean {
reinaortega's avatar
reinaortega committed
            
            // Variables
            var boolean v_return := true;

garciay's avatar
garciay committed
            //deactivate gnPort default alts
            vc_gnDefaultActive := false;
            
            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(UtGnTriggerResult:false) {
                    tc_wait.stop;
                    log("*** UtGnTriggerResult: INFO: UT trigger was not successful ***");
                    f_selfOrClientSyncAndVerdict("error", e_error);
reinaortega's avatar
reinaortega committed
                }
                [] a_utDefault() {
                }
                [] tc_wait.timeout {
                    v_return := false;
                }
reinaortega's avatar
reinaortega committed
            }
garciay's avatar
garciay committed
            
            //activate gnPort default alts
            vc_gnDefaultActive := true;
            
            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
filatov's avatar
filatov committed
//FIXME RGY Titan doesn't support mtc and system clauses yet
        function f_cf01Up(Scenario p_scenario := e_staticPosition) runs on ItsGeoNetworking /* TITAN TODO: system ItsGeoNetworkingSystem */ {
            // 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());
            // Initialise secured mode
            f_initialiseSecuredMode();
            
            f_initialState(p_scenario);
            // Positions & Areas
            f_preparePositionsAndAreas(v_positionTable, v_areaTable);
            f_initialiseComponent(v_positionTable, v_areaTable, c_compNodeB);
        } // end f_cf01Up
filatov's avatar
filatov committed
//FIXME RGY Titan doesn't support mtc and system clauses yet
        function f_cf01Down() runs on ItsGeoNetworking /* TITAN TODO: system ItsGeoNetworkingSystem */ {
            f_uninitialiseSecuredMode();
            
            unmap(self:acPort, system:acPort);
            unmap(self:utPort, system:utPort);
            unmap(self:geoNetworkingPort, system:geoNetworkingPort);
            
            // Disconnect
            f_disconnect4SelfOrClientSync();
            
        } // end f_cf01Down
Loading full blame...