private void CheckError(QcdmCommand command) { string message = null; switch (command) { case QcdmCommand.BadCmd: message = Strings.QcdmCommandBadCmd; break; case QcdmCommand.BadParm: message = Strings.QcdmCommandBadParm; break; case QcdmCommand.BadLen: message = Strings.QcdmCommandBadLen; break; case QcdmCommand.BadMode: message = Strings.QcdmCommandBadMode; break; case QcdmCommand.BadSpcMode: message = Strings.QcdmCommandBadSpcMode; break; } if (message != null) { throw new QcdmManagerException(message); } }
public static string ToString(QcdmCommand command, byte[] data) { var sb = new StringBuilder(); if (data == null) { sb.Append(" null"); } else { if (data.Length > 3 && command == QcdmCommand.SubsysCmd) { var text = QcdmSubSystemCommandUtils.ToString(data); sb.Append(text); } else { sb.Append(command); } sb.Append(ToString(data)); } return(sb.ToString()); }
private void LogCommandResponseDebug(QcdmCommand command, byte[] data) { var sb = new StringBuilder(); sb.Append("< "); sb.Append(QcdmCommandUtils.ToString(command, data)); LogDebug(sb.ToString()); }
private static IQcdmCommandResponse CreateCommandResponse(QcdmCommand command, byte[] data) { var key = (uint)command; if (_commandResponseCreators.TryGetValue(key, out var creator)) { return(creator(data)); } throw new QcdmManagerException(string.Format(Strings.QcdmUnsupportedCommandResponseFormat, command)); }
private void InitializeCommand() { var type = GetType(); if (Command == QcdmCommand.Max && type.GetCustomAttributes(typeof(QcdmCommandAttribute), true).FirstOrDefault() is QcdmCommandAttribute attribute) { Command = attribute.Command; } }
public static IQcdmCommandResponse CommandResponse(QcdmCommand command, byte[] data) { IQcdmCommandResponse result = null; switch (command) { case QcdmCommand.SubsysCmd: result = CreateSubsysCommandResponse(data); break; default: result = CreateCommandResponse(command, data); break; } return(result); }
private void Initialize() { var type = GetType(); if (Command == QcdmCommand.Max && type.GetCustomAttributes(typeof(QcdmCommandAttribute), true).FirstOrDefault() is QcdmCommandAttribute attribute) { Command = attribute.Command; } if (MinResponseLength == 0 && type.GetCustomAttributes(typeof(QcdmMinResponseLengthAttribute), true).FirstOrDefault() is QcdmMinResponseLengthAttribute attribute2) { MinResponseLength = attribute2.MinResponseLength; } }
public QcdmCommandAttribute(QcdmCommand command) { Command = command; }