public void SetMPsOn(string str1, string str2, List <DTPlcInfoSimple> pLst) { DTPlcInfoSimple p = getPsFromPslLst(str1, str2, pLst); if (p != null) { YbtdDevice.SetMValueON(p); } else { MessageBox.Show(Constant.SetDataFail); } }
public bool SaveDeviceToSql() { //获取数据库表格数据 //获取是否有数据操作 //将现有数据更新到表格 string sql = " SELECT * FROM " + YbdtWorkInfo.DeviceId; DataTable tempDataTable = SqlHelper.ExecuteDataTable(sql); foreach (DataRow dr in tempDataTable.Rows) { int opInt = 0; int valueInt = 0; string binStr = dr[Constant.Bin].ToString(); if (int.TryParse(dr[Constant.strParam3].ToString(), out opInt) && (int.TryParse(dr[Constant.strParam4].ToString(), out valueInt))) { if (opInt == Constant.sqlWrite) { DTPlcInfoSimple p = getPsFromPslLst(binStr, Constant.Read, PsLstAuto); if (p.Area.Equals(Constant.strDMArea[0]) || p.Area.Equals(Constant.strDMArea[1])) { YbtdDevice.SetDValue(p, valueInt); } else { if (p.Area.Equals(Constant.strDMArea[3]) || p.Area.Equals(Constant.strDMArea[4]) || p.Area.Equals(Constant.strDMArea[5]) || p.Area.Equals(Constant.strDMArea[6]) ) { if (valueInt == Constant.M_ON) { YbtdDevice.SetMValueON(p); } if (valueInt == Constant.M_OFF) { YbtdDevice.SetMValueOFF(p); } } } } } } UpdatePlcStatus(YbtdDevice.DataFormLst[0]); return(true); }