[31] | 1 | package vnsim.vehicular.routePlan.cityRouting; |
---|
| 2 | |
---|
| 3 | import vnsim.applications.adaptiveTL.WirelessTrafficLight; |
---|
| 4 | import vnsim.map.object.Globals; |
---|
| 5 | import vnsim.vehicular.simulator.intersections.DirectedRoadSegment; |
---|
| 6 | import vnsim.vehicular.simulator.intersections.Intersection; |
---|
| 7 | |
---|
| 8 | public class RoadSegmentCost { |
---|
| 9 | |
---|
| 10 | private DirectedRoadSegment roadSegment; |
---|
| 11 | private Double segmentCost; |
---|
| 12 | |
---|
| 13 | public RoadSegmentCost(DirectedRoadSegment d) { |
---|
| 14 | roadSegment = d; |
---|
| 15 | segmentCost = new Double(0); |
---|
| 16 | } |
---|
| 17 | |
---|
| 18 | public static void initRoadSegmentsCost() { |
---|
| 19 | int i, j; |
---|
| 20 | Intersection it; |
---|
| 21 | DirectedRoadSegment s; |
---|
| 22 | RoadSegmentCost rsc; |
---|
| 23 | System.out.println("Starting segmentsCost adding"); |
---|
| 24 | for (i = 0; i < Globals.map.allIntersections.size(); i++) { |
---|
| 25 | it = Globals.map.allIntersections.get(i); |
---|
| 26 | if (!(it instanceof WirelessTrafficLight)) { |
---|
| 27 | continue; |
---|
| 28 | } |
---|
| 29 | for (j = 0; j < it.segments.size(); j++) { |
---|
| 30 | s = it.segments.get(j); |
---|
| 31 | rsc = new RoadSegmentCost(s); |
---|
| 32 | if (!Globals.routePlanConstants.segmentsCost.contains(rsc)) { |
---|
| 33 | Globals.routePlanConstants.segmentsCost.add(rsc); |
---|
| 34 | } |
---|
| 35 | } |
---|
| 36 | } |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | public Double getCost() { |
---|
| 40 | return segmentCost; |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | public void setCost(Double cost) { |
---|
| 44 | segmentCost = cost; |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | public boolean equals(RoadSegmentCost r) { |
---|
| 48 | return roadSegment.equals(r.roadSegment); |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | public boolean equals(DirectedRoadSegment r) { |
---|
| 52 | return roadSegment.equals(r); |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | } |
---|