using System;
using System.ComponentModel.DataAnnotations;
namespace SharpCAT.Client.Models
{
///
/// Parity settings for serial communication
///
public enum Parity
{
///
/// No parity checking
///
None = 0,
///
/// Odd parity checking
///
Odd = 1,
///
/// Even parity checking
///
Even = 2,
///
/// Mark parity checking
///
Mark = 3,
///
/// Space parity checking
///
Space = 4
}
///
/// Stop bits settings for serial communication
///
public enum StopBits
{
///
/// No stop bits
///
None = 0,
///
/// One stop bit
///
One = 1,
///
/// Two stop bits
///
Two = 2,
///
/// One and a half stop bits
///
OnePointFive = 3
}
///
/// Handshake settings for serial communication
///
public enum Handshake
{
///
/// No flow control
///
None = 0,
///
/// XOn/XOff software flow control
///
XOnXOff = 1,
///
/// RTS hardware flow control
///
RequestToSend = 2,
///
/// Both RTS and XOn/XOff flow control
///
RequestToSendXOnXOff = 3
}
///
/// Response model for listing available serial ports
///
public class PortListResponse
{
///
/// Array of available serial port names
///
public string[] Ports { get; set; } = new string[0];
///
/// Number of available ports
///
public int Count => Ports.Length;
}
///
/// Request model for opening a serial port
///
public class OpenPortRequest
{
///
/// Name of the serial port to open (e.g., "COM1", "/dev/ttyUSB0")
///
[Required]
public string PortName { get; set; } = string.Empty;
///
/// Baud rate for communication (default: 9600)
///
public int BaudRate { get; set; } = 9600;
///
/// Parity setting (default: None)
///
public Parity Parity { get; set; } = Parity.None;
///
/// Stop bits setting (default: One)
///
public StopBits StopBits { get; set; } = StopBits.One;
///
/// Handshake setting (default: None)
///
public Handshake Handshake { get; set; } = Handshake.None;
}
///
/// Response model for port operations
///
public class PortOperationResponse
{
///
/// Indicates if the operation was successful
///
public bool Success { get; set; }
///
/// Human-readable message about the operation
///
public string Message { get; set; } = string.Empty;
///
/// Name of the port that was operated on
///
public string? PortName { get; set; }
///
/// Current status of the port (open/closed)
///
public bool IsOpen { get; set; }
}
///
/// Request model for sending CAT commands
///
public class SendCommandRequest
{
///
/// CAT command string to send to the radio
///
[Required]
public string Command { get; set; } = string.Empty;
}
///
/// Response model for CAT command operations
///
public class CommandResponse
{
///
/// Indicates if the command was sent successfully
///
public bool Success { get; set; }
///
/// The command that was sent
///
public string Command { get; set; } = string.Empty;
///
/// Response received from the radio (if any)
///
public string? Response { get; set; }
///
/// Human-readable message about the operation
///
public string Message { get; set; } = string.Empty;
///
/// Timestamp when the command was executed
///
public DateTime Timestamp { get; set; } = DateTime.UtcNow;
}
///
/// Response model for errors
///
public class ErrorResponse
{
///
/// Error message
///
public string Error { get; set; } = string.Empty;
///
/// Additional details about the error
///
public string? Details { get; set; }
///
/// Timestamp when the error occurred
///
public DateTime Timestamp { get; set; } = DateTime.UtcNow;
}
}