LibItsDcc_Functions.ttcn3 4.52 KB
Newer Older
schmitting's avatar
schmitting committed
module LibItsDccFunctions {
    
    // Libcommon
    import from LibCommon_Sync all;
    import from LibCommon_VerdictControl all;
    
    // LibIts
    import from LibItsDcc_Templates all;
    import from LibItsDcc_Pixits all;
    import from LibItsDcc_Pics all;
    import from LibItsDcc_TestSystem all; 

    group dccConfigurationFunctions {
        
        /**
         * @desc    Setups default configuration   
         */
        function f_cfUp() runs on ItsDcc {
            
            map(self:utPort, system:utPort);
            map(self:inPort, system:inPort);
            f_connect4SelfOrClientSync();
            
        } // end f_cfUp
        
        /**
         * @desc    Deletes default configuration 
         */
        function f_cfDown() runs on ItsDcc {
            
            unmap(self:utPort, system:utPort);
            unmap(self:inPort, system:inPort);
            f_disconnect4SelfOrClientSync();
            
        } // end f_cfDown
        
    } // end of dccConfigurationFunctions
    
    /**
     * @desc Upper tester functions
     */
    group utFuntions { 
        
        /**
         * @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 ItsDcc {
        
            utPort.send(p_init);
            tc_wait.start;
            alt {
                [] utPort.receive(UtResult:true) {
                    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
                    repeat; 
                }
            }
        
        }
        
        /**
         * @desc    Triggers event on the radio interface
         * @param   p_trigger The event to trigger.
         */
        function f_utTriggerEvent(template (value) UtTrigger p_trigger) runs on ItsDcc {
            
            utPort.send(p_trigger);
            alt {
                [] utPort.receive(UtResult:true) {
                    tc_wait.stop;
                    log("*** f_utTriggerEvent: INFO: Event sccessfully triggered ***");
                }
                [] utPort.receive {
                    tc_wait.stop;
                    log("*** f_utTriggerEvent: INFO: Event could not be triggered ***");
                    f_selfOrClientSyncAndVerdict("error", e_error);
                }
                [] tc_wait.timeout {
                    log("*** f_utTriggerEvent: INFO: Event could not be triggered in time ***");
                    f_selfOrClientSyncAndVerdict("error", e_timeout);
                }
                [else] { // Shortcut defaults
                    repeat; 
                }
            }
        
        }
        
        /**
         * @desc Capture the next event sent to the Upper Tester
         * @param   p_event     Receive template of the expected event
         * @param   p_result    Return the value of the received event if template matchs
         */
        function f_utCommandIndication( 
            in template UtCommandIndication p_event,
            out UtCommandIndication p_result
        ) runs on ItsDcc {
            
            tc_wait.start;
            alt {
//                        [] utPort.receive(p_event) -> value p_result {
//                            tc_wait.stop;
//                        }
                [] utPort.receive {
                    tc_wait.stop;
                    log("*** f_utCommandIndication: INFO: Another event indicated at application layer, repeating check ***");
                }
                [] tc_wait.timeout {
                    log("*** f_utCommandIndication: ERROR: Timeout while waiting for event check result ***");
                }
            } // end of 'alt' statement
        
        } // End of function f_utCommandIndication
    
    } // End of group utFunctions




    
} // End of module LibItsDcc_Functions