public void TestPositionEvent() { System.DateTime dt1 = new System.DateTime(1977, 5, 25); Vector2 rockstar1 = new Vector2(0, 0); Vector2 light1 = new Vector2(10, 10); List <Vector2> p1 = new List <Vector2>(); p1.Add(rockstar1); p1.Add(light1); PositionEvent pe1 = new PositionEvent(dt1, p1); Assert.IsNotNull(pe1); Assert.AreEqual(new System.DateTime(1977, 5, 25), pe1.eventTime); Assert.AreEqual(p1, pe1.positions); // Test creating position event with other reasonable inputs System.DateTime dt2 = new System.DateTime(2021, 2, 1, 4, 13, 12, 140); Vector2 rockstar2 = new Vector2(10, 10); Vector2 light2 = new Vector2(0, 0); List <Vector2> p2 = new List <Vector2>(); p2.Add(rockstar2); p2.Add(light2); PositionEvent pe2 = new PositionEvent(dt2, p2); Assert.IsNotNull(pe2); Assert.AreEqual(new System.DateTime(2021, 2, 1, 4, 13, 12, 140), pe2.eventTime); Assert.AreEqual(p2, pe2.positions); }
public void AddPositionEvent(PositionEvent pos) { if (posEvent != null) { Instance.posEvent.Add(pos); } }
protected void DispatchPositionEvent(PositionEvent positionEvent, Vector3 position) { if (positionEvent != null) { positionEvent(Camera.main.ScreenToWorldPoint(position)); } }
public void Regenerate(DateTime desde, DateTime hasta) { Regeneracion = true; var maxMonths = Vehiculo.Empresa != null ? Vehiculo.Empresa.MesesConsultaPosiciones : 3; var logMensajes = DaoFactory.LogMensajeDAO.GetEvents(Vehiculo.Id, desde, hasta, maxMonths); foreach (var logMensaje in logMensajes) { if (logMensaje.Latitud == 0 || logMensaje.Longitud == 0) { var pos = DaoFactory.LogPosicionDAO.GetFirstPositionOlderThanDate(Vehiculo.Id, logMensaje.Fecha, maxMonths); logMensaje.Latitud = pos.Latitud; logMensaje.Longitud = pos.Longitud; DaoFactory.LogMensajeDAO.SaveOrUpdate(logMensaje); } var evento = EventFactory.GetEvent(DaoFactory, logMensaje); if (evento == null) { continue; } ProcessEvent(evento); } var positions = DaoFactory.LogPosicionDAO.GetPositionsBetweenDates(Vehiculo.Id, desde, hasta, maxMonths); foreach (var logPosicion in positions) { var pos = new PositionEvent(logPosicion.FechaMensaje, logPosicion.Latitud, logPosicion.Longitud); ProcessEvent(pos); } Regeneracion = false; }
/// <summary> /// Setea el estado inicial (dentro/fuera) de todas las geocercas del ticket a partir de la ultima posicion del vehiculo. /// </summary> protected void FirstPosition() { try { var position = DaoFactory.LogPosicionDAO.GetLastOnlineVehiclePosition(Vehiculo); if (position == null) { return; } // Pongo todas las geocercas en Desconocido var geocercas = Geocercas.Select(geocerca => GetKeyGeocerca(geocerca)); foreach (var key in geocercas) { LogicCache.Store(typeof(EstadosEntrega), key, new EstadosEntrega(EstadosGeocerca.Desconocido), DateTime.UtcNow.AddHours(5)); } // Proceso la primera posicion var positionEvent = new PositionEvent(position.FechaMensaje, position.Latitud, position.Longitud); ProcessGeocercas(positionEvent); } catch (Exception ex) { STrace.Exception(typeof(CicloLogisticoFactory).FullName, ex); } }
void Awake() { GetPosition = CurrentPosition; destination = transform.position; cc = GetComponent <UnityEngine.CharacterController>(); ani = GetComponent <Animator>(); StartCoroutine(Facing()); }
private void Awake() { _transform = transform; _rigidbody = GetComponent <Rigidbody2D>(); ExitedBottomArea = new UnityEvent(); HitSomething = new PositionEvent(); _hasHitSomething = false; }
void Awake() { defaultPos = new Vector3(0, -0.5f, 0); ResetEvent = Reset; GetPosition = CurrentPosition; destination = transform.position; cc = GetComponent <UnityEngine.CharacterController>(); ani = GetComponent <Animator>(); StartCoroutine(Facing()); }
private void MoveSpeedMarker(global::Event e) { Debug.Assert(e.GetType() == typeof(PositionEvent), "Non-PositionEvent in MoveSpeedMarker"); PositionEvent posEvent = e as PositionEvent; readout.rectTransform.position = RepositionMarker(posEvent.pos); readout.text = ChangeMarkerText(posEvent.pos); readout.color = ChangeMarkerColor(posEvent.pos); }
/// <summary> /// Procesa una posicion y genera los eventos de entrada y salida de geocerca. /// </summary> /// <param name="data"></param> protected void ProcessGeocercas(PositionEvent data) { try { var geocercas = Puntos; var point = new GPSPoint(data.Date, (float)data.Latitud, (float)data.Longitud); foreach (var geocerca in geocercas) { var key = GetKeyGeocerca(geocerca); if (Regeneracion) { key = "recalc_" + key; } var lastState = LogicCache.KeyExists(typeof(EstadosEntrega), key) ? LogicCache.Retrieve <EstadosEntrega>(typeof(EstadosEntrega), key).Estado : EstadosGeocerca.Desconocido; var geo = DaoFactory.ReferenciaGeograficaDAO.FindGeocerca(geocerca); var p = new PointF(point.Lon, point.Lat); var inside = geo.IsInBounds(p) && geo.Contains(p.Y, p.X); var newState = inside ? EstadosGeocerca.Dentro : EstadosGeocerca.Fuera; if (lastState != newState) { var state = new EstadosEntrega(newState); LogicCache.Store(typeof(EstadosEntrega), key, state, Regeneracion ? DateTime.UtcNow.AddMinutes(5) : DateTime.UtcNow.AddHours(5)); IEvent evento = null; if (lastState == EstadosGeocerca.Dentro && newState == EstadosGeocerca.Fuera) { evento = EventFactory.GetEvent(DaoFactory, point, MessageCode.OutsideGeoRefference.GetMessageCode(), geocerca, 0, null, Empleado); } else if (lastState == EstadosGeocerca.Fuera && newState == EstadosGeocerca.Dentro) { evento = EventFactory.GetEvent(DaoFactory, point, MessageCode.InsideGeoRefference.GetMessageCode(), geocerca, 0, null, Empleado); } if (evento == null) { continue; } ProcessEvent(evento, true); } } } catch (Exception ex) { STrace.Exception(typeof(CicloLogisticoFactory).FullName, ex); } }
public void FillPositionEvent() { PositionEvent newPositionEvent = new PositionEvent(); newPositionEvent.pdata = playerData; newPositionEvent.eventID = ++evendIdCount; newPositionEvent.position = playerController.gameObject.transform.position; newPositionEvent.rotation = playerController.gameObject.transform.rotation; newPositionEvent.timeStamp = Time.time; positionEvents.events.Add(newPositionEvent); }
public Inputter() { OnPrimaryAction = new PositionEvent(); OnStartDrag = new PositionEvent(); OnDrag = new PositionEvent(); OnEndDrag = new PositionEvent(); OnZoom = new NormalisedZoomDeltaEvent(); results = new List <RaycastResult>(); RecalculateGlobalDragThreshold(); }
public static void Process(Coche vehiculo, GPSPoint position, bool ignoreMessages) { try { var evento = new PositionEvent(position.Date, position.Lat, position.Lon); Process(vehiculo, evento, ignoreMessages); } catch (Exception ex) { STrace.Exception(typeof(CicloLogisticoFactory).FullName, ex); } }
private void OnSessionPositionChanged(PositionEvent lmaxPos) { SendOutMessage(this .CreatePositionChangeMessage( lmaxPos.AccountId.To <string>(), new SecurityId { Native = lmaxPos.InstrumentId } ) .Add(PositionChangeTypes.CurrentValue, lmaxPos.OpenQuantity) .Add(PositionChangeTypes.CurrentPrice, lmaxPos.OpenCost)); }
public void Start() { Task.Run(() => { while (true) { PositionEvent?.Invoke(_instance, new EventArgs { X = _x, Y = _y }); Thread.Sleep(3000);//ogni 3s aggiorna posizione } }); }
private void button1_Click(object sender, EventArgs e) { data = new PositionEvent() { Long = txtLong.Text, Lat = txtLat.Text }; LogTextBox.Text += string.Format(">> Publishing event...\r\n"); WebClient.PostJsonAsync( string.Format("http://localhost:{0}/publish", DefaultSettings.BrokerPort), data, OnPublishResponse); }
private async void CheckPosition() { await Task.Run(async() => { while (true) { if (_mediaPlayer != null && _mediaPlayer.IsPlaying) { PositionEvent?.Invoke(_mediaPlayer.CurrentPosition, _mediaPlayer.Duration); } await Task.Delay(1000); } }); }
public void NewPositionsEvent() { PositionEvent positionEvent = new PositionEvent(); if (player) { positionEvent.seconds_since_start = timer_since_start; positionEvent.position.x = player.transform.position.x; positionEvent.position.y = player.transform.position.y; positionEvent.position.z = player.transform.position.z; } writer.AddPositionEvent(positionEvent); }
private static IPosition ConvertToPosition(this PositionEvent pPosition) { if (pPosition == null) { throw new ArgumentNullException("pPosition"); } return(new Position() { Latitude = pPosition.Latitude, Longitude = pPosition.Longitude, Date = pPosition.GPSDateTime, TripEventID = pPosition.TripEventID }); }
private void OnPositionChanged(PositionEvent position) { var instrument = Securities.FirstOrDefault(i => i.SecurityId == position.InstrumentId); if (instrument == null) { return; } var positionDetails = new Position(instrument.Symbol) { PositionSide = position.OpenQuantity > 0 ? Side.Buy : Side.Sell, Price = position.OpenQuantity != 0m ? Math.Abs(position.OpenCost / position.OpenQuantity) / instrument.ContractSize : 0, Quantity = position.OpenQuantity }; ProcessPositionUpdate(positionDetails); }
protected virtual void Process(PositionEvent data) { }
private void OnSessionPositionChanged(PositionEvent lmaxPos) { SendOutMessage(this .CreatePositionChangeMessage( lmaxPos.AccountId.To<string>(), new SecurityId { Native = lmaxPos.InstrumentId } ) .Add(PositionChangeTypes.CurrentValue, lmaxPos.OpenQuantity) .Add(PositionChangeTypes.CurrentPrice, lmaxPos.OpenCost)); }
private void PositionHandler(PositionEvent e) { UpdateDataIfExist(e.Session, data => data.Position = e.Position); }
protected override void Process(PositionEvent data) { ProcessGeocercas(data); }