/// <summary> /// 获取控制器上传的全部信息 /// </summary> /// <returns></returns> public override ControllerModel GetControllerUploadedInfo() { LoopModel loop = null; //= new LoopModel(); foreach (var device in DeviceInfoList) { if (loop == null) { loop = new LoopModel(); loop.ID = Convert.ToInt32(device.LoopID); } if (loop.ID == device.LoopID) { loop.SetDevice <DeviceInfo8036>(device); } else { base.ControllerModel.Loops.Add(loop); loop = new LoopModel(); loop.ID = Convert.ToInt32(device.LoopID); loop.SetDevice <DeviceInfo8036>(device); } } if (loop != null) //将最后一个回路增加至控制器的回路中 { base.ControllerModel.Loops.Add(loop); } foreach (var standard in StandardLinkageConfigList) { base.ControllerModel.StandardConfig.Add(standard); } return(base.ControllerModel); }
public static void Get8036DevInfo(out List <DeviceInfo8036> lstDevInfo) { ControllerModel cModel = new ControllerModel(1, "8036", ControllerType.NT8036, 3); cModel.MachineNumber = "001"; LoopModel lModel = new LoopModel(); lModel.Controller = cModel; lModel.Code = "01"; lstDevInfo = new List <DeviceInfo8036>(); DeviceInfo8036 dev = new DeviceInfo8036(); dev.ID = 1; dev.Loop = lModel; dev.Code = "00101001"; dev.TypeCode = 36; dev.Disable = 0; dev.LinkageGroup1 = "1"; dev.LinkageGroup2 = "2"; dev.AlertValue = 0; dev.ForcastValue = 0; dev.DelayValue = 0; dev.BuildingNo = 5; dev.ZoneNo = 6; dev.FloorNo = 7; dev.RoomNo = 8; dev.Location = "仙鹤哈里发9"; lstDevInfo.Add(dev); }
public LoopModel GetDevicesByLoop(LoopModel loop) { //StringBuilder sbQuerySQL = new StringBuilder("select ID,Code,Disable,CurrentThreshold,TemperatureThreshold,BuildingNo,ZoneNo,FloorNo,RoomNo,Location,LoopID,TypeCode from DeviceInfo8021 where LoopID=" + loop.ID); //System.Data.DataTable dt = _databaseService.GetDataTableBySQL(sbQuerySQL); //for (int i = 0; i < dt.Rows.Count; i++) //{ // Model.DeviceInfo8021 model = new Model.DeviceInfo8021(); // model.ID = Convert.ToInt32(dt.Rows[i]["id"]); // model.Code = dt.Rows[i]["Code"].ToString(); // model.Disable = (bool?)dt.Rows[i]["Disable"]; // model.CurrentThreshold = new Nullable<float>(Convert.ToSingle(dt.Rows[i]["CurrentThreshold"])); // model.TemperatureThreshold = new Nullable<float>(Convert.ToSingle(dt.Rows[i]["TemperatureThreshold"])); // model.BuildingNo = new Nullable<short>(Convert.ToInt16(dt.Rows[i]["BuildingNo"])); // model.ZoneNo = new Nullable<short>(Convert.ToInt16(dt.Rows[i]["ZoneNo"])); // model.FloorNo = new Nullable<short>(Convert.ToInt16(dt.Rows[i]["FloorNo"])); // model.RoomNo = new Nullable<short>(Convert.ToInt16(dt.Rows[i]["RoomNo"])); // model.Location = dt.Rows[i]["Location"].ToString(); // model.LoopID = Convert.ToInt32(dt.Rows[i]["LoopID"]); // model.TypeCode = Convert.ToInt16(dt.Rows[i]["TypeCode"]); // model.Loop = loop; // model.LoopID = loop.ID; // loop.SetDevice<DeviceInfo8021>(model); //} //return loop; return(_dbFileVersionService.GetDevicesByLoopForControllerType8021(loop)); }
public bool GetDevicesByLoopForControllerType8036(ref LoopModel loop) { List <DeviceInfo8036> lstDeviceInfo8036 = new List <DeviceInfo8036>(); string strDeviceQuerySQL = "select bianhao,leixing,geli,yanshi,shuchu1,shuchu2,nongdu,yjnongdu,louhao,quhao,cenghao,fangjianhao,didian from "; strDeviceQuerySQL += loop.Code; DataTable dtDevices = _databaseService.GetDataTableBySQL(new StringBuilder(strDeviceQuerySQL)); int dtDevicesRowsCount = dtDevices.Rows.Count; for (int j = 0; j < dtDevicesRowsCount; j++) //器件信息 { DeviceInfo8036 device = new DeviceInfo8036(); device.Code = dtDevices.Rows[j]["bianhao"].ToString(); device.Disable = dtDevices.Rows[j]["geli"].ToString().ToNullable <bool>(); Int16?intTypeCode = dtDevices.Rows[j]["leixing"].ToString().Substring(0, 3).ToNullable <Int16>(); device.TypeCode = (short)intTypeCode; device.DelayValue = dtDevices.Rows[j]["yanshi"].ToString().ToNullable <Int16>(); device.LinkageGroup1 = dtDevices.Rows[j]["shuchu1"].ToString(); device.LinkageGroup2 = dtDevices.Rows[j]["shuchu2"].ToString(); device.AlertValue = dtDevices.Rows[j]["nongdu"].ToString().ToNullable <float>(); device.ForcastValue = dtDevices.Rows[j]["yjnongdu"].ToString().ToNullable <float>(); device.BuildingNo = dtDevices.Rows[j]["louhao"].ToString().ToNullable <Int16>(); device.ZoneNo = dtDevices.Rows[j]["quhao"].ToString().ToNullable <Int16>(); device.FloorNo = dtDevices.Rows[j]["cenghao"].ToString().ToNullable <Int16>(); device.RoomNo = dtDevices.Rows[j]["fangjianhao"].ToString().ToNullable <Int16>(); device.Location = dtDevices.Rows[j]["didian"].ToString(); device.Loop = loop; loop.SetDevice <DeviceInfo8036>(device); lstDeviceInfo8036.Add(device); } return(true); }
public List <Model.LoopModel> CreateLoops <T>(int loopsAmount, int deviceAmount, Model.ControllerModel controller, IDeviceService <T> deviceService) { string strMachineNumber = controller.MachineNumber; ControllerOperationCommon controllerBase = new ControllerOperationCommon(); int loopID = controllerBase.GetMaxLoopID(); string strLoopLengthFormat = "#"; for (int i = 0; i < controller.LoopAddressLength; i++) { strLoopLengthFormat += "0"; } List <Model.LoopModel> lstLoopModel = new List <LoopModel>(); for (int i = 0; i < loopsAmount; i++) //创建回路 { LoopModel loop = new LoopModel(); loop.Controller = controller; loop.ID = loopID++; loop.Code = strMachineNumber + i.ToString(strLoopLengthFormat); loop.Name = strMachineNumber + i.ToString(strLoopLengthFormat); loop.DeviceAmount = deviceAmount; loop.SetDevices <T>(deviceService.InitializeDevices(deviceAmount)); lstLoopModel.Add(loop); loop.IsLoopDataDirty = true; // SetDataDirty(); } return(lstLoopModel); }
public ControllerModel OrganizeControllerInfoFromSpecifiedDBFileVersion(IDBFileVersionService dbFileVersionService, ControllerModel controller) { ControllerModel controllerInfo = controller; List <LoopModel> lstLoopInfo = dbFileVersionService.GetLoopsByController(controller); StringBuilder sbQuerySQL = new StringBuilder(); //set sdpkey=xianggh,xianggh= (Round((xianggh/756)+.4999999)-1),panhao=IIF(Round(((xianggh/63))+.4999999)>12,Round(((xianggh/63))+.4999999)-12,Round(((xianggh/63))+.4999999)),jianhao=IIF((xianggh Mod 63)=0,63,xianggh Mod 63) //(1)回路及器件 foreach (var l in lstLoopInfo)//回路信息 { LoopModel loop = l; dbFileVersionService.GetDevicesByLoopForControllerType8000(ref loop);//为loop赋予“器件信息” loop.Controller = controllerInfo; controllerInfo.Loops.Add(loop); } //(2)标准组态 List <LinkageConfigStandard> lstStandard = dbFileVersionService.GetStandardLinkageConfig(controller); foreach (var l in lstStandard) { LinkageConfigStandard standardConfig = l; standardConfig.Controller = controllerInfo; controllerInfo.StandardConfig.Add(standardConfig); } return(controllerInfo); }
public LoopModel GetDevicesByLoop(LoopModel loop) { StringBuilder sbQuerySQL = new StringBuilder("select ID,Code,Disable,Feature,SensitiveLevel,LinkageGroup1,LinkageGroup2,BuildingNo,ZoneNo,FloorNo,RoomNo,Location,LoopID,TypeCode from DeviceInfo8007 where LoopID=" + loop.ID); System.Data.DataTable dt = _databaseService.GetDataTableBySQL(sbQuerySQL); for (int i = 0; i < dt.Rows.Count; i++) { Model.DeviceInfo8007 model = new Model.DeviceInfo8007(); model.ID = Convert.ToInt32(dt.Rows[i]["id"]); model.Code = dt.Rows[i]["Code"].ToString(); model.Disable = (bool?)dt.Rows[i]["Disable"]; model.Feature = new Nullable <short>(Convert.ToInt16(dt.Rows[i]["Feature"])); model.SensitiveLevel = new Nullable <short>(Convert.ToInt16(dt.Rows[i]["SensitiveLevel"])); model.LinkageGroup1 = dt.Rows[i]["LinkageGroup1"].ToString(); model.LinkageGroup2 = dt.Rows[i]["LinkageGroup2"].ToString(); model.BuildingNo = new Nullable <short>(Convert.ToInt16(dt.Rows[i]["BuildingNo"])); model.ZoneNo = new Nullable <short>(Convert.ToInt16(dt.Rows[i]["ZoneNo"])); model.FloorNo = new Nullable <short>(Convert.ToInt16(dt.Rows[i]["FloorNo"])); model.RoomNo = new Nullable <short>(Convert.ToInt16(dt.Rows[i]["RoomNo"])); model.Location = dt.Rows[i]["Location"].ToString(); model.LoopID = Convert.ToInt32(dt.Rows[i]["LoopID"]); model.TypeCode = Convert.ToInt16(dt.Rows[i]["TypeCode"]); model.Loop = loop; model.LoopID = loop.ID; loop.SetDevice <DeviceInfo8007>(model); } return(loop); }
public bool AddDeviceForControllerType8007(LoopModel loop) { List <DeviceInfo8007> lstDeviceInfo8007 = new List <DeviceInfo8007>(); string strDeviceQuerySQL = "select bianhao,leixing,texing,geli,lingmd,shuchu1,shuchu2,louhao,quhao,cenghao,fangjianhao,didian from "; strDeviceQuerySQL += loop.Code; DataTable dtDevices = _databaseService.GetDataTableBySQL(new StringBuilder(strDeviceQuerySQL)); int dtDevicesRowsCount = dtDevices.Rows.Count; for (int j = 0; j < dtDevicesRowsCount; j++) //器件信息 { DeviceInfo8007 device = new DeviceInfo8007(); device.Code = dtDevices.Rows[j]["bianhao"].ToString(); Int16?intTypeCode = dtDevices.Rows[j]["leixing"].ToString().Substring(0, 3).ToNullable <Int16>(); device.TypeCode = (short)intTypeCode; //device.Feature = dtDevices.Rows[j]["texing"].ToString(); device.Disable = dtDevices.Rows[j]["geli"].ToString().ToNullable <bool>(); device.SensitiveLevel = dtDevices.Rows[j]["lingmd"].ToString().ToNullable <Int16>(); device.LinkageGroup1 = dtDevices.Rows[j]["shuchu1"].ToString(); device.LinkageGroup2 = dtDevices.Rows[j]["shuchu2"].ToString(); device.BuildingNo = dtDevices.Rows[j]["louhao"].ToString().ToNullable <Int16>(); device.ZoneNo = dtDevices.Rows[j]["quhao"].ToString().ToNullable <Int16>(); device.FloorNo = dtDevices.Rows[j]["cenghao"].ToString().ToNullable <Int16>(); device.RoomNo = dtDevices.Rows[j]["fangjianhao"].ToString().ToNullable <Int16>(); device.Location = dtDevices.Rows[j]["didian"].ToString(); device.Loop = loop; loop.SetDevice <DeviceInfo8007>(device); lstDeviceInfo8007.Add(device); } return(true); }
public ControllerModel OrganizeControllerInfoFromSpecifiedDBFileVersion(IDBFileVersionService dbFileVersionService, ControllerModel controller) { ControllerModel controllerInfo = controller; List <LoopModel> lstLoopInfo = dbFileVersionService.GetLoopsByController(controller); StringBuilder sbQuerySQL = new StringBuilder(); //(1)回路及器件 foreach (var l in lstLoopInfo)//回路信息 { LoopModel loop = l; dbFileVersionService.GetDevicesByLoopForControllerType8003(ref loop);//为loop赋予“器件信息” loop.Controller = controllerInfo; controllerInfo.Loops.Add(loop); } //(2)标准组态 List <LinkageConfigStandard> lstStandard = dbFileVersionService.GetStandardLinkageConfig(controller); foreach (var l in lstStandard) { LinkageConfigStandard standardConfig = l; standardConfig.Controller = controllerInfo; controllerInfo.StandardConfig.Add(standardConfig); } return(controllerInfo); }
public bool GetDevicesByLoopForControllerType8003(ref LoopModel loop) { List <DeviceInfo8003> lstDeviceInfo8003 = new List <DeviceInfo8003>(); string strDeviceQuerySQL = "select bianhao,leixing,geli,lingmd,shuchu1,shuchu2,shuchu3,yanshi,xianggh,zjczbh,GbZone,didian from "; strDeviceQuerySQL += loop.Code; DataTable dtDevices = _databaseService.GetDataTableBySQL(new StringBuilder(strDeviceQuerySQL)); int dtDevicesRowsCount = dtDevices.Rows.Count; for (int j = 0; j < dtDevicesRowsCount; j++) //器件信息 { DeviceInfo8003 device = new DeviceInfo8003(); device.Code = dtDevices.Rows[j]["bianhao"].ToString(); Int16?intTypeCode = dtDevices.Rows[j]["leixing"].ToString().Substring(0, 3).ToNullable <Int16>(); device.TypeCode = (short)intTypeCode; device.Disable = dtDevices.Rows[j]["geli"].ToString().ToNullable <bool>(); device.SensitiveLevel = dtDevices.Rows[j]["lingmd"].ToString().ToNullable <Int16>(); device.LinkageGroup1 = dtDevices.Rows[j]["shuchu1"].ToString(); device.LinkageGroup2 = dtDevices.Rows[j]["shuchu2"].ToString(); device.LinkageGroup3 = dtDevices.Rows[j]["shuchu3"].ToString(); device.DelayValue = dtDevices.Rows[j]["yanshi"].ToString().ToNullable <Int16>(); device.sdpKey = dtDevices.Rows[j]["xianggh"].ToString(); device.ZoneNo = dtDevices.Rows[j]["zjczbh"].ToString().ToNullable <Int16>(); device.BroadcastZone = dtDevices.Rows[j]["GbZone"].ToString(); device.Location = dtDevices.Rows[j]["didian"].ToString(); device.Loop = loop; loop.SetDevice <DeviceInfo8003>(device); lstDeviceInfo8003.Add(device); } return(true); }
public LoopModel GetDevicesByLoop(LoopModel loop) { //StringBuilder sbQuerySQL = new StringBuilder("select ID,Code,Disable,Feature,DelayValue,SensitiveLevel,BroadcastZone,LinkageGroup1,LinkageGroup2,LinkageGroup3,ZoneNo,Location,SDPKey,LoopID,TypeCode from DeviceInfo8000 where LoopID=" + loop.ID); //System.Data.DataTable dt = _databaseService.GetDataTableBySQL(sbQuerySQL); //for (int i = 0; i < dt.Rows.Count; i++) //{ // Model.DeviceInfo8000 model = new Model.DeviceInfo8000(); // model.ID = Convert.ToInt32(dt.Rows[i]["id"]); // model.Code = dt.Rows[i]["Code"].ToString(); // model.Disable = (bool?)dt.Rows[i]["Disable"]; // model.Feature = new Nullable<short>(Convert.ToInt16(dt.Rows[i]["Feature"])); // model.DelayValue = new Nullable<short>(Convert.ToInt16(dt.Rows[i]["DelayValue"])); // model.SensitiveLevel = new Nullable<short>(Convert.ToInt16(dt.Rows[i]["SensitiveLevel"])); // model.BroadcastZone = dt.Rows[i]["SensitiveLevel"].ToString(); // model.LinkageGroup1 = dt.Rows[i]["LinkageGroup1"].ToString(); // model.LinkageGroup2 = dt.Rows[i]["LinkageGroup2"].ToString(); // model.LinkageGroup3 = dt.Rows[i]["LinkageGroup3"].ToString(); // model.ZoneNo = new Nullable<short>(Convert.ToInt16(dt.Rows[i]["ZoneNo"])); // model.Location = dt.Rows[i]["Location"].ToString(); // model.sdpKey = dt.Rows[i]["sdpKey"].ToString(); // model.LoopID = Convert.ToInt32(dt.Rows[i]["LoopID"]); // model.TypeCode = Convert.ToInt16(dt.Rows[i]["TypeCode"]); // model.Loop = loop; // model.LoopID = loop.ID; // loop.SetDevice<DeviceInfo8000>(model); //} //return loop; return(_dbFileVersionService.GetDevicesByLoopForControllerType8000(loop)); }
public LoopModel GetDevicesByLoop(LoopModel loop) { StringBuilder sbQuerySQL = new StringBuilder("select ID,Code ,Disable,LinkageGroup1,LinkageGroup2,AlertValue ,ForcastValue ,DelayValue ,BuildingNo ,ZoneNo ,FloorNo ,RoomNo ,Location ,LoopID,TypeCode from DeviceInfo8036 where LoopID=" + loop.ID); System.Data.DataTable dt = _databaseService.GetDataTableBySQL(sbQuerySQL); for (int i = 0; i < dt.Rows.Count; i++) { Model.DeviceInfo8036 model = new Model.DeviceInfo8036(); model.ID = Convert.ToInt16(dt.Rows[i]["id"]); model.Code = dt.Rows[i]["Code"].ToString(); model.Disable = Convert.ToInt16(dt.Rows[i]["Disable"]); model.LinkageGroup1 = dt.Rows[i]["LinkageGroup1"].ToString(); model.LinkageGroup2 = dt.Rows[i]["LinkageGroup2"].ToString(); model.AlertValue = Convert.ToSingle(dt.Rows[i]["AlertValue"]); model.ForcastValue = Convert.ToSingle(dt.Rows[i]["ForcastValue"]); model.DelayValue = new Nullable <short>(Convert.ToInt16(dt.Rows[i]["DelayValue"])); model.BuildingNo = new Nullable <short>(Convert.ToInt16(dt.Rows[i]["BuildingNo"])); model.ZoneNo = new Nullable <short>(Convert.ToInt16(dt.Rows[i]["ZoneNo"])); model.FloorNo = new Nullable <short>(Convert.ToInt16(dt.Rows[i]["FloorNo"])); model.RoomNo = new Nullable <short>(Convert.ToInt16(dt.Rows[i]["RoomNo"])); model.Location = dt.Rows[i]["Location"].ToString(); model.LoopID = new Nullable <int>(Convert.ToInt32(dt.Rows[i]["LoopID"])); model.TypeCode = Convert.ToInt16(dt.Rows[i]["TypeCode"]); model.Loop = loop; model.LoopID = loop.ID; loop.SetDevice <DeviceInfo8036>(model); } return(loop); }
public bool GetDevicesByLoopForControllerType8021(ref LoopModel loop) { List <DeviceInfo8021> lstDeviceInfo8021 = new List <DeviceInfo8021>(); string strDeviceQuerySQL = "select bianhao,leixing,geli,didian,louhao,quhao,cenghao,fangjianhao,dlbaojing,wdbaojing from "; strDeviceQuerySQL += loop.Code; DataTable dtDevices = _databaseService.GetDataTableBySQL(new StringBuilder(strDeviceQuerySQL)); int dtDevicesRowsCount = dtDevices.Rows.Count; for (int j = 0; j < dtDevicesRowsCount; j++) //器件信息 { DeviceInfo8021 device = new DeviceInfo8021(); device.Code = dtDevices.Rows[j]["bianhao"].ToString(); device.Disable = dtDevices.Rows[j]["geli"].ToString().ToNullable <bool>(); Int16?intTypeCode = dtDevices.Rows[j]["leixing"].ToString().Substring(0, 3).ToNullable <Int16>(); device.TypeCode = (short)intTypeCode; device.Location = dtDevices.Rows[j]["didian"].ToString(); device.BuildingNo = dtDevices.Rows[j]["louhao"].ToString().ToNullable <Int16>(); device.ZoneNo = dtDevices.Rows[j]["quhao"].ToString().ToNullable <Int16>(); device.FloorNo = dtDevices.Rows[j]["cenghao"].ToString().ToNullable <Int16>(); device.RoomNo = dtDevices.Rows[j]["fangjianhao"].ToString().ToNullable <Int16>(); device.CurrentThreshold = dtDevices.Rows[j]["dlbaojing"].ToString().ToNullable <float>(); device.TemperatureThreshold = dtDevices.Rows[j]["wdbaojing"].ToString().ToNullable <float>(); device.Loop = loop; loop.SetDevice <DeviceInfo8021>(device); lstDeviceInfo8021.Add(device); } return(true); }
public ProjectModel UpgradeToDestinationVersion(ProjectModel project) { int controllerCount = project.Controllers.Count; int maxControllerID = ProjectManager.GetInstance.MaxIDForController; int maxLoopID = ProjectManager.GetInstance.MaxIDForLoop; for (int i = 0; i < controllerCount; i++) { maxControllerID++; ControllerModel controller = project.Controllers[i]; controller.ID = maxControllerID; for (int j = 0; j < controller.Loops.Count; j++) { maxLoopID++; if (controller.Loops[j].DeviceAmount != 0) { LoopModel loop = controller.Loops[j]; // loop.ID = maxLoopID; GenerateDeviceID(controller.Type, ref loop); UpdateDeviceInfo(controller.Type, ref loop); controller.Loops[j] = loop; } } for (int k = 0; k < controller.StandardConfig.Count; k++) { int maxStandardLinkageConfigID = ProjectManager.GetInstance.MaxIDForStandardLinkageConfig; maxStandardLinkageConfigID++; controller.StandardConfig[k].ID = maxStandardLinkageConfigID; ProjectManager.GetInstance.MaxIDForStandardLinkageConfig = maxStandardLinkageConfigID; } for (int m = 0; m < controller.MixedConfig.Count; m++) { int maxMixedLinkageConfigID = ProjectManager.GetInstance.MaxIDForMixedLinkageConfig; maxMixedLinkageConfigID++; controller.MixedConfig[m].ID = maxMixedLinkageConfigID; ProjectManager.GetInstance.MaxIDForMixedLinkageConfig = maxMixedLinkageConfigID; } for (int n = 0; n < controller.GeneralConfig.Count; n++) { int maxGeneralLinkageConfigID = ProjectManager.GetInstance.MaxIDForGeneralLinkageConfig; maxGeneralLinkageConfigID++; controller.GeneralConfig[n].ID = maxGeneralLinkageConfigID; ProjectManager.GetInstance.MaxIDForGeneralLinkageConfig = maxGeneralLinkageConfigID; } for (int o = 0; o < controller.MixedConfig.Count; o++) { int maxMCBConfigID = ProjectManager.GetInstance.MaxIDForManualControlBoard; maxMCBConfigID++; controller.ControlBoard[o].ID = maxMCBConfigID; ProjectManager.GetInstance.MaxIDForManualControlBoard = maxMCBConfigID; } project.Controllers[i] = controller; } ProjectManager.GetInstance.MaxIDForLoop = maxLoopID; ProjectManager.GetInstance.MaxIDForController = maxControllerID; return(project); }
public int SetLoopRange(LoopModel tmp) { int id_loop; db.SetLoopModels.Add(tmp); db.SaveChanges(); id_loop = tmp.Id; return(id_loop); }
public void DeleteLoopInfoExecute(object o) { if (o != null && o.GetType().Name == "LoopModel") { LoopModel loop = (LoopModel)o; SCA.Interface.ILoopService loopService = new SCA.BusinessLib.BusinessLogic.LoopService(loop.Controller); loopService.DeleteLoopBySpecifiedLoopCode(loop.Code); } }
private bool UpdateDeviceInfo(ControllerType controllerType, ref LoopModel loop) { bool result = false; switch (controllerType) { case ControllerType.NT8001: break; case ControllerType.NT8007: break; case ControllerType.NT8021: break; case ControllerType.NT8036: break; case ControllerType.FT8000: { List <DeviceInfo8000> lstDeviceInfo = loop.GetDevices <DeviceInfo8000>(); foreach (var device in lstDeviceInfo) { if (device.TypeCode > 36 && device.TypeCode < 66) { device.Feature = 0; } else if (device.TypeCode >= 101 && device.TypeCode <= 129) { device.Feature = 1; device.TypeCode = System.Convert.ToInt16(device.TypeCode - 64); } } } break; case ControllerType.FT8003: { List <DeviceInfo8003> lstDeviceInfo = loop.GetDevices <DeviceInfo8003>(); foreach (var device in lstDeviceInfo) { if (device.TypeCode > 36 && device.TypeCode < 66) { device.Feature = 0; } else if (device.TypeCode >= 101 && device.TypeCode <= 129) { device.Feature = 1; device.TypeCode = System.Convert.ToInt16(device.TypeCode - 64); } } } break; } return(result); }
public void DeleteLoopRange(int id_loop) { LoopModel tmp = db.SetLoopModels.FirstOrDefault(u => u.Id == id_loop); if (tmp != null) { db.SetLoopModels.Remove(tmp); db.SaveChanges(); } }
public EditableDeviceInfo8003Collection(LoopModel loop, List <DeviceInfo8003> lstDeviceInfo8003) { _loop = loop; if (lstDeviceInfo8003 != null) { foreach (var o in lstDeviceInfo8003) { this.Add(new EditableDeviceInfo8003(o)); } } }
public bool GetDevicesByLoopForControllerType8001(ref LoopModel loop, Dictionary <string, string> dictDeviceMappingManualControlBoard) { List <DeviceInfo8001> lstDeviceInfo8001 = new List <DeviceInfo8001>(); string strDeviceQuerySQL = "select bianhao,leixing,geli,lingmd,shuchu1,shuchu2,shuchu3,yanshi,xianggh,panhao,jianhao,cleixing,GbZone,didian,louhao,quhao,cenghao,fangjianhao,sdpkey from "; //if (Version == 6) //8001控制器的版本6中增加了texing字段 //{ // strDeviceQuerySQL = "select bianhao,leixing,texing,geli,lingmd,shuchu1,shuchu2,shuchu3,yanshi,xianggh,panhao,jianhao,cleixing,GbZone,didian,louhao,quhao,cenghao,fangjianhao,sdpkey from "; //} strDeviceQuerySQL += loop.Code; DataTable dtDevices = _databaseService.GetDataTableBySQL(new StringBuilder(strDeviceQuerySQL)); int dtDevicesRowsCount = dtDevices.Rows.Count; for (int j = 0; j < dtDevicesRowsCount; j++) //器件信息 { DeviceInfo8001 device = new DeviceInfo8001(); device.Code = dtDevices.Rows[j]["bianhao"].ToString(); device.Disable = dtDevices.Rows[j]["geli"].ToString().ToNullable <bool>(); device.SensitiveLevel = dtDevices.Rows[j]["lingmd"].ToString().ToNullable <Int16>(); device.LinkageGroup1 = dtDevices.Rows[j]["shuchu1"].ToString(); device.LinkageGroup2 = dtDevices.Rows[j]["shuchu2"].ToString(); device.LinkageGroup3 = dtDevices.Rows[j]["shuchu3"].ToString(); device.DelayValue = dtDevices.Rows[j]["yanshi"].ToString().ToNullable <Int16>(); device.BoardNo = dtDevices.Rows[j]["xianggh"].ToString().ToNullable <Int16>(); device.SubBoardNo = dtDevices.Rows[j]["panhao"].ToString().ToNullable <Int16>(); device.KeyNo = dtDevices.Rows[j]["jianhao"].ToString().ToNullable <Int16>(); Int16?intTypeCode = dtDevices.Rows[j]["leixing"].ToString().Substring(0, 3).ToNullable <Int16>(); device.TypeCode = (short)intTypeCode; device.BroadcastZone = dtDevices.Rows[j]["GbZone"].ToString(); device.Location = dtDevices.Rows[j]["didian"].ToString(); device.BuildingNo = dtDevices.Rows[j]["louhao"].ToString().ToNullable <Int16>(); device.ZoneNo = dtDevices.Rows[j]["quhao"].ToString().ToNullable <Int16>(); device.FloorNo = dtDevices.Rows[j]["cenghao"].ToString().ToNullable <Int16>(); device.RoomNo = dtDevices.Rows[j]["fangjianhao"].ToString().ToNullable <Int16>(); device.sdpKey = dtDevices.Rows[j]["sdpkey"].ToString(); device.Loop = loop; if (dictDeviceMappingManualControlBoard != null) { if (dictDeviceMappingManualControlBoard.ContainsKey(device.Code))//如果存在网络手动盘的信息定义,则设置MCBCode的值,建立与手动盘的关系 { device.MCBCode = dictDeviceMappingManualControlBoard[device.Code]; } } //if(lstDeviceInfo8001.Count>0) //{ // _deviceAddressLength = lstDeviceInfo8001[0].Code.Length; //} loop.SetDevice <DeviceInfo8001>(device); lstDeviceInfo8001.Add(device); } return(true); }
/// <summary> /// 获取控制器上传的全部信息 /// </summary> /// <returns></returns> public override ControllerModel GetControllerUploadedInfo() { LoopModel loop = null; //= new LoopModel(); int loopAddressLength = 2; foreach (var device in DeviceInfoList) { if (loop == null) { loop = new LoopModel(); //loop.ID = Convert.ToInt32(device.LoopID); loop.Controller = device.Loop.Controller; loopAddressLength = loop.Controller.LoopAddressLength; loop.Code = device.Loop.Code.PadLeft(loopAddressLength, '0'); loop.Name = loop.Code; } //if (loop.ID == device.LoopID) if (loop.Code == device.Loop.Code.PadLeft(loopAddressLength, '0')) { device.Loop = loop; loop.SetDevice <DeviceInfo8007>(device); } else { loop.Code = loop.Controller.MachineNumber + loop.Code; loop.Name = loop.Code; base.ControllerModel.Loops.Add(loop); loop = new LoopModel(); loop.Controller = device.Loop.Controller; loop.Code = device.Loop.Code.PadLeft(loopAddressLength, '0'); loop.Name = loop.Code; device.Loop = loop; loop.SetDevice <DeviceInfo8007>(device); //base.ControllerModel.Loops.Add(loop); //loop = new LoopModel(); //loop.ID = Convert.ToInt32(device.LoopID); //loop.SetDevice<DeviceInfo8007>(device); } } if (loop != null) //将最后一个回路增加至控制器的回路中 { loop.Code = loop.Controller.MachineNumber + loop.Code; loop.Name = loop.Code; ControllerModel.Loops.Add(loop); } foreach (var standard in StandardLinkageConfigList) { ControllerModel.StandardConfig.Add(standard); } return(ControllerModel); }
public void TestModelWithLoopShouldSucceed() { var model = new LoopModel { Content = "Content1", Identity = "Identity1", }; model.Reference = model; var context = Handle(model); Assert.Single(context.LinkToUids); }
public bool AddDevice(LoopModel loop) { try { List <DeviceInfo8003> lstDevices = loop.GetDevices <DeviceInfo8003>(); foreach (var device in lstDevices) { device.Loop.ID = loop.ID; device.LoopID = loop.ID; //StringBuilder sbDeviceInfoSQL = new StringBuilder("REPLACE INTO DeviceInfo8003("); //sbDeviceInfoSQL.Append("ID,"); //sbDeviceInfoSQL.Append("Code,"); //sbDeviceInfoSQL.Append("Disable,"); //sbDeviceInfoSQL.Append("Feature,"); //sbDeviceInfoSQL.Append("DelayValue,"); //sbDeviceInfoSQL.Append("SensitiveLevel,"); //sbDeviceInfoSQL.Append("LinkageGroup1,"); //sbDeviceInfoSQL.Append("LinkageGroup2,"); //sbDeviceInfoSQL.Append("LinkageGroup3,"); //sbDeviceInfoSQL.Append("sdpKey,"); //sbDeviceInfoSQL.Append("BroadcastZone,"); //sbDeviceInfoSQL.Append("ZoneNo,"); //sbDeviceInfoSQL.Append("Location,"); //sbDeviceInfoSQL.Append("LoopID,"); //sbDeviceInfoSQL.Append("TypeCode)"); //sbDeviceInfoSQL.Append(" VALUES("); //sbDeviceInfoSQL.Append(device.ID + ",'"); //sbDeviceInfoSQL.Append(device.Code + "','"); //sbDeviceInfoSQL.Append(device.Disable + "','"); //sbDeviceInfoSQL.Append(device.Feature + "','"); //sbDeviceInfoSQL.Append(device.DelayValue + "','"); //sbDeviceInfoSQL.Append(device.SensitiveLevel + "','"); //sbDeviceInfoSQL.Append(device.LinkageGroup1 + "','"); //sbDeviceInfoSQL.Append(device.LinkageGroup2 + "','"); //sbDeviceInfoSQL.Append(device.LinkageGroup3 + "','"); //sbDeviceInfoSQL.Append(device.sdpKey + "','"); //sbDeviceInfoSQL.Append(device.BroadcastZone + "','"); //sbDeviceInfoSQL.Append(device.ZoneNo + "','"); //sbDeviceInfoSQL.Append(device.Location + "','"); //sbDeviceInfoSQL.Append(device.LoopID + "','"); //sbDeviceInfoSQL.Append(device.TypeCode + "');"); //_databaseService.ExecuteBySql(sbDeviceInfoSQL); _dbFileVersionService.AddDeviceForControllerType8003(device); } } catch (Exception ex) { return(false); } return(true); }
bool IDeviceDBServiceTest.AddDevice(LoopModel loop) { try { List <DeviceInfo8036> lstDevices = loop.GetDevices <DeviceInfo8036>(); foreach (var device in lstDevices) { device.Loop.ID = loop.ID; device.LoopID = loop.ID; //StringBuilder sbDeviceInfoSQL = new StringBuilder("REPLACE INTO DeviceInfo8036"); //sbDeviceInfoSQL.Append("(ID,"); //sbDeviceInfoSQL.Append("Code ,"); //sbDeviceInfoSQL.Append("Disable,"); //sbDeviceInfoSQL.Append("LinkageGroup1,"); //sbDeviceInfoSQL.Append("LinkageGroup2,"); //sbDeviceInfoSQL.Append("AlertValue ,"); //sbDeviceInfoSQL.Append("ForcastValue ,"); //sbDeviceInfoSQL.Append("DelayValue ,"); //sbDeviceInfoSQL.Append("BuildingNo ,"); //sbDeviceInfoSQL.Append("ZoneNo ,"); //sbDeviceInfoSQL.Append("FloorNo ,"); //sbDeviceInfoSQL.Append("RoomNo ,"); //sbDeviceInfoSQL.Append("Location ,"); //sbDeviceInfoSQL.Append("LoopID,"); //sbDeviceInfoSQL.Append("TypeCode"); //sbDeviceInfoSQL.Append(") VALUES("); //sbDeviceInfoSQL.Append(device.ID + ",'"); //sbDeviceInfoSQL.Append(device.Code + "','"); //sbDeviceInfoSQL.Append(device.Disable + "','"); //sbDeviceInfoSQL.Append(device.LinkageGroup1 + "','"); //sbDeviceInfoSQL.Append(device.LinkageGroup2 + "','"); //sbDeviceInfoSQL.Append(device.AlertValue + "','"); //sbDeviceInfoSQL.Append(device.ForcastValue + "','"); //sbDeviceInfoSQL.Append(device.DelayValue + "','"); //sbDeviceInfoSQL.Append(device.BuildingNo + "','"); //sbDeviceInfoSQL.Append(device.ZoneNo + "','"); //sbDeviceInfoSQL.Append(device.FloorNo + "','"); //sbDeviceInfoSQL.Append(device.RoomNo + "','"); //sbDeviceInfoSQL.Append(device.Location + "','"); //sbDeviceInfoSQL.Append(device.LoopID + "','"); //sbDeviceInfoSQL.Append(device.TypeCode + "');"); //_databaseService.ExecuteBySql(sbDeviceInfoSQL); _dbFileVersionService.AddDeviceForControllerType8036(device); } } catch (Exception ex) { return(false); } return(true); }
protected override bool ExistSameDeviceCode(LoopModel loop) { DeviceService8003 deviceService = new DeviceService8003(); deviceService.TheLoop = loop; if (deviceService.IsExistSameDeviceCode()) { return(true); } else { return(false); } }
public bool AddLoops(LoopModel loop, string machineNumber, int loopsAmount) { try { ControllerOperationCommon controllerBase = new ControllerOperationCommon(); int loopID = controllerBase.GetMaxLoopID(); //ControllerModel controller = ProjectManager.GetInstance.GetPrimaryController(); int[] loopsCode = GetAllLoopCode(_controller, null); int currentMaxLoopCode = loopsCode.Max(); IControllerConfig config = ControllerConfigManager.GetConfigObject(_controller.Type); short allowMaxLoopValue = config.GetMaxLoopAmountValue(); if (loopsAmount > allowMaxLoopValue) { //超出最大数回数 return(false); } if ((allowMaxLoopValue - currentMaxLoopCode) < loopsAmount) { //剩余回路空间无法创建指定回路数量的回路 return(false); } string strLoopLengthFormat = "#"; for (int i = 0; i < _controller.LoopAddressLength; i++) { strLoopLengthFormat += "0"; } for (int i = 1; i <= loopsAmount; i++) { LoopModel l = new LoopModel(); l.ID = ++loopID; l.Code = _controller.MachineNumber + (currentMaxLoopCode + i).ToString().PadLeft(_controller.LoopAddressLength, '0'); l.Name = _controller.MachineNumber + (currentMaxLoopCode + i).ToString().PadLeft(_controller.LoopAddressLength, '0'); //l.Code = (currentMaxLoopCode + i).ToString().PadLeft(_controller.LoopAddressLength, '0'); //l.Name = loop.Name+i.ToString(); l.DeviceAmount = loop.DeviceAmount; l.Controller = _controller; _controller.Loops.Add(l); // SetDataDirty(); } } catch { return(false); } return(true); }
public bool AddDevice(LoopModel loop) { try { List <DeviceInfo8007> lstDevices = loop.GetDevices <DeviceInfo8007>(); foreach (var device in lstDevices) { device.Loop.ID = loop.ID; device.LoopID = loop.ID; StringBuilder sbDeviceInfoSQL = new StringBuilder("REPLACE INTO DeviceInfo8007("); sbDeviceInfoSQL.Append("ID,"); sbDeviceInfoSQL.Append("Code,"); sbDeviceInfoSQL.Append("Disable,"); sbDeviceInfoSQL.Append("Feature,"); sbDeviceInfoSQL.Append("SensitiveLevel,"); sbDeviceInfoSQL.Append("LinkageGroup1,"); sbDeviceInfoSQL.Append("LinkageGroup2,"); sbDeviceInfoSQL.Append("BuildingNo,"); sbDeviceInfoSQL.Append("ZoneNo,"); sbDeviceInfoSQL.Append("FloorNo,"); sbDeviceInfoSQL.Append("RoomNo,"); sbDeviceInfoSQL.Append("Location,"); sbDeviceInfoSQL.Append("LoopID,"); sbDeviceInfoSQL.Append("TypeCode)"); sbDeviceInfoSQL.Append(" VALUES("); sbDeviceInfoSQL.Append(device.ID + ",'"); sbDeviceInfoSQL.Append(device.Code + "','"); sbDeviceInfoSQL.Append(device.Disable + "','"); sbDeviceInfoSQL.Append(device.Feature + "','"); sbDeviceInfoSQL.Append(device.SensitiveLevel + "','"); sbDeviceInfoSQL.Append(device.LinkageGroup1 + "','"); sbDeviceInfoSQL.Append(device.LinkageGroup2 + "','"); sbDeviceInfoSQL.Append(device.BuildingNo + "','"); sbDeviceInfoSQL.Append(device.ZoneNo + "','"); sbDeviceInfoSQL.Append(device.FloorNo + "','"); sbDeviceInfoSQL.Append(device.RoomNo + "','"); sbDeviceInfoSQL.Append(device.Location + "','"); sbDeviceInfoSQL.Append(device.LoopID + "','"); sbDeviceInfoSQL.Append(device.TypeCode + "');"); _databaseService.ExecuteBySql(sbDeviceInfoSQL); } } catch (Exception ex) { return(false); } return(true); }
//public abstract void SendMixedLinkageConfigInfo(); //public abstract void SendGeneralLinkageConfigInfo(); //public abstract void SendManualControlBoardInfo(); #endregion /// <summary> /// 删除已经下传的回路 /// 用于全部下载 /// </summary> private void RemoveDownloadedLoop() { if (CurrentLoopForDownloadedDeviceInfo != null) { var result = from l in Loops where l.Code == CurrentLoopForDownloadedDeviceInfo.Code select l; LoopModel loop = result.FirstOrDefault(); if (loop != null) { Loops.Remove(loop); CurrentLoopForDownloadedDeviceInfo = null; //当前回路已删除,清空设置 } } if (Loops.Count > 0) //设置当前回路中的器件总数 { SetDownloadedDeviceInfoTotalAmountInCurrentLoop(_loops[0]); } }
public ControllerModel OrganizeControllerInfoFromSpecifiedDBFileVersion(IDBFileVersionService dbFileVersionService, ControllerModel controller) { ControllerModel controllerInfo = controller; List <LoopModel> lstLoopInfo = dbFileVersionService.GetLoopsByController(controller); StringBuilder sbQuerySQL = new StringBuilder(); //(1)回路及器件 foreach (var l in lstLoopInfo)//回路信息 { LoopModel loop = l; dbFileVersionService.GetDevicesByLoopForControllerType8021(ref loop);//为loop赋予“器件信息” loop.Controller = controllerInfo; controllerInfo.Loops.Add(loop); } return(controllerInfo); }
public bool AddDevice(LoopModel loop) { try { List <DeviceInfo8021> lstDevices = loop.GetDevices <DeviceInfo8021>(); foreach (var device in lstDevices) { device.Loop.ID = loop.ID; device.LoopID = loop.ID; //StringBuilder sbDeviceInfoSQL = new StringBuilder("REPLACE INTO DeviceInfo8021("); //sbDeviceInfoSQL.Append("ID,"); //sbDeviceInfoSQL.Append("Code,"); //sbDeviceInfoSQL.Append("Disable,"); //sbDeviceInfoSQL.Append("CurrentThreshold,"); //sbDeviceInfoSQL.Append("TemperatureThreshold,"); //sbDeviceInfoSQL.Append("BuildingNo,"); //sbDeviceInfoSQL.Append("ZoneNo,"); //sbDeviceInfoSQL.Append("FloorNo,"); //sbDeviceInfoSQL.Append("RoomNo,"); //sbDeviceInfoSQL.Append("Location,"); //sbDeviceInfoSQL.Append("LoopID,"); //sbDeviceInfoSQL.Append("TypeCode)"); //sbDeviceInfoSQL.Append(" VALUES("); //sbDeviceInfoSQL.Append(device.ID + ",'"); //sbDeviceInfoSQL.Append(device.Code + "','"); //sbDeviceInfoSQL.Append(device.Disable + "','"); //sbDeviceInfoSQL.Append(device.CurrentThreshold + "','"); //sbDeviceInfoSQL.Append(device.TemperatureThreshold + "','"); //sbDeviceInfoSQL.Append(device.BuildingNo + "','"); //sbDeviceInfoSQL.Append(device.ZoneNo + "','"); //sbDeviceInfoSQL.Append(device.FloorNo + "','"); //sbDeviceInfoSQL.Append(device.RoomNo + "','"); //sbDeviceInfoSQL.Append(device.Location + "','"); //sbDeviceInfoSQL.Append(device.LoopID + "','"); //sbDeviceInfoSQL.Append(device.TypeCode + "');"); //_databaseService.ExecuteBySql(sbDeviceInfoSQL); _dbFileVersionService.AddDeviceForControllerType8021(device); } } catch (Exception ex) { return(false); } return(true); }