Commit 346d986b LN

1

1 个父辈 2c170ea6
......@@ -77,7 +77,7 @@ namespace OnlineStore.Common
public static MyConfig<int> CameraScan_QRCodeCount = 3;
[MyConfigComment("二维码扫码超时毫秒")]
public static MyConfig<int> CameraScan_CodeTimeOut = 3000;
public static MyConfig<bool> R_IsPutReel;
public static MyConfig<string> R_WareCode;
......
......@@ -185,16 +185,15 @@ namespace DeviceLibrary
}
}
[HandleProcessCorruptedStateExceptions]
public static List<CodeInfo> CameraScan(List<string> cameraNameList)
{
{
HashSet<string> codestr = new HashSet<string>();
List<CodeInfo> codeList = new List<CodeInfo>();
string bitmapfilename = "";
if (cameraNameList == null || cameraNameList.Count <= 0)
{
return codeList;
throw new Exception("CameraScan方法没有传入相机名称.");
}
......@@ -213,8 +212,8 @@ namespace DeviceLibrary
if (cameraName.Trim().Equals(""))
{
return;
}
DateTime startTime = DateTime.Now;
}
DateTime startTime = DateTime.Now;
HalconDotNet.HObject ho_Image = null;
Bitmap bmp = null;
try
......@@ -228,7 +227,7 @@ namespace DeviceLibrary
retrytime++;
CloseCamera(cameraName);
LogUtil.info($"bitmap为空重试第{retrytime}次");
Task.Delay(1500).Wait();
Task.Delay(1500).Wait();
goto retry;
}
//HalconDotNet.HOperatorSet.RotateImage()
......@@ -238,7 +237,7 @@ namespace DeviceLibrary
CloseCamera(cameraName);
return;
}
if (idx==0)
if (idx == 0)
camera_event?.Invoke(null, bmp);
LogUtil.info(" 【" + cameraName + "】取图片完成,开始扫码");
string r = "";
......@@ -294,29 +293,37 @@ namespace DeviceLibrary
}
}));
Task.Delay(ii * 700).Wait();
Task.Delay(500).Wait();
}
while (!cameraTask[0].IsCompleted )
bool isfinish = false;
while (!isfinish)
{
Application.DoEvents();
Thread.Sleep(100);
isfinish = true;
for (int i = 0; i < cameraTask.Count(); i++)
{
if (!cameraTask[i].IsCompleted)
{
isfinish = false;
Application.DoEvents();
Thread.Sleep(100);
}
}
}
}
catch (AccessViolationException e)
{
LogUtil.error( " 扫码出现AccessViolationException异常:" + e.ToString());
LogUtil.error(" 扫码出现AccessViolationException异常:" + e.ToString());
//throw new Exception("扫码出现AccessViolationException异常");
// GC.Collect();
}
catch (Exception ex)
{
LogUtil.error( " 扫码出错:" + ex.ToString());
LogUtil.error(" 扫码出错:" + ex.ToString());
//throw new Exception("扫码出错");
}
return codeList;
}
/// <summary>
///
/// </summary>
......
......@@ -244,8 +244,8 @@ namespace DeviceLibrary
return tray;
}
tray = JsonHelper.DeserializeJsonToObject<TrayInfo>(data.data.ToString());
string dataStr = JsonHelper.SerializeObject(data.data);
tray = JsonHelper.DeserializeJsonToObject<TrayInfo>(dataStr);
if (tray == null || tray.rfid == "" || tray.rfidLoc == 0)
{
//msg = "获取位置失败";
......
......@@ -26,7 +26,8 @@ public class ReelParam
TargetOutShelf = posArray[0];
if (TargetOutShelf != "NG")
{
TargetLoc = posArray[1];
//取最后一位
TargetLoc = posArray[posArray.Length-1];
}
}
}
......
......@@ -738,11 +738,13 @@ namespace DeviceLibrary
ACStorePosition position = CSVPositionReader<ACStorePosition>.GetPositon(pName);
if (position == null)
{
LogUtil.error(Name + " " + tray.ToStr() + " 找到匹配料架,但未找到库位号:" + pName + ",查找库位号:" + targetPosName);
//判断库位号是否存在
position = CSVPositionReader<ACStorePosition>.GetPositon(targetPosName);
if (position == null)
{
LogUtil.error(Name + " " + tray.ToStr() + " 找到匹配料架,但未找到库位号:" + position);
LogUtil.error(Name + " " + tray.ToStr() + " 找到匹配料架,但未找到库位号:" + targetPosName);
WarnMsg = tray.barcode + "未找到库位号:" + position;
targetPosName = "";
break;
......@@ -750,8 +752,16 @@ namespace DeviceLibrary
}
targetPosName = position.PositionNum;
LogUtil.info(Name + " " + tray.ToStr() + " 使用料架:" + targetPosName + ",更改料架为忙碌状态,开始放料");
obj.StartPutReel();
bool result = obj.StartPutReel();
if (result)
{
LogUtil.info(Name + " " + tray.ToStr() + " 使用料架:" + targetPosName + ",更改料架为忙碌状态,开始放料 成功");
return targetPosName;
}
else
{
LogUtil.info(Name + " " + tray.ToStr() + " 使用料架:" + targetPosName + ",更改料架为忙碌状态,开始放料 失败");
}
break;
}
}
......
......@@ -161,7 +161,7 @@ namespace DeviceLibrary
else
{
OutShelfBean bean = getOutShelf(StoreMoveInfo.MoveParam.TargetOutShelf);
//通知服务器放料完成
ShelfTaskInfo taskInfo = HttpServer.ShelfFinish(bean.CurrShelf.realRFID, StoreMoveInfo.MoveParam.WareCode, StoreMoveInfo.MoveParam.TargetLoc);
bean.PutReelOk(taskInfo);
......
......@@ -170,7 +170,8 @@ namespace DeviceLibrary
if (ShelfReady())
{
MoveInfo.NextMoveStep(MoveStep.S11_PutReel);
MoveInfo.log("开始放料");
MoveInfo.log("开始放料 ,设置 CurrShelf.IsBusy = true");
CurrShelf.IsBusy = true;
return true;
}
return false;
......@@ -178,29 +179,31 @@ namespace DeviceLibrary
public void PutReelOk(ShelfTaskInfo taskInfo)
{
if (ShelfReady())
//if (ShelfReady())
//{
if (MoveInfo.MoveStep.Equals(MoveStep.S11_PutReel))
{
if (MoveInfo.MoveStep.Equals(MoveStep.S11_PutReel))
{
if (taskInfo.IsValid())
CurrShelf.IsBusy = false;
//TODO 暂不判断是否返回成功
//if (taskInfo.IsValid())
{
if (taskInfo.smallEmpty == 0 && taskInfo.bigEmpty == 0)
{
if (taskInfo.smallEmpty == 0 && taskInfo.bigEmpty == 0)
{
//MoveInfo.NextMoveStep(MoveStep.S10_ShelfReady);
//CurrShelf.IsNeedLeave = true;
//当前工单任务已完成,直接送料架离开
MoveInfo.log("放料完成,当前工单任务已完成,剩余空位=0,料架需要离开:" + taskInfo.ToStr());
S21_ShelfNeedLeave("剩余空位=0");
}
else
{
MoveInfo.NextMoveStep(MoveStep.S10_ShelfReady);
MoveInfo.log("放料完成,料架还有空位,准备放料完成");
}
//MoveInfo.NextMoveStep(MoveStep.S10_ShelfReady);
//CurrShelf.IsNeedLeave = true;
//当前工单任务已完成,直接送料架离开
MoveInfo.log("放料完成 ,设置CurrShelf.IsBusy = false,当前工单任务已完成,剩余空位=0,料架需要离开:" + taskInfo.ToStr());
S21_ShelfNeedLeave("剩余空位=0");
}
else
{
MoveInfo.NextMoveStep(MoveStep.S10_ShelfReady);
MoveInfo.log("放料完成,设置CurrShelf.IsBusy = false,料架还有空位,准备放料完成");
}
}
//}
}
}
......
using ConfigHelper;
using DeviceLibrary;
using log4net.Config;
//using Microsoft.Win32.TaskScheduler;
using OnlineStore.Common;
......@@ -23,7 +24,8 @@ namespace TheMachine
[STAThread]
static void Main()
{
//string resultStr = "{\"code\":0,\"data\":{\"w\":7,\"realRfid\":\"\",\"h\":12,\"rfid\":\"1-1F\",\"usedRfidList\":\"\",\"rfidLoc\":2,\"barcode\":\"34005600000807\"},\"msg\":\"ok\",\"msgKey\":\"smfcore.ok\",\"okResult\":true,\"params\":[]}";
// ResultData data = JsonHelper.DeserializeJsonToObject<ResultData>(resultStr);
_ = new Mutex(true, Application.ProductName, out bool ret);
if (!ret)
{
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!