Ejemplo n.º 1
0
    /// <summary>
    /// Awakes the script.
    /// </summary>
    void Awake()
    {
        trafficContr = FindObjectOfType <TrafficIntegrationController>();
        timeContr    = FindObjectOfType <TimeController>();

        if (trafficContr != null)
        {
            simulationIntegrated     = (trafficContr.typeOfIntegration != TrafficIntegrationController.TypeOfIntegration.NoTrafficIntegration);
            UseFrustumForUpdate      = trafficContr.useFrustumForUpdate;
            UseCoordinateConversion  = trafficContr.useCoordinateConversion;
            brakingActive            = trafficContr.vehicleBrakingActive;
            timeToBrakeInSeconds     = trafficContr.timeToBrakeInSeconds;
            driversPatienceInSeconds = trafficContr.driversPatientInSeconds;
            angleOfView = trafficContr.driversAngleOfView;
        }
    }
Ejemplo n.º 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");
        }
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Awakes the script.
    /// </summary>
    void Awake()
    {
        logSeriesId = LoggerAssembly.GetLogSeriesId();

        smc  = FindObjectOfType <SumoMainController>();
        tic  = FindObjectOfType <TrafficIntegrationController>();
        ebpc = FindObjectOfType <EventButtonPanelController>();
        fped = FindObjectOfType <FlashPedestriansGlobalParameters>();

        if (timeSlider != null)
        {
            timeSliderContr = timeSlider.GetComponent <TimeSliderController>();
        }

        if (loadingSplash != null)
        {
            loadingSplash.SetActive(true);
        }
    }
Ejemplo n.º 4
0
    public bool Initialized()
    {
        if (simulationIO != null && trafficDB != null)
        {
            trafficController = FindObjectOfType <TrafficIntegrationController>();
            if (trafficController != null)
            {
                switch (trafficController.typeOfIntegration)
                {
                case TrafficIntegrationController.TypeOfIntegration.SumoLiveIntegration:
                    return(true);

                case TrafficIntegrationController.TypeOfIntegration.SumoFCDFile:
                case TrafficIntegrationController.TypeOfIntegration.VissimFZPFile:
                case TrafficIntegrationController.TypeOfIntegration.PWSimPWSFile:
                    // Check file exists.
                    return(File.Exists(fileName));

                case TrafficIntegrationController.TypeOfIntegration.MatsimDatabase:
                    // Check connection open.
                    Debug.Log(connectionString);
                    return(IsConnectionOpen(connectionString));
                    //case TrafficIntegrationController.TypeOfIntegration.DecisionTreeIntegration:
                    //    return;
                    //case TrafficIntegrationController.TypeOfIntegration.NoTrafficIntegration:
                    //    return;
                }
            }
            //if (useNetworkStream)
            //{
            //    return true;
            //}
            //else
            //{
            //    if (File.Exists(fileName))
            //    {
            //        return true;
            //    }
            //}
        }

        return(false);
    }
Ejemplo n.º 5
0
    /// <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;
            }
        }
    }
Ejemplo n.º 6
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>();
    }
    /// <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;
            }
        }
    }
Ejemplo n.º 8
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();
    }
Ejemplo n.º 9
0
 /// <summary>
 /// Set the traffic controller.
 /// </summary>
 /// <param name="trafficController"></param>
 public void SetTrafficIntegrationController(TrafficIntegrationController trafficController)
 {
     this.trafficController = trafficController;
 }