Ejemplo n.º 1
0
        /// <summary>
        /// Part of the IFlowHandler interface. Called when the PipeLineValue is raised.
        /// Updates all the values of the connected pipelines.
        /// </summary>
        public void AdjustPipelineValues()
        {
            if (OutcomePipeline == null)
            {
                return;
            }
            double upperFlow = 0;
            double lowerFlow = 0;

            if (this.UpperIncomePipeline != null)
            {
                upperFlow = this.UpperIncomePipeline.CurrentFlow;
            }
            if (this.LowerIncomePipeline != null)
            {
                lowerFlow = this.LowerIncomePipeline.CurrentFlow;
            }
            this.OutcomePipeline.ChangeCurrentFlow(upperFlow + lowerFlow);
            IFlowHandler outcomeElement = OutcomePipeline.EndComponent as IFlowHandler;

            if (outcomeElement != null && OutcomePipeline.EndComponent != this)
            {
                outcomeElement.AdjustPipelineValues();
            }
        }
        /// <summary>
        /// Changes the max flow of the pipeline if it is bigger than the current flow.
        /// </summary>
        /// <param name="newMaxFlow">The new value for the max flow.</param>
        public void ChangeMaxFlow(double newMaxFlow)
        {
            if (newMaxFlow >= CurrentFlow)
            {
                this.MaxFlow = newMaxFlow;
            }
            Pump p = StartComponent as Pump;

            if (p != null)
            {
                this.ChangeCurrentFlow(p.Flow);
            }
            IFlowHandler flowHandlerStart = StartComponent as IFlowHandler;

            if (flowHandlerStart != null)
            {
                flowHandlerStart.AdjustPipelineValues();
            }
            IFlowHandler flowHandlerEnd = EndComponent as IFlowHandler;

            if (flowHandlerEnd != null)
            {
                flowHandlerEnd.AdjustPipelineValues();
            }
        }
 /// <summary>
 /// Part of the IFlowHandler interface. Called when the PipeLineValue is raised.
 /// Updates all the values of the connected pipelines.
 /// </summary>
 public void AdjustPipelineValues()
 {
     if (this.UpperOutcomePipeline != null)
     {
         double currentPercentage = ((double)UpperOutComePercentage) / 100;
         double newFlow           = 0;
         if (IncomePipeline != null)
         {
             newFlow = IncomePipeline.CurrentFlow * currentPercentage;
         }
         this.UpperOutcomePipeline.ChangeCurrentFlow(newFlow);
         IFlowHandler flowHandler = UpperOutcomePipeline.EndComponent as IFlowHandler;
         if (flowHandler != null && UpperOutcomePipeline.EndComponent != this)
         {
             flowHandler.AdjustPipelineValues();
         }
     }
     if (this.LowerOutcomePipeline != null)
     {
         double currentPercentage = ((double)LowerOutComePercentage) / 100;
         double newFlow           = 0;
         if (IncomePipeline != null)
         {
             newFlow = IncomePipeline.CurrentFlow * currentPercentage;
         }
         this.LowerOutcomePipeline.ChangeCurrentFlow(newFlow);
         IFlowHandler flowHandler = LowerOutcomePipeline.EndComponent as IFlowHandler;
         if (flowHandler != null && LowerOutcomePipeline.EndComponent != this)
         {
             flowHandler.AdjustPipelineValues();
         }
     }
 }
 /// <summary>
 /// Sets the flow of the pump if it does not exceed its capacity.
 /// </summary>
 /// <param name="max">The capacity of the pump.</param>
 /// <param name="current">The current flow of the pump.</param>
 public void SetFlow(double max, double current)
 {
     if (current <= max)
     {
         this.Flow     = current;
         this.Capacity = max;
         if (OutcomePipeline != null)
         {
             this.OutcomePipeline.ChangeCurrentFlow(current);
             IFlowHandler flowHandler = OutcomePipeline.EndComponent as IFlowHandler;
             if (flowHandler != null)
             {
                 flowHandler.AdjustPipelineValues();
             }
         }
     }
 }