Пример #1
0
        public static void Write <T>(string MapNameTemplate, string units, int TStep, ISiteVar <Landis.Library.Parameters.Species.AuxParm <T> > Values)
        {
            string FileName = FileNames.ReplaceTemplateVars(MapNameTemplate).Replace(".img", ".txt");

            if (PlugIn.ModelCore.CurrentTime == 0)
            {
                FileNames.MakeFolders(FileName);
                System.IO.File.WriteAllLines(FileName, new string[] { Header(units) });
            }

            AuxParm <ulong> Values_spc = new AuxParm <ulong>(PlugIn.ModelCore.Species);
            AuxParm <ulong> Values_cnt = new AuxParm <ulong>(PlugIn.ModelCore.Species);

            foreach (ActiveSite site in PlugIn.ModelCore.Landscape)
            {
                foreach (ISpecies spc in PlugIn.ModelCore.Species)
                {
                    if (typeof(T) == typeof(bool))
                    {
                        if (Values[site][spc].ToString() == bool.TrueString)
                        {
                            Values_spc[spc]++;
                        }
                    }
                    else
                    {
                        ulong numeric = ulong.Parse(Values[site][spc].ToString());
                        Values_spc[spc] += numeric;
                    }

                    Values_cnt[spc]++;
                }
            }

            string line = TStep + "\t";

            foreach (ISpecies spc in PlugIn.ModelCore.Species)
            {
                line += Values_spc[spc] / (float)Values_cnt[spc] + "\t";
            }

            System.IO.StreamWriter sw = new System.IO.StreamWriter(FileName, true);
            sw.WriteLine(line);
            sw.Close();
        }
        public static void WriteUpdate(string MapNameTemplate, int year, AuxParm<int> values)
        {
            string FileName  = FileNames.ReplaceTemplateVars(MapNameTemplate).Replace(".img", ".txt").Replace(".gis", ".txt");

            if (year == 0)
            {
                FileNames.MakeFolders(FileName);
                System.IO.File.WriteAllLines(FileName, new string[]{Header});
            }

            string line = year + "\t";
            foreach (ISpecies species in PlugIn.SelectedSpecies)
            {
                line += values[species] + "\t";
            }
            System.IO.StreamWriter sw = new System.IO.StreamWriter(FileName,true);
            sw.WriteLine(line);
            sw.Close();
        }
        public static void WriteUpdate(string MapNameTemplate, int year, AuxParm <int> values)
        {
            string FileName = FileNames.ReplaceTemplateVars(MapNameTemplate).Replace(".img", ".csv").Replace(".gis", ".csv");

            if (year == 0)
            {
                FileNames.MakeFolders(FileName);
                System.IO.File.WriteAllLines(FileName, new string[] { Header });
            }

            string line = year.ToString();

            foreach (ISpecies species in PlugIn.SelectedSpecies)
            {
                line += ", " + values[species];
            }
            System.IO.StreamWriter sw = new System.IO.StreamWriter(FileName, true);
            sw.WriteLine(line);
            sw.Close();
        }