private void LoadPVOutputSites()
        {
            _PvOutputSystemList = new ObservableCollection<PvOutputSiteSettings>();

            XmlElement sites = GetElement("pvoutputsitelist");
            if (sites == null)
                sites = AddElement(settings, "pvoutputsitelist");

            foreach (XmlNode e in sites.ChildNodes)
            {
                if (e.NodeType == XmlNodeType.Element && e.Name == "site")
                {
                    PvOutputSiteSettings site = new PvOutputSiteSettings(this, (XmlElement)e);
                    _PvOutputSystemList.Add(site);
                }
            }

            if (_PvOutputSystemList.Count == 0)
            {
                XmlElement e = AddElement(sites, "site");
                PvOutputSiteSettings site = new PvOutputSiteSettings(this, e);
                site.APIKey = "YourAPIKeyHere";
                site.APIVersion = "";
                site.SystemId = "YourSiteID";
                site.LiveDays = 2;
                site.AutoBackload = true;
                site.DataInterval = "10";
                site.Enable = EnablePVOutput;

                _PvOutputSystemList.Add(site);
            }
        }
        public void AddPvOutputSite()
        {
            XmlElement sites = GetElement("pvoutputsitelist");

            XmlElement e = AddElement(sites, "site");
            PvOutputSiteSettings site = new PvOutputSiteSettings(this, e);
            site.Name = "New System";
            site.SystemId = "0";

            _PvOutputSystemList.Add(site);
        }
        public void DeletePvOutputSite(PvOutputSiteSettings site)
        {
            XmlElement sites = GetElement("pvoutputsitelist");
            if (sites == null)
                return;

            int index = _PvOutputSystemList.IndexOf(site);
            _PvOutputSystemList.Remove(site);

            int pos = 0;
            foreach (XmlNode child in sites.ChildNodes)
            {
                if (child.NodeType == XmlNodeType.Element && child.Name == "site")
                {
                    if (ElementHasChild(child, "siteid", site.SystemId) && (pos == index))
                    {
                        sites.RemoveChild(child);
                        SettingChangedEventHandler("");
                        return;
                    }
                    pos++;
                }
            }
        }
        public PVOutputManager(GenThreadManager genThreadManager, IOutputManagerManager managerManager, PvOutputSiteSettings settings)
            : base(genThreadManager, GlobalSettings.SystemServices)
        {
            ManagerManager = managerManager;
            Settings = settings;
            SystemId = settings.SystemId;
            APIKey = settings.APIKey;
            if (settings.LiveDays == null)
                PVLiveDays = PVLiveDaysDefault;
            else
                PVLiveDays = settings.LiveDays.Value;

            if (Settings.HaveSubscription)
                PVOutputHourLimit = 100;
            else
                PVOutputHourLimit = 60;

            RequestCount = 0;
            RequestHour = (int)DateTime.Now.TimeOfDay.TotalHours;
            PVOutputLimitReported = false;
            PVOutputCurrentDayLimitReported = false;
            InitialOutputCycle = true;

            OutputReadyEvent = new ManualResetEvent(true);
            LastYieldReady = DateTime.MinValue;
            LastConsumeReady = DateTime.MinValue;
            PVInterval = settings.DataInterval == "" ? 10 : Convert.ToInt32(settings.DataInterval);
            // Common lock object for all OutputManagers
            if (OutputProcessLock == null)
                OutputProcessLock = new Object();
            ConsolidationDevice = ManagerManager.FindPVOutputConsolidationDevice(SystemId);
        }