Beispiel #1
0
 /// <summary>
 /// Initializes the fields when the script starts.
 /// </summary>
 void Start()
 {
     if (simulationIntegrated)
     {
         trafficData          = (TrafficIntegrationData)this.GetComponent("TrafficIntegrationData");
         vehControllers       = new Dictionary <string, TrafficIntegrationVehicle>();
         timeStepIndex        = 0;
         lastTimeStepExecuted = -1;
         cameraFrustum        = Camera.main.GetComponent <CameraFrustumScript>();
         routingContr         = FindObjectOfType <RoutingController>();
     }
 }
Beispiel #2
0
    /// <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");
        }
    }
Beispiel #3
0
    void Awake()
    {
        // Load the decision tree
        decisionTreeController = FindObjectOfType <DecisionTreeController>();
        if (decisionTreeController != null)
        {
            var path = decisionTreeController.pathDecisionXMLFile;
            decisionTree = DecisionTree.Load(path);
        }
        else
        {
            Debug.LogWarning("Scenario controller could not get the Decision Tree Controller");
        }

        // Get the traffic DB
        TrafficIntegrationController tic = FindObjectOfType <TrafficIntegrationController>();

        if (tic != null)
        {
            if (tic.typeOfIntegration == TrafficIntegrationController.TypeOfIntegration.DecisionTreeIntegration)
            {
                trafficDB = FindObjectOfType <TrafficIntegrationData>();

                if (trafficDB == null)
                {
                    Debug.LogWarning("Scenario controller could not get the Traffic Integration Data");
                }
            }
            else
            {
                Debug.LogWarning("Traffic Integration Controller not set for using decision tree integration");
            }
        }

        // Get the DecisionUIController
        decisionUI = FindObjectOfType <DecisionUIController>();

        // Get the TimeController
        timeController = FindObjectOfType <TimeController>();
    }
Beispiel #4
0
    void Awake()
    {
        timeController = FindObjectOfType <TimeController>();

        trafficDB = FindObjectOfType <TrafficIntegrationData>();
        if (trafficDB == null)
        {
            Debug.Log("TrafficIntegrationData NOT found. ");
            return;
        }

        trafficController = FindObjectOfType <TrafficIntegrationController>();
        if (trafficController == null)
        {
            Debug.Log("TrafficIntegrationController NOT found. ");
            return;
        }

        aramGisBoundaries = FindObjectOfType <MapBoundaries>();
        if (aramGisBoundaries == null)
        {
            Debug.Log("MapBoundaries NOT found. ");
            return;
        }

        var reader = FindSimulationReader();

        reader.SetTrafficDB(trafficDB);

        switch (trafficController.typeOfIntegration)
        {
        case TrafficIntegrationController.TypeOfIntegration.SumoLiveIntegration:
            SetUseNetworkStream(true);
            reader.SetIO(new SumoIO());
            break;

        case TrafficIntegrationController.TypeOfIntegration.SumoFCDFile:
            SetUseNetworkStream(false);
            reader.SetFileName(trafficController.pathSumoFCDFile);
            reader.SetIO(new SumoIO());
            break;

        case TrafficIntegrationController.TypeOfIntegration.VissimFZPFile:
            SetUseNetworkStream(false);
            reader.SetFileName(trafficController.pathVissimFZPFile);
            reader.SetIO(new VissimIO());
            break;

        case TrafficIntegrationController.TypeOfIntegration.MatsimDatabase:
            reader.SetConnectionString(aramGisBoundaries.GetOverridenConnectionString());
            reader.SetIO(new MatsimIO());
            break;

        case TrafficIntegrationController.TypeOfIntegration.PWSimPWSFile:
            SetUseNetworkStream(false);
            reader.SetFileName(trafficController.pathPWSimMetaFile);
            reader.SetIO(new ProtoMetaIO());
            break;

        case TrafficIntegrationController.TypeOfIntegration.DecisionTreeIntegration:
            return;

        case TrafficIntegrationController.TypeOfIntegration.NoTrafficIntegration:
            return;
        }

        reader.ThreadUpdate();
    }
Beispiel #5
0
 public void SetTrafficDB(TrafficIntegrationData trafficDB)
 {
     this.trafficDB = trafficDB;
 }