移植后台关灯机制 超时退出模式关灯,灯状态不对的恢复

This commit is contained in:
hehaibing-1996
2024-05-29 14:23:01 +08:00
parent 4958c58706
commit d1914bb2d1
10 changed files with 233 additions and 30 deletions

View File

@ -1,4 +1,5 @@
using WCS.BLL.Config;
using System;
using WCS.BLL.Config;
using WCS.BLL.DbModels;
using WCS.BLL.Manager;
using WCS.DAL.Db;
@ -7,6 +8,7 @@ using WCS.Model;
using WCS.Model.ApiModel.InOutRecord;
using WCS.Model.ApiModel.OutStore;
using WCS.Model.WebSocketModel;
using static WCS.BLL.HardWare.WarningLight;
namespace WCS.BLL.HardWare
{
@ -21,7 +23,8 @@ namespace WCS.BLL.HardWare
ShelfCode = shelfInfo.ShelfCode;
RowCounts = shelfInfo.Rowcounts;
ColumnCounts = shelfInfo.Columncounts;
CurrentMode = shelfInfo.CurrentMode;
//CurrentMode = shelfInfo.CurrentMode;
SetCurrentMode(Mode.);
ClientIp = shelfInfo.ClientIp;
LightId = shelfInfo.LightId;
WarningLight = new WarningLight() { LightId = shelfInfo.LightId };
@ -53,12 +56,15 @@ namespace WCS.BLL.HardWare
public int RowCounts { get; set; }
public int ColumnCounts { get; set; }
public Mode CurrentMode { get; set; }
public DateTime SetCurrentModeTime { get; set; }
public string ModulesStr { get; set; }//当前货架所有模组的Str
public string GroupName { get; set; }
public List<SmartShelfModule> Modules { get; set; } = new List<SmartShelfModule>();
public TCPClient TcpCleint { get { return TCPClientManager.GetTCPClientByIPHost(ClientIp); } }
public int LightId { get; set; }
public LightColorEnum LightColor { get; set; }
public bool IsWarning { get; set; } = false;
public WarningLight WarningLight { get; set; }
public void ClearWarning()
@ -124,7 +130,8 @@ namespace WCS.BLL.HardWare
}
else
{
this.CurrentMode = Mode.;
//this.CurrentMode = Mode.入库模式;
SetCurrentMode(Mode.);
}
//清空错误
ExceptionMessages.Clear();
@ -221,7 +228,8 @@ namespace WCS.BLL.HardWare
}
else
{
this.CurrentMode = Mode.;
//this.CurrentMode = Mode.待机模式;
SetCurrentMode(Mode.);
}
//清空错误
@ -258,7 +266,8 @@ namespace WCS.BLL.HardWare
.ToList();
if (list.Count > 0)
{
CurrentMode = Mode.;
//CurrentMode = Mode.待机模式;
SetCurrentMode(Mode.);
foreach (var item in list)
{
ExceptionMessages.Add($"模组{item.ModuleCode}未成功退出入库模式!");
@ -295,7 +304,8 @@ namespace WCS.BLL.HardWare
//复位需要点时间间隔才能响应指令
Thread.Sleep(1500);
}
CurrentMode = Mode.;
//CurrentMode = Mode.出库模式;
SetCurrentMode(Mode.);
//第二步货架添加需要出的SN 出库的领料单号
//移除货架所有现有待出库的MatSN
@ -424,7 +434,8 @@ namespace WCS.BLL.HardWare
CurrentOutStoreMatSNs.Clear();
WarningLight.CloseLight(TcpCleint);
this.CurrentMode = Mode.;
//this.CurrentMode = Mode.待机模式;
SetCurrentMode(Mode.);
Logs.Write($"货架【{ShelfCode}】,结束退出出库", LogsType.Outstore);
}
catch (Exception ex)
@ -449,7 +460,8 @@ namespace WCS.BLL.HardWare
Thread.Sleep(1500);
}
CurrentMode = Mode.;
//CurrentMode = Mode.盘点模式;
SetCurrentMode(Mode.);
//第二步:货架添加 盘点单号 记录当前盘点的发料单
CurrentStockTakingOrder = stockTakingOrder;
@ -609,7 +621,8 @@ namespace WCS.BLL.HardWare
});
CurrentOutStoreMatSNs.Clear();
WarningLight.CloseLight(TcpCleint);
this.CurrentMode = Mode.;
//this.CurrentMode = Mode.待机模式;
SetCurrentMode(Mode.);
}
public void Reset()
@ -623,7 +636,8 @@ namespace WCS.BLL.HardWare
});
}
WarningLight.CloseLight(TcpCleint);
this.CurrentMode = Mode.;
//this.CurrentMode = Mode.待机模式;
SetCurrentMode(Mode.);
}
public void QueryVoltage(int moduleId)
@ -635,9 +649,20 @@ namespace WCS.BLL.HardWare
}
}
void IShelfBase.SetCurrentMode()
public void SetCurrentMode(Mode mode)
{
throw new NotImplementedException();
this.CurrentMode = mode;
this.SetCurrentModeTime = DateTime.Now;
Task.Run(() =>
{
var shelf = DbHelp.db.Queryable<ShelfInfo>().Where(t => t.Id == ShelfId).First();
if (shelf != null)
{
shelf.CurrentMode = mode;
shelf.SetCurrentModeTime = SetCurrentModeTime;
DbHelp.db.Updateable(shelf).ExecuteCommand();
}
});
}
void IShelfBase.Warning()
@ -654,6 +679,39 @@ namespace WCS.BLL.HardWare
}
#endregion
#region
public void WarningLightProcess(byte[] data, int boardId, int lightNumber)
{
if (data[TcpCleint.PreFixLength + 2] == 0x20 && data[TcpCleint.PreFixLength + 3] == 0x01)
{
//常亮或关闭 0x00常亮 0x01关闭
if (data[TcpCleint.PreFixLength + 5] == 0x00)
{
LightColor = LightColorEnum.;
Logs.Write($"货架[{ShelfCode}],灯状态更新为:{LightColor}");
}
else if (data[TcpCleint.PreFixLength + 5] == 0x01)
{
switch (data[7])
{
case 0x01:
LightColor = LightColorEnum.;
break;
case 0x02:
LightColor = LightColorEnum.绿;
break;
case 0x03:
LightColor = LightColorEnum.;
break;
default:
break;
}
Logs.Write($"货架[{ShelfCode}],灯状态更新为:{LightColor}");
}
}
}
#endregion
#region
public void ProtocolProcess(byte[] data, int boardId, int lightNumber)
{
@ -1432,6 +1490,15 @@ namespace WCS.BLL.HardWare
//确认本次出库
module.ComfirmOutstore(TcpCleint, data[TcpCleint.PreFixLength + 3]);
//更新时间 避免被自动退出
Task.Run(() =>
{
var shelves = ShelfManager.Shelves.Where(t => t.CurrentMode == Mode. && t.OrderNumber == OrderNumber).ToList();
foreach (var shelf in shelves)
{
shelf.SetCurrentModeTime = DateTime.Now;
}
});
//当前柜子是否还存在未出库的