Skip to content
LibItsIicp_Functions.ttcn3 13 KiB
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, 
            MF_Request, MN_Request, MI_Request, 
            MF_Request_confirm 
garciay's avatar
garciay committed
    };
    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, IIC_Response, 
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;
            
        /**
         * @desc    Triggers a response command event in the test system adaptation.
         * @param   p_rCmd The remote commad to trigger
         * @return  FncRetCode
         */
        function f_iicpTriggerResponse(
            in template (value) IIC_Response p_rCmd
        ) runs on ItsMgt return FncRetCode {
            var FncRetCode v_ret := e_success;
            
            iicpPort.send(m_iicpResp(p_rCmd));
            
            return v_ret;
        }
        
    } // End of group iicpFunctions
    
    
    
    group iicpAltsteps {
        
        /**
         * @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 {
garciay's avatar
garciay committed
            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    Get the MI-Command value used for remote command
         * @return  The MI-Command value used for remote command
garciay's avatar
garciay committed
         * @see     PX_MI_RCMD_STATECINOTIFY
         */
        function f_getIutRCmdForMiCommand() return MI_Command {
            return PX_MI_RCMD_STATECINOTIFY;
        }
        
        /**
         * @desc    Get the MI-Request value used for remote command
         * @return  The MI-Request value used for remote command
         * @see     PX_MI_RCMD_REGTYPE
         */
        function f_getIutRCmdForMiRequest() return MI_Request {
            return PX_MI_RCMD_REGTYPE;
        }
        
        /**
         * @desc    Get the MM-Command value used for remote command
         * @return  The MM-Command value used for remote command
garciay's avatar
garciay committed
         * @see     PX_MN_RCMD_STATECINOTIFY
         */
        function f_getIutRCmdForMnCommand() return MN_Command {
            return PX_MN_RCMD_STATECINOTIFY;
        }
        
        /**
         * @desc    Get the MM-Request value used for remote command
         * @return  The MN-Request value used for remote command
         * @see     PX_MN_RCMD_FWYSETNOTIFY
         */
        function f_getIutRCmdForMnRequest() return MN_Request {
            return PX_MN_RCMD_FWYSETNOTIFY;
        }
        
        /**
         * @desc    Get the MF-Command value used for remote command
         * @return  The MF-Command value used for remote command
garciay's avatar
garciay committed
         * @see     PX_MF_RCMD_STATECINOTIFY
         */
        function f_getIutRCmdForMfCommand() return MF_Command {
            return PX_MF_RCMD_STATECINOTIFY;
        }
        
garciay's avatar
garciay committed
        /**
         * @desc    Get the MF-Request value used for remote command
         * @return  The MF-Request value used for remote command
         * @see     PX_MF_RCMD_LDM_REGISTER
         */
        function f_getIutRCmdForMfRequest() return MF_Request {
            return PX_MF_RCMD_LDM_REGISTER;
        }
        
        /**
         * @desc    Get the List of reference number of parameter to be monitored
         * @return  The List of reference number of parameter to be monitored
garciay's avatar
garciay committed
         * @see     PX_MI_IPARAMNOLIST
         */
        function f_getIutIParamNoList() return IParamNoList {
            return PX_MI_IPARAMNOLIST;
        }
        
        /**
         * @desc    Get the list of error status for each parameter to be monitored
         * @return  The list of error status for each parameter to be monitored
garciay's avatar
garciay committed
         * @see     PX_MI_IPARAMNOLIST
         */
        function f_getIutIParamList() return IParamList {
            return PX_MI_IPARAMLIST;
        }
        
garciay's avatar
garciay committed
        /**
         * @desc    Get the list of error status for each parameter to be monitored
         * @return  The list of error status for each parameter to be monitored
garciay's avatar
garciay committed
         * @see     PX_MI_ERRORSLIST
         */
        function f_getIutErrorsList() return ErrorsList { 
            return PX_MI_ERRORSLIST;
        }
        
        /**
         * @desc    Get a IIC-Response value
         * @return  The IIC-Response value
         * @see     PX_IIC_RESPONSE
         */
        function f_getIutIicResponse() return MF_Request_confirm { 
            return PX_IIC_RESPONSE;
        }
        
    } // End of group iutFunctions
    
} // End of module LibItsIicp_Functions