//---------------------------------------------------------------------
 public static void Initialize(ICore modelCore)
 {
     landUse = modelCore.Landscape.NewSiteVar<LandUse>();
     allowHarvest = new AllowHarvestSiteVar();
     Model.Core.RegisterSiteVar(allowHarvest, "LandUse.AllowHarvest");
     Landis.Library.BiomassHarvest.SiteVars.CohortsPartiallyDamaged = modelCore.Landscape.NewSiteVar<int>();
 }
Ejemplo n.º 2
0
        //---------------------------------------------------------------------

        public override void LoadParameters(string dataFile,
                                            ICore mCore)
        {
            ExtensionMain baseHarvest = new BaseHarvest.PlugIn();
            try
            {
                baseHarvest.LoadParameters(null, mCore);
            }
            catch (System.ArgumentNullException)
            {
                // ignore
            }

            modelCore = mCore;

            // Add local event handler for cohorts death due to age-only
            // disturbances.
            Landis.Library.LeafBiomassCohorts.Cohort.AgeOnlyDeathEvent += CohortKilledByAgeOnlyDisturbance;

            InputParametersParser parser = new InputParametersParser(modelCore.Species);

            BaseHarvest.IInputParameters baseParameters = Landis.Data.Load<BaseHarvest.IInputParameters>(dataFile, parser);
            parameters = baseParameters as IInputParameters;
            if (parser.RoundedRepeatIntervals.Count > 0)
            {
                modelCore.UI.WriteLine("NOTE: The following repeat intervals were rounded up to");
                modelCore.UI.WriteLine("      ensure they were multiples of the harvest timestep:");
                modelCore.UI.WriteLine("      File: {0}", dataFile);
                foreach (RoundedInterval interval in parser.RoundedRepeatIntervals)
                    modelCore.UI.WriteLine("      At line {0}, the interval {1} rounded up to {2}",
                                 interval.LineNumber,
                                 interval.Original,
                                 interval.Adjusted);
            }
        }
 public override void Action(ICore core)
 {
     if (core.TottalDurability <= 0)
     {
         core.TottalDurability += this.PressureAffection;
     }
 }
Ejemplo n.º 4
0
        public UIView(ICore core, UIType menuType, int width, int height, UIFlags flags, bool transparent)
            : base(core)
        {
            webCore = core.GetService<IUIManagerService>().GetWebCore();
            this.menuType = menuType;
            this.width = width;
            this.height = height;
            this.flags = flags;
            this.isTransparent = transparent;
            isLoading = false;
            pageLoaded = false;
            webTextureID = TextureFactory.CreateTexture(width, height, isTransparent);
            hudPosX = 0;
            hudPosY = 0;
            hud = new TVScreen2DImmediate();
            Keyboard = core.GetService<IKeyboardService>();
            Mouse = core.GetService<IMouseService>();
            JoyStick = core.GetService<IJoyStickService>();
            Gamepad = core.GetService<IGamepadsService>();

            CanculateHudPosition(flags);

            View = webCore.CreateWebView(width, height, isTransparent, true);
            View.OnFinishLoading += OnFinishLoading;
            View.OnCallback += OnCallback;
            View.Focus();

            buttonClickSound = Core.GetService<ISoundManagerService>().Load2DSound(Path.Combine(Application.StartupPath, @"Data\Sounds\menu\button_click.mp3"));
            buttonFocusSound = Core.GetService<ISoundManagerService>().Load2DSound(Path.Combine(Application.StartupPath, @"Data\Sounds\menu\button_focus.mp3"));
            Core.GetService<ISoundManagerService>().SetVolume(buttonClickSound, 0.5f);
            Core.GetService<ISoundManagerService>().SetVolume(buttonFocusSound, 0.5f);
        }
        //---------------------------------------------------------------------


        /// <summary>
        /// Initializes the instance and its associated site variables.
        /// </summary>
        protected void Initialize(ICore modelCore,
                                  SeedingAlgorithms seedAlg)//,
                                  //Reproduction.Delegates.AddNewCohort addNewCohort)
        {
            Model.Core = modelCore;
            SiteVars.Initialize();
            Seeding.InitializeMaxSeedNeighborhood();

            disturbedSites = new DisturbedSiteEnumerator(Model.Core.Landscape,
                                                         SiteVars.Disturbed);

            SeedingAlgorithm algorithm;
            switch (seedAlg)
            {
                case SeedingAlgorithms.NoDispersal:
                    algorithm = NoDispersal.Algorithm;
                    break;

                case SeedingAlgorithms.UniversalDispersal:
                    algorithm = UniversalDispersal.Algorithm;
                    break;

                case SeedingAlgorithms.WardSeedDispersal:
                    algorithm = WardSeedDispersal.Algorithm;
                    break;

                default:
                    throw new ArgumentException(string.Format("Unknown seeding algorithm: {0}", seedAlg));
            }

            Reproduction.Initialize(algorithm);
        }
 //---------------------------------------------------------------------
 public override void LoadParameters(string dataFile, ICore mCore)
 {
     modelCore = mCore;
     InputParametersParser.SpeciesDataset = modelCore.Species;
     InputParametersParser parser = new InputParametersParser();
     parameters = Landis.Data.Load<IInputParameters>(dataFile, parser);
 }
Ejemplo n.º 7
0
 //---------------------------------------------------------------------
 public override void LoadParameters(string dataFile,
                                     ICore mCore)
 {
     modelCore = mCore;
     InputParametersParser parser = new InputParametersParser();
     parameters = modelCore.Load<IInputParameters>(dataFile, parser);
 }
Ejemplo n.º 8
0
        //---------------------------------------------------------------------

        public override void LoadParameters(string dataFile, ICore mCore)
        {
            modelCore = mCore;
            SiteVars.Initialize();
            InputParameterParser parser = new InputParameterParser();
            parameters = Landis.Data.Load<IInputParameters>(dataFile, parser);
        }
        //---------------------------------------------------------------------

        public static void Initialize(ICore modelCore)
        {
            timeOfLastBDA = modelCore.Landscape.NewSiteVar<int>();
            neighborResourceDom = modelCore.Landscape.NewSiteVar<double>();
            siteResourceDomMod = modelCore.Landscape.NewSiteVar<double>();
            siteResourceDom = modelCore.Landscape.NewSiteVar<double>();
            vulnerability = modelCore.Landscape.NewSiteVar<double>();
            disturbed = modelCore.Landscape.NewSiteVar<bool>();
            numberCFSconifersKilled = modelCore.Landscape.NewSiteVar<Dictionary<int, int>>();
            timeOfNext = modelCore.Landscape.NewSiteVar<int>();

            SiteVars.TimeOfLastEvent.ActiveSiteValues = -10000;
            SiteVars.NeighborResourceDom.ActiveSiteValues = 0.0;
            SiteVars.SiteResourceDomMod.ActiveSiteValues = 0.0;
            SiteVars.SiteResourceDom.ActiveSiteValues = 0.0;
            SiteVars.Vulnerability.ActiveSiteValues = 0.0;
            SiteVars.TimeOfNext.ActiveSiteValues = 9999;

            cohorts = PlugIn.ModelCore.GetSiteVar<ISiteCohorts>("Succession.AgeCohorts");
            

            foreach (ActiveSite site in modelCore.Landscape)
                SiteVars.NumberCFSconifersKilled[site] = new Dictionary<int, int>();

            // Added for v1.1 to enable interactions with CFS fuels extension.
            modelCore.RegisterSiteVar(SiteVars.NumberCFSconifersKilled, "BDA.NumCFSConifers");
            modelCore.RegisterSiteVar(SiteVars.TimeOfLastEvent, "BDA.TimeOfLastEvent");

            //foreach (IAgent activeAgent in manyAgentParameters)
            //{
            //    string varName = activeAgent.AgentName + ".TimeToNext";
            //    modelCore.RegisterSiteVar(SiteVars.TimeToNext, varName);
            //}
            modelCore.RegisterSiteVar(SiteVars.TimeOfNext, "BDA.TimeOfNext");
        }
Ejemplo n.º 10
0
        //---------------------------------------------------------------------

        public static void Initialize(ICore modelCore)
        {
            timeOfLastBDA  = modelCore.Landscape.NewSiteVar<int>();
            neighborResourceDom = modelCore.Landscape.NewSiteVar<double>();
            siteResourceDomMod = modelCore.Landscape.NewSiteVar<double>();
            siteResourceDom = modelCore.Landscape.NewSiteVar<double>();
            vulnerability = modelCore.Landscape.NewSiteVar<double>();
            disturbed = modelCore.Landscape.NewSiteVar<bool>();
            numberCFSconifersKilled = modelCore.Landscape.NewSiteVar<Dictionary<int, int>>();
            timeOfNext = modelCore.Landscape.NewSiteVar<int>();
            agentName = modelCore.Landscape.NewSiteVar<string>();
            biomassInsectsAgent = modelCore.Landscape.NewSiteVar<string>();


            SiteVars.TimeOfLastEvent.ActiveSiteValues = -10000;
            SiteVars.NeighborResourceDom.ActiveSiteValues = 0.0;
            SiteVars.SiteResourceDomMod.ActiveSiteValues = 0.0;
            SiteVars.SiteResourceDom.ActiveSiteValues = 0.0;
            SiteVars.Vulnerability.ActiveSiteValues = 0.0;
            SiteVars.TimeOfNext.ActiveSiteValues = 9999;
            SiteVars.AgentName.ActiveSiteValues = "";

            cohorts = PlugIn.ModelCore.GetSiteVar<ISiteCohorts>("Succession.AgeCohorts");

            foreach(ActiveSite site in modelCore.Landscape)
                SiteVars.NumberCFSconifersKilled[site] = new Dictionary<int, int>();

            // Added for v1.1 to enable interactions with CFS fuels extension.
            modelCore.RegisterSiteVar(SiteVars.NumberCFSconifersKilled, "BDA.NumCFSConifers");
            modelCore.RegisterSiteVar(SiteVars.TimeOfLastEvent, "BDA.TimeOfLastEvent");
            modelCore.RegisterSiteVar(SiteVars.AgentName, "BDA.AgentName");
            // Added to enable interactions with other extensions (Presalvage harvest)
            modelCore.RegisterSiteVar(SiteVars.TimeOfNext, "BDA.TimeOfNext");

        }
    public static bool Run(Plugin plugin, ICore core)
    {
        var gcList = from Geocache gc in core.Geocaches 
                     where gc.FoundDate!=null
                        && ((DateTime)gc.FoundDate).Month == gc.PublishedTime.Month 
                        && ((DateTime)gc.FoundDate).Day == gc.PublishedTime.Day
                     select gc;

        //mass update, so within begin and end
        core.Geocaches.BeginUpdate();

        //reset current selection
        foreach (Geocache gc in core.Geocaches)
        {
            gc.Selected = false;
        }
        //set the intended selection
        foreach (Geocache gc in gcList)
        {
            gc.Selected = true;
        }

        core.Geocaches.EndUpdate();
        return true;
    }
    public static bool Run(Plugin plugin, ICore core)
    {
        DateTime dt = DateTime.Now.AddDays(-7);
        var gcList = from Geocache gc in core.Geocaches 
                     where gc.DataFromDate < dt 
                     select gc;

        //mass update, so within begin and end
        core.Geocaches.BeginUpdate();

        //reset current selection
        foreach (Geocache gc in core.Geocaches)
        {
            gc.Selected = false;
        }
        //set the intended selection
        foreach (Geocache gc in gcList)
        {
            gc.Selected = true;
        }

        if (MessageBox.Show(LanguageSupport.Instance.GetTranslation("Automatically archive selected geocaches?"),LanguageSupport.Instance.GetTranslation("Archive"), MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)== DialogResult.Yes)
        {
            foreach (Geocache gc in gcList)
            {
                gc.Archived = true;
                gc.Available = false;
            }
        }

        core.Geocaches.EndUpdate();
        return true;
    }
Ejemplo n.º 13
0
		/// <summary>Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded.</summary>
		/// <param term='application'>Root object of the host application.</param>
		/// <param term='connectMode'>Describes how the Add-in is being loaded.</param>
		/// <param term='addInInst'>Object representing this Add-in.</param>
		/// <seealso class='IDTExtensibility2' />
		public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
		{
			_application = (DTE2)application;
			_addInInstance = (AddIn)addInInst;

			// Core
			var name = _addInInstance.Name;
			var outputPane = _application.ToolWindows.OutputWindow.OutputWindowPanes.GetPane(name);
			var feedback = new FeedbackManager(name, outputPane);
			_core = new Core(feedback);

			// Events
			_events = (Events2)_application.Events;
			_projectsEvents = _events.ProjectsEvents;
			_projectItemsEvents = _events.ProjectItemsEvents;
			_documentEvents = _events.DocumentEvents;
			_buildEvents = _events.BuildEvents;
			
			AttachEvents();

			// If being connected when Solution is already loaded - try to load all projects
			if (_application.Solution != null)
			{
				_core.Load(_application.Solution);
			}
		}
Ejemplo n.º 14
0
        //---------------------------------------------------------------------

        public override void LoadParameters(string dataFile, ICore mCore)
        {
            modelCore = mCore;
            Landis.Library.HarvestManagement.Main.InitializeLib(modelCore);
            InputParametersParser parser = new InputParametersParser(mCore.Species);
            parameters = Landis.Data.Load<IInputParameters>(dataFile, parser);
            if (parser.RoundedRepeatIntervals.Count > 0)
            {
                PlugIn.ModelCore.UI.WriteLine("NOTE: The following repeat intervals were rounded up to");
                PlugIn.ModelCore.UI.WriteLine("      ensure they were multiples of the harvest timestep:");
                PlugIn.ModelCore.UI.WriteLine("      File: {0}", dataFile);
                foreach (RoundedInterval interval in parser.RoundedRepeatIntervals)
                    PlugIn.ModelCore.UI.WriteLine("      At line {0}, the interval {1} rounded up to {2}",
                                 interval.LineNumber,
                                 interval.Original,
                                 interval.Adjusted);
            }
            if (parser.ParserNotes.Count > 0)
            {
                foreach (List<string> nList in parser.ParserNotes)
                {
                    foreach (string nLine in nList)
                    {
                        PlugIn.ModelCore.UI.WriteLine(nLine);
                    }
                }
            }
        }
Ejemplo n.º 15
0
        //---------------------------------------------------------------------
        
        public override void LoadParameters(string dataFile,
                                            ICore mCore)
        {
            modelCore = mCore;

            // Add local event handler for cohorts death due to age-only
            // disturbances.
            Cohort.AgeOnlyDeathEvent += CohortKilledByAgeOnlyDisturbance;

            HarvestMgmtLib.Main.InitializeLib(modelCore);
            HarvestExtensionMain.SiteHarvestedEvent += SiteHarvested;
            Landis.Library.BiomassHarvest.Main.InitializeLib(modelCore);

            ParametersParser parser = new ParametersParser(modelCore.Species);

            HarvestMgmtLib.IInputParameters baseParameters = Landis.Data.Load<IInputParameters>(dataFile, parser);
            parameters = baseParameters as IParameters;
            if (parser.RoundedRepeatIntervals.Count > 0)
            {
                ModelCore.UI.WriteLine("NOTE: The following repeat intervals were rounded up to");
                ModelCore.UI.WriteLine("      ensure they were multiples of the harvest timestep:");
                ModelCore.UI.WriteLine("      File: {0}", dataFile);
                foreach (RoundedInterval interval in parser.RoundedRepeatIntervals)
                    ModelCore.UI.WriteLine("      At line {0}, the interval {1} rounded up to {2}",
                                 interval.LineNumber,
                                 interval.Original,
                                 interval.Adjusted);
            }

        }
Ejemplo n.º 16
0
        //---------------------------------------------------------------------

        public static void Initialize(ICore modelCore)
        {
            core = modelCore;
            modelCore.Log.WriteLine("Inside Initialize method !!!");
            ecoregions     = modelCore.Landscape.NewSiteVar<IFireRegion>();
            eventVar       = modelCore.Landscape.NewSiteVar<Event>(InactiveSiteMode.DistinctValues);
            timeOfLastFire = modelCore.Landscape.NewSiteVar<int>();
            severity = modelCore.Landscape.NewSiteVar<byte>();
            disturbed = modelCore.Landscape.NewSiteVar<bool>();

            cohorts = modelCore.GetSiteVar<SiteCohorts>("Succession.Cohorts");
            
            // Enable interactions with (almost) any fire extension:
            modelCore.RegisterSiteVar(SiteVars.Severity, "Fire.Severity");
            

            //Initialize TimeSinceLastFire to the maximum cohort age:
            foreach (ActiveSite site in modelCore.Landscape) 
            {
                // Test to make sure the cohort type is correct for this extension
                if (site.Location.Row == 1 && site.Location.Column == 1 && !SiteVars.Cohorts[site].HasAge())
                {
                    throw new System.ApplicationException("Error in the Scenario file:  Incompatible extensions; Cohort age data required for this extension to operate.");
                }

                //UI.WriteLine("Inside foreach loop.  Site R/C = {0}/{1} !!!", site.Location.Row, site.Location.Column);
                ushort maxAge = Library.BaseCohorts.Util.GetMaxAge(cohorts[site]);
                //ushort maxAge = Library.Cohort.AgeOnly.Util.GetMaxAge(SiteVars.Cohorts[site]);
                //UI.WriteLine("Assigned maxAge");
                timeOfLastFire[site] = modelCore.StartTime - maxAge;
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="Server" /> class.
        /// </summary>
        /// <param name="core">
        ///     進入點物件
        /// </param>
        /// <param name="port">
        ///     監聽的埠
        /// </param>
        public Server(ICore core, int port)
        {
            _ThreadCoreHandler = new ThreadCoreHandler(core);
            _ThreadSocketHandler = new ThreadSocketHandler(port, _ThreadCoreHandler);

            _WaitSocket = new AutoResetEvent(false);
        }
        //---------------------------------------------------------------------

        public override void Initialize(string        dataFile,
                                        ICore mCore)
        {
            Timestep = parameters.Timestep;
            mapNameTemplate = parameters.MapNamesTemplate;
            dynamicEcos = parameters.DynamicFireRegions;

            summaryFireRegionEventCount = new int[FireRegions.Dataset.Count];

            Event.Initialize(parameters.FireDamages);

            modelCore.Log.WriteLine("Opening Fire log file \"{0}\" ...", parameters.LogFileName);
            log = modelCore.CreateTextFile(parameters.LogFileName);
            log.AutoFlush = true;
            log.Write("Time,InitialSiteRow,InitialSiteColumn,SitesChecked,CohortsKilled,MeanSeverity,");
            foreach (IFireRegion ecoregion in FireRegions.Dataset)
                log.Write("{0},", ecoregion.Name);
            log.Write("TotalBurnedSites");
            log.WriteLine("");

            summaryLog = modelCore.CreateTextFile(parameters.SummaryLogFileName);
            summaryLog.AutoFlush = true;
            summaryLog.Write("Time,TotalSitesBurned,TotalNumberEvents");
            foreach (IFireRegion ecoregion in FireRegions.Dataset)
                summaryLog.Write(",{0}", ecoregion.Name);
            summaryLog.WriteLine("");


        }
Ejemplo n.º 19
0
        public eMailSettingsForm(ICore pipeProxy, GeneralOptions go)
        {
            InitializeComponent();

            _pipeProxy = pipeProxy;
            _go = go;
        }
Ejemplo n.º 20
0
        public virtual void Configure(ICore core, ContainerManager containerManager, EventBroker broker/*, AaronConfig configuration*/)
        {
            //other dependencies
            //containerManager.AddComponentInstance<AaronConfig>(configuration, "aaron.configuration");
            containerManager.AddComponentInstance<ICore>(core, "aaron.core");
            containerManager.AddComponentInstance<ContainerConfigurer>(this, "aaron.containerConfigurer");

            //type finder
            containerManager.AddComponent<ITypeFinder, WebAppTypeFinder>("aaron.typeFinder");

            //register dependencies provided by other assemblies
            var typeFinder = containerManager.Resolve<ITypeFinder>();
            containerManager.UpdateContainer(x =>
            {
                var drTypes = typeFinder.FindClassesOfType<IDependencyRegistrar>();
                var drInstances = new List<IDependencyRegistrar>();
                foreach (var drType in drTypes)
                    drInstances.Add((IDependencyRegistrar)Activator.CreateInstance(drType));
                //sort
                drInstances = drInstances.AsQueryable().OrderBy(t => t.Order).ToList();
                foreach (var dependencyRegistrar in drInstances)
                    dependencyRegistrar.Register(x, typeFinder);
            });

            //event broker
            containerManager.AddComponentInstance(broker);

            //service registration
            containerManager.AddComponent<DependencyAttributeRegistrator>("aaron.serviceRegistrator");
            var registrator = containerManager.Resolve<DependencyAttributeRegistrator>();
            var services = registrator.FindServices();
            var configurations = GetComponentConfigurations(/*configuration*/);
            services = registrator.FilterServices(services, configurations);
            registrator.RegisterServices(services);
        }
        public ExtensionMetadata(ICore mCore)
        //public ExtensionMetadata()
        {
            modelCore = mCore;
            ScenarioReplicationMetadata = new ScenarioReplicationMetadata();
            OutputMetadatas = new List<OutputMetadata>();

        }
Ejemplo n.º 22
0
 public Gamepads(ICore core)
     : base(core)
 {
     gamepadStates.Add(UserIndex.One, new GamepadState(UserIndex.One));
     gamepadStates.Add(UserIndex.Two, new GamepadState(UserIndex.Two));
     gamepadStates.Add(UserIndex.Three, new GamepadState(UserIndex.Three));
     gamepadStates.Add(UserIndex.Four, new GamepadState(UserIndex.Four));
 }
Ejemplo n.º 23
0
 public WaypointSelectorForm(ICore core)
 {
     _theCore = core;
     InitializeComponent();
     SetLanguageSpecificControlText();
     UpdateView();
     lbWaypoints.SelectedIndex = (lbWaypoints.Items.Count > 0) ? 0 : -1;
 }
Ejemplo n.º 24
0
        /// <summary>
        /// Initialize the library for use by client code.
        /// </summary>
        public static void InitializeLib(ICore modelCore)
        {
            Landis.Library.SiteHarvest.Main.InitializeLib(modelCore);

            Model.Core = modelCore;
            SiteVars.Initialize();
            PartialThinning.InitializeClass();
        }
 //---------------------------------------------------------------------
 public override void LoadParameters(string dataFile,
     ICore modelCore)
 {
     Model.Core = modelCore;
     Landis.Library.BiomassHarvest.Main.InitializeLib(Model.Core);
     Model.Core.UI.WriteLine("  Loading parameters from {0}", dataFile);
     ParameterParser parser = new ParameterParser(Model.Core.Species);
     parameters = Landis.Data.Load<Parameters>(dataFile, parser);
 }
        //---------------------------------------------------------------------

        public override void LoadParameters(string dataFile,
                                            ICore mCore)
        {
            modelCore = mCore;
            SiteVars.Initialize(mCore);
            ParameterParser parser = new ParameterParser();
            parameters = mCore.Load<IInputParameters>(dataFile, parser);
            modelCore.Log.WriteLine("Exiting LoadParameters method !!!");
        }
Ejemplo n.º 27
0
 public static bool Run(Plugin plugin, ICore core)
 {
     IPluginUIChildWindow mapPlugin = (from IPluginUIChildWindow a in core.GetPlugin(PluginType.Map) where a.GetType().ToString() == "GlobalcachingApplication.Plugins.GMap.GMap" select a).FirstOrDefault();
     if (mapPlugin.ChildForm!=null)
     {
         mapPlugin.ChildForm.Enabled = true;
         mapPlugin.ChildForm.MdiParent = null;
     }
     return true;
 }
        public static void InitializeMetadata(int timestep, ICore mCore)
        {
            ScenarioReplicationMetadata scenRep = new ScenarioReplicationMetadata() {
                RasterOutCellArea = Climate.ModelCore.CellArea,
                TimeMin = Climate.ModelCore.StartTime,
                TimeMax = Climate.ModelCore.EndTime,
            };

            Extension = new ExtensionMetadata(mCore){
                Name = "Climate-Library",
                TimeInterval = timestep, 
                ScenarioReplicationMetadata = scenRep
            };

            //---------------------------------------
            //          table outputs:   
            //---------------------------------------

            Climate.PdsiLog = new MetadataTable<PDSI_Log>("Climate-PDSI-log.csv");
            Climate.MonthlyLog = new MetadataTable<MonthlyLog>("Climate-monthly-log.csv");

            OutputMetadata tblOut_monthly = new OutputMetadata()
            {
                Type = OutputType.Table,
                Name = "MonthlyLog",
                FilePath = Climate.MonthlyLog.FilePath,
                Visualize = true,
            };
            tblOut_monthly.RetriveFields(typeof(MonthlyLog));
            Extension.OutputMetadatas.Add(tblOut_monthly);

            OutputMetadata tblOut_pdsi = new OutputMetadata()
            {
                Type = OutputType.Table,
                Name = "PDSILog",
                FilePath = Climate.PdsiLog.FilePath,
                Visualize = false,
            };
            tblOut_pdsi.RetriveFields(typeof(PDSI_Log));
            Extension.OutputMetadatas.Add(tblOut_pdsi);

            //---------------------------------------            
            //          map outputs:         
            //---------------------------------------

            // NONE

            //---------------------------------------
            MetadataProvider mp = new MetadataProvider(Extension);
            mp.WriteMetadataToXMLFile("Metadata", Extension.Name, Extension.Name);




        }
        public static void InitializeMetadata(int Timestep, string MapFileName, ICore mCore)
        {
            ScenarioReplicationMetadata scenRep = new ScenarioReplicationMetadata() {
                RasterOutCellArea = PlugIn.ModelCore.CellArea,
                TimeMin = PlugIn.ModelCore.StartTime,
                TimeMax = PlugIn.ModelCore.EndTime//,
                //ProjectionFilePath = "Projection.?" 
            };

            Extension = new ExtensionMetadata(mCore){
                Name = PlugIn.ExtensionName,
                TimeInterval = Timestep, 
                ScenarioReplicationMetadata = scenRep
            };

            //---------------------------------------
            //          table outputs:   
            //---------------------------------------

             PlugIn.eventLog = new MetadataTable<EventsLog>("wind-events-log.csv");

            OutputMetadata tblOut_events = new OutputMetadata()
            {
                Type = OutputType.Table,
                Name = "WindLog",
                FilePath = PlugIn.eventLog.FilePath,
                Visualize = false,
            };
            tblOut_events.RetriveFields(typeof(EventsLog));
            Extension.OutputMetadatas.Add(tblOut_events);


            //---------------------------------------            
            //          map outputs:         
            //---------------------------------------

            OutputMetadata mapOut_Severity = new OutputMetadata()
            {
                Type = OutputType.Map,
                Name = "severity",
                FilePath = @MapFileName,
                Map_DataType = MapDataType.Ordinal,
                Map_Unit = FieldUnits.Severity_Rank,
                Visualize = true,
            };
            Extension.OutputMetadatas.Add(mapOut_Severity);

            //---------------------------------------
            MetadataProvider mp = new MetadataProvider(Extension);
            mp.WriteMetadataToXMLFile("Metadata", Extension.Name, Extension.Name);




        }
Ejemplo n.º 30
0
        public static void Initialize(ICore modelCore)
        {
            string path = "land-uses.txt";
            modelCore.UI.WriteLine("Reading land uses from \"{0}\"...", path);
            Parser parser = new Parser();
            landUses = Data.Load<IList<LandUse>>(path, parser);

            SiteVar = modelCore.Landscape.NewSiteVar<LandUse>();
            // Initialize all the actives to the first land-use in table.
            SiteVar.ActiveSiteValues = landUses[0];
        }
Ejemplo n.º 31
0
 public virtual void InitializeComponent(ICore core)
 {
     this.IsInitialized = true;
 }
Ejemplo n.º 32
0
        //   private Landis.Library.Biomass.Species.AuxParm<int> establishments;
        //---------------------------------------------------------------------


        public void Grow(ushort years, ActiveSite site, int?successionTimestep, ICore mCore)
        {
        }
Ejemplo n.º 33
0
 public override void InitializeComponent(ICore core)
 {
     this.MetaDataProviderManager = core.Managers.MetaDataProvider;
     base.InitializeComponent(core);
 }
Ejemplo n.º 34
0
 public UpdateUserInfoCommand(ICore core, IPusher pusher) : base(core, pusher)
 {
 }
Ejemplo n.º 35
0
 public PowerReviewGetFaceOff(ICore core, List<SiteError> errors)
 {
     _core = core;
     _errors = errors;
 }
Ejemplo n.º 36
0
        /// <summary>
        /// 获取Materials
        /// 已获取,保存数据即可
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GetMaterial()
        {
            //根据MRP_NAME 属性 去掉重复的 Material  FOIL CORE PREPREG
            Dictionary <string, string> dictFoilMrpName    = new Dictionary <string, string>();
            Dictionary <string, string> dictPrepregMrpName = new Dictionary <string, string>();
            Dictionary <string, string> dictCoreMrpName    = new Dictionary <string, string>();

            //根据MRP_NAME 属性 去掉重复的 Material  FOIL CORE PREPREG
            Dictionary <string, string> dictFoilMrpName_N    = new Dictionary <string, string>();
            Dictionary <string, string> dictPrepregMrpName_N = new Dictionary <string, string>();
            Dictionary <string, string> dictCoreMrpName_N    = new Dictionary <string, string>();

            int Total_Core    = 0;
            int Total_Foil    = 0;
            int Total_Prepreg = 0;

            stackup = theJob.Stackup();//job->stackup

            //1、获取数组的长度  {CORE}[X]  [FOIL][X] <PREPREG>[X]
            foreach (IStackupSegment seg in stackup.BuildUpSegments()) //stackup->stksegements->stksegement
            {
                //***************生成stakupsegment
                seg.SegmentIndex();
                seg.SegmentType();
                //seg.JobMaterials();    //stackupsegement
                foreach (IJobMaterial jobmat in seg.JobMaterials()) //stksegement->jobmaterials
                {
                    IMaterial mat = jobmat.Material();              //jobmaterials->jobmaterial

                    //***************生成stakupsegment
                    mat.MrpName();
                    if (mat.MtrType() == MtrType.CORE_MTR)//material->分类  material(CORE)
                    {
                        if (!dictCoreMrpName.Keys.Contains(mat.MrpName()))
                        {
                            dictCoreMrpName.Add(mat.MrpName(), "第" + (Total_Core + 1).ToString() + "种类别的" + mat.MtrType() + ":  " + mat.MrpName());
                            Total_Core++;
                        }
                    }
                    if (mat.MtrType() == MtrType.FOIL_MTR)//material->分类  material(CORE)
                    {
                        if (!dictFoilMrpName.Keys.Contains(mat.MrpName()))
                        {
                            dictFoilMrpName.Add(mat.MrpName(), "第" + (Total_Foil + 1).ToString() + "种类别的" + mat.MtrType() + ":  " + mat.MrpName());
                            Total_Foil++;
                        }
                    }
                    if (mat.MtrType() == MtrType.PREPREG_MTR)//material->分类  material(CORE)
                    {
                        if (!dictPrepregMrpName.Keys.Contains(mat.MrpName()))
                        {
                            dictPrepregMrpName.Add(mat.MrpName(), "第" + (Total_Prepreg + 1).ToString() + "种类别的" + mat.MtrType() + ":  " + mat.MrpName());
                            Total_Prepreg++;
                        }
                    }
                }
            }

            //2 给键值对数组建立固定数组赋初值
            Dictionary <string, dynamic> udaObj = new Dictionary <string, dynamic>();

            Dictionary <string, string>[] dictFoil    = new Dictionary <string, string> [Total_Foil];
            Dictionary <string, string>[] dictCore    = new Dictionary <string, string> [Total_Core];
            Dictionary <string, string>[] dictPrepreg = new Dictionary <string, string> [Total_Prepreg];

            for (int arrayLenth = 0; arrayLenth < dictFoil.Length; arrayLenth++)
            {
                dictFoil[arrayLenth] = new Dictionary <string, string>();
            }
            for (int arrayLenth = 0; arrayLenth < dictCore.Length; arrayLenth++)
            {
                dictCore[arrayLenth] = new Dictionary <string, string>();
            }
            for (int arrayLenth = 0; arrayLenth < dictPrepreg.Length; arrayLenth++)
            {
                dictPrepreg[arrayLenth] = new Dictionary <string, string>();
            }

            //给键值对数组  添加指定属性的元素
            //数组下标

            int i, j, k;

            i = 0;
            j = 0;
            k = 0;



            try
            {
                foreach (IStackupSegment seg in stackup.BuildUpSegments()) //stackup->stksegements->stksegement
                {
                    foreach (IJobMaterial jobmat in seg.JobMaterials())    //stksegement->jobmaterials
                    {
                        IMaterial mat = jobmat.Material();                 //jobmaterials->jobmaterial
                        //base_Material = mat.Family();
                        if (mat.MtrType() == MtrType.FOIL_MTR)             //material->分类  material(CORE)
                        {
                            //针对CORE属性  1、CORE所有属性  2、属性筛选 3、添加键值对
                            IFoil foil = mat.Foil();
                            Dictionary <string, string> dictAllFoil = new Dictionary <string, string>();
                            XmlGenerate.AllAttrGetKeyValues(foil, dictAllFoil);
                            XmlGenerate.AllAttrGetKeyValues(mat, dictAllFoil);
                            //Base_Material = dictAllFoil["FAMILY"];
                            string[] a      = attrsMaterialsFoil;
                            string[] b      = attrsMaterialsFoil_Inplan;
                            int      length = 0;
                            if (a.Length == b.Length)
                            {
                                length = a.Length;
                            }
                            else
                            {
                                string str = "请检查是否数组长度定义一一对应";
                            }

                            if (!dictFoilMrpName_N.Keys.Contains(dictAllFoil["MRP_NAME"]))
                            {
                                dictFoilMrpName_N.Add(dictAllFoil["MRP_NAME"], "第" + (i + 1).ToString() + "种类别的" + mat.MtrType() + ":  " + dictAllFoil["MRP_NAME"]);
                                for (int l = 0; l < length; l++)
                                {
                                    dictFoil[i].Add(a[l], dictAllFoil[b[l]]);
                                }
                                i++;
                            }
                            string debug = "";
                        }
                        if (mat.MtrType() == MtrType.PREPREG_MTR)//material->分类  material(CORE)
                        {
                            IPrepreg prepreg = mat.Prepreg();
                            Dictionary <string, string> dictAllPrepreg = new Dictionary <string, string>();
                            XmlGenerate.AllAttrGetKeyValues(prepreg, dictAllPrepreg);
                            XmlGenerate.AllAttrGetKeyValues(mat, dictAllPrepreg);
                            base_Material = dictAllPrepreg["FAMILY"];
                            string[] a      = attrsMaterialsPrepreg;
                            string[] b      = attrsMaterialsPrepreg_Inplan;
                            int      length = 0;
                            if (a.Length == b.Length)
                            {
                                length = a.Length;
                            }
                            else
                            {
                                string str = "请检查是否数组长度定义一一对应";
                            }
                            if (!dictPrepregMrpName_N.Keys.Contains(dictAllPrepreg["MRP_NAME"]))
                            {
                                dictPrepregMrpName_N.Add(dictAllPrepreg["MRP_NAME"], "第" + (j + 1).ToString() + "种类别的" + mat.MtrType() + ":  " + dictAllPrepreg["MRP_NAME"]);
                                for (int l = 0; l < length; l++)
                                {
                                    dictPrepreg[j].Add(a[l], dictAllPrepreg[b[l]]);
                                }
                                j++;
                            }
                            string debug = "";
                        }
                        if (mat.MtrType() == MtrType.CORE_MTR)//material->分类  material(CORE)
                        {
                            ICore core = mat.Core();
                            Dictionary <string, string> dictAllCore = new Dictionary <string, string>();
                            XmlGenerate.AllAttrGetKeyValues(core, dictAllCore);
                            XmlGenerate.AllAttrGetKeyValues(mat, dictAllCore);
                            base_Material = dictAllCore["FAMILY"];
                            string[] a      = attrsMaterialsCore;
                            string[] b      = attrsMaterialsCore_Inplan;
                            int      length = 0;
                            if (a.Length == b.Length)
                            {
                                length = a.Length;
                            }
                            else
                            {
                                string str = "请检查是否数组长度定义一一对应";
                            }
                            if (!dictCoreMrpName_N.Keys.Contains(dictAllCore["MRP_NAME"]))
                            {
                                dictCoreMrpName_N.Add(dictAllCore["MRP_NAME"], "第" + (k + 1).ToString() + "种类别的" + mat.MtrType() + ":  " + dictAllCore["MRP_NAME"]);
                                for (int l = 0; l < length; l++)
                                {
                                    dictCore[k].Add(a[l], dictAllCore[b[l]]);
                                }
                                k++;
                            }
                            string debug = "";
                        }
                    }
                }

                //对应XML子节点个数
                jobNum_FOIL        = Total_Foil;
                jobNum_PREPREG     = Total_Prepreg;
                jobNum_CORE        = Total_Core;
                jobNum_STACKUP_SEG = Total_Foil + Total_Prepreg + Total_Core;

                listFoilT    = new List <Dictionary <string, string> >();
                listPrepregT = new List <Dictionary <string, string> >();
                listCoreT    = new List <Dictionary <string, string> >();
                foreach (var item in dictFoil)
                {
                    listFoilT.Add(item);
                }
                foreach (var item in dictPrepreg)
                {
                    listPrepregT.Add(item);
                }
                foreach (var item in dictCore)
                {
                    listCoreT.Add(item);
                }
                dictFoilT    = dictFoil;
                dictPrepregT = dictPrepreg;
                dictCoreT    = dictCore;
            }
            catch (Exception ex)
            {
                string exmess = ex.ToString();
                //throw;
            }
        }
Ejemplo n.º 37
0
 public override void InitializeComponent(ICore core)
 {
     this.Core = core;
     base.InitializeComponent(core);
 }
Ejemplo n.º 38
0
        public static void InitializeMetadata(int timestep, ICore mCore,
                                              string SoilCarbonMapNames,
                                              string SoilNitrogenMapNames,
                                              string ANPPMapNames,
                                              string ANEEMapNames,
                                              string TotalCMapNames)
        //string LAIMapNames,
        //string ShadeClassMapNames)
        {
            ScenarioReplicationMetadata scenRep = new ScenarioReplicationMetadata()
            {
                RasterOutCellArea = PlugIn.ModelCore.CellArea,
                TimeMin           = PlugIn.ModelCore.StartTime,
                TimeMax           = PlugIn.ModelCore.EndTime,
            };

            Extension = new ExtensionMetadata(mCore)
            {
                Name         = "NECN-Succession",
                TimeInterval = timestep,
                ScenarioReplicationMetadata = scenRep
            };

            //---------------------------------------
            //          table outputs:
            //---------------------------------------

            Outputs.primaryLog      = new MetadataTable <PrimaryLog>("NECN-succession-log.csv");
            Outputs.primaryLogShort = new MetadataTable <PrimaryLogShort>("NECN-succession-log-short.csv");
            Outputs.monthlyLog      = new MetadataTable <MonthlyLog>("NECN-succession-monthly-log.csv");

            OutputMetadata tblOut_monthly = new OutputMetadata()
            {
                Type      = OutputType.Table,
                Name      = "MonthlyLog",
                FilePath  = Outputs.monthlyLog.FilePath,
                Visualize = true,
            };

            tblOut_monthly.RetriveFields(typeof(MonthlyLog));
            Extension.OutputMetadatas.Add(tblOut_monthly);

            OutputMetadata tblOut_primary = new OutputMetadata()
            {
                Type      = OutputType.Table,
                Name      = "PrimaryLog",
                FilePath  = Outputs.primaryLog.FilePath,
                Visualize = false,
            };

            tblOut_primary.RetriveFields(typeof(PrimaryLog));
            Extension.OutputMetadatas.Add(tblOut_primary);

            OutputMetadata tblOut_primaryShort = new OutputMetadata()
            {
                Type      = OutputType.Table,
                Name      = "PrimaryLogShort",
                FilePath  = Outputs.primaryLogShort.FilePath,
                Visualize = true,
            };

            tblOut_primaryShort.RetriveFields(typeof(PrimaryLogShort));
            Extension.OutputMetadatas.Add(tblOut_primaryShort);

            //---------------------------------------
            //          map outputs:
            //---------------------------------------
            if (ANPPMapNames != null)
            {
                PlugIn.ModelCore.UI.WriteLine("  ANPP Map Names = \"{0}\" ...", ANPPMapNames);
                string[]       paths       = { @"NECN", "AG_NPP-{timestep}.img" };
                OutputMetadata mapOut_ANPP = new OutputMetadata()
                {
                    Type = OutputType.Map,
                    Name = "Aboveground Net Primary Production",
                    //FilePath = @"NECN\AG_NPP-{timestep}.img",
                    FilePath     = Path.Combine(paths),
                    Map_DataType = MapDataType.Continuous,
                    Map_Unit     = FieldUnits.g_C_m2,
                    Visualize    = true,
                };
                Extension.OutputMetadatas.Add(mapOut_ANPP);
            }

            if (ANEEMapNames != null)
            {
                string[]       paths      = { @"NECN", "NEE-{timestep}.img" };
                OutputMetadata mapOut_Nee = new OutputMetadata()
                {
                    Type = OutputType.Map,
                    Name = "Net Ecosystem Exchange",
                    //FilePath = @"NECN\NEE-{timestep}.img",
                    FilePath     = Path.Combine(paths),
                    Map_DataType = MapDataType.Continuous,
                    Map_Unit     = FieldUnits.g_C_m2,
                    Visualize    = true,
                };
                Extension.OutputMetadatas.Add(mapOut_Nee);
            }
            if (SoilCarbonMapNames != null)
            {
                string[]       paths      = { @"NECN", "SOC-{timestep}.img" };
                OutputMetadata mapOut_SOC = new OutputMetadata()
                {
                    Type = OutputType.Map,
                    Name = "Soil Organic Carbon",
                    //FilePath = @"NECN\SOC-{timestep}.img",
                    FilePath     = Path.Combine(paths),
                    Map_DataType = MapDataType.Continuous,
                    Map_Unit     = FieldUnits.g_C_m2,
                    Visualize    = true,
                };
                Extension.OutputMetadatas.Add(mapOut_SOC);
            }
            if (SoilNitrogenMapNames != null)
            {
                string[]       paths      = { @"NECN", "SON-{timestep}.img" };
                OutputMetadata mapOut_SON = new OutputMetadata()
                {
                    Type = OutputType.Map,
                    Name = "Soil Organic Nitrogen",
                    //FilePath = @"NECN\SON-{timestep}.img",
                    FilePath     = Path.Combine(paths),
                    Map_DataType = MapDataType.Continuous,
                    Map_Unit     = FieldUnits.g_N_m2,
                    Visualize    = true,
                };
                Extension.OutputMetadatas.Add(mapOut_SON);
            }
            if (TotalCMapNames != null)
            {
                string[]       paths         = { @"NECN", "TotalC-{timestep}.img" };
                OutputMetadata mapOut_TotalC = new OutputMetadata()
                {
                    Type = OutputType.Map,
                    Name = "Total Carbon",
                    //FilePath = @"NECN\TotalC-{timestep}.img",
                    FilePath     = Path.Combine(paths),
                    Map_DataType = MapDataType.Continuous,
                    Map_Unit     = FieldUnits.g_C_m2,
                    Visualize    = true,
                };
                Extension.OutputMetadatas.Add(mapOut_TotalC);
            }
//            if (LAImapnames != null) //These are new maps for testing and analysis purposes
//            {
//                OutputMetadata mapOut_LAI = new OutputMetadata()
//                {
//                    Type = OutputType.Map,
//                    Name = "LAI",
//                    FilePath = @"century\LAI-{timestep}.gis",  //century
//                    Map_DataType = MapDataType.Continuous,
//                   Map_Unit = FieldUnits.g_C_m2, //Not sure
//                    Visualize = true,
//                };
//                Extension.OutputMetadatas.Add(mapOut_LAI);
//            }
//            if (ShadeClassmapnames != null)
//            {
//                OutputMetadata mapOut_ShadeClass = new OutputMetadata()
//                {
//                    Type = OutputType.Map,
//                    Name = "ShadeClass",
//                    FilePath = @"century\ShadeClass-{timestep}.gis",  //century
//                    Map_DataType = MapDataType.Continuous,
//                   Map_Unit = FieldUnits.g_C_m2, //NOt sure
//                    Visualize = true,
//                };
//                Extension.OutputMetadatas.Add(mapOut_LAI);
//            }


            //---------------------------------------
            MetadataProvider mp = new MetadataProvider(Extension);

            mp.WriteMetadataToXMLFile("Metadata", Extension.Name, Extension.Name);
        }
 public override void InitializeComponent(ICore core)
 {
     this.Factory = new ArchiveLibraryItemFactory();
     this.Factory.InitializeComponent(core);
     base.InitializeComponent(core);
 }
Ejemplo n.º 40
0
 public PowerReviewGetFaceOff(ICore core)
 {
     _core = core;
     _errors = new List<SiteError>();
 }
Ejemplo n.º 41
0
 protected override void InitializeComponent(ICore core)
 {
     this.ArtworkBrushFactory = new ArtworkBrushFactory();
     this.ArtworkBrushFactory.InitializeComponent(core);
     base.InitializeComponent(core);
 }
Ejemplo n.º 42
0
 public bool Init(ref ICore odbms)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 43
0
 protected override void InitializeComponent(ICore core)
 {
     this.Dispatch(this.Refresh);
     base.InitializeComponent(core);
 }
 public override void InitializeComponent(ICore core)
 {
     BassUtils.BUILT_IN_FORMATS.Add("dts");
 }
Ejemplo n.º 45
0
 public static void SetCore(ViewModelBase source, ICore value)
 {
     source.SetValue(CoreProperty, value);
 }
Ejemplo n.º 46
0
 public override void InitializeComponent(ICore core)
 {
     this.Output          = core.Components.Output;
     this.PlaybackManager = core.Managers.Playback;
     base.InitializeComponent(core);
 }
Ejemplo n.º 47
0
 public IBlip Create(ICore core, IntPtr blipPointer)
 {
     return(new Blip(core, blipPointer));
 }
Ejemplo n.º 48
0
 public WorldObject(ICore core, IntPtr worldObjectPointer, BaseObjectType type) : base(core, GetBaseObjectPointer(core, worldObjectPointer), type)
 {
     WorldObjectNativePointer = worldObjectPointer;
 }
Ejemplo n.º 49
0
        public ContactsManager(ICore core, ISynchronizeInvoke syncInvoke)
        {
            Core = core;

            _contactsWrapper = new ObservableDictionaryValuesMapperConverter <Contact, IContact>(_contacts);
            _tagsWrapper     = new ObservableDictionaryValuesMapperConverter <TagLocal, IContactTagLocal>(_tags);

            var dbPath = string.Format("{0}{1}contactpoint{1}{2}", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Path.DirectorySeparatorChar, "address_book.s3db");

#if CONTACTS_DEBUG
            if (File.Exists(dbPath))
            {
                File.Delete(dbPath);
            }
#endif

            if (!File.Exists(dbPath))
            {
                CreateDatabase(dbPath);
            }
            else
            {
                if (!InitializeConnection(dbPath))
                {
                    Logger.LogWarn("Error loading ContactsManager - continue without Contacts API");
                    return;
                }
            }

            var contacts = new Dictionary <long, Contact>();
            using (new EnsuredResourceCriticalOperation(_sqlConnection))
            {
                DatabaseSchema.Upgrade(_sqlConnection);

                #region Load address books

                Logger.LogNotice("Loading Address Books");
                using (var command = _sqlConnection.CreateCommand())
                {
                    command.CommandText = @"select id, name, lastupdate, key from addressbooks";

                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            _addressBooks.Add(
                                new AddressBookLocal(
                                    this,
                                    reader.GetInt32(0),
                                    Guid.Parse(reader.GetString(3)),
                                    reader.GetString(1)
                                    )
                            {
                                LastUpdate =
                                    reader.IsDBNull(2)
                                                ? DateTime.Now - TimeSpan.FromDays(365)
                                                : reader.GetDateTime(2)
                            });
                        }
                    }
                }

                #endregion

                #region Load tags

                Logger.LogNotice("Loading Tags");
                using (var command = _sqlConnection.CreateCommand())
                {
                    command.CommandText =
                        @"select id, name, key, color, version_tag, addressbook_id from tags where is_deleted = 0";

                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var addressBookId = reader.GetInt64(5);
                            var addressBook   = AddressBooks.FirstOrDefault(x => x.Id == addressBookId);
                            if (addressBook == null)
                            {
                                continue;
                            }

                            var tag = new TagLocal(reader.GetInt64(0), addressBook, this)
                            {
                                Name       = reader.GetString(1),
                                Key        = reader.GetStringSafe(2),
                                Color      = reader.GetStringSafe(3),
                                VersionKey = reader.GetStringSafe(4),
                                IsDeleted  = false
                            };

                            tag.ResetIsChanged();

                            _tags.Add(tag.Id, tag);
                        }
                    }
                }

                #endregion

                #region Load contacts

                Logger.LogNotice("Loading Contacts");
                using (var command = _sqlConnection.CreateCommand())
                {
                    command.CommandText = @"select id, first_name, last_name, middle_name, company from contacts";

                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var id      = reader.GetInt32(0);
                            var contact = new Contact(this, id)
                            {
                                FirstName  = reader.GetStringSafe(1),
                                LastName   = reader.GetStringSafe(2),
                                MiddleName = reader.GetStringSafe(3),
                                Company    = reader.GetStringSafe(4)
                            };

                            contacts.Add(id, contact);
                        }
                    }
                }

                #endregion

                #region Load contact infos links for contacts

                Logger.LogNotice("Loading Contact Links");
                var contactInfoIdsContacts = new Dictionary <long, Contact>();
                using (var command = _sqlConnection.CreateCommand())
                {
                    command.CommandText = @"select contact_info_id, contact_id from contacts_links";

                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var contactInfoId = reader.GetInt64(0);
                            if (contactInfoIdsContacts.ContainsKey(contactInfoId))
                            {
                                continue;
                            }

                            var contactId = reader.GetInt64(1);

                            if (!contacts.ContainsKey(contactId))
                            {
                                continue;
                            }

                            contactInfoIdsContacts.Add(contactInfoId, contacts[contactId]);
                        }
                    }
                }

                #endregion

                #region Load contact infos

                Logger.LogNotice("Loading Contact details");
                var contactInfos = new Dictionary <long, ContactInfoLocal>();
                using (var command = _sqlConnection.CreateCommand())
                {
                    command.CommandText =
                        @"select id, first_name, last_name, middle_name, company, job_title, addressbook_id, key, note, version_tag from contact_infos where is_deleted = 0";

                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var id            = reader.GetInt64(0);
                            var addressBookId = reader.GetInt64(6);
                            var addressBook   = _addressBooks.FirstOrDefault(x => x.Id == addressBookId);

                            if (addressBook == null)
                            {
                                continue;
                            }
                            if (!contactInfoIdsContacts.ContainsKey(id))
                            {
                                continue;
                            }

                            var contactInfo = new ContactInfoLocal(id, addressBook, this)
                            {
                                FirstName  = reader.GetStringSafe(1),
                                LastName   = reader.GetStringSafe(2),
                                MiddleName = reader.GetStringSafe(3),
                                Company    = reader.GetStringSafe(4),
                                JobTitle   = reader.GetStringSafe(5),
                                Key        = reader.GetString(7),
                                Note       = reader.GetStringSafe(8),
                                VersionKey = reader.GetStringSafe(9),
                                Contact    = contactInfoIdsContacts[id],
                                IsDeleted  = false
                            };

                            contactInfos.Add(id, contactInfo);
                            contactInfo.ResetIsChanged();

                            contactInfoIdsContacts[id].ContactInfos.Add(contactInfo);
                        }
                    }
                }

                #endregion

                #region Load phone numbers

                Logger.LogNotice("Loading Phone Numbers");
                using (var command = _sqlConnection.CreateCommand())
                {
                    command.CommandText =
                        @"select id, number, comment, key, version_tag, contact_info_id from contact_info_phones";

                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var contactInfoId = reader.GetInt64(5);
                            if (!contactInfos.ContainsKey(contactInfoId))
                            {
                                continue;
                            }

                            var number = new ContactPhoneLocal(reader.GetInt64(0),
                                                               contactInfos[contactInfoId].AddressBook)
                            {
                                Number     = reader.GetString(1),
                                Comment    = reader.GetStringSafe(2),
                                Key        = reader.GetStringSafe(3),
                                VersionKey = reader.GetStringSafe(4)
                            };

                            number.ResetIsChanged();

                            contactInfos[contactInfoId].PhoneNumbers.Add(number);
                            contactInfos[contactInfoId].ResetIsChanged();
                        }
                    }
                }

                #endregion

                #region Load emails

                Logger.LogNotice("Loading Emails");
                using (var command = _sqlConnection.CreateCommand())
                {
                    command.CommandText =
                        @"select id, email, comment, key, version_tag, contact_info_id from contact_info_emails";

                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var contactInfoId = reader.GetInt64(5);
                            if (!contactInfos.ContainsKey(contactInfoId))
                            {
                                continue;
                            }

                            var email = new ContactEmailLocal(reader.GetInt64(0),
                                                              contactInfos[contactInfoId].AddressBook)
                            {
                                Email      = reader.GetString(1),
                                Comment    = reader.GetStringSafe(2),
                                Key        = reader.GetStringSafe(3),
                                VersionKey = reader.GetStringSafe(4)
                            };

                            email.ResetIsChanged();

                            contactInfos[contactInfoId].Emails.Add(email);
                            contactInfos[contactInfoId].ResetIsChanged();
                        }
                    }
                }

                #endregion

                #region Fill tags links on contacts infos

                Logger.LogNotice("Loading Tag links");
                using (var command = _sqlConnection.CreateCommand())
                {
                    command.CommandText = @"select tag_id, contact_info_id from tags_links";

                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var tagId         = reader.GetInt32(0);
                            var contactInfoId = reader.GetInt32(1);

                            if (!_tags.ContainsKey(tagId))
                            {
                                continue;
                            }
                            if (!contactInfos.ContainsKey(contactInfoId))
                            {
                                continue;
                            }

                            contactInfos[contactInfoId].Tags.Add(_tags[tagId]);
                            contactInfos[contactInfoId].ResetIsChanged();

                            if (!_contactsTags.ContainsKey(tagId))
                            {
                                _contactsTags.Add(tagId, new List <IContact>());
                            }

                            _contactsTags[tagId].Add(contactInfoIdsContacts[contactInfoId]);
                        }
                    }
                }

                #endregion
            }

            // Fill contacts into main collection
            foreach (var item in contacts)
            {
                _contacts.Add(item.Key, item.Value);
            }

            Logger.LogNotice("Starting update watcher");
            _updateWatcher = new UpdateWatcher(this, syncInvoke);
        }
Ejemplo n.º 50
0
        public static void InitializeMetadata(int Timestep, ICore mCore)
        {
            ScenarioReplicationMetadata scenRep = new ScenarioReplicationMetadata()
            {
                RasterOutCellArea = PlugIn.ModelCore.CellArea,
                TimeMin           = PlugIn.ModelCore.StartTime,
                TimeMax           = PlugIn.ModelCore.EndTime
            };

            Extension = new ExtensionMetadata(mCore)
            {
                Name         = PlugIn.ExtensionName,
                TimeInterval = Timestep,
                ScenarioReplicationMetadata = scenRep
            };

            //---------------------------------------
            //          table outputs:
            //---------------------------------------

            PlugIn.ignitionsLog = new MetadataTable <IgnitionsLog>("scrapple-ignitions-log.csv");

            OutputMetadata tblOut_igns = new OutputMetadata()
            {
                Type      = OutputType.Table,
                Name      = "ClimateFireIgnitionsLog",
                FilePath  = PlugIn.ignitionsLog.FilePath,
                Visualize = false,
            };

            tblOut_igns.RetriveFields(typeof(IgnitionsLog));
            Extension.OutputMetadatas.Add(tblOut_igns);

            PlugIn.eventLog = new MetadataTable <EventsLog>("scrapple-events-log.csv");

            OutputMetadata tblOut_events = new OutputMetadata()
            {
                Type      = OutputType.Table,
                Name      = "ClimateFireEventsLog",
                FilePath  = PlugIn.eventLog.FilePath,
                Visualize = false,
            };

            tblOut_events.RetriveFields(typeof(EventsLog));
            Extension.OutputMetadatas.Add(tblOut_events);

            PlugIn.summaryLog = new MetadataTable <SummaryLog>("scrapple-summary-log.csv");

            OutputMetadata tblSummaryOut_events = new OutputMetadata()
            {
                Type      = OutputType.Table,
                Name      = "ClimateFireSummaryLog",
                FilePath  = PlugIn.summaryLog.FilePath,
                Visualize = false,
            };

            tblSummaryOut_events.RetriveFields(typeof(SummaryLog));
            Extension.OutputMetadatas.Add(tblSummaryOut_events);

            //---------------------------------------
            //          map outputs:
            //---------------------------------------
            string         intensityMapFileName = "scrapple-intensity.img";
            OutputMetadata mapOut_Intensity     = new OutputMetadata()
            {
                Type         = OutputType.Map,
                Name         = "Intensity",
                FilePath     = @intensityMapFileName,
                Map_DataType = MapDataType.Ordinal,
                Map_Unit     = FieldUnits.Severity_Rank,
                Visualize    = true,
            };

            Extension.OutputMetadatas.Add(mapOut_Intensity);

            //string specialDeadWoodMapFileName = "scrapple-dead-wood.img";
            //OutputMetadata mapOut_SpecialDead = new OutputMetadata()
            //{
            //    Type = OutputType.Map,
            //    Name = "SpecialDeadWood",
            //    FilePath = @specialDeadWoodMapFileName,
            //    Map_DataType = MapDataType.Continuous,
            //    Map_Unit = FieldUnits.g_C_m2,
            //    Visualize = true,
            //};
            //Extension.OutputMetadatas.Add(mapOut_Intensity);
            //OutputMetadata mapOut_Time = new OutputMetadata()
            //{
            //    Type = OutputType.Map,
            //    Name = "TimeLastFire",
            //    FilePath = @TimeMapFileName,
            //    Map_DataType = MapDataType.Continuous,
            //    Map_Unit = FieldUnits.Year,
            //    Visualize = true,
            //};
            //Extension.OutputMetadatas.Add(mapOut_Time);
            //---------------------------------------
            MetadataProvider mp = new MetadataProvider(Extension);

            mp.WriteMetadataToXMLFile("Metadata", Extension.Name, Extension.Name);
        }
Ejemplo n.º 51
0
 public override void InitializeComponent(ICore core)
 {
     base.InitializeComponent(core);
 }
Ejemplo n.º 52
0
 public PluginSettings(ICore core)
 {
     _uniqueInstance = this;
     _core           = core;
 }
Ejemplo n.º 53
0
 public MyQueryHandler(ICore core)
 {
     this.core = core;
     this.log  = new LogHelper(core);
 }
 public override void InitializeComponent(ICore core)
 {
     base.InitializeComponent(core);
     this.SignalEmitter         = core.Components.SignalEmitter;
     this.SignalEmitter.Signal += this.OnSignal;
 }
Ejemplo n.º 55
0
        public override void LoadParameters(string InputParameterFile, ICore mCore)
        {
            ModelCore = mCore;

            parameters.Add(Names.ExtensionName, new Parameter <string>(Names.ExtensionName, InputParameterFile));

            //-------------PnET-Succession input files
            Dictionary <string, Parameter <string> > InputParameters = LoadTable(Names.ExtensionName, Names.AllNames, null, true);

            InputParameters.ToList().ForEach(x => parameters.Add(x.Key, x.Value));

            //-------------Read Species parameters input file
            List <string> SpeciesNames = PlugIn.ModelCore.Species.ToList().Select(x => x.Name).ToList();
            List <string> SpeciesPars  = SpeciesPnET.ParameterNames;

            SpeciesPars.Add(Names.PnETSpeciesParameters);
            Dictionary <string, Parameter <string> > speciesparameters = LoadTable(Names.PnETSpeciesParameters, SpeciesNames, SpeciesPars);

            foreach (string key in speciesparameters.Keys)
            {
                if (parameters.ContainsKey(key))
                {
                    throw new System.Exception("Parameter " + key + " was provided twice");
                }
            }
            speciesparameters.ToList().ForEach(x => parameters.Add(x.Key, x.Value));

            //-------------Ecoregion parameters
            List <string> EcoregionNames      = PlugIn.ModelCore.Ecoregions.ToList().Select(x => x.Name).ToList();
            List <string> EcoregionParameters = EcoregionPnET.ParameterNames;
            Dictionary <string, Parameter <string> > ecoregionparameters = LoadTable(Names.EcoregionParameters, EcoregionNames, EcoregionParameters);

            foreach (string key in ecoregionparameters.Keys)
            {
                if (parameters.ContainsKey(key))
                {
                    throw new System.Exception("Parameter " + key + " was provided twice");
                }
            }

            ecoregionparameters.ToList().ForEach(x => parameters.Add(x.Key, x.Value));



            //---------------DisturbanceReductionsParameterFile
            Parameter <string> DisturbanceReductionsParameterFile;

            if (TryGetParameter(Names.DisturbanceReductions, out DisturbanceReductionsParameterFile))
            {
                Allocation.Initialize(DisturbanceReductionsParameterFile.Value, parameters);
                Cohort.AgeOnlyDeathEvent += DisturbanceReductions.Events.CohortDied;
            }


            //---------------SaxtonAndRawlsParameterFile
            if (parameters.ContainsKey(PressureHeadSaxton_Rawls.SaxtonAndRawlsParameters) == false)
            {
                Parameter <string> SaxtonAndRawlsParameterFile = new Parameter <string>(PressureHeadSaxton_Rawls.SaxtonAndRawlsParameters, (string)PnETDefaultsFolder + "\\SaxtonAndRawlsParameters.txt");
                parameters.Add(PressureHeadSaxton_Rawls.SaxtonAndRawlsParameters, SaxtonAndRawlsParameterFile);
            }
            Dictionary <string, Parameter <string> > SaxtonAndRawlsParameters = LoadTable(PressureHeadSaxton_Rawls.SaxtonAndRawlsParameters, null, PressureHeadSaxton_Rawls.ParameterNames);

            foreach (string key in SaxtonAndRawlsParameters.Keys)
            {
                if (parameters.ContainsKey(key))
                {
                    throw new System.Exception("Parameter " + key + " was provided twice");
                }
            }
            SaxtonAndRawlsParameters.ToList().ForEach(x => parameters.Add(x.Key, x.Value));

            //--------------PnETGenericParameterFile

            //----------See if user supplied overwriting default parameters
            List <string> RowLabels = new List <string>(Names.AllNames);

            RowLabels.AddRange(SpeciesPnET.ParameterNames);

            if (parameters.ContainsKey(Names.PnETGenericParameters))
            {
                Dictionary <string, Parameter <string> > genericparameters = LoadTable(Names.PnETGenericParameters, RowLabels, null, true);
                foreach (KeyValuePair <string, Parameter <string> > par in genericparameters)
                {
                    if (parameters.ContainsKey(par.Key))
                    {
                        throw new System.Exception("Parameter " + par.Key + " was provided twice");
                    }
                    parameters.Add(par.Key, par.Value);
                }
            }

            //----------Load in default parameters to fill the gaps
            Parameter <string> PnETGenericDefaultParameterFile = new Parameter <string>(Names.PnETGenericDefaultParameters, (string)PnETDefaultsFolder + "\\PnETGenericDefaultParameters.txt");

            parameters.Add(Names.PnETGenericDefaultParameters, PnETGenericDefaultParameterFile);
            Dictionary <string, Parameter <string> > genericdefaultparameters = LoadTable(Names.PnETGenericDefaultParameters, RowLabels, null, true);

            foreach (KeyValuePair <string, Parameter <string> > par in genericdefaultparameters)
            {
                if (parameters.ContainsKey(par.Key) == false)
                {
                    parameters.Add(par.Key, par.Value);
                }
            }

            SiteOutputNames = new Dictionary <ActiveSite, string>();
            Parameter <string> OutputSitesFile;

            if (TryGetParameter(LocalOutput.PNEToutputsites, out OutputSitesFile))
            {
                Dictionary <string, Parameter <string> > outputfiles = LoadTable(LocalOutput.PNEToutputsites, null, AssignOutputFiles.ParameterNames.AllNames, true);
                AssignOutputFiles.MapCells(outputfiles, ref SiteOutputNames);
            }
        }
        public override void InitializeSites(string initialCommunitiesText, string initialCommunitiesMap, ICore modelCore)
        {
            ModelCore.UI.WriteLine("   Loading initial communities from file \"{0}\" ...", initialCommunitiesText);
            Landis.Library.InitialCommunities.DatasetParser parser      = new Landis.Library.InitialCommunities.DatasetParser(Timestep, ModelCore.Species);
            Landis.Library.InitialCommunities.IDataset      communities = Landis.Data.Load <Landis.Library.InitialCommunities.IDataset>(initialCommunitiesText, parser);

            ModelCore.UI.WriteLine("   Reading initial communities map \"{0}\" ...", initialCommunitiesMap);
            IInputRaster <uintPixel> map;

            map = ModelCore.OpenRaster <uintPixel>(initialCommunitiesMap);
            using (map)
            {
                uintPixel pixel = map.BufferPixel;
                foreach (Site site in ModelCore.Landscape.AllSites)
                {
                    map.ReadBufferPixel();
                    uint mapCode = pixel.MapCode.Value;
                    if (!site.IsActive)
                    {
                        continue;
                    }

                    //if (!modelCore.Ecoregion[site].Active)
                    //    continue;

                    //modelCore.Log.WriteLine("ecoregion = {0}.", modelCore.Ecoregion[site]);

                    ActiveSite activeSite = (ActiveSite)site;
                    initialCommunity = communities.Find(mapCode);
                    if (initialCommunity == null)
                    {
                        throw new ApplicationException(string.Format("Unknown map code for initial community: {0}", mapCode));
                    }

                    InitializeSite(activeSite);
                }
            }
        }
Ejemplo n.º 57
0
 public MyPlugin(ICore core, int plugin_id)
 {
     this.core      = core;
     this.log       = new LogHelper(core);
     this.plugin_id = plugin_id;
 }
Ejemplo n.º 58
0
        public ScriptingServiceManager(ICore core)
        {
            Core = core ?? throw new ArgumentNullException(nameof(core));
            _standardIndicatorsInstances = new List <IndicatorBase>
            {
                new SimpleMovingAverage(),
                new SmoothedMovingAverage(),
                new ExponentialMovingAverage(),
                new LinearWeightedMovingAverage(),
                new AcceleratorOscillator(),
                new AccumulationDistribution(),
                new AverageDirectionalMovement(),
                new Alligator(),
                new AwesomeOscillator(),
                new AverageTrueRange(),
                new BollingerBands(),
                new BearsPower(),
                new BullsPower(),
                new MarketFacilitationIndex(),
                new CommodityChannelIndex(),
                new Envelopes(),
                new ForceIndex(),
                new Gator(),
                new MACD(),
                new MoneyFlowIndex(),
                new Momentum(),
                new OnBalanceVolume(),
                new MovingAverageOfOscillator(),
                new RelativeStrengthIndex(),
                new RelativeVigorIndex(),
                new StandardDeviation(),
                new Volume(),
                new WPercentRange(),
                new ParabolicSAR(),
                new StochasticOscillator(),
                new PL(),
                new ZigZag()
            };

            _signalStore = new SignalStore(Core.FileManager);

            _userWorkingIndicators       = new Dictionary <string, List <IndicatorService> >();
            _userIndicators              = new Dictionary <string, Dictionary <string, List <ScriptingParameterBase> > >();
            _availableStandardIndicators = new Dictionary <string, List <ScriptingParameterBase> >();
            _userSignals        = new Dictionary <string, List <Signal> >();
            _userWorkingSignals = new Dictionary <string, List <SignalService> >();

            foreach (var indicator in _standardIndicatorsInstances)
            {
                _availableStandardIndicators.Add(indicator.Name, indicator.GetParameters().ToList());
            }

            try
            {
                const string folder = "CustomIndicators";
                _indicatorsFolderPath = Directory.Exists(folder)
                    ? new DirectoryInfo(folder).FullName
                    : Directory.CreateDirectory(folder).FullName;
            }
            catch (Exception ex)
            {
                Logger.Error("Failed to create folder for custom indicators", ex);
            }

            try
            {
                const string folder = "CustomSignals";
                _signalsFolderPath = Directory.Exists(folder)
                    ? new DirectoryInfo(folder).FullName
                    : Directory.CreateDirectory(folder).FullName;
            }
            catch (Exception ex)
            {
                Logger.Error("Failed to create folder for custom Signals", ex);
            }
        }
Ejemplo n.º 59
0
 public IBlip Create(ICore core, IntPtr baseObjectPointer)
 {
     return(new AsyncBlip(core, baseObjectPointer));
 }
Ejemplo n.º 60
0
 public override void InitializeComponent(ICore core)
 {
     BassUtils.BUILT_IN_FORMATS.AddRange(BassModStreamProvider.EXTENSIONS);
 }