public Alert(Radar radar, string Pluginname, AirplaneBasic airplane, IconType iconType, MessageType messageType = MessageType.General, RatificationType ratificationType = RatificationType.NoRatification) { this.Airplane = airplane; this.PluginName = Pluginname; ID = radar.Name + Pluginname + Airplane.ID; ID = ID.Replace(" ", "").Replace("-", ""); ID = (ID.Length > 25) ? ID.Substring(0, 24) : ID; if (ratificationType != RatificationType.NoRatification) { RatificationType = ratificationType; ID += "Ratification" + ratificationType.ToString(); } this.Radar = radar; TimeCreated = DateTime.Now; TimeToBeRemoved = DateTime.Now.AddHours(1); this.Icon = iconType; TimeCreated = new DateTime( TimeCreated.Ticks - (TimeCreated.Ticks % TimeSpan.TicksPerSecond), TimeCreated.Kind );; AirplaneID = airplane.ID; this.AirplaneHexa = airplane.ID; this.AirplaneFlight = airplane.FlightName; this.AirplaneReg = airplane.Registration.Name; this.AirplaneFrom = airplane.From.ICAO; this.AirplaneTo = airplane.To.ICAO; SetMessage(messageType); }
private void MakeCurrentMessage(AirplaneBasic airplane, Radar radar, RatificationType ratificationType = RatificationType.NoRatification, int seed = 0) { try { this.Airplane = airplane; this.Message = String.Empty; this.Radar = radar; this.article = RandomListPhrases(listOfArticles); this.indefinitiveArticle = RandomListPhrases(listOfIndefinitiveArticles); #region Setting the airplane name and/or model if (airplane.AircraftType.IsValid || !String.IsNullOrEmpty(airplane.AircraftType.Name)) { airplaneTypeLongPhrase = String.Format(", {0}", airplane.AircraftType.Name); } if (!String.IsNullOrEmpty(this.Airplane.SpecialDescription)) { if (this.Airplane.IsSpecial) { airplaneRegistrationOrModel = String.Format("{0}, {1} {2}", airplane.SpecialDescription, this.article.ToLower(), this.Airplane.Registration.Name); } else { airplaneRegistrationOrModel = String.Format("{0}, ({1})", airplane.SpecialDescription, this.Airplane.Registration.Name); } if (!String.IsNullOrEmpty(this.Airplane.FlightName)) { airplaneRegistrationOrModel += String.Format(", {0}", this.Airplane.FlightName); } article = String.Empty; } else if (this.Airplane.Registration.IsValid && this.Airplane.AircraftType.Type == AircraftModel.AirplaneHeavy) { if (!String.IsNullOrEmpty(this.Airplane.FlightName)) { airplaneRegistrationOrModel = String.Format("{0}, {1} ({2})", airplane.AircraftType.Name, this.Airplane.FlightName, this.Airplane.Registration.Name); } //airplaneRegistrationOrModel = airplane.AircraftType.Name + ", o " + this.Airplane.FlightName + " (" + this.Airplane.Registration.Name + ")"; else { airplaneRegistrationOrModel = String.Format("{0}, ({1})", airplane.AircraftType.Name, this.Airplane.Registration.Name); } //airplaneRegistrationOrModel = airplane.AircraftType.Name + " (" + this.Airplane.Registration.Name + ")"; airplaneTypeLongPhrase = String.Empty; if (ratificationType == RatificationType.NoRatification) { article = this.indefinitiveArticle; } } else if (!string.IsNullOrEmpty(this.Airplane.FlightName) && this.Airplane.Registration.IsValid && this.Airplane.AircraftType.Type == AircraftModel.Helicopter) { airplaneRegistrationOrModel = String.Format("{0}, {1} {2} ({3})", airplane.AircraftType.Name, this.article.ToLower(), this.Airplane.FlightName, this.Airplane.Registration.Name); if (ratificationType == RatificationType.NoRatification) { article = this.indefinitiveArticle; } } else if (!string.IsNullOrEmpty(this.Airplane.FlightName) && this.Airplane.Registration.IsValid) { airplaneRegistrationOrModel = String.Format("{0} ({1})", this.Airplane.FlightName, this.Airplane.Registration.Name); } else if (!string.IsNullOrEmpty(this.Airplane.Registration.Name)) { airplaneRegistrationOrModel = this.Airplane.Registration.Name; } else if (this.Airplane.AircraftType.IsValid) { airplaneRegistrationOrModel = this.Airplane.AircraftType.Name; article = this.indefinitiveArticle; airplaneTypeLongPhrase = String.Empty; } else if (!String.IsNullOrEmpty(this.Airplane.FlightName)) { airplaneRegistrationOrModel = String.Format("{1} {2} (?)", airplane.AircraftType.Name, this.article, this.Airplane.FlightName); if (ratificationType == RatificationType.NoRatification) { article = this.indefinitiveArticle; } } else { airplaneRegistrationOrModel = String.Format("{0} (Hex: {1})", notIdentifiedMessage, this.Airplane.ID); article = String.Empty; } if (!String.IsNullOrEmpty(article)) { phraseBeginningWithAirplaneRegistration = article + " " + airplaneRegistrationOrModel; phraseEndingWithAirplaneRegistration = article.ToLower() + " " + airplaneRegistrationOrModel; } else { phraseBeginningWithAirplaneRegistration = airplaneRegistrationOrModel; phraseEndingWithAirplaneRegistration = airplaneRegistrationOrModel[0].ToString().ToLower() + airplaneRegistrationOrModel.Substring(1); } if (ratificationType == RatificationType.NoRatification) { #region This code was commented for a while, the system is not giving enough support to these features // if (!this.Airplane.IsKnowCountry) // { // phraseBeginningWithAirplaneRegistration += " - " + this.Airplane.Registration.Country + " - "; // phraseEndingWithAirplaneRegistration += " - " + this.Airplane.Registration.Country + " - "; // } // if (this.Airplane.FollowingChart != null) // { // phraseBeginningWithAirplaneRegistration += ", seguindo " + this.Airplane.FollowingChart.ChartType + " " + this.Airplane.FollowingChart.Name + ","; // phraseEndingWithAirplaneRegistration += ", seguindo " + this.Airplane.FollowingChart.ChartType + " " + this.Airplane.FollowingChart.Name + ","; // } // if (!String.IsNullOrEmpty(this.Airplane.RunwayName) && (this.Airplane.State == AirplaneStatus.Landing || this.Airplane.State == AirplaneStatus.TakingOff)) // { // phraseBeginningWithAirplaneRegistration += ", pista " + this.Airplane.RunwayName + ","; // phraseEndingWithAirplaneRegistration += ", pista " + this.Airplane.RunwayName + ","; // } #endregion #endregion #region Setting what is the route of the airplane if (airplane.From.City != airplane.To.City) { fromPlace = !String.IsNullOrEmpty(airplane.From.City) ? String.Format(" {0} {1}", RandomListPhrases(listOfFromMessages), airplane.From.City) : String.Empty; toPlace = !String.IsNullOrEmpty(airplane.To.City) ? String.Format(" {0} {1}", RandomListPhrases(listOfToMessages), airplane.To.City) : String.Empty; } #endregion if (this.Airplane != null) { if (airplane.State == AirplaneStatus.TakingOff) { Message = GetTakingOffPhrase(); } else if (airplane.State == AirplaneStatus.Landing) { Message = GetLandingPhrase(); } else if (airplane.State == AirplaneStatus.Cruise) { Message = GetCruisePhrase() + fromPlace + toPlace; } else if (airplane.State == AirplaneStatus.ParkingOrTaxing) { Message = GetParkingTaxiPhrase(); } Message += airplaneTypeLongPhrase; if (airplane.State == AirplaneStatus.Cruise || airplane.State == AirplaneStatus.Landing) { if (Message.Length <= 100) { Message += fromPlace; } } if (airplane.State == AirplaneStatus.Cruise || airplane.State == AirplaneStatus.TakingOff) { if (Message.Length <= 100) { Message += toPlace; } } if (Message.Length <= 110) { Message += RobotBumLibCore.Plugins.HelperPlugin.GetForwardLocationsPhrase(this.Airplane, true, 2); } else { Message += RobotBumLibCore.Plugins.HelperPlugin.GetForwardLocationsPhrase(this.Airplane, true); } } Message += "."; } else if (ratificationType == RatificationType.Chart) { this.Message += GetChartPhrase(); } else if (ratificationType == RatificationType.FinalRunway) { this.Message += GetRunwayPhrase(); } else if (ratificationType == RatificationType.Orbit) { this.Message += GetOrbitPhrase(); } if (Message.Length <= 125 && (airplane.State == AirplaneStatus.Landing || airplane.State == AirplaneStatus.TakingOff) && radar.MainAirport != null) { Message += " #Airport" + radar.MainAirport.ICAO; } if (Message.Length <= 130) { Message += " #RobotBum"; } Message = Regex.Replace(Message, @"\s+", " "); } catch (Exception e) { ErrorManager.ThrowError(e, "Message Maker " + e.Message); } }
public MessageMaker(AirplaneBasic airplane, Radar radar, int seed, RatificationType ratificationType = RatificationType.NoRatification) { MakeCurrentMessage(airplane, radar, ratificationType, seed); }