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

Finalise UC6

parent 365ab4fc
...@@ -60,12 +60,21 @@ module ItsRSUsSimulator_Functions { ...@@ -60,12 +60,21 @@ module ItsRSUsSimulator_Functions {
group externalFunctions { 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( external function fx_computePositionFromRotation(
in Int32 p_refLatitude, in Int32 p_refLatitude,
in Int32 p_refLongitude, in Int32 p_refLongitude,
in Int32 p_cenLatitude, in Int32 p_cenLatitude,
in Int32 p_cenLongitude, in Int32 p_cenLongitude,
in float p_rotation, in Int32 p_rotation,
out Int32 p_latitude, out Int32 p_latitude,
out Int32 p_longitude out Int32 p_longitude
); );
...@@ -88,7 +97,7 @@ module ItsRSUsSimulator_Functions { ...@@ -88,7 +97,7 @@ module ItsRSUsSimulator_Functions {
// Map // Map
map(self:acPort, system:acPort); map(self:acPort, system:acPort);
map(self:cfPort, system:cfPort); //map(self:cfPort, system:cfPort);
map(self:geoNetworkingPort, system:geoNetworkingPort); map(self:geoNetworkingPort, system:geoNetworkingPort);
// Connect // Connect
...@@ -99,7 +108,7 @@ module ItsRSUsSimulator_Functions { ...@@ -99,7 +108,7 @@ module ItsRSUsSimulator_Functions {
f_initialiseSecuredMode(); f_initialiseSecuredMode();
//Initialze the Config module //Initialze the Config module
cfPort.send(CfInitialize:{}); //cfPort.send(CfInitialize:{});
// Initialisations // Initialisations
f_setup_rsu(vc_rsu_id); f_setup_rsu(vc_rsu_id);
...@@ -114,7 +123,7 @@ module ItsRSUsSimulator_Functions { ...@@ -114,7 +123,7 @@ module ItsRSUsSimulator_Functions {
// Unmap // Unmap
unmap(self:acPort, system:acPort); unmap(self:acPort, system:acPort);
unmap(self:cfPort, system:cfPort); //unmap(self:cfPort, system:cfPort);
unmap(self:geoNetworkingPort, system:geoNetworkingPort); unmap(self:geoNetworkingPort, system:geoNetworkingPort);
// Disconnect // Disconnect
...@@ -652,17 +661,29 @@ module ItsRSUsSimulator_Functions { ...@@ -652,17 +661,29 @@ module ItsRSUsSimulator_Functions {
var template (value) Payload v_payload; var template (value) Payload v_payload;
// Apply 90° rotation // Apply 90° rotation
fx_computePositionFromRotation( if (PICS_USE_SPV == true) {
p_location.latitude, fx_computePositionFromRotation(
p_location.longitude, p_location.latitude,
// p_camVehicle.cam.camParameters.basicContainer.referencePosition.latitude, p_location.longitude,
// p_camVehicle.cam.camParameters.basicContainer.referencePosition.longitude, PICS_UC6_COLLISION_POINT.latitude,
PICS_UC6_COLLISION_POINT.latitude, PICS_UC6_COLLISION_POINT.longitude,
PICS_UC6_COLLISION_POINT.longitude, 900,
-90.0, v_newPosition.latitude,
v_newPosition.latitude, v_newPosition.longitude
v_newPosition.longitude); );
log("Rotation: (", p_location.latitude, ", ", p_location.longitude, ") --> (", v_newPosition.latitude, ", ", 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.latitude := ;
v_newPosition.longitude := ;*/ v_newPosition.longitude := ;*/
// Update CAM // Update CAM
......
...@@ -425,6 +425,8 @@ module ItsRSUsSimulator_Pics { ...@@ -425,6 +425,8 @@ module ItsRSUsSimulator_Pics {
group camUseCase6 { group camUseCase6 {
modulepar integer SIMULTANEOUS_VEHICLE_NUM := 10;
group camUseCase6VehicleTemplateDescription { group camUseCase6VehicleTemplateDescription {
modulepar LongPosVector PICS_UC6_VEHICLE_TEMPLATE_POSITION := { modulepar LongPosVector PICS_UC6_VEHICLE_TEMPLATE_POSITION := {
...@@ -453,6 +455,8 @@ module ItsRSUsSimulator_Pics { ...@@ -453,6 +455,8 @@ module ItsRSUsSimulator_Pics {
} }
} // End of PICS_UC6_VEHICLE_GEOAREA } // End of PICS_UC6_VEHICLE_GEOAREA
modulepar boolean PICS_USE_SPV := true;
} // End of group camUseCase6VehicleDescription } // End of group camUseCase6VehicleDescription
group camUseCase6SyncLocation { group camUseCase6SyncLocation {
......
...@@ -97,12 +97,12 @@ module ItsRSUsSimulator_TestCases { ...@@ -97,12 +97,12 @@ module ItsRSUsSimulator_TestCases {
// Nothing to do, just for logging purposes // Nothing to do, just for logging purposes
repeat; repeat;
} }
[] cfPort.receive(CfEvent:?) -> value v_cfEvent { /*[] cfPort.receive(CfEvent:?) -> value v_cfEvent {
//log("*** " & testcasename() & ": DEBUG: Configuration port command:", v_cfEvent, " ***"); //log("*** " & testcasename() & ": DEBUG: Configuration port command:", v_cfEvent, " ***");
if (f_process_cf_event(v_cfEvent) == true) { if (f_process_cf_event(v_cfEvent) == true) {
repeat; repeat;
} }
} }*/
[vc_beacon == true] tc_beacon.timeout { [vc_beacon == true] tc_beacon.timeout {
//log("*** " & testcasename() & ": DEBUG: Processing BEACON ***"); //log("*** " & testcasename() & ": DEBUG: Processing BEACON ***");
f_prepare_beacon(v_payload); f_prepare_beacon(v_payload);
...@@ -171,7 +171,6 @@ module ItsRSUsSimulator_TestCases { ...@@ -171,7 +171,6 @@ module ItsRSUsSimulator_TestCases {
// Local variables // Local variables
const RectangularRegions c_detectionArea := { PICS_UC6_CAM_DETECTION_AREA }; const RectangularRegions c_detectionArea := { PICS_UC6_CAM_DETECTION_AREA };
var VehiclesSimulator v_vehicles := {}; var VehiclesSimulator v_vehicles := {};
var integer v_vehiclesIdx := 0;
var integer v_stationID; var integer v_stationID;
var boolean v_isInDetectionZone; var boolean v_isInDetectionZone;
var boolean v_notProcessed; var boolean v_notProcessed;
...@@ -191,7 +190,7 @@ module ItsRSUsSimulator_TestCases { ...@@ -191,7 +190,7 @@ module ItsRSUsSimulator_TestCases {
// Test adapter configuration // Test adapter configuration
// Preamble // 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].detected := false;
v_vehicles[v_idx].detectionCounter := 0; v_vehicles[v_idx].detectionCounter := 0;
v_vehicles[v_idx].stationId := 0; v_vehicles[v_idx].stationId := 0;
...@@ -211,69 +210,83 @@ module ItsRSUsSimulator_TestCases { ...@@ -211,69 +210,83 @@ module ItsRSUsSimulator_TestCases {
e_btpB e_btpB
)))) -> value v_gnInd { // Receive a CAM message )))) -> value v_gnInd { // Receive a CAM message
tc_ac.stop; tc_ac.stop;
v_location := { if (PICS_USE_SPV == true) {
v_gnInd.msgIn.gnPacket.packet.extendedHeader.shbHeader.srcPosVector.latitude, v_location := {
v_gnInd.msgIn.gnPacket.packet.extendedHeader.shbHeader.srcPosVector.longitude, v_gnInd.msgIn.gnPacket.packet.extendedHeader.shbHeader.srcPosVector.latitude,
int2oct(0, 2) v_gnInd.msgIn.gnPacket.packet.extendedHeader.shbHeader.srcPosVector.longitude,
// v_gnInd.msgIn.gnPacket.packet.payload.decodedPayload.btpPacket.payload.decodedPayload.camPacket.cam.camParameters.basicContainer.referencePosition.latitude, '0000'O
// 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) } 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; v_stationID := v_gnInd.msgIn.gnPacket.packet.payload.decodedPayload.btpPacket.payload.decodedPayload.camPacket.header.stationID;
// Check if it already processed // Check if it already processed
v_notProcessed := false; v_notProcessed := true;
for (v_idx := 0; v_idx < 10 and v_vehicles[v_idx].stationId != 0; v_idx := v_idx + 1) { // FIXME Use a PIXIT 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) { if (v_vehicles[v_idx].stationId == v_stationID) {
v_notProcessed := not(v_vehicles[v_idx].detected); v_notProcessed := not(v_vehicles[v_idx].detected);
break; break;
} }
} // End of 'for' statement } // End of 'for' statement
if (v_vehicles[v_idx].stationId == 0) { // FIXME Use a PIXIT if (v_idx < SIMULTANEOUS_VEHICLE_NUM) {
v_vehicles[v_vehiclesIdx].stationId := v_stationID; v_vehicles[v_idx].stationId := v_stationID;
v_vehiclesIdx := v_vehiclesIdx + 1; } else if (v_idx == SIMULTANEOUS_VEHICLE_NUM) {
} else if (v_idx == 10) {
log("*** " & testcasename() & ": ERROR: Increase the size of the file ***"); log("*** " & testcasename() & ": ERROR: Increase the size of the file ***");
stop; stop;
} }
v_isInDetectionZone := f_isLocationInsideRectangularRegion(c_detectionArea, v_location); 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_notProcessed == true) { // Vehicle not processed yet
if (v_isInDetectionZone == true) { // Check if it entered into the rectangular area 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 if (v_vehicles[v_idx].detectionCounter == 0) { // First detection, wait one CAM to confrm detection
// Prepare component // Prepare component
v_vehicles[v_idx].detectionCounter := 1; v_vehicles[v_idx].detectionCounter := v_vehicles[v_idx].detectionCounter + 1;
v_vehicles[v_idx].component_ := ItsRSUsSimulator.create("Node" & int2char(v_vehiclesIdx + 65)) alive; v_vehicles[v_idx].component_ := ItsRSUsSimulator.create("Node" & int2char(v_idx + 65)) alive;
// Wait next message in detection area // Wait next message in detection area
} else { } else {
log("*** " & testcasename() & ": DEBUG: StationID: " & int2str(v_stationID) & " is entering in area ***");
v_vehicles[v_idx].detectionCounter := 0; v_vehicles[v_idx].detectionCounter := 0;
v_vehicles[v_idx].detected := true; 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)); 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 { } else {
// Nothing to do // 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) { } else if (v_isInDetectionZone == false) {
if (v_vehicles[v_idx].detected == true) { // Remove station if from v_stationIDs 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].detectionCounter := 0;
v_vehicles[v_idx].detected := false; v_vehicles[v_idx].detected := false;
//v_vehicles[v_idx].stationId := 0;
v_vehicles[v_idx].component_.kill; 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 { } else {
// Nothing to do // Nothing to do
log("*** " & testcasename() & ": DEBUG: StationID: " & int2str(v_stationID) & " already processed ***"); // log("*** " & testcasename() & ": DEBUG: StationID: " & int2str(v_stationID) & " already processed ***");
} }
tc_ac.start; tc_ac.start;
repeat; repeat;
} }
[] cfPort.receive(CfEvent:?) -> value v_cfEvent { /*[] cfPort.receive {
//log("*** " & testcasename() & ": DEBUG: Configuration port command:", v_cfEvent, " ***"); tc_cam.stop;
if (f_process_cf_event(v_cfEvent) == true) {
repeat;
}
all component.stop; all component.stop;
} }*/
[] tc_ac.timeout { [] tc_ac.timeout {
log("*** " & testcasename() & ": DEBUG: No CAM message received ***"); log("*** " & testcasename() & ": DEBUG: No CAM message received ***");
all component.stop; all component.stop;
...@@ -283,7 +296,7 @@ module ItsRSUsSimulator_TestCases { ...@@ -283,7 +296,7 @@ module ItsRSUsSimulator_TestCases {
// Postamble // Postamble
for (v_idx := 0; v_idx < lengthof(v_vehicles); v_idx := v_idx + 1) { 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 } // End of 'for' statement
ItsRSUsSimulator_Functions.f_cf01Down(); ItsRSUsSimulator_Functions.f_cf01Down();
...@@ -302,11 +315,12 @@ module ItsRSUsSimulator_TestCases { ...@@ -302,11 +315,12 @@ module ItsRSUsSimulator_TestCases {
var GeoNetworkingInd v_gnInd; var GeoNetworkingInd v_gnInd;
var template (value) CAM v_camSimu; var template (value) CAM v_camSimu;
var ThreeDLocation v_location; 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); f_initialiseVehicleSimulatorComponent(p_component, p_vehicleIndex, v_camSimu);
tc_cam.start; tc_wait.start;
geoNetworkingPort.clear;
alt { alt {
[] geoNetworkingPort.receive( [] geoNetworkingPort.receive(
mw_geoNwInd( mw_geoNwInd(
...@@ -319,29 +333,38 @@ module ItsRSUsSimulator_TestCases { ...@@ -319,29 +333,38 @@ module ItsRSUsSimulator_TestCases {
-, -,
p_camVehicle.header.stationID p_camVehicle.header.stationID
))))) -> value v_gnInd { // Receive a CAM message from the processed vehicle ))))) -> value v_gnInd { // Receive a CAM message from the processed vehicle
tc_cam.stop; tc_wait.stop;
v_location := { // log("*** " & testcasename() & ": DEBUG: Processing CAM #" & int2str(p_camVehicle.header.stationID) & " ***");
v_gnInd.msgIn.gnPacket.packet.extendedHeader.shbHeader.srcPosVector.latitude, if (PICS_USE_SPV == true) {
v_gnInd.msgIn.gnPacket.packet.extendedHeader.shbHeader.srcPosVector.longitude, v_location := {
int2oct(0, 2) v_gnInd.msgIn.gnPacket.packet.extendedHeader.shbHeader.srcPosVector.latitude,
// v_gnInd.msgIn.gnPacket.packet.payload.decodedPayload.btpPacket.payload.decodedPayload.camPacket.cam.camParameters.basicContainer.referencePosition.latitude, v_gnInd.msgIn.gnPacket.packet.extendedHeader.shbHeader.srcPosVector.longitude,
// v_gnInd.msgIn.gnPacket.packet.payload.decodedPayload.btpPacket.payload.decodedPayload.camPacket.cam.camParameters.basicContainer.referencePosition.longitude, '0000'O
// int2oct(v_gnInd.msgIn.gnPacket.packet.payload.decodedPayload.btpPacket.payload.decodedPayload.camPacket.cam.camParameters.basicContainer.referencePosition.altitude.altitudeValue, 2) };
}; } 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*/); 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 // Check if the behicule leave the area
if (f_isLocationInsideRectangularRegion(c_detectionArea, v_location) == true) { v_inArea := f_isLocationInsideRectangularRegion(c_detectionArea, v_location);
tc_cam.start; log("*** " & testcasename() & ": DEBUG: In area: ", v_inArea, " ***");
if (v_inArea == true) {
tc_wait.start;
repeat; repeat;
} else { } else {
log("*** " & testcasename() & ": PASS: Terminate component for #" & int2str(p_camVehicle.header.stationID) & " ***");
f_setVerdict(e_success); f_setVerdict(e_success);
} }
} }
[] cfPort.receive { /*[] cfPort.receive {
tc_cam.stop; tc_wait.stop;
repeat; repeat;
} }*/
[] tc_cam.timeout { [] tc_wait.timeout {
log("*** " & testcasename() & ": DEBUG: No CAM message received ***"); log("*** " & testcasename() & ": DEBUG: No CAM message received ***");
} }
} // End of 'altstep' statement } // End of 'altstep' statement
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment