Пример #1
0
        public ScheduleAdherenceActor2(
            ITripClient tripClient,
            IRouteClient routeClient)
        {
            this.tripClient  = tripClient;
            this.routeClient = routeClient;

            Become(() => WaitingForTrip(passengerCount: 0));
        }
Пример #2
0
        public FsmScheduleAdherenceActor(
            ITripClient tripClient,
            IRouteClient routeClient)
        {
            this.tripClient  = tripClient;
            this.routeClient = routeClient;

            When(State.WaitingForTrip, evt =>
            {
                int passengerCount = (int)evt.StateData;
                switch (evt.FsmEvent)
                {
                case VehicleRouteStatus status when status.State == VehicleRouteState.OnRoute && status.TripId.IsSome():
                    var trip      = this.tripClient.GetTrip(status.TripId.Value).Result;
                    var route     = this.routeClient.GetRoute(trip.RouteId).Result;
                    var stopTimes = new List <StopTime>();

                    return(GoTo(State.CollectingTripData).Using((passengerCount, trip, route, stopTimes)));
Пример #3
0
        public ScheduleAdherenceActor1(
            ITripClient tripClient,
            IRouteClient routeClient)
        {
            this.tripClient  = tripClient;
            this.routeClient = routeClient;

            ReceiveAsync <VehicleRouteStatus>(async msg =>
            {
                if (msg.State == VehicleRouteState.OnRoute)
                {
                    this.stopTimes = new List <StopTime>();

                    if (msg.TripId.IsSome())
                    {
                        this.trip  = await this.tripClient.GetTrip(msg.TripId.Value);
                        this.route = await this.routeClient.GetRoute(trip.RouteId);
                    }
                }
                else if (msg.State == VehicleRouteState.NoRoute)
                {
                    if (this.trip == null)
                    {
                        return;
                    }

                    var tripExecution = new TripExecution(this.trip.TripId, this.SumDistances());

                    Context.System.EventStream.Publish(tripExecution);
                }
            });

            Receive <StopTime>(msg =>
            {
                this.stopTimes.Add(msg);

                this.passengerCount = this.passengerCount + msg.PassengerOn - msg.PassengerOff;

                if (this.passengerCount < 0)
                {
                    this.passengerCount = 0;
                }
            });
        }
Пример #4
0
 public TripLogic(ITopographicplaceClient topographicplaceClient, ITripClient tripClient)
 {
     _topographicplaceClient = topographicplaceClient;
     _tripClient             = tripClient;
 }
Пример #5
0
 public TripService(ITripClient tripClient)
 {
     _tripClient = tripClient;
 }