public IHttpActionResult postExchangers(ExchangerModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } List <PinchAnalysis_DLL.NormalStream> Streams = new List <PinchAnalysis_DLL.NormalStream>(); foreach (var exchanger in model.Exchangers) { double hotDuty; double coldDuty; if (model.DutyType == 0) { if (exchanger.exchangerType != ExchangerType.Cooler) { hotDuty = exchanger.duty / (exchanger.hotGroup.hotSupply - exchanger.hotGroup.hotTarget); } if (exchanger.exchangerType != ExchangerType.Heater) { coldDuty = exchanger.duty / (exchanger.coldGroup.coldTarget - exchanger.coldGroup.coldSupply); } } else { hotDuty = coldDuty = exchanger.duty; } if (exchanger.exchangerType != ExchangerType.Cooler) { hotStream hotStream = new hotStream(exchanger.name, model.Approach, exchanger.hotGroup.hotSupply, exchanger.hotGroup.hotTarget, exchanger.duty, 0, 0, model.Units, exchanger.exchangerType, exchanger.utility); Streams.Add(hotStream); } if (exchanger.exchangerType != ExchangerType.Heater) { coldStream coldStream = new coldStream(exchanger.name, model.Approach, exchanger.coldGroup.coldSupply, exchanger.coldGroup.coldTarget, exchanger.duty, 0, 0, model.Units, exchanger.exchangerType, exchanger.utility); Streams.Add(coldStream); } } //List<PinchAnalysis_DLL.UtilityStream> UtilityStreams = new List<PinchAnalysis_DLL.UtilityStream>(); UtilityStreams = FillUtilityStreamLists(UtilityStreams, model); this.formNumber = 2; if (model.optimize == false) { return(Calculate(Streams, UtilityStreams, model.Approach)); } else { return(null); } }
private void DoConnect(object obj) { try { ExchangerModel.RunExchanger(); DisplayTextModel.Run(); Notificate.ShowSuccess("Подключение к " + ExchangerModel.Portname); } catch (Exception ex) { Notificate.ShowError(ex.Message); } }
private void DoDisconnect(object obj) { try { ExchangerModel.StopExchanger(); DisplayTextModel.Stop(); Notificate.ShowSuccess("Отключение от устройства"); } catch (Exception ex) { Notificate.ShowError(ex.Message); } }
public IHttpActionResult postExchangersOptimize(ExchangerModel model) { MaxApproach = GetMaxTemp(model, 1); List <CostCalc> CostCalcList = new List <CostCalc>(); List <Point> CAPEXLine = new List <Point>(); List <Point> OPEXLine = new List <Point>(); List <Point> TotalCostLine = new List <Point>(); for (int i = 1; i <= MaxApproach; i++) { getPinchPoint trial = PinchFun(model, i, 1); double?HotUtilityCostPerHour = trial.UtilityStreams.Where(a => a.GetType() == typeof(PinchAnalysis_DLL.HotUtilityStream)).Sum(a => a.OptimiumDuty * a.Cost); double?ColdUtilityCostPerHour = trial.UtilityStreams.Where(a => a.GetType() == typeof(PinchAnalysis_DLL.ColdUtilityStream)).Sum(a => a.OptimiumDuty * a.Cost); CostCalc row = new CostCalc(trial.MaxHeatRecovery, trial.Get_Optimium_UA() / 1000000, model.DollarPerUA, model.LifeTime, HotUtilityCostPerHour, ColdUtilityCostPerHour); CostCalcList.Add(row); CAPEXLine.Add(new Point(i, row.HourlyCAPEX)); OPEXLine.Add(new Point(i, row.TotalOPEX)); TotalCostLine.Add(new Point(i, row.TotalCost)); Streams.Clear(); UtilityStreams.Clear(); } double OptimumT = CostCalcList.Min(a => a.TotalCost).GetValueOrDefault(); dynamic obj = new ExpandoObject(); obj.CAPEXLine = CAPEXLine; obj.OPEXLine = OPEXLine; obj.TotalCostLine = TotalCostLine; obj.OptimumT = OptimumT; return(Ok(obj)); }