Commit 840c00f0 authored by garciay's avatar garciay
Browse files

Finalise UC6

parent 365ab4fc
Loading
Loading
Loading
Loading
+36 −15
Original line number Diff line number Diff line
@@ -60,12 +60,21 @@ module ItsRSUsSimulator_Functions {
    
    group externalFunctions {
        
        /**
         * @desc    External function to compute a position using a reference position, a distance and an orientation 
         * @param   p_refLongPosVector  Vehicle reference position
         * @param   p_cenLongPosVector  Collision point position
         * @param   p_rotation          Rotation angle in 1/10 of degrees (from North)
         * @param   p_latitude          Computed position's latitude
         * @param   p_longitude         Computed position's longitude
         * @remark See http://www.movable-type.co.uk/scripts/latlong.html
         */
        external function fx_computePositionFromRotation(
                                                         in Int32 p_refLatitude, 
                                                         in Int32 p_refLongitude, 
                                                         in Int32 p_cenLatitude, 
                                                         in Int32 p_cenLongitude, 
                                                         in float p_rotation, 
                                                         in Int32 p_rotation, 
                                                         out Int32 p_latitude,
                                                         out Int32 p_longitude
        );
@@ -88,7 +97,7 @@ module ItsRSUsSimulator_Functions {
            
            // Map
            map(self:acPort, system:acPort);
            map(self:cfPort, system:cfPort);
            //map(self:cfPort, system:cfPort);
            map(self:geoNetworkingPort, system:geoNetworkingPort);
            
            // Connect
@@ -99,7 +108,7 @@ module ItsRSUsSimulator_Functions {
            f_initialiseSecuredMode();
            
            //Initialze the Config module
            cfPort.send(CfInitialize:{});
            //cfPort.send(CfInitialize:{});
            
            // Initialisations
            f_setup_rsu(vc_rsu_id);
@@ -114,7 +123,7 @@ module ItsRSUsSimulator_Functions {
            
            // Unmap
            unmap(self:acPort, system:acPort);
            unmap(self:cfPort, system:cfPort);
            //unmap(self:cfPort, system:cfPort);
            unmap(self:geoNetworkingPort, system:geoNetworkingPort);
            
            // Disconnect
@@ -652,17 +661,29 @@ module ItsRSUsSimulator_Functions {
        var template (value) Payload v_payload;
        
        // Apply 90° rotation
        if (PICS_USE_SPV == true) {
            fx_computePositionFromRotation(
                p_location.latitude,
                p_location.longitude,
//            p_camVehicle.cam.camParameters.basicContainer.referencePosition.latitude, 
//            p_camVehicle.cam.camParameters.basicContainer.referencePosition.longitude, 
                PICS_UC6_COLLISION_POINT.latitude, 
                PICS_UC6_COLLISION_POINT.longitude, 
            -90.0, 
                900, 
                v_newPosition.latitude, 
            v_newPosition.longitude);
                v_newPosition.longitude
            );
            log("Rotation: (", p_location.latitude, ", ", p_location.longitude, ") --> (", v_newPosition.latitude, ", ", v_newPosition.longitude, ")");
        } else {
            fx_computePositionFromRotation(
                p_camVehicle.cam.camParameters.basicContainer.referencePosition.latitude, 
                p_camVehicle.cam.camParameters.basicContainer.referencePosition.longitude, 
                PICS_UC6_COLLISION_POINT.latitude, 
                PICS_UC6_COLLISION_POINT.longitude, 
                900, 
                v_newPosition.latitude, 
                v_newPosition.longitude
            );
            log("Rotation: (", p_camVehicle.cam.camParameters.basicContainer.referencePosition.latitude, ", ", p_camVehicle.cam.camParameters.basicContainer.referencePosition.longitude, ") --> (", v_newPosition.latitude, ", ", v_newPosition.longitude, ")");
        }
        /*v_newPosition.latitude := ;
        v_newPosition.longitude := ;*/
        // Update CAM
+4 −0
Original line number Diff line number Diff line
@@ -425,6 +425,8 @@ module ItsRSUsSimulator_Pics {
        
        group camUseCase6 {
            
            modulepar integer SIMULTANEOUS_VEHICLE_NUM        := 10;
            
            group camUseCase6VehicleTemplateDescription {
                
                modulepar LongPosVector PICS_UC6_VEHICLE_TEMPLATE_POSITION := {
@@ -453,6 +455,8 @@ module ItsRSUsSimulator_Pics {
                    }
                } // End of PICS_UC6_VEHICLE_GEOAREA
                
                modulepar boolean PICS_USE_SPV := true;
                
            } // End of group camUseCase6VehicleDescription 
            
            group camUseCase6SyncLocation {
+71 −48
Original line number Diff line number Diff line
@@ -97,12 +97,12 @@ module ItsRSUsSimulator_TestCases {
                // Nothing to do, just for logging purposes
                repeat;
            }
            [] cfPort.receive(CfEvent:?) -> value v_cfEvent {
            /*[] cfPort.receive(CfEvent:?) -> value v_cfEvent {
                //log("*** " & testcasename() & ": DEBUG: Configuration port command:", v_cfEvent, " ***");
                if (f_process_cf_event(v_cfEvent) == true) {
                    repeat;
                }
            }
            }*/
            [vc_beacon == true] tc_beacon.timeout {
                //log("*** " & testcasename() & ": DEBUG: Processing BEACON ***");
                f_prepare_beacon(v_payload);
@@ -171,7 +171,6 @@ module ItsRSUsSimulator_TestCases {
        // Local variables
        const RectangularRegions c_detectionArea := { PICS_UC6_CAM_DETECTION_AREA };
        var VehiclesSimulator v_vehicles := {};
        var integer v_vehiclesIdx := 0;
        var integer v_stationID;
        var boolean v_isInDetectionZone;
        var boolean v_notProcessed;
@@ -191,7 +190,7 @@ module ItsRSUsSimulator_TestCases {
        // Test adapter configuration
        
        // Preamble
        for (v_idx := 0; v_idx < 10; v_idx := v_idx + 1) { // FIXME Use a PIXIT
        for (v_idx := 0; v_idx < SIMULTANEOUS_VEHICLE_NUM; v_idx := v_idx + 1) { 
            v_vehicles[v_idx].detected := false;
            v_vehicles[v_idx].detectionCounter := 0;
            v_vehicles[v_idx].stationId := 0;
@@ -211,69 +210,83 @@ module ItsRSUsSimulator_TestCases {
                            e_btpB
            )))) -> value v_gnInd { // Receive a CAM message
                tc_ac.stop;
                if (PICS_USE_SPV == true) {
                    v_location := {
                        v_gnInd.msgIn.gnPacket.packet.extendedHeader.shbHeader.srcPosVector.latitude,
                        v_gnInd.msgIn.gnPacket.packet.extendedHeader.shbHeader.srcPosVector.longitude,
                    int2oct(0, 2)
//                    v_gnInd.msgIn.gnPacket.packet.payload.decodedPayload.btpPacket.payload.decodedPayload.camPacket.cam.camParameters.basicContainer.referencePosition.latitude,
//                    v_gnInd.msgIn.gnPacket.packet.payload.decodedPayload.btpPacket.payload.decodedPayload.camPacket.cam.camParameters.basicContainer.referencePosition.longitude,
//                    int2oct(v_gnInd.msgIn.gnPacket.packet.payload.decodedPayload.btpPacket.payload.decodedPayload.camPacket.cam.camParameters.basicContainer.referencePosition.altitude.altitudeValue, 2)
                        '0000'O
                    };
                } else {
                    v_location := {
                        v_gnInd.msgIn.gnPacket.packet.payload.decodedPayload.btpPacket.payload.decodedPayload.camPacket.cam.camParameters.basicContainer.referencePosition.latitude,
                        v_gnInd.msgIn.gnPacket.packet.payload.decodedPayload.btpPacket.payload.decodedPayload.camPacket.cam.camParameters.basicContainer.referencePosition.longitude,
                        int2oct(v_gnInd.msgIn.gnPacket.packet.payload.decodedPayload.btpPacket.payload.decodedPayload.camPacket.cam.camParameters.basicContainer.referencePosition.altitude.altitudeValue, 2)
                    };
                }
                v_stationID := v_gnInd.msgIn.gnPacket.packet.payload.decodedPayload.btpPacket.payload.decodedPayload.camPacket.header.stationID;
                
                // Check if it already processed
                v_notProcessed := false;
                for (v_idx := 0; v_idx < 10 and v_vehicles[v_idx].stationId != 0; v_idx := v_idx + 1) { // FIXME Use a PIXIT
                v_notProcessed := true;
                for (v_idx := 0; v_idx < SIMULTANEOUS_VEHICLE_NUM and v_vehicles[v_idx].stationId != 0; v_idx := v_idx + 1) { 
                    if (v_vehicles[v_idx].stationId == v_stationID) {
                        v_notProcessed := not(v_vehicles[v_idx].detected);
                        break;
                    }
                } // End of 'for' statement
                if (v_vehicles[v_idx].stationId == 0) { // FIXME Use a PIXIT
                    v_vehicles[v_vehiclesIdx].stationId := v_stationID;
                    v_vehiclesIdx := v_vehiclesIdx + 1;
                } else if (v_idx == 10) {
                if (v_idx < SIMULTANEOUS_VEHICLE_NUM) {
                    v_vehicles[v_idx].stationId := v_stationID;
                } else if (v_idx == SIMULTANEOUS_VEHICLE_NUM) {
                    log("*** " & testcasename() & ": ERROR: Increase the size of the file ***");
                    stop;
                }
                v_isInDetectionZone := f_isLocationInsideRectangularRegion(c_detectionArea, v_location);
                log("v_idx:               ", v_idx);
                log("v_vehicles[v_idx]:   ", v_vehicles[v_idx]);
                log("v_notProcessed:      ", v_notProcessed);
                log("v_isInDetectionZone: ", v_isInDetectionZone);
                if (v_notProcessed == true) { // Vehicle not processed yet                    
                    if (v_isInDetectionZone == true) { // Check if it entered into the rectangular area
                        if (v_vehicles[v_idx].detectionCounter == 0) { // First detection, wait one CAM to confrm detection
                            // Prepare component
                            v_vehicles[v_idx].detectionCounter := 1;
                            v_vehicles[v_idx].component_ := ItsRSUsSimulator.create("Node" & int2char(v_vehiclesIdx + 65)) alive;
                            v_vehicles[v_idx].detectionCounter := v_vehicles[v_idx].detectionCounter + 1;
                            v_vehicles[v_idx].component_ := ItsRSUsSimulator.create("Node" & int2char(v_idx + 65)) alive;
                            // Wait next message in detection area
                        } else {
                            log("*** " & testcasename() & ": DEBUG: StationID: " & int2str(v_stationID) & " is entering in area ***");
                            v_vehicles[v_idx].detectionCounter := 0;
                            v_vehicles[v_idx].detected := true;
                            v_vehicles[v_idx].component_.start(f_startVehicleSimulator(v_vehicles[v_idx].component_, v_idx, v_gnInd.msgIn.gnPacket.packet.payload.decodedPayload.btpPacket.payload.decodedPayload.camPacket));
                        }
                    } else {
                        // Nothing to do
                        log("*** " & testcasename() & ": DEBUG: StationID: " & int2str(v_stationID) & " is outside of area ***");
//                        log("*** " & testcasename() & ": DEBUG: StationID: " & int2str(v_stationID) & " is outside of area ***");
                        v_vehicles[v_idx].detectionCounter := 0;
                        v_vehicles[v_idx].detected := false;
                        //v_vehicles[v_idx].stationId := 0;
                    }
                } else if (v_isInDetectionZone == false) {
                    if (v_vehicles[v_idx].detected == true) { // Remove station if from v_stationIDs
                        log("*** " & testcasename() & ": DEBUG: Suspend stationID: " & int2str(v_stationID) & " ***");
                        log("*** " & testcasename() & ": DEBUG: Remove stationID: " & int2str(v_stationID) & " ***");
                        v_vehicles[v_idx].detectionCounter := 0;
                        v_vehicles[v_idx].detected := false;
                        //v_vehicles[v_idx].stationId := 0;
                        v_vehicles[v_idx].component_.kill;
                    } // else Nothing to do
                    } else {
                        v_vehicles[v_idx].detectionCounter := 0;
                        v_vehicles[v_idx].detected := false;
                        //v_vehicles[v_idx].stationId := 0;
                    }
                } else {
                    // Nothing to do
                    log("*** " & testcasename() & ": DEBUG: StationID: " & int2str(v_stationID) & " already processed ***");
//                    log("*** " & testcasename() & ": DEBUG: StationID: " & int2str(v_stationID) & " already processed ***");
                }
                tc_ac.start;
                repeat;
            }
            [] cfPort.receive(CfEvent:?) -> value v_cfEvent {
                //log("*** " & testcasename() & ": DEBUG: Configuration port command:", v_cfEvent, " ***");
                if (f_process_cf_event(v_cfEvent) == true) {
                    repeat;
                }
            /*[] cfPort.receive {
                tc_cam.stop;
                all component.stop;
            }
            }*/
            [] tc_ac.timeout {
                log("*** " & testcasename() & ": DEBUG: No CAM message received ***");
                all component.stop;
@@ -283,7 +296,7 @@ module ItsRSUsSimulator_TestCases {
        
        // Postamble
        for (v_idx := 0; v_idx < lengthof(v_vehicles); v_idx := v_idx + 1) {
            v_vehicles[v_vehiclesIdx].component_.kill;
            v_vehicles[v_idx].component_.kill;
        } // End of 'for' statement
        ItsRSUsSimulator_Functions.f_cf01Down();
        
@@ -302,11 +315,12 @@ module ItsRSUsSimulator_TestCases {
            var GeoNetworkingInd v_gnInd;
            var template (value) CAM v_camSimu;
            var ThreeDLocation v_location;
            var boolean v_inArea;
            
            //log("*** " & testcasename() & ": DEBUG: >>> f_startVehicleSimulator: " & int2str(p_camVehicle.header.stationID) & " ***");
            f_initialiseVehicleSimulatorComponent(p_component, p_vehicleIndex, v_camSimu);
            
            tc_cam.start;
            tc_wait.start;
            geoNetworkingPort.clear;
            alt {
                [] geoNetworkingPort.receive(
                    mw_geoNwInd(
@@ -319,29 +333,38 @@ module ItsRSUsSimulator_TestCases {
                                    -,
                                    p_camVehicle.header.stationID
                ))))) -> value v_gnInd { // Receive a CAM message from the processed vehicle
                    tc_cam.stop;
                    tc_wait.stop;
//                    log("*** " & testcasename() & ": DEBUG: Processing CAM #" & int2str(p_camVehicle.header.stationID) & " ***");
                    if (PICS_USE_SPV == true) {
                        v_location := {
                            v_gnInd.msgIn.gnPacket.packet.extendedHeader.shbHeader.srcPosVector.latitude,
                            v_gnInd.msgIn.gnPacket.packet.extendedHeader.shbHeader.srcPosVector.longitude,
                        int2oct(0, 2)
//                        v_gnInd.msgIn.gnPacket.packet.payload.decodedPayload.btpPacket.payload.decodedPayload.camPacket.cam.camParameters.basicContainer.referencePosition.latitude,
//                        v_gnInd.msgIn.gnPacket.packet.payload.decodedPayload.btpPacket.payload.decodedPayload.camPacket.cam.camParameters.basicContainer.referencePosition.longitude,
//                        int2oct(v_gnInd.msgIn.gnPacket.packet.payload.decodedPayload.btpPacket.payload.decodedPayload.camPacket.cam.camParameters.basicContainer.referencePosition.altitude.altitudeValue, 2)
                            '0000'O
                        };
                    } else {
                        v_location := {
                            v_gnInd.msgIn.gnPacket.packet.payload.decodedPayload.btpPacket.payload.decodedPayload.camPacket.cam.camParameters.basicContainer.referencePosition.latitude,
                            v_gnInd.msgIn.gnPacket.packet.payload.decodedPayload.btpPacket.payload.decodedPayload.camPacket.cam.camParameters.basicContainer.referencePosition.longitude,
                            int2oct(v_gnInd.msgIn.gnPacket.packet.payload.decodedPayload.btpPacket.payload.decodedPayload.camPacket.cam.camParameters.basicContainer.referencePosition.altitude.altitudeValue, 2)
                        };
                    }
                    f_mirror_and_send_vehicle_cam(v_camSimu, v_gnInd.msgIn.gnPacket.packet.payload.decodedPayload.btpPacket.payload.decodedPayload.camPacket, v_location/*To ne removed*/);
                    // Check if the behicule leave the area
                    if (f_isLocationInsideRectangularRegion(c_detectionArea, v_location) == true) {
                        tc_cam.start;
                    v_inArea := f_isLocationInsideRectangularRegion(c_detectionArea, v_location);
                    log("*** " & testcasename() & ": DEBUG: In area: ", v_inArea, " ***");
                    if (v_inArea == true) {
                        tc_wait.start;
                        repeat;
                    } else {
                        log("*** " & testcasename() & ": PASS: Terminate component for #" & int2str(p_camVehicle.header.stationID) & " ***");
                        f_setVerdict(e_success);
                    }
                }
                [] cfPort.receive {
                    tc_cam.stop;
                /*[] cfPort.receive {
                    tc_wait.stop;
                    repeat;
                }
                [] tc_cam.timeout {
                }*/
                [] tc_wait.timeout {
                    log("*** " & testcasename() & ": DEBUG: No CAM message received ***");
                }
            } // End of 'altstep' statement