Skip to content
ItsCam_TpFunctions.ttcn 149 KiB
Newer Older
ASN.1 Documenter's avatar
ASN.1 Documenter committed
            } // end f_CAM_MSD_PAR_BV_03
        } // end group camLowerLayerParameters

        group camGenerationSSP {
          
            function f_CAM_MSD_SSP_BO_XX(
                            in charstring p_certName,
                            in template(value)   UtCamTrigger p_utEvent,
                            in template(present) CAM pmw_CamMsg,
            				in template(present) Bit256 pmw_ssp := ?  
            ) runs on ItsCam {
                
                // Local variables
                var Oct8 v_certHashedId8;
                
                // Test control
                if (not PICS_CAM_GENERATION) {
                    log("*** " & testcasename() & ": PICS_CAM_GENERATION required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }              
                
                if (not PICS_IS_IUT_SECURED) {
                    log("*** " & testcasename() & ": PICS_IS_IUT_SECURED required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }
                              
                // Test component configuration
                f_cfUp();
                
                // Test adapter configuration
                
                // Preamble
                // initialize IUT with given certificate
                fx_readCertificateDigest(p_certName, v_certHashedId8);
                if( '0000000000000000'O ==  v_certHashedId8) {
                    // Certificate not found
                    log("*** " & testcasename() & ": Required IUT certificate is not found on the test system ***");
                    setverdict(inconc);
                    stop;
                }

                
                f_prInitialState(
                    e_staticPosition, 
                    true, 
                    { hashedId8 := v_certHashedId8 }
                );
                    
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // execute UT Command
                f_utTriggerEvent(p_utEvent);
                
                // Test Body
                tc_ac.start;
                alt {
                    [] camPort.receive(mw_camIndWithSecurityParameters (
                      pmw_CamMsg,
                      pmw_ssp
                      )) { 
                        tc_ac.stop;
                        log("*** " & testcasename() & ": FAIL: Expected CAM message received ***");
                        f_selfOrClientSyncAndVerdict(c_tbDone, e_error);  
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": PASS: CAM message not received ***");
                        f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
                    }
                }
                
                // Postamble
                f_poDefault();
                f_cfDown();
                
            } // end f_CAM_MSD_SSP_BO_XX
                          
    
            function f_CAM_MSD_SSP_BO_01() runs on ItsCam {
                
                log("*** " & testcasename() & ": This TC is not implemented yet ***");
                setverdict(inconc);
                stop;
            
            } // end f_CAM_MSD_SSP_BO_01

            function f_CAM_MSD_SSP_BO_02() runs on ItsCam {

                if (not PICS_SPECIALVEHICLECONTAINER and not PICS_PUBLICTRANS) {
                    testcase.stop(testcasename() 
                        & ": PICS_SPECIALVEHICLECONTAINER and PICS_PUBLICTRANS need to be set to true");
                }
                
                f_CAM_MSD_SSP_BO_XX(PX_CERT_IUT_CAM_02,
                                    m_setVehicleRole(c_vehicleRole_publicTransport),
                                    mw_camMsg_SVC ( mw_publicTransport_any )
                );

            } // end f_CAM_MSD_SSP_BO_02

            function f_CAM_MSD_SSP_BO_03() runs on ItsCam {

                if (not PICS_SPECIALVEHICLECONTAINER and not PICS_SPECIALTRANS) {
                    testcase.stop(testcasename() 
                        & ": PICS_SPECIALVEHICLECONTAINER and PICS_SPECIALTRANS need to be set to true");
                }

                f_CAM_MSD_SSP_BO_XX(PX_CERT_IUT_CAM_03,
                                    m_setVehicleRole(c_vehicleRole_specialTransport),
                                    mw_camMsg_SVC ( mw_specialTransport_any )
                );
            } // end f_CAM_MSD_SSP_BO_03
        }
                    
    } // end group camSSP
      
    group camMessageProcessing {
        
        /**
         * @desc    TP Function for TC_CAM_MSP_BV_01
         */
        function f_CAM_MSP_BV_01() runs on ItsCam {
            
            // Local variables
            var CamReq v_camReq;
            var integer i;
            
            // Test control
            if (not PICS_CAM_RECEPTION) {
                log("*** " & testcasename() & ": PICS_CAM_RECEPTION required for executing the TC ***");
                setverdict(inconc);
                stop;
            }
            
            // Test component configuration
            f_cfUp();
            
            // Test adapter configuration
            
            // Preamble
            f_prInitialState();
            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
            
            // Test Body
            v_camReq := valueof(
                m_camReq(
                    m_camMsg_vehicle(
                        f_getTsStationId(),
                        f_getCurrentTime() mod 65536, // See ETSI EN 302 637-2 V1.3.0 - Clause B.3 generationDelatTime
                        m_tsPosition
                    )
                )
            );
            camPort.send( v_camReq ) ;
            
            f_sleep(PX_TNOAC);
            for(i:=0; i < lengthof(vc_utEvents) and not match(v_camReq.msgOut, vc_utEvents[i].camMsg); i:=i+1) {
                // empty on purpose 
            }
            if(i < lengthof(vc_utEvents)) {
                log("*** " & testcasename() & ": PASS: CAM was transmitted to upper layer ***");
                f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
            }
            else {
                log("*** " & testcasename() & ": FAIL: CAM was not transmitted to upper layer ***");
                f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
            }
            
            // Postamble
            f_poDefault();
            f_cfDown();
            
        } // end f_CAM_MSP_BV_01
        
        group camProcessingSSP{
            
            /**
             * @desc    TP Function for TC_CAM_MSP_SSP_BV_XX
             * @param p_certName Certificate to be used to sign the CAM message
             * @param p_camMsg   CAM value template to be sent to IUT 
             */
            function f_CAM_MSP_SSP_BV_XX(
                in charstring p_certName,
                in template (value) CAM p_camMsg
            ) runs on ItsCam {
                
                // Local variables
                var CamReq v_camReq;
                var integer i;
                
                // Test control
                if (not PICS_CAM_RECEPTION) {
                    log("*** " & testcasename() & ": PICS_CAM_RECEPTION required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }              
                
                if (not PICS_IS_IUT_SECURED) {
                    log("*** " & testcasename() & ": PICS_IS_IUT_SECURED required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cfUp(p_certName);
                
                // Preamble
                f_prInitialState();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_camReq := valueof(
                                m_camReq(
                                    p_camMsg
                                )
                            );
                camPort.send( v_camReq ) ;
                
                f_sleep(PX_TNOAC);
                for(i:=0; i < lengthof(vc_utEvents) and not match(v_camReq.msgOut, vc_utEvents[i].camMsg); i:=i+1) {
                    // empty on purpose 
                }
                if(i < lengthof(vc_utEvents)) {
                    log("*** " & testcasename() & ": FAIL: CAM was not transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
                }
                else {
                    log("*** " & testcasename() & ": PASS: CAM was transmitted to upper layer ***");
                    f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
                }
                
                // Postamble
                f_poDefault();
                f_cfDown();
                
            } // end f_CAM_MSP_SSP_BV_XX
    
            function f_CAM_MSP_SSP_BV_01() runs on ItsCam {
                
                log("*** " & testcasename() & ": This TC is not implemented yet ***");
                setverdict(inconc);
                stop;
            } // end f_CAM_MSP_SSP_BV_01
    
            function f_CAM_MSP_SSP_BV_02() runs on ItsCam {
    
                f_CAM_MSP_SSP_BV_XX("CERT_TS_CAM_BO_02_AT",
                                m_camMsg_publicTransport(
                                    f_getTsStationId(),
                                    f_getCurrentTime() mod 65536, // See ETSI EN 302 637-2 V1.3.0 - Clause B.3 generationDelatTime
                                    m_tsPosition
                                )
                );
            } // end f_CAM_MSP_SSP_BV_03
            
            function f_CAM_MSP_SSP_BV_03() runs on ItsCam {
    
                f_CAM_MSP_SSP_BV_XX("CERT_TS_CAM_BO_03_AT",
                                m_camMsg_specialTransport(
                                    f_getTsStationId(),
                                    f_getCurrentTime() mod 65536, // See ETSI EN 302 637-2 V1.3.0 - Clause B.3 generationDelatTime
                                    m_tsPosition
                                )
                );
            } // end f_CAM_MSP_SSP_BV_03
        }// end group camProcessingSSP
    } // end group camMessageProcessing
    
} // end ItsCam_TpFunctions