ItsCam_TpFunctions.ttcn 148 KB
Newer Older
garciay's avatar
garciay committed
                }
                
                // Test component configuration
                f_cfUp();
                
                // Test adapter configuration
                
                // Preamble
                f_prInitialState();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Set vehicle role
                f_utTriggerEvent(m_setVehicleRole(c_vehicleRole_roadWork));
                
                // Test Body
                tc_ac.start;
                alt {
                    [] camPort.receive(mw_camInd ( mw_camMsg_SVC( mw_roadWorks_any ))){ 
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: Expected CAM message received ***");
                        f_selfOrClientSyncAndVerdict(c_tbDone, e_success);  
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: CAM message not received ***");
                        f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
                    }
                }
                
                // Postamble
                f_poDefault();
                f_cfDown();
                
            } // end f_CAM_MSD_INA_BV_05
            
            /**
             * @desc    TP Function for TC_CAM_MSD_INA_BV_06
             */
            function f_CAM_MSD_INA_BV_06() runs on ItsCam {
                
                // Local variables
                
                // Test control
                if (not PICS_CAM_GENERATION or PICS_RSU) {
                    log("*** " & testcasename() & ": PICS_CAM_GENERATION and not PICS_RSU required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }              
                if (not PICS_RESCUE) {
                    testcase.stop(testcasename() & ": PICS_RESCUE need to be set to true");
                }
                
                // Test component configuration
                f_cfUp();
                
                // Test adapter configuration
                
                // Preamble
                f_prInitialState();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Set vehicle role
                f_utTriggerEvent(m_setVehicleRole(c_vehicleRole_rescue));
                
                // Test Body
                tc_ac.start;
                alt {
                    [] camPort.receive(mw_camInd ( mw_camMsg_SVC( mw_rescue_any ))){ 
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: Expected CAM message received ***");
                        f_selfOrClientSyncAndVerdict(c_tbDone, e_success);  
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: CAM message not received ***");
                        f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
                    }
                }
                
                // Postamble
                f_poDefault();
                f_cfDown();
                
            } // end f_CAM_MSD_INA_BV_06
            
            /**
             * @desc    TP Function for TC_CAM_MSD_INA_BV_07
             */
            function f_CAM_MSD_INA_BV_07() runs on ItsCam {
                
                // Local variables
                
                // Test control
                if (not PICS_CAM_GENERATION or PICS_RSU) {
                    log("*** " & testcasename() & ": PICS_CAM_GENERATION and not PICS_RSU required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }              
                if (not PICS_EMERGENCY) {
                    testcase.stop(testcasename() & ": PICS_EMERGENCY need to be set to true");
                }
                
                // Test component configuration
                f_cfUp();
                
                // Test adapter configuration
                
                // Preamble
                f_prInitialState();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Set vehicle role
                f_utTriggerEvent(m_setVehicleRole(c_vehicleRole_emergency));
                
                // Test Body
                tc_ac.start;
                alt {
                    [] camPort.receive(mw_camInd ( mw_camMsg_SVC( mw_emergency_any ))){ 
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: Expected CAM message received ***");
                        f_selfOrClientSyncAndVerdict(c_tbDone, e_success);  
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: CAM message not received ***");
                        f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
                    }
                }
                
                // Postamble
                f_poDefault();
                f_cfDown();
                
            } // end f_CAM_MSD_INA_BV_07
            
            /**
             * @desc    TP Function for TC_CAM_MSD_INA_BV_08
             */
            function f_CAM_MSD_INA_BV_08() runs on ItsCam {
                
                // Local variables
                
                // Test control
                if (not PICS_CAM_GENERATION or PICS_RSU) {
                    log("*** " & testcasename() & ": PICS_CAM_GENERATION and not PICS_RSU required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }              
                if (not PICS_SAFETY_CAR) {
                    testcase.stop(testcasename() & ": PICS_SAFETY_CAR need to be set to true");
                }
                
                // Test component configuration
                f_cfUp();
                
                // Test adapter configuration
                
                // Preamble
                f_prInitialState();
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Set vehicle role
                f_utTriggerEvent(m_setVehicleRole(c_vehicleRole_safetyCar));
                
                // Test Body
                tc_ac.start;
                alt {
                    [] camPort.receive(mw_camInd ( mw_camMsg_SVC( mw_safetyCar_any ))){ 
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: Expected CAM message received ***");
                        f_selfOrClientSyncAndVerdict(c_tbDone, e_success);  
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: CAM message not received ***");
                        f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
                    }
                }
                
                // Postamble
                f_poDefault();
                f_cfDown();
                
            } // end f_CAM_MSD_INA_BV_08
            
        } // end group camInformationAdaptation
        
        group camGenerationFrequency {
            
            group CAM_MSD_GFQ_TI_01 {
                
                /**
                 * @desc    TP Function for TC_CAM_MSD_GFQ_TI_01
                 */
                function f_CAM_MSD_GFQ_TI_01() runs on ItsCam {
                    
                    // Local variables
                    timer t_minTransInterval := PICS_T_GENCAMMIN * 0.90;
                    var SpeedValue v_speedValues[5] := { 1000, 2000, 3000, 4000, 5000 } //cm/s
                    var integer v_cntSpeed, v_cntTime;
                    var FncRetCode v_ret;
                    
                    // Test control
                    if (not PICS_CAM_GENERATION or PICS_RSU or (PICS_RADIO_COMM == e_lte_cv2x)) {
                        log("*** " & testcasename() & ": PICS_CAM_GENERATION and not PICS_RSU and PICS_RADIO_COMM ITS-G5 required for executing the TC ***");
garciay's avatar
garciay committed
                        setverdict(inconc);
                        stop;
                    }
                    
                    // Test component configuration
                    f_cfUp();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    f_prInitialState(e_dynamicPosition1500m);
                    camPort.clear;
                    tc_ac.start;
                    alt {
                        [] camPort.receive(mw_camInd ( mw_camMsg_any )){ 
                            tc_ac.stop;
                            t_minTransInterval.start;
                            log("*** " & testcasename() & ": INFO: Initial conditions: First CAM message received ***");
                            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                        }
                        [] tc_ac.timeout {
                            log("*** " & testcasename() & ": INCONC: Initial conditions: CAM message not received ***");
                            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_timeout);
                        }
                    }
                    
                    // Test Body
                    for (v_cntSpeed:=0; v_cntSpeed<lengthof(v_speedValues); v_cntSpeed:=v_cntSpeed + 1) {
                        for (v_cntTime:=0; v_cntTime<10; v_cntTime:=v_cntTime + 1) {
                            v_ret := f_CAM_MSD_GFQ_TI_01_helper(t_minTransInterval);
                            select (v_ret) {
                                case (e_error) {
                                    log("*** " & testcasename() & ": FAIL: CAM message received BEFORE expiry of the minimum generation timer interval ***");
                                    f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
                                }
                                case (e_timeout) {
                                    log("*** " & testcasename() & ": INCONC: CAM message not received ***");
                                    f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
                                }
                            }
                            t_minTransInterval.start;
                        }
                        f_changeSpeed(v_speedValues[v_cntSpeed]);
                    }
                    t_minTransInterval.stop;
                    log("*** " & testcasename() & ": PASS: Generation of CAM messages was successful ***");
                    f_selfOrClientSyncAndVerdict(c_tbDone, e_success);  
                    
                    // Postamble
                    f_poDefault();
                    f_cfDown();
                    
                } // end f_CAM_MSD_GFQ_TI_01
                
                function f_CAM_MSD_GFQ_TI_01_helper(timer t_minTransInterval) runs on ItsCam return FncRetCode {
                    
                    tc_ac.start;
                    alt {
                        [] camPort.receive(mw_camInd ( mw_camMsg_any )) {
                            tc_ac.stop;
                            if (t_minTransInterval.running) {
                                return e_error;
                            }
                        }
                        [] t_minTransInterval.timeout {
                            repeat;
                        }
                        [] tc_ac.timeout {
                            t_minTransInterval.stop;
                            return e_timeout;
                        }
                    }
                    
                    return e_success;
                } // end function f_CAM_MSD_GFQ_TI_01
                
            } // end group CAM_MSD_GFQ_TI_01
            
            group CAM_MSD_GFQ_TI_02 {
                
                /**
                 * @desc    TP Function for TC_CAM_MSD_GFQ_TI_02
                 */
                function f_CAM_MSD_GFQ_TI_02() runs on ItsCam {
                    
                    // Local variables
                    timer t_maxTransInterval := PICS_T_GENCAMMAX * 1.10;
                    var integer v_cntSpeed, v_cntTime;
                    var FncRetCode v_ret;
                    
                    // Test control
                    if (not PICS_CAM_GENERATION or PICS_RSU or (PICS_RADIO_COMM == e_lte_cv2x)) {
                        log("*** " & testcasename() & ": PICS_CAM_GENERATION and not PICS_RSU and PICS_RADIO_COMM ITS-G5 required for executing the TC ***");
garciay's avatar
garciay committed
                        setverdict(inconc);
                        stop;
                    }              
                    
                    // Test component configuration
                    f_cfUp();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    f_prInitialState();
                    camPort.clear;
                    tc_ac.start;
                    alt {
                        [] camPort.receive(mw_camInd ( mw_camMsg_any )){ 
                            tc_ac.stop;
                            t_maxTransInterval.start;
                            log("*** " & testcasename() & ": INFO: Initial conditions: First CAM message received ***");
                            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                        }
                        [] tc_ac.timeout {
                            log("*** " & testcasename() & ": INCONC: Initial conditions: CAM message not received ***");
                            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_timeout);
                        }
                    }
                    
                    // Test Body
                    for (v_cntTime:=0; v_cntTime<10; v_cntTime:=v_cntTime + 1) {
                        v_ret := f_CAM_MSD_GFQ_TI_02_helper(t_maxTransInterval);
                        select (v_ret) {
                            case (e_error) {
                                log("*** " & testcasename() & ": FAIL: No CAM message received BEFORE expiry of the maximum generation timer interval ***");
                                f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
                            }
                            case (e_timeout) {
                                log("*** " & testcasename() & ": INCONC: CAM message not received ***");
                                f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
                            }
                        }
                    }
                    t_maxTransInterval.stop;
                    log("*** " & testcasename() & ": PASS: Generation of CAM messages was successful ***");
                    f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
                    
                    // Postamble
                    f_poDefault();
                    f_cfDown();
                    
                } // end f_CAM_MSD_GFQ_TI_02
                
                function f_CAM_MSD_GFQ_TI_02_helper(timer t_maxTransInterval) runs on ItsCam return FncRetCode {
                    
                    tc_ac.start;
                    alt {
                        [] camPort.receive(mw_camInd ( mw_camMsg_any )) {
                            tc_ac.stop;
                            t_maxTransInterval.stop;
                            t_maxTransInterval.start;
                        }
                        [] t_maxTransInterval.timeout {
                            return e_error;
                        }
                        [] tc_ac.timeout {
                            t_maxTransInterval.stop;
                            return e_timeout;
                        }
                    }
                    
                    return e_success
                } // end function f_CAM_MSD_GFQ_TI_02
                
            } //end group CAM_MSD_GFQ_TI_02
            
            /**
             * @desc    TP Function for TC_CAM_MSD_GFQ_TI_03
             */
            function f_CAM_MSD_GFQ_TI_03() runs on ItsCam {
                
                // Local variables
                timer t_maxTransInterval_min := PICS_T_GENCAMMAX * 0.90;
                timer t_maxTransInterval_max := PICS_T_GENCAMMAX * 1.10;
                timer t_interval_1_measure := PX_TWAIT;
                timer t_interval_1_min;
                timer t_interval_1_max;
                var float v_interval_1_min;
                var float v_interval_1_max;
                var integer v_N_GenCam := 3;
                var integer v_i;
                
                // Test control
                if (not PICS_CAM_GENERATION or PICS_RSU or (PICS_RADIO_COMM == e_lte_cv2x)) {
                    log("*** " & testcasename() & ": PICS_CAM_GENERATION and not PICS_RSU and PICS_RADIO_COMM ITS-G5 required for executing the TC ***");
garciay's avatar
garciay committed
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cfUp();
                
                // Test adapter configuration
                
                // Preamble
                f_prInitialState(e_dynamicPosition1500m);
                              
                tc_ac.start;
                alt {
                    [] camPort.receive(mw_camInd ( mw_camMsg_any )){ 
                        t_interval_1_measure.start;
                        tc_ac.stop;                        
                        log("*** " & testcasename() & ": INFO: Initial conditions: First CAM message received ***");
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Initial conditions: CAM message not received ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_timeout);
                    }
                }
                f_changeSpeed(1000);
                tc_ac.start;
                alt {
                    [] camPort.receive(mw_camInd ( mw_camMsg_any )){
                        var float v_measured := t_interval_1_measure.read;
                        log("Elapsed time since last CAM: ", v_measured);
                        tc_ac.stop;
                        v_interval_1_min := v_measured * 0.8;
                        v_interval_1_max := v_measured * 1.2;
                        log("*** " & testcasename() & ": INFO: Initial conditions: Condition 1 CAM message received ***");
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Initial conditions:  Condition 1 CAM message not received ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_timeout);
                    }
                }
                for (v_i:=1; v_i <= v_N_GenCam; v_i:=v_i+1) {
                    t_interval_1_min.start(v_interval_1_min);
                    t_interval_1_max.start(v_interval_1_max);
                    alt {
                        [] camPort.receive(mw_camInd ( mw_camMsg_any )){
                            if (t_interval_1_min.running) {
                                log("*** " & testcasename() & ": INCONC: Initial conditions: Condition 2 CAM#", v_i, " message received BEFORE INTERVAL_1 expired ***");
                                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_timeout);
                            }
                            t_interval_1_max.stop;
                            log("*** " & testcasename() & ": INFO: Initial conditions: Condition 2 CAM#", v_i, " message received ***");
                        }
                        [] t_interval_1_min.timeout {
                            repeat;
                        }
                        [] t_interval_1_max.timeout {
                            log("*** " & testcasename() & ": INCONC: Initial conditions: Condition 2 CAM#", v_i, " message not received ***");
                            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_timeout);
                        }
                    }
                }
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                t_maxTransInterval_min.start;
                t_maxTransInterval_max.start;
                alt {
                    [] camPort.receive(mw_camInd ( mw_camMsg_any )){
                        if (t_maxTransInterval_min.running) {
                            log("*** " & testcasename() & ": FAIL: Next CAM message received BEFORE T_GenCamMax expired ***");
                            f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
                        }
                        t_maxTransInterval_max.stop;
                        log("*** " & testcasename() & ": PASS: Next CAM message received AFTER T_GenCamMax expired ***");
                        f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
                    }
                    [] t_maxTransInterval_min.timeout {
                        repeat;
                    }
                    [] t_maxTransInterval_max.timeout {
                        log("*** " & testcasename() & ": FAIL: Next CAM message not received AFTER T_GenCamMax expired ***");
                        f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
                    }
                }
                
                // Postamble
                f_poDefault();
                f_cfDown();
                
            } // end f_CAM_MSD_GFQ_TI_03
            
            /**
             * @desc    TP Function for TC_CAM_MSD_GFQ_BV_04
             */
            function f_CAM_MSD_GFQ_BV_04() runs on ItsCam {
                
                // Local variables
                timer t_genCam_dcc := PICS_T_GENCAMDCC * 0.90;
                timer t_genCam_min := PICS_T_GENCAMMIN * 1.10;
                var CamInd v_camPdu;
                var HeadingValue v_headingValue;
                var HeadingValue v_changeHeadingValue := 50; // 4° == 40
                
                // Test control
                if (not PICS_CAM_GENERATION or PICS_RSU or (PICS_RADIO_COMM == e_lte_cv2x)) {
                    log("*** " & testcasename() & ": PICS_CAM_GENERATION and not PICS_RSU and PICS_RADIO_COMM ITS-G5 required for executing the TC ***");
garciay's avatar
garciay committed
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cfUp();
                
                // Test adapter configuration
                
                // Preamble
                f_prInitialState();
                camPort.clear;
                tc_ac.start;
                alt {
                    [] camPort.receive(mw_camInd ( mw_camMsg_HF_BV ( mw_HF_BV_heading( ? ) ) )) -> value v_camPdu {
                        tc_ac.stop;
                        v_headingValue := v_camPdu.msgIn.cam.camParameters.highFrequencyContainer.basicVehicleContainerHighFrequency.heading.headingValue;
                        t_genCam_dcc.start;
                        log("*** " & testcasename() & ": INFO: Initial conditions: First CAM message received ***");
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Initial conditions: CAM message not received ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_timeout);
                    }
                }
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                f_changeHeading(v_changeHeadingValue);
                t_genCam_dcc.timeout;
                t_genCam_min.start;
                alt {
                    [] camPort.receive(mw_camInd ( mw_camMsg_HF_BV ( mw_HF_BV_heading( (v_headingValue + v_changeHeadingValue) mod 3600) ) )){ 
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: CAM message received ***");
                        f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
                    }
                    [] t_genCam_min.timeout {
                        log("*** " & testcasename() & ": FAIL: CAM message not received ***");
                        f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
                    }
                }
                
                // Postamble
                f_poDefault();
                f_cfDown();
                
            } // end f_CAM_MSD_GFQ_BV_04
            
            /**
             * @desc    TP Function for TC_CAM_MSD_GFQ_BV_05
             */
            function f_CAM_MSD_GFQ_BV_05() runs on ItsCam {
                
                // Local variables
                timer t_genCam_dcc := PICS_T_GENCAMDCC * 0.90;
                var CamInd v_camPdu;
                var ReferencePosition v_referencePosition, v_expectedReferencePosition;
                var float v_changePosValue := 8.0; // 8 >> 4m
                
                // Test control
                if (not PICS_CAM_GENERATION or PICS_RSU or (PICS_RADIO_COMM == e_lte_cv2x)) {
                    log("*** " & testcasename() & ": PICS_CAM_GENERATION and not PICS_RSU and PICS_RADIO_COMM ITS-G5 required for executing the TC ***");
garciay's avatar
garciay committed
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cfUp();
                
                // Test adapter configuration
                
                // Preamble
                f_prInitialState(e_dynamicPosition200m);
                
                camPort.clear;
                tc_ac.start;
                alt {
                    [] camPort.receive(mw_camInd ( mw_camMsg_any  )) -> value v_camPdu {
                        tc_ac.stop;
                        v_referencePosition := v_camPdu.msgIn.cam.camParameters.basicContainer.referencePosition;
                        t_genCam_dcc.start;
                        log("*** " & testcasename() & ": INFO: Initial conditions: First CAM message received ***");
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Initial conditions: CAM message not received ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_timeout);
                    }
                }
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                v_expectedReferencePosition := f_computePositionUsingDistance(v_referencePosition, v_changePosValue);
                
                if (PX_GNSS_SCENARIO_SUPPORT == false) {
                f_utChangePosition ( valueof ( UtCamChangePosition: {
                                latitude := v_expectedReferencePosition.latitude - v_referencePosition.latitude,
                                longitude := v_expectedReferencePosition.longitude - v_referencePosition.longitude,
                            elevation := 0 } ) );
                }
                
                t_genCam_dcc.timeout;
                t_genCam_dcc.start;
                alt {
                    [] camPort.receive(mw_camInd ( mw_camMsg_BC_refPos ( v_expectedReferencePosition ) )){ 
                        t_genCam_dcc.stop;
                        log("*** " & testcasename() & ": PASS: CAM message received ***");
                        f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
                    }
                    [] t_genCam_dcc.timeout {
                        log("*** " & testcasename() & ": FAIL: CAM message not received ***");
                        f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
                    }
                }
                
                // Postamble
                f_poDefault();
                f_cfDown();
                
            } // end f_CAM_MSD_GFQ_BV_05
            
            /**
             * @desc    TP Function for TC_CAM_MSD_GFQ_BV_06
             */
            function f_CAM_MSD_GFQ_BV_06() runs on ItsCam {
                
                // Local variables
                timer t_genCam_dcc := PICS_T_GENCAMDCC * 0.90;
                timer t_genCam_min := PICS_T_GENCAMMIN * 1.10;
                var CamInd v_camPdu;
                var SpeedValue v_speedValue;
                var SpeedValue v_changeSpeedValue := 60; // 0,5 m/s << 0,6 m/s == 60 cm/s
                
                // Test control
                if (not PICS_CAM_GENERATION or PICS_RSU or (PICS_RADIO_COMM == e_lte_cv2x)) {
                    log("*** " & testcasename() & ": PICS_CAM_GENERATION and not PICS_RSU and PICS_RADIO_COMM ITS-G5 required for executing the TC ***");
garciay's avatar
garciay committed
2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000
                    setverdict(inconc);
                    stop;
                }
                
                // Test component configuration
                f_cfUp();
                
                // Test adapter configuration
                
                // Preamble
                f_prInitialState(e_dynamicPosition1500m);
                camPort.clear;
                tc_ac.start;
                alt {
                    [] camPort.receive(mw_camInd ( mw_camMsg_HF_BV ( mw_HF_BV_speed( ? ) ) )) -> value v_camPdu {
                        tc_ac.stop;
                        v_speedValue := v_camPdu.msgIn.cam.camParameters.highFrequencyContainer.basicVehicleContainerHighFrequency.speed.speedValue;
                        t_genCam_dcc.start;
                        log("*** " & testcasename() & ": INFO: Initial conditions: First CAM message received ***");
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Initial conditions: CAM message not received ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_timeout);
                    }
                }
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                f_changeSpeed(v_changeSpeedValue);
                t_genCam_dcc.timeout;
                t_genCam_min.start;
                alt {
                    [] camPort.receive(mw_camInd ( mw_camMsg_HF_BV ( mw_HF_BV_speed( (v_speedValue + v_changeSpeedValue) mod 16384 ) ) )){ 
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: CAM message received ***");
                        f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
                    }
                    [] t_genCam_min.timeout {
                        log("*** " & testcasename() & ": FAIL: CAM message not received ***");
                        f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
                    }
                }
                
                // Postamble
                f_poDefault();
                f_cfDown();
                
            } // end f_CAM_MSD_GFQ_BV_06
            
            /**
             * @desc    TP Function for TC_CAM_MSD_GFQ_TI_07
             */
            function f_CAM_MSD_GFQ_TI_07() runs on ItsCam {
                
                // Local variables
                timer t_maxTransInterval_min := PICS_T_GENCAMMAX * 0.90;
                timer t_maxTransInterval_max := PICS_T_GENCAMMAX * 1.10;
                timer t_genCam_measure := PX_TWAIT;
                timer t_genCam_min;
                timer t_genCam_max;
                var float v_genCam_min;
                var float v_genCam_max;
                
                // Test control
                if (not PICS_CAM_GENERATION or PICS_RSU) {
                    log("*** " & testcasename() & ": PICS_CAM_GENERATION and not PICS_RSU required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }              
                
                // Test component configuration
                f_cfUp();
                
                // Test adapter configuration
                
                // Preamble
                f_prInitialState(e_dynamicPosition1500m);
                camPort.clear;
                tc_ac.start;
                alt {
                    [] camPort.receive(mw_camInd ( mw_camMsg_any )){ 
                        tc_ac.stop;
                        t_genCam_measure.start;
                        log("*** " & testcasename() & ": INFO: Initial conditions: First CAM message received ***");
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Initial conditions: CAM message not received ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_timeout);
                    }
                }
                f_changeSpeed(1000);
                tc_ac.start;
                alt {
                    [] camPort.receive(mw_camInd ( mw_camMsg_any )){
                        var float v_measured := t_genCam_measure.read;
                        tc_ac.stop;
                        v_genCam_min := v_measured * 0.9;
                        v_genCam_max := v_measured * 1.1;
                        log("*** " & testcasename() & ": INFO: Initial conditions: Anticipated CAM message received ***");
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Initial conditions: Anticipated CAM message not received ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_timeout);
                    }
                }
                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                
                // Test Body
                t_genCam_min.start(v_genCam_min);
                t_genCam_max.start(v_genCam_max);
                alt {
                    [] camPort.receive(mw_camInd ( mw_camMsg_any )){
                        if (t_genCam_min.running) {
                            log("*** " & testcasename() & ": FAIL: Anticipated CAM message received BEFORE T_GenCam expired ***");
                            f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
                        }
                        t_genCam_max.stop;
                        log("*** " & testcasename() & ": PASS: Anticipated CAM message received ***");
                        f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
                    }
                    [] t_genCam_min.timeout {
                        repeat;
                    }
                    [] t_genCam_max.timeout {
                        log("*** " & testcasename() & ": FAIL: Anticipated CAM message not received ***");
                        f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
                    }
                }
                
                // Postamble
                f_poDefault();
                f_cfDown();
                
            } // end f_CAM_MSD_GFQ_TI_07
            
            /**
             * @desc    TP Function for TC_CAM_MSD_GFQ_TI_08
             */
            function f_CAM_MSD_GFQ_TI_08() runs on ItsCam {
                
                // Local constants
                const float c_minTime := 0.90;
                const float c_maxTime := 1.10;

                // Local variables
                if (not PICS_CAM_GENERATION or not PICS_RSU) {
                    log("*** " & testcasename() & ": PICS_CAM_GENERATION and PICS_RSU required for executing the TC ***");
                    setverdict(inconc);
                    stop;
                }              
                
                // Test component configuration
                f_cfUp();

                // Preamble
                f_prInitialState();
                camPort.clear;
                tc_ac.start;
                alt {
                    [] camPort.receive(mw_camInd ( mw_camMsg_any )){ 
                        tc_ac.stop;
                        log("*** " & testcasename() & ": INFO: Initial conditions: First CAM message received ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: Initial conditions: CAM message not received ***");
                        f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_timeout);
                    }
                }
                
                // Test Body
                tc_ac.start;
                alt {
                    [] camPort.receive(mw_camInd ( mw_camMsg_any )){ 
                        if ( ( tc_ac.read  > c_minTime )) {
                            tc_ac.stop;
                            log("*** " & testcasename() & ": PASS: CAM message received in time***");
                            f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
                        }
                        else {
                            tc_ac.stop;
                            log("*** " & testcasename() & ": FAIL: CAM message not received in time***");
                            f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
                        }
                    }
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": FAIL: CAM message not received ***");
                        f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
                    }
                }
                
                // Postamble
                f_poDefault();
                f_cfDown();
                
            } // end f_CAM_MSD_GFQ_TI_08
            
        } // end group camGenerationFrequency

        group camLowerLayerParameters {
            
            /**
             * @desc    TP Function for TC_CAM_MSD_PAR_BV_01
             */
            function f_CAM_MSD_PAR_BV_01() runs on ItsCam {
                
                // Local variables
                const UInt8 c_gnNhBtpB := 2;
                
                // Test control
                if (not PICS_CAM_GENERATION or PICS_IS_IUT_SECURED) {
                    log("*** " & testcasename() & ": PICS_CAM_GENERATION and not PICS_IS_IUT_SECURED 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
                tc_ac.start;
                alt {
                    [] camPort.receive(mw_camIndWithGnParameters(mw_camMsg_any, c_gnNhBtpB)) { 
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: Expected CAM message encapsultated in BTP-B packet received ***");
                        f_selfOrClientSyncAndVerdict(c_tbDone, e_success);  
                    }
                    [] camPort.receive(mw_camIndWithGnParameters(mw_camMsg_any, omit)) { 
                        tc_ac.stop;
                        log("*** " & testcasename() & ": INCONC: no GN NH information in CamInd ***");
                        f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);  
                    }                    
                    [] camPort.receive(mw_camInd(mw_camMsg_any)) { 
                        tc_ac.stop;
                        log("*** " & testcasename() & ": FAIL: Expected CAM message received, but not encapsulated in BTP-B packet ***");
                        f_selfOrClientSyncAndVerdict(c_tbDone, e_error);  
                    }                    
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: CAM message not received ***");
                        f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
                    }
                }
                
                // Postamble
                f_poDefault();
                f_cfDown();
                
            } // end f_CAM_MSD_PAR_BV_01

            /**
             * @desc    TP Function for TC_CAM_MSD_PAR_BV_02
             */
            function f_CAM_MSD_PAR_BV_02() runs on ItsCam {
                
                // Local variables
                const UInt8 c_gnHtTsb := 5;
                const UInt8 c_GnHstSingleHop := 0;
                
                // Test control
                if (not PICS_CAM_GENERATION or PICS_IS_IUT_SECURED) {
                    log("*** " & testcasename() & ": PICS_CAM_GENERATION and not PICS_IS_IUT_SECURED 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
                tc_ac.start;
                alt {
                    [] camPort.receive(mw_camIndWithGnParameters(mw_camMsg_any, -, c_gnHtTsb, c_GnHstSingleHop)) { 
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: Expected CAM message encapsulated in SHB packet received ***");
                        f_selfOrClientSyncAndVerdict(c_tbDone, e_success);  
                    }
                    [] camPort.receive(mw_camIndWithGnParameters(mw_camMsg_any, -, omit, omit)) { 
                        tc_ac.stop;
                        log("*** " & testcasename() & ": INCONC: no GN HT/HST information in CamInd ***");
                        f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);  
                    }                    
                    [] camPort.receive(mw_camInd(mw_camMsg_any)) { 
                        tc_ac.stop;
                        log("*** " & testcasename() & ": FAIL: Expected CAM message received, but not encapsulated in SHB packet ***");
                        f_selfOrClientSyncAndVerdict(c_tbDone, e_error);  
                    }                    
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: CAM message not received ***");
                        f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
                    }
                }
                
                // Postamble
                f_poDefault();
                f_cfDown();
                
            } // end f_CAM_MSD_PAR_BV_02
            
            /**
             * @desc    TP Function for TC_CAM_MSD_PAR_BV_03
             */
            function f_CAM_MSD_PAR_BV_03() runs on ItsCam {
                
                // Local variables
                var CamInd v_camInd;
                
                // Test control
                if (not PICS_CAM_GENERATION or PICS_IS_IUT_SECURED) {
                    log("*** " & testcasename() & ": PICS_CAM_GENERATION and not PICS_IS_IUT_SECURED 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
                tc_ac.start;
                alt {
                    [] camPort.receive(mw_camIndWithGnParameters(mw_camMsg_any)) -> value v_camInd { 
                        tc_ac.stop;
                        if(not ispresent(v_camInd.gnLifetime)) {
                            log("*** " & testcasename() & ": INCONC: no GN lifetime information in CamInd ***");
                            f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);  
                        }
                        if(v_camInd.gnLifetime <= 1000) {
                            log("*** " & testcasename() & ": PASS: Expected CAM message received encapsulted in GN packet with correct lifetime value ***");
                            f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
                        }
                        else {
                            log("*** " & testcasename() & ": FAIL: Expected CAM message received encapsulted in GN packet with incorrect lifetime value ***");
                            f_selfOrClientSyncAndVerdict(c_tbDone, e_error);                            
                        }  
                    }                    
                    [] tc_ac.timeout {
                        log("*** " & testcasename() & ": INCONC: CAM message not received ***");
                        f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
                    }
                }
                
                // Postamble
                f_poDefault();
                f_cfDown();
                
            } // 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 := ?