source: proiecte/ptvs/src/vnsim/vehicular/routePlan/cityRouting/CarToIntersectionComm.java @ 31

Last change on this file since 31 was 31, checked in by (none), 14 years ago
File size: 923 bytes
Line 
1package vnsim.vehicular.routePlan.cityRouting;
2
3import vnsim.applications.trafficview.SimulatedCarInfo;
4import vnsim.applications.vitp.CarRunningVITP;
5import vnsim.map.object.Globals;
6import vnsim.vehicular.simulator.CarInstance;
7
8public 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.