public static EstadoVehiculo GetEstadoVehiculo(Coche vehiculo, DAOFactory daoFactory) { if (vehiculo == null) { return(null); } var ts = new TimeElapsed(); var estadoVehiculo = EstadoVehiculo.Load(vehiculo, daoFactory); if (ts.getTimeElapsed().TotalSeconds > 1) { STrace.Debug("DispatcherLock", vehiculo.Dispositivo.Id, String.Format("EstadoVehiculo.Load ({0} secs)", ts.getTimeElapsed().TotalSeconds)); } if (estadoVehiculo == null) { var posicion = daoFactory.LogPosicionDAO.GetLastOnlineVehiclePosition(vehiculo); if (posicion == null) { return(null); } var point = new GPSPoint(posicion.FechaMensaje, (float)posicion.Latitud, (float)posicion.Longitud, posicion.Velocidad, GPSPoint.SourceProviders.Unknown, 0); return(CalcularEstadoVehiculo(vehiculo, point, daoFactory)); } return(estadoVehiculo); }
public Vehiculo(EstadoVehiculo estado, TimeSpan llegada, TipoVehiculo tipo, bool solicitaLimpiezaParabrisas) { Estado = estado; Llegada = llegada; Tipo = tipo; SolicitaLimpiezaParabrisas = solicitaLimpiezaParabrisas; }
//CONSTRUCTORES public Coche(string nombre, int nRuedas, ConsoleColor color, TipoTraccion traccion, int velocidadmaxima, EstadoVehiculo estado) { this._nombre = nombre; this._nruedas = nRuedas; this._color = color; this._traccion = traccion; this._velocidadMaxima = velocidadmaxima; this._estado = estado; }
//Constructor vacío para crear un coche por defecto public Coche() { this._nombre = "Nissan"; this._nruedas = 4; this._color = ConsoleColor.DarkGray; this._traccion = TipoTraccion._4WD; this._velocidadMaxima = 315; this._estado = EstadoVehiculo.Marchando; }
public Vehiculo(EstadoVehiculo estado, TimeSpan llegada) { Estado = estado; Llegada = llegada; Tipo = GenerarTipo(); if (Tipo != TipoVehiculo.Motocicleta) { SolicitaLimpiezaParabrisas = GenerarSolicitaLimpiezaParabrisas(); } }
public static EstadoGeocerca GetEstadoGeocerca(Coche vehiculo, int geocerca, DAOFactory daoFactory) { if (vehiculo == null) { return(null); } var geo = daoFactory.ReferenciaGeograficaDAO.FindGeocerca(geocerca); return(geo == null ? null : EstadoVehiculo.GetEstadoGeocerca(vehiculo, geo)); }
private Texture g_pShadowMap; // Texture to which the shadow map is rendered // FOR SHADOW MAP //Timer shaderTime = new Timer(); //FloatModifier shaderColorModifier = new FloatModifier(0.84f, 0.74f, 0.94f); public Vehicle(TGCVector3 posicionInicial, SoundsManager soundsManager) { this.matrixs = new TransformationMatrix(); this.SoundsManager = soundsManager; this.vectorAdelante = new TGCVector3(0, 0, 1); this.velocidadActualDeSalto = this.velocidadInicialDeSalto; this.deltaTiempoAvance = new Timer(); this.deltaTiempoSalto = new Timer(); this.aceleracionRetroceso = this.aceleracionAvance * 0.8f; this.vectorDireccion = this.vectorAdelante; this.estado = new Stopped(this); this.velocidadMaximaDeRetroceso = this.velocidadMaximaDeAvance * 0.7f; g_LightPos = new TGCVector3(80, 120, 0); g_LightDir = TGCVector3.Empty; g_LightDir.Normalize(); this.Init(); }
private List <Datamart> GenerateRecords(PeriodData data) { var datamarter = new Datamarter(data); if (data.Posiciones.Count == 0) { var distancia = data.PosicionAnterior != null && data.PosicionSiguiente != null ? data.GetDistancia(data.PosicionAnterior, data.PosicionSiguiente, data.Inicio, data.Fin) : 0; return(datamarter.CreateNoReportDatamartRecords(data.Inicio, data.Fin, distancia)); } var listado = new List <Datamart>(); //if (data.PosicionAnterior == null && data.Posiciones[0].FechaMensaje > data.Inicio) //{ // listado.AddRange(datamarter.CreateNoReportDatamartRecords(data.Inicio, data.Posiciones[0].FechaMensaje, 0)); //} var posIndex = 0; var inicio = data.Inicio; var lastPosition = data.PosicionAnterior ?? data.Posiciones[0]; foreach (var fecha in data.FechasDeCorte) { var minSpeed = int.MaxValue; var maxSpeed = 0; var sumSpeed = 0; var lastHash = string.Empty; var posCount = 0; var km = 0.0; if (fecha < lastPosition.FechaMensaje) { listado.AddRange(datamarter.CreateNoReportDatamartRecords(inicio, fecha, 0)); inicio = fecha; continue; } for (; posIndex < data.Posiciones.Count && data.Posiciones[posIndex].FechaMensaje < fecha; posIndex++) { var position = data.Posiciones[posIndex]; var hash = data.GetHash(position); var timeBetween = position.FechaMensaje.Subtract(lastPosition.FechaMensaje); if (inicio >= position.FechaMensaje || timeBetween == TimeSpan.Zero) { lastPosition = position; lastHash = hash; continue; } var distancia = inicio > lastPosition.FechaMensaje ? data.GetDistancia(lastPosition, position, inicio, null) : data.GetDistancia(lastPosition, position, null, null); var nextIsLast = !(posIndex + 1 < data.Posiciones.Count && data.Posiciones[posIndex + 1].FechaMensaje < fecha); var cortar = hash != lastHash; var noreport = timeBetween.TotalMinutes > NoReportMinutes; var firstPos = posCount == 0; if (!firstPos && (cortar || noreport || nextIsLast)) { var estadoMotor = EstadoMotor.FromPosicion(lastPosition); var estadoVehiculo = EstadoVehiculo.FromPosicion(lastPosition); var zona = lastPosition.Zona; var avgSpeed = sumSpeed / posCount; var datamart = datamarter.CreateDatamartRecord(inicio, noreport ? lastPosition.FechaMensaje : position.FechaMensaje, km, estadoMotor, estadoVehiculo, avgSpeed, minSpeed, maxSpeed, zona); listado.Add(datamart); km = distancia; if (noreport) { var datamarts = datamarter.CreateNoReportDatamartRecords(lastPosition.FechaMensaje, position.FechaMensaje, km); listado.AddRange(datamarts); km = 0; } minSpeed = position.Velocidad; maxSpeed = position.Velocidad; sumSpeed = position.Velocidad; inicio = position.FechaMensaje; posCount = 1; } else { km += distancia; sumSpeed += position.Velocidad; if (position.Velocidad < minSpeed) { minSpeed = position.Velocidad; } if (position.Velocidad > maxSpeed) { maxSpeed = position.Velocidad; } posCount++; } lastPosition = position; lastHash = hash; } if (inicio < fecha) { var ultima = posIndex < data.Posiciones.Count - 1 ? data.Posiciones[posIndex + 1] : data.PosicionSiguiente; km += ultima == null ? 0 : (inicio > lastPosition.FechaMensaje ? data.GetDistancia(lastPosition, ultima, inicio, fecha) : data.GetDistancia(lastPosition, ultima, null, fecha)); if (posCount == 0) { var datamart2 = datamarter.CreateNoReportDatamartRecords(inicio, fecha, km); listado.AddRange(datamart2); } else { var estadoMotor2 = EstadoMotor.FromPosicion(lastPosition); var estadoVehiculo2 = EstadoVehiculo.FromPosicion(lastPosition); var zona = lastPosition.Zona; var avgSpeed2 = posCount > 0 ? sumSpeed / posCount : 0; var datamart2 = datamarter.CreateDatamartRecord(inicio, fecha, km, estadoMotor2, estadoVehiculo2, avgSpeed2, minSpeed, maxSpeed, zona); listado.Add(datamart2); } } inicio = fecha; } return(listado); }
public QuadrantBottomLeft(EstadoVehiculo state) : base(state) { }
public Vehiculo(int numero, EstadoVehiculo estado) { Numero = numero; Estado = estado; }
public QuadrantTopLeft(EstadoVehiculo state) : base(state) { }
public void ChangeToFreeze() { this.estado = new Frozen(this); }
virtual protected void ManageEntry(TgcD3dInput input) { if (input.keyDown(Key.NumPad4)) { Scene.GetInstance().camera.rotateY(-0.0005f); } if (input.keyDown(Key.NumPad6)) { Scene.GetInstance().camera.rotateY(0.0005f); } if (input.keyDown(Key.RightArrow)) { Scene.GetInstance().camera.OffsetHeight += 0.005f; } if (input.keyDown(Key.LeftArrow)) { Scene.GetInstance().camera.OffsetHeight -= 0.005f; } if (input.keyDown(Key.UpArrow)) { Scene.GetInstance().camera.OffsetForward += 0.01f; } if (input.keyDown(Key.DownArrow)) { Scene.GetInstance().camera.OffsetForward -= 0.01f; } if (input.keyDown(Key.W)) { this.estado.Advance(); } if (input.keyDown(Key.S)) { this.estado.Back(); } float rotation; if (input.keyDown(Key.D)) { rotation = this.estado.Right(); Scene.GetInstance().camera.rotateY(rotation); } else if (input.keyDown(Key.A)) { rotation = this.estado.Left(); Scene.GetInstance().camera.rotateY(rotation); } if (!input.keyDown(Key.A) && !input.keyDown(Key.D)) { this.estado.UpdateWheels(); } if (input.keyDown(Key.Space)) { this.estado.Jump(); } if (!input.keyDown(Key.W) && !input.keyDown(Key.S)) { this.estado.SpeedUpdate(); } if (input.keyDown(Key.P)) { this.Shoot(); } if (input.keyDown(Key.E)) { this.SoundsManager.GetSound("Bocina").play(); } if (input.keyDown(Key.R)) { this.SoundsManager.GetSound("Alarma").play(); } if (input.keyUp(Key.U)) { NextWeapon(); } if (input.keyDown(Key.C)) { estado = new Frozen(this); } /* * if (input.keyDown(Key.K)) * { * life -= 50; * } */ if (input.keyDown(Key.NumPad1)) { this.pointsOfCollision.constantOfDeformation += 0.01f; } if (input.keyDown(Key.NumPad2)) { this.pointsOfCollision.constantOfDeformation -= 0.01f; } if (input.keyDown(Key.NumPad7)) { this.pointsOfCollision.radio -= 0.01f; } if (input.keyDown(Key.NumPad9)) { this.pointsOfCollision.radio += 0.01f; } }
public void SetEstado(EstadoVehiculo estado) { this.estado = estado; }
public QuadranInFrontOf(EstadoVehiculo state) : base(state) { }
public Vehiculo() { Numero = 0; Estado = EstadoVehiculo.SinParquear; }
public static EstadoVehiculo CalcularEstadoVehiculo(Coche vehiculo, GPSPoint position, DAOFactory daoFactory) { if (vehiculo == null || position == null) { return(null); } var estadoVehiculo = new EstadoVehiculo(vehiculo) { Posicion = position }; var t = new TimeElapsed(); lock (GetLock(vehiculo.Id)) { if (t.getTimeElapsed().TotalSeconds > 0.5) { STrace.Error("DispatcherLock", vehiculo.Dispositivo.Id, String.Format("CalcularEstadoVehiculo/EntroAlLock ({0} secs)", t.getTimeElapsed().TotalSeconds)); } t.Restart(); var qtree = GetQtree(vehiculo); if (t.getTimeElapsed().TotalSeconds > 0.5) { STrace.Error("DispatcherLock", vehiculo.Dispositivo.Id, String.Format("CalcularEstadoVehiculo/GetQTree ({0} secs)", t.getTimeElapsed().TotalSeconds)); } var geocercas = qtree != null && qtree.GetData(position.Lat, position.Lon) != null ? qtree.GetData(position.Lat, position.Lon) : new List <Geocerca>(0); t.Restart(); if (vehiculo.Empresa.EvaluaSoloGeocercasViaje) { var viajeActivo = daoFactory.ViajeDistribucionDAO.FindEnCurso(vehiculo); if (viajeActivo != null) { var tiposGeocercaViaje = vehiculo.Empresa.TiposGeocercaViaje; var idGeocercas = geocercas.Where(g => !tiposGeocercaViaje.Contains(g.TipoReferenciaGeograficaId)).Select(g => g.Id).ToList(); var idsEntregas = viajeActivo.Detalles.Select(d => d.ReferenciaGeografica.Id).Distinct().ToList(); idGeocercas.AddRange(idsEntregas); idGeocercas = idGeocercas.Distinct().ToList(); var faltantes = idsEntregas.Where(id => !idGeocercas.Contains(id)); if (faltantes.Any()) { if (vehiculo.Empresa.Id == 92) { STrace.Error("ResetQtree", string.Format("Actual: {0} - Faltantes: {1}", geocercas.Count, faltantes.Count())); } foreach (var idGeocerca in faltantes) { try { var geocerca = daoFactory.ReferenciaGeograficaDAO.FindGeocerca(idGeocerca); geocercas.Add(geocerca); } catch { } } if (vehiculo.Empresa.Id == 92) { STrace.Error("ResetQtree", "Total: " + geocercas.Count); } } geocercas = geocercas.Where(g => idGeocercas.Contains(g.Id)).ToList(); if (t.getTimeElapsed().TotalSeconds > 0.5) { STrace.Error("DispatcherLock", vehiculo.Dispositivo.Id, String.Format("GeocercasViaje: {0} segundos", t.getTimeElapsed().TotalSeconds)); } } } t.Restart(); foreach (var geocerca in geocercas) { var estadoGeocerca = new EstadoGeocerca { Geocerca = geocerca }; var inside = IsInside(geocerca, position.Lat, position.Lon); if (!inside) { continue; } estadoGeocerca.Estado = EstadosGeocerca.Dentro; if (geocerca.ControlaVelocidad) { estadoGeocerca.VelocidadMaxima = geocerca.GetVelocidadMaxima(vehiculo.Id); estadoGeocerca.EnExcesoVelocidad = geocerca.ControlaVelocidad && position.Velocidad > estadoGeocerca.VelocidadMaxima; estadoGeocerca.PosicionInicioExceso = estadoGeocerca.EnExcesoVelocidad ? position : null; estadoGeocerca.VelocidadPico = estadoGeocerca.EnExcesoVelocidad ? position.Velocidad : 0; } if (geocerca.ZonaManejo > 0) { if (estadoVehiculo.ZonaManejo == null || estadoVehiculo.ZonaManejo.PrioridadZona > geocerca.PrioridadZona) { estadoVehiculo.ZonaManejo = geocerca; } } estadoVehiculo.GeocercasDentro.Add(estadoGeocerca); } if (t.getTimeElapsed().TotalSeconds > 0.5) { STrace.Error("DispatcherLock", vehiculo.Dispositivo.Id, String.Format("CalcularEstadoVehiculo/ForEach ({0} secs)", t.getTimeElapsed().TotalSeconds)); } return(estadoVehiculo); } }
public Quadrant(EstadoVehiculo state) { this.state = state; }