Ejemplo n.º 1
0
        public static SolveResults ComputeSunVecs(PBSun sun)
        {
            SolveResults result = new SolveResults();

            sun.ComputeVectors();
            result.Value = sun;
            return(result);
        }
Ejemplo n.º 2
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)
        {
            double latitude   = double.NaN;
            double longitude  = double.NaN;
            int    monthStart = 0;
            int    monthEnd   = 0;
            int    timeStart  = 0;
            int    timeEnd    = 0;

            if (InPreSolve)
            {
                DA.GetData(IN_Latitude, ref latitude);
                DA.GetData(IN_Longitude, ref longitude);
                DA.GetData(IN_MonthStart, ref monthStart);
                DA.GetData(IN_MonthEnd, ref monthEnd);
                DA.GetData(IN_TimeStart, ref timeStart);
                DA.GetData(IN_TimeEnd, ref timeEnd);

                _sun = new PBSun(latitude, longitude, monthStart, monthEnd, timeStart, timeEnd);
                Task <SolveResults> task = Task.Run(() => ComputeSunVecs(_sun), CancelToken);
                TaskList.Add(task);
                return;
            }

            if (!GetSolveResults(DA, out SolveResults result))
            {
                DA.GetData(IN_Latitude, ref latitude);
                DA.GetData(IN_Longitude, ref longitude);
                DA.GetData(IN_MonthStart, ref monthStart);
                DA.GetData(IN_MonthEnd, ref monthEnd);
                DA.GetData(IN_TimeStart, ref timeStart);
                DA.GetData(IN_TimeEnd, ref timeEnd);
                _sun   = new PBSun(latitude, longitude, monthStart, monthEnd, timeStart, timeEnd);
                result = ComputeSunVecs(_sun);
                _sun   = result.Value;
            }

            if (result != null)
            {
                sunVecs = _sun.SunVectors;
                DA.SetDataList(OUT_Vectors, sunVecs);
            }
        }