Exemple #1
0
        public PipeSectionEditor(IFlowsheet fs, DWSIM.UnitOperations.UnitOperations.Auxiliary.Pipe.PipeSection sec, DynamicLayout layout)
        {
            flowsheet = fs;
            section   = sec;
            container = layout;

            materials = new List <string>();

            materials.Add(fs.GetTranslatedString("AoComum"));
            materials.Add(fs.GetTranslatedString("AoCarbono"));
            materials.Add(fs.GetTranslatedString("FerroBottomido"));
            materials.Add(fs.GetTranslatedString("AoInoxidvel"));
            materials.Add("PVC");
            materials.Add("PVC+PFRV");
            materials.Add(fs.GetTranslatedString("CommercialCopper"));

            sectypes = new List <string>();
            sectypes.Add(fs.GetTranslatedString("Tubulaosimples"));

            var assembly = Assembly.GetAssembly(new PipeSection().GetType());

            var resourceName = "DWSIM.UnitOperations.fittings.dat";

            using (Stream stream = assembly.GetManifestResourceStream(resourceName))
                using (StreamReader reader = new StreamReader(stream))
                {
                    while (!reader.EndOfStream)
                    {
                        ACD.Add(reader.ReadLine().Split(';'));
                        sectypes.Add(ACD[ACD.Count - 1][0]);
                    }
                }

            Initialize();
        }
Exemple #2
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();
 }
Exemple #3
0
 public KineticReaction(IFlowsheet fs, IReaction reaction, DynamicLayout layout)
 {
     container = layout;
     flowsheet = fs;
     rx0       = reaction;
     rx        = (IReaction)((ICloneable)reaction).Clone();
     rx.ID     = reaction.ID;
     Initialize();
 }
Exemple #4
0
 public ReactionSetEditor(IFlowsheet fs, IReactionSet reactionset, DynamicLayout layout)
 {
     container = layout;
     flowsheet = fs;
     rset0     = reactionset;
     rset      = (IReactionSet)((ICloneable)reactionset).Clone();
     rset.ID   = reactionset.ID;
     Initialize();
 }
Exemple #5
0
 public List <Exception> CalculateFlowsheet2(IFlowsheet flowsheet)
 {
     GlobalSettings.Settings.SolverBreakOnException   = true;
     GlobalSettings.Settings.SolverMode               = 0;
     GlobalSettings.Settings.SolverTimeoutSeconds     = 120;
     GlobalSettings.Settings.EnableGPUProcessing      = false;
     GlobalSettings.Settings.EnableParallelProcessing = true;
     return(FlowsheetSolver.FlowsheetSolver.SolveFlowsheet(flowsheet, GlobalSettings.Settings.SolverMode));
 }
Exemple #6
0
 public List <Exception> CalculateFlowsheet3(IFlowsheet flowsheet, int timeout_seconds)
 {
     GlobalSettings.Settings.CalculatorActivated      = true;
     GlobalSettings.Settings.SolverBreakOnException   = true;
     GlobalSettings.Settings.SolverMode               = 1;
     GlobalSettings.Settings.SolverTimeoutSeconds     = timeout_seconds;
     GlobalSettings.Settings.EnableGPUProcessing      = false;
     GlobalSettings.Settings.EnableParallelProcessing = true;
     return(FlowsheetSolver.FlowsheetSolver.SolveFlowsheet(flowsheet, GlobalSettings.Settings.SolverMode));
 }
Exemple #7
0
 public void SaveFlowsheet(IFlowsheet flowsheet, string filepath, bool compressed)
 {
     if (compressed)
     {
         fm.SaveXMLZIP(filepath, (FormFlowsheet)flowsheet);
     }
     else
     {
         fm.SaveXML(filepath, (FormFlowsheet)flowsheet);
     }
 }
Exemple #8
0
 public void SaveFlowsheet(IFlowsheet flowsheet, string filepath, bool compressed)
 {
     Console.WriteLine("Saving the Flowsheet, please wait...");
     if (compressed)
     {
         fm.SaveXMLZIP(filepath, (FormFlowsheet)flowsheet);
     }
     else
     {
         fm.SaveXML(filepath, (FormFlowsheet)flowsheet);
     }
 }
Exemple #9
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);
     }
 }
Exemple #10
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);
     }
 }
Exemple #11
0
        public Spreadsheet(IFlowsheet fs)
        {
            flowsheet = fs;
            nf        = flowsheet.FlowsheetOptions.NumberFormat;

            this.ExprContext = new Ciloci.Flee.ExpressionContext();
            this.ExprContext.Imports.AddType(typeof(System.Math));
            this.ExprContext.Imports.AddType(typeof(System.String));

            rowlist = new ObservableCollection <RowItem>();

            int i;

            for (i = 0; i < 100; i++)
            {
                rowlist.Add(new RowItem((i + 1).ToString()));
            }

            DefineVariables();
        }
Exemple #12
0
 public OptimizerView(IFlowsheet fs)
     : base()
 {
     flowsheet = (Flowsheet)fs;
     Init();
 }
Exemple #13
0
 public void SaveFlowsheet(IFlowsheet flowsheet, string filepath, bool compressed)
 {
     Console.WriteLine("Saving the Flowsheet, please wait...");
     fm.FlowsheetObject = (Flowsheet)flowsheet;
     fm.SaveSimulation(filepath);
 }
Exemple #14
0
        public TableLayout GetSpreadsheet(IFlowsheet obj)
        {
            grid = new GridView {
                DataStore = rowlist, RowHeight = 20
            };
            if (Application.Instance.Platform.IsWinForms)
            {
                grid.Height = 1100;
            }

            if (GlobalSettings.Settings.RunningPlatform() != GlobalSettings.Settings.Platform.Windows)
            {
                grid.Columns.Add(new GridColumn {
                    HeaderText = "", DataCell = new TextBoxCell {
                        Binding = Binding.Property <RowItem, string>(r => r.index)
                    }, Editable = false, AutoSize = false, Width = 50, Resizable = false
                });
            }
            grid.Columns.Add(new GridColumn {
                HeaderText = "A", DataCell = new TextBoxCell {
                    Binding = Binding.Property <RowItem, string>(r => r.A)
                }, AutoSize = false, Editable = false, Width = 80
            });
            grid.Columns.Add(new GridColumn {
                HeaderText = "B", DataCell = new TextBoxCell {
                    Binding = Binding.Property <RowItem, string>(r => r.B)
                }, AutoSize = false, Editable = false, Width = 80
            });
            grid.Columns.Add(new GridColumn {
                HeaderText = "C", DataCell = new TextBoxCell {
                    Binding = Binding.Property <RowItem, string>(r => r.C)
                }, AutoSize = false, Editable = false, Width = 80
            });
            grid.Columns.Add(new GridColumn {
                HeaderText = "D", DataCell = new TextBoxCell {
                    Binding = Binding.Property <RowItem, string>(r => r.D)
                }, AutoSize = false, Editable = false, Width = 80
            });
            grid.Columns.Add(new GridColumn {
                HeaderText = "E", DataCell = new TextBoxCell {
                    Binding = Binding.Property <RowItem, string>(r => r.E)
                }, AutoSize = false, Editable = false, Width = 80
            });
            grid.Columns.Add(new GridColumn {
                HeaderText = "F", DataCell = new TextBoxCell {
                    Binding = Binding.Property <RowItem, string>(r => r.F)
                }, AutoSize = false, Editable = false, Width = 80
            });
            grid.Columns.Add(new GridColumn {
                HeaderText = "G", DataCell = new TextBoxCell {
                    Binding = Binding.Property <RowItem, string>(r => r.G)
                }, AutoSize = false, Editable = false, Width = 80
            });
            grid.Columns.Add(new GridColumn {
                HeaderText = "H", DataCell = new TextBoxCell {
                    Binding = Binding.Property <RowItem, string>(r => r.H)
                }, AutoSize = false, Editable = false, Width = 80
            });
            grid.Columns.Add(new GridColumn {
                HeaderText = "I", DataCell = new TextBoxCell {
                    Binding = Binding.Property <RowItem, string>(r => r.I)
                }, AutoSize = false, Editable = false, Width = 80
            });
            grid.Columns.Add(new GridColumn {
                HeaderText = "J", DataCell = new TextBoxCell {
                    Binding = Binding.Property <RowItem, string>(r => r.J)
                }, AutoSize = false, Editable = false, Width = 80
            });
            grid.Columns.Add(new GridColumn {
                HeaderText = "K", DataCell = new TextBoxCell {
                    Binding = Binding.Property <RowItem, string>(r => r.K)
                }, AutoSize = false, Editable = false, Width = 80
            });
            grid.Columns.Add(new GridColumn {
                HeaderText = "L", DataCell = new TextBoxCell {
                    Binding = Binding.Property <RowItem, string>(r => r.L)
                }, AutoSize = false, Editable = false, Width = 80
            });
            grid.Columns.Add(new GridColumn {
                HeaderText = "M", DataCell = new TextBoxCell {
                    Binding = Binding.Property <RowItem, string>(r => r.M)
                }, AutoSize = false, Editable = false, Width = 80
            });
            grid.Columns.Add(new GridColumn {
                HeaderText = "N", DataCell = new TextBoxCell {
                    Binding = Binding.Property <RowItem, string>(r => r.N)
                }, AutoSize = false, Editable = false, Width = 80
            });
            grid.Columns.Add(new GridColumn {
                HeaderText = "O", DataCell = new TextBoxCell {
                    Binding = Binding.Property <RowItem, string>(r => r.O)
                }, AutoSize = false, Editable = false, Width = 80
            });
            grid.Columns.Add(new GridColumn {
                HeaderText = "P", DataCell = new TextBoxCell {
                    Binding = Binding.Property <RowItem, string>(r => r.P)
                }, AutoSize = false, Editable = false, Width = 80
            });
            grid.Columns.Add(new GridColumn {
                HeaderText = "Q", DataCell = new TextBoxCell {
                    Binding = Binding.Property <RowItem, string>(r => r.Q)
                }, AutoSize = false, Editable = false, Width = 80
            });
            grid.Columns.Add(new GridColumn {
                HeaderText = "R", DataCell = new TextBoxCell {
                    Binding = Binding.Property <RowItem, string>(r => r.R)
                }, AutoSize = false, Editable = false, Width = 80
            });
            grid.Columns.Add(new GridColumn {
                HeaderText = "S", DataCell = new TextBoxCell {
                    Binding = Binding.Property <RowItem, string>(r => r.S)
                }, AutoSize = false, Editable = false, Width = 80
            });
            grid.Columns.Add(new GridColumn {
                HeaderText = "T", DataCell = new TextBoxCell {
                    Binding = Binding.Property <RowItem, string>(r => r.T)
                }, AutoSize = false, Editable = false, Width = 80
            });
            grid.Columns.Add(new GridColumn {
                HeaderText = "U", DataCell = new TextBoxCell {
                    Binding = Binding.Property <RowItem, string>(r => r.U)
                }, AutoSize = false, Editable = false, Width = 80
            });
            grid.Columns.Add(new GridColumn {
                HeaderText = "V", DataCell = new TextBoxCell {
                    Binding = Binding.Property <RowItem, string>(r => r.V)
                }, AutoSize = false, Editable = false, Width = 80
            });
            grid.Columns.Add(new GridColumn {
                HeaderText = "W", DataCell = new TextBoxCell {
                    Binding = Binding.Property <RowItem, string>(r => r.W)
                }, AutoSize = false, Editable = false, Width = 80
            });
            grid.Columns.Add(new GridColumn {
                HeaderText = "X", DataCell = new TextBoxCell {
                    Binding = Binding.Property <RowItem, string>(r => r.X)
                }, AutoSize = false, Editable = false, Width = 80
            });
            grid.Columns.Add(new GridColumn {
                HeaderText = "Y", DataCell = new TextBoxCell {
                    Binding = Binding.Property <RowItem, string>(r => r.Y)
                }, AutoSize = false, Editable = false, Width = 80
            });
            grid.Columns.Add(new GridColumn {
                HeaderText = "Z", DataCell = new TextBoxCell {
                    Binding = Binding.Property <RowItem, string>(r => r.Z)
                }, AutoSize = false, Editable = false, Width = 80
            });

            grid.AllowColumnReordering  = false;
            grid.AllowMultipleSelection = false;
            grid.GridLines = GridLines.Both;
            grid.Style     = "spreadsheet";

            var table = new TableLayout();

            var cellcp = new Panel();

            var txtcell = new TextBox {
                Width = 80, ReadOnly = true
            };
            var txttype = new TextBox {
                Width = 200, ReadOnly = true
            };
            var txtformula = new TextBox()
            {
                PlaceholderText = "To enter a formula,  type '=' followed by the math expression and press ENTER to commit changes."
            };
            var btnImport = new Button {
                Text = "Import"
            };
            var btnExport = new Button {
                Text = "Export"
            };
            var btnClear = new Button {
                Text = "Clear"
            };
            var btnEvaluate = new Button {
                Text = "Evaluate"
            };
            var btnEvaluateAll = new Button {
                Text = "Evaluate All"
            };

            btnEvaluate.Click += (sender, e) =>
            {
                EvaluateAll(ccparams);
                grid.ReloadData(int.Parse(rowitem.index) - 1);
            };

            btnEvaluateAll.Click += (sender, e) =>
            {
                EvaluateAll();
            };


            btnClear.Click += (sender, e) =>
            {
                ccparams.Expression = "";
                ccparams.ObjectID   = "";
                ccparams.PropID     = "";
                ccparams.PropUnit   = "";
                ccparams.CurrVal    = "";
                ccparams.PrevVal    = "";
                ccparams.CellType   = VarType.None;
                UpdateValue(ccparams);
                grid.ReloadData(int.Parse(rowitem.index) - 1);
            };

            btnImport.Click += (sender, e) =>
            {
                var selector = new PropertySelector()
                {
                    Flowsheet = flowsheet, ObjList = ObjList
                };

                selector.btnOK.Click += (sender2, e2) =>
                {
                    ccparams.Expression = ":" + selector.list2.SelectedKey + "," + selector.list3.SelectedKey;
                    ccparams.CellType   = global::DWSIM.SharedClasses.Spreadsheet.VarType.Read;
                    UpdateValue(ccparams);
                    grid.ReloadData(int.Parse(rowitem.index) - 1);
                    selector.Close();
                };

                selector.ShowModal(grid);
            };

            btnExport.Click += (sender, e) =>
            {
                var selector = new PropertySelector()
                {
                    Flowsheet = flowsheet, ObjList = ObjList, mode = 1
                };

                selector.btnOK.Click += (sender2, e2) =>
                {
                    ccparams.ObjectID = selector.list2.SelectedKey;
                    ccparams.PropID   = selector.list3.SelectedKey;
                    ccparams.CellType = global::DWSIM.SharedClasses.Spreadsheet.VarType.Write;
                    UpdateValue(ccparams);
                    grid.ReloadData(int.Parse(rowitem.index) - 1);
                    selector.Close();
                };

                selector.ShowModal(grid);
            };

            var tr = new TableRow(new Label {
                Text = "Selected Cell", VerticalAlignment = VerticalAlignment.Center
            }, txtcell,
                                  new Label {
                Text = "Type", VerticalAlignment = VerticalAlignment.Center
            }, txttype,
                                  new Label {
                Text = "Contents", VerticalAlignment = VerticalAlignment.Center
            }, txtformula,
                                  btnImport, btnExport, btnClear, btnEvaluate, btnEvaluateAll);

            tr.Cells[5].ScaleWidth = true;

            var tb = new TableLayout {
                Spacing = new Size(5, 5), Padding = new Padding(10)
            };

            tb.Rows.Add(tr);
            if (GlobalSettings.Settings.RunningPlatform() == GlobalSettings.Settings.Platform.Mac)
            {
                tb.Height = 44;
            }

            cellcp.Content = tb;

            table.Rows.Add(new TableRow(cellcp));

            var cnt = new DynamicLayout {
                Padding = new Padding(10, 0)
            };

            s.CreateAndAddDescriptionRow(cnt, "Select cells by clicking or touching on them (using arrow keys on the keyboard won't change the currently selected data cell). After selecting the cell, edit its contents on the 'Contents' input box, or configure it to import or export data from/to the flowsheet by clicking on the corresponding buttons.", true);

            table.Rows.Add(new TableRow(cnt));

            txtformula.TextChanged += (sender, e) =>
            {
                rowitem.CellParams[selectedcell].Expression = txtformula.Text;
            };

            txtformula.KeyDown += (sender, e) =>
            {
                if (e.Key == Keys.Enter)
                {
                    UpdateValue(rowitem.CellParams[selectedcell]);
                    grid.ReloadData(int.Parse(rowitem.index) - 1);
                }
            };

            grid.CellDoubleClick += (sender, e) =>
            {
                if (txtformula.Enabled)
                {
                    txtformula.Focus();
                }
            };

            grid.CellClick += (sender, e) =>
            {
                if (e.Item == null)
                {
                    return;
                }
                if (e.GridColumn.HeaderText == "")
                {
                    return;
                }
                selectedcell = e.GridColumn.HeaderText + (e.Row + 1).ToString();
                txtcell.Text = selectedcell;
                rowitem      = ((RowItem)e.Item);
                var cellp = ((RowItem)e.Item).CellParams[selectedcell];
                ccparams = cellp;
                switch (cellp.CellType)
                {
                case VarType.Expression:
                    txttype.Text       = "Expression";
                    txtformula.Enabled = true;
                    break;

                case VarType.Read:
                    txttype.Text       = "Imported from " + flowsheet.SimulationObjects[ccparams.ObjectID].GraphicObject.Tag + ", " + flowsheet.GetTranslatedString(ccparams.PropID);
                    txtformula.Enabled = false;
                    break;

                case VarType.Write:
                    txttype.Text       = "Exported to " + flowsheet.SimulationObjects[ccparams.ObjectID].GraphicObject.Tag + ", " + flowsheet.GetTranslatedString(ccparams.PropID);
                    txtformula.Enabled = false;
                    break;

                case VarType.None:
                    txttype.Text       = "Text";
                    txtformula.Enabled = true;
                    break;
                }
                txttype.ToolTip    = txttype.Text;
                txtformula.Text    = cellp.Expression;
                txtformula.ToolTip = txtformula.Text;
            };

            table.Rows.Add(new TableRow(new Scrollable {
                Content = grid, Border = BorderType.None
            }));

            return(table);
        }
 public SensAnalysisView(IFlowsheet fs)
     : base()
 {
     flowsheet = (Flowsheet)fs;
     Init();
 }
Exemple #16
0
 public PhaseEnvelopeView(IFlowsheet fs)
     : base()
 {
     flowsheet = fs;
     Init();
 }
Exemple #17
0
 public void SaveFlowsheet2(IFlowsheet flowsheet, string filepath)
 {
     SaveFlowsheet(flowsheet, filepath, true);
 }
Exemple #18
0
 public TrueCriticalPointView(IFlowsheet fs) : base()
 {
     flowsheet = fs;
     Init();
 }
Exemple #19
0
 public Compounds(IFlowsheet fs, TableLayout layout)
 {
     flowsheet = (Flowsheet)fs;
     container = layout;
     Initialize();
 }
Exemple #20
0
        public SimulationSetupWizard(IFlowsheet fs)
            : base()
        {

            flowsheet = fs;
        }
Exemple #21
0
 public ReactionsManager(IFlowsheet fs, DynamicLayout layout)
 {
     flowsheet = fs;
     container = layout;
     Initialize();
 }
 public MaterialStreamListViewer(IFlowsheet fs)
 {
     Flowsheet = fs;
     Init();
 }
Exemple #23
0
 public PixelLayout GetSpreadsheet(IFlowsheet obj)
 {
     return(scontrol);
 }
Exemple #24
0
 public ObjectAppearanceEditorView(IFlowsheet fs, Drawing.SkiaSharp.GraphicObjects.ShapeGraphic gobject)
 {
     flowsheet = fs;
     gobj      = gobject;
     Init();
 }
Exemple #25
0
 public BulkC7PCharacterization(IFlowsheet fs) : base()
 {
     flowsheet = fs;
     Init();
 }
Exemple #26
0
 public Models(IFlowsheet fs, DynamicLayout layout)
 {
     flowsheet = fs;
     container = layout;
     Initialize();
 }
Exemple #27
0
 public PropertyPackageSettingsView(IFlowsheet fs, PropertyPackage ppack) : base()
 {
     flowsheet = fs;
     pp        = ppack;
     Init();
 }
Exemple #28
0
 public BinaryEnvelopeView(IFlowsheet fs)
     : base()
 {
     flowsheet = fs;
     Init();
 }
Exemple #29
0
 public FloatingTablesView(IFlowsheet fs)
 {
     flowsheet = fs;
     Init();
 }
Exemple #30
0
 public DistCurvePCharacterization(IFlowsheet fs)
     : base()
 {
     flowsheet = fs;
     Init();
 }