LibItsIicp_Functions.ttcn3 14.5 KB
Newer Older
/**
 *  @author     ETSI / STF422_EETS
 *  @version    $URL:$
 *              $Id:$
 *  @desc       Inter-ITS-SCU communications (ISO 24102-4) functions
 */
module LibItsIicp_Functions {
    
    // LibCommon
    import from LibCommon_Sync all;
    import from LibCommon_Time {
        function f_sleepIgnoreDef
    };
    import from LibCommon_BasicTypesAndValues {
        const 
            c_uInt8Max;
    };
    import from LibCommon_Sync {
        function
            f_selfOrClientSyncAndVerdict, f_selfOrClientSyncAndVerdictPreamble
    };
    import from LibCommon_VerdictControl all;
    
    // LibIts
garciay's avatar
garciay committed
    import from CALMllsap language "ASN.1:1997" {
        type 
            Link_ID 
    };
    import from CALMmsap language "ASN.1:1997" {
        type 
            MF_Command, MN_Command, MI_Command 
    };
    import from CALMmanagement language "ASN.1:1997" {
        type 
garciay's avatar
garciay committed
            ITS_scuId, Talive
    };
    import from CALMiitsscu language "ASN.1:1997" {
        type 
            IIC_Request, 
            ITS_SCUtype 
    };
garciay's avatar
garciay committed
    import from LibItsMgt_TypesAndValues {
garciay's avatar
garciay committed
        type IParamNoList, IParamList, ErrorsList 
garciay's avatar
garciay committed
    };
    import from LibItsIicp_Templates all;
    import from LibItsIicp_Pics all;
    import from LibItsIicp_Pixits all;
reinaortega's avatar
reinaortega committed
    import from LibItsCalm_Interface {
reinaortega's avatar
reinaortega committed
            ItsMgt;
        function
		      f_utInitializeIut 
    };
    
    group iicpConfigurationFunctions {
        
        /**
         * @desc This configuration features:
         * <li>Host and Router are combined (see ISO/WD 29281-2 - Figure 1 - Implementation architecture I)</li>
         * <li>MGT1 IISC Port (IISC/LAN) is used if specified</li>
         */
        function f_cf01Up() runs on ItsMgt {
            
            // Map
            map(self:acPort, system:acPort);
            map(self:utPort, system:utPort);
            map(self:iicpPort, system:iicpPort);
            map(self:iicpPort, system:iicpPort);
            map(self:mgtMfSapPort, system:mgtMfSapPort);
            
            // Connect
            f_connect4SelfOrClientSync();
            
            // Set processing on shutdown
            activate(a_cf01Down());
            
            // Initialize the component
            f_initialiseComponent("cf01Up");

            // Initialze the IUT
            f_initialState();
            
        } // End of function f_cf01Up
        
        /**
         * @desc    Deletes configuration cf01
         */
        function f_cf01Down() runs on ItsMgt {
            
            deactivate;
            
            // Unmap
            unmap(self:acPort, system:acPort);
            unmap(self:utPort, system:utPort);
            unmap(self:mgtMfSapPort, system:mgtMfSapPort);
            
            // Disconnect
            f_disconnect4SelfOrClientSync();
            
        } // End of f_cf01Down
        
        /**
         * @desc    Behavior function for initializing component's variables and tables
         * @param   p_componentName Name of the component
         * @param   p_iicpMGM Set to true if IISC port shall be used
         */
        function f_initialiseComponent(in charstring p_componentName) runs on ItsMgt {
            
            // Initialize variables
            
            // Set defaults
            activate(a_iicpDefault()); 
            
        } // end f_initialiseComponent
        
    } // End of group iicpConfigurationFunctions
    
    group functions {
        
    } // End of group functions
    
    group iicpFunctions {
        
        /**
         * @desc    Triggers a request command event in the test system adaptation.
         * @param   p_rCmd The remote commad to trigger
         * @return  FncRetCode
         */
        function f_iicpTriggerRequest(
            in template (value) IIC_Request p_rCmd
        ) runs on ItsMgt return FncRetCode {
            var FncRetCode v_ret := e_success;
            
            
            return v_ret;
        }
        
    } // End of group iicpFunctions
    
    
    
    group iicpAltsteps {
        
//        /**
//         * @desc Trap for not processed IICP message
//         * @verdict Unchanged
//         */
//            in template (value) ITS_scuId p_sourceITS_scuId,
//            in template (value) ITS_scuId p_destinationITS_scuId,
//            in template (value) PduCounter p_pduCounter
//        ) runs on ItsMgt { 
//            [] iicpPort.receive(//mw_iicpResp(mdw_fWTupdateNotRequestReq)) {
//                mw_iicpResp(
//                    mw_iicpMnRequestReq(
//                        p_sourceITS_scuId,
//                        p_destinationITS_scuId,
//                        p_pduCounter,
//                        mdw_fWTupdateNotRequestReq))) {
//                log("*** a_iicpAwaitFWTupdateNot: INFO: IISC FWTupdateNot service primitive received ***");
        
        /**
         * @desc  Inter-ITS-SCU communications MN-rreq (see ISO/CD 24102-5) with payload MN-Request "SAMrxNot" (see ISO/CD 24102-3 & ISO/CD 24102-5)
         * @param p_sourceITS-scuId        ITS-SCU-ID of the source ITS-SCU which produces the request
         * @param p_destinationITS-scuId   ITS-SCU-ID of the destination ITS-SCU which shall evaluate the request
         * @param p_pduCounter             Even number generated fro a cyclic counter at the ITS-SCU
         * @param p_mn_rreq                The MN-REQUEST.request/SAMrxNot to be forwarded
         * @verdict Unchanged
         */
//            in template (value) ITS_scuId p_sourceITS_scuId,
//            in template (value) ITS_scuId p_destinationITS_scuId,
//            in template (value) PduCounter p_pduCounter,
//            in template (value) MN_Request_request p_mn_rreq // FIXME Replace MN_Request_request by SAMrxNot template
//        ) runs on ItsMgt {
//            [] iicpPort.receive(
//                mw_iicpResp(
//                    mw_iicpMnRequestReq(
//                        p_sourceITS_scuId,
//                        p_destinationITS_scuId,
//                        p_pduCounter,
//                        p_mn_rreq))) { // Receive MN-REQUEST.request/SAMrxNot message
//                log("*** a_iicpAwaitSAMrxNotRequestReq: INFO: Remote command service primitive received in default ***");
//        } // End of altstep a_iicpAwaitSAMrxNotRequestReq
        
        /**
         * @desc  Inter-ITS-SCU communications MN-rreq (see ISO/WD 24102-4) with payload MN-Request "CTXrxNot" (see ISO/CD 24102-3 & ISO/CD 24102-5)
         * @param p_sourceITS-scuId        ITS-SCU-ID of the source ITS-SCU which produces the request
         * @param p_destinationITS-scuId   ITS-SCU-ID of the destination ITS-SCU which shall evaluate the request
         * @param p_pduCounter             Even number generated fro a cyclic counter at the ITS-SCU
         * @param p_mn_rcmd                The MN-REQUEST.request/SAMrxNot to be forwarded
         * @verdict Unchanged
         */
//            in template (value) ITS_scuId p_sourceITS_scuId,
//            in template (value) ITS_scuId p_destinationITS_scuId,
//            in template (value) PduCounter p_pduCounter,
//            in template (value) MN_Request_request p_mn_rreq // FIXME Replace MN_Request_request by CTXrxNot template
//        ) runs on ItsMgt {
//            [] iicpPort.receive(mw_iicpResp(mw_iicpMnRequestReq(
//                    p_sourceITS_scuId,
//                    p_destinationITS_scuId,
//                    p_pduCounter,
//                    p_mn_rreq))) { // Receive MN-REQUEST.request/CTXrxNot message
//                log("*** a_iicpAwaitCTXrxNotRequestReq: INFO: Remote command service primitive received in default ***");
//        } // End of altstep a_iicpAwaitCTXrxNotRequestReq
        
        /**
         * @desc Trap for not processed IICP message.
         * @verdict Set to fail on unknown message
         */
        altstep a_iicpDefault() runs on ItsMgt {
            [] iicpPort.receive(mw_iicpRequest(mw_iicpRequest_any)) { // Receive any IIC-Request message
                log("*** a_iicpDefault: INFO: Remote IIC-Request command service primitive received in default ***");
                repeat;
            }
            [] iicpPort.receive(mw_iicpResponse(mw_iicpResponse_any)) { // Receive any IIC-Response message
                log("*** a_iicpDefault: INFO: Remote IIC-Response command service primitive received in default ***");
                repeat;
            }
                log("*** a_iicpDefault: ERROR: event received on IISC port in default ***");
                f_selfOrClientSyncAndVerdict("error", e_error);
            }
            [] tc_wait.timeout {
                log("*** a_iicpDefault: ERROR: Timeout while awaiting reaction of the IUT prior to Upper Tester action ***");
                f_selfOrClientSyncAndVerdict("error", e_timeout);
            }
            [] tc_ac.timeout {
                log("*** a_iicpDefault: ERROR: Timeout while awaiting the reception of a message ***");
                f_selfOrClientSyncAndVerdict("error", e_timeout);
            }
            [] any timer.timeout {
                log("*** a_iicpDefault: INCONC: An unknown timer has expired in default ***"); 
                f_selfOrClientSyncAndVerdict("error", e_timeout);
            }
            [] a_shutdown() {
                f_poDefault();
                log("*** a_iicpDefault: INFO: TEST COMPONENT NOW STOPPING ITSELF! ***");
                if(self == mtc) {
                    f_cf01Down();
                }
                stop;
            }
        } // End of altstep a_iicpDefault
        
        /**
         * @desc Default handling cf01 de-initialisation.
         */
        altstep a_cf01Down() runs on ItsMgt {
            [] a_shutdown() {
                f_poDefault();
                f_cf01Down();
                log("*** a_cf01Down: INFO: TEST COMPONENT NOW STOPPING ITSELF! ***");
                stop;
            }
        } // End of altstep a_cf01Down()
        
    } // End of group iicpAltsteps
    
    group preambule {
        
        /**
         * @desc Brings the IUT into an initial state.
         */
        function f_initialState() {
            f_utInitializeIut(m_iicpInitialize);
            f_sleepIgnoreDef(PX_WAIT_FOR_IUT_READY); // Wait until the IUT is in a stable situation (beaconing...)
        } // End of function f_initialState
        
    } // End of group preambule
    
    group postambles {
        
        /**
         * @desc The default postamble.
         */
        function f_poDefault() runs on ItsMgt {
            // Nothing to do
        } // End of function f_poDefault
        
    } // End of group postambles
    
    group adapterControl {
        
    } // End of group adapterControl
    
    group testerFunctions {
        
    } // End of group testerFunctions
    
    group iutFunctions {
        
garciay's avatar
garciay committed
        /**
         * @desc Get the active VCI link identifier
         * @return The active VCI link identifier
         * @see PX_ACTIVE_VCI_LINK_ID
         */
        function f_getIutCIlinkId() return Link_ID {
            return PX_ACTIVE_VCI_LINK_ID;
        }
        
        /**
         * @desc Gets the Local/source ITS scuID 
         * @return  The Local/source ITS scuID 
         * @see PX_LOCAL_ITS_SCU_ID 
         * @see ISO/WD 24102-4 - Table 2 — ITS-SCU-ID value assignment
         */
        function f_getIutLocalITSscuId() return ITS_scuId {
            return PX_LOCAL_ITS_SCU_ID;
        }
        
        /**
garciay's avatar
garciay committed
         * @desc    Get the type of ITS-SCU in the "Data" element
         * @return  The type of ITS-SCU in the "Data" element
         * @see     PX_SRC_ITS_SCU_TYPE
         */
        function f_getIutSourceITS_scuType() return ITS_SCUtype {
            return PX_SRC_ITS_SCU_TYPE;
        }
        
        
        /**
garciay's avatar
garciay committed
         * @desc    Gets the type ITS scuID
         * @return  The type ITS scuID
         * @see PX_LOCAL_ITS_TYPE 
         * @see ISO/WD 24102-4 - Table 2 — ITS-SCU-ID value assignment
         */
        function f_getIutLocalITSType() return ITS_SCUtype {
            return PX_LOCAL_ITS_TYPE;
        }
        
garciay's avatar
garciay committed
        /**
         * @desc    Gets the Alive timer
         * @return  The Alive timer
         * @see PX_TALIVE 
         */
        function f_getIutTAlive() return Talive {
            return PX_TALIVE;
        }
        
garciay's avatar
garciay committed
        /**
         * @desc    TODO
         * @return  TODO
         * @see     PX_MI_RCMD_STATECINOTIFY
         */
        function f_getIutRCmdForMiCommand() return MI_Command {
            return PX_MI_RCMD_STATECINOTIFY;
        }
        
        /**
         * @desc    TODO
         * @return  TODO
         * @see     PX_MN_RCMD_STATECINOTIFY
         */
        function f_getIutRCmdForMnCommand() return MN_Command {
            return PX_MN_RCMD_STATECINOTIFY;
        }
        
        /**
         * @desc    TODO
         * @return  TODO
         * @see     PX_MF_RCMD_STATECINOTIFY
         */
        function f_getIutRCmdForMfCommand() return MF_Command {
            return PX_MF_RCMD_STATECINOTIFY;
        }
        
garciay's avatar
garciay committed
        /**
         * @desc    TODO
         * @return  TODO
         * @see     PX_MI_IPARAMNOLIST
         */
        function f_getIutIParamNoList() return IParamNoList {
            return PX_MI_IPARAMNOLIST;
        }
        
        /**
         * @desc    TODO
         * @return  TODO
         * @see     PX_MI_IPARAMNOLIST
         */
        function f_getIutIParamList() return IParamList {
            return PX_MI_IPARAMLIST;
        }
        
garciay's avatar
garciay committed
        /**
         * @desc    TODO
         * @return  TODO
         * @see     PX_MI_ERRORSLIST
         */
        function f_getIutErrorsList() return ErrorsList { 
            return PX_MI_ERRORSLIST;
        }
        
    } // End of group iutFunctions
    
} // End of module LibItsIicp_Functions