Ejemplo n.º 1
0
 public SolvableConnection(Flowsheet flowsheet)
 {
     this.flowsheet = flowsheet;
     Init();
     InitializeComponent();
 }
Ejemplo n.º 2
0
 public ConnectionManager(Flowsheet flowsheet)
 {
     this.flowsheet   = flowsheet;
     this.Connections = new ArrayList();
 }
Ejemplo n.º 3
0
        private ArrayList GetFlowsheetContent(Flowsheet flowsheet)
        {
            ArrayList toSerializeItems = new ArrayList();

            toSerializeItems.Add(flowsheet.EvaporationAndDryingSystem);

            // get all the flowsheet element controls
            IEnumerator e = flowsheet.Controls.GetEnumerator();

            while (e.MoveNext())
            {
                object obj = e.Current;
                if (obj is GasStreamControl)
                {
                    GasStreamControl ctrl = (GasStreamControl)obj;
                    toSerializeItems.Add(ctrl);
                }
                else if (obj is MaterialStreamControl)
                {
                    MaterialStreamControl ctrl = (MaterialStreamControl)obj;
                    toSerializeItems.Add(ctrl);
                }
                else if (obj is DryerControl)
                {
                    DryerControl ctrl = (DryerControl)obj;
                    toSerializeItems.Add(ctrl);
                }
                else if (obj is HeatExchangerControl)
                {
                    HeatExchangerControl ctrl = (HeatExchangerControl)obj;
                    toSerializeItems.Add(ctrl);
                }
                else if (obj is CycloneControl)
                {
                    CycloneControl ctrl = (CycloneControl)obj;
                    toSerializeItems.Add(ctrl);
                }
                else if (obj is EjectorControl)
                {
                    EjectorControl ctrl = (EjectorControl)obj;
                    toSerializeItems.Add(ctrl);
                }
                else if (obj is WetScrubberControl)
                {
                    WetScrubberControl ctrl = (WetScrubberControl)obj;
                    toSerializeItems.Add(ctrl);
                }
                else if (obj is ScrubberCondenserControl)
                {
                    ScrubberCondenserControl ctrl = (ScrubberCondenserControl)obj;
                    toSerializeItems.Add(ctrl);
                }
                else if (obj is MixerControl)
                {
                    MixerControl ctrl = (MixerControl)obj;
                    toSerializeItems.Add(ctrl);
                }
                else if (obj is TeeControl)
                {
                    TeeControl ctrl = (TeeControl)obj;
                    toSerializeItems.Add(ctrl);
                }
                else if (obj is FlashTankControl)
                {
                    FlashTankControl ctrl = (FlashTankControl)obj;
                    toSerializeItems.Add(ctrl);
                }
                else if (obj is FanControl)
                {
                    FanControl ctrl = (FanControl)obj;
                    toSerializeItems.Add(ctrl);
                }
                else if (obj is ValveControl)
                {
                    ValveControl ctrl = (ValveControl)obj;
                    toSerializeItems.Add(ctrl);
                }
                else if (obj is BagFilterControl)
                {
                    BagFilterControl ctrl = (BagFilterControl)obj;
                    toSerializeItems.Add(ctrl);
                }
                else if (obj is AirFilterControl)
                {
                    AirFilterControl ctrl = (AirFilterControl)obj;
                    toSerializeItems.Add(ctrl);
                }
                else if (obj is CompressorControl)
                {
                    CompressorControl ctrl = (CompressorControl)obj;
                    toSerializeItems.Add(ctrl);
                }
                else if (obj is HeaterControl)
                {
                    HeaterControl ctrl = (HeaterControl)obj;
                    toSerializeItems.Add(ctrl);
                }
                else if (obj is CoolerControl)
                {
                    CoolerControl ctrl = (CoolerControl)obj;
                    toSerializeItems.Add(ctrl);
                }
                else if (obj is ElectrostaticPrecipitatorControl)
                {
                    ElectrostaticPrecipitatorControl ctrl = (ElectrostaticPrecipitatorControl)obj;
                    toSerializeItems.Add(ctrl);
                }
                else if (obj is PumpControl)
                {
                    PumpControl ctrl = (PumpControl)obj;
                    toSerializeItems.Add(ctrl);
                }
                else if (obj is RecycleControl)
                {
                    RecycleControl ctrl = (RecycleControl)obj;
                    toSerializeItems.Add(ctrl);
                }
            }

            // get all the connections
            e = flowsheet.ConnectionManager.Connections.GetEnumerator();
            while (e.MoveNext())
            {
                SolvableConnection dc = (SolvableConnection)e.Current;
                toSerializeItems.Add(dc);
            }

            // get the flowsheet preferences
            FlowsheetPreferences flowsheetPrefs = new FlowsheetPreferences(flowsheet);

            toSerializeItems.Add(flowsheetPrefs);

            // get the custom editor (we persist only the ID of the variables)
            toSerializeItems.Add(flowsheet.CustomEditor);

            // get the flowsheet version
            toSerializeItems.Add(flowsheet.Version);

            return(toSerializeItems);
        }
Ejemplo n.º 4
0
        private Flowsheet SetFlowsheetContent(NewProcessSettings newProcessSettings, ApplicationPreferences appPrefs, ArrayList items, string flowsheetName)
        {
            Flowsheet        flowsheet        = null;
            FlowsheetVersion flowsheetVersion = null;
            IEnumerator      e = items.GetEnumerator();

            while (e.MoveNext())
            {
                object obj = e.Current;

                if (obj is EvaporationAndDryingSystem)
                {
                    EvaporationAndDryingSystem persisted = (EvaporationAndDryingSystem)obj;
                    persisted.SetSystemFileName(flowsheetName); // call this before SetObjectData()
                    persisted.SetObjectData();
                    flowsheet = new Flowsheet(newProcessSettings, appPrefs, persisted);
                }

                else if (obj is GasStreamControl)
                {
                    GasStreamControl persistedCtrl = (GasStreamControl)obj;
                    string           solvableName  = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
                    DryingGasStream  stream        = flowsheet.EvaporationAndDryingSystem.GetGasStream(solvableName);
                    GasStreamControl newCtrl       = new GasStreamControl(flowsheet, new Point(0, 0), stream);
                    newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
                    flowsheet.Controls.Add(newCtrl);
                }
                else if (obj is MaterialStreamControl)
                {
                    MaterialStreamControl persistedCtrl = (MaterialStreamControl)obj;
                    string solvableName           = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
                    DryingMaterialStream  stream  = flowsheet.EvaporationAndDryingSystem.GetMaterialStream(solvableName);
                    MaterialStreamControl newCtrl = new MaterialStreamControl(flowsheet, new Point(0, 0), stream);
                    newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
                    flowsheet.Controls.Add(newCtrl);
                }
                else if (obj is DryerControl)
                {
                    DryerControl persistedCtrl = (DryerControl)obj;
                    string       solvableName  = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
                    Dryer        uo            = flowsheet.EvaporationAndDryingSystem.GetDryer(solvableName);
                    DryerControl newCtrl       = new DryerControl(flowsheet, new Point(0, 0), uo);
                    newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
                    flowsheet.Controls.Add(newCtrl);
                }
                else if (obj is HeatExchangerControl)
                {
                    HeatExchangerControl persistedCtrl = (HeatExchangerControl)obj;
                    string               solvableName  = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
                    HeatExchanger        uo            = flowsheet.EvaporationAndDryingSystem.GetHeatExchanger(solvableName);
                    HeatExchangerControl newCtrl       = new HeatExchangerControl(flowsheet, new Point(0, 0), uo);
                    newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
                    flowsheet.Controls.Add(newCtrl);
                }
                else if (obj is CycloneControl)
                {
                    CycloneControl persistedCtrl = (CycloneControl)obj;
                    string         solvableName  = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
                    Cyclone        uo            = flowsheet.EvaporationAndDryingSystem.GetCyclone(solvableName);
                    CycloneControl newCtrl       = new CycloneControl(flowsheet, new Point(0, 0), uo);
                    newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
                    flowsheet.Controls.Add(newCtrl);
                }
                else if (obj is EjectorControl)
                {
                    EjectorControl persistedCtrl = (EjectorControl)obj;
                    string         solvableName  = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
                    Ejector        uo            = flowsheet.EvaporationAndDryingSystem.GetEjector(solvableName);
                    EjectorControl newCtrl       = new EjectorControl(flowsheet, new Point(0, 0), uo);
                    newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
                    flowsheet.Controls.Add(newCtrl);
                }
                else if (obj is WetScrubberControl)
                {
                    WetScrubberControl persistedCtrl = (WetScrubberControl)obj;
                    string             solvableName  = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
                    WetScrubber        uo            = flowsheet.EvaporationAndDryingSystem.GetWetScrubber(solvableName);
                    WetScrubberControl newCtrl       = new WetScrubberControl(flowsheet, new Point(0, 0), uo);
                    newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
                    flowsheet.Controls.Add(newCtrl);
                }
                else if (obj is ScrubberCondenserControl)
                {
                    ScrubberCondenserControl persistedCtrl = (ScrubberCondenserControl)obj;
                    string                   solvableName  = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
                    ScrubberCondenser        uo            = flowsheet.EvaporationAndDryingSystem.GetScrubberCondenser(solvableName);
                    ScrubberCondenserControl newCtrl       = new ScrubberCondenserControl(flowsheet, new Point(0, 0), uo);
                    newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
                    flowsheet.Controls.Add(newCtrl);
                }
                else if (obj is MixerControl)
                {
                    MixerControl persistedCtrl = (MixerControl)obj;
                    string       solvableName  = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
                    Mixer        uo            = flowsheet.EvaporationAndDryingSystem.GetMixer(solvableName);
                    MixerControl newCtrl       = new MixerControl(flowsheet, new Point(0, 0), uo);
                    newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
                    flowsheet.Controls.Add(newCtrl);
                }
                else if (obj is TeeControl)
                {
                    TeeControl persistedCtrl = (TeeControl)obj;
                    string     solvableName  = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
                    Tee        uo            = flowsheet.EvaporationAndDryingSystem.GetTee(solvableName);
                    TeeControl newCtrl       = new TeeControl(flowsheet, new Point(0, 0), uo);
                    newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
                    flowsheet.Controls.Add(newCtrl);
                }
                else if (obj is FlashTankControl)
                {
                    FlashTankControl persistedCtrl = (FlashTankControl)obj;
                    string           solvableName  = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
                    FlashTank        uo            = flowsheet.EvaporationAndDryingSystem.GetFlashTank(solvableName);
                    FlashTankControl newCtrl       = new FlashTankControl(flowsheet, new Point(0, 0), uo);
                    newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
                    flowsheet.Controls.Add(newCtrl);
                }
                else if (obj is FanControl)
                {
                    FanControl persistedCtrl = (FanControl)obj;
                    string     solvableName  = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
                    Fan        uo            = flowsheet.EvaporationAndDryingSystem.GetFan(solvableName);
                    FanControl newCtrl       = new FanControl(flowsheet, new Point(0, 0), uo);
                    newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
                    flowsheet.Controls.Add(newCtrl);
                }
                else if (obj is ValveControl)
                {
                    ValveControl persistedCtrl = (ValveControl)obj;
                    string       solvableName  = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
                    Valve        uo            = flowsheet.EvaporationAndDryingSystem.GetValve(solvableName);
                    ValveControl newCtrl       = new ValveControl(flowsheet, new Point(0, 0), uo);
                    newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
                    flowsheet.Controls.Add(newCtrl);
                }
                else if (obj is BagFilterControl)
                {
                    BagFilterControl persistedCtrl = (BagFilterControl)obj;
                    string           solvableName  = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
                    BagFilter        uo            = flowsheet.EvaporationAndDryingSystem.GetBagFilter(solvableName);
                    BagFilterControl newCtrl       = new BagFilterControl(flowsheet, new Point(0, 0), uo);
                    newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
                    flowsheet.Controls.Add(newCtrl);
                }
                else if (obj is AirFilterControl)
                {
                    AirFilterControl persistedCtrl = (AirFilterControl)obj;
                    string           solvableName  = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
                    AirFilter        uo            = flowsheet.EvaporationAndDryingSystem.GetAirFilter(solvableName);
                    AirFilterControl newCtrl       = new AirFilterControl(flowsheet, new Point(0, 0), uo);
                    newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
                    flowsheet.Controls.Add(newCtrl);
                }
                else if (obj is CompressorControl)
                {
                    CompressorControl persistedCtrl = (CompressorControl)obj;
                    string            solvableName  = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
                    Compressor        uo            = flowsheet.EvaporationAndDryingSystem.GetCompressor(solvableName);
                    CompressorControl newCtrl       = new CompressorControl(flowsheet, new Point(0, 0), uo);
                    newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
                    flowsheet.Controls.Add(newCtrl);
                }
                else if (obj is HeaterControl)
                {
                    HeaterControl persistedCtrl = (HeaterControl)obj;
                    string        solvableName  = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
                    Heater        uo            = flowsheet.EvaporationAndDryingSystem.GetHeater(solvableName);
                    HeaterControl newCtrl       = new HeaterControl(flowsheet, new Point(0, 0), uo);
                    newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
                    flowsheet.Controls.Add(newCtrl);
                }
                else if (obj is CoolerControl)
                {
                    CoolerControl persistedCtrl = (CoolerControl)obj;
                    string        solvableName  = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
                    Cooler        uo            = flowsheet.EvaporationAndDryingSystem.GetCooler(solvableName);
                    CoolerControl newCtrl       = new CoolerControl(flowsheet, new Point(0, 0), uo);
                    newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
                    flowsheet.Controls.Add(newCtrl);
                }
                else if (obj is ElectrostaticPrecipitatorControl)
                {
                    ElectrostaticPrecipitatorControl persistedCtrl = (ElectrostaticPrecipitatorControl)obj;
                    string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
                    ElectrostaticPrecipitator        uo      = flowsheet.EvaporationAndDryingSystem.GetElectrostaticPrecipitator(solvableName);
                    ElectrostaticPrecipitatorControl newCtrl = new ElectrostaticPrecipitatorControl(flowsheet, new Point(0, 0), uo);
                    newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
                    flowsheet.Controls.Add(newCtrl);
                }
                else if (obj is PumpControl)
                {
                    PumpControl persistedCtrl = (PumpControl)obj;
                    string      solvableName  = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
                    Pump        uo            = flowsheet.EvaporationAndDryingSystem.GetPump(solvableName);
                    PumpControl newCtrl       = new PumpControl(flowsheet, new Point(0, 0), uo);
                    newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
                    flowsheet.Controls.Add(newCtrl);
                }
                else if (obj is RecycleControl)
                {
                    RecycleControl persistedCtrl = (RecycleControl)obj;
                    string         solvableName  = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
                    Recycle        uo            = flowsheet.EvaporationAndDryingSystem.GetRecycle(solvableName);
                    RecycleControl newCtrl       = new RecycleControl(flowsheet, new Point(0, 0), uo);
                    newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
                    flowsheet.Controls.Add(newCtrl);
                }
                else if (obj is SolvableConnection)
                {
                    SolvableConnection persistedDc = (SolvableConnection)obj;
                    SolvableConnection dc          = new SolvableConnection(flowsheet);
                    dc.SetObjectData(persistedDc.SerializationInfo, persistedDc.StreamingContext);
                    dc.UpdateConnection();
                    flowsheet.ConnectionManager.AddConnection(dc);
                }
                else if (obj is FlowsheetPreferences)
                {
                    FlowsheetPreferences flowsheetPrefs = obj as FlowsheetPreferences;
                    flowsheetPrefs.SetObjectData(flowsheetPrefs.SerializationInfo, flowsheetPrefs.StreamingContext);
                    flowsheet.BackColor = flowsheetPrefs.BackColor;
                }
                else if (obj is ProsimoUI.CustomEditor.CustomEditor)
                {
                    ProsimoUI.CustomEditor.CustomEditor persistedEditor = (ProsimoUI.CustomEditor.CustomEditor)obj;
                    flowsheet.CustomEditor.SetObjectData(persistedEditor.SerializationInfo, persistedEditor.StreamingContext);
                }
                else if (obj is FlowsheetVersion)
                {
                    flowsheetVersion = obj as FlowsheetVersion;
                    flowsheetVersion.SetObjectData(flowsheetVersion.SerializationInfo, flowsheetVersion.StreamingContext);
                }
            }

            if (flowsheetVersion != null)
            {
                flowsheet.Version = flowsheetVersion;
            }

            FlowsheetVersionStatus flowsheetVersionStatus = CheckFlowsheetVersion(flowsheet);

            if (flowsheetVersionStatus == FlowsheetVersionStatus.Ok)
            {
                flowsheet.IsDirty = false;
            }
            else if (flowsheetVersionStatus == FlowsheetVersionStatus.Upgraded)
            {
                flowsheet.IsDirty = true;
            }
            else if (flowsheetVersionStatus == FlowsheetVersionStatus.NotOk)
            {
                flowsheet = null;
            }

            return(flowsheet);
        }
Ejemplo n.º 5
0
        public FlowsheetPreferencesForm(Flowsheet flowsheet)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            if (flowsheet != null)
            {
                this.flowsheet = flowsheet;
                EvaporationAndDryingSystem system = this.flowsheet.EvaporationAndDryingSystem;
                this.textBoxDryingGas.Text      = system.DryingGas.ToString();
                this.textBoxDryingMaterial.Text = system.DryingMaterial.ToString();
                this.SetPreferences();

                //
                unitSystemsCtrl = new UnitSystemsControl();
                this.tabPageUnits.Controls.Add(unitSystemsCtrl);
                unitSystemsCtrl.Location = new Point(0, 0);

                UnitSystem unitSystem = unitSystemsCtrl.GetSelectedUnitSystem();
                int        selIdx     = unitSystemsCtrl.GetSelectedIndex();
                this.buttonCurrentUnitSys.Enabled = false;
                if (selIdx >= 0)
                {
                    if (unitSystem != null)
                    {
                        this.buttonCurrentUnitSys.Enabled = true;
                    }
                }

                UnitSystem currentUnitSystem = UnitSystemService.GetInstance().CurrentUnitSystem;
                this.labelCurrent.Text = this.CURRENT_UNIT_SYS + currentUnitSystem.Name;
                unitSystemsCtrl.SelectedUnitSystemChanged += new SelectedUnitSystemChangedEventHandler(unitSystemsCtrl_SelectedUnitSystemChanged);

                //
                SelectSolvablesControl selectSolvablesControl = new SelectSolvablesControl(flowsheet);
                selectSolvablesControl.Location = new Point(4, 4);
                this.tabPageEditor.Controls.Add(selectSolvablesControl);

                this.domainUpDownDecPlaces.SelectedItem = this.flowsheet.DecimalPlaces;
                if (this.flowsheet.NumericFormat.Equals(NumericFormat.FixedPoint))
                {
                    this.radioButtonFixedPoint.Checked = true;
                }
                else if (this.flowsheet.NumericFormat.Equals(NumericFormat.Scientific))
                {
                    this.radioButtonScientific.Checked = true;
                }
            }

/*
 *       else
 *       {
 *          // 0 = types
 *          // 1 = unit systems
 *          // 2 = show in editor
 *          // 3 = numeric format
 *          this.tabControlPrefs.Controls.RemoveAt(3);
 *          this.tabControlPrefs.Controls.RemoveAt(2);
 *          this.tabControlPrefs.Controls.RemoveAt(1);
 *
 *          this.groupBoxHeatExchangerInletType.Visible = false;
 *          this.groupBoxUnitOpCreation.Visible = false;
 *          this.groupBoxTeeMixerValveStreamsType.Visible = false;
 *       }
 */
        }
Ejemplo n.º 6
0
        private FlowsheetVersionStatus CheckFlowsheetVersion(Flowsheet flowsheet)
        {
            FlowsheetVersionStatus versionStatus = FlowsheetVersionStatus.Ok;

            string        messageObsolete1 = "You are trying to open a newer version of the flowsheet with an older version of the software!";
            string        messageObsolete2 = "Please use Version " + flowsheet.Version.Major.ToString() + "." + flowsheet.Version.Minor.ToString();
            string        messageObsolete3 = " (Build " + flowsheet.Version.Build.ToString() + ") or higher of the software, to open this flowsheet.";
            StringBuilder sb = new StringBuilder();

            sb.Append(messageObsolete1);
            sb.Append("\r\n");
            sb.Append(messageObsolete2);
            sb.Append(messageObsolete3);
            string messageObsolete = sb.ToString();

            Version softwareVersion = new Version(ApplicationInformation.VERSION);

            if (flowsheet.Version.Major > softwareVersion.Major)
            {
                // goodbye
                versionStatus = FlowsheetVersionStatus.NotOk;
                MessageBox.Show(messageObsolete, "Open Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else if (flowsheet.Version.Major < softwareVersion.Major)
            {
                // convert
                if (this.DoYouWantToConvertOlderFlowsheet())
                {
                    // DO THE CONVERSION

                    flowsheet.Version.Major = softwareVersion.Major;
                    flowsheet.Version.Minor = softwareVersion.Minor;
                    flowsheet.Version.Build = softwareVersion.Build;
                    versionStatus           = FlowsheetVersionStatus.Upgraded;
                }
            }
            else if (flowsheet.Version.Major == softwareVersion.Major)
            {
                if (flowsheet.Version.Minor > softwareVersion.Minor)
                {
                    // goodbye
                    versionStatus = FlowsheetVersionStatus.NotOk;
                    MessageBox.Show(messageObsolete, "Open Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else if (flowsheet.Version.Minor < softwareVersion.Minor)
                {
                    // convert
                    if (this.DoYouWantToConvertOlderFlowsheet())
                    {
                        // DO THE CONVERSION

                        flowsheet.Version.Minor = softwareVersion.Minor;
                        flowsheet.Version.Build = softwareVersion.Build;
                        versionStatus           = FlowsheetVersionStatus.Upgraded;
                    }
                }
                else if (flowsheet.Version.Minor == softwareVersion.Minor)
                {
                    if (flowsheet.Version.Build > softwareVersion.Build)
                    {
                        // goodbye
                        versionStatus = FlowsheetVersionStatus.NotOk;
                        MessageBox.Show(messageObsolete, "Open Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    else if (flowsheet.Version.Build < softwareVersion.Build)
                    {
                        // convert
                        if (this.DoYouWantToConvertOlderFlowsheet())
                        {
                            // DO THE CONVERSION

                            flowsheet.Version.Build = softwareVersion.Build;
                            versionStatus           = FlowsheetVersionStatus.Upgraded;
                        }
                    }
                    else if (flowsheet.Version.Build == softwareVersion.Build)
                    {
                        // ok
                    }
                }
            }

            return(versionStatus);
        }
Ejemplo n.º 7
0
        //version 2 addition

        public FlowsheetPreferences(Flowsheet flowsheet)
        {
            this.backColor = flowsheet.BackColor;

            SetFlowsheetPrefs(flowsheet);
        }
Ejemplo n.º 8
0
 public FlowsheetPreferences(Flowsheet flowsheet)
 {
     this.currentUnitSystemName = flowsheet.CurrentUnitSystemName;
     this.numericFormat         = flowsheet.NumericFormat;
     this.decimalPlaces         = flowsheet.DecimalPlaces;
 }
Ejemplo n.º 9
0
 public SolvableConnection(Flowsheet flowsheet)
 {
     this.flowsheet = flowsheet;
 }
Ejemplo n.º 10
0
      private Flowsheet SetFlowsheetContent(NewSystemPreferences newSystemPrefs, ArrayList items)
      {
         Flowsheet flowsheet = null;
         IEnumerator e = items.GetEnumerator();
         while (e.MoveNext())
         {
            object obj = e.Current;
            
            if (obj is EvaporationAndDryingSystem)
            {
               EvaporationAndDryingSystem persisted = (EvaporationAndDryingSystem)obj;
               persisted.SetObjectData();
               flowsheet = new Flowsheet(newSystemPrefs, persisted);
            }  

            else if (obj is GasStreamControl)
            {
               GasStreamControl persistedCtrl = (GasStreamControl)obj;
               string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
               DryingGasStream stream = flowsheet.EvaporationAndDryingSystem.GetGasStream(solvableName);
               GasStreamControl newCtrl = new GasStreamControl(flowsheet, new Point(0,0), stream); 
               newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
               flowsheet.Controls.Add(newCtrl);
            }
            else if (obj is MaterialStreamControl)
            {
               MaterialStreamControl persistedCtrl = (MaterialStreamControl)obj;
               string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
               DryingMaterialStream stream = flowsheet.EvaporationAndDryingSystem.GetMaterialStream(solvableName);
               MaterialStreamControl newCtrl = new MaterialStreamControl(flowsheet, new Point(0,0), stream); 
               newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
               flowsheet.Controls.Add(newCtrl);
            }
            else if (obj is DryerControl)
            {
               DryerControl persistedCtrl = (DryerControl)obj;
               string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
               Dryer uo = flowsheet.EvaporationAndDryingSystem.GetDryer(solvableName);
               DryerControl newCtrl = new DryerControl(flowsheet, new Point(0,0), uo); 
               newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
               flowsheet.Controls.Add(newCtrl);
            }
            else if (obj is HeatExchangerControl)
            {
               HeatExchangerControl persistedCtrl = (HeatExchangerControl)obj;
               string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
               HeatExchanger uo = flowsheet.EvaporationAndDryingSystem.GetHeatExchanger(solvableName);
               HeatExchangerControl newCtrl = new HeatExchangerControl(flowsheet, new Point(0,0), uo); 
               newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
               flowsheet.Controls.Add(newCtrl);
            }
            else if (obj is CycloneControl)
            {
               CycloneControl persistedCtrl = (CycloneControl)obj;
               string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
               Cyclone uo = flowsheet.EvaporationAndDryingSystem.GetCyclone(solvableName);
               CycloneControl newCtrl = new CycloneControl(flowsheet, new Point(0,0), uo); 
               newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
               flowsheet.Controls.Add(newCtrl);
            }
            else if (obj is EjectorControl)
            {
               EjectorControl persistedCtrl = (EjectorControl)obj;
               string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
               Ejector uo = flowsheet.EvaporationAndDryingSystem.GetEjector(solvableName);
               EjectorControl newCtrl = new EjectorControl(flowsheet, new Point(0,0), uo); 
               newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
               flowsheet.Controls.Add(newCtrl);
            }
            else if (obj is WetScrubberControl)
            {
               WetScrubberControl persistedCtrl = (WetScrubberControl)obj;
               string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
               WetScrubber uo = flowsheet.EvaporationAndDryingSystem.GetWetScrubber(solvableName);
               WetScrubberControl newCtrl = new WetScrubberControl(flowsheet, new Point(0,0), uo); 
               newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
               flowsheet.Controls.Add(newCtrl);
            }
            else if (obj is MixerControl)
            {
               MixerControl persistedCtrl = (MixerControl)obj;
               string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
               Mixer uo = flowsheet.EvaporationAndDryingSystem.GetMixer(solvableName);
               MixerControl newCtrl = new MixerControl(flowsheet, new Point(0,0), uo); 
               newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
               flowsheet.Controls.Add(newCtrl);
            }
            else if (obj is TeeControl)
            {
               TeeControl persistedCtrl = (TeeControl)obj;
               string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
               Tee uo = flowsheet.EvaporationAndDryingSystem.GetTee(solvableName);
               TeeControl newCtrl = new TeeControl(flowsheet, new Point(0,0), uo); 
               newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
               flowsheet.Controls.Add(newCtrl);
            }
            else if (obj is FlashTankControl)
            {
               FlashTankControl persistedCtrl = (FlashTankControl)obj;
               string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
               FlashTank uo = flowsheet.EvaporationAndDryingSystem.GetFlashTank(solvableName);
               FlashTankControl newCtrl = new FlashTankControl(flowsheet, new Point(0,0), uo); 
               newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
               flowsheet.Controls.Add(newCtrl);
            }
            else if (obj is FanControl)
            {
               FanControl persistedCtrl = (FanControl)obj;
               string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
               Fan uo = flowsheet.EvaporationAndDryingSystem.GetFan(solvableName);
               FanControl newCtrl = new FanControl(flowsheet, new Point(0,0), uo); 
               newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
               flowsheet.Controls.Add(newCtrl);
            }
            else if (obj is ValveControl)
            {
               ValveControl persistedCtrl = (ValveControl)obj;
               string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
               Valve uo = flowsheet.EvaporationAndDryingSystem.GetValve(solvableName);
               ValveControl newCtrl = new ValveControl(flowsheet, new Point(0,0), uo); 
               newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
               flowsheet.Controls.Add(newCtrl);
            }
            else if (obj is BagFilterControl)
            {
               BagFilterControl persistedCtrl = (BagFilterControl)obj;
               string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
               BagFilter uo = flowsheet.EvaporationAndDryingSystem.GetBagFilter(solvableName);
               BagFilterControl newCtrl = new BagFilterControl(flowsheet, new Point(0,0), uo); 
               newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
               flowsheet.Controls.Add(newCtrl);
            }
            else if (obj is AirFilterControl)
            {
               AirFilterControl persistedCtrl = (AirFilterControl)obj;
               string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
               AirFilter uo = flowsheet.EvaporationAndDryingSystem.GetAirFilter(solvableName);
               AirFilterControl newCtrl = new AirFilterControl(flowsheet, new Point(0,0), uo); 
               newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
               flowsheet.Controls.Add(newCtrl);
            }
            else if (obj is CompressorControl)
            {
               CompressorControl persistedCtrl = (CompressorControl)obj;
               string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
               Compressor uo = flowsheet.EvaporationAndDryingSystem.GetCompressor(solvableName);
               CompressorControl newCtrl = new CompressorControl(flowsheet, new Point(0,0), uo); 
               newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
               flowsheet.Controls.Add(newCtrl);
            }
            else if (obj is HeaterControl)
            {
               HeaterControl persistedCtrl = (HeaterControl)obj;
               string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
               Heater uo = flowsheet.EvaporationAndDryingSystem.GetHeater(solvableName);
               HeaterControl newCtrl = new HeaterControl(flowsheet, new Point(0,0), uo); 
               newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
               flowsheet.Controls.Add(newCtrl);
            }
            else if (obj is CoolerControl)
            {
               CoolerControl persistedCtrl = (CoolerControl)obj;
               string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
               Cooler uo = flowsheet.EvaporationAndDryingSystem.GetCooler(solvableName);
               CoolerControl newCtrl = new CoolerControl(flowsheet, new Point(0,0), uo); 
               newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
               flowsheet.Controls.Add(newCtrl);
            }
            else if (obj is ElectrostaticPrecipitatorControl)
            {
               ElectrostaticPrecipitatorControl persistedCtrl = (ElectrostaticPrecipitatorControl)obj;
               string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
               ElectrostaticPrecipitator uo = flowsheet.EvaporationAndDryingSystem.GetElectrostaticPrecipitator(solvableName);
               ElectrostaticPrecipitatorControl newCtrl = new ElectrostaticPrecipitatorControl(flowsheet, new Point(0,0), uo); 
               newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
               flowsheet.Controls.Add(newCtrl);
            }
            else if (obj is PumpControl)
            {
               PumpControl persistedCtrl = (PumpControl)obj;
               string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
               Pump uo = flowsheet.EvaporationAndDryingSystem.GetPump(solvableName);
               PumpControl newCtrl = new PumpControl(flowsheet, new Point(0,0), uo); 
               newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
               flowsheet.Controls.Add(newCtrl);
            }
            else if (obj is RecycleControl)
            {
               RecycleControl persistedCtrl = (RecycleControl)obj;
               string solvableName = (string)persistedCtrl.SerializationInfo.GetValue("SolvableName", typeof(string));
               Recycle uo = flowsheet.EvaporationAndDryingSystem.GetRecycle(solvableName);
               RecycleControl newCtrl = new RecycleControl(flowsheet, new Point(0,0), uo); 
               newCtrl.SetObjectData(persistedCtrl.SerializationInfo, persistedCtrl.StreamingContext);
               flowsheet.Controls.Add(newCtrl);
            }
            else if (obj is SolvableConnection)
            {
               SolvableConnection persistedDc = (SolvableConnection)obj;
               SolvableConnection dc = new SolvableConnection(flowsheet);
               dc.SetObjectData(persistedDc.SerializationInfo, persistedDc.StreamingContext);
               flowsheet.ConnectionManager.Connections.Add(dc);
            }
            else if (obj is FlowsheetPreferences)
            {
               FlowsheetPreferences flowsheetPrefs = obj as FlowsheetPreferences;
               flowsheetPrefs.SetObjectData(flowsheetPrefs.SerializationInfo, flowsheetPrefs.StreamingContext);
               flowsheet.InitializeCurrentUnitSystem(flowsheetPrefs.CurrentUnitSystemName);
               flowsheet.NumericFormat = flowsheetPrefs.NumericFormat;
               flowsheet.DecimalPlaces = flowsheetPrefs.DecimalPlaces;
            }
            else if (obj is ProsimoUI.CustomEditor.CustomEditor)
            {
               ProsimoUI.CustomEditor.CustomEditor persistedEditor = (ProsimoUI.CustomEditor.CustomEditor)obj;
               flowsheet.CustomEditor.SetObjectData(persistedEditor.SerializationInfo, persistedEditor.StreamingContext);
            }
         }

         if (this.CheckFlowsheetVersion(items, flowsheet))
            flowsheet.IsDirty = false;
         else
            flowsheet = null;

         return flowsheet;
      }
Ejemplo n.º 11
0
      private bool CheckFlowsheetVersion(ArrayList items, Flowsheet flowsheet)
      {
         bool ok = false;
         IEnumerator e2 = items.GetEnumerator();
         while (e2.MoveNext())
         {
            object obj = e2.Current;
            if (obj is FlowsheetVersion)
            {
               FlowsheetVersion flowsheetVersion = obj as FlowsheetVersion;
               flowsheetVersion.SetObjectData(flowsheetVersion.SerializationInfo, flowsheetVersion.StreamingContext);

               string messageObsolete1 = "You are trying to open a newer version of the flowsheet with an older version of the software!";
               string messageObsolete2 = "Please use Version " + flowsheetVersion.Major.ToString() + "." + flowsheetVersion.Minor.ToString();
               string messageObsolete3 = " (Build " + flowsheetVersion.Build.ToString() + ") or higher of the software, to open this flowsheet.";
               StringBuilder sb = new StringBuilder();
               sb.Append(messageObsolete1);
               sb.Append("\r\n");
               sb.Append(messageObsolete2);
               sb.Append(messageObsolete3);
               string messageObsolete = sb.ToString();

               Version softwareVersion = new Version(Application.ProductVersion);
               if (flowsheetVersion.Major > softwareVersion.Major)
               {
                  // goodbye
                  MessageBox.Show(messageObsolete, "Open Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
               }
               else if (flowsheetVersion.Major < softwareVersion.Major)
               {
                  // convert
                  if (this.DoYouWantToConvertOlderFlowsheet())
                  {
                     // DO THE CONVERSION

                     flowsheet.Version = flowsheetVersion;
                     ok = true;
                  }
               }
               else if (flowsheetVersion.Major == softwareVersion.Major)
               {
                  if (flowsheetVersion.Minor > softwareVersion.Minor)
                  {
                     // goodbye
                     MessageBox.Show(messageObsolete, "Open Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                  }
                  else if (flowsheetVersion.Minor < softwareVersion.Minor)
                  {
                     // convert
                     if (this.DoYouWantToConvertOlderFlowsheet())
                     {
                        // DO THE CONVERSION

                        flowsheet.Version = flowsheetVersion;
                        ok = true;
                     }
                  }
                  else if (flowsheetVersion.Minor == softwareVersion.Minor)
                  {
                     if (flowsheetVersion.Build > softwareVersion.Build)
                     {
                        // goodbye
                        MessageBox.Show(messageObsolete, "Open Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                     }
                     else if (flowsheetVersion.Build < softwareVersion.Build)
                     {
                        // convert
                        if (this.DoYouWantToConvertOlderFlowsheet())
                        {
                           // DO THE CONVERSION

                           flowsheet.Version = flowsheetVersion;
                           ok = true;
                        }
                     }
                     else if (flowsheetVersion.Build == softwareVersion.Build)
                     {
                        flowsheet.Version = flowsheetVersion;
                        ok = true;
                     }
                  }
               }
            }
         }