|
|
|
@ -32,9 +32,9 @@ namespace Aucma.Core.Palletiz.Business
|
|
|
|
|
|
|
|
|
|
#region 初始化对象
|
|
|
|
|
private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(InstoreBusiness));
|
|
|
|
|
private readonly IBaseSpaceInfoServices? _baseSpaceInfoServices;
|
|
|
|
|
private readonly ICodeBindingRecordServices? _codeBindingServices;
|
|
|
|
|
private readonly IRecordInStoreServices? _recordInstoreServices;
|
|
|
|
|
private readonly IBaseSpaceInfoServices _baseSpaceInfoServices;
|
|
|
|
|
private readonly ICodeBindingRecordServices _codeBindingServices;
|
|
|
|
|
private readonly IRecordInStoreServices _recordInstoreServices;
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 构造函数
|
|
|
|
@ -130,7 +130,7 @@ namespace Aucma.Core.Palletiz.Business
|
|
|
|
|
Console.WriteLine($"上位机获取配置的扫码器【IP:{model.ToJson()}》名称:{model.Name}】");
|
|
|
|
|
LogInStoreInfoDelegateEvent?.Invoke($"上位机获取配置的扫码器【IP:{model.ToJson()}》名称:{model.Name}】","White");
|
|
|
|
|
//1.根据成品码找货道
|
|
|
|
|
List<BaseSpaceInfo>? spaceList = GetSpaceBySNCode(SNCode, recordInstore);
|
|
|
|
|
List<BaseSpaceInfo> spaceList = GetSpaceBySNCode(SNCode, recordInstore);
|
|
|
|
|
Console.WriteLine($"上位机获取配置的货道数量【{spaceList.Count}】");
|
|
|
|
|
|
|
|
|
|
// 根据货道信息判断下发plc信号
|
|
|
|
@ -153,7 +153,7 @@ namespace Aucma.Core.Palletiz.Business
|
|
|
|
|
{
|
|
|
|
|
spaceNumList.Add(int.Parse(finalSpace.SpaceCode.Substring(5, 3)));
|
|
|
|
|
spaceNumList.Add(int.Parse(GetOtherSpace(finalSpace, spaceList).SpaceCode.Substring(5, 3)));
|
|
|
|
|
plcResult = SendAndAnswerPlc(scannerIp, spaceList[0].RotationRange, spaceNumList);
|
|
|
|
|
plcResult = SendAndAnswerPlc(scannerIp, spaceList[0].RotationRange, 1);
|
|
|
|
|
recordInstore.SpaceCode = finalSpace.SpaceCode;
|
|
|
|
|
recordInstore.StoreCode = finalSpace.StoreCode;
|
|
|
|
|
// 更新货道信息,大产品last存objId大的,储存上一个货道的主键 如货道7,8存8
|
|
|
|
@ -173,7 +173,7 @@ namespace Aucma.Core.Palletiz.Business
|
|
|
|
|
{
|
|
|
|
|
spaceNumList.Add(int.Parse(finalSpace.SpaceCode.Substring(5, 3)));
|
|
|
|
|
spaceNumList.Add(0);
|
|
|
|
|
plcResult = SendAndAnswerPlc(scannerIp, finalSpace.RotationRange, spaceNumList);
|
|
|
|
|
plcResult = SendAndAnswerPlc(scannerIp, finalSpace.RotationRange, 1);
|
|
|
|
|
UpdateSapceList(finalSpace.ObjId, spaceList);
|
|
|
|
|
Console.WriteLine("更新货道信息成功!");
|
|
|
|
|
LogInStoreInfoDelegateEvent?.Invoke("更新货道信息成功!", "White");
|
|
|
|
@ -182,7 +182,7 @@ namespace Aucma.Core.Palletiz.Business
|
|
|
|
|
{
|
|
|
|
|
spaceNumList.Add(0);
|
|
|
|
|
spaceNumList.Add(int.Parse(finalSpace.SpaceCode.Substring(5, 3)));
|
|
|
|
|
plcResult = SendAndAnswerPlc(scannerIp, finalSpace.RotationRange, spaceNumList);//给PLC下传入库信号
|
|
|
|
|
plcResult = SendAndAnswerPlc(scannerIp, finalSpace.RotationRange, 1);//给PLC下传入库信号
|
|
|
|
|
UpdateSapceList(finalSpace.ObjId, spaceList);
|
|
|
|
|
Console.WriteLine("更新货道信息成功!");
|
|
|
|
|
LogInStoreInfoDelegateEvent?.Invoke("更新货道信息成功!", "White");
|
|
|
|
@ -224,7 +224,7 @@ namespace Aucma.Core.Palletiz.Business
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="SNCode"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private List<BaseSpaceInfo>? GetSpaceBySNCode(string SNCode, RecordInStore recordInstore)
|
|
|
|
|
private List<BaseSpaceInfo> GetSpaceBySNCode(string SNCode, RecordInStore recordInstore)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
@ -356,7 +356,7 @@ namespace Aucma.Core.Palletiz.Business
|
|
|
|
|
/// <param name="range">转向角度</param>
|
|
|
|
|
/// <param name="spaceNum">货道号int集合</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private bool SendAndAnswerPlc(string scannerIp, int range, List<int> spaceNum)
|
|
|
|
|
private bool SendAndAnswerPlc(string scannerIp, int range,int spaceNum)
|
|
|
|
|
{
|
|
|
|
|
bool result = false;
|
|
|
|
|
try
|
|
|
|
@ -391,10 +391,10 @@ namespace Aucma.Core.Palletiz.Business
|
|
|
|
|
/// 下发plc信号
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="obj"></param>
|
|
|
|
|
/// <param name="range"></param>
|
|
|
|
|
/// <param name="spaceNum"></param>
|
|
|
|
|
/// <param name="range">转向</param>
|
|
|
|
|
/// <param name="spaceNum">库数量</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private bool SendPlc(PlcModel obj, int range, List<int> spaceNum)
|
|
|
|
|
private bool SendPlc(PlcModel obj, int range,int spaceNum)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
@ -403,24 +403,22 @@ namespace Aucma.Core.Palletiz.Business
|
|
|
|
|
DateTime targetTime = DateTime.Now.AddSeconds(8);
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
if (DateTime.Now > targetTime) // plc超最大时限无反馈
|
|
|
|
|
Console.WriteLine($"是否可以下发:【{obj.plc.ReadBool("D1000")}】");
|
|
|
|
|
if (obj.plc.ReadBool("D1000"))//如果为true 则可以下发 任务
|
|
|
|
|
{
|
|
|
|
|
logHelper.Error("等待plc放行反馈信号超时");
|
|
|
|
|
Console.WriteLine("等待plc放行反馈信号超时");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
// 应答字允许下发
|
|
|
|
|
Console.WriteLine($"读取应答字是否下传成功!【{obj.plc.ReadInt32("D102")}】");
|
|
|
|
|
if (obj.plc.ReadInt32("D102") == 1)
|
|
|
|
|
{
|
|
|
|
|
//obj.plc.WriteInt32("D110", range);//旋转角度暂时不赋值由PLC转向
|
|
|
|
|
|
|
|
|
|
obj.plc.WriteInt32("D112", spaceNum[0]); //货道号
|
|
|
|
|
obj.plc.WriteInt32("D114", spaceNum[1]); //货道号
|
|
|
|
|
Console.WriteLine($"plc信号货道信号下发成功!【D112:{spaceNum[0]}】D114:{spaceNum[1]}");
|
|
|
|
|
result = true;
|
|
|
|
|
break;
|
|
|
|
|
// 应答字允许下发
|
|
|
|
|
int storeNum = GetStoreNum(obj, spaceNum);
|
|
|
|
|
Console.WriteLine($"读取当前货道数量:【{storeNum}】");
|
|
|
|
|
if (storeNum == 1)
|
|
|
|
|
{
|
|
|
|
|
obj.plc.WriteInt32("D7010", range);//旋转角度1=》90 2=>反转90 D2 1正转 2反转
|
|
|
|
|
obj.plc.WriteInt32("D29", spaceNum); //货道号
|
|
|
|
|
Console.WriteLine($"plc信号货道信号下发成功!【货道号:{spaceNum}");
|
|
|
|
|
result = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Thread.Sleep(500);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
@ -432,6 +430,58 @@ namespace Aucma.Core.Palletiz.Business
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int GetStoreNum(PlcModel obj, int spaceNum)
|
|
|
|
|
{
|
|
|
|
|
int storeNum = 0;
|
|
|
|
|
switch (spaceNum)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
storeNum = obj.plc.ReadInt16("D1001");
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
storeNum = obj.plc.ReadInt16("D1002");
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
storeNum = obj.plc.ReadInt16("D1003");
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
storeNum = obj.plc.ReadInt16("D1004");
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
storeNum = obj.plc.ReadInt16("D1005");
|
|
|
|
|
break;
|
|
|
|
|
case 6:
|
|
|
|
|
storeNum = obj.plc.ReadInt16("D1006");
|
|
|
|
|
break;
|
|
|
|
|
case 7:
|
|
|
|
|
storeNum = obj.plc.ReadInt16("D1007");
|
|
|
|
|
break;
|
|
|
|
|
case 8:
|
|
|
|
|
storeNum = obj.plc.ReadInt16("D1008");
|
|
|
|
|
break;
|
|
|
|
|
case 9:
|
|
|
|
|
storeNum = obj.plc.ReadInt16("D1009");
|
|
|
|
|
break;
|
|
|
|
|
case 10:
|
|
|
|
|
storeNum = obj.plc.ReadInt16("D1010");
|
|
|
|
|
break;
|
|
|
|
|
case 11:
|
|
|
|
|
storeNum = obj.plc.ReadInt16("D1011");
|
|
|
|
|
break;
|
|
|
|
|
case 12:
|
|
|
|
|
storeNum = obj.plc.ReadInt16("D1012");
|
|
|
|
|
break;
|
|
|
|
|
case 13:
|
|
|
|
|
storeNum = obj.plc.ReadInt16("D1013");
|
|
|
|
|
break;
|
|
|
|
|
case 14:
|
|
|
|
|
storeNum = obj.plc.ReadInt16("D1014");
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return storeNum;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 等待plc信号反馈
|
|
|
|
|