示例#1
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object can be used to retrieve data from input parameters and
        /// to store data in output parameters.</param>
        protected override async void SolveInstance(IGH_DataAccess DA)
        {
            String pNumber = null;

            DA.GetData(0, ref pNumber);
            if (pNumber == null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Please provide a valid project number");
            }

            String pName = null;

            DA.GetData(1, ref pName);
            if (pName == null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Please provide a valid project name");
            }

            String skyMatrix = null;

            DA.GetData(2, ref skyMatrix);
            if (skyMatrix == null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Please provide a valid Zone folder");
            }

            if (!File.Exists(skyMatrix))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Please provide a valid, existing, Zone folder");
            }

            String surfaceJSON = null;

            DA.GetData(3, ref surfaceJSON);
            if (surfaceJSON == null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Please provide a valid Zone folder");
            }

            if (!File.Exists(surfaceJSON))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Please provide a valid, existing, Zone folder");
            }

            String key = "";

            DA.GetData(6, ref key);
            if (key == "" || key == null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Please provide a valid batch account key");
            }

            /*List<String> analysisGrid = new List<string>();
             * DA.GetDataList(3, folderNames);
             *
             * if (folderNames.Count == 0)
             *  AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Please provide a valid folder name to simulate");*/

            String analysisGridFolder = null;

            DA.GetData(4, ref analysisGridFolder);
            if (analysisGridFolder == null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Please provide a valid Analysis Grid folder location");
            }

            if (!Directory.Exists(analysisGridFolder))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Please provide a valid folder to simulate");
            }

            bool run = false;

            DA.GetData(5, ref run);

            if (pNumber == null || pName == null || skyMatrix == null || !File.Exists(skyMatrix) || surfaceJSON == null || !File.Exists(surfaceJSON) || analysisGridFolder == null || !Directory.Exists(analysisGridFolder) || !run)
            {
                return;
            }

            //Everything is valid - let's run a simulation!
            AZEngine aEngine = new AZEngine(pNumber, pName, key);

            aEngine.CreateBlobStorage();

            //aEngine.CreateBatchClients(idfFiles.Count);
            //aEngine.CreateBatchClients(folderNames.Count);
            String[]      jsonZones     = Directory.GetFiles(analysisGridFolder);
            List <String> jsonZoneNames = new List <String>();

            foreach (String s in jsonZones)
            {
                jsonZoneNames.Add(s);
            }

            aEngine.CreateBatchClients(jsonZoneNames.Count);

            aEngine.InstallRadiance();

            while (!aEngine.TrueWhenTasksComplete())
            {
                //Wait until the install is complete...
            }

            //Upload each analysis grid
            foreach (String s in jsonZoneNames)
            {
                aEngine.UploadFile(s);
            }

            aEngine.UploadFile(skyMatrix);
            aEngine.UploadFile(surfaceJSON);

            while (!aEngine.TrueWhenTasksComplete())
            {
                //Wait till all have uploaded...
            }

            /*aEngine.UploadFile(epwFile);
             * aEngine.UploadFiles(idfFiles);
             *
             * aEngine.RunEnergyPlus(idfFiles, epwFile);*/

            //aEngine.UploadFile(zoneFolder);

            aEngine.RunRadiance(jsonZoneNames, Path.GetFileName(skyMatrix), Path.GetFileName(surfaceJSON));

            if (aEngine.TrueWhenTasksComplete())
            {
                DA.SetData(0, true);
            }
        }
示例#2
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object can be used to retrieve data from input parameters and
        /// to store data in output parameters.</param>
        protected override async void SolveInstance(IGH_DataAccess DA)
        {
            String pNumber = null;

            DA.GetData(0, ref pNumber);
            if (pNumber == null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Please provide a valid project number");
            }

            String pName = null;

            DA.GetData(1, ref pName);
            if (pName == null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Please provide a valid project name");
            }

            String epwFile = null;

            DA.GetData(2, ref epwFile);
            if (epwFile == null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Please provide a valid EPW file");
            }

            if (!File.Exists(epwFile))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Please provide a valid, existing, EPW file");
            }

            List <String> idfFiles = new List <string>();

            DA.GetDataList(3, idfFiles);
            if (idfFiles.Count == 0)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Please provide a valid list of IDF files");
            }

            if (!AllValidFiles(idfFiles))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Please provide a list of valid, existing, IDF files");
            }

            bool run = false;

            DA.GetData(4, ref run);

            if (pNumber == null || pName == null || epwFile == null || idfFiles.Count == 0 || !File.Exists(epwFile) || !AllValidFiles(idfFiles) || !run)
            {
                return;
            }

            //Everything is valid - let's run a simulation!
            AZEngine aEngine = new AZEngine(pNumber, pName);

            aEngine.CreateBlobStorage();

            aEngine.CreateBatchClients(idfFiles.Count);

            aEngine.InstallEnergyPlus();

            while (!aEngine.TrueWhenTasksComplete())
            {
                //Wait until the install is complete...
            }

            aEngine.UploadFile(epwFile);
            aEngine.UploadFiles(idfFiles);

            aEngine.RunEnergyPlus(idfFiles, epwFile);

            if (aEngine.TrueWhenTasksComplete())
            {
                DA.SetData(0, true);
            }
        }