/// <summary>
        /// :-)
        /// </summary>
        /// <param name="tr"></param>
        /// <param name="steps"></param>
        private void SetupHalfHourBus5MinWalk25MinWaitHalfHourBus_Probe4MinAwayAtLatestAllowableTime(Traveler tr, List <Step> steps)
        {
            //Override times to make trip present tense
            //inbound step
            steps[0].StartDate = DateTime.UtcNow.AddMinutes(-60);
            steps[0].EndDate   = DateTime.UtcNow.AddMinutes(-30);
            //walk step
            steps[1].StartDate = DateTime.UtcNow.AddMinutes(-30);
            steps[1].EndDate   = DateTime.UtcNow.AddMinutes(-25);
            //tconnect step
            steps[2].StartDate = DateTime.UtcNow;
            steps[2].EndDate   = DateTime.UtcNow.AddMinutes(30);

            DateTime probetimestamp = DateTime.UtcNow.AddMinutes(-5).AddSeconds(30);
            //Set up a probe snapshot coming from the James Rd Gate
            //It takes 4:01 minutes to travel between gates.
            ProbeSnapshotEntry newProbeSnapshot = new ProbeSnapshotEntry
            {
                PartitionKey = tr.LastName,//inbound vehicle name is last name of traveler
                RowKey       = Guid.NewGuid().ToString(),

                PositionTimestamp = probetimestamp,
                Accuracy          = 5,
                Altitude          = 123,
                Heading           = 180,
                Latitude          = 39.977592,
                Longitude         = -82.913054,
                Satellites        = 0,
                Speed             = 14.77999305725097
            };

            _probeTable.AddEntity(newProbeSnapshot);
        }
Beispiel #2
0
        /// <summary>
        /// Receives ProbeVehicleData by inbound vehicle for the latest vehicle location and saves it to the cloud.
        /// </summary>
        /// <param name="probeDataMessage"></param>
        /// <returns></returns>
        public HttpResponseMessage PostProbeData(ProbeVehicleData probeDataMessage)
        {
            try
            {
                if (String.IsNullOrEmpty(probeDataMessage.InboundVehicle))
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "InboundVehicle cannot be null or empty"));
                }

                // Convert from Java timestamp
                DateTime dtTemp = new DateTime(1970, 1, 1, 0, 0, 0);

                DateTime           newestProbeTimestamp = dtTemp;
                ProbeSnapshotEntry newestProbeSnapshot  = null;

                foreach (PositionSnapshot positionSnapshot in probeDataMessage.Positions)
                {
                    DateTime lastUpdatedDate = dtTemp.AddMilliseconds(positionSnapshot.TimeStamp);

                    ProbeSnapshotEntry newProbeSnapshot = new ProbeSnapshotEntry
                    {
                        PartitionKey      = probeDataMessage.InboundVehicle,
                        RowKey            = Guid.NewGuid().ToString(),
                        Latitude          = positionSnapshot.Latitude,
                        Longitude         = positionSnapshot.Longitude,
                        Speed             = positionSnapshot.Speed,
                        Heading           = positionSnapshot.Heading,
                        PositionTimestamp = lastUpdatedDate,
                        Satellites        = positionSnapshot.Satellites,
                        Accuracy          = positionSnapshot.Accuracy,
                        Altitude          = positionSnapshot.Altitude
                    };

                    _probeTable.AddEntity(newProbeSnapshot);

                    //Check for and hang on to most recent probe snapshot
                    if (lastUpdatedDate > newestProbeTimestamp)
                    {
                        newestProbeTimestamp = lastUpdatedDate;
                        newestProbeSnapshot  = newProbeSnapshot;
                    }
                }

                SaveNewestProbeSnapshot(newestProbeSnapshot);

                return(Request.CreateResponse(HttpStatusCode.NoContent));
            }
            catch (Exception ex)
            {
                string msg = RecordException(ex, "ProbeController.PostProbeData");
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message + msg));
            }
        }