using System.ComponentModel.DataAnnotations; using System.IO.Ports; namespace Server.Models { /// /// Response model for listing available serial ports /// public class PortListResponse { /// /// Array of available serial port names /// public string[] Ports { get; set; } = Array.Empty(); /// /// 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; } }