Пример #1
0
 public ConnectionsEditor(ISimulationObject selectedobject, DynamicLayout layout)
 {
     SimObject = selectedobject;
     container = new TableLayout();
     Initialize();
     layout.Add(container);
 }
Пример #2
0
        public PipeHydraulicProfile(ISimulationObject selectedobject, DynamicLayout layout)
        {
            SimObject = selectedobject;
            container = layout;

            Initialize();
        }
Пример #3
0
 public void CalculateFlowsheet(IFlowsheet flowsheet, ISimulationObject sender)
 {
     GlobalSettings.Settings.SolverBreakOnException   = true;
     GlobalSettings.Settings.EnableGPUProcessing      = false;
     GlobalSettings.Settings.EnableParallelProcessing = true;
     Console.WriteLine("Solving Flowsheet, please wait...");
     fm.FlowsheetObject.SolveFlowsheet2();
 }
Пример #4
0
        public PipeThermalProfile(ISimulationObject obj, ThermalEditorDefinitions definitions, DynamicLayout layout)
        {
            SimObject    = obj;
            thermalprops = definitions;
            container    = layout;

            Initialize();
        }
Пример #5
0
 public ObjectEditorContainer(ISimulationObject sobj) : base()
 {
     obj        = sobj;
     Tag        = obj.Name;
     this.Width = 300;
     Init();
     SelectedIndexChanged += (sender, e) => { if (loaded)
                                              {
                                                  SelectedPanel = SelectedIndex;
                                              }
     };
 }
        public PanelForm(ISimulationObject aSimObject, string aPanleName, string aText)
        {
            mSimObject = aSimObject;
            mPanelName = aPanleName;

            InitializeComponent();

            Text = aText;
            Point lPoint = Cursor.Position;

            SetDesktopLocation(lPoint.X - Width / 2, lPoint.Y - Height / 2);
        }
Пример #7
0
        public static void Populate(ISimulationObject obj, DynamicLayout container)
        {
            var su = obj.GetFlowsheet().FlowsheetOptions.SelectedUnitSystem;
            var nf = obj.GetFlowsheet().FlowsheetOptions.NumberFormat;

            var recycle = (Recycle)obj;

            s.CreateAndAddLabelRow(container, "Object Details");

            s.CreateAndAddTwoLabelsRow(container, "Status", obj.GraphicObject.Active ? "Active" : "Inactive");

            s.CreateAndAddStringEditorRow(container, "Name", obj.GraphicObject.Tag, (TextBox arg3, EventArgs ev) =>
            {
                obj.GraphicObject.Tag = arg3.Text;
            });

            container.CreateAndAddLabelRow("Convergence Control");
            container.CreateAndAddCheckBoxRow("Converge using global solver",
                                              recycle.AccelerationMethod == Interfaces.Enums.AccelMethod.GlobalBroyden,
                                              (sender, e) => { if (sender.Checked.GetValueOrDefault())
                                                               {
                                                                   recycle.AccelerationMethod = Interfaces.Enums.AccelMethod.GlobalBroyden;
                                                               }
                                                               else
                                                               {
                                                                   recycle.AccelerationMethod = Interfaces.Enums.AccelMethod.None;
                                                               } });
            container.CreateAndAddLabelRow("Convergence Tolerances");
            container.CreateAndAddTextBoxRow(nf, "Mass Flow", cv.ConvertFromSI(su.massflow, recycle.ConvergenceParameters.VazaoMassica),
                                             (sender, e) => {
                if (sender.Text.IsValidDouble())
                {
                    recycle.ConvergenceParameters.VazaoMassica = cv.ConvertToSI(su.massflow, sender.Text.ToDoubleFromCurrent());
                }
            });
            container.CreateAndAddTextBoxRow(nf, "Temperature", cv.ConvertFromSI(su.deltaT, recycle.ConvergenceParameters.Temperatura),
                                             (sender, e) =>
            {
                if (sender.Text.IsValidDouble())
                {
                    recycle.ConvergenceParameters.Temperatura = cv.ConvertToSI(su.deltaT, sender.Text.ToDoubleFromCurrent());
                }
            });
            container.CreateAndAddTextBoxRow(nf, "Pressure", cv.ConvertFromSI(su.deltaP, recycle.ConvergenceParameters.Pressao),
                                             (sender, e) =>
            {
                if (sender.Text.IsValidDouble())
                {
                    recycle.ConvergenceParameters.Pressao = cv.ConvertToSI(su.deltaP, sender.Text.ToDoubleFromCurrent());
                }
            });
        }
Пример #8
0
 public void CalculateFlowsheet(IFlowsheet flowsheet, ISimulationObject sender)
 {
     GlobalSettings.Settings.SolverBreakOnException   = true;
     GlobalSettings.Settings.SolverMode               = 0;
     GlobalSettings.Settings.SolverTimeoutSeconds     = 120;
     GlobalSettings.Settings.EnableGPUProcessing      = false;
     GlobalSettings.Settings.EnableParallelProcessing = true;
     if ((sender != null))
     {
         FlowsheetSolver.FlowsheetSolver.CalculateObject(flowsheet, sender.Name);
     }
     else
     {
         FlowsheetSolver.FlowsheetSolver.SolveFlowsheet(flowsheet, GlobalSettings.Settings.SolverMode);
     }
 }
Пример #9
0
 public void CalculateFlowsheet(IFlowsheet flowsheet, ISimulationObject sender)
 {
     GlobalSettings.Settings.CalculatorActivated      = true;
     GlobalSettings.Settings.SolverBreakOnException   = true;
     GlobalSettings.Settings.SolverMode               = 0;
     GlobalSettings.Settings.SolverTimeoutSeconds     = 120;
     GlobalSettings.Settings.EnableGPUProcessing      = false;
     GlobalSettings.Settings.EnableParallelProcessing = true;
     Console.WriteLine("Solving Flowsheet, please wait...");
     if ((sender != null))
     {
         FlowsheetSolver.FlowsheetSolver.CalculateObject(flowsheet, sender.Name);
     }
     else
     {
         FlowsheetSolver.FlowsheetSolver.SolveFlowsheet(flowsheet, GlobalSettings.Settings.SolverMode);
     }
 }
Пример #10
0
 public AbsorptionColumnEditor(ISimulationObject selectedobject, DynamicLayout layout)
 {
     column    = (AbsorptionColumn)selectedobject;
     container = layout;
     Initialize();
 }
Пример #11
0
        public void SolveFlowsheet(bool wait, ISimulationObject gobj = null)
        {
            var surface = ((DWSIM.Drawing.SkiaSharp.GraphicsSurface) this.GetSurface());

            if (PropertyPackages.Count == 0)
            {
                ShowMessage("Please select a Property Package before solving the flowsheet.", IFlowsheet.MessageType.GeneralError);
                return;
            }

            if (SelectedCompounds.Count == 0)
            {
                ShowMessage("Please select a Compound before solving the flowsheet.", IFlowsheet.MessageType.GeneralError);
                return;
            }

            GlobalSettings.Settings.CalculatorActivated    = true;
            GlobalSettings.Settings.SolverMode             = 1;
            GlobalSettings.Settings.SolverBreakOnException = true;

            Application.Instance.AsyncInvoke(() =>
            {
                solvform = new Forms.SolvingFlowsheet();
                solvform.lblMessage.Text = "Solving flowsheet model, please wait...";
                solvform.btnAbort.Click += (sender, e) =>
                {
                    Application.Instance.AsyncInvoke(() =>
                    {
                        surface.BackgroundColor = SkiaSharp.SKColors.White;
                        FlowsheetForm.Enabled   = true;
                        FlowsheetControl.Invalidate();
                        solvform.Close();
                    });
                    GlobalSettings.Settings.CalculatorStopRequested = true;
                    if (GlobalSettings.Settings.TaskCancellationTokenSource != null)
                    {
                        try
                        {
                            GlobalSettings.Settings.TaskCancellationTokenSource.Cancel();
                        }
                        catch (Exception) { }
                    }
                };
            });

            Task st = new Task(() =>
            {
                if (!eventattached)
                {
                    eventattached = true;
                    FlowsheetSolver.FlowsheetSolver.CalculatingObject += (objinfo) =>
                    {
                        Application.Instance.AsyncInvoke(() =>
                        {
                            if (solvform != null && !optimizing)
                            {
                                solvform.lblMessage.Text = "Solving flowsheet model, please wait...\nCurrent object: " + objinfo.Tag;
                            }
                        });
                    };
                }
                RequestCalculation(gobj);
            });

            st.ContinueWith((t) =>
            {
                Application.Instance.AsyncInvoke(() =>
                {
                    surface.BackgroundColor = SkiaSharp.SKColors.White;
                    FlowsheetForm.Enabled   = true;
                    FlowsheetControl.Invalidate();
                    if (solvform != null)
                    {
                        solvform.Close();
                    }
                    solvform = null;
                });
                GlobalSettings.Settings.CalculatorStopRequested     = false;
                GlobalSettings.Settings.CalculatorBusy              = false;
                GlobalSettings.Settings.TaskCancellationTokenSource = new System.Threading.CancellationTokenSource();

                if (FinishedSolving != null)
                {
                    FinishedSolving.Invoke();
                }
            });


            if (wait)
            {
                try
                {
                    st.Start();
                    st.Wait();
                }
                catch (AggregateException aex)
                {
                    foreach (Exception ex2 in aex.InnerExceptions)
                    {
                        if (!SupressMessages)
                        {
                            ShowMessage(ex2.ToString(), IFlowsheet.MessageType.GeneralError);
                        }
                    }
                    GlobalSettings.Settings.CalculatorBusy = false;
                    GlobalSettings.Settings.TaskCancellationTokenSource = new System.Threading.CancellationTokenSource();
                }
                catch (Exception ex)
                {
                    if (!SupressMessages)
                    {
                        ShowMessage(ex.ToString(), IFlowsheet.MessageType.GeneralError);
                    }
                    GlobalSettings.Settings.CalculatorBusy = false;
                    GlobalSettings.Settings.TaskCancellationTokenSource = new System.Threading.CancellationTokenSource();
                }
            }
            else
            {
                st.Start();

                Application.Instance.AsyncInvoke(() =>
                {
                    surface.BackgroundColor = SkiaSharp.SKColors.LightGray;
                    FlowsheetForm.Enabled   = false;
                    FlowsheetControl.Invalidate();
                    FlowsheetForm.Invalidate();
                    solvform.ShowModalAsync(FlowsheetControl);
                });
            }
        }
Пример #12
0
 public ConnectionsEditor(ISimulationObject selectedobject, DynamicLayout layout)
 {
     SimObject = selectedobject;
     container = layout;
     Initialize();
 }
Пример #13
0
        public void SolveFlowsheet(bool wait, ISimulationObject gobj = null, bool changecalcorder = false)
        {
            if (PropertyPackages.Count == 0)
            {
                ShowMessage("Please select a Property Package before solving the flowsheet.", IFlowsheet.MessageType.GeneralError);
                return;
            }

            if (SelectedCompounds.Count == 0)
            {
                ShowMessage("Please select a Compound before solving the flowsheet.", IFlowsheet.MessageType.GeneralError);
                return;
            }

            GlobalSettings.Settings.CalculatorActivated    = true;
            GlobalSettings.Settings.SolverMode             = 1;
            GlobalSettings.Settings.SolverBreakOnException = true;

            Task st = new Task(() =>
            {
                RequestCalculation(gobj, changecalcorder);
                Task.Delay(1000).Wait();
            });

            st.ContinueWith((t) =>
            {
                GlobalSettings.Settings.CalculatorStopRequested     = false;
                GlobalSettings.Settings.CalculatorBusy              = false;
                GlobalSettings.Settings.TaskCancellationTokenSource = new System.Threading.CancellationTokenSource();

                if (FinishedSolving != null)
                {
                    FinishedSolving.Invoke();
                }
            });


            if (wait)
            {
                try
                {
                    st.Start(TaskScheduler.Default);
                    st.Wait();
                }
                catch (AggregateException aex)
                {
                    foreach (Exception ex2 in aex.InnerExceptions)
                    {
                        if (!SupressMessages)
                        {
                            ShowMessage(ex2.ToString(), IFlowsheet.MessageType.GeneralError);
                        }
                    }
                    GlobalSettings.Settings.CalculatorBusy = false;
                    GlobalSettings.Settings.TaskCancellationTokenSource = new System.Threading.CancellationTokenSource();
                }
                catch (Exception ex)
                {
                    if (!SupressMessages)
                    {
                        ShowMessage(ex.ToString(), IFlowsheet.MessageType.GeneralError);
                    }
                    GlobalSettings.Settings.CalculatorBusy = false;
                    GlobalSettings.Settings.TaskCancellationTokenSource = new System.Threading.CancellationTokenSource();
                }
            }
            else
            {
                st.Start(TaskScheduler.Default);
            }
        }
Пример #14
0
 public static int GetCellIndex(ISimulationObject simulationObject, int columns)
 {
     var location = simulationObject.Location;
     var cellIndex = columns * location.Y + location.X;
     return cellIndex;
 }
Пример #15
0
        void CreateAndAddRow(string direction, IConnectionPoint connector, IEnumerable <String> options)
        {
            DynamicLayout cont1 = new DynamicLayout();

            var cbConnection = s.CreateAndAddEditableDropDownRow(cont1, connector.ConnectorName, options.ToList(), 0, null);

            if (connector.IsAttached)
            {
                if (connector.AttachedConnector != null)
                {
                    if (direction == "In" && (connector.Type == ConType.ConIn | connector.Type == ConType.ConEn))
                    {
                        if (connector.IsEnergyConnector)
                        {
                            if (options.Contains(connector.AttachedConnector.AttachedTo.Tag))
                            {
                                cbConnection.SelectedIndex = Array.IndexOf(options.ToArray(), connector.AttachedConnector.AttachedTo.Tag);
                            }
                        }
                        else
                        {
                            if (options.Contains(connector.AttachedConnector.AttachedFrom.Tag))
                            {
                                cbConnection.SelectedIndex = Array.IndexOf(options.ToArray(), connector.AttachedConnector.AttachedFrom.Tag);
                            }
                        }
                    }
                    else if (connector.Type == ConType.ConOut | connector.Type == ConType.ConEn)
                    {
                        if (options.Contains(connector.AttachedConnector.AttachedTo.Tag))
                        {
                            cbConnection.SelectedIndex = Array.IndexOf(options.ToArray(), connector.AttachedConnector.AttachedTo.Tag);
                        }
                    }
                }
            }
            else
            {
                cbConnection.SelectedIndex = 0;
            }

            cbConnection.Tag = false;

            Action <object, EventArgs> schangedaction = (sender, e) =>
            {
                if (cbConnection.SelectedIndex == -1)
                {
                    return;
                }

                var fgui = (Interfaces.IFlowsheet)SimObject.GetFlowsheet();

                if ((bool)cbConnection.Tag)
                {
                    var sel = options.ElementAt(cbConnection.SelectedIndex);

                    var gobj      = SimObject.GraphicObject;
                    var flowsheet = SimObject.GetFlowsheet();

                    if (connector.IsAttached && sel == "")
                    {
                        if (direction == "In" && (connector.Type == ConType.ConIn | connector.Type == ConType.ConEn))
                        {
                            try
                            {
                                var objfrom = connector.AttachedConnector.AttachedFrom;
                                flowsheet.DisconnectObjects(objfrom, gobj);
                                flowsheet.ShowMessage(String.Format("Disconnected {0} from {1}.", objfrom.Tag, gobj.Tag), IFlowsheet.MessageType.Information);
                            }
                            catch (Exception ex)
                            {
                                flowsheet.ShowMessage(ex.Message.ToString(), IFlowsheet.MessageType.GeneralError);
                            }
                            fgui.UpdateInterface();
                            fgui.UpdateOpenEditForms();
                            return;
                        }
                        else if (connector.Type == ConType.ConOut | connector.Type == ConType.ConEn)
                        {
                            try
                            {
                                var objto = connector.AttachedConnector.AttachedTo;
                                flowsheet.DisconnectObjects(gobj, objto);
                                flowsheet.ShowMessage(String.Format("Disconnected {0} from {1}.", gobj.Tag, objto.Tag), IFlowsheet.MessageType.Information);
                            }
                            catch (Exception ex)
                            {
                                flowsheet.ShowMessage(ex.Message.ToString(), IFlowsheet.MessageType.GeneralError);;
                            }
                            fgui.UpdateInterface();
                            fgui.UpdateOpenEditForms();
                            return;
                        }
                    }

                    if (sel != "")
                    {
                        var gobj2 = flowsheet.GetFlowsheetSimulationObject(sel).GraphicObject;

                        if (direction == "In" && (connector.Type == ConType.ConIn | connector.Type == ConType.ConEn))
                        {
                            if (connector.IsAttached)
                            {
                                try
                                {
                                    var objfrom = connector.AttachedConnector.AttachedFrom;
                                    flowsheet.DisconnectObjects(objfrom, gobj);
                                    flowsheet.ShowMessage(String.Format("Disconnected {0} from {1}.", objfrom.Tag, gobj.Tag), IFlowsheet.MessageType.Information);
                                }
                                catch (Exception ex)
                                {
                                    flowsheet.ShowMessage(ex.Message.ToString(), IFlowsheet.MessageType.GeneralError);
                                }
                            }
                            if (connector.IsEnergyConnector)
                            {
                                if (gobj2.InputConnectors[0].IsAttached)
                                {
                                    flowsheet.ShowMessage("Selected object already connected to another object.", IFlowsheet.MessageType.GeneralError);
                                    cbConnection.SelectedIndex = 0;
                                    return;
                                }
                                try
                                {
                                    flowsheet.ConnectObjects(gobj, gobj2, 0, 0);
                                    flowsheet.ShowMessage(String.Format("Connected {0} to {1}.", gobj.Tag, gobj2.Tag), IFlowsheet.MessageType.Information);
                                }
                                catch (Exception ex)
                                {
                                    flowsheet.ShowMessage(ex.Message.ToString(), IFlowsheet.MessageType.GeneralError);
                                }
                            }
                            else
                            {
                                if (gobj2.OutputConnectors[0].IsAttached)
                                {
                                    flowsheet.ShowMessage("Selected object already connected to another object.", IFlowsheet.MessageType.GeneralError);
                                    cbConnection.SelectedIndex = 0;
                                    return;
                                }
                                try
                                {
                                    flowsheet.ConnectObjects(gobj2, gobj, 0, gobj.InputConnectors.IndexOf(connector));
                                    flowsheet.ShowMessage(String.Format("Connected {0} to {1}.", gobj2.Tag, gobj.Tag), IFlowsheet.MessageType.Information);
                                }
                                catch (Exception ex)
                                {
                                    flowsheet.ShowMessage(ex.Message.ToString(), IFlowsheet.MessageType.GeneralError);
                                }
                            }
                        }
                        else if (connector.Type == ConType.ConOut | connector.Type == ConType.ConEn)
                        {
                            if (gobj2.InputConnectors[0].IsAttached)
                            {
                                flowsheet.ShowMessage("Selected object already connected to another object.", IFlowsheet.MessageType.GeneralError);
                                cbConnection.SelectedIndex = 0;
                                return;
                            }
                            try
                            {
                                if (connector.IsAttached)
                                {
                                    var objto = connector.AttachedConnector.AttachedTo;
                                    flowsheet.DisconnectObjects(gobj, objto);
                                    flowsheet.ShowMessage(String.Format("Disconnected {0} from {1}.", gobj.Tag, objto.Tag), IFlowsheet.MessageType.Information);
                                }
                                flowsheet.ConnectObjects(gobj, gobj2, gobj.OutputConnectors.IndexOf(connector), 0);
                                flowsheet.ShowMessage(String.Format("Connected {0} to {1}.", gobj.Tag, gobj2.Tag), IFlowsheet.MessageType.Information);
                            }
                            catch (Exception ex)
                            {
                                flowsheet.ShowMessage(ex.Message.ToString(), IFlowsheet.MessageType.GeneralError);
                            }
                        }

                        fgui.UpdateInterface();
                        fgui.UpdateOpenEditForms();
                    }
                }
            };

            cbConnection.KeyUp += (sender, e) =>
            {
                if (e.Key == Keys.Enter)
                {
                    var items = cbConnection.Items.Select((x) => x.Text).ToList();
                    if (!items.Contains(cbConnection.Text))
                    {
                        var gobj = SimObject.GraphicObject;
                        var flowsheet = SimObject.GetFlowsheet();
                        int posx, posy;
                        if (direction == "In")
                        {
                            posx = gobj.X - 100;
                            posy = gobj.Y + gobj.Height / 2;
                        }
                        else
                        {
                            posx = gobj.X + gobj.Width + 100;
                            posy = gobj.Y + gobj.Height / 2;
                        }
                        ISimulationObject stream = flowsheet.GetFlowsheetSimulationObject(cbConnection.Text);
                        if (stream == null)
                        {
                            if (connector.Type == ConType.ConEn)
                            {
                                stream = flowsheet.AddObject(ObjectType.EnergyStream, posx, posy, cbConnection.Text);
                            }
                            else
                            {
                                stream = flowsheet.AddObject(ObjectType.MaterialStream, posx, posy, cbConnection.Text);
                            }
                        }
                        ((Drawing.SkiaSharp.GraphicObjects.GraphicObject)stream.GraphicObject).CreateConnectors(0, 0);
                        if (direction == "In")
                        {
                            try
                            {
                                if (connector.IsAttached)
                                {
                                    var objfrom = connector.AttachedConnector.AttachedFrom;
                                    flowsheet.DisconnectObjects(objfrom, gobj);
                                    flowsheet.ShowMessage(String.Format("Disconnected {0} from {1}.", objfrom.Tag, gobj.Tag), IFlowsheet.MessageType.Information);
                                }
                                flowsheet.ConnectObjects(stream.GraphicObject, gobj, 0, gobj.InputConnectors.IndexOf(connector));
                                flowsheet.ShowMessage(String.Format("Connected {0} to {1}.", stream.GraphicObject.Tag, gobj.Tag), IFlowsheet.MessageType.Information);
                                cbConnection.Items.Add(cbConnection.Text);
                                var list = new List <string>(options);
                                list.Add(cbConnection.Text);
                                options = list;
                            }
                            catch (Exception ex)
                            {
                                flowsheet.ShowMessage(ex.Message.ToString(), IFlowsheet.MessageType.GeneralError);
                            }
                        }
                        else
                        {
                            try
                            {
                                if (connector.IsAttached)
                                {
                                    var objto = connector.AttachedConnector.AttachedTo;
                                    flowsheet.DisconnectObjects(gobj, objto);
                                    flowsheet.ShowMessage(String.Format("Disconnected {0} from {1}", gobj.Tag, objto.Tag), IFlowsheet.MessageType.Information);
                                }
                                if (connector.IsEnergyConnector)
                                {
                                    flowsheet.ConnectObjects(gobj, stream.GraphicObject, 0, 0);
                                }
                                else
                                {
                                    flowsheet.ConnectObjects(gobj, stream.GraphicObject, gobj.OutputConnectors.IndexOf(connector), 0);
                                }
                                flowsheet.ShowMessage(String.Format("Connected {0} to {1}.", gobj.Tag, stream.GraphicObject.Tag), IFlowsheet.MessageType.Information);
                                cbConnection.Items.Add(cbConnection.Text);
                                var list = new List <string>(options);
                                list.Add(cbConnection.Text);
                                options = list;
                            }
                            catch (Exception ex)
                            {
                                flowsheet.ShowMessage(ex.Message.ToString(), IFlowsheet.MessageType.GeneralError);
                            }
                        }
                    }
                    else
                    {
                        schangedaction.Invoke(cbConnection, e);
                    }
                }
            };

            cbConnection.SelectedValueChanged += (sender, e) => schangedaction.Invoke(sender, e);

            cbConnection.Tag = true;

            container.Rows.Add(new TableRow(cont1));

            return;
        }
Пример #16
0
        public static void Populate(ISimulationObject simobj, DynamicLayout container)
        {
            var su = simobj.GetFlowsheet().FlowsheetOptions.SelectedUnitSystem;
            var nf = simobj.GetFlowsheet().FlowsheetOptions.NumberFormat;

            var adjust = (Adjust)simobj;

            s.CreateAndAddLabelRow(container, "Object Details");

            s.CreateAndAddTwoLabelsRow(container, "Status", simobj.GraphicObject.Active ? "Active" : "Inactive");

            s.CreateAndAddStringEditorRow(container, "Name", simobj.GraphicObject.Tag, (TextBox arg3, EventArgs ev) =>
            {
                simobj.GraphicObject.Tag = arg3.Text;
            });

            var objlist = adjust.GetFlowsheet().SimulationObjects.Values.Select((x2) => x2.GraphicObject.Tag).ToList();

            objlist.Insert(0, "");
            List <string> proplist = new List <string>();

            s.CreateAndAddLabelRow(container, "Manipulated Object");

            DropDown spin1 = null, spin2 = null;

            spin1 = s.CreateAndAddDropDownRow(container, "Manipulated Object", objlist, 0, (sender, e) => {
                if (sender.SelectedIndex > 0)
                {
                    if (adjust.GetFlowsheet().SimulationObjects.ContainsKey(adjust.ManipulatedObjectData.ID))
                    {
                        var prevobj = adjust.GetFlowsheet().SimulationObjects[adjust.ManipulatedObjectData.ID];
                        prevobj.IsAdjustAttached = false;
                        prevobj.AttachedAdjustId = "";
                        prevobj.AdjustVarType    = AdjustVarType.None;
                    }

                    var obj = adjust.GetFlowsheet().GetFlowsheetSimulationObject(objlist[sender.SelectedIndex]);
                    adjust.ManipulatedObjectData.ID = obj.Name;

                    obj.IsAdjustAttached = true;
                    obj.AttachedAdjustId = adjust.Name;
                    obj.AdjustVarType    = AdjustVarType.Manipulated;

                    adjust.ManipulatedObject = (DWSIM.SharedClasses.UnitOperations.BaseClass)obj;
                    ((AdjustGraphic)adjust.GraphicObject).ConnectedToMv = (GraphicObject)obj.GraphicObject;

                    proplist = obj.GetProperties(PropertyType.WR).ToList();
                    proplist.Insert(0, "");

                    spin2.Items.Clear();
                    spin2.Items.AddRange(proplist.Select(x => new ListItem()
                    {
                        Text = adjust.GetFlowsheet().GetTranslatedString(x)
                    }).ToList());

                    if (adjust.ManipulatedObjectData.PropertyName != "" && proplist.Contains(adjust.ManipulatedObjectData.PropertyName))
                    {
                        spin2.SelectedIndex = (proplist.IndexOf(adjust.ManipulatedObjectData.PropertyName));
                    }
                }
                else
                {
                    spin2.Items.Clear();
                }
            });

            spin2 = s.CreateAndAddDropDownRow(container, "Manipulated Property", proplist, 0, (sender, e) => {
                if (sender.SelectedIndex > 0)
                {
                    adjust.ManipulatedObjectData.PropertyName = proplist[sender.SelectedIndex];
                }
            });

            if (adjust.ManipulatedObjectData.ID != "" && adjust.GetFlowsheet().SimulationObjects.ContainsKey(adjust.ManipulatedObjectData.ID))
            {
                spin1.SelectedIndex = (objlist.IndexOf(adjust.GetFlowsheet().SimulationObjects[adjust.ManipulatedObjectData.ID].GraphicObject.Tag));
            }

            List <string> proplist2 = new List <string>();

            s.CreateAndAddLabelRow(container, "Controlled Object");

            DropDown spin3 = null, spin4 = null;

            spin3 = s.CreateAndAddDropDownRow(container, "Controlled Object", objlist, 0, (sender, e) => {
                if (sender.SelectedIndex > 0)
                {
                    if (adjust.GetFlowsheet().SimulationObjects.ContainsKey(adjust.ControlledObjectData.ID))
                    {
                        var prevobj = adjust.GetFlowsheet().SimulationObjects[adjust.ControlledObjectData.ID];
                        prevobj.IsAdjustAttached = false;
                        prevobj.AttachedAdjustId = "";
                        prevobj.AdjustVarType    = AdjustVarType.None;
                    }

                    var obj = adjust.GetFlowsheet().GetFlowsheetSimulationObject(objlist[sender.SelectedIndex]);
                    adjust.ControlledObjectData.ID = obj.Name;

                    obj.IsAdjustAttached = true;
                    obj.AttachedAdjustId = adjust.Name;
                    obj.AdjustVarType    = AdjustVarType.Controlled;

                    adjust.ControlledObject = (DWSIM.SharedClasses.UnitOperations.BaseClass)adjust.GetFlowsheet().SimulationObjects[adjust.ControlledObjectData.ID];
                    ((AdjustGraphic)adjust.GraphicObject).ConnectedToCv = (GraphicObject)adjust.ControlledObject.GraphicObject;

                    proplist2 = adjust.GetFlowsheet().GetFlowsheetSimulationObject(objlist[sender.SelectedIndex]).GetProperties(PropertyType.ALL).ToList();
                    proplist2.Insert(0, "");

                    spin4.Items.Clear();
                    spin4.Items.AddRange(proplist2.Select(x => new ListItem()
                    {
                        Text = adjust.GetFlowsheet().GetTranslatedString(x)
                    }).ToList());

                    if (adjust.ControlledObjectData.PropertyName != "" && proplist2.Contains(adjust.ControlledObjectData.PropertyName))
                    {
                        spin4.SelectedIndex = (proplist2.IndexOf(adjust.ControlledObjectData.PropertyName));
                    }
                }
                else
                {
                    spin4.Items.Clear();
                }
            });

            Label txtval = null;

            spin4 = s.CreateAndAddDropDownRow(container, "Controlled Property", proplist2, 0, (sender, e) => {
                if (sender.SelectedIndex > 0)
                {
                    adjust.ControlledObjectData.PropertyName = proplist2[sender.SelectedIndex];
                    var obj     = adjust.GetFlowsheet().SimulationObjects[adjust.ControlledObjectData.ID];
                    var currval = Convert.ToDouble(obj.GetPropertyValue(proplist2[sender.SelectedIndex], su)).ToString(nf) + " " + obj.GetPropertyUnit(proplist2[sender.SelectedIndex], su);
                    txtval.Text = "Current Value: " + currval;
                }
            });

            txtval = s.CreateAndAddLabelRow(container, "Current Value: N/A");

            var txtvalue = s.CreateAndAddTextBoxRow(container, nf, "Target Value", 0.0f, (sender, e) =>
            {
                if (adjust.GetFlowsheet().SimulationObjects.ContainsKey(adjust.ControlledObjectData.ID))
                {
                    var obj = adjust.GetFlowsheet().SimulationObjects[adjust.ControlledObjectData.ID];
                    if (s.IsValidDouble(sender.Text))
                    {
                        adjust.AdjustValue = cv.ConvertToSI(obj.GetPropertyUnit(adjust.ControlledObjectData.PropertyName, su), Double.Parse(sender.Text));
                    }
                }
            });

            if (adjust.ControlledObjectData.ID != "" && adjust.GetFlowsheet().SimulationObjects.ContainsKey(adjust.ControlledObjectData.ID))
            {
                spin3.SelectedIndex = (objlist.IndexOf(adjust.GetFlowsheet().SimulationObjects[adjust.ControlledObjectData.ID].GraphicObject.Tag));
                var obj = adjust.GetFlowsheet().SimulationObjects[adjust.ControlledObjectData.ID];
                txtvalue.Text = cv.ConvertFromSI(obj.GetPropertyUnit(adjust.ControlledObjectData.PropertyName, su), adjust.AdjustValue).ToString(nf);
            }

            s.CreateAndAddCheckBoxRow(container, "Run with the Simultaneous Adjust Solver", adjust.SimultaneousAdjust, (sender, e) => adjust.SimultaneousAdjust = sender.Checked.GetValueOrDefault());
        }
Пример #17
0
        public static void Populate(ISimulationObject simobj, DynamicLayout container)
        {
            var su = simobj.GetFlowsheet().FlowsheetOptions.SelectedUnitSystem;
            var nf = simobj.GetFlowsheet().FlowsheetOptions.NumberFormat;

            var spec = (Spec)simobj;

            s.CreateAndAddLabelRow(container, "Object Details");

            s.CreateAndAddTwoLabelsRow(container, "Status", simobj.GraphicObject.Active ? "Active" : "Inactive");

            s.CreateAndAddStringEditorRow(container, "Name", simobj.GraphicObject.Tag, (TextBox arg3, EventArgs ev) =>
            {
                simobj.GraphicObject.Tag = arg3.Text;
            });

            var objlist = spec.GetFlowsheet().SimulationObjects.Values.Select((x2) => x2.GraphicObject.Tag).ToList();

            objlist.Insert(0, "");
            List <string> proplist = new List <string>();

            s.CreateAndAddLabelRow(container, "Source Object");

            DropDown spin1 = null, spin2 = null;
            Label    txtval1 = null, txtval2 = null;

            spin1 = s.CreateAndAddDropDownRow(container, "Source Object", objlist, 0, (sender, e) =>
            {
                if (sender.SelectedIndex > 0)
                {
                    if (spec.GetFlowsheet().SimulationObjects.ContainsKey(spec.SourceObjectData.ID))
                    {
                        var prevobj            = spec.GetFlowsheet().SimulationObjects[spec.SourceObjectData.ID];
                        prevobj.IsSpecAttached = false;
                        prevobj.AttachedSpecId = "";
                        prevobj.SpecVarType    = SpecVarType.None;
                    }

                    var obj = spec.GetFlowsheet().GetFlowsheetSimulationObject(objlist[sender.SelectedIndex]);
                    spec.SourceObjectData.ID = obj.Name;

                    obj.IsSpecAttached = true;
                    obj.AttachedSpecId = spec.Name;
                    obj.SpecVarType    = SpecVarType.Source;

                    spec.SourceObject = (DWSIM.SharedClasses.UnitOperations.BaseClass)obj;
                    ((SpecGraphic)spec.GraphicObject).ConnectedToSv = (GraphicObject)obj.GraphicObject;

                    proplist = obj.GetProperties(PropertyType.ALL).ToList();
                    proplist.Insert(0, "");

                    spin2.Items.Clear();
                    spin2.Items.AddRange(proplist.Select(x => new ListItem()
                    {
                        Text = spec.GetFlowsheet().GetTranslatedString(x)
                    }).ToList());

                    if (spec.SourceObjectData.PropertyName != "" && proplist.Contains(spec.SourceObjectData.PropertyName))
                    {
                        spin2.SelectedIndex = (proplist.IndexOf(spec.SourceObjectData.PropertyName));
                    }
                }
                else
                {
                    spin2.Items.Clear();
                }
            });

            spin2 = s.CreateAndAddDropDownRow(container, "Source Property", proplist, 0, (sender, e) =>
            {
                if (sender.SelectedIndex > 0)
                {
                    spec.SourceObjectData.PropertyName = proplist[sender.SelectedIndex];
                    var obj      = spec.GetFlowsheet().SimulationObjects[spec.SourceObjectData.ID];
                    var currval  = Convert.ToDouble(obj.GetPropertyValue(proplist[sender.SelectedIndex], su)).ToString(nf) + " " + obj.GetPropertyUnit(proplist[sender.SelectedIndex], su);
                    txtval1.Text = "Current Value: " + currval;
                }
            });

            txtval1 = container.CreateAndAddLabelRow2("Current Value: N/A");

            if (spec.SourceObjectData.ID != "" && spec.GetFlowsheet().SimulationObjects.ContainsKey(spec.SourceObjectData.ID))
            {
                spin1.SelectedIndex = (objlist.IndexOf(spec.GetFlowsheet().SimulationObjects[spec.SourceObjectData.ID].GraphicObject.Tag));
            }

            List <string> proplist2 = new List <string>();

            s.CreateAndAddLabelRow(container, "Target Object");

            DropDown spin3 = null, spin4 = null;

            spin3 = s.CreateAndAddDropDownRow(container, "Target Object", objlist, 0, (sender, e) =>
            {
                if (sender.SelectedIndex > 0)
                {
                    if (spec.GetFlowsheet().SimulationObjects.ContainsKey(spec.TargetObjectData.ID))
                    {
                        var prevobj            = spec.GetFlowsheet().SimulationObjects[spec.TargetObjectData.ID];
                        prevobj.IsSpecAttached = false;
                        prevobj.AttachedSpecId = "";
                        prevobj.SpecVarType    = SpecVarType.None;
                    }

                    var obj = spec.GetFlowsheet().GetFlowsheetSimulationObject(objlist[sender.SelectedIndex]);
                    spec.TargetObjectData.ID = obj.Name;

                    obj.IsSpecAttached = true;
                    obj.AttachedSpecId = spec.Name;
                    obj.SpecVarType    = SpecVarType.Target;

                    spec.TargetObject = (DWSIM.SharedClasses.UnitOperations.BaseClass)spec.GetFlowsheet().SimulationObjects[spec.TargetObjectData.ID];
                    ((SpecGraphic)spec.GraphicObject).ConnectedToTv = (GraphicObject)spec.TargetObject.GraphicObject;

                    proplist2 = spec.GetFlowsheet().GetFlowsheetSimulationObject(objlist[sender.SelectedIndex]).GetProperties(PropertyType.WR).ToList();
                    proplist2.Insert(0, "");

                    spin4.Items.Clear();
                    spin4.Items.AddRange(proplist2.Select(x => new ListItem()
                    {
                        Text = spec.GetFlowsheet().GetTranslatedString(x)
                    }).ToList());

                    if (spec.TargetObjectData.PropertyName != "" && proplist2.Contains(spec.TargetObjectData.PropertyName))
                    {
                        spin4.SelectedIndex = (proplist2.IndexOf(spec.TargetObjectData.PropertyName));
                    }
                }
                else
                {
                    spin4.Items.Clear();
                }
            });


            spin4 = s.CreateAndAddDropDownRow(container, "Target Property", proplist2, 0, (sender, e) =>
            {
                if (sender.SelectedIndex > 0)
                {
                    spec.TargetObjectData.PropertyName = proplist2[sender.SelectedIndex];
                    var obj      = spec.GetFlowsheet().SimulationObjects[spec.TargetObjectData.ID];
                    var currval  = Convert.ToDouble(obj.GetPropertyValue(proplist2[sender.SelectedIndex], su)).ToString(nf) + " " + obj.GetPropertyUnit(proplist2[sender.SelectedIndex], su);
                    txtval2.Text = "Current Value: " + currval;
                }
            });

            txtval2 = container.CreateAndAddLabelRow2("Current Value: N/A");

            if (spec.TargetObjectData.ID != "" && spec.GetFlowsheet().SimulationObjects.ContainsKey(spec.TargetObjectData.ID))
            {
                spin3.SelectedIndex = (objlist.IndexOf(spec.GetFlowsheet().SimulationObjects[spec.TargetObjectData.ID].GraphicObject.Tag));
            }

            container.CreateAndAddLabelRow("Expression");

            container.CreateAndAddStringEditorRow2("Y = f(X) = ", "enter a math expression using X as the only variable", spec.Expression, (sender, e) => spec.Expression = sender.Text);
        }
Пример #18
0
        public static void Populate(ISimulationObject simobj, DynamicLayout container)
        {
            var su = simobj.GetFlowsheet().FlowsheetOptions.SelectedUnitSystem;
            var nf = simobj.GetFlowsheet().FlowsheetOptions.NumberFormat;

            var adjust = (Adjust)simobj;

            s.CreateAndAddLabelRow(container, "Object Details");

            s.CreateAndAddTwoLabelsRow(container, "Status", simobj.GraphicObject.Active ? "Active" : "Inactive");

            s.CreateAndAddStringEditorRow(container, "Name", simobj.GraphicObject.Tag, (TextBox arg3, EventArgs ev) =>
            {
                simobj.GraphicObject.Tag = arg3.Text;
            });

            var objlist = adjust.GetFlowsheet().SimulationObjects.Values.Select((x2) => x2.GraphicObject.Tag).ToList();

            objlist.Insert(0, "");
            List <string> proplist = new List <string>();

            s.CreateAndAddLabelRow(container, "Manipulated Object");

            DropDown spin1 = null, spin2 = null;
            Label    lblMv = null, lblCv = null, lblRv = null;

            spin1 = s.CreateAndAddDropDownRow(container, "Manipulated Object", objlist, 0, (sender, e) =>
            {
                if (sender.SelectedIndex > 0)
                {
                    if (adjust.GetFlowsheet().SimulationObjects.ContainsKey(adjust.ManipulatedObjectData.ID))
                    {
                        var prevobj = adjust.GetFlowsheet().SimulationObjects[adjust.ManipulatedObjectData.ID];
                        prevobj.IsAdjustAttached = false;
                        prevobj.AttachedAdjustId = "";
                        prevobj.AdjustVarType    = AdjustVarType.None;
                    }

                    var obj = adjust.GetFlowsheet().GetFlowsheetSimulationObject(objlist[sender.SelectedIndex]);
                    adjust.ManipulatedObjectData.ID = obj.Name;

                    obj.IsAdjustAttached = true;
                    obj.AttachedAdjustId = adjust.Name;
                    obj.AdjustVarType    = AdjustVarType.Manipulated;

                    adjust.ManipulatedObject = (DWSIM.SharedClasses.UnitOperations.BaseClass)obj;
                    ((AdjustGraphic)adjust.GraphicObject).ConnectedToMv = (GraphicObject)obj.GraphicObject;

                    proplist = obj.GetProperties(PropertyType.WR).ToList();
                    proplist.Insert(0, "");

                    spin2.Items.Clear();
                    spin2.Items.AddRange(proplist.Select(x => new ListItem()
                    {
                        Text = adjust.GetFlowsheet().GetTranslatedString(x)
                    }).ToList());

                    if (adjust.ManipulatedObjectData.PropertyName != "" && proplist.Contains(adjust.ManipulatedObjectData.PropertyName))
                    {
                        spin2.SelectedIndex = (proplist.IndexOf(adjust.ManipulatedObjectData.PropertyName));
                    }
                }
                else
                {
                    spin2.Items.Clear();
                }
            });

            spin2 = s.CreateAndAddDropDownRow(container, "Manipulated Property", proplist, 0, (sender, e) =>
            {
                if (sender.SelectedIndex > 0)
                {
                    adjust.ManipulatedObjectData.PropertyName = proplist[sender.SelectedIndex];
                    var obj     = adjust.GetFlowsheet().SimulationObjects[adjust.ManipulatedObjectData.ID];
                    var currval = Convert.ToDouble(obj.GetPropertyValue(proplist[sender.SelectedIndex], su)).ToString(nf) + " " + obj.GetPropertyUnit(proplist[sender.SelectedIndex], su);
                    lblMv.Text  = "Current Value: " + currval;
                }
            });

            lblMv = s.CreateAndAddLabelRow2(container, "");

            List <string> proplist2 = new List <string>();

            s.CreateAndAddLabelRow(container, "Controlled Object");

            DropDown spin3 = null, spin4 = null;

            spin3 = s.CreateAndAddDropDownRow(container, "Controlled Object", objlist, 0, (sender, e) =>
            {
                if (sender.SelectedIndex > 0)
                {
                    if (adjust.GetFlowsheet().SimulationObjects.ContainsKey(adjust.ControlledObjectData.ID))
                    {
                        var prevobj = adjust.GetFlowsheet().SimulationObjects[adjust.ControlledObjectData.ID];
                        prevobj.IsAdjustAttached = false;
                        prevobj.AttachedAdjustId = "";
                        prevobj.AdjustVarType    = AdjustVarType.None;
                    }

                    var obj = adjust.GetFlowsheet().GetFlowsheetSimulationObject(objlist[sender.SelectedIndex]);
                    adjust.ControlledObjectData.ID = obj.Name;

                    obj.IsAdjustAttached = true;
                    obj.AttachedAdjustId = adjust.Name;
                    obj.AdjustVarType    = AdjustVarType.Controlled;

                    adjust.ControlledObject = (DWSIM.SharedClasses.UnitOperations.BaseClass)adjust.GetFlowsheet().SimulationObjects[adjust.ControlledObjectData.ID];
                    ((AdjustGraphic)adjust.GraphicObject).ConnectedToCv = (GraphicObject)adjust.ControlledObject.GraphicObject;

                    proplist2 = adjust.GetFlowsheet().GetFlowsheetSimulationObject(objlist[sender.SelectedIndex]).GetProperties(PropertyType.ALL).ToList();
                    proplist2.Insert(0, "");

                    spin4.Items.Clear();
                    spin4.Items.AddRange(proplist2.Select(x => new ListItem()
                    {
                        Text = adjust.GetFlowsheet().GetTranslatedString(x)
                    }).ToList());

                    if (adjust.ControlledObjectData.PropertyName != "" && proplist2.Contains(adjust.ControlledObjectData.PropertyName))
                    {
                        spin4.SelectedIndex = (proplist2.IndexOf(adjust.ControlledObjectData.PropertyName));
                    }
                }
                else
                {
                    spin4.Items.Clear();
                }
            });

            spin4 = s.CreateAndAddDropDownRow(container, "Controlled Property", proplist2, 0, (sender, e) =>
            {
                if (sender.SelectedIndex > 0)
                {
                    adjust.ControlledObjectData.PropertyName = proplist2[sender.SelectedIndex];
                    var obj     = adjust.GetFlowsheet().SimulationObjects[adjust.ControlledObjectData.ID];
                    var currval = Convert.ToDouble(obj.GetPropertyValue(proplist2[sender.SelectedIndex], su)).ToString(nf) + " " + obj.GetPropertyUnit(proplist2[sender.SelectedIndex], su);
                    lblCv.Text  = "Current Value: " + currval;
                }
            });

            lblCv = s.CreateAndAddLabelRow2(container, "");

            List <string> proplist3 = new List <string>();

            s.CreateAndAddLabelRow(container, "Referenced Object");

            s.CreateAndAddCheckBoxRow(container, "Use Referenced Object", adjust.Referenced, (sender, e) => { adjust.Referenced = sender.Checked.GetValueOrDefault(); });

            s.CreateAndAddDescriptionRow(container, "When a Reference Object is used, the Adjust/Controller block will change the Manipulated Variable so the Controlled Variable matches the Referenced value plus/minus the defined Set-Point/Offset.");

            DropDown spin5 = null, spin6 = null;

            spin5 = s.CreateAndAddDropDownRow(container, "Referenced Object", objlist, 0, (sender, e) =>
            {
                if (sender.SelectedIndex > 0)
                {
                    if (adjust.GetFlowsheet().SimulationObjects.ContainsKey(adjust.ReferencedObjectData.ID))
                    {
                        var prevobj = adjust.GetFlowsheet().SimulationObjects[adjust.ReferencedObjectData.ID];
                        prevobj.IsAdjustAttached = false;
                        prevobj.AttachedAdjustId = "";
                        prevobj.AdjustVarType    = AdjustVarType.None;
                    }

                    var obj = adjust.GetFlowsheet().GetFlowsheetSimulationObject(objlist[sender.SelectedIndex]);
                    adjust.ReferencedObjectData.ID = obj.Name;

                    obj.IsAdjustAttached = true;
                    obj.AttachedAdjustId = adjust.Name;
                    obj.AdjustVarType    = AdjustVarType.Reference;

                    adjust.ReferenceObject = (DWSIM.SharedClasses.UnitOperations.BaseClass)adjust.GetFlowsheet().SimulationObjects[adjust.ReferencedObjectData.ID];
                    ((AdjustGraphic)adjust.GraphicObject).ConnectedToRv = (GraphicObject)adjust.ReferenceObject.GraphicObject;

                    proplist3 = adjust.GetFlowsheet().GetFlowsheetSimulationObject(objlist[sender.SelectedIndex]).GetProperties(PropertyType.ALL).ToList();
                    proplist3.Insert(0, "");

                    spin6.Items.Clear();
                    spin6.Items.AddRange(proplist3.Select(x => new ListItem()
                    {
                        Text = adjust.GetFlowsheet().GetTranslatedString(x)
                    }).ToList());

                    if (adjust.ReferencedObjectData.PropertyName != "" && proplist3.Contains(adjust.ReferencedObjectData.PropertyName))
                    {
                        spin6.SelectedIndex = (proplist3.IndexOf(adjust.ReferencedObjectData.PropertyName));
                    }
                }
                else
                {
                    spin6.Items.Clear();
                }
            });

            spin6 = s.CreateAndAddDropDownRow(container, "Referenced Property", proplist3, 0, (sender, e) =>
            {
                if (sender.SelectedIndex > 0)
                {
                    adjust.ReferencedObjectData.PropertyName = proplist3[sender.SelectedIndex];
                    var obj     = adjust.GetFlowsheet().SimulationObjects[adjust.ReferencedObjectData.ID];
                    var currval = Convert.ToDouble(obj.GetPropertyValue(proplist3[sender.SelectedIndex], su)).ToString(nf) + " " + obj.GetPropertyUnit(proplist3[sender.SelectedIndex], su);
                    lblRv.Text  = "Current Value: " + currval;
                }
            });

            lblRv = s.CreateAndAddLabelRow2(container, "");

            s.CreateAndAddLabelRow(container, "Controller Parameters");

            var txtvalue = s.CreateAndAddTextBoxRow(container, nf, "Set-Point/Offset", 0.0f, (sender, e) =>
            {
                if (adjust.GetFlowsheet().SimulationObjects.ContainsKey(adjust.ControlledObjectData.ID))
                {
                    var obj = adjust.GetFlowsheet().SimulationObjects[adjust.ControlledObjectData.ID];
                    if (s.IsValidDouble(sender.Text))
                    {
                        if (adjust.Referenced)
                        {
                            obj       = adjust.GetFlowsheet().SimulationObjects[adjust.ReferencedObjectData.ID];
                            var punit = obj.GetPropertyUnit(adjust.ReferencedObjectData.PropertyName, su);
                            if (su.GetUnitType(punit) == UnitOfMeasure.temperature)
                            {
                                adjust.AdjustValue = cv.ConvertToSI(punit + ".", Double.Parse(sender.Text));
                            }
                            else
                            {
                                adjust.AdjustValue = cv.ConvertToSI(punit, Double.Parse(sender.Text));
                            }
                        }
                        else
                        {
                            adjust.AdjustValue = cv.ConvertToSI(obj.GetPropertyUnit(adjust.ControlledObjectData.PropertyName, su), Double.Parse(sender.Text));
                        }
                    }
                }
            }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged)
                       {
                           ((Shared.Flowsheet)adjust.GetFlowsheet()).HighLevelSolve.Invoke();
                       }
                });

            if (adjust.ManipulatedObjectData.ID != "" && adjust.GetFlowsheet().SimulationObjects.ContainsKey(adjust.ManipulatedObjectData.ID))
            {
                spin1.SelectedIndex = (objlist.IndexOf(adjust.GetFlowsheet().SimulationObjects[adjust.ManipulatedObjectData.ID].GraphicObject.Tag));
            }

            if (adjust.ControlledObjectData.ID != "" && adjust.GetFlowsheet().SimulationObjects.ContainsKey(adjust.ControlledObjectData.ID))
            {
                spin3.SelectedIndex = (objlist.IndexOf(adjust.GetFlowsheet().SimulationObjects[adjust.ControlledObjectData.ID].GraphicObject.Tag));
                var obj = adjust.GetFlowsheet().SimulationObjects[adjust.ControlledObjectData.ID];
                txtvalue.Text = cv.ConvertFromSI(obj.GetPropertyUnit(adjust.ControlledObjectData.PropertyName, su), adjust.AdjustValue).ToString(nf);
            }

            if (adjust.ReferencedObjectData.ID != "" && adjust.GetFlowsheet().SimulationObjects.ContainsKey(adjust.ReferencedObjectData.ID))
            {
                spin5.SelectedIndex = (objlist.IndexOf(adjust.GetFlowsheet().SimulationObjects[adjust.ReferencedObjectData.ID].GraphicObject.Tag));
                var obj = adjust.GetFlowsheet().SimulationObjects[adjust.ReferencedObjectData.ID];
                txtvalue.Text = cv.ConvertFromSI(obj.GetPropertyUnit(adjust.ReferencedObjectData.PropertyName, su), adjust.AdjustValue).ToString(nf);
            }

            s.CreateAndAddCheckBoxRow(container, "Run with the Simultaneous Adjust Solver", adjust.SimultaneousAdjust, (sender, e) => adjust.SimultaneousAdjust = sender.Checked.GetValueOrDefault());
        }
Пример #19
0
 public MaterialStreamEditor(ISimulationObject selectedobject, DynamicLayout layout)
 {
     MatStream = (MaterialStream)selectedobject;
     container = layout;
     Initialize();
 }
Пример #20
0
 public Results(ISimulationObject selectedobject, TableLayout layout)
 {
     SimObject = selectedobject;
     container = layout;
     Initialize();
 }
Пример #21
0
 public ShellAndTubePropertiesView(ISimulationObject selectedobject)
     : base()
 {
     SimObject = selectedobject;
     Init();
 }
Пример #22
0
 public CustomPropertiesEditor(ISimulationObject selectedobject, DynamicLayout layout)
 {
     SimObject = selectedobject;
     container = layout;
     Initialize();
 }
Пример #23
0
        private bool ChooseVictim(ISimulationObject[,]plane, Location location, Offset[] offsets, int neg, out int ox, out int oy)
        {
            var ax = location.X;
            var ay = location.Y;

            foreach (var offset in offsets)
            {
                var xOffset = Clip(ax + (offset.Dx * neg));
                var yOffset = Clip(ay + (offset.Dy * neg));

                // Если объект найден, возвращаем его индекс
                if (plane[yOffset, xOffset] != null)
                {
                    ox = xOffset;
                    oy = yOffset;

                    return true;
                }
            }

            ox = -1;
            oy = -1;
            return false;
        }
Пример #24
0
        private static Location FindEmptySpot(ISimulationObject[,] plane)
        {
            int x = 0;
            int y = 0;
            do
            {
                x = Rand.GetRand(GridSize);
                y = Rand.GetRand(GridSize);
            } while (plane[y, x] != null);

            return new Location(x, y);
        }