/// <summary>Convert ground mission data to train mission data.</summary> /// <param name="inputData">Information describing the input.</param> /// <param name="outputDelay">[out] The output delay.</param> /// <param name="outputWeather">[out] The output weather.</param> public static void ConvertGroundMissionDataToTrainMissionData(RealTimeInformationType inputData, out Train.RealTime.DelayType outputDelay, out Train.RealTime.WeatherType outputWeather) { outputDelay = null; outputWeather = null; if (inputData != null) { if (inputData.MissionDelay != null) { TimeSpan age = DateTime.Now - inputData.MissionDelay.UpdateDate; outputDelay = new Train.RealTime.DelayType() { Age = (uint)age.TotalSeconds, DelayValue = inputData.MissionDelay.Delay, DelayReason = inputData.MissionDelay.DelayReason, DelayReasonCode = inputData.MissionDelay.DelayReasonCode, }; } if (inputData.MissionWeather != null) { TimeSpan age = DateTime.Now - inputData.MissionWeather.UpdateDate; outputWeather = new Train.RealTime.WeatherType() { Age = (uint)age.TotalSeconds, WeatherCondition = inputData.MissionWeather.WeatherCondition, WeatherConditionCode = inputData.MissionWeather.WeatherConditionCode, TemperatureInCentigrade = inputData.MissionWeather.TemperatureInCentigrade, TemperatureInFahrenheit = inputData.MissionWeather.TemperatureInFahrenheit, Humidity = inputData.MissionWeather.Humidity }; } } }
/// <summary> /// This function allows the GroundApp to clear the Real Time information associated to a /// particular mission and list of station. /// </summary> /// <param name="sessionId">Identifier for the session.</param> /// <param name="missionCode">The mission code.</param> /// <param name="stationList">List of stations.</param> /// <returns> /// The code “request accepted” when the command is valid and the list of informations for the /// given stations codes, or and error code when the command is rejected. /// </returns> RealTimeClearRealTimeInformationResult IRealTimeService.ClearRealTimeInformation(Guid sessionId, string missionCode, List <string> stationList) { var result = new RealTimeClearRealTimeInformationResult(); result.ResultCode = RealTimeServiceErrorEnum.ErrorInvalidSessionId; result.RequestId = Guid.Empty; result.MissionCode = missionCode; result.StationList = null; if (_sessionManager.IsSessionValid(sessionId)) { if (!string.IsNullOrEmpty(missionCode)) { string error = _sessionManager.GenerateRequestID(sessionId, out result.RequestId); if (string.IsNullOrEmpty(error)) { RealTimeInformationType missionData = RealTimeService._rtpisDataStore.GetMissionRealTimeInformation(result.MissionCode); List <RealTimeStationStatusType> stationListData = RealTimeService._rtpisDataStore.GetStationRealTimeInformation(result.MissionCode, stationList); if (missionData == null) { result.RequestId = Guid.Empty; result.ResultCode = RealTimeServiceErrorEnum.ErrorInvalidMissionCode; } else if (missionData.MissionDelay != null || missionData.MissionWeather != null || (stationListData != null && stationListData.Count > 0)) { result.ResultCode = RealTimeServiceErrorEnum.RequestAccepted; result.StationList = new List <string>(); RealTimeService._rtpisDataStore.ClearRealTimeInformation(result.MissionCode, stationList, out result.StationList); } else { result.RequestId = Guid.Empty; result.ResultCode = RealTimeServiceErrorEnum.ErrorNoRtpisData; } } else { result.RequestId = Guid.Empty; result.ResultCode = RealTimeServiceErrorEnum.ErrorRequestIdGeneration; } } else { result.RequestId = Guid.Empty; result.ResultCode = RealTimeServiceErrorEnum.ErrorInvalidMissionCode; } } else { result.ResultCode = RealTimeServiceErrorEnum.ErrorInvalidSessionId; } return(result); }
/// <summary>Sets mission real time information.</summary> /// <param name="missionCode">The mission code.</param> /// <param name="missionDelay">The mission delay.</param> /// <param name="missionWeather">The mission weather.</param> void IRTPISDataStore.SetMissionRealTimeInformation(string missionCode, RealTimeDelayType missionDelay, RealTimeWeatherType missionWeather) { bool dataUpdated = false; if (!string.IsNullOrEmpty(missionCode)) { lock (_missionData) { RealTimeInformationType update; bool found = _missionData.TryGetValue(missionCode, out update); if (!found) { update = new RealTimeInformationType(); dataUpdated = true; } if (missionDelay != null) { update.MissionDelay = missionDelay.Clone(); update.MissionDelay.UpdateDate = DateTime.Now; dataUpdated = true; } else if (update.MissionDelay != null) { update.MissionDelay = null; dataUpdated = true; } if (missionWeather != null) { update.MissionWeather = missionWeather.Clone(); update.MissionWeather.UpdateDate = DateTime.Now; dataUpdated = true; } else if (update.MissionWeather != null) { update.MissionWeather = null; dataUpdated = true; } if (!found) { _missionData.Add(missionCode, update); } ///Call event if (dataUpdated) { OnChanged(new RTPISDataStoreEventArgs(missionCode, null)); } } } }
/// <summary>Gets mission real time information.</summary> /// <param name="missionCode">The mission code.</param> /// <returns>The mission real time information.</returns> RealTimeInformationType IRTPISDataStore.GetMissionRealTimeInformation(string missionCode) { RealTimeInformationType result = null; if (!string.IsNullOrEmpty(missionCode)) { lock (_missionData) { if (_missionData.TryGetValue(missionCode, out result)) { result = result.Clone(); } } } return(result); }