public virtual void Evaluate(VehicleState vehicleState, GPSPoint point) { // Actualizo la ultima posicion if (point.Date > LastPosition.Fecha) { LastPosition = LastPosition.Create(point); } else { return; } var qLevel = vehicleState.QtreeRepository.GetPositionClass(point.Lat, point.Lon); var velocidadExceso = vehicleState._infraccion[qLevel]; if (point.Velocidad > velocidadExceso) { // Console.WriteLine("[0] velo: {0} exce:{1} qlevel:{2}", point.Velocidad, velocidadExceso, qLevel); // Inicia el exceso de velocidad var estadoExceso = new VehicleEnInfraccion(LastPosition, velocidadExceso); vehicleState.SetState(estadoExceso); return; } // Sigue en estado normal vehicleState.SetState(this); }
//private HandleResults ProcessVelocidadExcedidaEvent(SpeedingTicket velocidadExcedida) //{ // var texto = GetVelocidadExcedidaText(velocidadExcedida); // var chofer = GetChofer(velocidadExcedida.GetRiderId()); // var velocidadPermitida = Convert.ToInt32(velocidadExcedida.SpeedLimit); // var velocidadAlcanzada = Convert.ToInt32(velocidadExcedida.SpeedReached); // var estado = GeocercaManager.CalcularEstadoVehiculo(Coche, inicio, DaoFactory); // var zona = estado != null && estado.ZonaManejo != null && estado.ZonaManejo.ZonaManejo > 0 // ? DaoFactory.ZonaDAO.FindById(estado.ZonaManejo.ZonaManejo) : null; // var evento = MessageSaver.Save(velocidadExcedida, MessageCode.SpeedingTicket.GetMessageCode(), Dispositivo, Coche, chofer, inicio.Date, inicio, velocidadExcedida.EndPoint, texto, velocidadPermitida, velocidadAlcanzada, null, zona); // var infraccion = new Infraccion // { // Vehiculo = Coche, // Alcanzado = velocidadAlcanzada, // CodigoInfraccion = Infraccion.Codigos.ExcesoVelocidad, // Empleado = evento.Chofer, // Fecha = inicio.Date, // Latitud = inicio.Lat, // Longitud = inicio.Lon, // FechaFin = velocidadExcedida.EndPoint.Date, // LatitudFin = velocidadExcedida.EndPoint.Lat, // LongitudFin = velocidadExcedida.EndPoint.Lon, // Permitido = velocidadPermitida, // Zona = zona, // FechaAlta = DateTime.UtcNow // }; // DaoFactory.InfraccionDAO.Save(infraccion); // return HandleResults.Success; //} public VehicleEnInfraccion(LastPosition lastPosition, byte velocidadInfraccion) : base(lastPosition) { _inicioExceso = LastPosition.Create(lastPosition); _velocidadAlcanzada = lastPosition.Velocidad; _velocidadInfraccion = velocidadInfraccion; }
public override void Evaluate(VehicleState vehicleState, GPSPoint point) { if (point.Date >= LastPosition.Fecha) { LastPosition = LastPosition.Create(point); } else { if (point.Velocidad >= LastPosition.Velocidad) { } Console.WriteLine("Posicion descartada {0} vs {1}", point.Date, LastPosition.Fecha); return; } var qLevel = vehicleState.QtreeRepository.GetPositionClass(point.Lat, point.Lon); _velocidadInfraccion = Math.Min(_velocidadInfraccion, vehicleState._infraccion[qLevel]); _velocidadAlcanzada = Math.Max(_velocidadAlcanzada, point.Velocidad); if (_velocidadInfraccion > point.Velocidad) { // Fin de infracccion var normal = new VechicleNormal(LastPosition); OnFinInfraccion(vehicleState); vehicleState.SetState(normal); return; } // Continua en Infraccion vehicleState.SetState(this); }
internal static VehicleState Create(LogPosicion position, Dispositivo dispositivo) { return(new VehicleState(LastPosition.Create(position), dispositivo)); }