/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
- using System;
- using System.Net;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Documents;
- using System.Windows.Ink;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Animation;
- using System.Windows.Shapes;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using Model.WS;
-
- namespace Model.Datos
- {
- public class Vehiculo
- {
- //private int id;
- private string matricula;
- //private TimeSpan tiempoMaxUso;
- //private TimeSpan tiempoUsoSalida; // tiempo de carga
- //private TimeSpan tiempoUsoLlegada; // tiempo de descarga
- //private DateTime inicio; // inicio de la disponibilidad
- //private DateTime fin; // fin de la disponibilidad
- //private TimeSpan tolerancia;
- //private Ruta ruta;
-
- //private List<Pedido> pedidos;
- //private List<Caracteristicas> caracteristicas;
- //private List<Escenario> escenarios;
- //private List<Capacidad> capacidades;
- private Vehicle veh;
-
- public Vehiculo(int id, string matricula, TimeSpan tiempoMaxUso, TimeSpan tiempoUsoSalida, TimeSpan tiempoUsoLlegada, DateTime inicio, DateTime fin, TimeSpan tolerancia)
- {
- #region Cargo vehicles
- int compartimiento = 1;
- veh = new Vehicle();
-
- Compartment comp = new Compartment();
- comp.capacities = new Dictionary<string, object>();
- comp.characteristics = new Dictionary<int, object>();
- comp.code = compartimiento;
- compartimiento = compartimiento + 1;
-
- veh.compartments = new List<object>();
- veh.compartments.Add(comp);
-
- veh.arrivalTime = tiempoUsoLlegada;
- veh.departureTime = tiempoUsoSalida;
- veh.maxUsage = tiempoMaxUso;
-
- veh.timeWindows = new Dictionary<int, List<object>>();
- List<object> listaTiempo = new List<object>();
- TimeWindow t = new TimeWindow()
- {
- code = 1,
- startingTime = inicio,
- endingTime = fin
- };
- listaTiempo.Add(t);
- veh.timeWindows.Add(1, listaTiempo);
-
- veh.maxWaitingTime = tolerancia;
-
- veh.code = id;
- #endregion
-
- this.matricula = matricula;
- }
-
- public void sacarCaracteristica(Caracteristicas c)
- {
- ((Compartment)veh.compartments[0]).characteristics.Remove(c.Id);
- }
-
- public void agregarCaracteristica(Caracteristicas c)
- {
- ((Compartment)veh.compartments[0]).characteristics.Add(c.Id, c.Car);
- }
-
- public void sacarCapacidades(Capacidad c)
- {
- ((Compartment)veh.compartments[0]).capacities.Remove(c.Cap.code);
- }
-
- public void agregarCapacidades(Capacidad c)
- {
- ((Compartment)veh.compartments[0]).capacities.Add(c.Cap.code, c.Cap);
- }
-
- public List<Caracteristicas> Caracteristicas
- {
- get
- {
- List<Caracteristicas> lista = new List<Caracteristicas>();
- Model.Manejadores.MCaracteristica MC = Model.Manejadores.MCaracteristica.getInstance();
- foreach (var item in ((Compartment)veh.compartments[0]).characteristics)
- {
- lista.Add(new Caracteristicas(item.Key, MC.getCaracteristica(item.Key).Nombre));
- }
-
- return lista;
- }
- set
- {
- foreach (var item in value)
- {
- ((Compartment)veh.compartments[0]).characteristics.Add(item.Id, item.Car);
- }
- }
- }
-
- public List<Capacidad> Capacidades
- {
- get
- {
- List<Capacidad> lista = new List<Capacidad>();
- Model.Manejadores.MCapacidad MC = Model.Manejadores.MCapacidad.getInstance();
- foreach (var item in ((Compartment)veh.compartments[0]).capacities)
- {
- lista.Add(new Capacidad(MC.getCapacidad(item.Key).IdCapacidad, ((Capacity)item.Value).value, ((Capacity)item.Value).name));
- }
-
- return lista;
- }
- set
- {
- foreach (var item in value)
- {
- ((Compartment)veh.compartments[0]).capacities.Add(item.Cap.code, item.Cap);
- }
- }
- }
-
- public int Id
- {
- get { return veh.code; }
- set { veh.code = value; }
- }
-
- public TimeSpan TiempoMaxUso
- {
- get { return veh.maxDuration; }
- set { veh.maxDuration = value; }
- }
-
- public DateTime Inicio
- {
- get { return ((TimeWindow)veh.timeWindows[1][0]).startingTime; }
- set { ((TimeWindow)veh.timeWindows[1][0]).startingTime = value; }
- }
-
- public DateTime Fin
- {
- get { return ((TimeWindow)veh.timeWindows[1][0]).endingTime; }
- set { ((TimeWindow)veh.timeWindows[1][0]).endingTime = value; }
- }
-
- public TimeSpan Tolerancia
- {
- get { return veh.maxWaitingTime; }
- set { veh.maxWaitingTime = value; }
- }
-
- public TimeSpan TiempoUsoSalida
- {
- get { return veh.departureTime; }
- set { veh.departureTime = value; }
- }
-
- public TimeSpan TiempoUsoLlegada
- {
- get { return veh.arrivalTime; }
- set { veh.arrivalTime = value; }
- }
-
- public string Matricula
- {
- get { return matricula; }
- set { matricula = value; }
- }
-
- internal Vehicle Veh
- {
- get { return veh; }
- set { veh = value; }
- }
- }
- }