public override void HandleEvent(IUnitTripService tripService, EventDTO evt) { if (evt.EventData == IgnitionEvent.IGNITION_ON) { // Ignition on when trip in progress - mark current trip as undetermined tripService.CurrentTrip.SetUndetermined(); // Add the undetermined trip to the list tripService.AddCurrentTripToList(); // Create a new trip from this start date tripService.CurrentTrip = _tripFactory.CreateNewTrip(tripService.UnitId, evt.DateTime.Value); } else { // Ingition Off - complete the trip tripService.CurrentTrip.Complete(evt.DateTime.Value); // Perform additional processing on the complete trip foreach (var processor in _tripProcessors) { processor.Process(tripService.CurrentTrip); } // Add the undetermined trip to the list tripService.AddCurrentTripToList(); // Finished tripService.SetState(TripState.Finished); } }
public override void HandleEvent(IUnitTripService tripService, EventDTO evt) { // No action required if ignition off event and no trip in progress if (evt.EventData == IgnitionEvent.IGNITION_ON) { tripService.CurrentTrip = _tripFactory.CreateNewTrip(tripService.UnitId, evt.DateTime.Value); tripService.SetState(TripState.Started); } }