' DWSIM Interface definitions ' Copyright 2010-2021 Daniel Wagner O. de Medeiros ' ' This file is part of DWSIM. ' ' DWSIM is free software: you can redistribute it and/or modify ' it under the terms of the GNU General Public License as published by ' the Free Software Foundation, either version 3 of the License, or ' (at your option) any later version. ' ' DWSIM is distributed in the hope that it will be useful, ' but WITHOUT ANY WARRANTY; without even the implied warranty of ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ' GNU General Public License for more details. ' ' You should have received a copy of the GNU General Public License ' along with DWSIM. If not, see . ''' ''' The IFlowsheet interface is the main interface which should be implemented by the Flowsheet class. ''' It provides direct access to the various flowsheet components and helper functions to manipulate objects. ''' Public Interface IFlowsheet Enum MessageType Information Warning GeneralError Tip Other End Enum Property DynamicMode As Boolean Property FileDatabaseProvider As IFileDatabaseProvider Property DynamicsManager As IDynamicsManager Property ExtraProperties As Dynamic.ExpandoObject Function GetApplicationObject() As Object Property AvailableCompounds As Dictionary(Of String, ICompoundConstantProperties) Property ExternalSolvers As Dictionary(Of String, IExternalSolverIdentification) Function SaveToXML() As XDocument Property FilePath As String Property RedirectMessages As Boolean ReadOnly Property UtilityPlugins As Dictionary(Of String, IUtilityPlugin) Property MasterUnitOp As ISimulationObject Property GraphicObjects As Dictionary(Of String, IGraphicObject) Property PropertyPackages As Dictionary(Of String, IPropertyPackage) Property AvailablePropertyPackages As Dictionary(Of String, IPropertyPackage) Property AvailableSystemsOfUnits As List(Of IUnitsOfMeasure) Property Reactions As Dictionary(Of String, IReaction) Property ReactionSets As Dictionary(Of String, IReactionSet) Property SelectedCompounds As Dictionary(Of String, ICompoundConstantProperties) Property SimulationObjects As Dictionary(Of String, ISimulationObject) Property StoredSolutions As Dictionary(Of String, List(Of XElement)) Property Charts As Dictionary(Of String, IChart) Property WatchItems As List(Of IWatchItem) Sub ShowMessage(ByVal text As String, ByVal mtype As MessageType, Optional ByVal exceptionID As String = "") Sub ShowDebugInfo(ByVal text As String, ByVal level As Integer) Sub CheckStatus() Sub RequestCalculation(Optional ByVal sender As ISimulationObject = Nothing, Optional ByVal ChangeCalculationOrder As Boolean = False) Function GetTranslatedString(text As String, locale As String) As String Function GetTranslatedString(text As String) As String ReadOnly Property FlowsheetOptions As IFlowsheetOptions Function GetFlowsheetSimulationObject(tag As String) As ISimulationObject Function GetSelectedFlowsheetSimulationObject(tag As String) As ISimulationObject Function GetObject(name As String) As ISimulationObject Function GetCompound(name As String) As ICompoundConstantProperties Function GetPropertyPackage(name As String) As IPropertyPackage Function GetReaction(name As String) As IReaction Function GetReactionSet(name As String) As IReactionSet Sub AutoLayout() Sub NaturalLayout() Sub DisplayForm(form As Object) Sub UpdateOpenEditForms() Sub ConnectObjects(gobjfrom As IGraphicObject, gobjto As IGraphicObject, fromidx As Integer, toidx As Integer) Sub DisconnectObjects(gobjfrom As IGraphicObject, gobjto As IGraphicObject) Function GetFlowsheetBag() As IFlowsheetBag Sub AddCompoundsToMaterialStream(stream As IMaterialStream) Function AddObject(t As Enums.GraphicObjects.ObjectType, xcoord As Integer, ycoord As Integer, tag As String) As ISimulationObject Function AddObject(t As Enums.GraphicObjects.ObjectType, xcoord As Integer, ycoord As Integer, id As String, tag As String) As ISimulationObject Sub AddGraphicObject(obj As IGraphicObject) Sub AddSimulationObject(obj As ISimulationObject) Function GetUtility(uttype As Enums.FlowsheetUtility) As IAttachedUtility Function GetSurface() As Object Function GetSurfaceControl() As Object Function GetNewInstance() As IFlowsheet Sub AddPropertyPackage(obj As IPropertyPackage) Property MasterFlowsheet As IFlowsheet Sub AddUndoRedoAction(action As IUndoRedoAction) Sub UpdateSpreadsheet(act As Action) Sub WriteSpreadsheetVariables(act As Action) Function GetSpreadsheetData(range As String) As List(Of String()) Function GetSpreadsheetFormat(range As String) As List(Of String()) Property MobileCompatibilityMode As Boolean Property Message As String Sub SetMessageListener(act As Action(Of String, MessageType)) Property Solved As Boolean Property ErrorMessage As String Sub RunCodeOnUIThread(act As Action) Function GetDockPanel() As Object Sub LoadFromXML(xdoc As XDocument) Sub Initialize() Sub Reset() Sub DeleteSelectedObject(sender As Object, e As EventArgs, gobj As IGraphicObject, Optional confirmation As Boolean = True, Optional triggercalc As Boolean = False) Sub ProcessScripts(eventType As Enums.Scripts.EventType, objectType As Enums.Scripts.ObjectType, obj As String) Property Scripts As Dictionary(Of String, IScript) Sub UpdateInterface() Sub UpdateInformation() Sub RefreshInterface() Function GetFlowsheetSurfaceWidth() As Integer Function GetFlowsheetSurfaceHeight() As Integer Function ChangeCalculationOrder(objects As List(Of String)) As List(Of String) Function GetProcessData() As List(Of XElement) Sub LoadProcessData(data As List(Of XElement)) Function GetSpreadsheetObject() As Object Sub SetTranslateTextExternalFunction(act As Func(Of String, String)) Function GetScriptText(name As String) As String Sub RunScript(name As String) Function GetSimulationFilePath() As String Function GetSimulationFileDirectory() As String Sub ClearLog() Property PythonPreprocessor() As Action(Of String) Property SupressMessages As Boolean Sub RequestSave() Sub RequestSaveWithDirectory(directory As String) Sub RequestSaveWithPath(filepath As String) Sub ToggleFlowsheetAnimation() Function RunCodeOnUIThread2(act As Action) As Task Property WeatherProvider As IWeatherProvider ''' ''' Creates a Conversion reaction object. ''' ''' Name/ID of the reaction ''' Description of the reaction ''' Compound names and stoichiometric coefficients ''' Name of the base reaction compound ''' Reaction phase ('Mixture', 'Vapor', 'Liquid' or 'Solid') ''' Expression for evaluating conversion of the base compound as a function of temperature in K. Function CreateConversionReaction(name As String, description As String, compounds_and_stoichcoeffs As Dictionary(Of String, Double), basecompound As String, reactionphase As String, conversionExpression As String) As IReaction ''' ''' Creates an Equilibrium reaction object. ''' ''' Name/ID of the reaction ''' Description of the reaction ''' Compound names and stoichiometric coefficients ''' Name of the base reaction compound ''' Reaction phase ('Mixture', 'Vapor', 'Liquid' or 'Solid') ''' Reaction basis ('Activity', 'Fugacity', 'Molar Concentration', 'Molar Fraction', 'Mass Concentration', 'Mass Fraction' or 'Partial Pressure') ''' Expression for evaulating the equilibrium constant as a function of temperature in K. Will use gibbs energy of formation if empty. ''' Temperature value that will be added or removed to the system temperature in order to evaluate the equilibrium constant ''' Basis units. See the list of supported units Function CreateEquilibriumReaction(name As String, description As String, compounds_and_stoichcoeffs As Dictionary(Of String, Double), basecompound As String, reactionphase As String, basis As String, units As String, Tapproach As Double, lnKeq_fT As String) As IReaction ''' ''' Creates a Kinetic reaction object. ''' ''' Name/ID of the reaction ''' Description of the reaction ''' Compound names and stoichiometric coefficients ''' Compound names and direct order coefficients ''' Compound names and reverse order coefficients ''' Name of the base reaction compound ''' Reaction phase ('Mixture', 'Vapor', 'Liquid' or 'Solid') ''' Reaction basis ('Activity', 'Fugacity', 'Molar Concentration', 'Molar Fraction', 'Mass Concentration', 'Mass Fraction' or 'Partial Pressure') ''' Amount units. See the list of supported units ''' Rate units. See the list of supported units ''' Arrhenius forward reaction's A parameter. Ignored if Expr_forward is not empty. ''' Arrhenius forward reaction's E parameter. Ignored if Expr_forward is not empty. ''' Arrhenius reverse reaction's A parameter. Ignored if Expr_reverse is not empty. ''' Arrhenius reverse reaction's E parameter. Ignored if Expr_reverse is not empty. ''' User-defined expression for forward reaction kinetics as a function of temperature in K. Will use Arrhenius if empty. ''' User-defined expression for reverse reaction kinetics as a function of temperature in K. Will use Arrhenius if empty. ''' Function CreateKineticReaction(name As String, description As String, compounds_and_stoichcoeffs As Dictionary(Of String, Double), directorders As Dictionary(Of String, Double), reverseorders As Dictionary(Of String, Double), basecompound As String, reactionphase As String, basis As String, amountunits As String, rateunits As String, Aforward As Double, Eforward As Double, Areverse As Double, Ereverse As Double, Expr_forward As String, Expr_reverse As String) As IReaction ''' ''' Creates a Heterogeneous Catalytic reaction object. ''' ''' Name/ID of the reaction ''' Description of the reaction ''' Compound names and stoichiometric coefficients ''' Name of the base reaction compound ''' Reaction phase ('Mixture', 'Vapor', 'Liquid' or 'Solid') ''' Reaction basis ('Activity', 'Fugacity', 'Molar Concentration', 'Molar Fraction', 'Mass Concentration', 'Mass Fraction' or 'Partial Pressure') ''' Amount units. See the list of supported units ''' Rate units. See the list of supported units ''' Numerator expression ''' Denominator expression ''' Reaction object Function CreateHetCatReaction(name As String, description As String, compounds_and_stoichcoeffs As Dictionary(Of String, Double), basecompound As String, reactionphase As String, basis As String, amountunits As String, rateunits As String, numeratorExpression As String, denominatorExpression As String) As IReaction ''' ''' Creates a Reaction Set object. ''' ''' Name/ID of the reaction set ''' Description ''' Function CreateReactionSet(name As String, description As String) As IReactionSet ''' ''' Add a reaction to the flowsheet. ''' ''' reaction object Sub AddReaction(reaction As IReaction) ''' ''' Add a reaction set to the flowsheet. ''' ''' reaction set object Sub AddReactionSet(reactionSet As IReactionSet) ''' ''' Adds a reaction to a reaction set. ''' ''' reaction ID ''' reaction set ID ''' True if the reaction is to be active in the reaction set ''' Rank (0, 1, 2, 3...) of the reaction in the reaction set Sub AddReactionToSet(reactionID As String, reactionSetID As String, enabled As Boolean, rank As Integer) ''' ''' Gets a list of all available Property Packages. ''' ''' A list containing the names of the available property packages. Function GetAvailablePropertyPackages() As List(Of String) ''' ''' Creates and returns a new Property Package. ''' ''' Name of the Property Package as returned by GetAvailablePropertyPackages ''' Function CreatePropertyPackage(name As String) As IPropertyPackage ''' ''' Creates and adds a Property Package to the flowsheet. ''' ''' Name of the Property Package as returned by GetAvailablePropertyPackages. ''' Function CreateAndAddPropertyPackage(name As String) As IPropertyPackage ''' ''' Adds a compound to the flowsheet. ''' ''' Compound name exactly as in the database. ''' Function AddCompound(compname As String) As ICompoundConstantProperties Sub SetDirtyStatus() Function GetAvailableFlowsheetObjectTypeNames() As Array Function AddFlowsheetObject(typename As String, objname As String) As ISimulationObject Sub DisplayBrowserWindow(url As String) Sub DisplayDockableBrowserWindow(url As String) Sub RequestCalculation2(Wait As Boolean) Sub RequestCalculation3(obj As ISimulationObject, Wait As Boolean) Function RequestCalculationAndWait() As List(Of Exception) Property MessagesLog As List(Of String) Property AvailableExternalUnitOperations As Dictionary(Of String, IExternalUnitOperation) Property AvailableSimulationObjects As Dictionary(Of String, ISimulationObject) Function GetSnapshot(type As Enums.SnapshotType, Optional obj As ISimulationObject = Nothing) As XDocument Sub RestoreSnapshot(data As XDocument, type As Enums.SnapshotType) Sub RegisterSnapshot(stype As Enums.SnapshotType, Optional obj As ISimulationObject = Nothing) Sub ResetCalculationStatus() Sub CloseOpenEditForms() Function Clone() As IFlowsheet Property Results As IFlowsheetResults Property GHGEmissionCompositions As Dictionary(Of String, IGHGComposition) Function GetResultIDs() As List(Of String) Function GetResultValue(id As String) As Double Function GetResultUnits(id As String) As String Property ParticleSizeDistributions As List(Of ISolidParticleSizeDistribution) Sub ReleaseResources() Sub UpdateMassAndEnergyBalance() End Interface ''' ''' This is an interface which provides direct access to collections of flowsheet objects. ''' Public Interface IFlowsheetBag Property SimulationObjects As Dictionary(Of String, ISimulationObject) Property GraphicObjects As Dictionary(Of String, IGraphicObject) Property Compounds As Dictionary(Of String, ICompoundConstantProperties) Property PropertyPackages As Dictionary(Of String, IPropertyPackage) Property Reactions As Dictionary(Of String, IReaction) Property ReactionSets As Dictionary(Of String, IReactionSet) Sub SaveToXML(file As String) Sub UpdateProcessData(xdoc As XDocument) Function GetSurface() As Object 'For COM compatibility Property SimulationObjectsArray As ISimulationObject() Property GraphicObjectsArray As IGraphicObject() Property CompoundsArray As ICompoundConstantProperties() Property PropertyPackagesArray As IPropertyPackage() Property ReactionsArray As IReaction() Property ReactionSetsArray As IReactionSet() End Interface ''' ''' This is an interface which defines helper functions to a Flowsheet GUI implementation. ''' Public Interface IFlowsheetGUI Sub ShowMessage(ByVal text As String, ByVal mtype As IFlowsheet.MessageType, Optional ByVal exceptionID As String = "") Sub ShowDebugInfo(ByVal text As String, ByVal level As Integer) Sub CheckStatus() Function GetTranslatedString(text As String, locale As String) As String Function GetTranslatedString(text As String) As String Sub ProcessScripts(eventType As Enums.Scripts.EventType, objectType As Enums.Scripts.ObjectType, obj As String) Sub UpdateInterface() Sub UpdateInformation() End Interface ''' ''' This interface defines the calculation queue to be used by the flowsheet solver. ''' Public Interface IFlowsheetCalculationQueue Property CalculationQueue As Queue(Of ICalculationArgs) End Interface Public Interface ICalculationArgs Property Sender As String Property Calculated As Boolean Property Tag As String Property Name As String Property ObjectType As Enums.GraphicObjects.ObjectType End Interface