修改一些BUG

修改碳达人问题,增加小数,增加门锁的支持
This commit is contained in:
2026-03-03 17:18:43 +08:00
parent 10e3a135dd
commit 990ba9ce7b
8 changed files with 171 additions and 22 deletions

View File

@@ -1231,6 +1231,15 @@ namespace RCUHost.Implement
}, TS);
}
public static SearchHostPacketReply? DecodeSearchHostPacketReply(byte[] data, int startIndex)
{
return StructConverter.BytesToStruct(data, startIndex, typeof(SearchHostPacketReply)) as SearchHostPacketReply?;
}
public static SearchHostPacketReplyV2? DecodeSearchHostPacketReplyV2(byte[] data, int startIndex)
{
return StructConverter.BytesToStruct(data, startIndex, typeof(SearchHostPacketReplyV2)) as SearchHostPacketReplyV2?;
}
//private static readonly RecyclableMemoryStreamManager manager = new RecyclableMemoryStreamManager();
/// <summary>
/// 处理数据
@@ -1335,6 +1344,45 @@ namespace RCUHost.Implement
}
#endregion
///注册指令 也要推送
if (cmdType == 0x01)
{
string RoomNUMBER = CSRedisCacheHelper.HMGet<string>(5, CacheKey.RoomNumber_HostNumber, HostNNN)[0];
if (string.IsNullOrEmpty(RoomNUMBER))
{
return;
}
int startIndex = StructConverter.SizeOf(context111.SystemHeader);
SearchHostPacketReply? reply = DecodeSearchHostPacketReply(context111.Data, startIndex);
//SearchHostPacketReplyV2? C_Xilie_zhuji = null;
//if (context111.Data.Length > 100)//V2版本新补充的内容
//{
// C_Xilie_zhuji = DecodeSearchHostPacketReplyV2(context111.Data, 58);
//}
string MAC = "";
if (reply.HasValue)
{
MAC = BitConverter.ToString(reply.Value.MAC);
//string version = reply.Value.Version;
//var ConfigVersion = String.Join(".", reply.Value.ConfigVersion);
//var SubnetMask = String.Join(".", reply.Value.SubnetMask);
//var Gateway = String.Join(".", reply.Value.Gateway);
}
LMRegisterInfo lma = new LMRegisterInfo();
lma.HotelCode = CODE;
lma.RoomNumber = RoomNUMBER;
lma.HostNumber = HostNNN;
lma.MAC = MAC;
lma.Original_Data = context111.Data;
string ti = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
lma.CurrentDateTime = ti;
lma.UnixTime = Tools.GetUnixTime();
string sss = Newtonsoft.Json.JsonConvert.SerializeObject(lma);
CSRedisCacheHelper.Publish("redis-0X01", sss);
}
try
{
@@ -2286,7 +2334,7 @@ namespace RCUHost.Implement
var CarbonVIP = reader.ReadByte();
int Bright_Va = -1;
if (Version == 0x03)
if (Version == 0x03 || Version == 0x04)
{
var LiangDu = reader.ReadBytes(4);
Bright_Va = (int)LiangDu[0];
@@ -2298,6 +2346,40 @@ namespace RCUHost.Implement
{
CarbonVIP = 0x00;
}
///碳达人状态更新
if (!string.IsNullOrEmpty(HostID))
{
string KKey = CacheKey.HostModalStatus_Prefix + "_" + HostID + "_" + "054000001";
//var OldHostModal = CSRedisCacheHelper.Get_Partition<HostModal_Cache>(KKey);
//OldHostModal.Status = CarbonVIP;
//CSRedisCacheHelper.Set_Partition<HostModal_Cache>(KKey,OldHostModal);
StringBuilder sb = new StringBuilder();
sb.Append(CacheKey.CarbonVIP_Prefix);
sb.Append("_");
sb.Append(HostID.ToString());
string Key = sb.ToString();
string current_status_new = "";
if (CarbonVIP == 0x01)
{
current_status_new = "open";
}
else if (CarbonVIP == 0x02)
{
current_status_new = "close";
}
else
{
current_status_new = "unknow";
}
CSRedisCacheHelper.Set(Key, current_status_new);
}
var DeviceCount = reader.ReadByte();
int DeviceCount_I = (int)DeviceCount;
@@ -2307,7 +2389,11 @@ namespace RCUHost.Implement
List<KongTiao> kongtiaoList = new List<KongTiao>();
for (int i = 0; i < DeviceCount_I; i++)
{
var QA = reader.ReadBytes(4);
byte[] QA = reader.ReadBytes(4);
//if (Version == 0x04)
//{
// QA = reader.ReadBytes(5);
//}
//说明是能耗设备
#region
if (QA[0] == 0x39)
@@ -2413,6 +2499,14 @@ namespace RCUHost.Implement
///ushort StatusReceiver = reader.ReadUInt16();
ushort StatusReceiver = BitConverter.ToUInt16(reader.ReadBytes(2).Reverse().ToArray(), 0);
int XiaoShu_BuFen = 0;
float xiaoshu_l = 0.0f;
if (Version == 0x04)
{
var XiaoShu = reader.ReadByte();
XiaoShu_BuFen = XiaoShu;
xiaoshu_l = XiaoShu_BuFen / 10;
}
if (true)
{
@@ -2436,7 +2530,7 @@ namespace RCUHost.Implement
kkk.address = address;
kkk.model = mode;
kkk.speed = fanspeed;
kkk.now_temp = currentTemp;
kkk.now_temp = Convert.ToInt32((currentTemp + xiaoshu_l) * 10);
kkk.set_temp = temperature;
kkk.solenoid_valve = valve;
kongtiaoList.Add(kkk);
@@ -2556,8 +2650,9 @@ namespace RCUHost.Implement
}
catch (Exception ex)
{
logger.Error("定上报出错:" + ex.Message);
logger.Error("定上报出错:" + ex.StackTrace);
logger.Error("定上报出错:" + Tools.ByteToString(context111.Data));
logger.Error("定上报出错:" + ex.Message);
logger.Error("定时上报出错:" + ex.StackTrace);
}
}
#endregion