Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DynamicVehicleRouting/HeuristicLab.PDPSimulation/3.3/VehicleHistoryVisualization.cs @ 10194

Last change on this file since 10194 was 8670, checked in by svonolfe, 12 years ago

Added first version of the dynamic vehicle routing addon (#1955)

File size: 3.3 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using HeuristicLab.PDPSimulation.DomainModel;
6using HeuristicLab.Core;
7using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
8using HeuristicLab.Common;
9
10namespace HeuristicLab.PDPSimulation {
11  [StorableClass]
12  public class VehicleHistory: Item {
13    [Storable]
14    public string VehicleName { get; private set; }
15    [Storable]
16    public List<VehicleState> VehicleState { get; private set; }
17    [Storable]
18    public List<int> VehicleAvailability { get; private set; }
19    [Storable]
20    public List<string> AvailabilityInformation { get; private set; }
21    [Storable]
22    public List<Order> ActiveOrders { get; private set; }
23    [Storable]
24    public List<Order> AssignedOrders { get; private set; }
25
26    public VehicleHistory(string vehicleName) {
27      VehicleName = vehicleName;
28      VehicleState = new List<VehicleState>();
29      VehicleAvailability = new List<int>();
30      AvailabilityInformation = new List<string>();
31      ActiveOrders = new List<Order>();
32      AssignedOrders = new List<Order>();
33    }
34     [StorableConstructor]
35    private VehicleHistory(bool deserializing) : base(deserializing) {
36    }
37     private VehicleHistory(VehicleHistory original, Cloner cloner)
38      : base(original, cloner) {
39        VehicleName = original.VehicleName;
40        VehicleState = new List<VehicleState>(original.VehicleState);
41        AvailabilityInformation = new List<string>(original.AvailabilityInformation);
42        ActiveOrders = new List<Order>();
43        foreach (Order order in original.ActiveOrders)
44          ActiveOrders.Add(cloner.Clone<Order>(order));
45        AssignedOrders = new List<Order>();
46        foreach (Order order in original.AssignedOrders)
47          AssignedOrders.Add(cloner.Clone<Order>(order));
48        VehicleAvailability = new List<int>();
49        VehicleAvailability.AddRange(original.VehicleAvailability);
50    }
51    public override IDeepCloneable Clone(Cloner cloner) {
52      return new VehicleHistory(this, cloner);
53    }
54  }
55
56  [StorableClass]
57  public class VehicleHistoryVisualization: Item {
58    [Storable]
59    public double ResultCollectionInterval { get; set; }
60   
61    [Storable]
62    public List<VehicleHistory> VehicleHistory { get; private set; }
63
64    public VehicleHistoryVisualization() {
65      VehicleHistory = new List<VehicleHistory>();
66      ResultCollectionInterval = 1.0;
67    }
68    [StorableConstructor]
69    protected VehicleHistoryVisualization(bool deserializing) : base(deserializing) {
70    }
71    protected VehicleHistoryVisualization(VehicleHistoryVisualization original, Cloner cloner)
72      : base(original, cloner) {
73        VehicleHistory = new List<VehicleHistory>();
74        foreach (VehicleHistory history in original.VehicleHistory) {
75          VehicleHistory.Add(cloner.Clone<VehicleHistory>(history));
76        }
77    }
78    public override IDeepCloneable Clone(Cloner cloner) {
79      return new VehicleHistoryVisualization(this, cloner);
80    }
81    public event EventHandler ContentChanged;
82    private void OnContentChanged() {
83      var changed = ContentChanged;
84      if (changed != null)
85        changed(this, EventArgs.Empty);
86    }
87
88    public void Refresh() {
89      OnContentChanged();
90    }
91  }
92}
Note: See TracBrowser for help on using the repository browser.