菜单状态切换

This commit is contained in:
zqm
2025-10-29 12:55:14 +08:00
parent fc66e8df33
commit 8f7585fd0f
3 changed files with 186 additions and 18 deletions

View File

@@ -251,14 +251,26 @@ namespace JoyD.Windows.CS.Toprie
// 解析响应数据
private int ParseResponseValue(string response)
{
if (string.IsNullOrEmpty(response) || !response.StartsWith("+RET:"))
if (string.IsNullOrEmpty(response))
return -1; // 返回-1表示解析失败
// 支持两种响应格式: +RET: 和 +RSP:
int startIndex = -1;
if (response.StartsWith("+RET:"))
startIndex = 5;
else if (response.StartsWith("+RSP:"))
startIndex = 5;
if (startIndex == -1)
return -1;
try
{
// 从第5个字符开始解析数值与热像仪SDK保持一致
// SDK使用atoi(buff + 5)直接解析,不检查$符号
string valueStr = response.Substring(5);
string valueStr = response.Substring(startIndex);
// 移除结尾可能存在的$符号
if (valueStr.EndsWith("$"))
valueStr = valueStr.Substring(0, valueStr.Length - 1);
return int.Parse(valueStr);
}
catch (Exception ex)