public override int GetPlcStatus(ref ComLink.PLCStatus status) { StringBuilder strCommand = new StringBuilder("@"); strCommand.Append(this._strUnitNo); strCommand.Append("FA100000000"); strCommand.Append("0601"); string strFcs = this.GetFcs(strCommand.ToString()); strCommand.Append(strFcs); strCommand.Append("*"); strCommand.Append('\r'); int result; try { string strRead = null; lock (this._port) { this._port.Write(strCommand.ToString()); strRead = this._port.ReadTo(this._strReadTo); } if (strRead.Substring(19, 4).Equals("0000")) { string strStatus = strRead.Substring(25, 2); string text = strStatus; if (text != null) { if (!(text == "00")) { if (!(text == "02")) { if (text == "04") { status = ComLink.PLCStatus.RUN; } } else { status = ComLink.PLCStatus.MONITOR; } } else { status = ComLink.PLCStatus.PROGRAM; } } result = 0; return(result); } } catch (Exception ex) { throw new Exception(ex.Message); } result = 1; return(result); }
public abstract int GetPlcStatus(ref ComLink.PLCStatus status);