1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using HeuristicLab.PDPSimulation.DomainModel;
|
---|
6 | using HeuristicLab.Core;
|
---|
7 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
8 | using HeuristicLab.Common;
|
---|
9 |
|
---|
10 | namespace 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 | }
|
---|