Line | |
---|
1 | package vnsim.vehicular.routePlan.cityRouting; |
---|
2 | |
---|
3 | import vnsim.applications.trafficview.SimulatedCarInfo; |
---|
4 | import vnsim.applications.vitp.CarRunningVITP; |
---|
5 | import vnsim.map.object.Globals; |
---|
6 | import vnsim.vehicular.simulator.CarInstance; |
---|
7 | |
---|
8 | public class CarToIntersectionComm { |
---|
9 | |
---|
10 | // if the car has computed the average speed on a segment route |
---|
11 | // broadcast a packet to IntersectionNode |
---|
12 | public static void updateMetrics(CarInstance car) { |
---|
13 | double avgSpeed = car.getAvgSpeed(); |
---|
14 | if (avgSpeed < 0) { // average speed is positive once per segment |
---|
15 | return; |
---|
16 | } |
---|
17 | int nTLCycles = car.getTLCycles(); |
---|
18 | int segmentIndex = car.getSegmentIndex(); |
---|
19 | SimulatedCarInfo myCar = Globals.engine.getCarIdx(car.ID); |
---|
20 | if (myCar != null && !(myCar instanceof IntersectionNode)) { |
---|
21 | ((CarRunningVITP) myCar).broadcastRoadPacket("RM " + car.ID + " " |
---|
22 | + avgSpeed + " " + nTLCycles + " " + segmentIndex); |
---|
23 | } |
---|
24 | |
---|
25 | } |
---|
26 | |
---|
27 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.