示例#1
0
        public override void SetObjectData()
        {
            base.SetObjectData();
            int persistedClassVersion = (int)info.GetValue("ClassPersistenceVersionProcessStreamBase", typeof(int));

            if (persistedClassVersion == 1)
            {
                this.materialComponents = RecallStorableObject("MaterialComponents", typeof(MaterialComponents)) as MaterialComponents;

                this.upStreamOwner   = info.GetValue("UpStreamOwner", typeof(UnitOperation)) as UnitOperation;
                this.downStreamOwner = info.GetValue("DownStreamOwner", typeof(UnitOperation)) as UnitOperation;

                //this.specificVolume = (ProcessVarDouble)info.GetValue("SpecificVolume", typeof(ProcessVarDouble));
                //this.dynamicViscosity = info.GetValue("DynamicViscosity", typeof(ProcessVarDouble)) as ProcessVarDouble;
                //this.thermalConductivity = info.GetValue("ThermalConductivity", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.massFlowRate     = RecallStorableObject("MassFlowRate", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.volumeFlowRate   = RecallStorableObject("VolumeFlowRate", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.vaporFraction    = RecallStorableObject("VaporFraction", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.pressure         = RecallStorableObject("Pressure", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.temperature      = RecallStorableObject("Temperature", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.specificEnthalpy = RecallStorableObject("SpecificEnthalpy", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.specificHeat     = RecallStorableObject("SpecificHeat", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.density          = RecallStorableObject("Density", typeof(ProcessVarDouble)) as ProcessVarDouble;
            }
        }
示例#2
0
        protected override void ValidatingHandler(object sender, System.ComponentModel.CancelEventArgs e)
        {
            UnitOperation unitOp = UnitOpCtrl.UnitOperation;
            TextBox       tb     = (TextBox)sender;

            if (tb.Text != null)
            {
                if (tb.Text.Trim().Equals(""))
                {
                    if (sender == this.textBoxName)
                    {
                        e.Cancel = true;
                        string message3 = "Please specify a name!";
                        MessageBox.Show(message3, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else
                {
                    if (sender == this.textBoxName)
                    {
                        ErrorMessage error = unitOp.SpecifyName(this.textBoxName.Text);
                        if (error != null)
                        {
                            UI.ShowError(error);
                        }
                    }
                }
            }
        }
示例#3
0
        public override async ETTask UnitOperationHandler(ETModel.Session session, UnitOperation message)
        {
            var unit = UnitComponent.Instance.Get(message.UnitId);

            if (unit == null)
            {
                return;
            }
            if (unit.BodyView == null)
            {
                return;
            }
            var newPosition = new Vector3(message.X / 100f, message.Y / 100f, message.Z / 100f);

            Log.Debug($"UnitOperationHandler newPosition {newPosition}");
            //unit.KinematicCharacterMotor.MoveCharacter(newPosition);
            unit.TransformComponent.SetPosition(newPosition);
            unit.Rotation = new Vector3(0, message.AngleY / 100f, 0);
            //if (message.Operation == OperaType.Fire)
            //{
            //	var x = (int)(message.IntParams[0] / 100f);
            //	var y = (int)(message.IntParams[1] / 100f);
            //	var z = (int)(message.IntParams[2] / 100f);
            //	var bulletType = message.IntParams[3];
            //	var bulletId = message.LongParams[0];
            //	unit.Fire(new Vector3(x, y, z), bulletType, bulletId);
            //}
            await ETTask.CompletedTask;
        }
示例#4
0
        public override void NetReceive(BinaryReader reader, bool lightReceive)
        {
            base.NetReceive(reader, lightReceive);
            if (TileEntity.ByPosition.ContainsKey(Position) && TileEntity.ByPosition[Position] is TEStorageUnit)
            {
                TEStorageUnit other = (TEStorageUnit)TileEntity.ByPosition[Position];
                items           = other.items;
                hasSpaceInStack = other.hasSpaceInStack;
                hasItem         = other.hasItem;
            }
            receiving = true;
            int  count = reader.ReadUInt16();
            bool flag  = false;

            for (int k = 0; k < count; k++)
            {
                if (UnitOperation.Receive(reader, this))
                {
                    flag = true;
                }
            }
            if (flag)
            {
                RepairMetadata();
            }
            receiving = false;
        }
示例#5
0
        public static Bullet Fire(this Unit self, UnitOperation message)
        {
            var bullet = EntityFactory.Create <Bullet>(self.Domain);

            bullet.OwnerId = self.Id;
            bullet.Setup(self.Position);

            var msg = new M2C_OnEnterView();

            msg.EnterEntity                 = new EntiyInfo();
            msg.EnterEntity.Type            = EntityDefine.GetTypeId <Bullet>();
            msg.EnterEntity.BsonBytes.bytes = MongoHelper.ToBson(bullet);
            var p = bullet.Position;

            msg.X = (int)(p.x * 100);
            msg.Y = (int)(p.y * 100);
            msg.Z = (int)(p.z * 100);
            MessageHelper.Broadcast(self.Domain, msg);

            var targetPoint = new Vector3();

            targetPoint.x = message.IntParams[0] / 100f;
            targetPoint.y = message.IntParams[1] / 100f;
            targetPoint.z = message.IntParams[2] / 100f;
            bullet.MoveTo(targetPoint);
            return(bullet);
        }
示例#6
0
        public override SolvableConnection CreateConnection(UnitOperation uo, ProcessStreamBase ps, int ad)
        {
            //StreamType streamType = StreamType.Unknown;
            //if (ps is DryingGasStream) {
            //   streamType = StreamType.Gas;
            //}
            //else if (ps is ProcessStream) {
            //   streamType = StreamType.Process;
            //}
            //else if (ps is DryingMaterialStream) {
            //   streamType = StreamType.Material;
            //}

            ProcessStreamBaseControl ctrl = this.flowsheet.StreamManager.GetProcessStreamBaseControl(ps);
            SolvableConnection       conn = null;

            if (ad > 0)
            {
                int              strIdx         = ProcessStreamBaseControl.OUT_INDEX;
                string           strName        = ctrl.Solvable.Name;
                Point            strPoint       = ctrl.GetOutConnectionPoint();
                PointOrientation strOrientation = ctrl.OutOrientation;
                ConnectionPoint  strConnPoint   = new ConnectionPoint(strIdx, strName, strPoint, strOrientation);

                int              uoIdx         = ad;
                string           uoName        = this.solvable.Name;
                Point            uoPoint       = this.GetStreamInConnectionPoint(ad, uo.InletStreams.Count);
                PointOrientation uoOrientation = MixerControl.INLET_ORIENTATION;
                ConnectionPoint  uoConnPoint   = new ConnectionPoint(uoIdx, uoName, uoPoint, uoOrientation);

                conn = new SolvableConnection(this.flowsheet, strConnPoint, uoConnPoint, ps.GetType());
            }
            else if (ad == Mixer.OUTLET_INDEX)
            {
                int              strIdx         = ProcessStreamBaseControl.IN_INDEX;
                string           strName        = ctrl.Solvable.Name;
                Point            strPoint       = ctrl.GetInConnectionPoint();
                PointOrientation strOrientation = ctrl.InOrientation;
                ConnectionPoint  strConnPoint   = new ConnectionPoint(strIdx, strName, strPoint, strOrientation);

                int              uoIdx         = Mixer.OUTLET_INDEX;
                string           uoName        = this.solvable.Name;
                Point            uoPoint       = this.GetStreamOutConnectionPoint();
                PointOrientation uoOrientation = MixerControl.OUTLET_ORIENTATION;
                ConnectionPoint  uoConnPoint   = new ConnectionPoint(uoIdx, uoName, uoPoint, uoOrientation);

                conn = new SolvableConnection(this.flowsheet, strConnPoint, uoConnPoint, ps.GetType());
            }

            if (conn != null)
            {
                this.flowsheet.ConnectionManager.AddConnection(conn);
                //this.flowsheet.ConnectionManager.Connections.Add(conn);
                //this.flowsheet.ConnectionManager.UpdateConnections(this);
                //this.flowsheet.ConnectionManager.DrawConnections();
                //this.DoThePaint();
                this.flowsheet.ConnectionManager.UpdateConnections(this);
            }
            return(conn);
        }
示例#7
0
 private void listViewUnitOps_SelectedIndexChanged(object sender, System.EventArgs e)
 {
     if (this.listViewUnitOps.SelectedItems.Count > 0)
     {
         this.Cursor  = Cursors.WaitCursor;
         this.Enabled = false;
         this.panelVariables.Visible = false;
         this.panelVariables.Controls.Clear();
         this.panelVariables.Controls.Add(this.formulaEditorHeaderControl);
         ListViewSolvableItem item = (ListViewSolvableItem)this.listViewUnitOps.SelectedItems[0];
         UnitOperation        uo   = item.Solvable as UnitOperation;
         IEnumerator          en   = uo.GetAllVariables().GetEnumerator();
         while (en.MoveNext())
         {
             ProcessVar pv = (ProcessVar)en.Current;
             FormulaEditorElementControl ctrl = new FormulaEditorElementControl(pv, this.evapAndDryingSystem.FormulaTable);
             ctrl.Dock = DockStyle.Top;
             this.panelVariables.Controls.Add(ctrl);
             ctrl.BringToFront();
         }
         this.panelVariables.Visible = true;
         this.Enabled = true;
         this.Cursor  = Cursors.Default;
     }
 }
示例#8
0
        protected GasSolidSeparatorRatingModel(IGasSolidSeparator owner) : base()
        {
            this.owner       = owner;
            this.ownerUnitOp = owner.MyUnitOperation;
            DryingGasStream     dgs = owner.GasInlet as DryingGasStream;
            DryingGasComponents dgc = dgs.GasComponents;
            SolidPhase          sp  = dgc.SolidPhase;

            if (sp == null)
            {
                particleProperties = new ParticleProperties();
            }
            else
            {
                ParticleSizeFractionAndEfficiency sfe;
                particleProperties = sp.ParticleProperties;
                ArrayList sizeAndFractionList = particleProperties.ParticleSizeAndFractionList;
                if (particleProperties.IsParticleDistributionsCalculated)
                {
                    foreach (ParticleSizeAndFraction psf in sizeAndFractionList)
                    {
                        sfe = new ParticleSizeFractionAndEfficiency(psf);
                        particleSizeFractionAndEfficiencyList.Add(sfe);
                    }
                }
            }

            this.ParticleDensity.Owner     = ownerUnitOp;
            this.ParticleBulkDensity.Owner = ownerUnitOp;
        }
示例#9
0
            public UnitOperation Create(Item item)
            {
                UnitOperation clone = Create();

                clone.data = item;
                return(clone);
            }
示例#10
0
        public UnitOpControl(Flowsheet flowsheet, Point location, UnitOperation unitOp)
            : base(flowsheet, location, unitOp)
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            HookEventHandler();
        }
示例#11
0
        public UnitOpControl(Flowsheet flowsheet, Point location, UnitOperation unitOp) :
            base(flowsheet, location, unitOp)
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            this.UnitOperation.StreamAttached += new StreamAttachedEventHandler(UnitOperation_StreamAttached);
            this.UnitOperation.StreamDetached += new StreamDetachedEventHandler(UnitOperation_StreamDetached);
        }
示例#12
0
        public override SolvableConnection CreateConnection(UnitOperation uo, ProcessStreamBase ps, int ad)
        {
            ProcessStreamBaseControl ctrl = this.flowsheet.StreamManager.GetProcessStreamBaseControl(ps);
            SolvableConnection       conn = null;

            if (ad == TwoStreamUnitOperation.INLET_INDEX)
            {
                int              strIdx         = ProcessStreamBaseControl.OUT_INDEX;
                string           strName        = ctrl.Solvable.Name;
                Point            strPoint       = ctrl.GetOutConnectionPoint();
                PointOrientation strOrientation = ctrl.OutOrientation;
                ConnectionPoint  strConnPoint   = new ConnectionPoint(strIdx, strName, strPoint, strOrientation);

                int              uoIdx         = TwoStreamUnitOperation.INLET_INDEX;
                string           uoName        = this.solvable.Name;
                Point            uoPoint       = this.GetStreamInConnectionPoint();
                PointOrientation uoOrientation = TwoStreamUnitOpControl.INLET_ORIENTATION;
                // adjust for Recycle
                if (uo is Recycle)
                {
                    uoOrientation = RecycleControl.INLET_ORIENTATION;
                }
                ConnectionPoint uoConnPoint = new ConnectionPoint(uoIdx, uoName, uoPoint, uoOrientation);

                conn = new SolvableConnection(this.flowsheet, strConnPoint, uoConnPoint, ps.GetType());
            }
            else if (ad == TwoStreamUnitOperation.OUTLET_INDEX)
            {
                int              strIdx         = ProcessStreamBaseControl.IN_INDEX;
                string           strName        = ctrl.Solvable.Name;
                Point            strPoint       = ctrl.GetInConnectionPoint();
                PointOrientation strOrientation = ctrl.InOrientation;
                ConnectionPoint  strConnPoint   = new ConnectionPoint(strIdx, strName, strPoint, strOrientation);

                int              uoIdx         = TwoStreamUnitOperation.OUTLET_INDEX;
                string           uoName        = this.solvable.Name;
                Point            uoPoint       = this.GetStreamOutConnectionPoint();
                PointOrientation uoOrientation = TwoStreamUnitOpControl.OUTLET_ORIENTATION;
                // adjust for Recycle
                if (uo is Recycle)
                {
                    uoOrientation = RecycleControl.OUTLET_ORIENTATION;
                }
                ConnectionPoint uoConnPoint = new ConnectionPoint(uoIdx, uoName, uoPoint, uoOrientation);
                conn = new SolvableConnection(this.flowsheet, strConnPoint, uoConnPoint, ps.GetType());
            }

            if (conn != null)
            {
                //this.flowsheet.ConnectionManager.DrawConnection(conn);
                this.flowsheet.ConnectionManager.AddConnection(conn);
                //this.flowsheet.ConnectionManager.Connections.Add(conn);
                //this.flowsheet.ConnectionManager.DrawConnections();
            }
            return(conn);
        }
示例#13
0
        public ActionResult EditModal(int id)
        {
            UnitOperation uo = this.orgTasks.GetUnitOperation(id);

            if (uo != null)
            {
                return(View(new UnitOperationViewModel(uo)));
            }
            return(new HttpNotFoundResult());
        }
示例#14
0
        public void InitializeUI()
        {
            this.Controls.Clear();
            x = 0;
            y = 0;

            y += 20; // make place for name

            Label label = new Label();

            label.Text        = this.GetTitle();
            label.Width       = 192;
            label.Height      = 20;
            label.Location    = new Point(x, y - 20);
            label.BorderStyle = BorderStyle.FixedSingle;
            label.TextAlign   = ContentAlignment.MiddleRight;
            label.BackColor   = Color.DarkGray;
            this.Controls.Add(label);

            //
            IList         list   = this.GetUnitOpList();
            IEnumerator   e2     = list.GetEnumerator();
            UnitOperation solvab = null;

            while (e2.MoveNext())
            {
                solvab = (UnitOperation)e2.Current;
                break; // need only one
            }
            UserControl labelsCtrl = this.GetNewUnitOpLabelsControl(solvab);

            labelsCtrl.Location = new Point(x, y);
            this.Controls.Add(labelsCtrl);

            x += labelsCtrl.Width;

            e2 = this.GetShowableInEditorUnitOpControls().GetEnumerator();
            while (e2.MoveNext())
            {
                UnitOpControl unitOpCtrl = (UnitOpControl)e2.Current;
                Solvable      solvable   = unitOpCtrl.Solvable;

                SolvableNameTextBox textBoxName = new SolvableNameTextBox(solvable);
                textBoxName.Location = new Point(x, y - 20);
                this.Controls.Add(textBoxName);

                UserControl valuesCtrl = this.GetNewUnitOpValuesControl(unitOpCtrl);
                valuesCtrl.Location = new Point(x, y);
                this.Controls.Add(valuesCtrl);

                x          += valuesCtrl.Width;
                this.Width  = x;
                this.Height = y + labelsCtrl.Height;
            }
        }
示例#15
0
 private void DetachStreamFromUnitOp(UnitOperation unitOp, ProcessStreamBase ps)
 {
     if (unitOp != null && ps != null)
     {
         ErrorMessage error = unitOp.DetachStream(ps);
         if (error != null)
         {
             UI.ShowError(error);
         }
     }
 }
示例#16
0
        public void DeleteSelectedSolvables()
        {
            if (this.Controls.Count > 0)
            {
                ArrayList toDeleteControls = new ArrayList();

                IEnumerator e = this.Controls.GetEnumerator();
                while (e.MoveNext())
                {
                    if (e.Current is SolvableControl)
                    {
                        SolvableControl ctrl = (SolvableControl)e.Current;
                        if (ctrl.IsSelected)
                        {
                            toDeleteControls.Add(ctrl);
                        }
                    }
                }

                if (toDeleteControls.Count > 0)
                {
                    string       message = "Are you sure that you want to delete the selected items?";
                    DialogResult dr      = MessageBox.Show(this, message, "Delete: " + this.Text,
                                                           MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    switch (dr)
                    {
                    case System.Windows.Forms.DialogResult.Yes:
                        //IEnumerator e2 = toDeleteControls.GetEnumerator();
                        //while (e2.MoveNext()) {
                        //SolvableControl ctrl = (SolvableControl)e2.Current;
                        foreach (SolvableControl ctrl in toDeleteControls)
                        {
                            // delete from the model, the UI will be updated in the event listener
                            if (ctrl is UnitOpControl)
                            {
                                UnitOperation unitOp = ((UnitOpControl)ctrl).UnitOperation;
                                this.evapAndDryingSystem.DeleteUnitOperation(unitOp);
                            }
                            else if (ctrl is ProcessStreamBaseControl)
                            {
                                ProcessStreamBase processStream = ((ProcessStreamBaseControl)ctrl).ProcessStreamBase;
                                this.evapAndDryingSystem.DeleteStream(processStream);
                            }
                        }
                        break;

                    case System.Windows.Forms.DialogResult.No:
                        break;
                    }
                }
            }
        }
示例#17
0
        public JsonNetResult EditModal(UnitOperationViewModel vm)
        {
            if (ModelState.IsValid)
            {
                UnitOperation uo = this.orgTasks.GetUnitOperation(vm.Id);
                uo = Mapper.Map(vm, uo);

                uo = this.orgTasks.SaveUnitOperation(uo);
                return(JsonNet(string.Empty));
            }
            return(JsonNet(this.GetErrorsForJson()));
        }
示例#18
0
 public override async ETTask UnitOperationHandler(Unit unit, UnitOperation message)
 {
     Log.Msg(message);
     //Log.Debug($"UnitOperationHandler {message}");
     unit.Position = new Vector3(message.X / 100f, message.Y / 100f, message.Z / 100f);
     if (message.Operation == OperaType.Fire)
     {
         unit.Fire(message);
     }
     MessageHelper.BroadcastToOther(unit, message);
     await ETTask.CompletedTask;
 }
示例#19
0
 /// <summary>
 /// 窗体加载事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void RegisterForm_Load(object sender, EventArgs e)
 {
     unitOperation = new UnitOperation();
     SetUnitClass();
     if (UnitClass != "")
     {
         comboBox_unitKind.Text = UnitClass;
     }
     else
     {
         comboBox_unitKind.SelectedIndex = 0;
     }
 }
示例#20
0
        private void PopulateUnitOpList(EvaporationAndDryingSystem evapAndDryingSystem)
        {
            IEnumerator e = evapAndDryingSystem.GetUnitOpList().GetEnumerator();

            while (e.MoveNext())
            {
                UnitOperation uo = (UnitOperation)e.Current;
                if (!(uo is Recycle))
                {
                    this.solvableVariablesControlUnitOp.ListBoxSolvable.Items.Add(uo);
                }
            }
        }
示例#21
0
        public override void NetReceive(BinaryReader trueReader, bool lightReceive)
        {
            //If the workaround is active, then the entity isn't being sent via the NetWorkaround packet
            byte workaround = trueReader.ReadByte();

            if (EditsLoader.MessageTileEntitySyncing || workaround != 1)
            {
                base.NetReceive(trueReader, lightReceive);
                return;
            }

            /* Reads the buffer off the network */
            MemoryStream buffer       = new MemoryStream(65536);
            BinaryWriter bufferWriter = new BinaryWriter(buffer);

            bufferWriter.Write(trueReader.ReadBytes(trueReader.ReadUInt16()));
            buffer.Position = 0;

            /* Recreate the BinaryReader reader */
            DeflateStream decompressor = new DeflateStream(buffer, CompressionMode.Decompress, true);
            BinaryReader  reader       = new BinaryReader(decompressor);

            /* Original code */
            base.NetReceive(reader, lightReceive);
            if (TileEntity.ByPosition.ContainsKey(Position) && TileEntity.ByPosition[Position] is TEStorageUnit)
            {
                TEStorageUnit other = (TEStorageUnit)TileEntity.ByPosition[Position];
                items           = other.items;
                hasSpaceInStack = other.hasSpaceInStack;
                hasItem         = other.hasItem;
            }
            receiving = true;
            int  count = reader.ReadUInt16();
            bool flag  = false;

            for (int k = 0; k < count; k++)
            {
                if (UnitOperation.Receive(reader, this))
                {
                    flag = true;
                }
            }
            if (flag)
            {
                RepairMetadata();
            }
            receiving = false;

            /* Dispose all objects */
            reader.Dispose(); decompressor.Dispose(); bufferWriter.Dispose(); buffer.Dispose();
        }
示例#22
0
        public GasSolidSeparatorBalanceModel(IGasSolidSeparator owner) : base()
        {
            this.owner       = owner;
            this.ownerUnitOp = owner.MyUnitOperation;

            gasPressureDrop        = new ProcessVarDouble(StringConstants.GAS_PRESSURE_DROP, PhysicalQuantity.Pressure, VarState.Specified, ownerUnitOp);
            collectionEfficiency   = new ProcessVarDouble(StringConstants.COLLECTION_EFFICIENCY, PhysicalQuantity.Fraction, VarState.Specified, ownerUnitOp);
            inletParticleLoading   = new ProcessVarDouble(StringConstants.INLET_PARTICLE_LOADING, PhysicalQuantity.MassVolumeConcentration, VarState.Specified, ownerUnitOp);
            outletParticleLoading  = new ProcessVarDouble(StringConstants.OUTLET_PARTICLE_LOADING, PhysicalQuantity.MassVolumeConcentration, VarState.Specified, ownerUnitOp);
            particleCollectionRate = new ProcessVarDouble(StringConstants.PARTICLE_COLLECTION_RATE, PhysicalQuantity.MassFlowRate, VarState.Specified, ownerUnitOp);
            massFlowRateOfParticleLostToGasOutlet = new ProcessVarDouble(StringConstants.PARTICLE_LOSS_TO_GAS_OUTLET, PhysicalQuantity.MassFlowRate, VarState.Specified, ownerUnitOp);

            InitializeVarListAndRegisterVars();
        }
示例#23
0
        public JsonNetResult Remove(int id)
        {
            UnitOperation uo = this.orgTasks.GetUnitOperation(id);

            if (uo != null)
            {
                this.orgTasks.DeleteUnitOperation(uo);
                Response.StatusCode = (int)HttpStatusCode.OK;
                return(JsonNet("Unit involvement with operation successfully removed."));
            }
            else
            {
                Response.StatusCode = (int)HttpStatusCode.NotFound;
                return(JsonNet("Unit involvement with operation not found."));
            }
        }
示例#24
0
 public void DeleteSolvable(SolvableControl ctrl)
 {
     if (ctrl != null)
     {
         if (ctrl is UnitOpControl)
         {
             UnitOperation unitOp = ((UnitOpControl)ctrl).UnitOperation;
             this.evapAndDryingSystem.DeleteUnitOperation(unitOp);
         }
         else if (ctrl is ProcessStreamBaseControl)
         {
             ProcessStreamBase processStream = ((ProcessStreamBaseControl)ctrl).ProcessStreamBase;
             this.evapAndDryingSystem.DeleteStream(processStream);
         }
     }
 }
示例#25
0
        public override void NetReceive(BinaryReader trueReader, bool lightReceive)
        {
            /* Reads the buffer off the network */
            MemoryStream buffer       = new MemoryStream(65536);
            BinaryWriter bufferWriter = new BinaryWriter(buffer);

            int count = trueReader.ReadUInt16();

            for (int i = 0; i < count; i++)
            {
                bufferWriter.Write(trueReader.ReadByte());
            }
            buffer.Position = 0;

            /* Recreate the BinaryReader reader */
            DeflateStream decompressor = new DeflateStream(buffer, CompressionMode.Decompress, true);
            BinaryReader  reader       = new BinaryReader(decompressor);

            /* Original code */
            base.NetReceive(reader, lightReceive);
            if (TileEntity.ByPosition.ContainsKey(Position) && TileEntity.ByPosition[Position] is TEStorageUnit)
            {
                TEStorageUnit other = (TEStorageUnit)TileEntity.ByPosition[Position];
                items           = other.items;
                hasSpaceInStack = other.hasSpaceInStack;
                hasItem         = other.hasItem;
            }
            receiving       = true;
            /* int */ count = reader.ReadUInt16();
            bool flag = false;

            for (int k = 0; k < count; k++)
            {
                if (UnitOperation.Receive(reader, this))
                {
                    flag = true;
                }
            }
            if (flag)
            {
                RepairMetadata();
            }
            receiving = false;

            /* Dispose all objects */
            reader.Dispose(); decompressor.Dispose(); bufferWriter.Dispose(); buffer.Dispose();
        }
示例#26
0
        public IActionResult Convert(UnitOperation unitOp)
        {
            if (ModelState.IsValid)
            {
                switch (unitOp.conversionType)
                {
                case "Speed":
                    switch (unitOp.inputType)
                    {
                    case "MPH":
                        //1.60934 is conversion rate from mph to km per hour (source: google convert)
                        unitOp.result = unitOp.input * (float)1.60934;
                        break;

                    case "KMPH":
                        //0.6213671 is conversion rate from kmph to mph (source: google convert)
                        unitOp.result = unitOp.input * (float)0.621371;
                        break;

                    default:
                        return(View("Error"));
                    }
                    break;

                case "Temperature":
                    switch (unitOp.inputType)
                    {
                    case "Farenheit":
                        unitOp.result = (unitOp.input - (float)32) / (float)1.8;
                        break;

                    case "Celcius":
                        unitOp.result = unitOp.input * (float)1.8 + (float)32;
                        break;

                    default:
                        return(View("Error"));
                    }
                    break;
                }
            }
            else
            {
                return(View("Error"));
            }
            return(View(unitOp));
        }
示例#27
0
 public UnitOperationViewModel(UnitOperation uo)
 {
     if (uo != null)
     {
         Mapper.Map(uo, this);
         if (uo.Unit != null)
         {
             this.UnitId   = uo.Unit.Id;
             this.UnitName = uo.Unit.UnitName;
         }
         if (uo.Operation != null)
         {
             this.OperationId   = uo.Operation.Id;
             this.OperationName = uo.Operation.Name;
         }
     }
 }
示例#28
0
        public override void SetObjectData()
        {
            base.SetObjectData();
            int persistedClassVersion = (int)info.GetValue("ClassPersistenceVersionGasSolidSeparatorBalanceModel", typeof(int));

            if (persistedClassVersion == 1)
            {
                this.owner       = info.GetValue("Owner", typeof(IGasSolidSeparator)) as IGasSolidSeparator;
                this.ownerUnitOp = info.GetValue("OwnerUnitOp", typeof(UnitOperation)) as UnitOperation;
                this.procVarList = info.GetValue("ProcVarList", typeof(ArrayList)) as ArrayList;

                this.gasPressureDrop        = RecallStorableObject("GasPressureDrop", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.collectionEfficiency   = RecallStorableObject("CollectionEfficiency", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.inletParticleLoading   = RecallStorableObject("InletParticleLoading", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.outletParticleLoading  = RecallStorableObject("OutletParticleLoading", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.particleCollectionRate = RecallStorableObject("ParticleCollectionRate", typeof(ProcessVarDouble)) as ProcessVarDouble;
                this.massFlowRateOfParticleLostToGasOutlet = RecallStorableObject("MassFlowRateOfParticleLostToGasOutlet", typeof(ProcessVarDouble)) as ProcessVarDouble;
            }
        }
示例#29
0
        protected ErrorMessage CheckSpecifiedValueInContextOfOwner(ProcessVarDouble pv, double aValue)
        {
            ErrorMessage  retValue = null;
            UnitOperation uo       = this.downStreamOwner;

            if (uo != null && uo.IsBalanceCalcReady())
            {
                retValue = uo.CheckSpecifiedValueInContext(pv, aValue);
            }
            if (retValue == null)
            {
                uo = this.upStreamOwner;
                if (uo != null && uo.IsBalanceCalcReady())
                {
                    retValue = uo.CheckSpecifiedValueInContext(pv, aValue);
                }
            }
            return(retValue);
        }
示例#30
0
        public JsonNetResult AddOperationModal(UnitOperationViewModel vm)
        {
            if (ModelState.IsValid)
            {
                Unit unit = this.orgTasks.GetUnit(vm.UnitId.Value);

                if (unit != null)
                {
                    if (vm.OperationId.HasValue)
                    {
                        Operation op = this.orgTasks.GetOperation(vm.OperationId.Value);
                        if (op != null)
                        {
                            UnitOperation uo = Mapper.Map(vm, new UnitOperation());
                            uo.Operation = op;
                            uo.Unit      = unit;
                            uo           = this.orgTasks.SaveUnitOperation(uo);
                            return(JsonNet(string.Empty));
                        }
                        else
                        {
                            ModelState.AddModelError("OperationId", "That operation doesn't exist.");
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("OperationId", "No operation selected.");
                    }
                }
                else
                {
                    ModelState.AddModelError("UnitId", "That unit doesn't exist.");
                }
            }
            return(JsonNet(this.GetErrorsForJson()));
        }