private List <int> GetApplicableSecondaryStrata()
        {
            List <int> l   = new List <int>();
            string     psl = null;
            string     ssl = null;
            string     tsl = null;

            TerminologyUtilities.GetStratumLabelTerminology(this.Project.GetDataSheet(Strings.DATASHEET_TERMINOLOGY_NAME), ref psl, ref ssl, ref tsl);
            DataSheet ds = this.ResultScenario.GetDataSheet(Strings.DATASHEET_NSIC_DISTRIBUTION_NAME);

            foreach (DataRow dr in ds.GetData().Rows)
            {
                if (dr[Strings.DATASHEET_SECONDARY_STRATUM_ID_COLUMN_NAME] == DBNull.Value)
                {
                    ExceptionUtils.ThrowInvalidOperationException(
                        "Cannot split by '{0}' because '{1}' is not specified for all records in Initial Conditions Distribution.", ssl, ssl);
                }

                int id = Convert.ToInt32(dr[Strings.DATASHEET_SECONDARY_STRATUM_ID_COLUMN_NAME], CultureInfo.InvariantCulture);

                if (!l.Contains(id))
                {
                    l.Add(id);
                }
            }

            Debug.Assert(l.Count > 0);
            return(l);
        }
Exemplo n.º 2
0
        protected override void ModifyLayout(SyncroSimLayout layout)
        {
            if (this.Library == null)
            {
                Debug.Assert(false);
                return;
            }

            if (this.Library.Session.ActiveProject == null)
            {
                Debug.Assert(false);
                return;
            }

            SyncroSimLayoutItem PrimaryStrataGroup = layout.Items.FindItem("stsim_PrimaryStrata", true);

            if (PrimaryStrataGroup == null)
            {
                Debug.Assert(false);
                return;
            }

            string psl = null;
            string ssl = null;
            string tsl = null;

            DataSheet dsterm = this.Library.Session.ActiveProject.GetDataSheet(Strings.DATASHEET_TERMINOLOGY_NAME);

            TerminologyUtilities.GetStratumLabelTerminology(dsterm, ref psl, ref ssl, ref tsl);

            PrimaryStrataGroup.DisplayName = psl;
        }
Exemplo n.º 3
0
        private ExportColumnCollection CreateColumnCollection()
        {
            ExportColumnCollection c = new ExportColumnCollection();

            string          AmountLabel           = null;
            string          UnitsLabel            = null;
            TerminologyUnit TermUnit              = 0;
            string          PrimaryStratumLabel   = null;
            string          SecondaryStratumLabel = null;
            string          TertiaryStratumLabel  = null;
            DataSheet       dsterm        = this.Project.GetDataSheet(Strings.DATASHEET_TERMINOLOGY_NAME);
            string          TimestepLabel = TerminologyUtilities.GetTimestepUnits(this.Project);

            TerminologyUtilities.GetAmountLabelTerminology(dsterm, ref AmountLabel, ref TermUnit);
            TerminologyUtilities.GetStratumLabelTerminology(dsterm, ref PrimaryStratumLabel, ref SecondaryStratumLabel, ref TertiaryStratumLabel);
            UnitsLabel = TerminologyUtilities.TerminologyUnitToString(TermUnit);
            string AmountTitle = string.Format(CultureInfo.InvariantCulture, "{0} ({1})", AmountLabel, UnitsLabel);

            c.Add(new ExportColumn("ScenarioID", "Scenario ID"));
            c.Add(new ExportColumn("ScenarioName", "Scenario"));
            c.Add(new ExportColumn("Iteration", "Iteration"));
            c.Add(new ExportColumn("Timestep", TimestepLabel));
            c.Add(new ExportColumn("Stratum", PrimaryStratumLabel));
            c.Add(new ExportColumn("SecondaryStratum", SecondaryStratumLabel));
            c.Add(new ExportColumn("TertiaryStratum", TertiaryStratumLabel));
            c.Add(new ExportColumn("StateClass", "State Class"));
            c.Add(new ExportColumn("AgeMin", "Age Min"));
            c.Add(new ExportColumn("AgeMax", "Age Max"));
            c.Add(new ExportColumn("Amount", AmountTitle));

            c["Amount"].DecimalPlaces = 2;
            c["Amount"].Alignment     = ColumnAlignment.Right;

            return(c);
        }
Exemplo n.º 4
0
        private ExportColumnCollection CreateColumnCollection()
        {
            ExportColumnCollection c = new ExportColumnCollection();

            string    PrimaryStratumLabel   = null;
            string    SecondaryStratumLabel = null;
            string    TertiaryStratumLabel  = null;
            DataSheet dsterm        = this.Project.GetDataSheet(Strings.DATASHEET_TERMINOLOGY_NAME);
            string    TimestepLabel = TerminologyUtilities.GetTimestepUnits(this.Project);

            TerminologyUtilities.GetStratumLabelTerminology(
                dsterm, ref PrimaryStratumLabel, ref SecondaryStratumLabel, ref TertiaryStratumLabel);

            c.Add(new ExportColumn("ScenarioID", "Scenario ID"));
            c.Add(new ExportColumn("ScenarioName", "Scenario"));
            c.Add(new ExportColumn("Iteration", "Iteration"));
            c.Add(new ExportColumn("Timestep", TimestepLabel));
            c.Add(new ExportColumn("Stratum", PrimaryStratumLabel));
            c.Add(new ExportColumn("SecondaryStratum", SecondaryStratumLabel));
            c.Add(new ExportColumn("TertiaryStratum", TertiaryStratumLabel));
            c.Add(new ExportColumn("AttributeType", "Attribute"));
            c.Add(new ExportColumn("AgeMin", "Age Min"));
            c.Add(new ExportColumn("AgeMax", "Age Max"));
            c.Add(new ExportColumn("Amount", "Total Value"));

            c["Amount"].DecimalPlaces = 2;
            c["Amount"].Alignment     = ColumnAlignment.Right;

            return(c);
        }
Exemplo n.º 5
0
        private static void AddChartTransitionVariables(SyncroSimLayoutItemCollection items, Project project)
        {
            string          AmountLabel = null;
            string          UnitsLabel  = null;
            TerminologyUnit TermUnit    = 0;
            DataSheet       dsterm      = project.GetDataSheet(Strings.DATASHEET_TERMINOLOGY_NAME);

            TerminologyUtilities.GetAmountLabelTerminology(dsterm, ref AmountLabel, ref TermUnit);
            UnitsLabel = TerminologyUtilities.TerminologyUnitToString(TermUnit);

            string disp = string.Format(CultureInfo.InvariantCulture, "{0} ({1})", AmountLabel, UnitsLabel);
            SyncroSimLayoutItem Normal     = new SyncroSimLayoutItem(Strings.TRANSITION_AMOUNT_VARIABLE_NAME, disp, false);
            SyncroSimLayoutItem Proportion = new SyncroSimLayoutItem(Strings.TRANSITION_PROPORTION_VARIABLE_NAME, "Proportion", false);

            Normal.Properties.Add(new MetaDataProperty("dataSheet", "stsim_OutputStratumTransition"));
            Proportion.Properties.Add(new MetaDataProperty("dataSheet", "stsim_OutputStratumTransition"));

            Normal.Properties.Add(new MetaDataProperty("column", "Amount"));
            Proportion.Properties.Add(new MetaDataProperty("column", "Amount"));

            Normal.Properties.Add(new MetaDataProperty("skipTimestepZero", "True"));
            Proportion.Properties.Add(new MetaDataProperty("skipTimestepZero", "True"));

            Normal.Properties.Add(new MetaDataProperty("defaultValue", "0.0"));
            Proportion.Properties.Add(new MetaDataProperty("defaultValue", "0.0"));

            items.Add(Normal);
            items.Add(Proportion);
        }
Exemplo n.º 6
0
        internal void InternalExport(string location, ExportType exportType, bool showMessage)
        {
            string                 AmountLabel = null;
            TerminologyUnit        TermUnit    = 0;
            DataSheet              dsterm      = this.Project.GetDataSheet(Strings.DATASHEET_TERMINOLOGY_NAME);
            ExportColumnCollection columns     = this.CreateColumnCollection();

            TerminologyUtilities.GetAmountLabelTerminology(dsterm, ref AmountLabel, ref TermUnit);

            string WorksheetName = string.Format(CultureInfo.InvariantCulture, "{0} by Transition and State", AmountLabel);

            if (exportType == ExportType.ExcelFile)
            {
                this.ExcelExport(location, columns, this.CreateReportQuery(false), WorksheetName);
            }
            else
            {
                columns.Remove("ScenarioName");
                this.CSVExport(location, columns, this.CreateReportQuery(true));

                if (showMessage)
                {
                    FormsUtilities.InformationMessageBox("Data saved to '{0}'.", location);
                }
            }
        }
Exemplo n.º 7
0
        private void RefreshCalculatedValues()
        {
            DataRow drProp = this.DataFeed.GetDataSheet(Strings.DATASHEET_SPPIC_NAME).GetDataRow();

            if (drProp == null)
            {
                return;
            }

            //Num Cells
            int NumCells = DataTableUtilities.GetDataInt(drProp[Strings.DATASHEET_SPPIC_NUM_CELLS_COLUMN_NAME]);

            this.TextBoxNumCells.Text = NumCells.ToString(CultureInfo.InvariantCulture);

            //Get the units and refresh the units labels - the default Raster Cell Units is Metres^2
            string          srcSizeUnits = DataTableUtilities.GetDataStr(drProp[Strings.DATASHEET_SPPIC_CELL_SIZE_UNITS_COLUMN_NAME]);
            string          srcAreaUnits = srcSizeUnits + "^2";
            string          amountlabel  = null;
            TerminologyUnit destUnitsVal = 0;

            TerminologyUtilities.GetAmountLabelTerminology(
                this.Project.GetDataSheet(Strings.DATASHEET_TERMINOLOGY_NAME), ref amountlabel, ref destUnitsVal);

            string destAreaLbl = TerminologyUtilities.TerminologyUnitToString(destUnitsVal);

            srcAreaUnits = srcAreaUnits.ToLower(CultureInfo.InvariantCulture);
            amountlabel  = amountlabel.ToLower(CultureInfo.InvariantCulture);
            destAreaLbl  = destAreaLbl.ToLower(CultureInfo.InvariantCulture);

            this.LabelRasterCellArea.Text = string.Format(CultureInfo.InvariantCulture, "Cell size ({0}):", srcAreaUnits);
            this.LabelCalcCellArea.Text   = string.Format(CultureInfo.InvariantCulture, "Cell size ({0}):", destAreaLbl);
            this.LabelCalcTtlAmount.Text  = string.Format(CultureInfo.InvariantCulture, "Total {0} ({1}):", amountlabel, destAreaLbl);

            // Calculate Cell Area in raster's native units
            float  cellSize = DataTableUtilities.GetDataSingle(drProp[Strings.DATASHEET_SPPIC_CELL_SIZE_COLUMN_NAME]);
            double cellArea = Math.Pow(cellSize, 2);

            this.TextBoxCellArea.Text = cellArea.ToString("N4", CultureInfo.InvariantCulture);

            // Calc Cell Area in terminology units
            double cellAreaTU = 0;

            if (!CheckBoxCellSizeOverride.Checked)
            {
                cellAreaTU = InitialConditionsSpatialDataSheet.CalcCellArea(cellArea, srcSizeUnits, destUnitsVal);
                this.TextBoxCellAreaCalc.Text = cellAreaTU.ToString("N4", CultureInfo.InvariantCulture);
                drProp[Strings.DATASHEET_SPPIC_CELL_AREA_COLUMN_NAME] = cellAreaTU;
                TextBoxCellAreaCalc.ReadOnly = true;
            }
            else
            {
                cellAreaTU = DataTableUtilities.GetDataDbl(drProp[Strings.DATASHEET_SPPIC_CELL_AREA_COLUMN_NAME]);
                TextBoxCellAreaCalc.ReadOnly = false;
            }

            // Now calculate total area in the specified terminology units
            var ttlArea = cellAreaTU * NumCells;

            this.TextBoxTotalArea.Text = ttlArea.ToString("N4", CultureInfo.InvariantCulture);
        }
Exemplo n.º 8
0
        private void ResetSlxAndSlyLabels()
        {
            string slxlabel = null;
            string slylabel = null;

            TerminologyUtilities.GetStateLabelTerminology(this.m_TerminologyDataSheet, ref slxlabel, ref slylabel);

            this.LabelStateLabelX.Text = slxlabel + ":";
            this.LabelStateLabelY.Text = slylabel + ":";
        }
Exemplo n.º 9
0
        private void RefreshTitleBar(Project project)
        {
            string    primary   = null;
            string    secondary = null;
            string    tertiary  = null;
            DataSheet ds        = project.GetDataSheet(Strings.DATASHEET_TERMINOLOGY_NAME);

            TerminologyUtilities.GetStratumLabelTerminology(ds, ref primary, ref secondary, ref tertiary);
            this.Text = "Select " + primary;
        }
Exemplo n.º 10
0
        private void OnTerminologyChanged(DataSheetMonitorEventArgs e)
        {
            string slxlabel = null;
            string slylabel = null;

            DataSheet ds = this.m_Project.GetDataSheet(Strings.DATASHEET_TERMINOLOGY_NAME);

            TerminologyUtilities.GetStateLabelTerminology(ds, ref slxlabel, ref slylabel);

            this.m_TooltipText = slxlabel + ": " + this.m_SLXDisplayName + Environment.NewLine + slylabel + ": " + this.m_SLYDisplayName;
        }
Exemplo n.º 11
0
        protected STSimMapBase(Scenario scenario)
        {
            this.m_Scenario = scenario;

            DataSheet ds = scenario.Project.GetDataSheet(Strings.DATASHEET_TERMINOLOGY_NAME);

            TerminologyUtilities.GetStratumLabelTerminology(
                ds,
                ref this.m_PrimaryStratumLabel,
                ref this.m_SecondaryStratumLabel,
                ref this.m_TertiaryStratumLabel);
        }
        protected override void OnDataSheetChanged(DataSheetMonitorEventArgs e)
        {
            base.OnDataSheetChanged(e);

            string          AmountLabel = null;
            TerminologyUnit AmountUnits = TerminologyUnit.None;

            TerminologyUtilities.GetAmountLabelTerminology(e.DataSheet, ref AmountLabel, ref AmountUnits);

            this.Columns[Strings.DATASHEET_TRANSITION_SIZE_DISTRIBUTION_MAXIMUM_AREA_COLUMN_NAME].DisplayName =
                (string.Format(CultureInfo.InvariantCulture, "Maximum {0} ({1})",
                               AmountLabel, TerminologyUtilities.TerminologyUnitToString(AmountUnits)));
        }
Exemplo n.º 13
0
        private void CreateExcelReport(string fileName)
        {
            string          AmountLabel      = null;
            TerminologyUnit AmountLabelUnits = 0;
            string          ReportQuery      = CreateReportQuery(false);
            DataTable       ReportData       = this.GetDataTableForReport(ReportQuery);
            DataSheet       dsterm           = this.Project.GetDataSheet(Strings.DATASHEET_TERMINOLOGY_NAME);

            TerminologyUtilities.GetAmountLabelTerminology(dsterm, ref AmountLabel, ref AmountLabelUnits);
            string WorksheetName = string.Format(CultureInfo.InvariantCulture, "{0} by State Class", AmountLabel);

            ExportTransformer.ExcelExport(fileName, this.CreateColumnCollection(), ReportData, WorksheetName);
        }
Exemplo n.º 14
0
        protected override void OnDataSheetChanged(DataSheetMonitorEventArgs e)
        {
            base.OnDataSheetChanged(e);

            string Primary   = null;
            string Secondary = null;
            string Tertiary  = null;

            TerminologyUtilities.GetStratumLabelTerminology(e.DataSheet, ref Primary, ref Secondary, ref Tertiary);

            this.Columns[Strings.DATASHEET_PT_STRATUMIDSOURCE_COLUMN_NAME].DisplayName = Primary;
            this.Columns[Strings.DATASHEET_PT_STRATUMIDDEST_COLUMN_NAME].DisplayName   = "To " + Primary;
        }
        protected override void OnDataSheetChanged(DataSheetMonitorEventArgs e)
        {
            base.OnDataSheetChanged(e);

            string          amountlabel = null;
            TerminologyUnit units       = 0;
            string          unitsLbl    = null;

            TerminologyUtilities.GetAmountLabelTerminology(e.DataSheet, ref amountlabel, ref units);
            unitsLbl = TerminologyUtilities.TerminologyUnitToString(units).ToLower(CultureInfo.InvariantCulture);

            this.LabelTotalAmount.Text   = string.Format(CultureInfo.InvariantCulture, "Total ({0}):", unitsLbl);
            this.LabelCellSize.Text      = string.Format(CultureInfo.InvariantCulture, "Cell size ({0}):", unitsLbl);
            this.TextBoxNumCells.Enabled = (this.ShouldEnableView() && (!this.CheckBoxCalcFromDist.Checked));
        }
Exemplo n.º 16
0
        protected override void OnDataSheetChanged(DataSheetMonitorEventArgs e)
        {
            base.OnDataSheetChanged(e);

            string          AmountLabel = null;
            TerminologyUnit AmountUnits = TerminologyUnit.None;

            TerminologyUtilities.GetAmountLabelTerminology(e.DataSheet, ref AmountLabel, ref AmountUnits);

            this.Columns[Strings.DATASHEET_AMOUNT_COLUMN_NAME].DisplayName                 = (string.Format(CultureInfo.InvariantCulture, "Target {0} ({1})", AmountLabel, TerminologyUtilities.TerminologyUnitToString(AmountUnits)));
            this.Columns[Strings.DATASHEET_DISTRIBUTIONTYPE_COLUMN_NAME].DisplayName       = string.Format(CultureInfo.InvariantCulture, "Target {0} Distribution", AmountLabel);
            this.Columns[Strings.DATASHEET_DISTRIBUTION_FREQUENCY_COLUMN_NAME].DisplayName = string.Format(CultureInfo.InvariantCulture, "Target {0} Sampling Frequency", AmountLabel);
            this.Columns[Strings.DATASHEET_DISTRIBUTIONSD_COLUMN_NAME].DisplayName         = string.Format(CultureInfo.InvariantCulture, "Target {0} SD", AmountLabel);
            this.Columns[Strings.DATASHEET_DISTRIBUTIONMIN_COLUMN_NAME].DisplayName        = string.Format(CultureInfo.InvariantCulture, "Target {0} Min", AmountLabel);
            this.Columns[Strings.DATASHEET_DISTRIBUTIONMAX_COLUMN_NAME].DisplayName        = string.Format(CultureInfo.InvariantCulture, "Target {0} Max", AmountLabel);
        }
Exemplo n.º 17
0
        private void OnTerminologyChanged(DataSheetMonitorEventArgs e)
        {
            string          Primary     = null;
            string          Secondary   = null;
            string          Tertiary    = null;
            string          AmountLabel = null;
            TerminologyUnit AmountUnits = TerminologyUnit.None;

            TerminologyUtilities.GetStratumLabelTerminology(e.DataSheet, ref Primary, ref Secondary, ref Tertiary);
            TerminologyUtilities.GetAmountLabelTerminology(e.DataSheet, ref AmountLabel, ref AmountUnits);

            this.m_FilesDataGrid.Columns[PRIMARY_STRATUM_FILE_NAME_COLUMN_INDEX].HeaderText   = BuildLowerCaseLabel(Primary);
            this.m_FilesDataGrid.Columns[SECONDARY_STRATUM_FILE_NAME_COLUMN_INDEX].HeaderText = BuildLowerCaseLabel(Secondary);
            this.m_FilesDataGrid.Columns[TERTIARY_STRATUM_FILE_NAME_COLUMN_INDEX].HeaderText  = BuildLowerCaseLabel(Tertiary);

            this.RefreshCalculatedValues();
        }
Exemplo n.º 18
0
        private void ValidateNormalSplit()
        {
            string          psl = null;
            string          ssl = null;
            string          tsl = null;
            string          aml = null;
            TerminologyUnit amu = 0;
            DataSheet       tds = this.Project.GetDataSheet(Strings.DATASHEET_TERMINOLOGY_NAME);

            TerminologyUtilities.GetStratumLabelTerminology(tds, ref psl, ref ssl, ref tsl);
            TerminologyUtilities.GetAmountLabelTerminology(tds, ref aml, ref amu);

            //We don't support splits by secondary strata for spatial runs as this time

            if (this.IsSpatial)
            {
                ExceptionUtils.ThrowInvalidOperationException("Cannot split by '{0}' for a spatial model run.", ssl);
            }

            //If there are less than 2 secondary strata records referenced by
            //Initial Conditions Distribution we cannot do a split by secondary strata

            List <int> l = this.GetApplicableSecondaryStrata();

            if (l.Count < 2)
            {
                ExceptionUtils.ThrowInvalidOperationException("Cannot split by '{0}' because there are fewer than two references to '{1}' in Initial Conditions Distribution.", ssl, ssl);
            }

            //If there are Transition Targets with NULL secondary stata then add a warning

            if (NullValueExists(this.ResultScenario.GetDataSheet(Strings.DATASHEET_TRANSITION_TARGET_NAME).GetData(), Strings.DATASHEET_SECONDARY_STRATUM_ID_COLUMN_NAME))
            {
                this.RecordStatus(StatusType.Warning, string.Format(CultureInfo.InvariantCulture, "Run is splitting by '{0}' but Transition Targets are not specified by '{1}'.  Allocating targets in proportion to '{2}'.", ssl, ssl, aml));
            }

            //If there are Transition Attribute Targets with NULL secondary stata then add a warning

            if (NullValueExists(this.ResultScenario.GetDataSheet(Strings.DATASHEET_TRANSITION_ATTRIBUTE_TARGET_NAME).GetData(), Strings.DATASHEET_SECONDARY_STRATUM_ID_COLUMN_NAME))
            {
                this.RecordStatus(StatusType.Warning, string.Format(CultureInfo.InvariantCulture, "Run is splitting by '{0}' but Transition Attribute Targets are not specified by '{1}'.  Allocating targets in proportion to '{2}'.", ssl, ssl, aml));
            }
        }
Exemplo n.º 19
0
        protected override void OnRowsAdded(object sender, DataSheetRowEventArgs e)
        {
            base.OnRowsAdded(sender, e);

            var       ThisData = this.GetData();
            DataSheet dsProp   = this.GetDataSheet(Strings.DATASHEET_SPPIC_NAME);
            DataRow   drProp   = dsProp.GetDataRow();

            if (drProp == null && ThisData.DefaultView.Count > 0)
            {
                dsProp.BeginAddRows();
                drProp = dsProp.GetData().NewRow();

                DataRow FirstRow = ThisData.DefaultView[0].Row;
                StochasticTimeRaster FirstRast = this.LoadRaster(FirstRow, Strings.DATASHEET_SPIC_STRATUM_FILE_COLUMN_NAME);

                if (FirstRast.IntCells == null)
                {
                    FirstRast.LoadData();
                }

                drProp[Strings.DATASHEET_SPPIC_NUM_ROWS_COLUMN_NAME]           = FirstRast.Height;
                drProp[Strings.DATASHEET_SPPIC_NUM_COLUMNS_COLUMN_NAME]        = FirstRast.Width;
                drProp[Strings.DATASHEET_SPPIC_NUM_CELLS_COLUMN_NAME]          = FirstRast.GetNumberValidCells();
                drProp[Strings.DATASHEET_SPPIC_XLLCORNER_COLUMN_NAME]          = FirstRast.XllCorner;
                drProp[Strings.DATASHEET_SPPIC_YLLCORNER_COLUMN_NAME]          = FirstRast.YllCorner;
                drProp[Strings.DATASHEET_SPPIC_CELL_SIZE_COLUMN_NAME]          = FirstRast.CellSize;
                drProp[Strings.DATASHEET_SPPIC_CELL_SIZE_UNITS_COLUMN_NAME]    = FirstRast.CellSizeUnits;
                drProp[Strings.DATASHEET_SPPIC_SRS_COLUMN_NAME]                = FirstRast.Projection;
                drProp[Strings.DATASHEET_SPPIC_CELL_AREA_OVERRIDE_COLUMN_NAME] = false;

                string          amountlabel  = null;
                TerminologyUnit destUnitsVal = 0;
                double          cellArea     = System.Math.Pow((double)FirstRast.CellSize, 2);

                TerminologyUtilities.GetAmountLabelTerminology(this.Project.GetDataSheet(Strings.DATASHEET_TERMINOLOGY_NAME), ref amountlabel, ref destUnitsVal);
                drProp[Strings.DATASHEET_SPPIC_CELL_AREA_COLUMN_NAME] = CalcCellArea(cellArea, FirstRast.CellSizeUnits, destUnitsVal);

                dsProp.Changes.Add(new ChangeRecord(this, "Added raster metadata"));
                dsProp.GetData().Rows.Add(drProp);
                dsProp.EndAddRows();
            }
        }
Exemplo n.º 20
0
        public void ThrowDataException(int stateClassId, bool isDestination)
        {
            string    psl                 = null;
            string    ssl                 = null;
            string    tsl                 = null;
            string    StateClassName      = "NULL";
            DataSheet StateClassDataSheet = this.m_Project.GetDataSheet(Strings.DATASHEET_STATECLASS_NAME);
            string    Location            = "From";

            if (isDestination)
            {
                Location = "To";
            }

            TerminologyUtilities.GetStratumLabelTerminology(this.m_Project.GetDataSheet(Strings.DATASHEET_TERMINOLOGY_NAME), ref psl, ref ssl, ref tsl);
            StateClassName = Convert.ToString(DataTableUtilities.GetTableValue(StateClassDataSheet.GetData(), StateClassDataSheet.ValueMember, stateClassId, Strings.DATASHEET_NAME_COLUMN_NAME), CultureInfo.InvariantCulture);
            string msg = string.Format(CultureInfo.InvariantCulture, "The state class '{0}' could not be located in '{1} {2}'.", StateClassName, Location, psl);

            throw new DataException(msg);
        }
Exemplo n.º 21
0
 /// <summary>
 /// Configures the lower case version of the timestep units
 /// </summary>
 private void ConfigureTimestepUnits()
 {
     this.TimestepUnits        = TerminologyUtilities.GetTimestepUnits(this.Project);
     this.m_TimestepUnitsLower = this.TimestepUnits.ToLower(CultureInfo.InvariantCulture);
 }
Exemplo n.º 22
0
        private void CreatePartialLibraries(DataTable splitData, bool isSpatialSplit)
        {
            string psl = null;
            string ssl = null;
            string tsl = null;

            TerminologyUtilities.GetStratumLabelTerminology(
                this.Project.GetDataSheet(Strings.DATASHEET_TERMINOLOGY_NAME), ref psl, ref ssl, ref tsl);

            //Save the library because we may have added status data to the scenario

            if (this.Library.HasChanges())
            {
                this.Library.Save();
            }

            this.BeginProgress(splitData.Rows.Count + 1);

            this.SetStatusMessage(string.Format(CultureInfo.InvariantCulture,
                                                "Preparing Data For Parallel Processing (Split by '{0}')",
                                                ssl));

            //We have numJobs + 1 because we want the progress indicator to include
            //the time it takes to create the partial library.

            this.CreatePartialLibrary();
            this.StepProgress();

            //Then make a copy of the partial library for each job.  Note, however, that for the final
            //job we move the partial library instead of copying it.

            List <string> Files = new List <string>();
            DataView      dv    = new DataView(splitData, null, "ID", DataViewRowState.CurrentRows);
            int           JobId = 1;

            foreach (DataRowView drv in dv)
            {
                string JobFileName  = string.Format(CultureInfo.InvariantCulture, "Job-{0}.ssim", JobId);
                string FullFileName = Path.Combine(this.JobFolderName, JobFileName);

                drv.Row["FileName"] = FullFileName;

                if (JobId == splitData.Rows.Count)
                {
                    File.Move(this.PartialLibraryName, FullFileName);
                }
                else
                {
                    File.Copy(this.PartialLibraryName, FullFileName);
                }

                this.ConfigureDatabase(drv.Row, isSpatialSplit);

                Debug.Assert(!Files.Contains(FullFileName));
                Files.Add(FullFileName);

                this.StepProgress();

                JobId += 1;
            }

            this.CompleteProgress();

            //If it is a spatial split, configure the external files

            if (isSpatialSplit)
            {
                this.ConfigureExternalFiles(splitData);
            }

            //Create the configuration file

            this.CreateSplitConfigurationFile(Files, splitData.Rows.Count);

            //The partial file and input folder should now be gone

            Debug.Assert(!File.Exists(this.PartialLibraryName));
            Debug.Assert(!Directory.Exists(Path.Combine(this.JobFolderName, "Partial.ssim.input")));

            this.SetStatusMessage(null);
        }
Exemplo n.º 23
0
        private void ValidateRaster(StochasticTimeRaster rast, int rows, int columns, string columnName)
        {
            string PrimaryStratumLabel   = null;
            string SecondaryStratumLabel = null;
            string TertiaryStratumLabel  = null;
            string ColumnDisplayName     = this.Columns[columnName].DisplayName;

            DataSheet TerminologySheet =
                this.Project.GetDataSheet(Strings.DATASHEET_TERMINOLOGY_NAME);

            TerminologyUtilities.GetStratumLabelTerminology(
                TerminologySheet, ref PrimaryStratumLabel, ref SecondaryStratumLabel, ref TertiaryStratumLabel);

            if (columnName == Strings.DATASHEET_SPIC_STRATUM_FILE_COLUMN_NAME)
            {
                ColumnDisplayName = PrimaryStratumLabel;
            }
            else if (columnName == Strings.DATASHEET_SPIC_SECONDARY_STRATUM_FILE_COLUMN_NAME)
            {
                ColumnDisplayName = SecondaryStratumLabel;
            }

            if (rast.Height != rows)
            {
                string msg = null;

                if (columnName == Strings.DATASHEET_SPIC_STRATUM_FILE_COLUMN_NAME)
                {
                    msg = string.Format(CultureInfo.InvariantCulture,
                                        "The number of rows for the '{0}' raster does not match that of the other '{1}' rasters.",
                                        PrimaryStratumLabel, PrimaryStratumLabel);
                }
                else
                {
                    msg = string.Format(CultureInfo.InvariantCulture,
                                        "The number of rows for the '{0}' raster does not match that of the '{1}' raster.",
                                        ColumnDisplayName, PrimaryStratumLabel);
                }

                throw new DataException(msg);
            }
            else if (rast.Width != columns)
            {
                string msg = null;

                if (columnName == Strings.DATASHEET_SPIC_STRATUM_FILE_COLUMN_NAME)
                {
                    msg = string.Format(CultureInfo.InvariantCulture,
                                        "The number of columns for the '{0}' raster does not match that of the other '{1}' rasters.",
                                        PrimaryStratumLabel, PrimaryStratumLabel);
                }
                else
                {
                    msg = string.Format(CultureInfo.InvariantCulture,
                                        "The number of columns for the '{0}' raster does not match that of the '{1}' raster.",
                                        ColumnDisplayName, PrimaryStratumLabel);
                }

                throw new DataException(msg);
            }
        }