public override string GetPowerStatus(string pct) { byte[] pctBytes = GetCommandBytes(pct); string response = string.Empty; foreach (byte b in pctBytes) { response += b.ToString(); } if (_communicationType == "RS232 MDC") { response = _comRS232.ExecuteCommand(pctBytes); } else { byte[] serverResponse = _comRJ45.ExecuteCommand(pctBytes); response = System.Text.Encoding.ASCII.GetString(serverResponse); } bool success = response.Contains("OK"); if (success) { int k = response.IndexOf('O') + 2; if (response.Substring(k, response.IndexOf('x') - k) == "01") { return("On"); } return("Off"); } return("Error"); }
public override string GetPowerStatus(string pct) { pct = GetSum(pct); byte[] pctBytes = GetCommandBytes(pct); bool success = false; if (_communicationType == "RS232 MDC") { string serverResponse = _comRS232.ExecuteCommand(pctBytes); } else { byte[] serverResponse = _comRJ45.ExecuteCommand(pctBytes); success = serverResponse.Contains((byte)65); if (success) { if (serverResponse[Array.IndexOf(serverResponse, (byte)17) + 1] == (byte)1) { return("On"); } return("Off"); } } return("Error"); }