public bool SetDValue(PlcInfoSimple p, int value0) { if (p == null || p.BelongToDataform == null || p.Area == null || p.Mode == null) { return(false); } if (p != null && p.BelongToDataform != null) { WriteSingleDData(p.Addr, value0, p.Area, p.Mode); } ConstantMethod.DelayWriteCmdOk(Constant.XJConnectTimeOut, ref value0, ref p); if (p.Ration > 0) { if (value0 == p.ShowValue * p.Ration) { return(true); } else { return(false); } } else if (value0 == p.ShowValue * Constant.dataMultiple) { return(true); } else { return(false); } }
private void FindPlcInfo(PlcInfoSimple p, List <XJPlcInfo> dplc, List <List <XJPlcInfo> > mplc) { if ((p.Area != null) && ((dplc != null) && (mplc != null))) { foreach (XJPlcInfo info in dplc) { if ((info.RelAddr == p.Addr) && info.StrArea.Equals(p.Area.Trim())) { p.SetPlcInfo(info); return; } } for (int i = 0; i < mplc.Count; i++) { for (int j = 0; j < mplc[i].Count; j++) { if ((mplc[i][j].RelAddr == p.Addr) && mplc[i][j].StrArea.Equals(p.Area.Trim())) { p.SetPlcInfo(mplc[i][j]); break; } } } } }
public bool opposite(PlcInfoSimple p) { if (p.ShowValue > 0) { return(SetMValueOFF(p)); } else { return(SetMValueON(p)); } }
public bool SetMultiPleDValue(PlcInfoSimple stPlcInfoSimple, int[] value0) { if (stPlcInfoSimple != null && stPlcInfoSimple.BelongToDataform != null && value0.Count() > 0) { bool writeok = WriteMultiPleDMData( stPlcInfoSimple.Addr, value0, stPlcInfoSimple.Area, stPlcInfoSimple.Mode); //取消查看 在多次发送的时候会比较卡 // LogManager.WriteProgramLog("数据下发地址:"+ stPlcInfoSimple.Addr+"写入值:"+ value0[0].ToString()); ConstantMethod.DelayWriteCmdOk(300, ref value0[0], ref stPlcInfoSimple); //可能时间太久 要等下 //LogManager.WriteProgramLog("数据下发地址:" + stPlcInfoSimple.Addr + "返回值:" + stPlcInfoSimple.ShowValue); if (stPlcInfoSimple.Ration > 0) { int margin = Math.Abs(value0[0]) - Math.Abs((int)(stPlcInfoSimple.ShowValue * stPlcInfoSimple.Ration)); if (Math.Abs(margin) < 1 * stPlcInfoSimple.Ration) { return(true); } } if (value0[0] == stPlcInfoSimple.ShowValue) { return(true); } return(false); } if (stPlcInfoSimple == null) { LogManager.WriteProgramLog(stPlcInfoSimple.Name + "数据下发地址:附属类为空!"); } if (stPlcInfoSimple != null && stPlcInfoSimple.BelongToDataform == null) { LogManager.WriteProgramLog(stPlcInfoSimple.Name + "附属类所属表格为空!"); } if (value0.Count() == 0 && stPlcInfoSimple != null) { LogManager.WriteProgramLog("数据下发地址:" + stPlcInfoSimple.Name + stPlcInfoSimple.Addr + "写入数据数量错误:" + value0.Count().ToString()); } return(false); }
public bool SetMValueOFF(PlcInfoSimple p) { int value0 = 0; if (p != null && p.BelongToDataform != null) { WriteSingleMData(p.Addr, value0, p.Area, p.Mode); } ConstantMethod.DelayWriteCmdOk(Constant.XJConnectTimeOut, ref value0, ref p); if (value0 == p.ShowValue) { return(true); } else { return(false); } }
public void SetPage(int id) { if ((evokDevice.DataFormLst.Count > 1) && (evokDevice.DataFormLst[id].Rows.Count > 0)) { AllPlcSimpleLst[id].Clear(); foreach (DataRow row in evokDevice.DataFormLst[id].Rows) { if (row != null) { string str = row["bin"].ToString(); if (!string.IsNullOrWhiteSpace(str)) { PlcInfoSimple item = new PlcInfoSimple(str); try { item.Mode = row["mode"].ToString(); item.RowIndex = evokDevice.DataFormLst[id].Rows.IndexOf(row); item.BelongToDataform = evokDevice.DataFormLst[id]; int addr = 0; string area = "D"; string userdata = row["addr"].ToString(); string str4 = row["param3"].ToString(); string str5 = row["param4"].ToString(); if (!string.IsNullOrWhiteSpace(str4)) { item.ShowStr.Add(str4); } if (!string.IsNullOrWhiteSpace(str5)) { item.ShowStr.Add(str5); } ConstantMethod.SplitAreaAndAddr(userdata, ref addr, ref area); item.Area = area; item.Addr = addr; if (row.Table.Columns.Contains("param7")) { string str6 = row["param7"].ToString(); if (!string.IsNullOrWhiteSpace(str6)) { item.Ration = int.Parse(str6); } } if (row.Table.Columns.Contains("param8")) { string str7 = row["param8"].ToString(); if (!string.IsNullOrWhiteSpace(str7)) { item.MaxValue = int.Parse(str7); } } if (row.Table.Columns.Contains("param9")) { string str8 = row["param9"].ToString(); if (!string.IsNullOrWhiteSpace(str8)) { item.MinValue = int.Parse(str8); } } AllPlcSimpleLst[id].Add(item); } catch (Exception) { } } } } } }
public void SetMValueOFF2ON2OFF(PlcInfoSimple p) { SetMValueON2OFF(p); }
public void SetMValueON2OFF(PlcInfoSimple p) { SetMValueON(p); ConstantMethod.Delay(200); SetMValueOFF(p); }