/// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            var launch = false;

            if (!DA.GetData(0, ref launch))
            {
                return;
            }
            DA.DisableGapLogic();
            const string url = "https://energyplus.net/weather";

            if (launch)
            {
                QueueManager.addToQueue(url, () =>
                {
                    try
                    {
                        Process.Start(url);
                    }
                    catch (Exception e)
                    {
                        StringCache.setCache(InstanceGuid.ToString(), e.Message);
                    }
                });
            }

            var errors = StringCache.getCache(InstanceGuid.ToString());

            if (errors != null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, errors);
            }
        }
Beispiel #2
0
        private void PollDownloadContent(
            string inputJson,
            string downloadPath,
            string localPath,
            string overrides,
            bool reload,
            string cacheKey
            )
        {
            var queueName = "Download" + cacheKey;

            // Get queue lock
            var queueLock  = StringCache.getCache(queueName);
            var downloaded = false;
            var inputData  = new Inputs().FromJson(inputJson);

            if (reload)
            {
                StringCache.setCache(InstanceGuid.ToString(), "");
            }

            if (queueLock != "true" && inputData.Task != null)
            {
                StringCache.setCache(queueName, "true");
                StringCache.setCache(cacheKey, null);
                QueueManager.addToQueue(queueName, () => {
                    try
                    {
                        while (!downloaded)
                        {
                            StringCache.setCache(cacheKey + "progress", "Downloading...");
                            ExpireSolutionThreadSafe(true);

                            downloaded = DownloadContent.Download(inputJson, downloadPath, localPath, overrides);
                            StringCache.setCache(cacheKey, downloaded.ToString());

                            if (!downloaded)
                            {
                                StringCache.setCache(cacheKey + "progress", "Waiting for results...");
                                ExpireSolutionThreadSafe(true);
                                Thread.Sleep(60000);
                            }
                            else
                            {
                                StringCache.setCache(cacheKey + "progress", "Downloaded files");
                            }
                            ExpireSolutionThreadSafe(true);
                        }
                    }
                    catch (Exception e)
                    {
                        StringCache.setCache(InstanceGuid.ToString(), e.Message);
                        StringCache.setCache(cacheKey, "error");
                    }
                    ExpireSolutionThreadSafe(true);
                    Thread.Sleep(2000);
                    StringCache.setCache(queueName, "");
                });
            }
        }
Beispiel #3
0
        public static void ExecuteAsync(
            string cacheKey,
            string queueName,
            string executeable
            )
        {
            // Get Cache to see if we already did this
            var cachedValues = StringCache.getCache(cacheKey);

            if (cachedValues == null)
            {
                // Get queue lock
                var queueLock = StringCache.getCache(queueName);
                if (queueLock != "true")
                {
                    StringCache.setCache(queueName, "true");
                    QueueManager.addToQueue(queueName, () =>
                    {
                        try
                        {
                            var results = executeable;
                            StringCache.setCache(cacheKey, results);
                        }
                        catch (Exception e)
                        {
                            //StringCache.AppendCache(this.InstanceGuid.ToString(), e.ToString() + "\n");
                        }

                        StringCache.setCache(queueName, "");
                    });
                    //ExpireSolution(true);
                }
            }
        }
Beispiel #4
0
        private void RunHoneybeeRadiance(string inputJson, string folder, string cacheKey, bool compute)
        {
            var results = Compute.CreateRadiance(
                inputJson,
                folder,
                compute
                );

            StringCache.setCache(cacheKey, results);
            StringCache.setCache(this.InstanceGuid.ToString(), "");
            if (compute)
            {
                StringCache.setCache(cacheKey + "create", "true");
            }
        }
Beispiel #5
0
        private void RunRadiance(string inputJson, List <GH_Mesh> geometry, string cacheKey, bool compute)
        {
            var geometryFile = Export.STLObject(geometry);
            var results      = Compute.Create(
                inputJson,
                geometryFile,
                "Probe",
                compute
                );

            StringCache.setCache(cacheKey, results);
            StringCache.setCache(InstanceGuid.ToString(), "");
            if (compute)
            {
                StringCache.setCache(cacheKey + "create", "true");
            }
        }
Beispiel #6
0
        public void PutOnQueue(FunctionToQueue functionToQueue, string cachedValues, bool create)
        {
            if (cachedValues != null && !create)
            {
                return;
            }

            // Get queue lock
            var queueLock = StringCache.getCache(QueueName);

            if (queueLock == "true")
            {
                return;
            }

            StringCache.setCache(QueueName, "true");
            StringCache.setCache(CacheKey, null);
            QueueManager.addToQueue(QueueName, () =>
            {
                try
                {
                    cachedValues = functionToQueue();
                    StringCache.setCache(CacheKey, cachedValues);
                    if (create)
                    {
                        StringCache.setCache(CacheKey + "create", "true");
                    }
                }
                catch (NoObjectFoundException)
                {
                    StringCache.setCache(CacheKey + "create", "");
                }
                catch (Exception e)
                {
                    StringCache.setCache(InstanceGuid.ToString(), e.Message);
                    StringCache.setCache(CacheKey, "error");
                    StringCache.setCache(CacheKey + "create", "");
                }


                ExpireSolutionThreadSafe(true);
                Thread.Sleep(2000);
                StringCache.setCache(QueueName, "");
            });
        }
Beispiel #7
0
        private void RunCFD(string inputJson, List <GH_Mesh> geometry, string cacheKey, bool compute)
        {
            var geometryFile       = Export.STLObject(geometry);
            var refinementGeometry = Export.RefinementRegionsToSTL(geometry);
            var results            = Compute.Create(
                inputJson,
                geometryFile,
                refinementGeometry,
                compute
                );

            StringCache.setCache(cacheKey, results);
            StringCache.setCache(InstanceGuid.ToString(), "");
            if (compute)
            {
                StringCache.setCache(cacheKey + "create", "true");
            }
        }
        private static bool HasFetched(string url, string method, int timeLimit = 100)
        {
            Logger.Debug($"Checking fetch cache");
            var now      = DateTime.Now;
            var cacheKey = $"{method} {url}";

            var value = StringCache.getCache(cacheKey);

            if (!string.IsNullOrEmpty(value))
            {
                var lastFetched = DateTime.Parse(value);
                var timeDelta   = now - lastFetched;
                if (timeDelta < TimeSpan.FromMilliseconds(timeLimit))
                {
                    Logger.Debug($"Found valid cache for {url} and {method}");
                    return(true);
                }
            }
            StringCache.setCache(cacheKey, now.ToUniversalTime().ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'"));
            Logger.Debug($"Did not find valid cache for {url} and {method}");
            return(false);
        }
Beispiel #9
0
        private void ClearLocalFolder(string localPath, bool clear, string cacheKey)
        {
            if (!Directory.Exists(localPath))
            {
                return;
            }
            if (!clear)
            {
                return;
            }

            var directoryInfo = new DirectoryInfo(localPath);

            foreach (var file in directoryInfo.EnumerateFiles())
            {
                file.Delete();
            }
            foreach (var dir in directoryInfo.EnumerateDirectories())
            {
                dir.Delete(true);
            }

            StringCache.setCache(cacheKey + "progress", "Cleared Folder");
        }
Beispiel #10
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            var inputJson = "";
            var exclude   = "";
            var include   = "";
            var rerun     = false;

            if (!DA.GetData(0, ref inputJson))
            {
                return;
            }
            DA.GetData(1, ref exclude);
            DA.GetData(2, ref include);
            DA.GetData(3, ref rerun);

            // Get Cache to see if we already did this
            var cacheKey     = inputJson + "exc" + exclude + "inc" + include;
            var cachedValues = StringCache.getCache(cacheKey);

            DA.DisableGapLogic();

            if (cachedValues == null || rerun == true)
            {
                var queueName = "FileList" + cacheKey;

                // Get queue lock
                var queueLock = StringCache.getCache(queueName);
                if (queueLock != "true")
                {
                    StringCache.setCache(queueName, "true");
                    StringCache.setCache(cacheKey, null);
                    QueueManager.addToQueue(queueName, () =>
                    {
                        try
                        {
                            var results = FileList.GetFileList(
                                inputJson,
                                exclude,
                                include
                                );
                            cachedValues = results;
                            StringCache.setCache(cacheKey, cachedValues);
                            StringCache.setCache(InstanceGuid.ToString(), "");
                        }
                        catch (Exception e)
                        {
                            StringCache.setCache(InstanceGuid.ToString(), e.Message);
                            StringCache.setCache(cacheKey, "error");
                        }

                        ExpireSolutionThreadSafe(true);
                        Thread.Sleep(2000);
                        StringCache.setCache(queueName, "");
                    });
                }
            }

            // Read from Cache
            if (cachedValues != null)
            {
                var outputs = cachedValues.Split(',');
                if (outputs.Length > 1)
                {
                    outputs = outputs.OrderBy(file => file).ToArray();
                }
                DA.SetDataList(0, outputs);
            }

            HandleErrors();
        }
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            string inputJson   = null;
            var    epwFile     = "";
            var    method      = 0;
            var    probes      = new List <string>();
            var    thresholds  = new List <string>();
            var    cpus        = 4;
            var    dependentOn = "Probe";
            var    create      = false;

            if (!DA.GetData(0, ref inputJson))
            {
                return;
            }
            if (inputJson == "error")
            {
                return;
            }
            if (!DA.GetData(1, ref epwFile))
            {
                return;
            }
            DA.GetData(2, ref method);
            if (!DA.GetDataList(3, probes))
            {
                return;
            }

            DA.GetDataList(4, thresholds);
            DA.GetData(5, ref cpus);

            DA.GetData(6, ref dependentOn);
            DA.GetData(8, ref create);

            // Get Cache to see if we already did this
            var cacheKey     = string.Join("", probes) + epwFile + inputJson + method;
            var cachedValues = StringCache.getCache(cacheKey);

            DA.DisableGapLogic();

            if (cachedValues == null || create)
            {
                const string queueName = "outdoorComfortSimulation";

                // Get queue lock
                var queueLock = StringCache.getCache(queueName);
                if (queueLock != "true")
                {
                    StringCache.setCache(queueName, "true");
                    StringCache.setCache(InstanceGuid.ToString(), "");
                    StringCache.setCache(cacheKey, null);
                    QueueManager.addToQueue(queueName, () =>
                    {
                        try
                        {
                            cachedValues = OutdoorComfort.CreateComfortTask(
                                inputJson,
                                epwFile,
                                Presets[method],
                                probes,
                                thresholds,
                                ComponentUtils.ValidateCPUs(cpus),
                                dependentOn,
                                create
                                );
                            StringCache.setCache(cacheKey, cachedValues);
                            if (create)
                            {
                                StringCache.setCache(cacheKey + "create", "true");
                            }
                        }
                        catch (NoObjectFoundException)
                        {
                            StringCache.setCache(cacheKey + "create", "");
                        }
                        catch (Exception e)
                        {
                            StringCache.AppendCache(InstanceGuid.ToString(), e.Message + "\n");
                            StringCache.setCache(cacheKey, "error");
                            StringCache.setCache(cacheKey + "create", "");
                        }


                        ExpireSolutionThreadSafe(true);
                        Thread.Sleep(2000);
                        StringCache.setCache(queueName, "");
                    });
                }
            }

            HandleErrors();

            // Read from Cache
            if (cachedValues != null)
            {
                DA.SetData(0, cachedValues);
                Message = "";
                if (StringCache.getCache(cacheKey + "create") == "true")
                {
                    Message = "Task Created";
                }
            }
        }
Beispiel #12
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 void SolveInstance(IGH_DataAccess DA)
        {
            string inputJson = null;
            var    overrides = "";
            var    caseDir   = "metrics";
            var    preset_   = 0;
            var    compute   = false;
            var    cpus      = 1;

            if (!DA.GetData(0, ref inputJson))
            {
                return;
            }
            if (inputJson == "error")
            {
                return;
            }
            if (!DA.GetData(1, ref preset_))
            {
                return;
            }

            var preset = Presets[preset_];

            if (!DA.GetData(2, ref overrides))
            {
                return;
            }

            DA.GetData(3, ref cpus);
            DA.GetData(4, ref caseDir);
            DA.GetData(5, ref compute);

            // Get Cache to see if we already did this
            var cacheKey     = inputJson;
            var cachedValues = StringCache.getCache(cacheKey);

            DA.DisableGapLogic();

            if (cachedValues == null || compute)
            {
                var queueName = "daylightMetric" + cacheKey;
                StringCache.setCache(InstanceGuid.ToString(), "");

                // Get queue lock
                var queueLock = StringCache.getCache(queueName);
                if (queueLock != "true")
                {
                    StringCache.setCache(queueName, "true");
                    QueueManager.addToQueue(queueName, () =>
                    {
                        try
                        {
                            cachedValues = DaylightMetrics.Create(inputJson, overrides, preset,
                                                                  ComponentUtils.ValidateCPUs(cpus), caseDir, compute);
                            StringCache.setCache(cacheKey, cachedValues);
                            if (compute)
                            {
                                StringCache.setCache(cacheKey + "create", "true");
                            }
                        }
                        catch (NoObjectFoundException)
                        {
                            StringCache.setCache(cacheKey + "create", "");
                        }
                        catch (Exception e)
                        {
                            StringCache.setCache(InstanceGuid.ToString(), e.Message);
                            StringCache.setCache(cacheKey, "error");
                            StringCache.setCache(cacheKey + "create", "");
                        }

                        ExpireSolutionThreadSafe(true);
                        Thread.Sleep(2000);
                        StringCache.setCache(queueName, "");
                    });
                }
            }

            HandleErrors();

            // Read from Cache
            if (cachedValues != null)
            {
                var outputs = cachedValues;
                DA.SetData(0, outputs);
                Message = "";
                if (StringCache.getCache(cacheKey + "create") == "true")
                {
                    Message = "Task Created";
                }
            }
        }
Beispiel #13
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            string inputJson = null;
            var    geometry  = new List <GH_Mesh>();
            var    compute   = false;
            var    folder    = string.Empty;

            if (!DA.GetData(0, ref inputJson))
            {
                return;
            }
            if (inputJson == "error")
            {
                return;
            }

            DA.GetDataList(1, geometry);
            DA.GetData(2, ref folder);

            DA.GetData(3, ref compute);

            // Get Cache to see if we already did this
            var cacheKey     = inputJson;
            var cachedValues = StringCache.getCache(cacheKey);

            DA.DisableGapLogic();

            if (cachedValues == null || compute)
            {
                var queueName = "compute" + cacheKey;
                StringCache.setCache(InstanceGuid.ToString(), "");

                // Get queue lock
                var queueLock = StringCache.getCache(queueName);
                if (queueLock != "true")
                {
                    StringCache.setCache(queueName, "true");
                    QueueManager.addToQueue(queueName, () =>
                    {
                        try
                        {
                            try
                            {
                                TimeEstimate = Compute.GetTaskEstimates(inputJson);
                            }
                            catch (Exception)
                            {
                            }

                            RunOnCompute(inputJson, geometry, folder, cacheKey, compute);
                        }
                        catch (NoObjectFoundException)
                        {
                            StringCache.setCache(cacheKey + "create", "");
                        }
                        catch (Exception e)
                        {
                            StringCache.setCache(InstanceGuid.ToString(), e.Message);
                            StringCache.setCache(cacheKey, "error");
                            StringCache.setCache(cacheKey + "create", "");
                        }

                        ExpireSolutionThreadSafe(true);
                        Thread.Sleep(2000);
                        StringCache.setCache(queueName, "");
                    });
                }
            }

            HandleErrors();

            Message = "";

            // Read from Cache
            if (cachedValues != null)
            {
                DA.SetData(0, Info(TimeEstimate));
                DA.SetData(1, cachedValues);

                if (StringCache.getCache(cacheKey + "create") == "true")
                {
                    Message = "Tasks Created";
                }
            }
        }
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            string input      = null;
            string uploadPath = null;
            string text       = null;
            var    upload     = false;

            if (!DA.GetData(0, ref input))
            {
                return;
            }
            if (!DA.GetData(1, ref uploadPath))
            {
                return;
            }
            if (!DA.GetData(2, ref text))
            {
                return;
            }
            DA.GetData(3, ref upload);

            // Get Cache to see if we already did this
            var cacheKey     = input + uploadPath + text;
            var cachedValues = StringCache.getCache(cacheKey);

            DA.DisableGapLogic();

            var response = string.Empty;

            if (cachedValues == null || upload == true)
            {
                const string queueName = "upload";

                // Get queue lock
                var queueLock = StringCache.getCache(queueName);
                if (queueLock != "true")
                {
                    try
                    {
                        cachedValues = UploadFile.UploadTextFile(input, uploadPath, text, upload);
                        StringCache.setCache(cacheKey, cachedValues);
                        StringCache.setCache(this.InstanceGuid.ToString(), "");
                        if (upload)
                        {
                            StringCache.setCache(cacheKey + "create", "true");
                        }
                    }
                    catch (Exception e)
                    {
                        StringCache.AppendCache(this.InstanceGuid.ToString(), e.Message);
                        StringCache.setCache(cacheKey, "error");
                        StringCache.setCache(cacheKey + "create", "");
                    }

                    ExpireSolutionThreadSafe(true);
                    StringCache.setCache(queueName, "");
                }
            }


            HandleErrors();

            // Read from Cache
            if (cachedValues != null)
            {
                DA.SetData(0, cachedValues);
                Message = "";
                if (StringCache.getCache(cacheKey + "create") == "true")
                {
                    Message = "File Uploaded";
                }
            }
        }
Beispiel #15
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            string folder   = null;
            var    criteria = 0;
            var    thresholdsFrequencies = new List <string>();
            var    refresh = false;

            if (!DA.GetData(0, ref folder))
            {
                return;
            }
            DA.GetData(1, ref criteria);
            DA.GetDataList(2, thresholdsFrequencies);
            DA.GetData(3, ref refresh);

            var cacheKey     = folder + criteria + string.Join("", thresholdsFrequencies);
            var cachedValues = StringCache.getCache(cacheKey);

            DA.DisableGapLogic();

            if (cachedValues == null || refresh)
            {
                const string queueName = "thresholdResults";
                StringCache.setCache(InstanceGuid.ToString(), "");

                // Get queue lock
                var queueLock = StringCache.getCache(queueName);
                if (queueLock != "true")
                {
                    StringCache.setCache(queueName, "true");
                    StringCache.setCache(cacheKey + "progress", "Loading...");

                    QueueManager.addToQueue(queueName, () =>
                    {
                        try
                        {
                            var results = WindThreshold.ReadThresholdResults(folder);
                            if (criteria == 1)
                            {
                                _thresholdFrequencies = thresholdsFrequencies
                                                        .Select(frequency => new Thresholds.WindThreshold().FromJson(frequency)).ToList();
                                lawsonResults = WindThreshold.LawsonsCriteria(results, _thresholdFrequencies);
                            }
                            else
                            {
                                (thresholdOutput, thresholdLegend) = TransposeThresholdMatrix(results);
                            }
                            StringCache.setCache(cacheKey + "progress", "Done");
                            StringCache.setCache(cacheKey, "results");
                        }
                        catch (Exception e)
                        {
                            StringCache.setCache(InstanceGuid.ToString(), e.Message);
                            StringCache.setCache(cacheKey, "error");
                            StringCache.setCache(cacheKey + "progress", "");
                        }

                        ExpireSolutionThreadSafe(true);
                        Thread.Sleep(2000);
                        StringCache.setCache(queueName, "");
                    });
                    ExpireSolutionThreadSafe(true);
                }
            }

            HandleErrors();

            if (lawsonResults != null && criteria == 1)
            {
                foreach (var season in lawsonResults.Keys)
                {
                    var data = ConvertLawsonToDataTree(lawsonResults[season]);
                    AddToOutput(DA, season, data);
                }

                info = UpdateInfo(lawsonResults.First().Value.Keys.ToList(), _thresholdFrequencies, criteria);
                RemoveUnusedOutputs(lawsonResults.Keys.ToList());
            }

            if (thresholdOutput != null && criteria == 0)
            {
                foreach (var key in thresholdOutput.Keys)
                {
                    AddToOutput(DA, key, thresholdOutput[key]);
                }

                info = UpdateInfo(
                    thresholdLegend["patch"],
                    thresholdLegend["threshold"].Select(threshold => new Thresholds.WindThreshold {
                    Field = threshold
                })
                    .ToList(),
                    criteria
                    );
                RemoveUnusedOutputs(thresholdOutput.Keys.ToList());
            }

            if (info != null)
            {
                DA.SetDataTree(0, info);
            }
            Message = StringCache.getCache(cacheKey + "progress");
        }
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            string inputJson   = null;
            var    points      = new GH_Structure <GH_Point>();
            var    names       = new List <string>();
            var    fields      = new List <string>();
            var    mesh        = new GH_Structure <GH_Mesh>();
            var    cpus        = 1;
            var    dependentOn = "VirtualWindTunnel";
            var    caseDir     = "VWT";
            var    overrides   = "";
            var    create      = false;

            if (!DA.GetData(0, ref inputJson))
            {
                return;
            }
            if (!DA.GetDataTree(1, out points))
            {
                return;
            }
            if (!DA.GetDataList(2, names))
            {
                for (var i = 0; i < points.Branches.Count; i++)
                {
                    names.Add($"set{i.ToString()}");
                }
            }
            else
            {
                foreach (var name in names)
                {
                    ValidateName(name);
                }
            }

            if (!DA.GetDataList(3, fields))
            {
                fields.Add("U");
            }

            DA.GetDataTree(4, out mesh);
            DA.GetData(5, ref cpus);
            DA.GetData(6, ref dependentOn);
            DA.GetData(7, ref caseDir);
            DA.GetData(8, ref overrides);
            DA.GetData(9, ref create);

            var convertedPoints = Geometry.ConvertPointsToList(points);

            caseDir = caseDir.TrimEnd('/');

            // Get Cache to see if we already did this
            var cacheKey     = inputJson + string.Join("", points) + string.Join("", fields) + string.Join("", names);
            var cachedValues = StringCache.getCache(cacheKey);

            DA.DisableGapLogic();

            if (cachedValues == null || create)
            {
                var queueName = "probe";

                // Get queue lock
                var queueLock = StringCache.getCache(queueName);
                if (queueLock != "true")
                {
                    StringCache.setCache(queueName, "true");
                    StringCache.setCache(cacheKey, null);
                    QueueManager.addToQueue(queueName, () =>
                    {
                        try
                        {
                            var meshFile = Export.MeshToObj(mesh, names);
                            var results  = Probe.ProbePoints(
                                inputJson,
                                convertedPoints,
                                fields,
                                names,
                                ComponentUtils.ValidateCPUs(cpus),
                                meshFile,
                                dependentOn,
                                caseDir,
                                overrides,
                                create
                                );
                            cachedValues = results;
                            StringCache.setCache(cacheKey, cachedValues);
                            if (create)
                            {
                                StringCache.setCache(cacheKey + "create", "true");
                            }
                        }
                        catch (NoObjectFoundException)
                        {
                            StringCache.setCache(cacheKey + "create", "");
                        }
                        catch (Exception e)
                        {
                            StringCache.setCache(InstanceGuid.ToString(), e.Message);
                            StringCache.setCache(cacheKey, "error");
                            StringCache.setCache(cacheKey + "create", "");
                        }


                        ExpireSolutionThreadSafe(true);
                        Thread.Sleep(2000);
                        StringCache.setCache(queueName, "");
                    });
                }
            }

            HandleErrors();
            Message = "";

            if (cachedValues != null)
            {
                DA.SetData(0, cachedValues);

                if (StringCache.getCache(cacheKey + "create") == "true")
                {
                    Message = "Task Created";
                }
            }
        }
Beispiel #17
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            string auth            = null;
            string projectName     = null;
            int?   projectNumber   = null;
            var    excludeChildren = true;
            var    refresh         = false;

            if (!DA.GetData(0, ref auth))
            {
                return;
            }
            if (!DA.GetData(1, ref projectName))
            {
                return;
            }
            DA.GetData(2, ref projectNumber);
            DA.GetData(3, ref excludeChildren);
            DA.GetData(4, ref refresh);

            // Get Cache to see if we already did this
            var cacheKey     = projectName + projectNumber + excludeChildren;
            var cachedValues = StringCache.getCache(cacheKey);

            DA.DisableGapLogic();

            if (cachedValues == null || refresh == true)
            {
                var queueName = "ListTasks" + cacheKey;

                // Get queue lock
                var queueLock = StringCache.getCache(queueName);
                if (queueLock != "true")
                {
                    StringCache.setCache(queueName, "true");
                    StringCache.setCache(cacheKey, null);
                    QueueManager.addToQueue(queueName, () =>
                    {
                        try
                        {
                            cachedValues = ProjectAndTask.GetTasks(
                                auth,
                                projectName,
                                projectNumber,
                                excludeChildren
                                );
                            StringCache.setCache(cacheKey, cachedValues);
                            StringCache.setCache(this.InstanceGuid.ToString(), "");
                        }
                        catch (NoObjectFoundException)
                        {
                            StringCache.setCache(cacheKey + "create", "");
                        }
                        catch (Exception e)
                        {
                            StringCache.setCache(InstanceGuid.ToString(), e.Message);
                            StringCache.setCache(cacheKey, "error");
                        }

                        ExpireSolutionThreadSafe(true);
                        Thread.Sleep(2000);
                        StringCache.setCache(queueName, "");
                    });
                }
            }

            HandleErrors();

            // Read from Cache
            if (cachedValues != null)
            {
                var outputs = cachedValues.Split(';');
                if (outputs.Length > 1)
                {
                    outputs = outputs.OrderBy(task => task).ToArray();
                }
                DA.SetDataList(0, outputs);
            }
        }
Beispiel #18
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            string inputJson   = null;
            var    epwFile     = "";
            var    patches     = new List <string>();
            var    thresholds  = new List <string>();
            var    cpus        = 4;
            var    dependentOn = "Probe";
            var    create      = false;

            if (!DA.GetData(0, ref inputJson))
            {
                return;
            }
            if (inputJson == "error")
            {
                return;
            }
            if (!DA.GetData(1, ref epwFile))
            {
                return;
            }
            if (!DA.GetDataList(2, patches))
            {
                patches.Add("set1");
            }

            DA.GetDataList(3, thresholds);
            DA.GetData(4, ref cpus);

            DA.GetData(5, ref dependentOn);
            DA.GetData(6, ref create);

            // Get Cache to see if we already did this
            var cacheKey     = string.Join("", patches) + epwFile + inputJson;
            var cachedValues = StringCache.getCache(cacheKey);

            DA.DisableGapLogic();

            if (cachedValues == null || create)
            {
                var queueName = "windThreshold";

                // Get queue lock
                var queueLock = StringCache.getCache(queueName);
                if (queueLock != "true")
                {
                    StringCache.setCache(queueName, "true");
                    StringCache.setCache(InstanceGuid.ToString(), "");
                    StringCache.setCache(cacheKey, null);
                    QueueManager.addToQueue(queueName, () =>
                    {
                        try
                        {
                            var results = WindThreshold.ComputeWindThresholds(
                                inputJson,
                                epwFile,
                                patches,
                                thresholds,
                                ComponentUtils.ValidateCPUs(cpus),
                                dependentOn,
                                create
                                );
                            cachedValues = results;
                            StringCache.setCache(cacheKey, cachedValues);
                            if (create)
                            {
                                StringCache.setCache(cacheKey + "create", "true");
                            }
                        }
                        catch (NoObjectFoundException)
                        {
                            StringCache.setCache(cacheKey + "create", "");
                        }
                        catch (Exception e)
                        {
                            StringCache.setCache(InstanceGuid.ToString(), e.Message);
                            StringCache.setCache(cacheKey, "error");
                            StringCache.setCache(cacheKey + "create", "");
                        }


                        ExpireSolutionThreadSafe(true);
                        Thread.Sleep(2000);
                        StringCache.setCache(queueName, "");
                    });
                }
            }

            HandleErrors();

            // Read from Cache
            if (cachedValues != null)
            {
                DA.SetData(0, cachedValues);
                Message = "";
                if (StringCache.getCache(cacheKey + "create") == "true")
                {
                    Message = "Task Created";
                }
            }
        }
Beispiel #19
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            string auth          = null;
            string projectName   = null;
            int?   projectNumber = null;
            string taskName      = null;
            string overrides     = null;
            var    create        = false;

            if (!DA.GetData(0, ref auth))
            {
                return;
            }
            if (!DA.GetData(1, ref projectName))
            {
                return;
            }
            DA.GetData(2, ref projectNumber);
            if (!DA.GetData(3, ref taskName))
            {
                return;
            }
            DA.GetData(4, ref overrides);
            DA.GetData(5, ref create);

            ValidateName(taskName);
            ValidateName(projectName);

            // Get Cache to see if we already did this
            var cacheKey     = projectName + taskName + overrides;
            var cachedValues = StringCache.getCache(cacheKey);

            DA.DisableGapLogic();

            if (cachedValues == null || create)
            {
                var queueName = "ProjectAndTask" + cacheKey;

                // Get queue lock
                var queueLock = StringCache.getCache(queueName);
                if (queueLock != "true")
                {
                    StringCache.setCache(queueName, "true");
                    StringCache.setCache(cacheKey, null);
                    QueueManager.addToQueue(queueName, () =>
                    {
                        try
                        {
                            var results = ProjectAndTask.GetOrCreate(
                                auth,
                                projectName,
                                projectNumber,
                                taskName,
                                overrides,
                                create
                                );
                            cachedValues = results;
                            StringCache.setCache(cacheKey, cachedValues);
                            StringCache.setCache(this.InstanceGuid.ToString(), "");
                            if (create)
                            {
                                StringCache.setCache(cacheKey + "create", "true");
                            }
                        }
                        catch (Exception e)
                        {
                            StringCache.setCache(InstanceGuid.ToString(), e.Message);
                            StringCache.setCache(cacheKey, "error");
                            StringCache.setCache(cacheKey + "create", "");
                        }

                        ExpireSolutionThreadSafe(true);
                        Thread.Sleep(2000);
                        StringCache.setCache(queueName, "");
                    });
                }
            }

            // Read from Cache
            if (cachedValues != null)
            {
                var outputs = cachedValues;
                DA.SetData(0, outputs);
                Message = "";
                if (StringCache.getCache(cacheKey + "create") == "true")
                {
                    Message = "Task Created";
                }
            }

            // Handle Errors
            var errors = StringCache.getCache(InstanceGuid.ToString());

            if (!string.IsNullOrEmpty(errors))
            {
                var messageLevel = GH_RuntimeMessageLevel.Error;
                if (errors.Contains("No object found"))
                {
                    errors       = "Could not find the desired project. Click create to create a new project.";
                    messageLevel = GH_RuntimeMessageLevel.Warning;
                }

                AddRuntimeMessage(messageLevel, errors);
            }
        }
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            string folder  = null;
            var    refresh = false;

            if (!DA.GetData(0, ref folder))
            {
                return;
            }
            DA.GetData(1, ref refresh);

            var cacheKey     = folder;
            var cachedValues = StringCache.getCache(cacheKey);

            DA.DisableGapLogic();

            if (cachedValues == null || refresh)
            {
                const string queueName = "comfortResults";
                StringCache.setCache(InstanceGuid.ToString(), "");

                // Get queue lock
                var queueLock = StringCache.getCache(queueName);
                if (queueLock != "true")
                {
                    StringCache.setCache(queueName, "true");
                    StringCache.setCache(cacheKey + "progress", "Loading...");

                    QueueManager.addToQueue(queueName, () =>
                    {
                        try
                        {
                            var results = OutdoorComfort.ReadComfortResults(folder);
                            (comfortOutput, comfortLegend) = TransposeThresholdMatrix(results);
                            StringCache.setCache(cacheKey + "progress", "Done");
                            StringCache.setCache(cacheKey, "results");
                            StringCache.setCache(InstanceGuid.ToString(), "");
                        }
                        catch (Exception e)
                        {
                            StringCache.setCache(InstanceGuid.ToString(), e.Message);
                            StringCache.setCache(cacheKey, "error");
                            StringCache.setCache(cacheKey + "progress", "");
                        }

                        ExpireSolutionThreadSafe(true);
                        Thread.Sleep(2000);
                        StringCache.setCache(queueName, "");
                    });
                    ExpireSolutionThreadSafe(true);
                }
            }

            // Handle Errors
            HandleErrors();

            if (comfortOutput != null)
            {
                foreach (var key in comfortOutput.Keys)
                {
                    AddToOutput(DA, key, comfortOutput[key]);
                }

                info = UpdateInfo(
                    comfortLegend["patch"],
                    comfortLegend["threshold"].Select(threshold => new Thresholds.ComfortThreshold {
                    Field = threshold
                })
                    .ToList()
                    );
            }

            if (info != null)
            {
                DA.SetDataTree(0, info);
            }

            Message = StringCache.getCache(cacheKey + "progress");
        }
Beispiel #21
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            string folder  = null;
            var    refresh = false;

            if (!DA.GetData(0, ref folder))
            {
                return;
            }
            DA.GetData(1, ref refresh);

            // Get Cache to see if we already did this
            var cacheKey     = folder;
            var cachedValues = StringCache.getCache(cacheKey);

            DA.DisableGapLogic();

            if (cachedValues == null || refresh)
            {
                const string queueName = "radiationProbeResults";
                StringCache.setCache(InstanceGuid.ToString(), "");

                // Get queue lock
                var queueLock = StringCache.getCache(queueName);
                if (queueLock != "true")
                {
                    StringCache.setCache(queueName, "true");
                    StringCache.setCache(cacheKey + "progress", "Loading...");

                    QueueManager.addToQueue(queueName, () =>
                    {
                        try
                        {
                            var results  = RadiationProbeResult.ReadResults(folder);
                            probeResults = ConvertToDataTree(results);
                            info         = UpdateInfo(results);
                            StringCache.setCache(cacheKey + "progress", "Done");
                            StringCache.setCache(cacheKey, "results");
                        }
                        catch (Exception e)
                        {
                            StringCache.setCache(InstanceGuid.ToString(), e.Message);
                            StringCache.setCache(cacheKey, "error");
                            StringCache.setCache(cacheKey + "progress", "");
                        }

                        ExpireSolutionThreadSafe(true);
                        Thread.Sleep(2000);
                        StringCache.setCache(queueName, "");
                    });
                    ExpireSolutionThreadSafe(true);
                }
            }

            HandleErrors();

            if (info != null)
            {
                DA.SetDataTree(0, info);
            }

            if (probeResults != null)
            {
                DA.SetDataTree(1, probeResults);
            }

            Message = StringCache.getCache(cacheKey + "progress");
        }
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            var baseSurfaces    = new List <Brep>();
            var gridSize        = 1.0;
            var excludeGeometry = new List <Brep>();
            var offset          = 1.5;
            var offsetDirection = 2;

            if (!DA.GetDataList(0, baseSurfaces))
            {
                return;
            }
            DA.GetData(1, ref gridSize);
            DA.GetDataList(2, excludeGeometry);
            DA.GetData(3, ref offset);
            DA.GetData(4, ref offsetDirection);

            var cacheKey =
                JsonConvert.SerializeObject(baseSurfaces) +
                gridSize.ToString() +
                JsonConvert.SerializeObject(excludeGeometry) +
                offset.ToString() + offsetDirection.ToString();
            var          cachedValues = StringCache.getCache(cacheKey);
            const string queueName    = "analysisMesh";

            DA.DisableGapLogic();


            if (cachedValues == null)
            {
                StringCache.setCache(InstanceGuid.ToString(), "");

                // Get queue lock
                var queueLock = StringCache.getCache(queueName);
                if (queueLock != "true")
                {
                    StringCache.setCache(queueName, "true");
                    StringCache.setCache(queueName + "progress", "Loading...");

                    QueueManager.addToQueue(queueName, () =>
                    {
                        try
                        {
                            meshResult = Geometry.CreateAnalysisMesh(
                                baseSurfaces, gridSize, excludeGeometry, offset, OffsetDirection[offsetDirection]
                                );

                            StringCache.setCache(queueName + "progress", "Done");
                            StringCache.setCache(cacheKey, meshResult.GetHashCode().ToString());
                        }
                        catch (Exception e)
                        {
                            StringCache.setCache(InstanceGuid.ToString(), e.Message);
                            StringCache.setCache(cacheKey, "error");
                            StringCache.setCache(queueName + "progress", "");
                        }

                        ExpireSolutionThreadSafe(true);
                        Thread.Sleep(2000);
                        StringCache.setCache(queueName, "");
                    });
                    ExpireSolutionThreadSafe(true);
                }
            }

            Message = StringCache.getCache(queueName + "progress");

            // Handle Errors
            var errors = StringCache.getCache(InstanceGuid.ToString());

            if (!string.IsNullOrEmpty(errors))
            {
                throw new Exception(errors);
            }

            if (meshResult != null)
            {
                DA.SetDataTree(0, meshResult["analysisMesh"]);
                DA.SetDataTree(1, meshResult["faceCenters"]);
                DA.SetDataTree(2, meshResult["faceNormals"]);
            }
        }
        public static bool Download(
            string inputJson,
            string downloadPath,
            string localPath,
            string overrides
            )
        {
            var inputData    = new Inputs().FromJson(inputJson);
            var tokens       = inputData.Auth;
            var parentTask   = inputData.Task;
            var overrideDict = JsonConvert.DeserializeObject <Dictionary <string, List <string> > >(overrides);


            if (parentTask?.UID == null)
            {
                throw new Exception("Cannot download content without a parent task.");
            }

            if (!Directory.Exists(localPath))
            {
                Directory.CreateDirectory(localPath);
            }

            var localFiles = Directory.EnumerateFiles(localPath, "*", SearchOption.AllDirectories)
                             .Select(file => file.Remove(0, localPath.Length + 1)).ToList();

            foreach (var fileWin in localFiles)
            {
                var fileUnix = fileWin.Replace('\\', '/');
                if (StringCache.getCache(fileUnix) == null)
                {
                    StringCache.setCache(fileUnix, GetMD5(Path.Combine(localPath, fileWin)));
                }
            }

            var queryParams = new Dictionary <string, object> {
                { "filepath", downloadPath }, { "hash", true }
            };

            if (overrideDict != null && overrideDict.ContainsKey("exclude"))
            {
                queryParams.Add("exclude", string.Join(",", overrideDict["exclude"]));
            }
            if (overrideDict != null && overrideDict.ContainsKey("include"))
            {
                queryParams.Add("pattern", string.Join(",", overrideDict["include"]));
            }
            var serverFiles = new GenericViewSet <TaskFile>(
                tokens,
                inputData.Url,
                $"/api/task/{parentTask.UID}/file/"
                ).List(queryParams);

            if (serverFiles.Count == 0)
            {
                return(false);
            }

            foreach (var serverFile in serverFiles)
            {
                // fileName is Unix path
                var filePathUnix = serverFile.File;
                var fileHash     = serverFile.Hash;

                if (!filePathUnix.StartsWith(downloadPath))
                {
                    continue;
                }

                var filePathWin = filePathUnix == downloadPath?filePathUnix.Split('/').Last() : filePathUnix.Remove(0, downloadPath.Length + 1).Replace('/', '\\');

                var localFilePath      = Path.Combine(localPath, filePathWin);
                var localFileDirectory =
                    string.Join("\\", localFilePath.Split('\\').Take(localFilePath.Split('\\').Length - 1));
                if (!Directory.Exists(localFileDirectory))
                {
                    Directory.CreateDirectory(localFileDirectory);
                }
                if (!localFiles.Contains(filePathWin))
                {
                    var response = new GenericViewSet <string>(
                        tokens,
                        inputData.Url,
                        $"/api/task/{parentTask.UID}/file/"
                        ).Retrieve(filePathUnix, localFileDirectory, new Dictionary <string, object> {
                        { "download", true }
                    });
                    StringCache.setCache(filePathUnix, GetMD5(localFilePath));
                    Thread.Sleep(100);
                }
                else if (fileHash != StringCache.getCache(filePathUnix.Remove(0, downloadPath.Length + 1)))
                {
                    var response = new GenericViewSet <string>(
                        tokens,
                        inputData.Url,
                        $"/api/task/{parentTask.UID}/file/"
                        ).Retrieve(filePathUnix, localFileDirectory, new Dictionary <string, object> {
                        { "download", true }
                    });
                    StringCache.setCache(filePathUnix, GetMD5(localFilePath));
                    Thread.Sleep(100);
                }
            }
            return(true);
        }
Beispiel #24
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            string username = null;
            string password = null;
            var    url      = "https://compute.procedural.build";
            var    retry    = false;

            if (!DA.GetData(0, ref username))
            {
                return;
            }
            if (!DA.GetData(1, ref password))
            {
                return;
            }
            DA.GetData(2, ref url);
            DA.GetData(3, ref retry);

            var client = new ComputeClient(url);

            if (retry)
            {
                StringCache.ClearCache();
            }

            //Async Execution
            var cacheKey     = username + password + url;
            var cachedTokens = StringCache.getCache(cacheKey);

            DA.DisableGapLogic();
            if (cachedTokens == null)
            {
                var queueName = "login";
                // Get queue lock
                var queueLock = StringCache.getCache(queueName);
                if (queueLock != "true")
                {
                    StringCache.setCache(queueName, "true");
                    QueueManager.addToQueue(queueName, () =>
                    {
                        try
                        {
                            var results = client.Auth(username, password);

                            if (results.ErrorMessages != null)
                            {
                                StringCache.setCache(cacheKey, "error");
                                throw new Exception(results.ErrorMessages.First());
                            }
                            if (results.ErrorMessages == null)
                            {
                                StringCache.ClearCache();
                                cachedTokens = results.ToJson();
                                StringCache.setCache(cacheKey, cachedTokens);
                            }
                        }
                        catch (Exception e)
                        {
                            StringCache.setCache(InstanceGuid.ToString(), e.Message);
                        }

                        ExpireSolutionThreadSafe(true);
                        Thread.Sleep(2000);
                        StringCache.setCache(queueName, "");
                    });
                }
            }


            // Read from Cache
            var errors = StringCache.getCache(InstanceGuid.ToString());

            if (errors != null)
            {
                if (errors.Contains("(401) Unauthorized"))
                {
                    errors = "Could not login with the provided credentials. Try again.";
                }

                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, errors);
            }

            var tokens = new AuthTokens();

            if (cachedTokens != null)
            {
                tokens = tokens.FromJson(cachedTokens);
                var output = new Inputs
                {
                    Auth = tokens,
                    Url  = url
                };
                DA.SetData(0, output.ToJson());
            }
        }
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            string inputJson = null;
            var    mesh      = new GH_Structure <GH_Mesh>();
            var    points    = new GH_Structure <GH_Point>();
            var    normals   = new GH_Structure <GH_Vector>();
            var    names     = new List <string>();
            var    create    = false;

            if (!DA.GetData(0, ref inputJson))
            {
                return;
            }
            if (!DA.GetDataTree(1, out mesh))
            {
                return;
            }
            if (!DA.GetDataTree(2, out points))
            {
                return;
            }
            if (!DA.GetDataTree(3, out normals))
            {
                return;
            }
            if (!DA.GetDataList(4, names))
            {
                for (var i = 0; i < points.Branches.Count; i++)
                {
                    names.Add($"set{i.ToString()}");
                }
            }

            DA.GetData(5, ref create);



            // Get Cache to see if we already did this
            var cacheKey     = string.Join("", points) + string.Join("", names) + inputJson;
            var cachedValues = StringCache.getCache(cacheKey);

            DA.DisableGapLogic();

            if (cachedValues == null || create)
            {
                var queueName = "radiationProbe";

                // Get queue lock
                var queueLock = StringCache.getCache(queueName);
                if (queueLock != "true")
                {
                    StringCache.setCache(queueName, "true");
                    StringCache.setCache(cacheKey, null);
                    QueueManager.addToQueue(queueName, () =>
                    {
                        try
                        {
                            var meshFile = Export.MeshToObj(mesh, names);
                            var results  = Probe.RadiationProbes(
                                inputJson,
                                Geometry.ConvertPointsToList(points),
                                Geometry.ConvertPointsToList(normals),
                                names,
                                meshFile,
                                create
                                );
                            cachedValues = results;
                            StringCache.setCache(cacheKey, cachedValues);
                            if (create)
                            {
                                StringCache.setCache(cacheKey + "create", "true");
                            }
                        }
                        catch (NoObjectFoundException)
                        {
                            StringCache.setCache(cacheKey + "create", "");
                        }
                        catch (Exception e)
                        {
                            StringCache.setCache(InstanceGuid.ToString(), e.Message);
                            StringCache.setCache(cacheKey, "error");
                            StringCache.setCache(cacheKey + "create", "");
                        }


                        ExpireSolutionThreadSafe(true);
                        Thread.Sleep(2000);
                        StringCache.setCache(queueName, "");
                    });
                }
            }

            // Handle Errors
            var errors = StringCache.getCache(InstanceGuid.ToString());

            if (errors != null)
            {
                if (errors.Contains("No object found"))
                {
                    Message = "No Probe Task found.";
                }
                else
                {
                    throw new Exception(errors);
                }
            }

            // Read from Cache
            Message = "";
            if (cachedValues != null)
            {
                var outputs = cachedValues;
                DA.SetData(0, outputs);
                if (StringCache.getCache(cacheKey + "create") == "true")
                {
                    Message = "Task Created";
                }
            }
        }
Beispiel #26
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            string folder     = null;
            string meshPath   = null;
            var    refresh    = false;
            var    _overrides = "";

            DA.GetData(0, ref folder);
            DA.GetData(1, ref meshPath);
            DA.GetData(2, ref _overrides);
            DA.GetData(3, ref refresh);

            var overrides = new ProbeResultOverrides().FromJson(_overrides) ?? new ProbeResultOverrides {
                Exclude = null, Include = null, Distance = 0.1, Outputs = null
            };

            AddOverrideOutputs(overrides);

            if (string.IsNullOrEmpty(folder))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Please provide a valid string to the Folder input.");
            }

            // Get Cache to see if we already did this
            var cacheKey     = folder + meshPath + _overrides;
            var cachedValues = StringCache.getCache(cacheKey);

            DA.DisableGapLogic();

            if (!string.IsNullOrEmpty(folder) && (cachedValues == null || refresh))
            {
                const string queueName = "probeResults";
                StringCache.setCache(InstanceGuid.ToString(), "");

                // Get queue lock
                var queueLock = StringCache.getCache(queueName);
                if (queueLock != "true")
                {
                    StringCache.setCache(queueName, "true");
                    StringCache.setCache(cacheKey + "progress", "Loading...");

                    QueueManager.addToQueue(queueName, () =>
                    {
                        try
                        {
                            var results = ProbeResult.ReadProbeResults(
                                folder,
                                overrides.Exclude,
                                overrides.Include
                                );
                            cachedValues = JsonConvert.SerializeObject(results);
                            StringCache.setCache(cacheKey, cachedValues);

                            var points = ProbeResult.ReadPointsFromResults(
                                folder,
                                overrides.Exclude,
                                overrides.Include
                                );
                            probePoints = ConvertPointsToDataTree(points);

                            if (!string.IsNullOrEmpty(meshPath))
                            {
                                loadedMeshes = Import.LoadMeshFromPath(meshPath, overrides.Exclude, overrides.Include);
                            }


                            if (loadedMeshes != null && loadedMeshes.Any())
                            {
                                if (points != null && points.Any())
                                {
                                    try
                                    {
                                        correctedMesh = CorrectMesh(loadedMeshes, points, overrides.Distance ?? 0.1);
                                    }
                                    catch (InvalidOperationException error)
                                    {
                                        AddRuntimeMessage(GH_RuntimeMessageLevel.Warning,
                                                          $"Could not construct new mesh. Got error: {error.Message}");
                                    }
                                }
                                else
                                {
                                    correctedMesh = CorrectMesh(loadedMeshes);
                                }
                            }

                            probeResults = new Dictionary <string, DataTree <object> >();
                            foreach (var key in results.Keys)
                            {
                                probeResults.Add(key, ConvertToDataTree(results[key]));
                            }

                            info       = UpdateInfo(results);
                            resultKeys = results.Keys.ToList();
                            StringCache.setCache(cacheKey + "progress", "Done");
                        }
                        catch (Exception e)
                        {
                            StringCache.setCache(InstanceGuid.ToString(), e.Message);
                            StringCache.setCache(cacheKey, "error");
                            StringCache.setCache(cacheKey + "progress", "");
                        }

                        ExpireSolutionThreadSafe(true);
                        Thread.Sleep(2000);
                        StringCache.setCache(queueName, "");
                    });
                    ExpireSolutionThreadSafe(true);
                }
            }


            HandleErrors();

            if (probePoints != null)
            {
                DA.SetDataTree(1, probePoints);
            }

            if (correctedMesh != null)
            {
                DA.SetDataTree(2, correctedMesh);
            }

            if (info != null)
            {
                DA.SetDataTree(0, info);
            }

            if (probeResults != null)
            {
                foreach (var key in probeResults.Keys)
                {
                    AddToOutput(DA, key, probeResults[key], overrides.Outputs);
                }
            }

            if (resultKeys != null && overrides.Outputs == null)
            {
                resultKeys.Add("Info");
                resultKeys.Add("Points");
                resultKeys.Add("Mesh");
                RemoveUnusedOutputs(resultKeys);
            }

            Message = StringCache.getCache(cacheKey + "progress");
        }