增加MXL4模组
This commit is contained in:
389
WCS.BLL/HardWare/MXL4Shelf.cs
Normal file
389
WCS.BLL/HardWare/MXL4Shelf.cs
Normal file
@ -0,0 +1,389 @@
|
||||
using System;
|
||||
using WCS.BLL.Config;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.Manager;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.DAL.DbModels;
|
||||
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
|
||||
{
|
||||
/// <summary>
|
||||
/// 智能货架
|
||||
/// </summary>
|
||||
public class MXL4Shelf : IShelfBase
|
||||
{
|
||||
public MXL4Shelf(ShelfInfo shelfInfo)
|
||||
{
|
||||
ShelfId = shelfInfo.Id;
|
||||
ShelfCode = shelfInfo.ShelfCode;
|
||||
RowCounts = shelfInfo.Rowcounts;
|
||||
ColumnCounts = shelfInfo.Columncounts;
|
||||
SetCurrentMode(Mode.待机模式);
|
||||
ClientIp = shelfInfo.ClientIp;
|
||||
LightId = shelfInfo.LightId;
|
||||
WarningLight = new WarningLight() { LightId = shelfInfo.LightId };
|
||||
|
||||
//初始化Module
|
||||
Task.Run(() =>
|
||||
{
|
||||
var modules = DbHelp.db.Queryable<ModuleInfo>().Where(t => t.ShelfId == ShelfId).ToList();
|
||||
foreach (var module in modules)
|
||||
{
|
||||
MXL4Modules.Add(new MXL4ShelfModule()
|
||||
{
|
||||
ModuleId = module.Id,
|
||||
ModuleCode = module.ModuleCode,
|
||||
BoardId = module.BoardId,
|
||||
IsEnable = module.IsEnable,
|
||||
CurrentMode = module.CurrentMode
|
||||
});
|
||||
}
|
||||
ModulesStr = string.Join(";", MXL4Modules.Select(t => t.ModuleCode));
|
||||
|
||||
ModuleIds = MXL4Modules.Select(t => t.BoardId).ToList();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public int ShelfId { get; set; }
|
||||
public string ShelfCode { get; set; }
|
||||
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 List<MXL4ShelfModule> MXL4Modules { get; set; } = new List<MXL4ShelfModule>();
|
||||
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()
|
||||
{
|
||||
if (this.CurrentMode == Mode.入库模式)
|
||||
{
|
||||
WarningLight.BlueLight(TcpCleint);
|
||||
}
|
||||
else if (this.CurrentMode == Mode.出库模式)
|
||||
{
|
||||
WarningLight.GreenLight(TcpCleint);
|
||||
}
|
||||
else if (this.CurrentMode == Mode.盘点模式)
|
||||
{
|
||||
WarningLight.GreenLight(TcpCleint);
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningLight.CloseLight(TcpCleint);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 自检异常、未响应对应模式的异常
|
||||
/// </summary>
|
||||
public List<string> ExceptionMessages { get; set; } = new List<string>();
|
||||
/// <summary>
|
||||
/// 过程中异常 入库过程中异常/出库过程中异常
|
||||
/// </summary>
|
||||
public List<ProcessingExceptionType> ProcessingExceptions { get; set; } = new List<ProcessingExceptionType>();
|
||||
public string? CurrentCom { get; set; } = string.Empty;
|
||||
|
||||
public MatInfoResponse InStoreData { get; set; }
|
||||
|
||||
public List<string> CurrentOutStoreMatSNs { get; set; } = new List<string>();
|
||||
|
||||
public OutOrder CurrentOutOrder { get; set; }
|
||||
|
||||
public string OrderNumber { get; set; }
|
||||
|
||||
public StockTakingOrder CurrentStockTakingOrder { get; set; }
|
||||
|
||||
public List<int> ModuleIds { get; set; }
|
||||
public string ClientIp { get; set; }
|
||||
|
||||
//websocket通知的前端的IP地址
|
||||
public string WebSocketIpAddress { get; set; } = "127.0.0.2";
|
||||
|
||||
public string OutOperateUser { get; set; } = string.Empty;
|
||||
#region 协议处理
|
||||
public void GoInInstore(string? IPAddress)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void GoOutInstore()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 由自检异常等错误导致的 手动操作处理后重新进入出库模式
|
||||
/// </summary>
|
||||
/// <param name="ModuleId"></param>
|
||||
public void GoInOutstoreByWebSocket(int moduleId)
|
||||
{
|
||||
|
||||
}
|
||||
public void GoInOutstore(List<OutOrderMatDetail> MatDetails, OutOrder outOrder, string OperateUser)
|
||||
{
|
||||
|
||||
}
|
||||
public void GoOutOutstore()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void GoInStocktaking(List<StockTakingOrderMatDetail> MatDetails, StockTakingOrder stockTakingOrder)
|
||||
{
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 确认盘点 Pda进行触发
|
||||
/// </summary>
|
||||
public bool ConfirmStocktakingSingle(int BoardId, int LightNumber)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public void GoOutStocktaking()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void QueryVoltage(int moduleId)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void CalibrationSetOffset(int moduleId, int offSet)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void SetCurrentMode(Mode mode)
|
||||
{
|
||||
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()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void ShelfCheck()
|
||||
{
|
||||
|
||||
}
|
||||
#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)
|
||||
{
|
||||
//协议处理 判断功能位
|
||||
switch (data[TcpCleint.PreFixLength + 2])
|
||||
{
|
||||
case 0x01://进入入库模式返回信号
|
||||
GoInInstoreProcess(data, boardId, lightNumber);
|
||||
break;
|
||||
case 0x02://退出入库模式返回信号
|
||||
GoOutInstoreProcess(data, boardId, lightNumber);
|
||||
break;
|
||||
case 0x03://正常入库信号
|
||||
InStoreReturnProcess(data);
|
||||
break;
|
||||
case 0x04://入库模式中异常信号
|
||||
InStoreExceptionReturnProcess(data, boardId, lightNumber);
|
||||
break;
|
||||
case 0x05://进入出库模式返回信号
|
||||
GoInOutstoreProcess(data, boardId, lightNumber);
|
||||
break;
|
||||
case 0x06://退出出库模式返回信号
|
||||
GoOutOutstoreProcess(data, boardId, lightNumber);
|
||||
break;
|
||||
case 0x07://正常出库返回信号
|
||||
OutstoreReturnProcess(data, boardId, lightNumber);
|
||||
break;
|
||||
case 0x08://出库模式中异常信号
|
||||
OutstoreExceptionReturnProcess(data, boardId, lightNumber);
|
||||
break;
|
||||
case 0x09://进入盘点模式返回信号
|
||||
GoInStockTakingReturnProcess(data, boardId, lightNumber);
|
||||
break;
|
||||
case 0x0A://退出盘点模式返回信号
|
||||
GoOutStockTakingReturnProcess(data, boardId, lightNumber);
|
||||
break;
|
||||
case 0x13://复位的返回信号
|
||||
ResetReturnProcess(data, boardId, lightNumber);
|
||||
break;
|
||||
case 0x17://电压值1
|
||||
QueryVoltageProcess(data, boardId, lightNumber);
|
||||
break;
|
||||
case 0x18://电压值2
|
||||
QueryVoltageProcess(data, boardId, lightNumber);
|
||||
break;
|
||||
case 0x19://电压值3
|
||||
QueryVoltageProcess(data, boardId, lightNumber);
|
||||
break;
|
||||
case 0x0B://自检结果反馈
|
||||
SelfCheckProcess(data, boardId, lightNumber);
|
||||
break;
|
||||
default:
|
||||
;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 进入入库模式返回信号处理
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
public void GoInInstoreProcess(byte[] data, int boardId, int lightNumber)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 退出入库模式返回信号处理
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
public void GoOutInstoreProcess(byte[] data, int boardId, int lightNumber)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 正常入库信号
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
public void InStoreReturnProcess(byte[] data)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 入库模式中异常处理
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="boardId"></param>
|
||||
/// <param name="lightNumber"></param>
|
||||
public void InStoreExceptionReturnProcess(byte[] data, int boardId, int lightNumber)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 进入出库模式协议返回
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="boardId"></param>
|
||||
/// <param name="lightNumber"></param>
|
||||
public void GoInOutstoreProcess(byte[] data, int boardId, int lightNumber)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void OutstoreReturnProcess(byte[] data, int boardId, int lightNumber)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 退出出库模式返回信号处理
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
public void GoOutOutstoreProcess(byte[] data, int boardId, int lightNumber)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 出库模式中异常处理
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="boardId"></param>
|
||||
/// <param name="lightNumber"></param>
|
||||
public void OutstoreExceptionReturnProcess(byte[] data, int boardId, int lightNumber)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 进入盘点模式返回信号
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="boardId"></param>
|
||||
/// <param name="lightNumber"></param>
|
||||
public void GoInStockTakingReturnProcess(byte[] data, int boardId, int lightNumber)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void GoOutStockTakingReturnProcess(byte[] data, int boardId, int lightNumber)
|
||||
{
|
||||
}
|
||||
|
||||
public void ResetReturnProcess(byte[] data, int boardId, int lightNumber)
|
||||
{
|
||||
}
|
||||
|
||||
public void QueryVoltageProcess(byte[] data, int boardId, int lightNumber)
|
||||
{
|
||||
}
|
||||
|
||||
public void SelfCheckProcess(byte[] data, int boardId, int lightNumber)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user