/**
*    @author   ETSI / TTF041
*    @version  $URL$
*              $Id$
*    @desc     This module provides test configuration description for NG_NAS tests.
*    @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.
*    @see      ETSI TS 
*/

module NG_NAS_TestConfiguration{

    // LibCommon
    import from LibCommon_Sync all;
    import from LibCommon_VerdictControl all;

    // NG_NAS_Ats
    import from NG_NAS_TestSystem all;
    // Lib_NG_NAS
    import from Lib_NG_NAS_Interface all;

    //NGAP
    import from NGAP_TestSystem all;


    group cfUp {

        /**
         * @desc Creates test configuration of cf_NGAP_AMF - gNB is SUT
         * @param p_NGAPComponent_mme
         */
        /*function f_cf_NGAP_aMF_Up(
                                 out aMFNGAPComponent p_NGAPComponent_amf
        ) runs on aMFNGAPComponent system TestAdapter {
            //Variables
            var FncRetCode v_ret := e_success;

            //Create
            p_NGAPComponent_amf := aMFNGAPComponent.create ;

            // Connect mtc sync port
            connect(self:syncPort, self:syncPort);
            // Connect client sync port
            connect(p_NGAPComponent_amf:syncPort, self:syncPort) ;
            //Map
            map(p_NGAPComponent_amf:N2_gNBaMF_P, system:NGAP_AMF);

            activate(a_mtc_shutdown());

            f_setVerdict(v_ret);
        } // End of function f_cf_NGAP_AMF_Up*/

        /**
         * @desc Creates test configuration of cf_NGNAS_gNB - AMF is SUT
         * @param p_NGNAS_Component_gnb
         */
        function f_cf_NGNAS_gNB_Up(
                                   out gNB_NGNAS_NGAPComponent p_NGNAS_Component_gnb
                                   ) runs on gNB_NGNAS_NGAPComponent system TestAdapter {
            //Variables
            var FncRetCode v_ret := e_success;

            //Create
            p_NGNAS_Component_gnb := gNB_NGNAS_NGAPComponent.create ;

            // Connect mtc sync port
            connect(self:syncPort, self:syncPort);
            // Connect client sync port
            connect(p_NGNAS_Component_gnb:syncPort, self:syncPort) ;
            //Map
            map(p_NGNAS_Component_gnb:N2_gNBaMF_P, system:NGAP_gNB_1);

            activate(a_mtc_shutdown());

            f_setVerdict(v_ret);
        } // End of function f_cf_NG_NAS_gNB_Up

        /**
         * @desc Creates test configuration of cf_NGAP_2gNB - AMF is SUT
         * @param p_NGAPComponent_enb1, p_NGAPComponent_gnb2
         */
        /*function f_cf_NGAP_2gNB_Up(
                                   out gNBNGAPComponent p_NGAPComponent_gnb1,
                                   out gNBNGAPComponent p_NGAPComponent_gnb2
        ) runs on gNBNGAPComponent system TestAdapter {
            //Variables
            var FncRetCode v_ret := e_success;

            //Create
            p_NGAPComponent_gnb1 := gNBNGAPComponent.create;
            p_NGAPComponent_gnb2 := gNBNGAPComponent.create;

            // Connect mtc sync port
            connect(self:syncPort, self:syncPort);
            // Connect client sync port
            connect(p_NGAPComponent_gnb1:syncPort, self:syncPort);
            connect(p_NGAPComponent_gnb2:syncPort, self:syncPort) ;

            //Map
            map(p_NGAPComponent_gnb1:N2_gNBaMF_P, system:NGAP_gNB_1);
            map(p_NGAPComponent_gnb2:N2_gNBaMF_P, system:NGAP_gNB_2);

            activate(a_mtc_shutdown());

            f_setVerdict(v_ret);
        } // End of function f_cf_NGAP_2gNB_Up*/

    } // End of group cfUp

    group cfDown {

        /**
         * @desc Deletes configuration
         * @param 
         */
        function f_cf_NGNAS_gNB_Down(
                                     inout gNB_NGNAS_NGAPComponent p_NGNAS_Component_gnb
                                     ) runs on gNB_NGNAS_NGAPComponent system TestAdapter {
            // Unmap all
            unmap(p_NGNAS_Component_gnb:N2_gNBaMF_P, system:NGAP_gNB_1);
            // Disconnect all
            disconnect(self:syncPort, self:syncPort);
            disconnect(p_NGNAS_Component_gnb:syncPort, self:syncPort) ;
            // Deactivate all
            deactivate;
        } // End of function f_cf_NGNAS_gNB_Down

    } // End of group cfDown

    group shutDownAltsteps {

        altstep a_mtc_shutdown() 
        runs on SelfSyncComp {
            [] syncSendPort.receive(m_syncServerStop) {
                tc_sync.stop ;
                log("**** a_mtc_shutdown: MTC component received STOP signal **** ");
            }
        } // End of altstep a_mtc_shutdown

    } // End of group shutDownAltsteps

} // End of module NG_NAS_TestConfiguration
