Ejemplo n.º 1
0
        public List <SolarPanelsDTO> GetSolarPanelProduction(DateTime date)
        {
            ISolarPanels solar        = new SolarPanels();
            DateTime     centuryBegin = new DateTime(2020, 1, 1);

            long ticks        = date.Ticks - centuryBegin.Ticks;
            long secondsStart = ticks / 10000000;
            long secondsEnd   = secondsStart + 86400;

            return((List <SolarPanelsDTO>)solar.FindAll((int)secondsStart, (int)secondsEnd));
        }
Ejemplo n.º 2
0
        public void DrawSolarPanels()
        {
            SolarPanels.Clear();
            var panelPlacingPoints = _panelCalculations.GetPlacingPoints(SolarPanelData, _siteZonePoints, _restrictionZonePoints, _zoneCalculations);

            foreach (var panel in panelPlacingPoints.Select(CreateNewSolarPanel))
            {
                SolarPanels.Add(panel);
            }

            SolarPanelData.ResetPanel();
        }
Ejemplo n.º 3
0
 public void InstantiateBlueprint(GameObject blueprint)
 {
     if (!BlueprintIsSelected)
     {
         if (blueprint == ballisticTurretPrefab)
         {
             BallisticTurret ballisticTurret = ObjectPooler.Instance.ballisticTurretPool.Retrieve();
             ballisticTurret.Relocate();
         }
         else if (blueprint == energyTurretPrefab)
         {
             EnergyTurret energyTurret = ObjectPooler.Instance.energyTurretPool.Retrieve();
             energyTurret.Relocate();
         }
         else if (blueprint == missileTurretPrefab)
         {
             MissileTurret missileTurret = ObjectPooler.Instance.missileTurretPool.Retrieve();
             missileTurret.Relocate();
         }
         else if (blueprint == solarPanelsPrefab)
         {
             SolarPanels solarPanels = ObjectPooler.Instance.solarPanelsPool.Retrieve();
             solarPanels.Relocate();
         }
         else if (blueprint == windTurbinePrefab)
         {
             WindTurbine windTurbine = ObjectPooler.Instance.windTurbinePool.Retrieve();
             windTurbine.Relocate();
         }
         else if (blueprint == minerPrefab)
         {
             Miner miner = ObjectPooler.Instance.minerPool.Retrieve();
             miner.Relocate();
         }
     }
 }
Ejemplo n.º 4
0
        public List <SolarPanel> GetSolarPanels()
        {
            ISolarPanels solar = new SolarPanels();

            return((List <SolarPanel>)solar.FindAll());
        }
Ejemplo n.º 5
0
        public void SaveSolarPanels(IEnumerable <SolarPanel> list)
        {
            ISolarPanels solar = new SolarPanels();

            solar.SaveAll(list);
        }
Ejemplo n.º 6
0
        public void SaveSolarPanelProduction(double power, int time)
        {
            ISolarPanels solar = new SolarPanels();

            solar.SaveProduction(power, time);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Main method
        /// </summary>
        /// <param name="argument">supplied by game</param>
        /// <param name="updateSource">supplied by game</param>
        public void Main(string argument, UpdateType updateSource)
        {
            StartTime           = DateTime.Now;
            CombinedSolarOutput = 0.0f;
            ExecutionCounter   += 1;

            if (ExecutionCounter == 100)
            {
                ExecutionCounter = 0;
            }

            if (Utilities == null)
            {
                Utilities = new Utils(GridTerminalSystem);
            }

            //Set up all the lcds in the list as panels and add to panel list
            if (Surface == null)
            {
                Surface = Utilities.SetupPanel(Lcd);
            }

            //Find the blocks
            if (HRotor == null)
            {
                HRotor = GridTerminalSystem.GetBlockWithName(SolarArrayNameBase + SolarArrayHorizontalRotorSuffix);
            }

            if (VRotor1 == null)
            {
                VRotor1 = GridTerminalSystem.GetBlockWithName(SolarArrayNameBase + SolarArrayVerticalRotorSuffix1);
            }

            if (VRotor2 == null)
            {
                VRotor2 = GridTerminalSystem.GetBlockWithName(SolarArrayNameBase + SolarArrayVerticalRotorSuffix2);
            }

            //handle error if rotor not found
            if (HRotor == null || VRotor1 == null || VRotor2 == null)
            {
                Echo("One or more rotors not found, exiting");
                return;
            }

            //Get rotor angles
            var horizontalRotorAngle = Utilities.OutputRotorAngle(HRotor);
            var verticalRotorAngle1  = Utilities.OutputRotorAngle(VRotor1);
            var verticalRotorAngle2  = Utilities.OutputRotorAngle(VRotor2);

            if (SolarPanels == null || SolarPanels.Count == 0)
            {
                foreach (var solarPanel in SolarArrayPanelSuffixList)
                {
                    string fullName = SolarArrayNameBase + solarPanel;
                    var    thePanel = GridTerminalSystem.GetBlockWithName(fullName);

                    if (thePanel == null)
                    {
                        Echo("Did not find " + SolarArrayNameBase + solarPanel);
                    }
                    else
                    {
                        float panelOutput = Utilities.GetSolarPanelOutput(thePanel);
                        CombinedSolarOutput += panelOutput;
                        SolarPanels.Add(thePanel);
                    }
                }
            }
            else
            {
                foreach (var thePanel in SolarPanels)
                {
                    float panelOutput = Utilities.GetSolarPanelOutput(thePanel);
                    CombinedSolarOutput += panelOutput;
                }
            }

            //Calculate average output
            AverageSolarOutput = CombinedSolarOutput / (float)SolarArrayPanelSuffixList.Count;

            //Calculate Solar Panel State
            float velocity = 0f;

            if (AverageSolarOutput <= NighttimeThreshold)
            {
                SolarPanelState = SolarPanelStates.NighttimeMode;
                velocity        = 0.0f;
            }
            else if (AverageSolarOutput > NighttimeThreshold && AverageSolarOutput < DesiredSolarYield - 30)
            {
                SolarPanelState = SolarPanelStates.SeekingSun;
                velocity        = 6.0f;
            }
            else
            {
                SolarPanelState        = SolarPanelStates.TrackingSun;
                SolarPanelTrackingCase = SolarPanelTrackingCases.None;

                //If the current reading is better and within 10 of desired
                if (AverageSolarOutput > LastReading && AverageSolarOutput > DesiredSolarYield - 10.0f)
                {
                    velocity = 0.1f;

                    SolarPanelTrackingCase = SolarPanelTrackingCases.ImprovedWithinTen;
                }
                //If the current reading is better and within 50 of desired
                else if (AverageSolarOutput > LastReading && AverageSolarOutput > DesiredSolarYield - 50.0f)
                {
                    velocity = 2.0f;

                    SolarPanelTrackingCase = SolarPanelTrackingCases.ImprovedWithinFifty;
                }
                //If current reading is better but not close to desired
                else if (AverageSolarOutput > LastReading)
                {
                    velocity = 4.0f;

                    SolarPanelTrackingCase = SolarPanelTrackingCases.ImprovedNotClose;
                }
                else if (AverageSolarOutput == LastReading)
                {
                    velocity = 0.0f;

                    SolarPanelTrackingCase = SolarPanelTrackingCases.Equal;
                }
                //If the current reading is less than last reading but still within 10f then reverse direction
                else if (AverageSolarOutput < LastReading && (AverageSolarOutput > LastReading - 10.0f))
                {
                    velocity = -0.5f;

                    SolarPanelTrackingCase = SolarPanelTrackingCases.WorsenedWithinTen;
                }
                else
                {
                    velocity = 6.0f;

                    SolarPanelTrackingCase = SolarPanelTrackingCases.LostSun;
                    SolarPanelState        = SolarPanelStates.SeekingSun;
                }
            }

            if (RotateAntiClockwise)
            {
                velocity = velocity * -1;
            }

            //Set the calculated velocity or horizontal rotor
            HRotor.SetValueFloat("Velocity", velocity);
            VRotor1.SetValueFloat("Velocity", velocity);
            VRotor2.SetValueFloat("Velocity", velocity * -1);

            //Set the last solar panel output reading
            LastReading = AverageSolarOutput;

            //Work out script execution time
            AverageExecution = Utilities.CalculateExecutionTime(ExecutionTimes, AverageExecution, StartTime, ExecutionCounter);

            //Output to LCD Panel
            Utilities.WriteToPanel($"Solar Array 1 Online " +
                                   $"\n{StartTime}" +
                                   $"\nRotor velocity: {velocity}" +
                                   $"\nPanel Output: {AverageSolarOutput}kw" +
                                   $"\nHRotor Angle: {horizontalRotorAngle}{(Char)176}" +
                                   $"\nVRotor Angles: {verticalRotorAngle1}{(Char)176}" +
                                   $"\nTracking mode: {SolarPanelState}" +
                                   $"\nTracking case: {SolarPanelTrackingCase}" +
                                   $"\nExecution time avg ({ExecutionCounter} runs):\n {AverageExecution}", Surface);
        }