Esempio n. 1
0
 public FloatStatTracker(float initValue, Recalculate update)
 {
     baseValue      = initValue;
     internalUpdate = recalculateCache + update;
     dirty          = false;
     _cachedValue   = initValue;
 }
 public FloatStatTracker(float initValue, Recalculate update)
 {
     baseValue = initValue;
     internalUpdate = recalculateCache + update;
     dirty = false;
     _cachedValue = initValue;
 }
Esempio n. 3
0
        public IActionResult Recalculate([FromBody] Recalculate obj)
        {
            // Get From DB
            if (obj == null)
            {
                return(BadRequest());
            }

            UtilitiesDAL utilDAL = new UtilitiesDAL(_db.ConnectionString);

            electrictyRate = utilDAL.GetElectricityRate(obj.Building);
            utilDAL        = new UtilitiesDAL(_db.ConnectionString);
            pvOutput       = utilDAL.GetPVOutput(obj.City);

            electrictyConsumptionPerMonth = Math.Round(obj.Bill / electrictyRate, 2);
            decimal electrictyConsumptionPerDay = Math.Round(electrictyConsumptionPerMonth / 30, 2);

            power = obj.Power;
            coveragePercentage = obj.Coverage / 100;

            decimal co2Reduction = 0.934M;

            averageCostperKWp = 15500000M;
            int yearInvestment = 25;

            CalculateSavings(yearInvestment);

            CalculationResult result = new CalculationResult();

            result.BuildingType           = obj.Building;
            result.MonthlyElectricityBill = obj.Bill;
            result.Power            = obj.Power;
            result.Coverage         = obj.Coverage;
            result.City             = obj.City;
            result.FirstYearSavings = savingList[0].SavingsValue;
            result.AnnualSavings    = averageSavings;
            if (savingList.Exists(x => x.AccumulatedSavings >= 0))
            {
                result.PaybackPeriod = savingList.FirstOrDefault(x => x.AccumulatedSavings >= 0).Year;
            }
            else
            {
                result.PaybackPeriod = 0;
            }
            result.SolarSystemCost           = costOfSystem;
            result.ReturnOnInvestment        = Math.Round((totalSavings - costOfSystem) / costOfSystem * 100, 2);
            result.SystemSize                = systemSize;
            result.MonthlyElectricityUse     = electrictyConsumptionPerMonth;
            result.MonthlySolarProduction    = Math.Round(powerList[0].EnergyOutput / 12, 0);
            result.LifetimeCO2Reduction      = Math.Round(totalEnergyOutput * co2Reduction, 2);
            result.NumberOfPanels            = Math.Round(systemSize / 0.3M, 0);
            result.AreaRequired              = Math.Round(result.NumberOfPanels * 1.5M, 0);
            result.CostOfSolarPerWatt        = Math.Round(costOfSystem / systemSize / 1000, 2);
            result.LifetimeCostOfElectricity = LCOE;
            result.LifetimeSavings           = totalSavings;
            result.ElectricityBillComparison = savingList;

            return(new ObjectResult(result));
        }
Esempio n. 4
0
 /// <summary>
 /// Returns a hash code for this instance.
 /// </summary>
 /// <returns>
 /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
 /// </returns>
 public override int GetHashCode()
 {
     unchecked {
         var result = Success.GetHashCode();
         result = (result * 397) ^ Error.GetHashCode();
         result = (result * 397) ^ NumPods;
         result = (result * 397) ^ (DataTypes != null ? DataTypes.GetHashCode() : 0);
         result = (result * 397) ^ (TimedOut != null ? TimedOut.GetHashCode() : 0);
         result = (result * 397) ^ Timing.GetHashCode();
         result = (result * 397) ^ ParseTiming.GetHashCode();
         result = (result * 397) ^ ParseTimedOut.GetHashCode();
         result = (result * 397) ^ (Recalculate != null ? Recalculate.GetHashCode() : 0);
         result = (result * 397) ^ (Version != null ? Version.GetHashCode() : 0);
         result = (result * 397) ^ (Pods != null ? Pods.GetHashCode() : 0);
         return(result);
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Returns a hash code for this instance.
 /// </summary>
 /// <returns>
 /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
 /// </returns>
 public override int GetHashCode()
 {
     unchecked
     {
         var result = Success.GetHashCode();
         result = (result * 397) ^ Error.GetHashCode();
         result = (result * 397) ^ NumPods;
         result = (result * 397) ^ (!DataTypes.IsNull() ? DataTypes.GetHashCode() : 0);
         result = (result * 397) ^ (!TimedOut.IsNull() ? TimedOut.GetHashCode() : 0);
         result = (result * 397) ^ Timing.GetHashCode();
         result = (result * 397) ^ ParseTiming.GetHashCode();
         result = (result * 397) ^ ParseTimedOut.GetHashCode();
         result = (result * 397) ^ (!Recalculate.IsNull() ? Recalculate.GetHashCode() : 0);
         result = (result * 397) ^ (!Version.IsNull() ? Version.GetHashCode() : 0);
         result = (result * 397) ^ (!Pods.IsNull() ? Pods.GetHashCode() : 0);
         return(result);
     }
 }
Esempio n. 6
0
 public FloatStatTracker(float initValue)
 {
     baseValue      = initValue;
     internalUpdate = setDirty;
     internalUpdate();
 }
 public FloatStatTracker(float initValue)
 {
     baseValue = initValue;
     internalUpdate = setDirty;
     internalUpdate();
 }