Exemple #1
0
 private void UpdateVariableValue(UnitSystem unitSystem)
 {
     if (this.var is ProcessVarDouble)
     {
         ProcessVarDouble varDouble = (ProcessVarDouble)this.var;
         double           val       = UnitSystemService.GetInstance().ConvertFromSIValue(this.var.Type, varDouble.Value);
         if (varDouble.Value == Constants.NO_VALUE)
         {
             this.Text = "";
         }
         else
         {
             this.Text = val.ToString(this.iNumericFormat.NumericFormatString);
         }
     }
     else if (this.var is ProcessVarInt)
     {
         ProcessVarInt varInt = (ProcessVarInt)this.var;
         if (varInt.Value == Constants.NO_VALUE_INT)
         {
             this.Text = "";
         }
         else
         {
             this.Text = varInt.Value.ToString(UI.DECIMAL);
         }
     }
 }
Exemple #2
0
        public static string GetVariableValue(ProcessVar var, UnitSystem unitSystem, string numericFormatStr)
        {
            string valStr = null;

            if (var is ProcessVarDouble)
            {
                ProcessVarDouble varDouble = (ProcessVarDouble)var;
                double           val       = UnitSystemService.GetInstance().ConvertFromSIValue(var.Type, varDouble.Value);
                if (varDouble.Value == Constants.NO_VALUE)
                {
                    valStr = "";
                }
                else
                {
                    valStr = val.ToString(numericFormatStr);
                }
            }
            else if (var is ProcessVarInt)
            {
                ProcessVarInt varInt = (ProcessVarInt)var;
                if (varInt.Value == Constants.NO_VALUE_INT)
                {
                    valStr = "";
                }
                else
                {
                    valStr = varInt.Value.ToString(UI.DECIMAL);
                }
            }
            return(valStr);
        }
Exemple #3
0
        public UnitSystemsControl()
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            unitSystemCtrl = new UnitSystemControl();
            this.Controls.Add(this.unitSystemCtrl);
            this.unitSystemCtrl.Location = new Point(160, 5);

            IList       unitSystems = UnitSystemService.GetInstance().GetUnitSystemCatalog().GetList();
            IEnumerator e           = unitSystems.GetEnumerator();

            while (e.MoveNext())
            {
                this.listBoxUnitSystems.Items.Add((UnitSystem)e.Current);
            }
            this.listBoxUnitSystems.SetSelected(0, true);

            this.UpdateUnitSystemUI();
            UnitSystemCatalog unitSystemCatalog = UnitSystemService.GetInstance().GetUnitSystemCatalog();

            unitSystemCatalog.UnitSystemAdded   += new UnitSystemAddedEventHandler(unitSystemCatalog_UnitSystemAdded);
            unitSystemCatalog.UnitSystemDeleted += new UnitSystemDeletedEventHandler(unitSystemCatalog_UnitSystemDeleted);
            unitSystemCatalog.UnitSystemChanged += new UnitSystemChangedEventHandler(unitSystemCatalog_UnitSystemChanged);
        }
Exemple #4
0
        public void InitializeVariable(INumericFormat iNumericFormat, ProcessVar var)
        {
            if (var.Enabled)
            {
                this.iNumericFormat = iNumericFormat;
                this.var            = var;
                this.UpdateVariableValue(UnitSystemService.GetInstance().CurrentUnitSystem);
                if (this.var.Owner is Solvable)
                {
                    Solvable solvable = this.var.Owner as Solvable;
                    solvable.SolveComplete += new SolveCompleteEventHandler(solvable_SolveComplete);
                }
                else
                {
                    this.var.Owner.ProcessVarValueCommitted += new ProcessVarValueCommittedEventHandler(Owner_ProcessVarValueCommitted);
                }

                UnitSystemService.GetInstance().CurrentUnitSystemChanged += new CurrentUnitSystemChangedEventHandler(ProcessVarNonEditableTextBox_CurrentUnitSystemChanged);
                this.iNumericFormat.NumericFormatStringChanged += new NumericFormatStringChangedEventHandler(iNumericFormat_NumericFormatStringChanged);
            }
            else
            {
                this.Enabled = false;
            }
        }
Exemple #5
0
        public void InitializeVariable(INumericFormat iNumericFormat, ProcessVar var)
        {
            if (var.Enabled)
            {
                this.iNumericFormat = iNumericFormat;
                this.var            = var;
                this.UpdateVariableValue(UnitSystemService.GetInstance().CurrentUnitSystem);
                if (this.var.Owner is Solvable)
                {
                    Solvable solvable = this.var.Owner as Solvable;
                    solvable.SolveComplete += new SolveCompleteEventHandler(solvable_SolveComplete);
                }
                else
                {
                    this.var.Owner.ProcessVarValueCommitted += new ProcessVarValueCommittedEventHandler(Owner_ProcessVarValueCommitted);
                }

                UnitSystemService.GetInstance().CurrentUnitSystemChanged += new CurrentUnitSystemChangedEventHandler(ProcessVarTextBox_CurrentUnitSystemChanged);
                this.iNumericFormat.NumericFormatStringChanged += new NumericFormatStringChangedEventHandler(iNumericFormat_NumericFormatStringChanged);
                this.Validating += new System.ComponentModel.CancelEventHandler(ProcessVarTextBox_Validating);
                // NOTE: the subscription to the KeyUp event is done in the context where this textBox is used
            }
            else
            {
                this.Enabled = false;
            }
        }
Exemple #6
0
        /// <summary>
        /// initialize the process variable object
        /// </summary>
        /// <param name="iNumericFormat"></param>
        /// <param name="var"></param>
        public ProcessVarObj(INumericFormat iNumericFormat, ProcessVar var)
        {
            if (var.Enabled)
            {
                this.iNumericFormat = iNumericFormat;
                this.var            = var;
                this.UpdateVariableValue(UnitSystemService.GetInstance().CurrentUnitSystem);
                if (this.var.Owner is Solvable)
                {
                    Solvable solvable = this.var.Owner as Solvable;
                    solvable.SolveComplete += new SolveCompleteEventHandler(solvable_SolveComplete);
                }
                else
                {
                    this.var.Owner.ProcessVarValueCommitted += new ProcessVarValueCommittedEventHandler(Owner_ProcessVarValueCommitted);
                }

                UnitSystemService.GetInstance().CurrentUnitSystemChanged += new CurrentUnitSystemChangedEventHandler(ProcessVarTextBox_CurrentUnitSystemChanged);
                this.iNumericFormat.NumericFormatStringChanged += new NumericFormatStringChangedEventHandler(iNumericFormat_NumericFormatStringChanged);
                //     this.Validating += new System.ComponentModel.CancelEventHandler(ProcessVarTextBox_Validating);
            }
            else
            {
                //  this.Enabled = false;
            }
        }
Exemple #7
0
        public override string ToPrint()
        {
            UnitSystem    us  = UnitSystemService.GetInstance().CurrentUnitSystem;
            string        nfs = this.flowsheet.ApplicationPrefs.NumericFormatString;
            StringBuilder sb  = new StringBuilder();

            string ttip = "Drying Material Stream: ";

            if (this.MaterialStream.MaterialStateType == MaterialStateType.Liquid)
            {
                ttip = "Liquid Material Stream: ";
            }
            else if (this.MaterialStream.MaterialStateType == MaterialStateType.Solid)
            {
                ttip = "Solid Material Stream: ";
            }
            else if (this.MaterialStream.MaterialStateType == MaterialStateType.Sludge)
            {
                ttip = "Sludge Material Stream: ";
            }

            sb.Append(ttip);
            sb.Append(this.MaterialStream.Name);
            sb.Append("\r\n");
            sb.Append(UI.UNDERLINE);
            sb.Append("\r\n");

            sb.Append(ToPrintVarList());
            return(sb.ToString());
        }
Exemple #8
0
        public void PersistUnitSystemCatalog(string fileName)
        {
            //FileStream fs = null;
            try {
                //if (File.Exists(fileName)) {
                //   File.Copy(fileName, bakFileName, true);
                //   File.Delete(fileName);
                //}

                //fs = new FileStream(fileName, FileMode.Create);

                ArrayList customUnitSystems = UnitSystemService.GetInstance().GetUnitSystemCatalog().GetCustomUnitList();
                PersistFile(fileName, customUnitSystems);
                //SoapFormatter serializer = new SoapFormatter();
                //BinaryFormatter serializer = new BinaryFormatter();
                //serializer.AssemblyFormat = FormatterAssemblyStyle.Simple;
                //IFormatter serializer = GetPersistenceSerializer();
                //serializer.Serialize(fs, customUnitSystems);
            }
            catch (Exception e) {
                string message = e.ToString();
                MessageBox.Show(message, "Error Saving Unit System Catalog", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            //finally {
            //   if (fs != null) {
            //      fs.Flush();
            //      fs.Close();
            //   }
            //}
        }
Exemple #9
0
        public override string ToPrint()
        {
            UnitSystem    us  = UnitSystemService.GetInstance().CurrentUnitSystem;
            string        nfs = this.flowsheet.ApplicationPrefs.NumericFormatString;
            StringBuilder sb  = new StringBuilder();

            sb.Append("Bag Filter: ");
            sb.Append(this.BagFilter.Name);
            sb.Append("\r\n");
            sb.Append(UI.UNDERLINE);
            sb.Append("\r\n");

            sb.Append(base.ToPrint());

            sb.Append(UI.GetVariableName(this.BagFilter.BagDiameter, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.BagFilter.BagDiameter, us, nfs));
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.BagFilter.BagLength, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.BagFilter.BagLength, us, nfs));
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.BagFilter.NumberOfBags, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.BagFilter.NumberOfBags, us, nfs));
            sb.Append("\r\n");

            return(sb.ToString());
        }
Exemple #10
0
        protected string ToPrintVarList()
        {
            UnitSystem    us  = UnitSystemService.GetInstance().CurrentUnitSystem;
            string        nfs = this.flowsheet.ApplicationPrefs.NumericFormatString;
            StringBuilder sb  = new StringBuilder();

            sb.Append(SolvableDispalyTitle);
            sb.Append("\r\n");
            sb.Append(UI.UNDERLINE);
            sb.Append("\r\n");

            foreach (ProcessVar var in solvable.VarList)
            {
                if (var.Enabled)
                {
                    sb.Append(GetVariableName(var, us));
                    sb.Append(" = ");
                    sb.Append(GetVariableValue(var, us, nfs));
                    if (var.IsSpecified)
                    {
                        sb.Append(" * ");
                    }
                    sb.Append(UI.NEW_LINE);
                }
            }
            return(sb.ToString());
        }
Exemple #11
0
        public override string ToPrint()
        {
            UnitSystem    us  = UnitSystemService.GetInstance().CurrentUnitSystem;
            string        nfs = this.flowsheet.ApplicationPrefs.NumericFormatString;
            StringBuilder sb  = new StringBuilder();

            sb.Append("Ejector: ");
            sb.Append(this.Ejector.Name);
            sb.Append("\r\n");
            sb.Append(UI.UNDERLINE);
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.Ejector.EntrainmentRatio, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.Ejector.EntrainmentRatio, us, nfs));
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.Ejector.CompressionRatio, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.Ejector.CompressionRatio, us, nfs));
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.Ejector.SuctionMotivePressureRatio, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.Ejector.SuctionMotivePressureRatio, us, nfs));
            sb.Append("\r\n");

            return(sb.ToString());
        }
Exemple #12
0
        public bool UnpersistUnitSystemCatalog(string fileName)
        {
            bool ok = true;

            try {
                if (!File.Exists(fileName))
                {
                    fileName = GetBackupFileName(fileName);
                }

                if (File.Exists(fileName))
                {
                    ArrayList customUnitList = (ArrayList)UnpersistFile(fileName);

                    UnitSystemCatalog unitSystemCatalog = UnitSystemService.GetInstance().GetUnitSystemCatalog();

                    foreach (UnitSystem us in customUnitList)
                    {
                        us.SetObjectData();
                        unitSystemCatalog.Add(us);
                    }
                }
            }
            catch (Exception e) {
                ok = false;
                string message = e.ToString();
                MessageBox.Show(message, "Error Retrieving Unit System Catalog", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            return(ok);
        }
Exemple #13
0
        private void SetUnits(UnitSystem unitSystem)
        {
            string unitTemp = UnitSystemService.GetInstance().GetUnitAsString(PhysicalQuantity.Temperature);

            if (unitTemp != null && !unitTemp.Trim().Equals(""))
            {
                this.labelStart.Text = "Start Boiling Point" + " (" + unitTemp + ")";
                this.labelEnd.Text   = "End Boiling Point" + " (" + unitTemp + ")";
            }
            else
            {
                this.labelStart.Text = "Start Boiling Point";
                this.labelEnd.Text   = "End Boiling Point";
            }

            string unitMoistureCont = UnitSystemService.GetInstance().GetUnitAsString(PhysicalQuantity.MoistureContent);

            if (unitMoistureCont != null && !unitMoistureCont.Trim().Equals(""))
            {
                this.labelConcentration.Text = "Concentration" + " (" + unitMoistureCont + ")";
            }
            else
            {
                this.labelConcentration.Text = "Concentration";
            }
        }
Exemple #14
0
        public override string ToPrint()
        {
            UnitSystem    us  = UnitSystemService.GetInstance().CurrentUnitSystem;
            string        nfs = this.flowsheet.ApplicationPrefs.NumericFormatString;
            StringBuilder sb  = new StringBuilder();

            sb.Append("Heater: ");
            sb.Append(this.Heater.Name);
            sb.Append("\r\n");
            sb.Append(UI.UNDERLINE);
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.Heater.PressureDrop, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.Heater.PressureDrop, us, nfs));
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.Heater.HeatLoss, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.Heater.HeatLoss, us, nfs));
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.Heater.HeatInput, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.Heater.HeatInput, us, nfs));
            sb.Append("\r\n");

            return(sb.ToString());
        }
Exemple #15
0
 public void InitializeVariable(ProcessVar var)
 {
     this.var              = var;
     this.Text             = SolvableControl.GetVariableName(this.var, UnitSystemService.GetInstance().CurrentUnitSystem);
     this.var.NameChanged += new NameChangedEventHandler(var_NameChanged);
     UnitSystemService.GetInstance().CurrentUnitSystemChanged += new CurrentUnitSystemChangedEventHandler(ProcessVarLabel_CurrentUnitSystemChanged);
 }
Exemple #16
0
        public void SetDuhringLinesCache(DryingMaterialCache dryingMaterialCache, INumericFormat iNumericFormat)
        {
            this.SetUnits(UnitSystemService.GetInstance().CurrentUnitSystem);

            DuhringLinesCache duhringLinesCache = new DuhringLinesCache(dryingMaterialCache);

            this.UpdateTheUI(iNumericFormat, duhringLinesCache);
        }
Exemple #17
0
        public void SetOyMax(float max)
        {
            PhysicalQuantity pq     = this.yPlotVariable.Variable.Type;
            double           newMax = UnitSystemService.GetInstance().ConvertToSIValue(pq, (double)max);

            this.psychrometricChartModel.SetOyMax((double)newMax);
            this.UpdateCurrentStateOrProcess();
        }
Exemple #18
0
        private void buttonOk_Click(object sender, System.EventArgs e)
        {
            bool numericFormatOk = true;

            IEnumerator en = this.panelCenter.Controls.GetEnumerator();

            while (en.MoveNext())
            {
                Control ctrl = (Control)en.Current;
                if (ctrl is RecommProcVarElementControl)
                {
                    RecommProcVarElementControl pveCtrl = ctrl as RecommProcVarElementControl;
                    if (!pveCtrl.IsNewValueValid)
                    {
                        numericFormatOk = false;
                        break;
                    }
                }
            }

            if (numericFormatOk)
            {
                // build the hashtable with procVars and values
                Hashtable hashtable = new Hashtable();
                if (initialProcVar is ProcessVarDouble)
                {
                    double val = UnitSystemService.GetInstance().ConvertToSIValue(this.initialProcVar.Type, (double)initialVarNewValue);
                    hashtable.Add(this.initialProcVar, val);
                }
                else
                {
                    hashtable.Add(this.initialProcVar, (int)initialVarNewValue);
                }

                IEnumerator en2 = this.panelCenter.Controls.GetEnumerator();
                while (en2.MoveNext())
                {
                    Control ctrl = (Control)en2.Current;
                    if (ctrl is RecommProcVarElementControl)
                    {
                        RecommProcVarElementControl pveCtrl = ctrl as RecommProcVarElementControl;
                        hashtable.Add(pveCtrl.Variable, pveCtrl.NewValue);
                    }
                }

                ErrorMessage error = this.initialProcVar.Owner.Specify(hashtable);
                if (error != null)
                {
                    UI.ShowError(error);
                }
                this.Close();
            }
            else
            {
                string message = "Please enter numeric values!";
                MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Exemple #19
0
        public Flowsheet(NewSystemPreferences newSystemPrefs, EvaporationAndDryingSystem system)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            this.newSystemPrefs = newSystemPrefs;
            UnitSystemCatalog catalog = UnitSystemService.GetInstance().GetUnitSystemCatalog();
            UnitSystem        us      = catalog.Get("SI-2");

            UnitSystemService.GetInstance().CurrentUnitSystem = us;
            this.currentUnitSystemName = us.Name;

            this.MultipleSelection = false;
            this.Activity          = FlowsheetActivity.Default;

            if (system == null)
            {
                DryingGas dg = DryingGasCatalog.GetInstance().GetDryingGas(newSystemPrefs.DryingGasName);
                if (dg == null)
                {
                    dg = DryingGasCatalog.GetInstance().GetDryingGas("Air");
                }

                DryingMaterial dm = DryingMaterialCatalog.GetInstance().GetDryingMaterial(newSystemPrefs.DryingMaterialName);
                if (dm == null)
                {
                    dm = DryingMaterialCatalog.GetInstance().GetDryingMaterial("Generic Material");
                }

                this.evapAndDryingSystem = new EvaporationAndDryingSystem("New System", dm, dg);
            }
            else
            {
                this.evapAndDryingSystem = system;
            }

            this.evapAndDryingSystem.SystemChanged      += new SystemChangedEventHandler(evapAndDryingSystem_SystemChanged);
            this.evapAndDryingSystem.CalculationStarted += new CalculationStartedEventHandler(evapAndDryingSystem_CalculationStarted);
            this.evapAndDryingSystem.CalculationEnded   += new CalculationEndedEventHandler(evapAndDryingSystem_CalculationEnded);

            this.connectionManager = new ConnectionManager(this);
            this.customEditor      = new ProsimoUI.CustomEditor.CustomEditor(this);
            this.streamManager     = new StreamManager(this);
            this.unitOpManager     = new UnitOpManager(this);
            UI ui = new UI();

            this.BackColor     = ui.FLOWSHEET_COLOR;
            this.NumericFormat = NumericFormat.FixedPoint;
            this.DecimalPlaces = "3";
            this.Version       = new FlowsheetVersion();

            this.KeyDown += new KeyEventHandler(Flowsheet_KeyDown);
            this.KeyUp   += new KeyEventHandler(Flowsheet_KeyUp);
            UnitSystemService.GetInstance().CurrentUnitSystemChanged += new CurrentUnitSystemChangedEventHandler(Flowsheet_CurrentUnitSystemChanged);
            this.IsDirty = false;
        }
Exemple #20
0
        //
        private PointF Get_SI_DomainCoordinate(StateControl stateCtrl)
        {
            PointF domainCoordinate = this.plotCtrl.Graph.ConvertMousePosition(StateControl.RADIUS + stateCtrl.Location.X, StateControl.RADIUS + stateCtrl.Location.Y);
            double x = UnitSystemService.GetInstance().ConvertToSIValue(this.xPlotVariable.Variable.Type, (double)domainCoordinate.X);
            double y = UnitSystemService.GetInstance().ConvertToSIValue(this.yPlotVariable.Variable.Type, (double)domainCoordinate.Y);
            PointF p = new PointF((float)x, (float)y);

            return(p);
        }
Exemple #21
0
        private PointF ConvertFromSI(PointF siPoint)
        {
            float newX = (float)UnitSystemService.GetInstance().
                         ConvertFromSIValue(this.xPlotVariable.Variable.Type, siPoint.X);
            float newY = (float)UnitSystemService.GetInstance().
                         ConvertFromSIValue(this.yPlotVariable.Variable.Type, siPoint.Y);

            return(new PointF(newX, newY));
        }
Exemple #22
0
 protected override void Dispose(bool disposing)
 {
     if (this.var != null)
     {
         this.var.NameChanged -= new NameChangedEventHandler(var_NameChanged);
     }
     UnitSystemService.GetInstance().CurrentUnitSystemChanged -= new CurrentUnitSystemChangedEventHandler(ProcessVarLabel_CurrentUnitSystemChanged);
     base.Dispose(disposing);
 }
Exemple #23
0
        public override string ToPrintToolTip()
        {
            UnitSystem    us  = UnitSystemService.GetInstance().CurrentUnitSystem;
            string        nfs = this.flowsheet.ApplicationPrefs.NumericFormatString;
            StringBuilder sb  = new StringBuilder();

            string ttip = "Drying Material Stream: ";

            if (this.MaterialStream.MaterialStateType == MaterialStateType.Liquid)
            {
                ttip = "Liquid Material Stream: ";
            }
            else if (this.MaterialStream.MaterialStateType == MaterialStateType.Solid)
            {
                ttip = "Solid Material Stream: ";
            }
            else if (this.MaterialStream.MaterialStateType == MaterialStateType.Sludge)
            {
                ttip = "Sludge Material Stream: ";
            }

            sb.Append(ttip);
            sb.Append(this.MaterialStream.Name);
            sb.Append("\r\n");
            sb.Append(UI.UNDERLINE);
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.MaterialStream.MassFlowRate, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.MaterialStream.MassFlowRate, us, nfs));
            sb.Append("\r\n");

            if (this.MaterialStream.MaterialStateType == MaterialStateType.Liquid)
            {
                sb.Append(UI.GetVariableName(this.MaterialStream.VolumeFlowRate, us));
                sb.Append(" = ");
                sb.Append(UI.GetVariableValue(this.MaterialStream.VolumeFlowRate, us, nfs));
                sb.Append("\r\n");

                sb.Append(UI.GetVariableName(this.MaterialStream.Pressure, us));
                sb.Append(" = ");
                sb.Append(UI.GetVariableValue(this.MaterialStream.Pressure, us, nfs));
                sb.Append("\r\n");
            }

            sb.Append(UI.GetVariableName(this.MaterialStream.Temperature, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.MaterialStream.Temperature, us, nfs));
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.MaterialStream.MoistureContentDryBase, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.MaterialStream.MoistureContentDryBase, us, nfs));
            sb.Append("\r\n");

            return(sb.ToString());
        }
Exemple #24
0
        public void InitializeCurrentUnitSystem(string name)
        {
            UnitSystemCatalog catalog = UnitSystemService.GetInstance().GetUnitSystemCatalog();
            UnitSystem        us      = catalog.Get(name);

            if (us != null)
            {
                UnitSystemService.GetInstance().CurrentUnitSystem = us;
            }
        }
Exemple #25
0
 public static string GetVariableName(ProcessVar var, UnitSystem unitSystem)
 {
     string name = null;
      string unit = UnitSystemService.GetInstance().GetUnitAsString(var.Type);
      if (unit != null && !unit.Trim().Equals(""))
     name = var.VarTypeName + " (" + unit + ")";
      else
     name = var.VarTypeName;
      return name;
 }
Exemple #26
0
 public static AxisVariable ConvertToAxisVariable(PlotVariable pv)
 {
     // Note: this also converts the values from model's default Unit System to the current Unit System
      string currentUnit = UnitSystemService.GetInstance().GetUnitAsString(pv.Variable.Type);
      double currentMin = UnitSystemService.GetInstance().ConvertFromSIValue(pv.Variable.Type, pv.Min);
      double currentMax = UnitSystemService.GetInstance().ConvertFromSIValue(pv.Variable.Type, pv.Max);
      Range currentRange = new Range((float)currentMin, (float)currentMax);
      AxisVariable av = new AxisVariable(pv.Variable.Name, currentUnit, currentRange);
      return av;
 }
Exemple #27
0
        private void buttonCurrentUnitSys_Click(object sender, EventArgs e)
        {
            UnitSystem unitSystem = this.unitSystemsCtrl.GetSelectedUnitSystem();

            if (unitSystem != null && unitSystem != UnitSystemService.GetInstance().CurrentUnitSystem)
            {
                UnitSystemService.GetInstance().CurrentUnitSystem = unitSystem;
                this.labelCurrent.Text = this.CURRENT_UNIT_SYS + unitSystem.Name;
            }
        }
Exemple #28
0
 public void PersistUnitSystemCatalog(string fileName)
 {
     try {
         ArrayList customUnitSystems = UnitSystemService.GetInstance().GetUnitSystemCatalog().GetCustomUnitList();
         PersistFile(fileName, customUnitSystems);
     }
     catch (Exception e) {
         string message = e.ToString();
         MessageBox.Show(message, "Error Saving Unit System Catalog", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }
Exemple #29
0
        public void SetDuhringLinesCache(DryingMaterialCache dryingMaterialCache)
        {
            // TODO: from where to get the numeric format?
            MainNumericFormat iNumericFormat = new MainNumericFormat();

            this.SetUnits(UnitSystemService.GetInstance().CurrentUnitSystem);

            DuhringLinesCache duhringLinesCache = new DuhringLinesCache(dryingMaterialCache);

            this.UpdateTheUI(iNumericFormat, duhringLinesCache);
        }
Exemple #30
0
        public override string ToPrint()
        {
            UnitSystem    us  = UnitSystemService.GetInstance().CurrentUnitSystem;
            string        nfs = this.flowsheet.ApplicationPrefs.NumericFormatString;
            StringBuilder sb  = new StringBuilder();

            sb.Append("Electrostatic Precipitator: ");
            sb.Append(this.ElectrostaticPrecipitator.Name);
            sb.Append("\r\n");
            sb.Append(UI.UNDERLINE);
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.ElectrostaticPrecipitator.GasPressureDrop, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.ElectrostaticPrecipitator.GasPressureDrop, us, nfs));
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.ElectrostaticPrecipitator.CollectionEfficiency, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.ElectrostaticPrecipitator.CollectionEfficiency, us, nfs));
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.ElectrostaticPrecipitator.InletParticleLoading, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.ElectrostaticPrecipitator.InletParticleLoading, us, nfs));
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.ElectrostaticPrecipitator.OutletParticleLoading, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.ElectrostaticPrecipitator.OutletParticleLoading, us, nfs));
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.ElectrostaticPrecipitator.ParticleCollectionRate, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.ElectrostaticPrecipitator.ParticleCollectionRate, us, nfs));
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.ElectrostaticPrecipitator.MassFlowRateOfParticleLostToGasOutlet, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.ElectrostaticPrecipitator.MassFlowRateOfParticleLostToGasOutlet, us, nfs));
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.ElectrostaticPrecipitator.DriftVelocity, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.ElectrostaticPrecipitator.DriftVelocity, us, nfs));
            sb.Append("\r\n");

            sb.Append(UI.GetVariableName(this.ElectrostaticPrecipitator.TotalSurfaceArea, us));
            sb.Append(" = ");
            sb.Append(UI.GetVariableValue(this.ElectrostaticPrecipitator.TotalSurfaceArea, us, nfs));
            sb.Append("\r\n");

            return(sb.ToString());
        }