package vnsim.vehicular.routePlan.cityRouting; import vnsim.applications.trafficview.SimulatedCarInfo; import vnsim.applications.vitp.CarRunningVITP; import vnsim.map.object.Globals; import vnsim.vehicular.simulator.CarInstance; public class CarToIntersectionComm { // if the car has computed the average speed on a segment route // broadcast a packet to IntersectionNode public static void updateMetrics(CarInstance car) { double avgSpeed = car.getAvgSpeed(); if (avgSpeed < 0) { // average speed is positive once per segment return; } int nTLCycles = car.getTLCycles(); int segmentIndex = car.getSegmentIndex(); SimulatedCarInfo myCar = Globals.engine.getCarIdx(car.ID); if (myCar != null && !(myCar instanceof IntersectionNode)) { ((CarRunningVITP) myCar).broadcastRoadPacket("RM " + car.ID + " " + avgSpeed + " " + nTLCycles + " " + segmentIndex); } } }