/CapaLogica/LogicaSilverlight/LogicaSilverlight/data/Vehiculo.cs
C# | 216 lines | 186 code | 25 blank | 5 comment | 0 complexity | c83e2429a01e40886509251d65cc6555 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;
-
- namespace LogicaSilverlight.data
- {
- public class Vehiculo
- {
- private int id;
- private string matricula;
- private TimeSpan tiempoMaxUso;
- private TimeSpan tiempoUsoSalida;
- private TimeSpan tiempoUsoLlegada;
- private DateTime inicio;
- private DateTime fin;
- private TimeSpan tolerancia;
-
- private List<Pedido> pedidos;
- private List<Caracteristicas> caracteristicas;
- private List<Escenario> escenarios;
- private List<Capacidad> capacidades;
-
- public Vehiculo(int id, string matricula, TimeSpan tiempoMaxUso, TimeSpan tiempoUsoSalida, TimeSpan tiempoUsoLlegada, DateTime inicio, DateTime fin, TimeSpan tolerancia)
- {
- this.id = id;
- this.matricula = matricula;
- this.tiempoMaxUso = tiempoMaxUso;
- this.tiempoUsoSalida = tiempoUsoSalida;
- this.tiempoUsoLlegada = tiempoUsoLlegada;
- this.inicio = inicio;
- this.fin = fin;
- this.tolerancia = tolerancia;
-
- pedidos = new List<Pedido>();
- caracteristicas = new List<Caracteristicas>();
- escenarios = new List<Escenario>();
- capacidades = new List<Capacidad>();
- }
-
- public VRP.Vehicle getVRPVehiculo()
- {
- #region CREO EL VEHICULO
- VRP.Vehicle vehicleVRP = new VRP.Vehicle()
- {
- compartments = new List<object>(),
- //originItem. NO SE ESPECIFICA EN CASO DE QUE EL VEHICULO PARTA DEL DEPOSITO COMO EN ESTE CASO.
- //destinationItem. IDEM AL ANTERIOR PERO EL FINAL.
- departureTime = tiempoUsoSalida,
- arrivalTime = tiempoUsoLlegada,
- timeWindows = new Dictionary<int,List<object>>(),
- maxUsage = tiempoMaxUso,
- //maxCost FALTA PEDIRLO O NO VA
- //productReloadingPoints= new System.Collections.ObjectModel.ObservableCollection<object>(),//LO DEJO VACIO O NO VA.
- code=id,
- };
- #endregion
- #region CARGA DE LA VENTAN DE TIEMPO
- //TAMBIEN PUEDE SER QUE NO ALLA VENTANA DE TIEMPO
- VRP.TimeWindow t = new VRP.TimeWindow()
- {
- code=1,
- startingTime= inicio,
- endingTime= fin,
- period=1
- };
- List<object> listaVentanaTiempo=new List<object>();
- listaVentanaTiempo.Add(t);
- vehicleVRP.timeWindows.Add(1,listaVentanaTiempo);
- #endregion
- #region LLENO LAS CARACTERIRSTICAS Y CAPACIDADES
- VRP.Compartment comportament = new VRP.Compartment();
- comportament.code = id;
- comportament.capacities = new Dictionary<string, object>();
- foreach (var item in capacidades)
- {
- comportament.capacities.Add(item.Nombre, new VRP.Capacity()
- {
- name=item.Nombre,
- value=item.Cantidad,
- code=item.IdCapacidad.ToString()
- });
- }
- comportament.characteristics = new Dictionary<int, object>();
- foreach (var item in caracteristicas)
- {
- comportament.characteristics.Add(item.Id, new VRP.Characteristic()
- {
- code=item.Id
- });
- }
- vehicleVRP.compartments.Add(comportament);
- #endregion
- return vehicleVRP;
- }
-
- public void sacarPedido(Pedido p)
- {
- pedidos.Remove(p);
- }
-
- public void agregarPedido(Pedido p)
- {
- pedidos.Add(p);
- }
-
- public void sacarCaracteristica(Caracteristicas c)
- {
- caracteristicas.Remove(c);
- }
-
- public void agregarCaracteristica(Caracteristicas c)
- {
- caracteristicas.Add(c);
- }
-
- public void sacarEscenario(Escenario e)
- {
- escenarios.Remove(e);
- }
-
- public void agregarEscenario(Escenario e)
- {
- escenarios.Add(e);
- }
-
- public void sacarCapacidades(Capacidad c)
- {
- capacidades.Remove(c);
- }
-
- public void agregarCapacidades(Capacidad c)
- {
- capacidades.Add(c);
- }
-
- public List<Pedido> Pedidos
- {
- get { return pedidos; }
- set { pedidos = value; }
- }
-
- public List<Caracteristicas> Caracteristicas
- {
- get { return caracteristicas; }
- set { caracteristicas = value; }
- }
-
- public List<Escenario> Escenarios
- {
- get { return escenarios; }
- set { escenarios = value; }
- }
-
- public List<Capacidad> Capacidades
- {
- get { return capacidades; }
- set { capacidades = value; }
- }
-
- public int Id
- {
- get { return id; }
- set { id = value; }
- }
-
- public TimeSpan TiempoMaxUso
- {
- get { return tiempoMaxUso; }
- set { tiempoMaxUso = value; }
- }
-
- public DateTime Inicio
- {
- get { return Inicio; }
- set { Inicio = value; }
- }
-
- public DateTime Fin
- {
- get { return fin; }
- set { fin = value; }
- }
-
- public TimeSpan Tolerancia
- {
- get { return tolerancia; }
- set { tolerancia = value; }
- }
-
- public TimeSpan TiempoUsoSalida
- {
- get { return tiempoUsoSalida; }
- set { tiempoUsoSalida = value; }
- }
-
- public TimeSpan TiempoUsoLlegada
- {
- get { return tiempoUsoLlegada; }
- set { tiempoUsoLlegada = value; }
- }
-
- public string Matricula
- {
- get { return matricula; }
- set { matricula = value; }
- }
- }
- }