public override void OnInspectorGUI() { DrawDefaultInspector(); SumoConfig script = (SumoConfig)target; if (GUILayout.Button("Run simulation")) { script.gameObject.GetComponentInChildren <SumoMainController>().RunSimulation(); } if (GUILayout.Button("Pause simulation")) { script.gameObject.GetComponentInChildren <SumoMainController>().PauseSimulation(); } if (GUILayout.Button("Run single step (only if pause)")) { script.gameObject.GetComponentInChildren <SumoMainController>().RunSingleStep(); } if (GUILayout.Button("Spawn bus")) { script.gameObject.GetComponentInChildren <SumoMainController>().AddNewVehicle("Bus" + (busCounter++), "BUS", "busRoute", -2, -4, 0, 0); } }
/// <summary> /// Awakes the script. /// </summary> void Awake() { conf = this.GetComponentInParent <SumoConfig>(); UseFrustumForUpdate = conf.useFrustumForUpdate; UseCoordinateConversion = conf.useCoordinateConversion; brakingActive = conf.vehicleBrakingActive; timeToBrakeInSeconds = conf.timeToBrakeInSeconds; driversPatienceInSeconds = conf.driversPatientInSeconds; angleOfView = conf.driversAngleOfView; }
/// <summary> /// Creates a thread for listening the FCD output of SUMO when the script is awaked. /// </summary> /// <seealso cref="ListeningSumoFCD"/> void Awake() { trafficContr = FindObjectOfType <TrafficIntegrationController>(); if (trafficContr != null) { port = trafficContr.remotePortForListener; pathFCD = trafficContr.pathSumoFCDFile; readFromFCDFile = (trafficContr.typeOfIntegration == TrafficIntegrationController.TypeOfIntegration.SumoFCDFile); readFromSumoFCDOutput = (trafficContr.typeOfIntegration == TrafficIntegrationController.TypeOfIntegration.SumoLiveIntegration); } else { // running SUMO with old module: conf = this.GetComponentInParent <SumoConfig>(); if (conf != null) { port = conf.remotePortForListener; pathFCD = conf.FCDFilePath; readFromFCDFile = conf.integrateSumo && conf.simulateFromFCDFile; readFromSumoFCDOutput = conf.integrateSumo && !conf.simulateFromFCDFile; } } trafficDB = FindObjectOfType <TrafficIntegrationData>(); _shouldStop = false; //Create a thread for the listener/reader if (readFromSumoFCDOutput) { ThreadStart ts = new ThreadStart(ListeningSumoFCD); thread = new Thread(ts); thread.Start(); UnityEngine.Debug.Log("Thread for SUMO FCD listening created"); } else if (readFromFCDFile) { ////Create a thread for the listener //ThreadStart ts = new ThreadStart(ReadingFileFCD); //thread = new Thread(ts); //thread.Start(); //UnityEngine.Debug.Log("Thread for FILE FCD listening created"); UnityEngine.Debug.Log("SumoFCDListener = obsolete. Please use SimulationReader"); } }
/// <summary> /// Awakes the script. /// </summary> void Awake() { trafficContr = FindObjectOfType <TrafficIntegrationController>(); if (trafficContr != null) { runSumoWhenGameModeStarts = (trafficContr.typeOfIntegration == TrafficIntegrationController.TypeOfIntegration.SumoLiveIntegration); timeStepVelocityInMs = trafficContr.timeStepVelocityInMs; } else { // running SUMO with old module: oldConf = this.GetComponentInParent <SumoConfig>(); if (oldConf != null) { runSumoWhenGameModeStarts = oldConf.integrateSumo && !oldConf.simulateFromFCDFile; } } }
/// <summary> /// Awakes the script. /// </summary> void Awake() { trafficContr = FindObjectOfType <TrafficIntegrationController>(); if (trafficContr != null) { useLocalHost = trafficContr.sumoIsRunningInLocalHost; ip = trafficContr.remoteIp; port = trafficContr.remotePortForTraci; makeTCPConnection = (trafficContr.typeOfIntegration == TrafficIntegrationController.TypeOfIntegration.SumoLiveIntegration); } else { // running SUMO with old module: oldConf = this.GetComponentInParent <SumoConfig>(); if (oldConf != null) { useLocalHost = oldConf.sumoIsRunningInLocalHost; ip = oldConf.remoteIp; port = oldConf.remotePortForTraci; makeTCPConnection = oldConf.integrateSumo && !oldConf.simulateFromFCDFile; } } }