Ejemplo n.º 1
0
    private void JobCreationGUI()
    {
        EditorGUILayout.BeginVertical("box");
        TileManager.TileWidth       = (double)EditorGUILayout.FloatField("TileWidth", (float)TileManager.TileWidth);
        TileManager.tileRadius      = EditorGUILayout.IntField("TileRadius", TileManager.tileRadius);
        TileManager.LOD             = EditorGUILayout.IntField("LOD", TileManager.LOD);
        TileManager.OriginLatitude  = (double)EditorGUILayout.FloatField("OriginLatitude", (float)TileManager.OriginLatitude);
        TileManager.OriginLongitude = (double)EditorGUILayout.FloatField("OriginLongitude", (float)TileManager.OriginLongitude);
        EditorGUILayout.EndVertical();
        client.method = (SerializationMethod)EditorGUILayout.EnumPopup("SerializationMethod", client.method);

        if (GUILayout.Button("Send OSM-Job-Messages"))
        {
            startTime     = TimeStamp.Now();
            stopTime      = null;
            done          = false;
            generateLocal = false;

            client.SendOSMJobMessages(
                jobQueueName,
                replyQueueName,
                statusUpdateQueueName,
                TileManager.tileRadius,
                TileManager.TileWidth,
                TileManager.OriginLongitude,
                TileManager.OriginLatitude,
                client.method);
        }

        sequential = EditorGUILayout.ToggleLeft("Sequential", sequential);
        if (GUILayout.Button("Generate Local"))
        {
            startTime     = TimeStamp.Now();
            stopTime      = null;
            done          = false;
            generateLocal = true;

            if (sequential)
            {
                tiles = new List <Tile>();
                jobs  = 0;
                for (int i = -TileManager.tileRadius; i <= TileManager.tileRadius; i++)
                {
                    for (int j = -TileManager.tileRadius; j <= TileManager.tileRadius; j++)
                    {
                        StatusUpdateMessage msg = new StatusUpdateMessage(jobs, i + "," + j);

                        TodoItem worker = msg.AddTodo(Job.Worker);
                        //worker.AddTodo(Job.CreateTile);
                        worker.AddTodo(Job.StartOSMQuery);
                        worker.AddTodo(Job.StartProcedural);
                        worker.AddTodo(Job.ProceduralPreparation);
                        worker.AddTodo(Job.CreateTerrain);
                        worker.AddTodo(Job.MeshPreparation);
                        worker.AddTodo(Job.TileQuad);
                        worker.AddTodo(Job.River);
                        worker.AddTodo(Job.Ways);
                        worker.AddTodo(Job.CreateBuildingMesh);
                        worker.AddTodo(Job.FillMeshDivideMaterials);
                        worker.AddTodo(Job.GarbageCollection);
                        worker.AddTodo(Job.ProceduralDone);
                        SimpleClient.jobStatus.Add(jobs, msg);

                        Tile newTile = Tile.CreateTileGO(i, j, 5);
                        tiles.Add(newTile);
                        newTile.SetJobInfo(jobs, msg);

                        jobs++;
                    }
                }

                // Start first Tile-Generation
                // Next Tile will be started after "GenerationDone" of first Tile
                tiles[0].ProceduralDoneLocal += GenerationDone;
                tiles[0].StartQuery();
            }
            else
            {
                // Start parallel Generation of Tiles locally
                TileManager.GenerateLocal();
            }
        }

        #region ScaleWorkers
        int newNumberOfWorkers = EditorGUILayout.IntSlider("Number of Workers", numberOfWorkers, 1, 100);
        if (newNumberOfWorkers != numberOfWorkers)
        {
            if (newNumberOfWorkers > numberOfWorkers)
            {
                Debug.Log("Scaling UP number of workers (from " + numberOfWorkers + " to " + newNumberOfWorkers + ")");
            }
            else
            {
                Debug.Log("Scaling DOWN number of workers (from " + numberOfWorkers + " to " + newNumberOfWorkers + ")");
            }
            numberOfWorkers = newNumberOfWorkers;
            ScaleWorkers(numberOfWorkers);
        }
        #endregion // ScaleWorkers

        #region DrawOSM-Map
        if (osmMapRect == null)
        {
            osmMapRect = new OSMMapRect();
        }
        osmMapRect.DrawOSMMapRect(new Rect(0, 300, this.position.width, this.position.height - 300));
        if (osmMapRect.ShouldRepaint())
        {
            Repaint();
        }
        #endregion // DrawOSM-Map
    }