public void CreateHeatExchanger(Project proj)
        {
            try
            {
                string newRoomName     = "";
                string newRoomId       = "";
                double newRoomFreshAir = 0;

                Indoor item = new Indoor();
                item.Series      = SelectedSeries.SelectedValues;
                item.DisplayName = SelectedSeries.SelectedValues;
                if (_SelectedRoom != null)
                {
                    newRoomName                 = _SelectedRoom.Name;
                    newRoomId                   = _SelectedRoom.Id;
                    newRoomFreshAir             = _SelectedRoom.FreshAir;
                    SelectedRoom.FreshAir       = FreshAir;
                    SelectedRoom.StaticPressure = ESPVal;
                    SelectedRoom.Area           = Area;
                    SelectedRoom.PeopleNumber   = NoOfPeople;
                }
                else
                {
                    newRoomName     = "";
                    newRoomId       = null;
                    newRoomFreshAir = this.FreshAir;
                }

                proj.ExchangerList.Add(new RoomIndoor
                {
                    IndoorName       = UnitName,
                    IndoorItem       = item,
                    Power            = SelectedPower.SelectedValues,
                    FanSpeedLevel    = (int)SFanSpeed,
                    RqFreshAir       = newRoomFreshAir,
                    Area             = Area,
                    RqStaticPressure = ESPVal,
                    NumberOfPeople   = NoOfPeople,
                    DBCooling        = Convert.ToDouble(Project.CurrentProject.DesignCondition.indoorCoolingDB),
                    WBCooling        = Convert.ToDouble(Project.CurrentProject.DesignCondition.indoorCoolingWB),
                    DBHeating        = Convert.ToDouble(Project.CurrentProject.DesignCondition.indoorCoolingHDB),
                    RHCooling        = Convert.ToDouble(Project.CurrentProject.DesignCondition.indoorCoolingRH),
                    RoomName         = newRoomName,
                    RoomID           = newRoomId,
                    SelectedFloor    = SelectedFloor,
                    SystemID         = HvacSystem.Id
                });
            }
            catch (Exception ex)
            {
                int?id = Project.GetProjectInstance?.projectID;
                Logger.LogProjectError(id, ex);
            }
        }
Example #2
0
        /// <summary>
        /// 兼容旧数据 axj 20160707
        /// </summary>
        /// <param name="inItem"></param>
        public static void CompatType(RoomIndoor ri)
        {
            if (ri.ListAccessory == null)
            {
                return;
            }
            Indoor inItem = ri.IndoorItem;

            if (inItem == null)
            {
                return;
            }
            var list = ri.ListAccessory;

            for (int i = 0; i < list.Count; i++)
            {
                var ent = list[i];
                if (ent == null)
                {
                    continue;
                }
                //修正产品类型
                if (ent.UnitType != inItem.Type)
                {
                    ent.UnitType = inItem.Type;
                }
                //修正工厂代码
                //string modelfull = inItem.ModelFull;
                //string fCode = modelfull.Substring(modelfull.Length - 1, 1);
                // 室内机工厂代码改为类函数获取,用于处理Wuxi design特殊逻辑 20180627 by Yunxiao Lin
                string fCode = inItem.GetFactoryCodeForAccess();
                if (ent.FactoryCode != fCode)
                {
                    ent.FactoryCode = fCode;
                }
                //旧数据Type修正
                switch (ent.Type)
                {
                case "Drainage Pump": ent.Type = "Drain Pump"; break;

                case "Half size remote control switch": ent.Type = "Half-size Remote Control Switch"; break;

                case "Liquid Crystal Remote Control Switch": ent.Type = "Remote Control Switch"; break;

                case "Panel": ent.Type = "Air panel"; break;

                case "Remote Controler": ent.Type = "Remote Control Switch"; break;

                case "Wireless Receiver Kit": ent.Type = "Receiver Kit for Wireless Control"; break;

                default: break;
                }
            }
        }
Example #3
0
        static void AddDataToDB()
        {
            using (var db = new EFContext())
            {
                if (db.Outdoors.Any())
                {
                    //Console.Write("Db already exists!");
                    return;
                }
            }

            List <Indoor>  indoorList  = new List <Indoor>();
            List <Outdoor> outdoorList = new List <Outdoor>();

            using (var reader = new StreamReader("Data\\TemperaturData.csv"))
            {
                var provider = new CultureInfo("en-US");

                while (!reader.EndOfStream)
                {
                    var line   = reader.ReadLine();
                    var values = line.Split(',');
                    if (values[1] == "Inne")
                    {
                        var indoorData = new Indoor();
                        indoorData.Date        = DateTime.Parse(values[0]);
                        indoorData.Temperature = double.Parse(values[2], provider);
                        indoorData.Humidity    = int.Parse(values[3]);
                        indoorList.Add(indoorData);
                    }
                    else
                    {
                        var outdoorData = new Outdoor();
                        outdoorData.Date        = DateTime.Parse(values[0]);
                        outdoorData.Temperature = double.Parse(values[2], provider);
                        outdoorData.Humidity    = int.Parse(values[3]);
                        outdoorList.Add(outdoorData);
                    }
                }
            }

            using (var db = new EFContext())
            {
                Console.Write("Working...");
                db.Indoors.AddRange(indoorList);
                db.Outdoors.AddRange(outdoorList);
                db.SaveChanges();
                Console.WriteLine("Finished.");
            }
        }
Example #4
0
        private RoomIndoor GetNewRoomIndoor(DataRow stdRow, RoomIndoor ri)
        {
            RoomIndoor door   = new RoomIndoor();
            Indoor     inItem = bll.GetItem(stdRow["ModelFull"].ToString(), _unitType, _productType, _series); // 新室内机对象

            door.SetIndoorItemWithAccessory(inItem);
            door.RoomID          = "";
            door.RoomName        = "";
            door.IsFreshAirArea  = ri.IsFreshAirArea;
            door.CoolingCapacity = Convert.ToDouble(inItem.CoolingCapacity);
            door.SensibleHeat    = Convert.ToDouble(inItem.SensibleHeat);
            door.RqAirflow       = door.AirFlow;//Convert.ToDouble(inItem.AirFlow);
            door.HeatingCapacity = Convert.ToDouble(inItem.HeatingCapacity);
            //door.AirFlow = Convert.ToDouble(inItem.AirFlow);
            door.IndoorItem.Series = ri.IndoorItem.Series;
            door.IsDelete          = false;

            return(door);
        }
        private void UpdateHeatExchanger()
        {
            try
            {
                string newRoomName = "";
                string newRoomId   = "";
                Indoor inItem      = null;

                if (SelectedRoom != null)
                {
                    newRoomName = SelectedRoom.Name;
                    newRoomId   = SelectedRoom.Id;
                    // Updating capacity rq values for room
                    SelectedRoom.FreshAir       = FreshAir;
                    SelectedRoom.StaticPressure = ESPVal;
                    SelectedRoom.Area           = Area;
                    SelectedRoom.PeopleNumber   = NoOfPeople;
                }
                else
                {
                    newRoomName = "";
                    newRoomId   = null;
                }
                if (SelectedSeries != null)
                {
                    if (proj.IndoorItem != null)
                    {
                        proj.IndoorItem.Series = SelectedSeries.SelectedValues;
                    }
                    else
                    {
                    }
                    if (SelectedPower != null)
                    {
                        DataTable dt = _bll.GetExchnagerListStd(SelectedSeries.SelectedValues, "", SelectedPower.Code);
                        dt.DefaultView.Sort = "AirFlow";
                        if (dt.Rows.Count > 0)
                        {
                            DataTable sortedDT = dt.DefaultView.ToTable();
                            DataRow   dr       = dt.Rows[0];
                            //DataRow dr = GetAutoModel(sortedDT.Rows);
                            string ProductType = string.Empty;
                            if (thisProject.RegionCode == "EU_W" || thisProject.RegionCode == "EU_S" || thisProject.RegionCode == "EU_E")
                            {
                                ProductType = "Universal IDU";
                            }
                            else
                            {
                                ProductType = SelectedSeries.SelectedValues;
                            }

                            inItem        = _bll.GetItem(dr["ModelFull"].ToString(), SelectedSeries.SelectedValues, ProductType, SelectedSeries.SelectedValues);
                            inItem.Series = SelectedSeries.SelectedValues;
                            //Required field for Report
                            inItem.DisplayName = SelectedSeries.SelectedValues;
                        }
                        proj.IndoorItem = inItem;
                    }
                }

                if (SelectedPower != null)
                {
                    proj.Power = SelectedPower.SelectedValues;
                }
                proj.RoomName         = newRoomName;
                proj.RoomID           = newRoomId;
                proj.FanSpeedLevel    = (int)SFanSpeed;
                proj.IndoorName       = UnitName;
                proj.SelectedFloor    = SelectedFloor;
                proj.RqFreshAir       = FreshAir;
                proj.Area             = Area;
                proj.RqStaticPressure = ESPVal;
                proj.NumberOfPeople   = NoOfPeople;
                proj.DBCooling        = outdoorCoolingDB;
                proj.WBCooling        = outdoorCoolingWB;
                proj.DBHeating        = outdoorHeatingDB;
                proj.RHCooling        = outdoorHeatingRH;

                _eventAggregator.GetEvent <SendHEDetails>().Publish(false);
            }
            catch (Exception ex)
            {
                int?id = Project.GetProjectInstance?.projectID;
                Logger.LogProjectError(id, ex);
            }
        }
Example #6
0
        private void BatchCalculateEstValue(List <IDUEquipmentModel> IDUEquipmentModelList, ref List <IDUEquipmentModel> objEquipmentList)
        {
            if (SelectedFanSpeed != -1)
            {
                _fanSpeedLevel = SelectedFanSpeed - 1;
            }
            double outdoorCoolingDB = SystemSetting.UserSetting.defaultSetting.OutdoorCoolingDB;
            double outdoorHeatingWB = SystemSetting.UserSetting.defaultSetting.OutdoorHeatingWB;
            double outdoorCoolingIW = SystemSetting.UserSetting.defaultSetting.OutdoorCoolingIW;
            double outdoorHeatingIW = SystemSetting.UserSetting.defaultSetting.OutdoorHeatingIW;
            double wb_c             = Unit.ConvertToSource(Convert.ToDouble(LblWbCool), UnitType.TEMPERATURE, SystemSetting.UserSetting.unitsSetting.settingTEMPERATURE);
            double db_h             = Unit.ConvertToSource(Convert.ToDouble(LblDBHeat), UnitType.TEMPERATURE, SystemSetting.UserSetting.unitsSetting.settingTEMPERATURE);
            double fa             = 0;
            double airflow        = 0;
            double staticPressure = 0;

            for (int i = 0; i < IDUEquipmentModelList.Count; ++i)
            {
                Indoor inItem = indoorBLL.GetItem(IDUEquipmentModelList[i].ModelFull, null, IDUEquipmentModelList[i].ProductType, null);
                if (inItem == null)
                {
                    continue;
                }
                double est_cool = 0;
                double est_heat = 0;
                double est_sh   = 0;
                string type     = inItem.Type;
                if (type.Contains("YDCF") || (type.Contains("Fresh Air") && JCHVRF.Model.Project.CurrentProject.SubRegionCode != "LA_BR") || type.Contains("Ventilation"))
                {
                    est_cool = inItem.CoolingCapacity;
                    est_heat = inItem.HeatingCapacity;
                    est_sh   = inItem.SensibleHeat;
                }
                else if (type.Contains("Hydro Free") || type == "DX-Interface")
                {
                    est_cool = inItem.CoolingCapacity;
                    est_heat = inItem.HeatingCapacity;
                    est_sh   = 0d;
                }
                else
                {
                    double db_c = inItem.ProductType.Contains("Water Source") ? outdoorCoolingIW : outdoorCoolingDB;
                    double wb_h = inItem.ProductType.Contains("Water Source") ? outdoorHeatingIW : outdoorHeatingWB;
                    est_cool = indoorBLL.CalIndoorEstCapacity(inItem, db_c, wb_c, false);
                    double shf = inItem.GetSHF(_fanSpeedLevel);
                    est_sh = est_cool * shf;
                    if (!inItem.ProductType.Contains(", CO"))
                    {
                        est_heat = indoorBLL.CalIndoorEstCapacity(inItem, wb_h, db_h, true);
                    }
                }
                if (IndoorBLL.IsFreshAirUnit(type))
                {
                    fa = inItem.AirFlow;
                }
                else if (!type.Contains("Hydro Free") && type != "DX-Interface")
                {
                    airflow = inItem.GetAirFlow(_fanSpeedLevel);
                    if (type.Contains("Ducted") || type.Contains("Total Heat Exchanger"))
                    {
                        staticPressure = inItem.GetStaticPressure();
                    }
                }
                objEquipmentList.Add(new IDUEquipmentModel
                {
                    Model        = IDUEquipmentModelList[i].Model,
                    ModelFull    = IDUEquipmentModelList[i].ModelFull,
                    ModelYork    = IDUEquipmentModelList[i].ModelYork,
                    ModelHitachi = IDUEquipmentModelList[i].ModelHitachi,
                    CoolCapacity = Math.Round(est_cool, 1),
                    SensibleHeat = Math.Round(est_sh, 1),
                    HeatCapacity = Math.Round(est_heat, 1),
                    AirFlow      = Math.Round(airflow, 1, MidpointRounding.AwayFromZero),
                    Type         = IDUEquipmentModelList[i].Type,
                    ESP          = staticPressure
                });
            }
        }
Example #7
0
 void SetEquipmentProperties(Indoor ri)
 {
     this.SelectedType  = ri.Type;
     this.SelectedModel = ri.Model;
 }
Example #8
0
 public DataTable GetAllAvailable(Indoor inItem, string RegionCode, string SubRegionCode)
 {
     return(_dal.GetAllAvailable(inItem, RegionCode, SubRegionCode));
 }
Example #9
0
 public Accessory GetItem(string type, Indoor inItem, string RegionCode, string SubRegionCode)
 {
     return(_dal.GetItem(type, inItem, RegionCode, SubRegionCode));
 }
Example #10
0
 public Accessory GetItems(string type, string model_Hitachi, Indoor inItem, string RegionCode, string SubRegionCode)
 {
     return(_dal.GetItems(type, model_Hitachi, inItem, RegionCode, SubRegionCode));
 }
Example #11
0
 public List <Accessory> GetDefault(Indoor inItem, string RegionCode, string SubRegionCode, string Series)
 {
     return(_dal.GetDefault(inItem, RegionCode, SubRegionCode, Series));
 }
        private void CreateHeatExchanger()
        {
            string newRoomName     = "";
            string newRoomId       = "";
            double newRoomFreshAir = 0;
            string powerSelected   = "";

            double airFlow = 0;
            double ESP     = 0;

            Indoor inItem        = null;
            var    fanspeedLevel = (int)_sfanspeed;

            if (UserSelSeries != null && SelectedPower != null)
            {
                _indoorBll = new JCHVRF.BLL.IndoorBLL(JCHVRF.Model.Project.CurrentProject.SubRegionCode, JCHVRF.Model.Project.CurrentProject.BrandCode);
                DataTable dt = _indoorBll.GetExchnagerListStd(UserSelSeries, "", SelectedPower.Code);
                dt.DefaultView.Sort = "AirFlow";

                if (dt.Rows.Count > 0)
                {
                    DataRow dr = dt.Rows[0];
                    //DataRow dr = GetAutoModel(dt.DefaultView.ToTable().Rows);
                    _indoorBll = new JCHVRF.BLL.IndoorBLL(JCHVRF.Model.Project.CurrentProject.SubRegionCode, JCHVRF.Model.Project.CurrentProject.BrandCode);
                    string ProductType = string.Empty;
                    if (thisProject.RegionCode == "EU_W" || thisProject.RegionCode == "EU_S" || thisProject.RegionCode == "EU_E")
                    {
                        ProductType = "Universal IDU";
                    }
                    else
                    {
                        ProductType = UserSelSeries;
                    }

                    inItem = _indoorBll.GetItem(dr["ModelFull"].ToString(), UserSelSeries, ProductType, UserSelSeries);
                    if (inItem != null)
                    {
                        inItem.Series = UserSelSeries;
                        //Required field for Report
                        inItem.DisplayName = UserSelSeries;
                    }
                }
            }
            if (SelectedRoom != null)
            {
                newRoomName                 = SelectedRoom.Name;
                newRoomId                   = SelectedRoom.Id;
                newRoomFreshAir             = SelectedRoom.FreshAir;
                SelectedRoom.FreshAir       = FreshAir;
                SelectedRoom.StaticPressure = ESPVal;
                SelectedRoom.Area           = Area;
                SelectedRoom.PeopleNumber   = NoOfPeople;
            }
            else
            {
                newRoomName     = "";
                newRoomId       = null;
                newRoomFreshAir = FreshAir;
            }
            if (SelectedPower != null)
            {
                powerSelected = SelectedPower.SelectedValues;
            }

            airFlow = newRoomFreshAir;
            ESP     = ESPVal;

            Project.CurrentProject.ExchangerList.Add(new RoomIndoor
            {
                IndoorName         = UnitName,
                IndoorItem         = inItem,
                Power              = powerSelected,
                FanSpeedLevel      = fanspeedLevel,
                RqFreshAir         = airFlow,
                RqAirflow          = airFlow,
                Area               = Area,
                RqStaticPressure   = ESP,
                NumberOfPeople     = NoOfPeople,
                DBCooling          = outdoorCoolingDB,
                WBCooling          = outdoorCoolingWB,
                DBHeating          = outdoorHeatingDB,
                RHCooling          = outdoorHeatingRH,
                RoomName           = newRoomName,
                RoomID             = newRoomId,
                SelectedFloor      = _sIndex,
                SystemID           = WorkFlowContext.NewSystem.Id,
                IsExchanger        = true,
                HECanvFreshAirUnit = SystemSetting.UserSetting.unitsSetting.settingAIRFLOW,
                HECanvAreaUnit     = SystemSetting.UserSetting.unitsSetting.settingAREA,
                HECanvTempUnit     = SystemSetting.UserSetting.unitsSetting.settingTEMPERATURE
            });
        }
Example #13
0
 public Indoor getBiggerIndoor(Indoor litem)
 {
     return(_dal.getBiggerIndoor(litem));
 }
Example #14
0
 //public double CalIndoorEstCapacity(Indoor inItem, double OutTemperature, double InTemperature, out double estSH, bool isHeating)
 //{
 //    return _dal.CalEstCapacity(inItem, OutTemperature, InTemperature, out estSH, isHeating);
 //}
 //室内机估算容量不再返回显热 20161111
 public double CalIndoorEstCapacity(Indoor inItem, double OutTemperature, double InTemperature, bool isHeating)
 {
     return(_dal.CalEstCapacity(inItem, OutTemperature, InTemperature, isHeating));
 }
Example #15
0
        /// <summary>
        /// Startar en ny transaktion där datat läggs in i databasen, beroende på vilken typ T är
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        public static void ImportToDB <T>()
        {
            //format "2016 - 05 - 31 13:58:30,Inne,24.8,42";
            string[] temperatureFileRows;

            Type t = typeof(T);

            if (t == typeof(Outdoor))
            {
                temperatureFileRows = File.ReadAllLines(Directory.GetCurrentDirectory() + @"\TemperaturData.csv")
                                      .Where(line => line.Contains($",Ute,"))
                                      .ToArray();
            }
            else
            {
                temperatureFileRows = File.ReadAllLines(Directory.GetCurrentDirectory() + @"\TemperaturData.csv")
                                      .Where(line => line.Contains($",Inne,"))
                                      .ToArray();
            }

            int i = 1;


            using (var context = new TemperatureDBContext())
            {
                using (var transaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        foreach (string row in temperatureFileRows)
                        {
                            string consoleOutput = "";

                            string[] rowData             = row.Split(',');
                            DateTime dateFromFile        = DateTime.Parse(rowData[0]);
                            double   temperatureFromFile = double.Parse(rowData[2].Replace('.', ',')); //ersätter . med , för att kunda köra parse
                            int      humidityFromFile    = int.Parse(rowData[3]);

                            if (t == typeof(Indoor))
                            {
                                Indoor temperatureIndoor = new Indoor()
                                {
                                    Date        = dateFromFile,
                                    Temperature = temperatureFromFile,
                                    Humidity    = humidityFromFile
                                };
                                context.Indoors.Add(temperatureIndoor);
                                consoleOutput = $"#{i}. Added indoor date: {temperatureIndoor.Date}," +
                                                $"\n\t Deg: {temperatureIndoor.Temperature} Hum: {temperatureIndoor.Humidity}";
                            }
                            else
                            {
                                Outdoor temperatureOutdoor = new Outdoor()
                                {
                                    Date        = dateFromFile,
                                    Temperature = temperatureFromFile,
                                    Humidity    = humidityFromFile
                                };

                                context.Outdoors.Add(temperatureOutdoor);

                                consoleOutput = $"#{i}. Added outdoor date: {temperatureOutdoor.Date}," +
                                                $"\n\t Deg: {temperatureOutdoor.Temperature} Hum: {temperatureOutdoor.Humidity}";
                            }
                            Console.WriteLine(consoleOutput);
                            i++;
                        }
                        Console.WriteLine("Saving changes please wait...");
                        context.SaveChanges();
                        Console.WriteLine("Done! press any key to continue");
                        Console.ReadKey();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message + "\n\t" + e.InnerException);
                        transaction.Rollback();
                    }
                    finally
                    {
                        Console.WriteLine("Comitting please wait...");
                        transaction.Commit();
                    }
                }
            }
        }
Example #16
0
        // 将选择的室内机预添加到已选室内机
        /// <summary>
        /// 将选择的室内机预添加到已选室内机,并执行容量估算
        /// </summary>
        /// <param name="stdRow">标准表记录行</param>
        /// <param name="isAppend">是否附加到已选记录行,true则附加且count值可修改;false则添加唯一记录且count值不可修改</param>
        private void DoCalculateEstValue(DataRow stdRow)
        {
            string type = _unitType; //this.jccmbType.Text.Trim();
            //由于untTypeList中的值含有厂名,所以在取出来的时候需要去掉 20161118 by Yunxiao Lin
            int i = type.IndexOf("-");

            if (i > 0)
            {
                if (thisProject.RegionCode != "EU_W" && thisProject.RegionCode != "EU_S" && thisProject.RegionCode != "EU_E") //EU区域的 暂时不取厂名 20180302 by xyj
                {
                    type = type.Substring(0, i);
                }
            }
            string modelFull = stdRow["ModelFull"].ToString();
            Indoor inItem    = bll.GetItem(modelFull, type, _productType, _series);

            if (inItem != null)
            {
                inItem.Series = _series;   //将当前的series封装室内机列表   add on 20161027
            }
            if (type.Contains("YDCF"))
            {
                est_cool = Convert.ToDouble(stdRow["CoolCapacity"].ToString());
                est_heat = Convert.ToDouble(stdRow["HeatCapacity"].ToString());
                est_sh   = Convert.ToDouble(stdRow["SensibleHeat"].ToString());
            }
            else
            {
                // 执行容量估算
                double wb_c = rq_wb_c;
                double db_c = rq_db_c;
                double db_h = rq_db_h;
                double wb_h = rq_wb_h;
                //double est_sh_h = 0;

                //est_cool = bll.CalIndoorEstCapacity(inItem, db_c, wb_c, out est_sh, false);
                //估算室内机容量不再返回显热 20161111 by Yunxiao Lin
                est_cool = bll.CalIndoorEstCapacity(inItem, db_c, wb_c, false);
                if (!ValidateEstCapacity(est_cool, inItem.PartLoadTableName))
                {
                    return;
                }
                //显热由估算容量乘以SHF系数得到 20161112 by Yunxiao Lin
                //double shf = 0d;
                //if (_shf_mode == "High")
                //    shf = inItem.SHF_Hi;
                //else if (_shf_mode == "Medium")
                //    shf = inItem.SHF_Med;
                //else
                //    shf = inItem.SHF_Lo;
                //if (shf == 0d)
                //    shf = inItem.SHF_Hi;
                double shf = inItem.GetSHF(_fanSpeedLevel);
                est_sh = est_cool * shf;

                if (!inItem.ProductType.Contains(", CO"))
                {
                    //估算室内机容量不再返回显热 20161111 by Yunxiao Lin
                    //est_heat = bll.CalIndoorEstCapacity(inItem, wb_h, db_h, out est_sh_h, true);
                    est_heat = bll.CalIndoorEstCapacity(inItem, wb_h, db_h, true);
                    if (!ValidateEstCapacity(est_heat, inItem.PartLoadTableName))
                    {
                        return;
                    }
                }
            }
            airflow = Convert.ToDouble(stdRow["AirFlow"].ToString());
        }