PageRenderTime 47ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/Exav_V2-branch_logica_v1.0/Model/Datos/Vehiculo.cs

#
C# | 191 lines | 152 code | 27 blank | 12 comment | 0 complexity | 1811db0a20bb39f0e6ba8fc9d4a339df MD5 | raw file
  1. using System;
  2. using System.Net;
  3. using System.Windows;
  4. using System.Windows.Controls;
  5. using System.Windows.Documents;
  6. using System.Windows.Ink;
  7. using System.Windows.Input;
  8. using System.Windows.Media;
  9. using System.Windows.Media.Animation;
  10. using System.Windows.Shapes;
  11. using System.Collections.Generic;
  12. using System.Collections.ObjectModel;
  13. using Model.WS;
  14. namespace Model.Datos
  15. {
  16. public class Vehiculo
  17. {
  18. //private int id;
  19. private string matricula;
  20. //private TimeSpan tiempoMaxUso;
  21. //private TimeSpan tiempoUsoSalida; // tiempo de carga
  22. //private TimeSpan tiempoUsoLlegada; // tiempo de descarga
  23. //private DateTime inicio; // inicio de la disponibilidad
  24. //private DateTime fin; // fin de la disponibilidad
  25. //private TimeSpan tolerancia;
  26. //private Ruta ruta;
  27. //private List<Pedido> pedidos;
  28. //private List<Caracteristicas> caracteristicas;
  29. //private List<Escenario> escenarios;
  30. //private List<Capacidad> capacidades;
  31. private Vehicle veh;
  32. public Vehiculo(int id, string matricula, TimeSpan tiempoMaxUso, TimeSpan tiempoUsoSalida, TimeSpan tiempoUsoLlegada, DateTime inicio, DateTime fin, TimeSpan tolerancia)
  33. {
  34. #region Cargo vehicles
  35. int compartimiento = 1;
  36. veh = new Vehicle();
  37. Compartment comp = new Compartment();
  38. comp.capacities = new Dictionary<string, object>();
  39. comp.characteristics = new Dictionary<int, object>();
  40. comp.code = compartimiento;
  41. compartimiento = compartimiento + 1;
  42. veh.compartments = new List<object>();
  43. veh.compartments.Add(comp);
  44. veh.arrivalTime = tiempoUsoLlegada;
  45. veh.departureTime = tiempoUsoSalida;
  46. veh.maxUsage = tiempoMaxUso;
  47. veh.timeWindows = new Dictionary<int, List<object>>();
  48. List<object> listaTiempo = new List<object>();
  49. TimeWindow t = new TimeWindow()
  50. {
  51. code = 1,
  52. startingTime = inicio,
  53. endingTime = fin
  54. };
  55. listaTiempo.Add(t);
  56. veh.timeWindows.Add(1, listaTiempo);
  57. veh.maxWaitingTime = tolerancia;
  58. veh.code = id;
  59. #endregion
  60. this.matricula = matricula;
  61. }
  62. public void sacarCaracteristica(Caracteristicas c)
  63. {
  64. ((Compartment)veh.compartments[0]).characteristics.Remove(c.Id);
  65. }
  66. public void agregarCaracteristica(Caracteristicas c)
  67. {
  68. ((Compartment)veh.compartments[0]).characteristics.Add(c.Id, c.Car);
  69. }
  70. public void sacarCapacidades(Capacidad c)
  71. {
  72. ((Compartment)veh.compartments[0]).capacities.Remove(c.Cap.code);
  73. }
  74. public void agregarCapacidades(Capacidad c)
  75. {
  76. ((Compartment)veh.compartments[0]).capacities.Add(c.Cap.code, c.Cap);
  77. }
  78. public List<Caracteristicas> Caracteristicas
  79. {
  80. get
  81. {
  82. List<Caracteristicas> lista = new List<Caracteristicas>();
  83. Model.Manejadores.MCaracteristica MC = Model.Manejadores.MCaracteristica.getInstance();
  84. foreach (var item in ((Compartment)veh.compartments[0]).characteristics)
  85. {
  86. lista.Add(new Caracteristicas(item.Key, MC.getCaracteristica(item.Key).Nombre));
  87. }
  88. return lista;
  89. }
  90. set
  91. {
  92. foreach (var item in value)
  93. {
  94. ((Compartment)veh.compartments[0]).characteristics.Add(item.Id, item.Car);
  95. }
  96. }
  97. }
  98. public List<Capacidad> Capacidades
  99. {
  100. get
  101. {
  102. List<Capacidad> lista = new List<Capacidad>();
  103. Model.Manejadores.MCapacidad MC = Model.Manejadores.MCapacidad.getInstance();
  104. foreach (var item in ((Compartment)veh.compartments[0]).capacities)
  105. {
  106. lista.Add(new Capacidad(MC.getCapacidad(item.Key).IdCapacidad, ((Capacity)item.Value).value, ((Capacity)item.Value).name));
  107. }
  108. return lista;
  109. }
  110. set
  111. {
  112. foreach (var item in value)
  113. {
  114. ((Compartment)veh.compartments[0]).capacities.Add(item.Cap.code, item.Cap);
  115. }
  116. }
  117. }
  118. public int Id
  119. {
  120. get { return veh.code; }
  121. set { veh.code = value; }
  122. }
  123. public TimeSpan TiempoMaxUso
  124. {
  125. get { return veh.maxDuration; }
  126. set { veh.maxDuration = value; }
  127. }
  128. public DateTime Inicio
  129. {
  130. get { return ((TimeWindow)veh.timeWindows[1][0]).startingTime; }
  131. set { ((TimeWindow)veh.timeWindows[1][0]).startingTime = value; }
  132. }
  133. public DateTime Fin
  134. {
  135. get { return ((TimeWindow)veh.timeWindows[1][0]).endingTime; }
  136. set { ((TimeWindow)veh.timeWindows[1][0]).endingTime = value; }
  137. }
  138. public TimeSpan Tolerancia
  139. {
  140. get { return veh.maxWaitingTime; }
  141. set { veh.maxWaitingTime = value; }
  142. }
  143. public TimeSpan TiempoUsoSalida
  144. {
  145. get { return veh.departureTime; }
  146. set { veh.departureTime = value; }
  147. }
  148. public TimeSpan TiempoUsoLlegada
  149. {
  150. get { return veh.arrivalTime; }
  151. set { veh.arrivalTime = value; }
  152. }
  153. public string Matricula
  154. {
  155. get { return matricula; }
  156. set { matricula = value; }
  157. }
  158. internal Vehicle Veh
  159. {
  160. get { return veh; }
  161. set { veh = value; }
  162. }
  163. }
  164. }