Commit dcd8c821 authored by garciay's avatar garciay
Browse files

Add support of SPATEM, including one state rotation

parent 45ff4c90
Loading
Loading
Loading
Loading
+44 −27
Original line number Diff line number Diff line
@@ -123,7 +123,7 @@ module ItsRSUsSimulator_Functions {
            // Build the list of the MAPEM events
            v_mapem := 
                m_mapemParm(
                    PICS_RSU_PARAMS[PX_RSU_ID - 1].stationID,
                    PICS_RSU_PARAMS[vc_rsu_id].stationID,
                    m_mapem(
                        f_getMsgIssueRevision(),
                        PICS_MAPEM_PARMS_RSUs[p_rsu_id].intersections,
@@ -135,6 +135,10 @@ module ItsRSUsSimulator_Functions {
        }
        // SPATEM
        if (PICS_GENERATE_SPATEM and (lengthof(PICS_SPATEM_PARMS_RSUs[p_rsu_id]) != 0)) {
            // Reset counter
            vc_currentPhaseStartTime := 36001;
            vc_endPhaseStartTime := 0;
            vc_spatemStatesId := 0;
            // Build the list of the SPATEM events
            for (v_counter := 0; v_counter < lengthof(PICS_SPATEM_PARMS_RSUs[p_rsu_id]); v_counter := v_counter + 1) {
                v_spatems[v_counter] := 
@@ -235,19 +239,19 @@ module ItsRSUsSimulator_Functions {
        
        // Terminate simulation
        if (p_cfEvent == "stop") {
            if (ispresent(vc_rsuMessagesValueList[PX_RSU_ID - 1].cam)) {
            if (ispresent(vc_rsuMessagesValueList[vc_rsu_id].cam)) {
                tc_cam.stop;
            }
            if (ispresent(vc_rsuMessagesValueList[PX_RSU_ID - 1].denms)) {
            if (ispresent(vc_rsuMessagesValueList[vc_rsu_id].denms)) {
                tc_denm.stop;
            }
            if (ispresent(vc_rsuMessagesValueList[PX_RSU_ID - 1].mapem)) {
            if (ispresent(vc_rsuMessagesValueList[vc_rsu_id].mapem)) {
                tc_mapem.stop;
            }
            if (ispresent(vc_rsuMessagesValueList[PX_RSU_ID - 1].spatems)) {
            if (ispresent(vc_rsuMessagesValueList[vc_rsu_id].spatems)) {
                tc_spatem.stop;
            }
            if (ispresent(vc_rsuMessagesValueList[PX_RSU_ID - 1].ivim)) {
            if (ispresent(vc_rsuMessagesValueList[vc_rsu_id].ivim)) {
                tc_ivim.stop;
            }
        } else {
@@ -263,13 +267,13 @@ module ItsRSUsSimulator_Functions {
                           out template (value) Payload p_payload
    ) runs on ItsRSUsSimulator {
        
        vc_rsuMessagesValueList[PX_RSU_ID - 1].cam.cam.generationDeltaTime := f_getCurrentTime() mod 65536; // See ETSI EN 302 637-2 V1.3.0 - Clause B.3 generationDelatTime
        vc_rsuMessagesValueList[vc_rsu_id].cam.cam.generationDeltaTime := f_getCurrentTime() mod 65536; // See ETSI EN 302 637-2 V1.3.0 - Clause B.3 generationDelatTime
        p_payload := valueof(
            f_adaptPayload(
                bit2oct(
                    encvalue(
                        valueof(
                            vc_rsuMessagesValueList[PX_RSU_ID - 1].cam
                            vc_rsuMessagesValueList[vc_rsu_id].cam
                ))),
                PICS_CAM_BTP_DESTINATION_PORT,
                PICS_CAM_BTP_SOURCE_PORT
@@ -282,18 +286,18 @@ module ItsRSUsSimulator_Functions {
    ) runs on ItsRSUsSimulator {
        
        // Update dynamic parms
        vc_rsuMessagesValueList[PX_RSU_ID - 1].denms[vc_denmEventCounter].denm.management.referenceTime  := f_getCurrentTime();
        vc_rsuMessagesValueList[vc_rsu_id].denms[vc_denmEventCounter].denm.management.referenceTime  := f_getCurrentTime();
        p_payload := valueof(
            f_adaptPayload(
                bit2oct(
                    encvalue(
                        valueof(vc_rsuMessagesValueList[PX_RSU_ID - 1].denms[vc_denmEventCounter]
                        valueof(vc_rsuMessagesValueList[vc_rsu_id].denms[vc_denmEventCounter]
                ))),
                PICS_DENM_BTP_DESTINATION_PORT,
                PICS_DENM_BTP_SOURCE_PORT
            )
        ); 
        vc_denmEventCounter := (vc_denmEventCounter + 1) mod lengthof(vc_rsuMessagesValueList[PX_RSU_ID - 1].denms);
        vc_denmEventCounter := (vc_denmEventCounter + 1) mod lengthof(vc_rsuMessagesValueList[vc_rsu_id].denms);
    } // End of function f_prepare_denm
    
    function f_prepare_mapem(
@@ -305,7 +309,7 @@ module ItsRSUsSimulator_Functions {
                bit2oct(
                    encvalue(
                        valueof(
                            vc_rsuMessagesValueList[PX_RSU_ID - 1].mapem
                            vc_rsuMessagesValueList[vc_rsu_id].mapem
                ))),
                PICS_MAPEM_BTP_DESTINATION_PORT,
                PICS_MAPEM_BTP_SOURCE_PORT
@@ -313,27 +317,37 @@ module ItsRSUsSimulator_Functions {
        );
    } // End of function f_prepare_mapem
    
    function f_computeEndPhaseStartTime(
                               in TimeMark p_timeMark,
                               in UInt32 p_inc
    ) return TimeMark {
        var UInt32 v_endPhaseStartTime := p_timeMark + p_inc;
        return v_endPhaseStartTime mod 36000;
    }
    
    function f_prepare_spatem(
                              in template (value) SPATEM p_spatem,
                              out template (value) Payload p_payload
    ) runs on ItsRSUsSimulator {
        var template (value) SPATEM v_spatem := p_spatem; // Make a copy
        var TimeMark v_currentTimeMark := f_getCurrentTimeMark();
        
        
        
        
        
		vc_currentPhaseStartTime := f_getCurrentTime();
		vc_endPhaseStartTime := vc_currentPhaseStartTime + vc_repitition_duration[vc_spatemStatesId];
        
        
        
        
        
        
        if (vc_currentPhaseStartTime == 36001) {
		    vc_currentPhaseStartTime := v_currentTimeMark;
		    vc_endPhaseStartTime := f_computeEndPhaseStartTime(vc_currentPhaseStartTime, vc_repitition_duration[vc_spatemStatesId]);
        }
        if (v_currentTimeMark >= vc_endPhaseStartTime) {
            vc_spatemStatesId := (vc_spatemStatesId + 1) mod vc_spatemStatesNum; // Change state
		    vc_currentPhaseStartTime := v_currentTimeMark;
		    vc_endPhaseStartTime := f_computeEndPhaseStartTime(vc_currentPhaseStartTime, vc_repitition_duration[vc_spatemStatesId]);
        }
        log("vc_currentPhaseStartTime = ", vc_currentPhaseStartTime);
        log("vc_endPhaseStartTime = ", vc_endPhaseStartTime);
        log("v_currentTimeMark = ", v_currentTimeMark);
        log("vc_spatemStatesId = ", vc_spatemStatesId);
        // Rebuild SPATEM message
        for (var integer v_intersection := 0; v_intersection < lengthof(v_spatem.spat.intersections); v_intersection := v_intersection + 1) {
            var template (value) MovementList v_states := vc_states[PX_RSU_ID - 1][v_intersection];
            var template (value) MovementList v_states := vc_states[vc_signalGroupParmId][v_intersection];
            select (vc_spatemStatesId) {
                case (0) {
                    v_spatem.spat.intersections[v_intersection].states[0] := v_states[0];
@@ -353,8 +367,11 @@ module ItsRSUsSimulator_Functions {
                case else {
                }
            } // End of 'select' statement
            // Update 'minEndTime' field
            v_spatem.spat.intersections[v_intersection].states[0].state_time_speed[0].timing.minEndTime := vc_currentPhaseStartTime;
            v_spatem.spat.intersections[v_intersection].states[1].state_time_speed[0].timing.minEndTime := vc_currentPhaseStartTime + vc_repitition_duration[(vc_spatemStatesId + 1) mod vc_spatemStatesNum];
            v_spatem.spat.intersections[v_intersection].states[2].state_time_speed[0].timing.minEndTime := vc_currentPhaseStartTime + vc_repitition_duration[(vc_spatemStatesId + 2) mod vc_spatemStatesNum];
        } // End of 'for' statement
        vc_spatemStatesId := (vc_spatemStatesId + 1) mod 4; // TODO To be refined
        
        p_payload := valueof(
            f_adaptPayload(
@@ -379,7 +396,7 @@ module ItsRSUsSimulator_Functions {
                bit2oct(
                    encvalue(
                        valueof(
                            vc_rsuMessagesValueList[PX_RSU_ID - 1].ivim
                            vc_rsuMessagesValueList[vc_rsu_id].ivim
                ))),
                PICS_IVIM_BTP_DESTINATION_PORT,
                PICS_IVIM_BTP_SOURCE_PORT
+39 −39
Original line number Diff line number Diff line
@@ -51,8 +51,8 @@ module ItsRSUsSimulator_Pics {
                longPosVector := {
                    gnAddr        := PICS_RSU_GN_ADDRESS_RSU1,
                    timestamp_    := 0,
                    latitude      := 43551050,
                    longitude     := 10298730,
                    latitude      := 435510500,
                    longitude     := 102987300,
                    pai           := '0'B,
                    speed         := 0,
                    heading       := 0
@@ -92,8 +92,8 @@ module ItsRSUsSimulator_Pics {
                longPosVector := {
                    gnAddr        := PICS_RSU_GN_ADDRESS_RSU2,
                    timestamp_    := 0,
                    latitude      := 43551209,
                    longitude     := 10300251,
                    latitude      := 435512090,
                    longitude     := 103002510,
                    pai           := '0'B,
                    speed         := 0,
                    heading       := 0
@@ -133,8 +133,8 @@ module ItsRSUsSimulator_Pics {
                longPosVector := {
                    gnAddr        := PICS_RSU_GN_ADDRESS_RSU3,
                    timestamp_    := 0,
                    latitude      := 43551209,
                    longitude     := 10300251,
                    latitude      := 435512090,
                    longitude     := 103002510,
                    pai           := '0'B,
                    speed         := 0,
                    heading       := 0
@@ -174,8 +174,8 @@ module ItsRSUsSimulator_Pics {
                longPosVector := {
                    gnAddr        := PICS_RSU_GN_ADDRESS_RSU4,
                    timestamp_    := 0,
                    latitude      := 43558215,
                    longitude     := 10306517,
                    latitude      := 435582150,
                    longitude     := 103065170,
                    pai           := '0'B,
                    speed         := 0,
                    heading       := 0
@@ -215,8 +215,8 @@ module ItsRSUsSimulator_Pics {
                longPosVector := {
                    gnAddr        := PICS_RSU_GN_ADDRESS_RSU5,
                    timestamp_    := 0,
                    latitude      := 43556350,
                    longitude     := 10304745,
                    latitude      := 435563500,
                    longitude     := 103047450,
                    pai           := '0'B,
                    speed         := 0,
                    heading       := 0
@@ -256,8 +256,8 @@ module ItsRSUsSimulator_Pics {
                longPosVector := {
                    gnAddr        := PICS_RSU_GN_ADDRESS_RSU6,
                    timestamp_    := 0,
                    latitude      := 43557066,
                    longitude     := 10301917,
                    latitude      := 435570660,
                    longitude     := 103019170,
                    pai           := '0'B,
                    speed         := 0,
                    heading       := 0
@@ -297,8 +297,8 @@ module ItsRSUsSimulator_Pics {
                longPosVector := {
                    gnAddr        := PICS_RSU_GN_ADDRESS_RSU7,
                    timestamp_    := 0,
                    latitude      := 43555058,
                    longitude     := 10303298,
                    latitude      := 435550580,
                    longitude     := 103032980,
                    pai           := '0'B,
                    speed         := 0,
                    heading       := 0
@@ -338,8 +338,8 @@ module ItsRSUsSimulator_Pics {
                longPosVector := {
                    gnAddr        := PICS_RSU_GN_ADDRESS_RSU8,
                    timestamp_    := 0,
                    latitude      := 43554663,
                    longitude     := 10304190,
                    latitude      := 435546630,
                    longitude     := 103041900,
                    pai           := '0'B,
                    speed         := 0,
                    heading       := 0
@@ -379,8 +379,8 @@ module ItsRSUsSimulator_Pics {
                longPosVector := {
                    gnAddr        := PICS_RSU_GN_ADDRESS_RSU9,
                    timestamp_    := 0,
                    latitude      := 43554128,
                    longitude     := 10301578,
                    latitude      := 435541280,
                    longitude     := 103015780,
                    pai           := '0'B,
                    speed         := 0,
                    heading       := 0
@@ -420,8 +420,8 @@ module ItsRSUsSimulator_Pics {
                longPosVector := {
                    gnAddr        := PICS_RSU_GN_ADDRESS_RSU10,
                    timestamp_    := 0,
                    latitude      := 43553552,
                    longitude     := 10301039,
                    latitude      := 435535520,
                    longitude     := 103010390,
                    pai           := '0'B,
                    speed         := 0,
                    heading       := 0
@@ -461,8 +461,8 @@ module ItsRSUsSimulator_Pics {
                longPosVector := {
                    gnAddr        := PICS_RSU_GN_ADDRESS_RSU11,
                    timestamp_    := 0,
                    latitude      := 43552878,
                    longitude     := 10300865,
                    latitude      := 435528780,
                    longitude     := 103008650,
                    pai           := '0'B,
                    speed         := 0,
                    heading       := 0
@@ -2623,6 +2623,8 @@ module ItsRSUsSimulator_Pics {
        } // End of group denmUseCase2 
            
        modulepar DenmEventsParmsUseCaseRsu PICS_DENM_EVENTS_RSU := {
            PICS_DENM_PARMS_UC1_RWW,
            PICS_DENM_PARMS_UC1_RWW,
            PICS_DENM_PARMS_UC1_RWW
        } // End of PICS_DENM_EVENTS_RSU
        
@@ -2832,7 +2834,7 @@ module ItsRSUsSimulator_Pics {
            modulepar MapemParm PICS_Z2_M1_SL := {
                intersections := {
                    { // Start of intersection #0
                        name                                := "PICS_Z2_M1_SL - RSU_2",
                        name                                := "PICS_Z2_M1_SL - RSU_3",
                        id                                  := PICS_Z2_M1_SL_IDX,
                        revision                            := 0,
                        refPoint                            := PICS_Z2_M1_SL_RP,
@@ -3419,11 +3421,11 @@ module ItsRSUsSimulator_Pics {
                intersections := omit,
                roadSegments  := omit
            },                              // RSU #1
            PICS_Z2_M1_SL,                  // RSU #2
            {
                intersections := omit,
                roadSegments  := omit
            },                              // RSU #3
            },                              // RSU #2
            PICS_Z2_M1_SL,                  // RSU #3
            PICS_Z5_M1_SL,                  // RSU #4
            PICS_Z4_M1_SL,                  // RSU #5
            {
@@ -3431,10 +3433,7 @@ module ItsRSUsSimulator_Pics {
                roadSegments  := omit
            },                              // RSU #6
            PICS_Z6_M1_SL,                  // RSU #7
            {
                intersections := omit,
                roadSegments  := omit
            },                              // RSU #8
            PICS_Z3_M1_SL,                  // RSU #8
            {
                intersections := omit,
                roadSegments  := omit
@@ -3459,11 +3458,11 @@ module ItsRSUsSimulator_Pics {
            
            modulepar UInt32 PICS_SPATEM_ITS_AID                        := 137;
            
            modulepar UInt32 PICS_SPATEM_REPITITION_DURATION_STATE_1    := 30;
            modulepar UInt32 PICS_SPATEM_REPITITION_DURATION_STATE_1    := 5*10; // In units of 1/10th second
            
            modulepar UInt32 PICS_SPATEM_REPITITION_DURATION_STATE_2    := 10;
            modulepar UInt32 PICS_SPATEM_REPITITION_DURATION_STATE_2    := 5*10; // In units of 1/10th second
            
            modulepar UInt32 PICS_SPATEM_REPITITION_DURATION_STATE_3    := 20;
            modulepar UInt32 PICS_SPATEM_REPITITION_DURATION_STATE_3    := 5*10; // In units of 1/10th second
            
        } // End of group spatemCommonParams
        
@@ -3563,7 +3562,7 @@ module ItsRSUsSimulator_Pics {
                signalGroupID                               := 1,
                intersections := {
                    {
                        name                                := "PICS_SPATEM_PARMS_SG_1 - RSU_2",
                        name                                := "PICS_SPATEM_PARMS_SG_1 - RSU_3",
                        id                                  := PICS_Z2_M1_SL_IDX,
                        revision                            := 0,   
                        status                              := int2bit(0, 16),
@@ -4009,7 +4008,8 @@ module ItsRSUsSimulator_Pics {
        
        modulepar SpatemParmRsu PICS_SPATEM_PARMS_RSUs := {
            {},                              // RSU #1
            PICS_Z2_S1_SL_LIST,              // RSU #2
            {},                              // RSU #2
            PICS_Z2_S1_SL_LIST,              // RSU #3
            PICS_Z5_S1_SL_LIST,              // RSU #4
            PICS_Z4_S1_SL_LIST,              // RSU #5
            {},                              // RSU #6
@@ -5450,12 +5450,12 @@ module ItsRSUsSimulator_Pics {
                iviIdentificationNumber := omit, 
                iviContainers := omit 
            },                                           // RSU #1
            PICS_Z2_I1_POS1,                             // RSU #2
            { 
                provider := omit, 
                iviIdentificationNumber := omit, 
                iviContainers := omit 
            },                                           // RSU #3
            },                                           // RSU #2
            PICS_Z2_I1_POS1,                             // RSU #3
            PICS_Z5_I1_POS1,                             // RSU #4
            PICS_Z4_I1_POS1,                             // RSU #5
            { 
@@ -5518,11 +5518,11 @@ module ItsRSUsSimulator_Pics {
        
        modulepar boolean PICS_GENERATE_CAM      := false;
        
        modulepar boolean PICS_GENERATE_DENM     := true;
        modulepar boolean PICS_GENERATE_DENM     := false;
        
        modulepar boolean PICS_GENERATE_IVIM     := true;
        modulepar boolean PICS_GENERATE_IVIM     := false;
        
        modulepar boolean PICS_GENERATE_MAPEM    := true;
        modulepar boolean PICS_GENERATE_MAPEM    := false;
        
        modulepar boolean PICS_GENERATE_SPATEM   := true;
        
+4 −2
Original line number Diff line number Diff line
@@ -22,16 +22,18 @@ module ItsRSUsSimulator_Pixits {
    /**
     * @desc Indicate which RSU to simulate
     */
    modulepar integer PX_RSU_ID := 1; 
    modulepar integer PX_RSU_ID := 3; 
    
    /**
     * @desc Indicate which Use Case to simulate
     * @remark Used only for DENM
     */
    modulepar integer PX_ETSI_USE_CASE_ID := 1;
    
    /**
     * @desc Indicate which zone to simulate
     * @remark Used only for DENM
     */
    modulepar integer PX_ETSI_ZONE_ID := 1;
    modulepar integer PX_ETSI_ZONE_ID := 2;
    
} // End of module ItsRSUsSimulator_Pixits
+15 −4
Original line number Diff line number Diff line
@@ -54,23 +54,34 @@ module ItsRSUsSimulator_TestSystem {
         * @desc List of MovementState per intersection and per RSU 
         */
        var template (value) MovementListPerIntersectionRsu vc_states;
        /**
         * @desc The SPATEM message to use in SignalGroupParmList
         */
        var integer vc_signalGroupParmId := 0; // TODO Use a PIXIT 
        /**
         * @desc Current SPATEM state
         */
        var integer vc_spatemStatesId := 0;
        /**
         * @desc TODO
         * @desc TimeMark of the begining of a new SPATEM phase
         */
        var TimestampIts vc_currentPhaseStartTime := 0;
        var TimeMark vc_currentPhaseStartTime := 36001;
        /**
         * @desc TODO
         * @desc Estimated TimeMark of the end of the current SPATEM phase
         */
        var TimeMark vc_endPhaseStartTime := 0;
        /**
         * @desc Repetition duration times of SPATEM phases
         */
        var TimestampIts vc_endPhaseStartTime := 0;
        var SpatemRepetionDuration vc_repitition_duration := { 
            PICS_SPATEM_REPITITION_DURATION_STATE_1, 
            PICS_SPATEM_REPITITION_DURATION_STATE_2, 
            PICS_SPATEM_REPITITION_DURATION_STATE_3 
        };
        /**
         * @desc Number of SPATEM phases
         */
        var integer vc_spatemStatesNum := lengthof(vc_repitition_duration);
        
        timer tc_cam    := PICS_CAM_FREQUENCY;
        timer tc_denm   := PICS_DENM_FREQUENCY;