提交代码
This commit is contained in:
@ -66,6 +66,8 @@ namespace WCS.BLL.HardWare
|
||||
public string GroupName { get; set; }
|
||||
|
||||
public string WebSocketIpAddress { get; set; }
|
||||
|
||||
public string? CurrentCom { get; set; }
|
||||
/// <summary>
|
||||
/// 模组
|
||||
/// </summary>
|
||||
|
@ -4,6 +4,9 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.Manager;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.DAL.DbModels;
|
||||
using WCS.Model;
|
||||
using static WCS.BLL.HardWare.WarningLight;
|
||||
|
||||
@ -11,26 +14,40 @@ namespace WCS.BLL.HardWare
|
||||
{
|
||||
public class SingleLightShelf : IShelfBase
|
||||
{
|
||||
public int ShelfId { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public string ShelfCode { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public int RowCounts { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public int ColumnCounts { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public Mode CurrentMode { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public string ModulesStr { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public string GroupName { get; set; }
|
||||
public MatInfoResponse InStoreData { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public SingleLightShelf(ShelfInfo shelfInfo)
|
||||
{
|
||||
ShelfId = shelfInfo.Id;
|
||||
ShelfCode = shelfInfo.ShelfCode;
|
||||
RowCounts = shelfInfo.Rowcounts;
|
||||
ColumnCounts = shelfInfo.Columncounts;
|
||||
SetCurrentMode(Mode.待机模式);
|
||||
ClientIp = shelfInfo.ClientIp;
|
||||
LightId = shelfInfo.LightId;
|
||||
}
|
||||
|
||||
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 string ModulesStr { get; set; }
|
||||
public string GroupName { get; set; }
|
||||
public MatInfoResponse InStoreData { get; set; }
|
||||
public string? CurrentCom { get; set; } = string.Empty;
|
||||
public string OrderNumber { get; set; }
|
||||
public int LightId { get; set; }
|
||||
public LightColorEnum LightColor { get; set; }
|
||||
public List<int> ModuleIds { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public string ClientIp { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public List<string> ExceptionMessages { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public bool IsWarning { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public string WebSocketIpAddress { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public List<SmartShelfModule> Modules { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public List<int> ModuleIds { get; set; }
|
||||
public string ClientIp { get; set; }
|
||||
public List<string> ExceptionMessages { get; set; }
|
||||
public bool IsWarning { get; set; }
|
||||
public string WebSocketIpAddress { get; set; }
|
||||
|
||||
public List<SmartShelfModule> Modules { get; set; } = new List<SmartShelfModule>();
|
||||
public DateTime SetCurrentModeTime { get; set; }
|
||||
|
||||
public TCPClient TcpCleint { get { return TCPClientManager.GetTCPClientByIPHost(ClientIp); } }
|
||||
|
||||
public bool ConfirmStocktakingSingle(int BoardId, int LightNumber)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
@ -56,6 +56,7 @@ 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; }
|
||||
@ -95,7 +96,6 @@ namespace WCS.BLL.HardWare
|
||||
/// </summary>
|
||||
public List<ProcessingExceptionType> ProcessingExceptions { get; set; } = new List<ProcessingExceptionType>();
|
||||
public string? CurrentCom { get; set; } = string.Empty;
|
||||
//TODO 退出入库清除
|
||||
|
||||
public MatInfoResponse InStoreData { get; set; }
|
||||
|
||||
@ -119,6 +119,7 @@ namespace WCS.BLL.HardWare
|
||||
{
|
||||
try
|
||||
{
|
||||
Logs.Write($"[GoInInstore IPAddress]{IPAddress}", LogsType.Instore);
|
||||
if (this.CurrentMode == Mode.入库模式)
|
||||
{
|
||||
CurrentCom = IPAddress;
|
||||
@ -217,6 +218,7 @@ namespace WCS.BLL.HardWare
|
||||
WarningLight.BlueLight(TcpCleint);
|
||||
//绑定当前进入入库PDA/WCS前端的IP
|
||||
CurrentCom = IPAddress;
|
||||
Logs.Write($"[GoInInstore CurrentCom]{CurrentCom}", LogsType.Instore);
|
||||
//返回成功
|
||||
return;
|
||||
}
|
||||
@ -866,6 +868,15 @@ namespace WCS.BLL.HardWare
|
||||
}
|
||||
}
|
||||
|
||||
public void CalibrationSetOffset(int moduleId, int offSet)
|
||||
{
|
||||
var moudle = Modules.Where(t => t.ModuleId == moduleId).First();
|
||||
if (moudle != null)
|
||||
{
|
||||
moudle.CalibrationSetOffset(offSet, TcpCleint);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetCurrentMode(Mode mode)
|
||||
{
|
||||
this.CurrentMode = mode;
|
||||
@ -891,11 +902,62 @@ namespace WCS.BLL.HardWare
|
||||
{
|
||||
try
|
||||
{
|
||||
OrderNumber = "自检中...";
|
||||
if (CurrentMode == Mode.待机模式)
|
||||
OrderNumber = "自检中...";
|
||||
foreach (var module in Modules.Where(t => t.IsEnable).ToList())
|
||||
{
|
||||
module.IsSelfCheck = true;
|
||||
module.ShelfCheck(TcpCleint);
|
||||
}
|
||||
|
||||
//状态校验 自检模式未响应
|
||||
Task.Run(() =>
|
||||
{
|
||||
var timeOut = 3000;
|
||||
var timeSpan = TimeSpan.FromMilliseconds(0);
|
||||
var beginTime = DateTime.Now;
|
||||
while (timeSpan <= TimeSpan.FromMilliseconds(timeOut))
|
||||
{
|
||||
timeSpan = DateTime.Now - beginTime;
|
||||
//所有板子成功进入入库模式 表示进入入库模式成功,跳出循环
|
||||
var isSelfChecking = Modules.Where(t => t.IsSelfCheck)
|
||||
.Where(t => t.IsEnable)
|
||||
.Any();
|
||||
if (!isSelfChecking)
|
||||
{
|
||||
break;
|
||||
}
|
||||
//循环延时处理
|
||||
Thread.Sleep(50);
|
||||
}
|
||||
|
||||
var notReturnList = Modules.Where(t => t.IsSelfCheck)
|
||||
.Where(t => t.IsEnable).ToList();
|
||||
|
||||
if (notReturnList.Count > 0)
|
||||
{
|
||||
Logs.Write($"货架{ShelfCode}存在模组自检未响应:", LogsType.Instore);
|
||||
foreach (var item in notReturnList)
|
||||
{
|
||||
ExceptionMessages.Add($"模组{item.ModuleCode}未响应自检!");
|
||||
}
|
||||
//通信校验
|
||||
var messages = notReturnList.Select(t => $"模组{t.ModuleCode}未响应自检!").ToList();
|
||||
var exceptionMessage = string.Join("\r\n", messages);
|
||||
var warningModel = new WebSocketMessageModel()
|
||||
{
|
||||
IsWarning = false,
|
||||
WarningType = WarningTypeEnum.自检未响应,
|
||||
StoreId = 0,
|
||||
StoreCode = "",
|
||||
ShelfCode = ShelfCode,
|
||||
ShelfId = ShelfId,
|
||||
WarningMessage = exceptionMessage,
|
||||
ClientIp = WebSocketIpAddress,
|
||||
};
|
||||
WarningManager.SendWarning(warningModel);
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -903,7 +965,8 @@ namespace WCS.BLL.HardWare
|
||||
}
|
||||
finally
|
||||
{
|
||||
OrderNumber = string.Empty;
|
||||
if (CurrentMode == Mode.待机模式)
|
||||
OrderNumber = string.Empty;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
@ -1211,7 +1274,6 @@ namespace WCS.BLL.HardWare
|
||||
|
||||
if (storeInfo == null)
|
||||
{
|
||||
//TODO 报错
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1219,7 +1281,6 @@ namespace WCS.BLL.HardWare
|
||||
.FirstOrDefault();
|
||||
if (module == null)
|
||||
{
|
||||
//TODO 报错
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1261,7 +1322,7 @@ namespace WCS.BLL.HardWare
|
||||
{
|
||||
module.ComfirmErrInstore(TcpCleint);
|
||||
WarningLight.WaringLightBlueEnd(TcpCleint);
|
||||
//TO DO Logs.Write($"[{guid}]该位置已放置物料!");
|
||||
Logs.Write($"{storeInfo.StoreCode}该位置已放置物料!", LogsType.Instore);
|
||||
return;
|
||||
}
|
||||
#endregion
|
||||
@ -1293,7 +1354,7 @@ namespace WCS.BLL.HardWare
|
||||
MatSupplier = this.InStoreData.supplier,
|
||||
|
||||
InstoreTime = DateTime.Now,
|
||||
InstoreUser = ""
|
||||
InstoreUser = this.InStoreData.InstoreUser,
|
||||
};
|
||||
|
||||
//出入库记录表
|
||||
@ -1367,9 +1428,10 @@ namespace WCS.BLL.HardWare
|
||||
.Where(t => t.ShelfId == ShelfId)
|
||||
.Where(t => t.BoardId == boardId && t.LightNumber == lightNumber)
|
||||
.First();
|
||||
//库位未找到
|
||||
if (storeInfo == null)
|
||||
{
|
||||
//TO DO 库位未找到
|
||||
Logs.Write($"【InStoreExceptionReturnProcess】boardId:{boardId},lightNumber{lightNumber},库位未找到 ", LogsType.Instore);
|
||||
return;
|
||||
}
|
||||
//已放物料丢失了 物料多放了 储位恢复正常
|
||||
@ -1421,6 +1483,8 @@ namespace WCS.BLL.HardWare
|
||||
};
|
||||
WarningManager.SendWarning(warningModel);
|
||||
|
||||
WarningLight.WaringLightAlwaysRed(TcpCleint);
|
||||
|
||||
ProcessingExceptions.Add(new ProcessingExceptionType()
|
||||
{
|
||||
BoardId = boardId,
|
||||
@ -1446,6 +1510,8 @@ namespace WCS.BLL.HardWare
|
||||
};
|
||||
WarningManager.SendWarning(warningModel);
|
||||
|
||||
WarningLight.WaringLightAlwaysRed(TcpCleint);
|
||||
|
||||
ProcessingExceptions.Add(new ProcessingExceptionType()
|
||||
{
|
||||
BoardId = boardId,
|
||||
@ -1651,6 +1717,7 @@ namespace WCS.BLL.HardWare
|
||||
var orderMatDetails = DbHelp.db.Queryable<OutOrderMatDetail>()
|
||||
.Where(t => t.OrderId == CurrentOutOrder.Id)
|
||||
.Where(t => t.MatSN == inventoryDetail.MatSN)
|
||||
.Where(t => t.IsSended == false)
|
||||
.First();
|
||||
|
||||
if (orderMatDetails == null)
|
||||
@ -2030,7 +2097,9 @@ namespace WCS.BLL.HardWare
|
||||
WarningMessage = exceptionMessage,
|
||||
ClientIp = WebSocketIpAddress,
|
||||
};
|
||||
|
||||
WarningManager.SendWarning(warningModel);
|
||||
WarningLight.WaringLightAlwaysRed(TcpCleint);
|
||||
|
||||
ProcessingExceptions.Add(new ProcessingExceptionType()
|
||||
{
|
||||
@ -2055,7 +2124,9 @@ namespace WCS.BLL.HardWare
|
||||
WarningMessage = exceptionMessage,
|
||||
ClientIp = WebSocketIpAddress
|
||||
};
|
||||
|
||||
WarningManager.SendWarning(warningModel);
|
||||
WarningLight.WaringLightAlwaysRed(TcpCleint);
|
||||
|
||||
ProcessingExceptions.Add(new ProcessingExceptionType()
|
||||
{
|
||||
@ -2182,6 +2253,16 @@ namespace WCS.BLL.HardWare
|
||||
|
||||
public void SelfCheckProcess(byte[] data, int boardId, int lightNumber)
|
||||
{
|
||||
var module = this.Modules.Where(t => t.BoardId == boardId).FirstOrDefault();
|
||||
if (module == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
module.IsSelfCheck = false;
|
||||
}
|
||||
|
||||
if (data[TcpCleint.PreFixLength + 3] == 0x01)
|
||||
{
|
||||
//比对结果相同
|
||||
|
@ -75,20 +75,33 @@ namespace WCS.BLL.HardWare
|
||||
/// </summary>
|
||||
public byte[] VoltageSingleData = { 0x17, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
/// <summary>
|
||||
/// 电压偏移值
|
||||
/// 查询电压偏移值
|
||||
/// </summary>
|
||||
public byte[] OffsetSingleData = { 0x18, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
/// <summary>
|
||||
/// 电压标准值
|
||||
/// 查询电压标准值
|
||||
/// </summary>
|
||||
public byte[] StandardSingleData = { 0x19, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
|
||||
/// <summary>
|
||||
/// 标定
|
||||
/// </summary>
|
||||
public byte[] CalibrationData = { 0x0D, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
/// <summary>
|
||||
/// 设置偏移量 01 F4 = 500
|
||||
/// </summary>
|
||||
public byte[] SetOffsetData = { 0x0E, 0x0A, 0x01, 0xF4, 0x00, 0x00, 0x00, 0x00 };
|
||||
|
||||
#endregion
|
||||
public int ModuleId { get; set; }
|
||||
public string ModuleCode { get; set; }
|
||||
public int BoardId { get; set; }
|
||||
public bool IsEnable { get; set; }
|
||||
public Mode CurrentMode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否已发送自检命令
|
||||
/// </summary>
|
||||
public bool IsSelfCheck { get; set; } = false;
|
||||
public List<string> CurrentOutSns { get; set; }
|
||||
public List<string> CurrentStockTakingSns { get; set; }
|
||||
|
||||
@ -197,7 +210,7 @@ namespace WCS.BLL.HardWare
|
||||
/// <param name="tcpClient"></param>
|
||||
public void GoInOutStoreMode(TCPClient tcpClient, List<string> outSns)
|
||||
{
|
||||
Logs.Write($"模组{ModuleCode},本次亮灯物料{string.Join(",",outSns)}", LogsType.Outstore);
|
||||
Logs.Write($"模组{ModuleCode},本次亮灯物料{string.Join(",", outSns)}", LogsType.Outstore);
|
||||
CurrentOutSns = outSns;
|
||||
var storeInfos = DbHelp.db.Queryable<StoreInfo>().Where(t => t.ModuleId == ModuleId)
|
||||
.Where(t => t.BoardId == BoardId)
|
||||
@ -408,5 +421,25 @@ namespace WCS.BLL.HardWare
|
||||
tcpClient.Send(tcpClient.GenerateMessage(BoardId, OffsetSingleData));
|
||||
});
|
||||
}
|
||||
|
||||
public void CalibrationSetOffset(int offSet, TCPClient tcpClient)
|
||||
{
|
||||
var offSetData = BitConverter.GetBytes(unchecked((short)offSet));
|
||||
// 检查是否需要交换字节
|
||||
if (BitConverter.IsLittleEndian)
|
||||
{
|
||||
// 如果是小端序系统,则交换字节
|
||||
byte temp = offSetData[0];
|
||||
offSetData[0] = offSetData[1];
|
||||
offSetData[1] = temp;
|
||||
}
|
||||
|
||||
SetOffsetData[2] = offSetData[0];
|
||||
SetOffsetData[3] = offSetData[1];
|
||||
|
||||
tcpClient.Send(tcpClient.GenerateMessage(BoardId, CalibrationData));
|
||||
Thread.Sleep(100);
|
||||
tcpClient.Send(tcpClient.GenerateMessage(BoardId, SetOffsetData));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user