48 lines
1.3 KiB
C#
48 lines
1.3 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
using DM_Weight.Port;
|
||
using log4net;
|
||
|
||
namespace DM_Weight.Common
|
||
{
|
||
public class Temperature
|
||
{
|
||
private readonly static ILog logger = LogManager.GetLogger(typeof(Temperature));
|
||
/// <summary>
|
||
/// 将收到的返回转换成具体温度数值
|
||
/// </summary>
|
||
/// <param name="receiveData"></param>
|
||
/// <returns></returns>
|
||
public static string GetResultWD(string receiveData)
|
||
{
|
||
try
|
||
{
|
||
|
||
string newStrWD = receiveData.Substring(10, 4);
|
||
|
||
logger.Info($"截取后数据newStrWD:{newStrWD}");
|
||
int iWD = Convert.ToInt32(newStrWD, 16);
|
||
logger.Info($"截取后数据iWD:{iWD}");
|
||
float fWD = 0;
|
||
if (iWD != 0)
|
||
{
|
||
fWD = iWD * 1.0f / 10;
|
||
}
|
||
|
||
logger.Info($"截取后数据fWD:{fWD}");
|
||
string strRet = $"冰箱抽屉当前温度:{fWD}℃;";
|
||
|
||
return strRet;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
logger.Info("GetResultWD异常", new Exception($"{ex.ToString()}"));
|
||
}
|
||
return "数据异常";
|
||
}
|
||
}
|
||
}
|