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 List <LinkageConfigStandard> GetStandardLinkageConfig() { List <LinkageConfigStandard> lstStandard = new List <LinkageConfigStandard>(); try { StringBuilder sbQuerySQL = new StringBuilder("select 输出组号,编号1,编号2,编号3,编号4,编号5,编号6,编号7,编号8,动作常数,联动组1,联动组2,联动组3 from 器件组态;"); DataTable dt = _databaseService.GetDataTableBySQL(sbQuerySQL); int dtRowsCount = dt.Rows.Count; for (int i = 0; i < dtRowsCount; i++) { LinkageConfigStandard linkageConfigStandard = new LinkageConfigStandard(); linkageConfigStandard.Code = dt.Rows[i]["输出组号"].ToString(); linkageConfigStandard.DeviceNo1 = dt.Rows[i]["编号1"].ToString(); linkageConfigStandard.DeviceNo2 = dt.Rows[i]["编号2"].ToString(); linkageConfigStandard.DeviceNo3 = dt.Rows[i]["编号3"].ToString(); linkageConfigStandard.DeviceNo4 = dt.Rows[i]["编号4"].ToString(); linkageConfigStandard.DeviceNo5 = dt.Rows[i]["编号5"].ToString(); linkageConfigStandard.DeviceNo6 = dt.Rows[i]["编号6"].ToString(); linkageConfigStandard.DeviceNo7 = dt.Rows[i]["编号7"].ToString(); linkageConfigStandard.DeviceNo8 = dt.Rows[i]["编号8"].ToString(); linkageConfigStandard.ActionCoefficient = Convert.ToInt32(dt.Rows[i]["动作常数"].ToString()); linkageConfigStandard.LinkageNo1 = dt.Rows[i]["联动组1"].ToString(); linkageConfigStandard.LinkageNo2 = dt.Rows[i]["联动组2"].ToString(); linkageConfigStandard.LinkageNo3 = dt.Rows[i]["联动组3"].ToString(); lstStandard.Add(linkageConfigStandard); } } catch { } return(lstStandard); }
public List <Model.LinkageConfigStandard> GetStandardLinkageConfigInfoByController(Model.ControllerModel controller) { List <LinkageConfigStandard> lstData = new List <LinkageConfigStandard>(); StringBuilder sbQuerySQL = new StringBuilder("select ID,Code,DeviceNo1,DeviceNo2 , DeviceNo3 , DeviceNo4, DeviceNo5,DeviceNo6,DeviceNo7,DeviceNo8,DeviceNo9,DeviceNo10, ActionCoefficient , LinkageNo1 ,LinkageNo2 ,LinkageNo3,controllerID from LinkageConfigStandard where controllerID=" + controller.ID); System.Data.DataTable dt = _databaseService.GetDataTableBySQL(sbQuerySQL); for (int i = 0; i < dt.Rows.Count; i++) { LinkageConfigStandard model = new LinkageConfigStandard(); model.ID = Convert.ToInt32(dt.Rows[i]["id"]); model.Code = dt.Rows[i]["Code"].ToString(); model.DeviceNo1 = dt.Rows[i]["DeviceNo1"].ToString(); model.DeviceNo2 = dt.Rows[i]["DeviceNo2"].ToString(); model.DeviceNo3 = dt.Rows[i]["DeviceNo3"].ToString(); model.DeviceNo4 = dt.Rows[i]["DeviceNo4"].ToString(); model.DeviceNo5 = dt.Rows[i]["DeviceNo5"].ToString(); model.DeviceNo6 = dt.Rows[i]["DeviceNo6"].ToString(); model.DeviceNo7 = dt.Rows[i]["DeviceNo7"].ToString(); model.DeviceNo8 = dt.Rows[i]["DeviceNo8"].ToString(); model.DeviceNo9 = dt.Rows[i]["DeviceNo9"].ToString(); model.DeviceNo10 = dt.Rows[i]["DeviceNo10"].ToString(); model.ActionCoefficient = Convert.ToInt32(dt.Rows[i]["ActionCoefficient"]); model.LinkageNo1 = dt.Rows[i]["LinkageNo1"].ToString(); model.LinkageNo2 = dt.Rows[i]["LinkageNo2"].ToString(); model.LinkageNo3 = dt.Rows[i]["LinkageNo3"].ToString(); model.Controller = controller; model.ControllerID = controller.ID; lstData.Add(model); } return(lstData); }
protected override List <LinkageConfigStandard> ConvertToStandardLinkageModelFromDataTable(System.Data.DataTable dtStandard) { List <LinkageConfigStandard> lstStandardLinkage = new List <LinkageConfigStandard>(); int maxID = ProjectManager.GetInstance.MaxIDForStandardLinkageConfig; for (int i = 0; i < dtStandard.Rows.Count; i++) { if (dtStandard.Rows[i]["输出组号"].ToString() == "")//无输出组号值,认为此工作表已不存在有效数据 { break; } maxID++; LinkageConfigStandard lcs = new LinkageConfigStandard(); lcs.ID = maxID; lcs.Code = dtStandard.Rows[i]["输出组号"].ToString(); lcs.DeviceNo1 = dtStandard.Rows[i]["联动模块1"].ToString(); lcs.DeviceNo2 = dtStandard.Rows[i]["联动模块2"].ToString(); lcs.DeviceNo3 = dtStandard.Rows[i]["联动模块3"].ToString(); lcs.DeviceNo4 = dtStandard.Rows[i]["联动模块4"].ToString(); lcs.ActionCoefficient = Convert.ToInt32(dtStandard.Rows[i]["动作常数"].ToString().NullToZero()); lcs.LinkageNo1 = dtStandard.Rows[i]["联动组1"].ToString(); lcs.LinkageNo2 = dtStandard.Rows[i]["联动组2"].ToString(); lcs.LinkageNo3 = dtStandard.Rows[i]["联动组3"].ToString(); lcs.Memo = dtStandard.Rows[i]["备注"].ToString(); lstStandardLinkage.Add(lcs); } ProjectManager.GetInstance.MaxIDForStandardLinkageConfig = maxID; return(lstStandardLinkage); }
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 LinkageConfigStandard ToLinkageConfigStandard() { LinkageConfigStandard linkageConfigStandard = new LinkageConfigStandard(); linkageConfigStandard.ID = this.ID; linkageConfigStandard.Controller = this.Controller; linkageConfigStandard.ControllerID = this.ControllerID; linkageConfigStandard.Code = this.Code; linkageConfigStandard.ActionCoefficient = this.ActionCoefficient; linkageConfigStandard.DeviceNo1 = this.DeviceNo1; linkageConfigStandard.DeviceNo2 = this.DeviceNo2; linkageConfigStandard.DeviceNo3 = this.DeviceNo3; linkageConfigStandard.DeviceNo4 = this.DeviceNo4; linkageConfigStandard.DeviceNo5 = this.DeviceNo5; linkageConfigStandard.DeviceNo6 = this.DeviceNo6; linkageConfigStandard.DeviceNo7 = this.DeviceNo7; linkageConfigStandard.DeviceNo8 = this.DeviceNo8; linkageConfigStandard.DeviceNo9 = this.DeviceNo9; linkageConfigStandard.DeviceNo10 = this.DeviceNo10; linkageConfigStandard.DeviceNo11 = this.DeviceNo11; linkageConfigStandard.DeviceNo12 = this.DeviceNo12; linkageConfigStandard.OutputDevice1 = this.OutputDevice1; linkageConfigStandard.OutputDevice2 = this.OutputDevice2; linkageConfigStandard.LinkageNo1 = this.LinkageNo1; linkageConfigStandard.LinkageNo2 = this.LinkageNo2; linkageConfigStandard.LinkageNo3 = this.LinkageNo3; linkageConfigStandard.Memo = this.Memo; return(linkageConfigStandard); }
public EditableLinkageConfigStandard(LinkageConfigStandard linkageConfigStandard) { this.ID = linkageConfigStandard.ID; this.Controller = linkageConfigStandard.Controller; this.ControllerID = linkageConfigStandard.ControllerID; this.Code = linkageConfigStandard.Code; this.ActionCoefficient = linkageConfigStandard.ActionCoefficient; this.DeviceNo1 = linkageConfigStandard.DeviceNo1; this.DeviceNo2 = linkageConfigStandard.DeviceNo2; this.DeviceNo3 = linkageConfigStandard.DeviceNo3; this.DeviceNo4 = linkageConfigStandard.DeviceNo4; this.DeviceNo5 = linkageConfigStandard.DeviceNo5; this.DeviceNo6 = linkageConfigStandard.DeviceNo6; this.DeviceNo7 = linkageConfigStandard.DeviceNo7; this.DeviceNo8 = linkageConfigStandard.DeviceNo8; this.DeviceNo9 = linkageConfigStandard.DeviceNo9; this.DeviceNo10 = linkageConfigStandard.DeviceNo10; this.DeviceNo11 = linkageConfigStandard.DeviceNo11; this.DeviceNo12 = linkageConfigStandard.DeviceNo12; this.OutputDevice1 = linkageConfigStandard.OutputDevice1; this.OutputDevice2 = linkageConfigStandard.OutputDevice2; this.LinkageNo1 = linkageConfigStandard.LinkageNo1; this.LinkageNo2 = linkageConfigStandard.LinkageNo2; this.LinkageNo3 = linkageConfigStandard.LinkageNo3; this.Memo = linkageConfigStandard.Memo; }
public bool Update(Model.LinkageConfigStandard linkageConfigStandard) { try { LinkageConfigStandard result = _controller.StandardConfig.Find( delegate(LinkageConfigStandard x) { return(x.ID == linkageConfigStandard.ID); } ); if (result != null) { result.Code = linkageConfigStandard.Code; //result.ID = linkageConfigStandard.ID; result.Controller = linkageConfigStandard.Controller; result.ControllerID = linkageConfigStandard.ControllerID; result.ActionCoefficient = linkageConfigStandard.ActionCoefficient; result.DeviceNo1 = linkageConfigStandard.DeviceNo1; result.DeviceNo2 = linkageConfigStandard.DeviceNo2; result.DeviceNo3 = linkageConfigStandard.DeviceNo3; result.DeviceNo4 = linkageConfigStandard.DeviceNo4; result.DeviceNo5 = linkageConfigStandard.DeviceNo5; result.DeviceNo6 = linkageConfigStandard.DeviceNo6; result.DeviceNo7 = linkageConfigStandard.DeviceNo7; result.DeviceNo8 = linkageConfigStandard.DeviceNo8; result.DeviceNo9 = linkageConfigStandard.DeviceNo9; result.DeviceNo10 = linkageConfigStandard.DeviceNo10; result.DeviceNo11 = linkageConfigStandard.DeviceNo11; result.DeviceNo12 = linkageConfigStandard.DeviceNo12; result.OutputDevice1 = linkageConfigStandard.OutputDevice1; result.OutputDevice2 = linkageConfigStandard.OutputDevice2; result.LinkageNo1 = linkageConfigStandard.LinkageNo1; result.LinkageNo2 = linkageConfigStandard.LinkageNo2; result.LinkageNo3 = linkageConfigStandard.LinkageNo3; result.Memo = linkageConfigStandard.Memo; } else { _controller.StandardConfig.Add(linkageConfigStandard); DataRecordAlreadySet = true; if (linkageConfigStandard.ID > ProjectManager.GetInstance.MaxIDForStandardLinkageConfig) { ProjectManager.GetInstance.MaxIDForStandardLinkageConfig = linkageConfigStandard.ID; } else { ProjectManager.GetInstance.MaxIDForStandardLinkageConfig++; } } } catch { return(false); } return(true); }
public List <Model.LinkageConfigStandard> Create(int amount) { List <LinkageConfigStandard> lstLinkageConfigStandard = new List <LinkageConfigStandard>(); //int currentMaxCode = GetMaxCode(); //for (int i = 0; i < amount; i++) //{ // currentMaxCode++; // LinkageConfigStandard lcs = new LinkageConfigStandard(); // lcs.Controller = _controller; // lcs.Code = currentMaxCode.ToString().PadLeft(4, '0'); // lstLinkageConfigStandard.Add(lcs); //} //return lstLinkageConfigStandard; if (DataRecordAlreadySet) //如果数据已经填写完成,则可获取最大编号 { _maxCode = GetMaxCode(); _maxID = GetMaxID(); } int tempCode = _maxCode; if (tempCode >= MaxStandardLinkageConfigAmount) //如果已经达到上限,则不添加任何行 { amount = 0; } else { if ((tempCode + amount) > MaxStandardLinkageConfigAmount) //如果需要添加的行数将达上限,则增加剩余的行数 { amount = MaxStandardLinkageConfigAmount - tempCode; } for (int i = 0; i < amount; i++) { tempCode++; _maxID++; LinkageConfigStandard lcs = new LinkageConfigStandard(); lcs.Controller = _controller; lcs.ControllerID = _controller.ID; lcs.ID = _maxID; lcs.Code = tempCode.ToString().PadLeft(MaxStandardLinkageConfigAmount.ToString().Length, '0'); lcs.IsDirty = true; lstLinkageConfigStandard.Add(lcs); } _maxCode = tempCode; DataRecordAlreadySet = false; foreach (var singleItem in lstLinkageConfigStandard) { Update(singleItem); } } return(lstLinkageConfigStandard); }
public bool DeleteBySpecifiedID(int id) { try { var result = from lcs in _controller.StandardConfig where lcs.ID == id select lcs; LinkageConfigStandard o = result.FirstOrDefault(); if (o != null) { _controller.StandardConfig.Remove(o); } } catch { return(false); } return(true); }
public LinkageConfigStandard Build() { LinkageConfigStandard standardConfig = new LinkageConfigStandard { Code = _code, ActionCoefficient = _actionCoefficient, DeviceNo1 = _deviceNo1, DeviceNo2 = _deviceNo2, DeviceNo3 = _deviceNo3, DeviceNo4 = _deviceNo4, DeviceNo5 = _deviceNo5, DeviceNo6 = _deviceNo6, DeviceNo7 = _deviceNo7, DeviceNo8 = _deviceNo8, LinkageNo1 = _linkageNo1, LinkageNo2 = _linkageNo2, LinkageNo3 = _linkageNo3 }; return(standardConfig); }
private void OrganizeStandardLinkageConfigModel(DataTable dt, ref ControllerModel controller) { int intControllerID = controller.ID; var rows = from row in dt.AsEnumerable() where Convert.ToInt16(row["controllerId"]) == intControllerID group row["standardID"] by new { id = row["standardID"], code = row["standardCode"] } into g select new { linkageId = g.Key.id, linkageCode = g.Key.code }; foreach (var row in rows) { if (!(row.linkageId is System.DBNull)) { LinkageConfigStandard loop = new LinkageConfigStandard { ID = Convert.ToInt16(row.linkageId), Code = row.linkageCode.ToString(), ControllerID = controller.ID }; controller.StandardConfig.Add(loop); } } }
public void ImportExecute() { //得到需要导入的控制器的信息 ControllerModel controller = ProjectManager.GetInstance.TheControllerViaImporting; ControllerOperationCommon controllerBase = new ControllerOperationCommon(); LinkageConfigStandardService standardLinkageService = new LinkageConfigStandardService(TheController); LinkageConfigMixedService mixedLinkageService = new LinkageConfigMixedService(TheController); LinkageConfigGeneralService gerneralLinkageService = new LinkageConfigGeneralService(TheController); int maxLoopID = controllerBase.GetMaxLoopID(); List <CheckItem> selectedLoops = LoopNameCollection.Where((d) => d.IsChecked == true).ToList <CheckItem>(); //比对回路信息是否已经存在:提示,是否覆盖 foreach (var loop in controller.Loops) { int selectedLoopCount = selectedLoops.Count((d) => d.Value == loop.Code); if (selectedLoopCount <= 0) //未勾选的回路,放弃导入 { continue; } LoopModel existLoop = TheController.Loops.Where((d) => d.Code == loop.Code).FirstOrDefault(); int amount = TheController.Loops.Count((d) => d.Code == loop.Code); if (amount > 0) { string strPromptInfo = "控制器" + TheController.Name + ":已经存在" + loop.Code + ",覆盖吗?"; if (MessageBox.Show(strPromptInfo, "提示", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { TheController.Loops.RemoveAll((d) => d.Code == loop.Code); loop.Controller = TheController; loop.ControllerID = TheController.ID; loop.ID = existLoop.ID; TheController.Loops.Add(loop); } } else { maxLoopID++; loop.Controller = TheController; loop.ControllerID = TheController.ID; loop.ID = maxLoopID; TheController.Loops.Add(loop); } } List <CheckItem> lstOtherSetting = OtherSettingsCollection.Where((d) => d.IsChecked == true).ToList <CheckItem>(); int selectedStandardCount = lstOtherSetting.Count((d) => d.Value == "标准组态"); int maxStandardLinkageConfigID = standardLinkageService.GetMaxID(); if (selectedStandardCount > 0) //未勾选,放弃导入 { //比对组态信息,按编号比对 foreach (var importConfig in controller.StandardConfig) { LinkageConfigStandard existConfig = TheController.StandardConfig.Where((d) => d.Code == importConfig.Code).FirstOrDefault(); int amount = TheController.StandardConfig.Count((d) => d.Code == importConfig.Code); if (amount > 0) { string strPromptInfo = "控制器" + TheController.Name + ":已经存在标准组态" + importConfig.Code + ",覆盖吗?"; if (MessageBox.Show(strPromptInfo, "提示", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { TheController.StandardConfig.RemoveAll((d) => d.Code == importConfig.Code); importConfig.Controller = TheController; importConfig.ControllerID = TheController.ID; importConfig.ID = existConfig.ID; TheController.StandardConfig.Add(importConfig); } } else { maxStandardLinkageConfigID++; importConfig.Controller = TheController; importConfig.ControllerID = TheController.ID; importConfig.ID = maxStandardLinkageConfigID; TheController.StandardConfig.Add(importConfig); } } } int selectedMixedCount = lstOtherSetting.Count((d) => d.Value == "混合组态"); if (selectedMixedCount > 0) //未勾选,放弃导入 { //比对组态信息,按编号比对 foreach (var importConfig in controller.MixedConfig) { int amount = TheController.MixedConfig.Count((d) => d.Code == importConfig.Code); if (amount > 0) { string strPromptInfo = "控制器" + TheController.Name + ":已经存在混合组态" + importConfig.Code + ",覆盖吗?"; if (MessageBox.Show(strPromptInfo, "提示", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { TheController.MixedConfig.RemoveAll((d) => d.Code == importConfig.Code); TheController.MixedConfig.Add(importConfig); } } else { TheController.MixedConfig.Add(importConfig); } } } int selectedGeneralCount = lstOtherSetting.Count((d) => d.Value == "通用组态"); if (selectedGeneralCount > 0) //未勾选,放弃导入 { //比对组态信息,按编号比对 foreach (var importConfig in controller.GeneralConfig) { int amount = TheController.GeneralConfig.Count((d) => d.Code == importConfig.Code); if (amount > 0) { string strPromptInfo = "控制器" + TheController.Name + ":已经存在通用组态" + importConfig.Code + ",覆盖吗?"; if (MessageBox.Show(strPromptInfo, "提示", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { TheController.GeneralConfig.RemoveAll((d) => d.Code == importConfig.Code); TheController.GeneralConfig.Add(importConfig); } } else { TheController.GeneralConfig.Add(importConfig); } } } int selectedMCBCount = lstOtherSetting.Count((d) => d.Value == "网络手动盘"); if (selectedMCBCount > 0) //未勾选,放弃导入 { { foreach (var importConfig in controller.ControlBoard) { int amount = TheController.ControlBoard.Count((d) => d.Code == importConfig.Code); if (amount > 0) { string strPromptInfo = "控制器" + TheController.Name + ":已经存在网络手动盘" + importConfig.Code + ",覆盖吗?"; if (MessageBox.Show(strPromptInfo, "提示", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { TheController.ControlBoard.RemoveAll((d) => d.Code == importConfig.Code); TheController.ControlBoard.Add(importConfig); } } else { TheController.ControlBoard.Add(importConfig); } } } CloseExecute(); ProjectManager.GetInstance.TheControllerViaImporting = null; //导入完成,导入信息清除 EventMediator.NotifyColleagues("RefreshNavigator", TheController); }
/// <summary> /// 更新指定标准组态ID的数据 /// </summary> /// <param name="id">待更新数据的ID</param> /// <param name="columnNames">列名</param> /// <param name="data">新数据</param> /// <returns></returns> public bool UpdateViaSpecifiedColumnName(int id, string[] columnNames, string[] data) { try { LinkageConfigStandard result = _controller.StandardConfig.Find( delegate(LinkageConfigStandard x) { return(x.ID == id); } ); for (int i = 0; i < columnNames.Length; i++) { switch (columnNames[i]) { //case "输出组号": // result.Code = data[i]; // break; case "联动模块1": result.DeviceNo1 = data[i]; break; case "联动模块2": result.DeviceNo2 = data[i]; break; case "联动模块3": result.DeviceNo3 = data[i]; break; case "联动模块4": result.DeviceNo4 = data[i]; break; case "联动模块5": result.DeviceNo5 = data[i]; break; case "联动模块6": result.DeviceNo6 = data[i]; break; case "联动模块7": result.DeviceNo7 = data[i]; break; case "联动模块8": result.DeviceNo8 = data[i]; break; case "联动模块9": result.DeviceNo9 = data[i]; break; case "联动模块10": result.DeviceNo10 = data[i]; break; case "输入模块1": result.DeviceNo1 = data[i]; break; case "输入模块2": result.DeviceNo2 = data[i]; break; case "输入模块3": result.DeviceNo3 = data[i]; break; case "输入模块4": result.DeviceNo4 = data[i]; break; case "输入模块5": result.DeviceNo5 = data[i]; break; case "输入模块6": result.DeviceNo6 = data[i]; break; case "输入模块7": result.DeviceNo7 = data[i]; break; case "输入模块8": result.DeviceNo8 = data[i]; break; case "输入模块9": result.DeviceNo9 = data[i]; break; case "输入模块10": result.DeviceNo10 = data[i]; break; case "输入模块11": result.DeviceNo11 = data[i]; break; case "输入模块12": result.DeviceNo12 = data[i]; break; case "输出模块1": result.OutputDevice1 = data[i]; break; case "输出模块2": result.OutputDevice2 = data[i]; break; case "动作常数": result.ActionCoefficient = Convert.ToInt32(data[i]); break; case "联动组1": result.LinkageNo1 = data[i]; break; case "联动组2": result.LinkageNo1 = data[i]; break; case "联动组3": result.LinkageNo1 = data[i]; break; case "备注": result.Memo = data[i]; break; } } } catch (Exception ex) { return(false); } return(true); }
/// <summary> /// 解析收到的标准组态数据包 /// </summary> /// <param name="standardLinkagePackage"></param> /// <returns></returns> public override Model.LinkageConfigStandard ParsePackageCD(byte[] standardLinkagePackage) { //第7字节作为基址 //采用GB18030编码 System.Text.Encoding ascii = System.Text.Encoding.GetEncoding(54936); //机号 string tempMachineNo = Convert.ToInt16(standardLinkagePackage[8]).ToString(); switch (base.ControllerModel.DeviceAddressLength) { case 7: tempMachineNo = tempMachineNo.PadLeft(2, '0'); break; case 8: tempMachineNo = tempMachineNo.PadLeft(3, '0'); break; default: //默认7位,但此分支不应该走,此时应该知道编码位数 tempMachineNo = tempMachineNo.PadLeft(2, '0'); break; } LinkageConfigStandard standardLinkageInfo = new LinkageConfigStandard(); this.ControllerModel.Type = ControllerType.NT8036; standardLinkageInfo.Controller = this.ControllerModel; //组号 standardLinkageInfo.Code = (standardLinkagePackage[7]).ToString().PadLeft(4, '0'); //器件编码 string strMachineNo, strLoopNo, strDeviceNo; //存储机号,路号,器件编码 List <string> lstDeviceInfo = new List <string>(); for (int i = 0; i < 4; i++) { if (base.ControllerModel.DeviceAddressLength == 8) { strMachineNo = standardLinkagePackage[8 + i * 3].ToString().PadLeft(3, '0'); } else { strMachineNo = standardLinkagePackage[8 + i * 3].ToString().PadLeft(2, '0'); } strLoopNo = standardLinkagePackage[9 + i * 3].ToString().PadLeft(2, '0'); strDeviceNo = standardLinkagePackage[10 + i * 3].ToString().PadLeft(3, '0'); if ((strMachineNo + strLoopNo + strDeviceNo) != "0000000" && (strMachineNo + strLoopNo + strDeviceNo) != "00000000" && (strMachineNo + strLoopNo + strDeviceNo).Length == base.ControllerModel.DeviceAddressLength) { lstDeviceInfo.Add(strMachineNo + strLoopNo + strDeviceNo); } else { lstDeviceInfo.Add(""); } } standardLinkageInfo.SetDeviceNoList = lstDeviceInfo; //动作常数 standardLinkageInfo.ActionCoefficient = Convert.ToInt32(standardLinkagePackage[20].ToString().NullToImpossibleValue()); //输出组1~3 string strLinkageGroupCode; //输出组号 strLinkageGroupCode = (standardLinkagePackage[21]).ToString().PadLeft(4, '0'); standardLinkageInfo.LinkageNo1 = strLinkageGroupCode == "0000" ? "" : strLinkageGroupCode; strLinkageGroupCode = (standardLinkagePackage[22]).ToString().PadLeft(4, '0'); standardLinkageInfo.LinkageNo2 = strLinkageGroupCode == "0000" ? "" : strLinkageGroupCode; strLinkageGroupCode = (standardLinkagePackage[23]).ToString().PadLeft(4, '0'); standardLinkageInfo.LinkageNo3 = strLinkageGroupCode == "0000" ? "" : strLinkageGroupCode; return(standardLinkageInfo); }
protected override byte[] AssemblePackageBC(LinkageConfigStandard standardConfig) { throw new NotImplementedException(); }
public int AddStandardLinkageConfigInfo(LinkageConfigStandard linkageConfigStandard) { throw new NotImplementedException(); }