/// <summary> /// 检查组合限制 /// </summary> /// <returns></returns> private bool CheckCombinationLimitation(CentralController newType) { foreach (Control item in this.Controls) { if (item is ucDropController) { ucDropController uc = (item as ucDropController); CentralController existControllerType = uc.TypeInfo; if (existControllerType == null) { continue; } if (newType == existControllerType) { continue; } //验证新加的控制器类型是否和已有的控制器互相兼容 if (CheckControllerCompatible(newType, existControllerType, 1) == false) { return(false); } } } return(true); }
public ucDropController GetEmptyController() { for (int i = this.Controls.Count - 1; i >= 0; i--) { if (this.Controls[i] is ucDropController) { ucDropController c = this.Controls[i] as ucDropController; if (c.Controller == null) { return(c); } } } return(null); }
public bool HasHLinkI() { foreach (Control control in this.Controls) { if (control is ucDropController) { ucDropController ucController = control as ucDropController; if (ucController.TypeInfo != null && ucController.TypeInfo.Protocol.Trim().ToUpper() == "H-LINK") { return(true); } } } return(false); }
public ucDropController GetControllerByModelName(string modelName) { foreach (Control control in this.Controls) { if (control is ucDropController) { ucDropController ucController = control as ucDropController; if (ucController.TypeInfo != null && ucController.TypeInfo.Model == modelName) { return(ucController); } } } return(null); }
/// 后台加载Controller对象 /// <summary> /// 后台加载Controller对象 /// </summary> /// <param name="item"></param> public ucDropController AddController(Controller item, CentralController type) { ucDropController uc = new ucDropController(); if (item != null && type != null) { uc.BindToControl_Controller(item, type); } this.Controls.Add(uc); uc.BeforeDrop += new DropEventHandler(ucController_BeforeDrop); uc.AfterDrop += new DropEventHandler(ucController_AfterDrop); uc.BeforeRemove += new EventHandler(ucController_BeforeRemove); uc.BeforeAdd += new EventHandler(ucController_BeforeAdd); return(uc); }
/// 获取当前控件中指定控制器类型以外的ucDropController控件的数量,用于验证 /// <summary> /// 获取当前控件中指定控制器类型以外的ucDropController控件的数量,用于验证 /// </summary> /// <param name="type"></param> /// <returns></returns> public int GetOtherControllerQty(string modelName) { int qty = 0; foreach (Control item in this.Controls) { if (item is ucDropController) { ucDropController uc = (item as ucDropController); if (uc.IsActive) { if (uc.Controller.Model != modelName) { qty += uc.Controller.Quantity; } } } } return(qty); }
/// 获取当前控件中指定控制器类型的ucDropController控件的数量,用于验证 /// <summary> /// 获取当前控件中指定控制器类型的ucDropController控件的数量,用于验证,需求更改 /// </summary> /// <param name="type"></param> /// <returns></returns> public int GetControllerQty(ControllerType type) { int qty = 0; foreach (Control item in this.Controls) { if (item is ucDropController) { ucDropController uc = (item as ucDropController); Controller controller = uc.Controller; CentralController typeInfo = uc.TypeInfo; if (uc.IsActive) { if (uc.Controller.Type == type) { qty += uc.Controller.Quantity; } } } } return(qty); }
/// 获取当前控件中ucDropController控件的数量,用于验证是否超出最大数量限制 /// <summary> /// 获取当前控件中ucDropController控件的数量,用于验证是否超出最大数量限制 /// </summary> /// <returns></returns> public int GetControllerQty() { int qty = 0; foreach (Control item in this.Controls) { if (item is ucDropController) { ucDropController ucController = item as ucDropController; Controller controller = ucController.Controller; CentralController typeInfo = ucController.TypeInfo; if (controller != null) { //软件不参与统计 modified by Shen Junjie on 2017/12/20 if (typeInfo.Type != ControllerType.Software) { qty += controller.Quantity; } } } } return(qty); }
///// 计算当前Control Group中不同模式下最大的室外机数量 ///// <summary> ///// 计算当前Control Group中不同模式下最大的室外机数量, ///// Model模式:一个ONOFF返回4,一个CC返回16; ///// Bacnet模式:返回16 ///// </summary> ///// <returns></returns> //public int GetMaxOutdoorQty_BeforeDrop(ControllerLayoutType type) //{ // if (type == ControllerLayoutType.MODBUS) // { // foreach (Control item in this.Controls) // { // if (item is ucDropController) // { // ucDropController ucController = item as ucDropController; // if (ucController.IsActive) // { // ControllerType controllerType = ucController.TypeInfo.Type; // if (controllerType == ControllerType.ONOFF) // return 4; // } // } // } // } // return 16; //} ///// 计算当前Control Group中不同模式下最大的室外机数量 ///// <summary> ///// 计算当前Control Group中不同模式下最大的室外机数量, ///// 只要看Bacnet模式:有CC则返回16,没有CC则返回ONOFF个数×4(小于等于16时)的值 ///// </summary> ///// <param name="type"></param> ///// <returns></returns> //public int GetMaxOutdoorQty_AfterDrop(ControllerLayoutType type) //{ // if (type == ControllerLayoutType.BACNET) // { // int controllerQty_CC = GetControllerQty(ControllerType.CentralController); // if (controllerQty_CC == 0) // { // int controllerQty = GetControllerQty(ControllerType.ONOFF); // return controllerQty * 4; // } // } // return GetMaxOutdoorQty_BeforeDrop(type); //} ///// 获取当前Control Group中不同模式下最大的控制器数量 ///// <summary> ///// 获取当前Control Group中不同模式下最大的控制器数量 ///// </summary> ///// <param name="type"></param> ///// <returns></returns> //public int GetMaxControllerQty(ControllerLayoutType type) //{ // if (type == ControllerLayoutType.MODBUS) // return 1; // return 16; //} /// Outdoor拖拽前可行性检查,不满足拖拽条件则弹出提示 /// <summary> /// Outdoor拖拽前可行性检查,不满足拖拽条件则弹出提示 /// </summary> /// <param name="sender">目标控件</param> /// <param name="e">源控件</param> /// <returns></returns> private bool CheckBeforeDropOutdoor(object sender, DragEventArgs e) { if (UtilControl.CheckDragType_ListViewItem(e)) { ListView lvTarget = (sender as ListView); // 目标控件 ListViewItem item = (ListViewItem)e.Data.GetData(type_ListViewItem, false); // 源控件 ListView lvSrc = item.ListView; // 如果源跟目标ListView同一个,则不可拖拽且不提示 if (lvTarget == lvSrc && lvSrc.Parent is ucDropOutdoor) { return(false); } //int currentOutdoorQty = GetOutdoorQty(); //int maxOutdoorQty = GetMaxOutdoorQty_BeforeDrop(glProject.ControllerLayoutType); //// 拖拽前检查必须小于,不能等于允许的最大数量 //if (currentOutdoorQty < maxOutdoorQty) // return true; //else // JCMsg.ShowWarningOK(Msg.CONTROLLER_OUTDOOR_QTY); //获取已经目标区域的各种设备数量 int controllerQty = GetControllerQty(); int outdoorQty = GetOutdoorQty(); int indoorQty = GetIndoorQty(); if (!item.Name.Contains("Heat Exchanger")) { outdoorQty++; } //加上拖动的设备数量 // outdoorQty++; if (item.Tag is Int32) { indoorQty += Convert.ToInt32(item.Tag); } else if (item.Tag is Object[]) { Object[] values = item.Tag as Object[]; if (values != null && values.Length > 1 && values[1] is Int32) { indoorQty += Convert.ToInt32(values[1]); } } //EU暂时忽略设备数及Hlink限制 add on 20180629 by axj if (_mainRegion == "EU_E" || _mainRegion == "EU_S" || _mainRegion == "EU_W") { return(true); } //Ooutdoor Unit Quantity + Indoor Unit Quantity int unitQty = outdoorQty + indoorQty; //总设备数量 int deviceQty = controllerQty + unitQty; //TODO: 此处还需要加上remote controller的数量 //检查设备数量是否符合H-Link的限制范围之内 bool isHLinkII = !HasHLinkI(); if (CheckHLinkLimiation(isHLinkII, indoorQty, outdoorQty, deviceQty) == false) { return(false); } List <string> types = ucDropOutdoor1.GetProductTypesWith(item); //if (_mainRegion.StartsWith("EU")) //对EU暂时取消限制 // return true; //检查设备数量是否符合各种controller的限制 foreach (Control control in this.Controls) { if (control is ucDropController) { ucDropController ucController = control as ucDropController; if (ucController.TypeInfo != null) { ////检查产品类型是否匹配 //if (CheckProductType(types, ucController.TypeInfo.ProductType) == false) //{ // return false; //} //检查室内机、室外机和设备总数的限制 if (CheckSystemQtyLimitation(ucController.TypeInfo, indoorQty, outdoorQty, deviceQty) == false) { return(false); } } } } } return(true); }
/// 检验ucDropControlGroup中的Controller的拖拽 /// <summary> /// 检验ucDropControlGroup中的Controller的拖拽 /// </summary> /// <param name="sender">目标控件</param> /// <param name="e">源控件</param> /// <returns></returns> private bool CheckBeforeDropController(object sender, DragEventArgs e) { if (!UtilControl.CheckDragType_PictureBox(e)) { return(false); } PictureBox pbTarget = sender as PictureBox; // 目标控件 PictureBox pbSrc = (PictureBox)e.Data.GetData(type_PictureBox); // 源控件 //不能自己拖向自己 if (pbTarget == pbSrc) { return(false); } ucDropController ucDropControllerSource = pbSrc.Parent is ucDropController ? (ucDropController)pbSrc.Parent : null; ucDropController ucDropControllerTarget = pbTarget.Parent is ucDropController ? (ucDropController)pbTarget.Parent : null; //不能目标不在controller group区域 if (ucDropControllerTarget == null) { return(false); } CentralController controllerTypeSource; if (ucDropControllerSource == null) { controllerTypeSource = (pbSrc.Tag as CentralController); } else { controllerTypeSource = ucDropControllerSource.TypeInfo; } if (controllerTypeSource == null) { return(false); } //目标ucDropController控件已经含有controller if (ucDropControllerTarget.IsActive) { //如果不是同一种控制器,则不允许拖上去 if (controllerTypeSource.Model != ucDropControllerTarget.TypeInfo.Model) { return(false); } } //目标ucDropController控件是空白的 else { // 若属于同一个ucDropControlGroup,则不可以拖拽 if (pbSrc.Parent.Parent is ucDropControlGroup && pbSrc.Parent.Parent == this) { return(false); } //如果已经存在此型号的controller则不允许添加 if (this.HasControllerType(controllerTypeSource.Model)) { return(false); } } //拖动的controller的数量 int addNumber = 1; if (ucDropControllerSource != null && ucDropControllerSource.Controller != null) { addNumber = ucDropControllerSource.Controller.Quantity; } ListViewItem item = (ListViewItem)e.Data.GetData(type_ListViewItem, false); //继续检查 return(CheckBeforeAddController(controllerTypeSource, addNumber)); }