2025-07-31 18:51:24 +08:00

60 lines
1.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using YunDa.Server.ISMSTcp.Models;
namespace YunDa.Server.ISMSTcp.Interfaces
{
/// <summary>
/// 命令状态机接口
/// </summary>
public interface ICommandStateMachine
{
/// <summary>
/// 当前命令状态
/// </summary>
CommandState CurrentCommand { get; }
/// <summary>
/// 是否有命令正在执行
/// </summary>
bool HasPendingCommand { get; }
/// <summary>
/// 开始执行命令
/// </summary>
/// <param name="commandName">命令名称</param>
/// <param name="fullMessage">完整消息</param>
/// <param name="timeoutSeconds">超时时间(秒)</param>
/// <returns>是否成功开始执行</returns>
bool StartCommand(string commandName, string fullMessage, int timeoutSeconds = 180);
/// <summary>
/// 完成当前命令
/// </summary>
/// <param name="commandName">响应的命令名称(用于验证)</param>
/// <returns>是否成功完成</returns>
bool CompleteCommand(string commandName = null);
/// <summary>
/// 设置命令超时
/// </summary>
/// <returns>是否有命令被设置为超时</returns>
bool TimeoutCommand();
/// <summary>
/// 检查并处理超时
/// </summary>
/// <returns>是否有命令超时</returns>
bool CheckAndHandleTimeout();
/// <summary>
/// 处理OK响应解锁命令状态
/// </summary>
/// <returns>是否成功处理OK响应</returns>
bool HandleOkResponse();
/// <summary>
/// 重置状态机
/// </summary>
void Reset();
}
}