/// <summary> /// Sets the mode of the car /// </summary> /// <param name="mode"></param> public override void SetCarMode(CarMode mode) { if (this.ClientArbiter != null) { try { this.DynamicsVehicle.SetRunMode(mode); Console.WriteLine("Set dynamics vehicle run mode to: " + mode.ToString()); } catch (Exception e) { Console.WriteLine("Error setting dynamics vehicle run mode to: " + mode.ToString() + "\n" + e.ToString()); } } }
/// <summary> /// Jumpstarts the ai with a new road network and mission if we can /// </summary> /// <param name="roadNetwork"></param> /// <param name="mission"></param> public override void JumpstartArbiter(ArbiterRoadNetwork roadNetwork, ArbiterMissionDescription mission) { try { ArbiterOutput.Output("Jumpstarting Arbiter"); // warn if carmode not correct CarMode carMode = CoreCommon.Communications.GetCarMode(); if (carMode != CarMode.Pause && carMode != CarMode.Human) { ArbiterOutput.Output("Warning: Vehicle is in CarMode: " + carMode.ToString()); } if (roadNetwork != null && mission != null) { // destroy intelligence if exists this.intelligenceCore.DestroyIntelligence(); // create roads and mission roadNetwork.SetSpeedLimits(mission.SpeedLimits); roadNetwork.GenerateVehicleAreas(); this.arbiterRoadNetwork = roadNetwork; this.arbiterMissionDescription = mission; CoreCommon.RoadNetwork = roadNetwork; CoreCommon.Mission = mission; // startup ai this.intelligenceCore.Jumpstart(); } else { ArbiterOutput.Output("RoadNetwork and Mission must both have value"); } } catch (Exception ex) { ArbiterOutput.Output("JumpstartArbiter(ArbiterRoadNetwork roadNetwork, ArbiterMissionDescription mission) Failed", ex); } }
/// <summary> /// Updates the ai with a new mission if can /// </summary> /// <param name="mission"></param> /// <returns></returns> public override bool UpdateMission(ArbiterMissionDescription mission) { try { ArbiterOutput.Output("Setting new mission"); CarMode carMode = CoreCommon.Communications.GetCarMode(); if (carMode == CarMode.Pause || carMode == CarMode.Human) { if (mission != null) { // create roads and mission CoreCommon.RoadNetwork.SetSpeedLimits(mission.SpeedLimits); this.arbiterMissionDescription = mission; CoreCommon.Mission = mission; return(true); } else { ArbiterOutput.Output("Mission must have value"); } } else { ArbiterOutput.Output("Cannot set mission when car is in CarMode: " + carMode.ToString()); } } catch (Exception ex) { ArbiterOutput.Output("UpdateMission(ArbiterMissionDescription mission) Failed", ex); } return(false); }