private static IMessage GetSalida(GPSPoint gpsPoint, String rfid, int codEv, INode device, ulong msgId) { MessageIdentifier codigo; switch (codEv) // codigo del Evento generador del reporte { case Evento.Panico: codigo = MessageIdentifier.PanicButtonOn; break; case Evento.DoorOpenned: codigo = MessageIdentifier.DoorOpenned; break; case Evento.SemiTrailerUnhook: codigo = MessageIdentifier.TrailerUnHooked; break; case Evento.Substitute: codigo = MessageIdentifier.SubstituteViolation; break; case Evento.Generic01: codigo = MessageIdentifier.CustomMsg1On; break; case Evento.Generic02: codigo = MessageIdentifier.CustomMsg2On; break; case Evento.EngineOn: codigo = MessageIdentifier.EngineOn; break; case Evento.EngineOff: codigo = MessageIdentifier.EngineOff; break; //case Evento.Periodic01: goto default; //case Evento.Periodic02: goto default; case Evento.DeviceTurnedOn: codigo = MessageIdentifier.DeviceTurnedOn; break; default: return(gpsPoint.ToPosition(device.Id, msgId)); } return(codigo.FactoryEvent(device.Id, msgId, gpsPoint, gpsPoint.GetDate(), rfid, null)); }
private static IMessage FactoryBrusca(String[] partes, INode node, GPSPoint evpos, MessageIdentifier ev, ulong mid) { var res = ev.FactoryEvent(node.Id, mid, evpos, evpos.GetDate(), null, null); res.SensorsDataString = String.Format( CultureInfo.InvariantCulture, "VelocidadInicial:{0},VelocidadFinal:{1},LapsoProgramado:{2}", Speed.KnotToKm(Convert.ToInt16(partes[5])), Speed.KnotToKm(Convert.ToInt16(partes[6])), Convert.ToInt16(partes[7])); STrace.Debug(typeof(Entrante).FullName, node.Id, String.Format("{0} {1}", ev, res.SensorsDataString)); return(res); }
private IMessage Translate(SitrackFrame frame) { var deviceId = 0; if (frame.HolderDomain != null) { deviceId = FindDeviceId(frame.HolderDomain); } if (deviceId != 0 && deviceId != -1) { var pos = new GPSPoint { Lat = (float)frame.Latitude, Lon = (float)frame.Longitude, Date = frame.ReportDate.ToUniversalTime(), Speed = new Speed(frame.Speed), Course = new Course(frame.Course) }; if (frame.EventDesc != null) { var dispositivoDao = new DispositivoDAO(); var dispositivo = dispositivoDao.FindById(deviceId); var codeEvent = frame.EventId + 9000; var msgTraduccionDao = new MensajeTraducidoDAO(); var codeEventTraducido = msgTraduccionDao.GetCodigoFinal(dispositivo.Empresa.Id, codeEvent.ToString()); var evento = new Event(Convert.ToInt16(codeEventTraducido), -1, deviceId, (ulong)frame.EventId, pos, pos.GetDate(), "", null, true); return(evento); } var message = pos.ToPosition(deviceId, 0); return(message); } return(null); }
/// <summary> /// Determines if the givenn speed message has valid values. /// </summary> /// <param name="inicio"></param> /// <param name="velocidadExcedida"></param> /// <returns></returns> private Boolean IsInvalidVelocidadExcedidaMessage(GPSPoint inicio, SpeedingTicket velocidadExcedida) { var discardReason = DiscardReason.None; if (velocidadExcedida.EndPoint == null || inicio == null) { discardReason = DiscardReason.MissingPositions; } else if (FechaInvalida(velocidadExcedida.EndPoint.Date, DeviceParameters)) { discardReason = DiscardReason.InvalidDate; } else if (FechaInvalida(inicio.Date, DeviceParameters)) { discardReason = DiscardReason.InvalidDate; } else if (FueraDelGlobo(inicio)) { discardReason = DiscardReason.OutOfGlobe; } else if (FueraDelGlobo(velocidadExcedida.EndPoint)) { discardReason = DiscardReason.OutOfGlobe; } else if (VelocidadInvalida(velocidadExcedida)) { discardReason = DiscardReason.InvalidSpeed; } else if (InvalidDuration(velocidadExcedida, inicio)) { discardReason = DiscardReason.InvalidDuration; } else if (InvalidTicketData(velocidadExcedida, inicio)) { discardReason = DiscardReason.InvalidTicketData; } if (discardReason.Equals(DiscardReason.None)) { return(false); } MessageSaver.Discard(MessageCode.SpeedingTicket.GetMessageCode(), Dispositivo, Coche, GetChofer(velocidadExcedida.GetRiderId()), inicio.GetDate(), inicio, velocidadExcedida.EndPoint, discardReason); return(true); }
private static IMessage GetSalidaReal(GPSPoint gpsPoint, String rfid, int codEv, INode device, ulong msgId, byte[] data) { MessageIdentifier codigo; switch (codEv) // codigo del Evento generador del reporte { case Evento.MotorOn: codigo = MessageIdentifier.EngineOnInternal; break; case Evento.MotorOff: codigo = MessageIdentifier.EngineOffInternal; break; case Evento.GarminOn: codigo = MessageIdentifier.GarminOn; break; case Evento.GarminOff: codigo = MessageIdentifier.GarminOff; break; case Evento.PanicButtonOn: codigo = MessageIdentifier.PanicButtonOn; break; case Evento.PanicButtonOff: codigo = MessageIdentifier.PanicButtonOff; break; case Evento.AmbulanciaSirenaOn: codigo = MessageIdentifier.SirenOn; break; case Evento.AmbulanciaSirenaOff: codigo = MessageIdentifier.SirenOff; break; case Evento.AmbulanciaBalizaOn: codigo = MessageIdentifier.BeaconOn; break; case Evento.AmbulanciaBalizaOff: codigo = MessageIdentifier.BeaconOff; break; case Evento.GsmOn: codigo = MessageIdentifier.GsmSignalOn; break; case Evento.GsmOff: codigo = MessageIdentifier.GsmSignalOff; break; case Evento.GpsSignalOn: codigo = MessageIdentifier.GpsSignalOn; break; case Evento.GpsSignalOff: codigo = MessageIdentifier.GpsSignalOff; break; case Evento.Gps3DSignalOff: codigo = MessageIdentifier.GpsSignal3DOff; break; case Evento.Gps2DSignalOn: codigo = MessageIdentifier.GpsSignal2DOn; break; case Evento.PistonOff: codigo = MessageIdentifier.PistonOff; break; case Evento.PistonOn: codigo = MessageIdentifier.PistonOn; break; case Evento.DistanciaSinChofer: codigo = MessageIdentifier.NoDriverMovement; break; case Evento.DistanciaMotorOff: codigo = MessageIdentifier.NoEngineMovement; break; case Evento.ChoferLoggedOn: return(MessageIdentifierX.FactoryRfid(device.Id, msgId, gpsPoint, gpsPoint.GetDate(), rfid, 0)); case Evento.ChoferLoggedOff: return(MessageIdentifierX.FactoryRfid(device.Id, msgId, gpsPoint, gpsPoint.GetDate(), rfid, 1)); case Evento.Infraccion: var maxVel = data[14]; var maxPermitida = Speed.KmToKnot(80); //volvemos al hardcoded ya q no hay qtree var posIni = device.Retrieve <GPSPoint>("IniInfraccion") ?? gpsPoint; return(new SpeedingTicket(device.Id, msgId, posIni, gpsPoint, maxVel, maxPermitida, rfid)); case Evento.InfraccionInicio: device.Store("IniInfraccion", gpsPoint); goto default; default: return(gpsPoint.ToPosition(device.Id, msgId)); } return(codigo.FactoryEvent(device.Id, msgId, gpsPoint, gpsPoint.GetDate(), rfid, null)); }