public static bool TryParse(Protocol protocol, byte[] data, out TorqueAlarmEventArgs args) { args = null; try { switch (protocol) { case Protocol.OpenProtocol: args = ParseOpenProtocol(data); return true; default: return false; } } catch { return false; } }
private static TorqueAlarmEventArgs ParseOpenProtocol(byte[] data) { string str; TorqueAlarmEventArgs args = new TorqueAlarmEventArgs(); str = ASCIIEncoding.ASCII.GetString(data, 3, 3); args.mErrorCode = Convert.ToInt32(str); args.mControllerReadyStatus = (data[8] == 1); args.mToolReadyStatus = (data[11] == 1); return args; }