/**
*    @author   ETSI / TTF033
*    @version  $URL$
*              $Id$
*    @desc     This module provides test configuration description for NGAP 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 NGAP_TestConfiguration {

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

    // NGAP_Ats
    import from NGAP_TestSystem all;
    //  LibNGAP
    import from LibNGAP_Interface 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_NGAP_gNB - AMF is SUT
         * @param p_NGAPComponent_gnb
         */
        function f_cf_NGAP_gNB_Up(
                                  out gNBNGAPComponent p_NGAPComponent_gnb
        ) runs on gNBNGAPComponent system TestAdapter {
            //Variables
            var FncRetCode v_ret := e_success;

            //Create
            p_NGAPComponent_gnb := gNBNGAPComponent.create ;

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

            activate(a_mtc_shutdown());

            f_setVerdict(v_ret);
        } // End of function f_cf_NGAP_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_Down() runs on NGAPComponent system TestAdapter {
            // Deactivate all
            deactivate;
            // Unmap all
            //unmap;
            // Disconnect all
            //disconnect;

        } // End of function f_cf_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 NGAP_TestConfiguration
