public void AddItem(FlowPathway pathway) { int StockTypeId = pathway.FromStockTypeId.HasValue ? pathway.FromStockTypeId.Value : Constants.NULL_FROM_STOCK_TYPE_ID; SortedKeyMap4 <List <FlowPathway> > m1 = this.m_Map.GetItemExact( pathway.FromStratumId, pathway.FromSecondaryStratumId, pathway.FromTertiaryStratumId, pathway.FromStateClassId, StockTypeId, pathway.ToStratumId, pathway.ToStateClassId, pathway.TransitionGroupId, pathway.FlowTypeId); if (m1 == null) { m1 = new SortedKeyMap4 <List <FlowPathway> >(SearchMode.ExactPrev); this.m_Map.AddItem(pathway.FromStratumId, pathway.FromSecondaryStratumId, pathway.FromTertiaryStratumId, pathway.FromStateClassId, StockTypeId, pathway.ToStratumId, pathway.ToStateClassId, pathway.TransitionGroupId, pathway.FlowTypeId, m1); } List <FlowPathway> l = m1.GetItemExact(pathway.FromMinimumAge, pathway.ToMinimumAge, pathway.Iteration, pathway.Timestep); if (l == null) { l = new List <FlowPathway>(); m1.AddItem(pathway.FromMinimumAge, pathway.ToMinimumAge, pathway.Iteration, pathway.Timestep, l); } l.Add(pathway); this.m_HasRecords = true; }
private static FlowPathwayLine CreatePathwayLineToSelf(StockTypeShape shape, FlowPathway pathway) { FlowPathwayLine l = new FlowPathwayLine(Constants.DIAGRAM_FLOW_PATHWAY_LINE_COLOR, pathway); const int PT_CIRCLE_RADIUS = 10; int lrx = shape.Bounds.X + shape.Bounds.Width - PT_CIRCLE_RADIUS; int lry = shape.Bounds.Y + shape.Bounds.Height - PT_CIRCLE_RADIUS; Rectangle rc = new Rectangle(lrx, lry, 2 * PT_CIRCLE_RADIUS, 2 * PT_CIRCLE_RADIUS); l.AddEllipse(rc); return(l); }
private void FillIncomingPathways(StockTypeShape shape) { DataRow[] IncomingRows = this.GetIncomingPathways(shape.StockTypeId); foreach (DataRow dr in IncomingRows) { Debug.Assert(Convert.ToInt32(dr[Constants.TO_STOCK_TYPE_ID_COLUMN_NAME], CultureInfo.InvariantCulture) == shape.StockTypeId); FlowPathway fp = DataTableUtilities.CreateFlowPathway(dr); shape.IncomingFlowPathways.Add(fp); } }
private void FillFlowPathways() { Debug.Assert(this.m_FlowPathways.Count == 0); Debug.Assert(this.m_LateralFlowCoupletMap == null); this.m_LateralFlowCoupletMap = new LateralFlowCoupletMap(); DataSheet ds = this.ResultScenario.GetDataSheet(Constants.DATASHEET_FLOW_PATHWAY_NAME); foreach (DataRow dr in ds.GetData().Rows) { FlowPathway fp = DataTableUtilities.CreateFlowPathway(dr); this.m_FlowPathways.Add(fp); if (fp.IsLateral) { this.m_LateralFlowCoupletMap.AddCouplet(fp.ToStockTypeId, fp.FlowTypeId); } } }
private void RecordSummaryFlowOutputData( int timestep, Cell cell, DeterministicTransition deterministicPathway, Transition probabilisticPathway, FlowPathway flowPathway, double flowAmount) { int?TransitionTypeId = null; int StratumIdDest = cell.StratumId; int StateClassIdDest = cell.StateClassId; if (probabilisticPathway != null) { TransitionTypeId = probabilisticPathway.TransitionTypeId; if (probabilisticPathway.StratumIdDestination.HasValue) { StratumIdDest = probabilisticPathway.StratumIdDestination.Value; } if (probabilisticPathway.StateClassIdDestination.HasValue) { StateClassIdDest = probabilisticPathway.StateClassIdDestination.Value; } } else { if (deterministicPathway != null) { if (deterministicPathway.StratumIdDestination.HasValue) { StratumIdDest = deterministicPathway.StratumIdDestination.Value; } if (deterministicPathway.StateClassIdDestination.HasValue) { StateClassIdDest = deterministicPathway.StateClassIdDestination.Value; } } } if (this.m_STSimTransformer.IsOutputTimestep( timestep, this.m_SummaryFlowOutputTimesteps, this.m_CreateSummaryFlowOutput)) { FlowType t = this.m_FlowTypes[flowPathway.FlowTypeId]; foreach (FlowGroupLinkage l in t.FlowGroupLinkages) { if (!l.FlowGroup.OutputFilter.HasFlag(Constants.OutputFilter.Tabular)) { continue; } FifteenIntegerLookupKey k = new FifteenIntegerLookupKey( cell.StratumId, GetSecondaryStratumIdKey(cell), GetTertiaryStratumIdKey(cell), cell.StateClassId, LookupKeyUtilities.GetOutputCollectionKey(flowPathway.FromStockTypeId), LookupKeyUtilities.GetOutputCollectionKey(TransitionTypeId), StratumIdDest, StateClassIdDest, LookupKeyUtilities.GetOutputCollectionKey(flowPathway.ToStockTypeId), l.FlowGroup.Id, LookupKeyUtilities.GetOutputCollectionKey(flowPathway.TransferToStratumId), LookupKeyUtilities.GetOutputCollectionKey(flowPathway.TransferToSecondaryStratumId), LookupKeyUtilities.GetOutputCollectionKey(flowPathway.TransferToTertiaryStratumId), LookupKeyUtilities.GetOutputCollectionKey(flowPathway.TransferToStateClassId), LookupKeyUtilities.GetOutputCollectionKey(flowPathway.TransferToMinimumAge)); if (this.m_SummaryOutputFlowRecords.Contains(k)) { OutputFlow r = this.m_SummaryOutputFlowRecords[k]; r.Amount += (flowAmount * l.Value); } else { OutputFlow r = new OutputFlow( cell.StratumId, GetSecondaryStratumIdValue(cell), GetTertiaryStratumIdValue(cell), cell.StateClassId, flowPathway.FromStockTypeId, TransitionTypeId, StratumIdDest, StateClassIdDest, flowPathway.ToStockTypeId, l.FlowGroup.Id, flowPathway.TransferToStratumId, flowPathway.TransferToSecondaryStratumId, flowPathway.TransferToTertiaryStratumId, flowPathway.TransferToStateClassId, flowPathway.TransferToMinimumAge, flowAmount * l.Value); this.m_SummaryOutputFlowRecords.Add(r); } } } }
public FlowPathwayLine(Color lineColor, FlowPathway pathway) : base(lineColor) { this.m_Pathway = pathway; }
private static FlowPathwayLine CreateNullFromStockTypeCue(StockTypeShape shape, FlowPathway fp) { int X1 = shape.Bounds.X - Constants.FLOW_PATHWAY_NULL_STOCK_TYPE_CUE_SIZE; int Y1 = shape.Bounds.Y - Constants.FLOW_PATHWAY_NULL_STOCK_TYPE_CUE_SIZE; int X2 = shape.Bounds.X; int Y2 = shape.Bounds.Y; FlowPathwayLine Line = new FlowPathwayLine(Constants.DIAGRAM_FLOW_PATHWAY_LINE_COLOR, fp); Line.AddLineSegment(X1, Y1, X2, Y2); Line.AddArrowSegments(X2, Y2, BoxArrowDiagramArrowDirection.Southeast); return(Line); }
public static FlowPathway CreateFlowPathway(DataRow dr) { int? Iteration = null; int? Timestep = null; int? FromStratumId = null; int? FromSecondaryStratumId = null; int? FromTertiaryStratumId = null; int? FromStateClassId = null; int? FromMinimumAge = null; int? FromStockTypeId = null; int? ToStratumId = null; int? ToStateClassId = null; int? ToMinimumAge = null; int? ToStockTypeId = null; int TransitionGroupId = 0; int? StateAttributeTypeId = null; int FlowTypeId = 0; int? TargetType = null; double Multiplier = 0; int? TransferToStratumId = null; int? TransferToSecondaryStratumId = null; int? TransferToTertiaryStratumId = null; int? TransferToStateClassId = null; int? TransferToMinimumAge = null; if (dr[Constants.ITERATION_COLUMN_NAME] != DBNull.Value) { Iteration = Convert.ToInt32(dr[Constants.ITERATION_COLUMN_NAME], CultureInfo.InvariantCulture); } if (dr[Constants.TIMESTEP_COLUMN_NAME] != DBNull.Value) { Timestep = Convert.ToInt32(dr[Constants.TIMESTEP_COLUMN_NAME], CultureInfo.InvariantCulture); } if (dr[Constants.FROM_STRATUM_ID_COLUMN_NAME] != DBNull.Value) { FromStratumId = Convert.ToInt32(dr[Constants.FROM_STRATUM_ID_COLUMN_NAME], CultureInfo.InvariantCulture); } if (dr[Constants.FROM_SECONDARY_STRATUM_ID_COLUMN_NAME] != DBNull.Value) { FromSecondaryStratumId = Convert.ToInt32(dr[Constants.FROM_SECONDARY_STRATUM_ID_COLUMN_NAME], CultureInfo.InvariantCulture); } if (dr[Constants.FROM_TERTIARY_STRATUM_ID_COLUMN_NAME] != DBNull.Value) { FromTertiaryStratumId = Convert.ToInt32(dr[Constants.FROM_TERTIARY_STRATUM_ID_COLUMN_NAME], CultureInfo.InvariantCulture); } if (dr[Constants.FROM_STATECLASS_ID_COLUMN_NAME] != DBNull.Value) { FromStateClassId = Convert.ToInt32(dr[Constants.FROM_STATECLASS_ID_COLUMN_NAME], CultureInfo.InvariantCulture); } if (dr[Constants.FROM_MIN_AGE_COLUMN_NAME] != DBNull.Value) { FromMinimumAge = Convert.ToInt32(dr[Constants.FROM_MIN_AGE_COLUMN_NAME], CultureInfo.InvariantCulture); } if (dr[Constants.FROM_STOCK_TYPE_ID_COLUMN_NAME] != DBNull.Value) { FromStockTypeId = Convert.ToInt32(dr[Constants.FROM_STOCK_TYPE_ID_COLUMN_NAME], CultureInfo.InvariantCulture); } if (dr[Constants.TO_STRATUM_ID_COLUMN_NAME] != DBNull.Value) { ToStratumId = Convert.ToInt32(dr[Constants.TO_STRATUM_ID_COLUMN_NAME], CultureInfo.InvariantCulture); } if (dr[Constants.TO_STATECLASS_ID_COLUMN_NAME] != DBNull.Value) { ToStateClassId = Convert.ToInt32(dr[Constants.TO_STATECLASS_ID_COLUMN_NAME], CultureInfo.InvariantCulture); } if (dr[Constants.TO_MIN_AGE_COLUMN_NAME] != DBNull.Value) { ToMinimumAge = Convert.ToInt32(dr[Constants.TO_MIN_AGE_COLUMN_NAME], CultureInfo.InvariantCulture); } if (dr[Constants.TO_STOCK_TYPE_ID_COLUMN_NAME] != DBNull.Value) { ToStockTypeId = Convert.ToInt32(dr[Constants.TO_STOCK_TYPE_ID_COLUMN_NAME], CultureInfo.InvariantCulture); } if (dr[Constants.TRANSITION_GROUP_ID_COLUMN_NAME] != DBNull.Value) { TransitionGroupId = Convert.ToInt32(dr[Constants.TRANSITION_GROUP_ID_COLUMN_NAME], CultureInfo.InvariantCulture); } else { TransitionGroupId = 0; } if (dr[Constants.STATE_ATTRIBUTE_TYPE_ID_COLUMN_NAME] != DBNull.Value) { StateAttributeTypeId = Convert.ToInt32(dr[Constants.STATE_ATTRIBUTE_TYPE_ID_COLUMN_NAME], CultureInfo.InvariantCulture); } FlowTypeId = Convert.ToInt32(dr[Constants.FLOW_TYPE_ID_COLUMN_NAME], CultureInfo.InvariantCulture); if (dr[Constants.TARGET_TYPE] != DBNull.Value) { TargetType = Convert.ToInt32(dr[Constants.TARGET_TYPE], CultureInfo.InvariantCulture); } Multiplier = Convert.ToDouble(dr[Constants.MULTIPLIER_COLUMN_NAME], CultureInfo.InvariantCulture); if (dr[Constants.TRANSFER_TO_STRATUM_ID_COLUMN_NAME] != DBNull.Value) { TransferToStratumId = Convert.ToInt32(dr[Constants.TRANSFER_TO_STRATUM_ID_COLUMN_NAME], CultureInfo.InvariantCulture); } if (dr[Constants.TRANSFER_TO_SECONDARY_STRATUM_ID_COLUMN_NAME] != DBNull.Value) { TransferToSecondaryStratumId = Convert.ToInt32(dr[Constants.TRANSFER_TO_SECONDARY_STRATUM_ID_COLUMN_NAME], CultureInfo.InvariantCulture); } if (dr[Constants.TRANSFER_TO_TERTIARY_STRATUM_ID_COLUMN_NAME] != DBNull.Value) { TransferToTertiaryStratumId = Convert.ToInt32(dr[Constants.TRANSFER_TO_TERTIARY_STRATUM_ID_COLUMN_NAME], CultureInfo.InvariantCulture); } if (dr[Constants.TRANSFER_TO_STATECLASS_ID_COLUMN_NAME] != DBNull.Value) { TransferToStateClassId = Convert.ToInt32(dr[Constants.TRANSFER_TO_STATECLASS_ID_COLUMN_NAME], CultureInfo.InvariantCulture); } if (dr[Constants.TRANSFER_TO_MIN_AGE_COLUMN_NAME] != DBNull.Value) { TransferToMinimumAge = Convert.ToInt32(dr[Constants.TRANSFER_TO_MIN_AGE_COLUMN_NAME], CultureInfo.InvariantCulture); } FlowPathway p = new FlowPathway( Iteration, Timestep, FromStratumId, FromSecondaryStratumId, FromTertiaryStratumId, FromStateClassId, FromMinimumAge, FromStockTypeId, ToStratumId, ToStateClassId, ToMinimumAge, ToStockTypeId, TransitionGroupId, StateAttributeTypeId, FlowTypeId, TargetType, Multiplier, TransferToStratumId, TransferToSecondaryStratumId, TransferToTertiaryStratumId, TransferToStateClassId, TransferToMinimumAge); return(p); }