diff --git a/.vs/HighWayIot/FileContentIndex/1908475a-6cd8-4b3f-902e-143be43b2f61.vsidx b/.vs/HighWayIot/FileContentIndex/1908475a-6cd8-4b3f-902e-143be43b2f61.vsidx
new file mode 100644
index 00000000..3cbe3d1c
Binary files /dev/null and b/.vs/HighWayIot/FileContentIndex/1908475a-6cd8-4b3f-902e-143be43b2f61.vsidx differ
diff --git a/.vs/HighWayIot/FileContentIndex/67c94427-ab2b-4412-98b6-a0e695f2ad6e.vsidx b/.vs/HighWayIot/FileContentIndex/67c94427-ab2b-4412-98b6-a0e695f2ad6e.vsidx
new file mode 100644
index 00000000..000d10fd
Binary files /dev/null and b/.vs/HighWayIot/FileContentIndex/67c94427-ab2b-4412-98b6-a0e695f2ad6e.vsidx differ
diff --git a/.vs/HighWayIot/FileContentIndex/fd5383d1-b774-4d1d-8d24-2a29cdcf4783.vsidx b/.vs/HighWayIot/FileContentIndex/8cada85f-6b77-4880-8437-b0e056c5b368.vsidx
similarity index 66%
rename from .vs/HighWayIot/FileContentIndex/fd5383d1-b774-4d1d-8d24-2a29cdcf4783.vsidx
rename to .vs/HighWayIot/FileContentIndex/8cada85f-6b77-4880-8437-b0e056c5b368.vsidx
index 7d546efb..eda0c4f5 100644
Binary files a/.vs/HighWayIot/FileContentIndex/fd5383d1-b774-4d1d-8d24-2a29cdcf4783.vsidx and b/.vs/HighWayIot/FileContentIndex/8cada85f-6b77-4880-8437-b0e056c5b368.vsidx differ
diff --git a/.vs/HighWayIot/FileContentIndex/a89fc347-e1ca-4ab6-9e64-fb705e97c5f0.vsidx b/.vs/HighWayIot/FileContentIndex/a89fc347-e1ca-4ab6-9e64-fb705e97c5f0.vsidx
new file mode 100644
index 00000000..ddcc1c07
Binary files /dev/null and b/.vs/HighWayIot/FileContentIndex/a89fc347-e1ca-4ab6-9e64-fb705e97c5f0.vsidx differ
diff --git a/.vs/HighWayIot/v17/.suo b/.vs/HighWayIot/v17/.suo
index 203e6ef9..734ddbc5 100644
Binary files a/.vs/HighWayIot/v17/.suo and b/.vs/HighWayIot/v17/.suo differ
diff --git a/Aucma.Scada.Business/AssemblyPlanBusiness.cs b/Aucma.Scada.Business/AssemblyPlanBusiness.cs
index c70f676c..06cc21d2 100644
--- a/Aucma.Scada.Business/AssemblyPlanBusiness.cs
+++ b/Aucma.Scada.Business/AssemblyPlanBusiness.cs
@@ -5,6 +5,7 @@ using HighWayIot.Repository.service;
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Windows.Forms;
namespace Aucma.Scada.Business
{
@@ -31,6 +32,8 @@ namespace Aucma.Scada.Business
private AppConfig appConfig = AppConfig.Instance;
private RegisterServices registerServices = RegisterServices.Instance;
+
+
#endregion
#region 接口引用
@@ -59,6 +62,21 @@ namespace Aucma.Scada.Business
///
public delegate void NextPassExecutePlanInfo(ExecutePlanInfo planInfo,BaseSpaceInfo spaceInfo = null);
public event NextPassExecutePlanInfo NextPassExecutePlanInfoEvent;
+
+ ///
+ /// 弹框提示
+ ///
+ ///
+ public delegate void PrintMessage(string log);
+ public event PrintMessage PrintMessageEvent;
+
+ ///
+ /// 找出库货道
+ ///
+ ///
+ public delegate BaseSpaceInfo GetSpaceInfoByMaterialType(string storeCode, string materialType);
+ public event GetSpaceInfoByMaterialType GetSpaceInfoByMaterialTypeEvent;
+
#endregion
private AssemblyPlanBusiness()
@@ -129,6 +147,7 @@ namespace Aucma.Scada.Business
var productPlanInfo = _productPlanInfoService.GetProductPlanByPlanCode(productPlanCode);
if (productPlanInfo != null)
{
+
ExecutePlanInfo executePlanInfo = new ExecutePlanInfo();
executePlanInfo.executePlanCode = System.Guid.NewGuid().ToString("N");
executePlanInfo.productPlanCode = productPlanInfo.planCode;
@@ -137,8 +156,28 @@ namespace Aucma.Scada.Business
executePlanInfo.materialCode = productPlanInfo.materialCode;
executePlanInfo.materialName = productPlanInfo.materialName;
executePlanInfo.executeOrder = _executePlanInfoService.GetExecuteOrderByProductLineCode(appConfig.stationCode);
+
+ if (spaceInfo == null)
+ {//下总装计划 筛选货道
+ spaceInfo = GetSpaceInfoByMaterialTypeEvent?.Invoke(appConfig.foamStoreCode, executePlanInfo.materialCode);
+ if(transmitAmount > spaceInfo.spaceStock)
+ {
+ //弹框提示
+ PrintMessageEvent?.Invoke($"收到出库计划数:{transmitAmount},匹配到货道:{spaceInfo.spaceCode},库存数:{spaceInfo.spaceStock},已自动将计划数改为库存!");
+ executePlanInfo.planAmount = spaceInfo.spaceStock;
+ }
+ else
+ {
+ executePlanInfo.planAmount = transmitAmount;
+ }
+
+ }
+ else // 手动出一个或者整道出
+ {
+ executePlanInfo.planAmount = transmitAmount;
+ }
executePlanInfo.executeStatus = 1;
- executePlanInfo.planAmount = transmitAmount;
+
executePlanInfo.createdTime = DateTime.Now;
result = _executePlanInfoService.InsertExecutePlanInfo(executePlanInfo);
diff --git a/Aucma.Scada.Business/InStoreBusiness.cs b/Aucma.Scada.Business/InStoreBusiness.cs
index af22ac43..191351be 100644
--- a/Aucma.Scada.Business/InStoreBusiness.cs
+++ b/Aucma.Scada.Business/InStoreBusiness.cs
@@ -113,10 +113,11 @@ namespace Aucma.Scada.Business
_baseBomInfoService = registerServices.GetService();
_recordInStoreService = registerServices.GetService();
_printBarCodeServices = registerServices.GetService();
+ _iMaterialCompletionServices = registerServices.GetService();
_productPlanInfoServices = registerServices.GetService();
taskHandle.InStoreFinsihEvent += InStoreFinish;
taskHandle.InStoreAnswerEvent += InStoreAnswer;
-
+ taskHandle.InStoreFinsihBySpaceCodeEvent += InStoreAllBySpaceCode;
MvCodeHelper.RefreshMaterialCodeStrEvent += InStore;
MvCodeHelper.RefreshLogMessageEvent += PrintLogInfoMessage;
MvCodeHelper.MessageNoReadEvent += MessageNoRead;
@@ -184,12 +185,12 @@ namespace Aucma.Scada.Business
}
#endregion
-
+
///
/// 入库
///
///
- private void InStore(string materialCode)
+ public void InStore(string materialCode)
{
try
{
@@ -210,24 +211,12 @@ namespace Aucma.Scada.Business
PrintLogInfoMessage($"匹配货道:{spaceInfo.spaceName}");
spaceInfo.materialType = materialType;
spaceInfo.typeNameA = GetMaterialName(materialType);
+ // 入库禁止出库
+ spaceInfo.outStoreFlag = 2;
RefreshScanMateriaCodeEvent?.Invoke(materialCode, GetMaterialName(materialType), spaceInfo.spaceName, appConfig.foamStoreCode); //刷新界面扫码信息
var result = CreateInStoreTask(spaceInfo, materialCode); //创建入库任务
if (result)
- {
- #region delete/20240105/正式生产启用 更新过点数据,插入记录到MATERIAL_COMPLETION表
- //PrintBarCode print = _printBarCodeServices.query(materialCode);
- //string planCode = _productPlanInfoServices.GetPlanCode(print.OrderCode, appConfig.stationCode);
- //MaterialCompletion completion = new MaterialCompletion();
- //completion.OrderCode = print.OrderCode;
- //completion.MaterialBarcode = materialCode;
- //completion.MaterialCode = print.MaterialCode;
- //completion.MaterialName = print.MaterialName;
- //completion.StationName = appConfig.stationCode;
- //completion.CompleteDate = DateTime.Now;
- //completion.planCode = planCode;
- //_iMaterialCompletionServices.Add(completion);
- #endregion
-
+ {
_spaceInfoService.UpdateSpaceInfo(spaceInfo);
}
}
@@ -246,6 +235,17 @@ namespace Aucma.Scada.Business
}
}
+ ///
+ /// 根据指定货道异常入库
+ ///
+ public void ExceptionInstore(string spaceCode)
+ {
+ BaseSpaceInfo space = _spaceInfoService.GetSpaceInfoBySpaceCode(appConfig.foamStoreCode,spaceCode);
+ if(space != null)
+ {
+ CreateInStoreTask(space, "");
+ }
+ }
///
/// 创建入库任务
///
@@ -317,15 +317,7 @@ namespace Aucma.Scada.Business
///
private void PassDownFoamTask()
{
- #region 出库不需要堵塞整个库
- ////出库时堵塞入库,这个地方如果有问题的话,改为操作StartPassDown,将_isBlocked初始值true给while,开始出库时设成false结束while,出库完成后改为ture重新调用StartPassDown
- //if (_isBlocked)
- //{
- // PrintLogInfoMessage("正在出库,当前入库状态堵塞,出库完成后进行释放");
- // _autoResetEvent.WaitOne();
- //}
- #endregion
-
+
try
{
RealTaskInfo taskInfo = _taskInfoService.GetTaskInfoByStoreCode(appConfig.foamStoreCode, 1);
@@ -403,63 +395,90 @@ namespace Aucma.Scada.Business
//}
#endregion
-
+ ///
+ /// 在途为0后,根据货道完成该货道所有入库任务
+ ///
+ ///
+ public void InStoreAllBySpaceCode(string spaceCode)
+ {
+ try
+ {
+ List list = _taskInfoService.GetAllInstoreTaskByStoreCode(appConfig.foamStoreCode, spaceCode, 1, 2);
+ if (list != null && list.Count > 0)
+ {
+ foreach (RealTaskInfo task in list)
+ {
+ InStoreFinish(task.taskCode);
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ logHelper.Info("InStoreAllBySpaceCode异常:"+ex.Message.ToString());
+ }
+ }
+
///
/// 入库完成
///
///
///
///
- private void InStoreFinish(string taskCode)
+ public void InStoreFinish(string taskCode)
{
try
{
var taskInfo = _taskInfoService.GetTaskInfoByTaskCode(taskCode, appConfig.foamStoreCode);
if (taskInfo != null)
{
- var spaceInfo = _spaceInfoService.GetSpaceInfoBySpaceCode(taskInfo.storeCode, taskInfo.spaceCode);
-
- if (spaceInfo != null)
+ #region 添加入库记录
+ RecordInstore recordInstore = new RecordInstore();
+ recordInstore.storeCode = taskInfo.storeCode;
+ recordInstore.spaceCode = taskInfo.spaceCode;
+ recordInstore.materialCode = taskInfo.materialCode;
+ recordInstore.materialType = taskInfo.materialType;
+ recordInstore.materialName = GetMaterialName(taskInfo.materialType);
+ recordInstore.inStoreAmount = 1;
+ recordInstore.inStoreTime = DateTime.Now;
+ recordInstore.barcodeCode = taskInfo.materialCode;
+ _recordInStoreService.InsertRecordInStore(recordInstore);
+ #endregion
+
+
+ #region 更新过点数据,插入记录到MATERIAL_COMPLETION表
+ if (!string.IsNullOrEmpty(taskInfo.materialCode))
{
-
- spaceInfo.materialType = taskInfo.materialType;
- //spaceInfo.spaceStock = spaceInfo.spaceStock + 1;
- //spaceInfo.onRouteAmount -= 1;
-
- //读取PLC获取货道信息:存放数量、在途数量,
- #region Add By wenjy 2023-10-30 13:44:00 通过PLC获取货道信息
- var item = taskHandle.ReadSpaceInfoByPlc(spaceInfo);
- spaceInfo.spaceStock = item.spaceStock;
- spaceInfo.onRouteAmount = item.onRouteAmount;
- spaceInfo.spaceStatus = item.spaceStatus;
- #endregion
-
- _spaceInfoService.UpdateSpaceInfo(spaceInfo);
- #region 添加货道明细
- BaseSpaceDetail spaceDetail = new BaseSpaceDetail();
- spaceDetail.materialType = taskInfo.materialType;
- spaceDetail.materialCode = taskInfo.materialCode;
- spaceDetail.materialName = GetMaterialName(taskInfo.materialType);
- spaceDetail.storeCode = spaceInfo.storeCode;
- spaceDetail.spaceCode = spaceInfo.spaceCode;
- spaceDetail.materialAmount = 1;
- _baseSpaceDetailService.InsertSpaceDetail(spaceDetail);
- #endregion
-
- #region 添加入库记录
- RecordInstore recordInstore = new RecordInstore();
- recordInstore.storeCode = taskInfo.storeCode;
- recordInstore.spaceCode = taskInfo.spaceCode;
- recordInstore.materialCode = taskInfo.materialCode;
- recordInstore.materialType = taskInfo.materialType;
- recordInstore.materialName = GetMaterialName(taskInfo.materialType);
- recordInstore.inStoreAmount = 1;
- recordInstore.inStoreTime = DateTime.Now;
- recordInstore.barcodeCode = taskInfo.materialCode;
- _recordInStoreService.InsertRecordInStore(recordInstore);
- #endregion
-
+ PrintBarCode print = _printBarCodeServices.query(taskInfo.materialCode);
+ if (print != null)
+ {
+ string planCode = _productPlanInfoServices.GetPlanCode(print.OrderCode, appConfig.stationCode);
+ MaterialCompletion completion = new MaterialCompletion();
+ completion.OrderCode = print.OrderCode;
+ completion.MaterialBarcode = taskInfo.materialCode;
+ completion.MaterialCode = print.MaterialCode;
+ completion.MaterialName = print.MaterialName;
+ completion.StationName = appConfig.stationCode;
+ completion.CompleteDate = DateTime.Now;
+ completion.planCode = planCode;
+ _iMaterialCompletionServices.Add(completion);
+ }
}
+ #endregion
+
+
+ #region 添加货道明细,取消记录库存明细
+ BaseSpaceDetail spaceDetail = new BaseSpaceDetail();
+ spaceDetail.materialType = taskInfo.materialType;
+ spaceDetail.materialCode = taskInfo.materialCode;
+ spaceDetail.materialName = GetMaterialName(taskInfo.materialType);
+ spaceDetail.storeCode = appConfig.foamStoreCode;
+ spaceDetail.spaceCode = taskInfo.spaceCode;
+ spaceDetail.materialAmount = 1;
+ spaceDetail.createTime = DateTime.Now;
+ _baseSpaceDetailService.InsertSpaceDetail(spaceDetail);
+ #endregion
+
+
//清除任务信息
_taskInfoService.DeleteTaskInfo(taskCode, appConfig.foamStoreCode);
}
@@ -593,7 +612,10 @@ namespace Aucma.Scada.Business
}
var list = info.Where(x => x.spaceStatus == 1 && x.spaceStock > 0 ? x.spaceCapacity > (x.spaceStock + x.onRouteAmount) : 1 == 1).ToList();
-
+ if(list==null || list.Count == 0)
+ {
+ list = _spaceInfoService.GetEmptySpaceInfo(appConfig.foamStoreCode);
+ }
if (list.Count > 0)
{
result = list.OrderByDescending(x => x.spaceStock).First();
diff --git a/Aucma.Scada.Business/InStoreTaskHandle.cs b/Aucma.Scada.Business/InStoreTaskHandle.cs
index 7066e38f..7e077d73 100644
--- a/Aucma.Scada.Business/InStoreTaskHandle.cs
+++ b/Aucma.Scada.Business/InStoreTaskHandle.cs
@@ -52,7 +52,7 @@ namespace Aucma.Scada.Business
///
/// 已下传的任务信息
///
- private List foamRearTaskInfos ;
+ private List foamRearTaskInfos;
///
/// 实时任务
@@ -72,7 +72,7 @@ namespace Aucma.Scada.Business
#endregion
#region 委托事件
-
+
///
/// 实时库存刷新
@@ -96,6 +96,14 @@ namespace Aucma.Scada.Business
///
public delegate void InStoreFinsih(string taskCode);
public event InStoreFinsih InStoreFinsihEvent;
+
+ ///
+ /// 在途清0,完成货道任务
+ ///
+ ///
+ public delegate void InStoreFinsihBySpaceCode(string spaceCode);
+ public event InStoreFinsihBySpaceCode InStoreFinsihBySpaceCodeEvent;
+
#endregion
private InStoreTaskHandle()
@@ -113,7 +121,7 @@ namespace Aucma.Scada.Business
// RealReadFinish(); change-入库完成信号改回监测在途数
// test();
}
-
+
///
/// 实时读取plc更新数据库货道数量及在途
@@ -133,8 +141,21 @@ namespace Aucma.Scada.Business
{
int Stock = spaceInfo.spaceStock;
int OnAmount = spaceInfo.onRouteAmount;
-
+
ReadSpaceInfoByPlc(spaceInfo);
+ if (spaceInfo.onRouteAmount == 0)
+ {
+ //自动完成该货道的所有入库任务
+ InStoreFinsihBySpaceCodeEvent?.Invoke(spaceInfo.spaceCode);
+
+ //该货道没有入库任务了,重置货道出库标识,可以再次出库
+ spaceInfo.outStoreFlag = 1;
+ _spaceInfoService.UpdateSpaceInfo(spaceInfo);
+ RefreshFoamStockEvent?.Invoke();
+
+ // 删除多余入库任务
+
+ }
if (spaceInfo.spaceStock == 0 && spaceInfo.onRouteAmount == 0)
{
// 清空型号供新型号使用
@@ -142,6 +163,7 @@ namespace Aucma.Scada.Business
spaceInfo.typeNameA = null;
//重置货道,可以再次入库
spaceInfo.inStoreFlag = 1;
+ spaceInfo.outStoreFlag = 1;
_spaceInfoService.UpdateSpaceInfo(spaceInfo);
RefreshFoamStockEvent?.Invoke();
}
@@ -149,7 +171,7 @@ namespace Aucma.Scada.Business
// 更新库存
if (Stock != spaceInfo.spaceStock || OnAmount != spaceInfo.onRouteAmount)
{
-
+
_spaceInfoService.UpdateSpaceInfo(spaceInfo);
RefreshFoamStockEvent?.Invoke();
@@ -206,7 +228,7 @@ namespace Aucma.Scada.Business
Task.Run(() =>
{
- Thread.Sleep(2000);
+ Thread.Sleep(2000);
while (true)
{
if (_plcDictionary.Count > 0)
@@ -214,7 +236,7 @@ namespace Aucma.Scada.Business
IPlc _plc = _plcDictionary[appConfig.foamStoreCode];
if (_plc != null)
{
-
+
List taskList = _taskInfoService.GetTaskInfosForInstore(appConfig.foamStoreCode, appConfig.instoreTaskType, 2);
if (taskList != null && taskList.Count > 0)
{
@@ -229,7 +251,7 @@ namespace Aucma.Scada.Business
{
logHelper.Info($"PLC信息为空或连接失败,通过{appConfig.foamStoreCode}未获取到该仓库对应的PLC信息");
}
- }
+ }
Thread.Sleep(1000);
};
});
@@ -240,13 +262,13 @@ namespace Aucma.Scada.Business
///
///
///
- public void JudgeIsFinish(RealTaskInfo taskInfo,IPlc _plc,SpaceAddress spaceAddress)
+ public void JudgeIsFinish(RealTaskInfo taskInfo, IPlc _plc, SpaceAddress spaceAddress)
{
// 测试方法,模拟plc,正式启用删除
- // _plc.writeInt32ByAddress(spaceAddress.inStoreFinish, 1);
+ // _plc.writeInt32ByAddress(spaceAddress.inStoreFinish, 1);
//读取入库完成反馈信号
if (_plc.readInt32ByAddress(spaceAddress.inStoreFinish) == 1)
- {
+ {
_plc.writeInt32ByAddress(spaceAddress.inStoreFinish, 0);
InStoreFinsihEvent(taskInfo.taskCode);
}
@@ -275,9 +297,9 @@ namespace Aucma.Scada.Business
///
private void RealReadShellPlcSpace()
{
- if (foamRearTaskInfos != null && foamRearTaskInfos.Count>0)
+ if (foamRearTaskInfos != null && foamRearTaskInfos.Count > 0)
{
-
+
List spaceCodes = foamRearTaskInfos.Select(x => x.spaceCode).Distinct().ToList();
for (int i = 0; i < spaceCodes.Count; i++)
@@ -327,102 +349,102 @@ namespace Aucma.Scada.Business
#region 泡后入库任务下发处理
public int SendFoamTask_InStore(RealTaskInfo taskInfo)
+ {
+ int result = 0;
+ try
{
- int result = 0;
- try
+ IPlc _plc = _plcDictionary[taskInfo.storeCode];
+
+ if (_plc != null)
{
- IPlc _plc = _plcDictionary[taskInfo.storeCode];
- if (_plc != null)
+
+ if (_plc.readInt32ByAddress(plcConfig.in_foam_answer) == 1)
{
-
-
- if (_plc.readInt32ByAddress(plcConfig.in_foam_answer) == 1)
- {
- logHelper.Info("泡后入库应答字为1,货道号:" + plcConfig.in_foam_spaceCode + ";写" + short.Parse(taskInfo.spaceCode.Substring(5, 1)));
- //写入货道号
- _plc.writeInt32ByAddress(plcConfig.in_foam_spaceCode, short.Parse(taskInfo.spaceCode.Substring(5, 1)));
- //写入应答字
- // _plc.writeInt32ByAddress(plcConfig.in_foam_answer, 1);
- //写入任务号
- // _plc.writeStringByAddress(plcConfig.in_foam_task, taskInfo.taskCode);
-
- //写入完成后读取应答字进行复位
- ReadAnswer_InStore(taskInfo);
-
- result = 1;
- }
- else
- {
- result = 2;
- logHelper.Info("应答字为2,下发新任务plc未就绪");
- }
-
-
+ logHelper.Info("泡后入库应答字为1,货道号:" + plcConfig.in_foam_spaceCode + ";写" + short.Parse(taskInfo.spaceCode.Substring(5, 1)));
+ //写入货道号
+ _plc.writeInt32ByAddress(plcConfig.in_foam_spaceCode, short.Parse(taskInfo.spaceCode.Substring(5, 1)));
+ //写入应答字
+ // _plc.writeInt32ByAddress(plcConfig.in_foam_answer, 1);
+ //写入任务号
+ // _plc.writeStringByAddress(plcConfig.in_foam_task, taskInfo.taskCode);
+
+ //写入完成后读取应答字进行复位
+ ReadAnswer_InStore(taskInfo);
+
+ result = 1;
}
else
{
- logHelper.Info($"PLC信息为空,通过{taskInfo.storeCode}未获取到该仓库对应的PLC信息");
+ result = 2;
+ logHelper.Info("应答字为2,下发新任务plc未就绪");
}
+
+
}
- catch (Exception ex)
+ else
{
- logHelper.Error("泡后入库任务下发异常", ex);
+ logHelper.Info($"PLC信息为空,通过{taskInfo.storeCode}未获取到该仓库对应的PLC信息");
}
-
- return result;
}
+ catch (Exception ex)
+ {
+ logHelper.Error("泡后入库任务下发异常", ex);
+ }
+
+ return result;
+ }
- ///
- /// 读取泡后入库应答
- ///
- private void ReadAnswer_InStore(RealTaskInfo taskInfo)
+ ///
+ /// 读取泡后入库应答
+ ///
+ private void ReadAnswer_InStore(RealTaskInfo taskInfo)
+ {
+ lock (string.Empty)
{
- lock (string.Empty)
+ bool isFlag = true;
+ IPlc _plc = _plcDictionary[appConfig.foamStoreCode];
+ try
{
- bool isFlag = true;
- IPlc _plc = _plcDictionary[appConfig.foamStoreCode];
- try
+ Task.Run(() =>
{
- Task.Run(() =>
+ if (_plc != null)
{
- if (_plc != null)
- {
-
- do
- {
- // 测试方法,模拟plc,正式启用删除
- // _plc.writeInt32ByAddress(plcConfig.in_foam_answer, 2);
- //读取PLC应答字为2时,上位机清空写入的入库内容
- if (_plc.readInt32ByAddress(plcConfig.in_foam_answer) == 2)
- {
- logHelper.PlcLog("入库应答字为2,货道号:" + plcConfig.in_foam_spaceCode + ";复位写0");
- //写入货道号
- _plc.writeInt32ByAddress(plcConfig.in_foam_spaceCode, 0);
- //写入应答字
- // _plc.writeInt32ByAddress(plcConfig.in_foam_answer, 0);
-
- isFlag = false;
- foamRearTaskInfos.Add(taskInfo);
- InStoreAnswerEvent?.Invoke(appConfig.foamStoreCode, taskInfo.taskCode);
- }
-
- Thread.Sleep(500);
- } while (isFlag);
-
- }
- else
+
+ do
{
- logHelper.Info($"PLC信息为空,通过{appConfig.foamStoreCode}未获取到该仓库对应的PLC信息");
- }
- });
- }
- catch (Exception ex)
- {
- logHelper.Error("读取泡后入库应答字异常", ex);
- }
+ // 测试方法,模拟plc,正式启用删除
+ // _plc.writeInt32ByAddress(plcConfig.in_foam_answer, 2);
+ //读取PLC应答字为2时,上位机清空写入的入库内容
+ if (_plc.readInt32ByAddress(plcConfig.in_foam_answer) == 2)
+ {
+ logHelper.PlcLog("入库应答字为2,货道号:" + plcConfig.in_foam_spaceCode + ";复位写0");
+ //写入货道号
+ _plc.writeInt32ByAddress(plcConfig.in_foam_spaceCode, 0);
+ //写入应答字
+ // _plc.writeInt32ByAddress(plcConfig.in_foam_answer, 0);
+
+ isFlag = false;
+ foamRearTaskInfos.Add(taskInfo);
+ InStoreAnswerEvent?.Invoke(appConfig.foamStoreCode, taskInfo.taskCode);
+ }
+
+ Thread.Sleep(500);
+ } while (isFlag);
+
+ }
+ else
+ {
+ logHelper.Info($"PLC信息为空,通过{appConfig.foamStoreCode}未获取到该仓库对应的PLC信息");
+ }
+ });
+ }
+ catch (Exception ex)
+ {
+ logHelper.Error("读取泡后入库应答字异常", ex);
}
}
+ }
#endregion
@@ -433,21 +455,21 @@ namespace Aucma.Scada.Business
#region 泡后库plc报警信息
public void SendPlcWarnInfo(short flag)
{
- try
- {
-
- IPlc _plc = _plcDictionary[appConfig.foamStoreCode];
-
- if (_plc != null)
- {
- _plc.writeInt32ByAddress("D7018", flag);
- }
- }
- catch (Exception ex)
- {
- logHelper.Error(ex.Message.ToString());
- }
-
+ try
+ {
+
+ IPlc _plc = _plcDictionary[appConfig.foamStoreCode];
+
+ if (_plc != null)
+ {
+ _plc.writeInt32ByAddress("D7018", flag);
+ }
+ }
+ catch (Exception ex)
+ {
+ logHelper.Error(ex.Message.ToString());
+ }
+
}
#endregion
///
@@ -456,74 +478,73 @@ namespace Aucma.Scada.Business
///
///
public BaseSpaceInfo ReadSpaceInfoByPlc(BaseSpaceInfo spaceInfo)
- {
- var spaceAddress = spaceConfig.GetSpaceAddress(spaceInfo.storeCode, spaceInfo.spaceCode);
- IPlc _plc = _plcDictionary[spaceInfo.storeCode];
+ {
+ var spaceAddress = spaceConfig.GetSpaceAddress(spaceInfo.storeCode, spaceInfo.spaceCode);
+ IPlc _plc = _plcDictionary[spaceInfo.storeCode];
- if (_plc != null)
- {
-
- spaceInfo.spaceStock = _plc.readInt32ByAddress(spaceAddress.onStore);
- spaceInfo.onRouteAmount = _plc.readInt32ByAddress(spaceAddress.onRoute);
- // spaceInfo.spaceStatus = _plc.readInt32ByAddress(spaceAddress.spaceStatus);
-
- }
+ if (_plc != null)
+ {
+ spaceInfo.spaceStock = _plc.readInt32ByAddress(spaceAddress.onStore);
+ spaceInfo.onRouteAmount = _plc.readInt32ByAddress(spaceAddress.onRoute);
+ // spaceInfo.spaceStatus = _plc.readInt32ByAddress(spaceAddress.spaceStatus);
- return spaceInfo;
}
-
- #region 2023-01-04delete 入库逻辑修改,删除引用方法
-
- ///
- /// 读取泡后入库完成
- ///
- //private void ReadShellFinish_InStore(string taskCode)
- //{
- // lock (string.Empty)
- // {
- // bool isFlag = true;
- // IPlc _plc = _plcDictionary[appConfig.foamStoreCode];
- // foamTaskCode = taskCode;
- // try
- // {
- // Task.Run(() =>
- // {
- // if (_plc != null)
- // {
- //
- // do
- // {
- // //读取PLC入库任务完成
- // if (_plc.readInt32ByAddress(plcConfig.in_foam_finish) == 1)
- // {
- // _plc.writeInt32ByAddress(plcConfig.in_foam_finish, 0);
-
- // //string taskCode = _plc.readStringByAddress(plcConfig.out_foam_task, 10);
-
- // InStoreFinsihEvent?.Invoke(taskCode);
-
- // isFlag = false;
- // }
-
- // Thread.Sleep(1000);
- // } while (isFlag);
- //
- // }
- // else
- // {
- // logHelper.Info($"PLC信息为空,通过{appConfig.foamStoreCode}未获取到该仓库对应的PLC信息");
- // }
- // });
- // }
- // catch (Exception ex)
- // {
- // logHelper.Error("读取泡后入库完成异常", ex);
- // }
- // }
- //}
-
- #endregion
+ return spaceInfo;
}
+
+
+ #region 2023-01-04delete 入库逻辑修改,删除引用方法
+
+ ///
+ /// 读取泡后入库完成
+ ///
+ //private void ReadShellFinish_InStore(string taskCode)
+ //{
+ // lock (string.Empty)
+ // {
+ // bool isFlag = true;
+ // IPlc _plc = _plcDictionary[appConfig.foamStoreCode];
+ // foamTaskCode = taskCode;
+ // try
+ // {
+ // Task.Run(() =>
+ // {
+ // if (_plc != null)
+ // {
+ //
+ // do
+ // {
+ // //读取PLC入库任务完成
+ // if (_plc.readInt32ByAddress(plcConfig.in_foam_finish) == 1)
+ // {
+ // _plc.writeInt32ByAddress(plcConfig.in_foam_finish, 0);
+
+ // //string taskCode = _plc.readStringByAddress(plcConfig.out_foam_task, 10);
+
+ // InStoreFinsihEvent?.Invoke(taskCode);
+
+ // isFlag = false;
+ // }
+
+ // Thread.Sleep(1000);
+ // } while (isFlag);
+ //
+ // }
+ // else
+ // {
+ // logHelper.Info($"PLC信息为空,通过{appConfig.foamStoreCode}未获取到该仓库对应的PLC信息");
+ // }
+ // });
+ // }
+ // catch (Exception ex)
+ // {
+ // logHelper.Error("读取泡后入库完成异常", ex);
+ // }
+ // }
+ //}
+
+ #endregion
}
+}
diff --git a/Aucma.Scada.Business/InventoryInfoBusiness.cs b/Aucma.Scada.Business/InventoryInfoBusiness.cs
index 13e6311c..21dd4292 100644
--- a/Aucma.Scada.Business/InventoryInfoBusiness.cs
+++ b/Aucma.Scada.Business/InventoryInfoBusiness.cs
@@ -129,7 +129,7 @@ namespace Aucma.Scada.Business
}
///
- /// 修改异常货道标识
+ /// 设置异常货道标识
///
///
///
@@ -143,7 +143,8 @@ namespace Aucma.Scada.Business
BaseSpaceInfo spaceInfo = _spaceInfoService.GetSpaceInfoBySpaceCode(storeCode, spaceCode);
if (spaceInfo != null)
{
- spaceInfo.unusualFlag = spaceInfo.unusualFlag == 1 ? 2 : 1;
+
+ spaceInfo.unusualFlag = spaceInfo.unusualFlag == 1 ? 2 : 1;
result = _spaceInfoService.UpdateSpaceInfo(spaceInfo);
logHelper.Info($"修改仓库:{storeCode};货道:{spaceCode};异常标识:{spaceInfo.unusualFlag};修改{(result == true ? "成功" : "失败")}");
}
@@ -170,7 +171,7 @@ namespace Aucma.Scada.Business
BaseSpaceInfo spaceInfo = _spaceInfoService.GetSpaceInfoBySpaceCode(storeCode, spaceCode);
if (spaceInfo != null)
{
- spaceInfo.spaceStatus = spaceInfo.spaceStatus == 1 ? 2 : 1;
+ spaceInfo.spaceStatus = spaceInfo.spaceStatus == 1 ? 4 : 1;
result = _spaceInfoService.UpdateSpaceInfo(spaceInfo);
logHelper.Info($"修改仓库:{storeCode};货道:{spaceCode};货道状态:{spaceInfo.unusualFlag};修改{(result == true ? "成功" : "失败")}");
}
diff --git a/Aucma.Scada.Business/MainBusiness.cs b/Aucma.Scada.Business/MainBusiness.cs
index 076d6021..586d64db 100644
--- a/Aucma.Scada.Business/MainBusiness.cs
+++ b/Aucma.Scada.Business/MainBusiness.cs
@@ -53,28 +53,7 @@ namespace Aucma.Scada.Business
plcPool.disConnectAll();
}
- ///
- /// 开启海康扫码器
- ///
- public void InitHikRobot()
- {
- try
- {
- Task.Run(() =>
- {
- Thread.Sleep(2000);
-
- MvCodeHelper.Shell();
- });
-
-
- }
- catch (Exception ex)
- {
-
- Console.WriteLine("InitHikRobotAndGun()开启海康扫码器和扫码枪方法异常" + ex.Message.ToString());
- }
- }
+
///
/// 关闭海康扫码器
diff --git a/Aucma.Scada.Business/OutStoreBusiness.cs b/Aucma.Scada.Business/OutStoreBusiness.cs
index 164c4bd1..cb9258ad 100644
--- a/Aucma.Scada.Business/OutStoreBusiness.cs
+++ b/Aucma.Scada.Business/OutStoreBusiness.cs
@@ -1,4 +1,5 @@
-using Aucma.Scada.Model.domain;
+using Aucma.Core.Scanner;
+using Aucma.Scada.Model.domain;
using HighWayIot.Config;
using HighWayIot.Log4net;
using HighWayIot.Repository.service;
@@ -39,6 +40,7 @@ namespace Aucma.Scada.Business
private OutStoreTaskHandle taskHandleBusiness = OutStoreTaskHandle.Instance;
+
private InStoreBusiness inStoreBusiness = InStoreBusiness.Instance;
#endregion
@@ -70,6 +72,11 @@ namespace Aucma.Scada.Business
private IRecordOutStoreService _recordOutStoreService;
private IRecordProductfinishService _recordProductfinishService;
+
+ private IPrintBarCodeServices _printBarCodeServices;
+
+ // 过点数据表
+ private IMaterialCompletionServices _iMaterialCompletionServices;
#endregion
#region 委托事件
@@ -77,7 +84,7 @@ namespace Aucma.Scada.Business
/// 初始化出库任务
///
///
- public delegate void RefreshOutStoreTask(RealTaskInfo taskInfos);
+ public delegate void RefreshOutStoreTask();
public event RefreshOutStoreTask RefreshOutStoreTaskEvent;
///
@@ -106,6 +113,8 @@ namespace Aucma.Scada.Business
private OutStoreBusiness()
{
+ _iMaterialCompletionServices = registerServices.GetService();
+ _printBarCodeServices = registerServices.GetService();
_spaceInfoService = registerServices.GetService();
_taskInfoService = registerServices.GetService();
_bomInfoService = registerServices.GetService();
@@ -115,12 +124,23 @@ namespace Aucma.Scada.Business
_recordOutStoreService = registerServices.GetService();
_recordProductfinishService = registerServices.GetService();
assemblyPlanBusiness.NextPassExecutePlanInfoEvent += PlanHandle;
+ MvCodeHelper.OutMaterialCodeStrEvent += OutStoreFinishHandle;
+ //assemblyPlanBusiness.PrintLogAndRefreshEvent += PrintLogInfoMessage;
+ assemblyPlanBusiness.GetSpaceInfoByMaterialTypeEvent += GetSpaceInfoByMaterialType;
taskHandleBusiness.OutStoreAnswerEvent += OutStoreAnswer;
- taskHandleBusiness.OutStoreFinsihEvent += OutStoreFinish;
-
+ // taskHandleBusiness.OutStoreFinsihEvent += OutStoreFinish;
+ // test();
StartPassDown();
}
+ public void test()
+ {
+ //var productInfo = _productPlanInfoService.GetProductPlanByPlanCode("2402290019");
+ //productInfo.beginTime = DateTime.Now;
+ //productInfo.completeAmount = productInfo.completeAmount + 1;
+ //_productPlanInfoService.UpdateProductPlanInfo(productInfo);
+ }
+
///
/// 接收下达的组装计划,根据BOM获取需要出库的泡后、内胆物料信息
@@ -134,19 +154,41 @@ namespace Aucma.Scada.Business
{
if (planInfo != null)
{
- // var bomInfo = _bomInfoService.GetChildenBomInfoByMaterialCode(planInfo.materialCode, appConfig.foamMaterialType);
+
var bomInfo = _bomInfoService.GetBomInfoByMaterialCode(planInfo.materialCode);
if (bomInfo==null)
{
PrintLogInfoMessage($"物料:{planInfo.materialCode};获取Bom信息为空");
return;
}
- for (int i = 0; i < planInfo.planAmount - planInfo.completeAmount; i++)
- {
- string taskCode = System.Guid.NewGuid().ToString("N").Substring(0, 10);
- OutStore(appConfig.foamStoreCode, bomInfo, planInfo.executePlanCode, taskCode,spaceInfo);
- Thread.Sleep(500);
- }
+ // 组装计划出库
+ //if (spaceInfo == null)
+ //{
+ // //筛选后的货道
+ // spaceInfo = GetSpaceInfoByMaterialType(appConfig.foamStoreCode, bomInfo.materialCode);
+ // if (spaceInfo == null)
+ // {
+ // PrintLogInfoMessage($"物料:{planInfo.materialCode};未匹配到货道");
+ // return;
+ // }
+ // for (int i = 0; i < spaceInfo.spaceStock; i++)
+ // {
+ // string taskCode = System.Guid.NewGuid().ToString("N").Substring(0, 7);
+ // OutStore(appConfig.foamStoreCode, bomInfo, planInfo.executePlanCode, taskCode, spaceInfo);
+ // Thread.Sleep(500);
+ // }
+ //}
+ // else // 指定货道出一个或者整道出
+ // {
+ for (int i = 0; i < planInfo.planAmount - planInfo.completeAmount; i++)
+ {
+ string taskCode = System.Guid.NewGuid().ToString("N").Substring(0, 7);
+ OutStore(appConfig.foamStoreCode, bomInfo, planInfo.executePlanCode, taskCode, spaceInfo);
+ Thread.Sleep(500);
+ }
+ // }
+
+
}
});
}
@@ -163,13 +205,8 @@ namespace Aucma.Scada.Business
try
{
PrintLogInfoMessage($"收到出库计划,物料码:{bomInfo.materialCode}");
- #region Delete By wenjy 2023-10-30 11:41:00 取消通过数据库获取货道数量、在途量,改为通过PLC获取货道信息
- //BaseSpaceInfo spaceInfo = _spaceInfoService.OutStoreGetSpaceInfoByMaterialCode(storeCode, bomInfo.materialCode);
- #endregion
- if(spaceInfo == null)
- {
- spaceInfo = GetSpaceInfoByMaterialType(storeCode, bomInfo.materialCode);
- }
+
+
if (spaceInfo != null)
{
PrintLogInfoMessage($"匹配货道:{spaceInfo.spaceName}");
@@ -209,10 +246,6 @@ namespace Aucma.Scada.Business
bool result = false;
try
{
- //获取出库的货道明细物料信息
- BaseSpaceDetail spaceDetail = GetSpaceDetailFirstOrderByCreatTime(spaceInfo);
- if (spaceDetail != null)
- {
#region 出库任务赋值
RealTaskInfo realTaskInfo = new RealTaskInfo();
// 执行计划编号
@@ -223,32 +256,30 @@ namespace Aucma.Scada.Business
realTaskInfo.storeCode = spaceInfo.storeCode;
realTaskInfo.spaceCode = spaceInfo.spaceCode;
realTaskInfo.spaceName = spaceInfo.spaceName;
- realTaskInfo.materialType = spaceDetail.materialType;
- realTaskInfo.materialCode = spaceDetail.materialCode;
+ realTaskInfo.materialType = spaceInfo.materialType;
realTaskInfo.planAmount = 1;
realTaskInfo.taskStatus = 1;
realTaskInfo.createTime = DateTime.Now;
- #endregion
+ #endregion
result = _taskInfoService.AddTaskInfo(realTaskInfo);
if (result)
{
+ // 禁止入库
+ spaceInfo.inStoreFlag = 2;
+ _spaceInfoService.UpdateSpaceInfo(spaceInfo);
PrintLogInfoMessage("出库任务创建成功");
- RefreshOutStoreTaskEvent?.Invoke(realTaskInfo);
+ RefreshOutStoreTaskEvent?.Invoke();
- UpdateSpaceAndDetial(spaceInfo, spaceDetail);
+ // UpdateSpaceAndDetial(spaceInfo, spaceDetail);
}
else
{
PrintLogInfoMessage("出库任务创建失败");
}
- }
- else
- {
- PrintLogInfoMessage("出库任务创建失败,货道明细为空");
- }
+
}
catch (Exception ex)
{
@@ -324,7 +355,7 @@ namespace Aucma.Scada.Business
while (true)
{
PassDownTaskInfo();
- Thread.Sleep(500);
+ Thread.Sleep(1000);
}
});
@@ -357,7 +388,9 @@ namespace Aucma.Scada.Business
taskInfo.taskStatus = 2;
_taskInfoService.UpdateTaskInfo(taskInfo);
- RefreshScanMateriaCodeEvent?.Invoke(taskInfo.materialCode, taskInfo.materialType, taskInfo.spaceName, taskInfo.storeCode);
+ //刷新出库任务界面
+ RefreshOutStoreTaskEvent?.Invoke();
+ // RefreshScanMateriaCodeEvent?.Invoke(taskInfo.materialCode, taskInfo.materialType, taskInfo.spaceName, taskInfo.storeCode);
}
else if (result == 2)
{
@@ -411,20 +444,21 @@ namespace Aucma.Scada.Business
PrintLogInfoMessage("出库应答成功,自动释放信号量,进行下发新任务");
semaphore.Release();
// 视为出库完成,后续改为监测在库数
- OutStoreFinish(storeCode, taskCode);
+ // OutStoreFinish(storeCode, taskCode);
}
- ///
- /// 出库完成
- ///
- ///
- ///
- private void OutStoreFinish(string storeCode, string taskCode)
- {
- PrintLogInfoMessage($"出库任务:{taskCode};执行完成");
+
+ /////
+ ///// 出库完成
+ /////
+ /////
+ /////
+ //private void OutStoreFinish(string storeCode, string taskCode)
+ //{
+ // PrintLogInfoMessage($"出库任务:{taskCode};执行完成");
- OutStoreFinishHandle(taskCode, appConfig.foamStoreCode);
- }
+ // OutStoreFinishHandle(taskCode, appConfig.foamStoreCode);
+ //}
///
/// 信号量释放,根据任务完成数量,执行完成后进行释放
@@ -447,66 +481,104 @@ namespace Aucma.Scada.Business
///
///
///
- private void OutStoreFinishHandle(string taskCode, string storeCode)
+ private void OutStoreFinishHandle(string code)
{
try
{
- var taskInfo = _taskInfoService.GetTaskInfoByTaskCode(taskCode, storeCode);
+
+ // 插入出库记录
+ PrintLogInfoMessage($"{code}:出库完成");
+ RealTaskInfo taskInfo = _taskInfoService.GetTaskInfoByTaskCode(SubStringMaterialCode(code), appConfig.foamStoreCode, 2);
if (taskInfo != null)
- {
- var spaceInfo = _spaceInfoService.GetSpaceInfoBySpaceCode(taskInfo.storeCode, taskInfo.spaceCode);
+ {
+ //更新计划信息
+ UpdatePlanInfo(taskInfo.planCode);
- if (spaceInfo != null)
- {
- // taskHandleBusiness.WritePlc(spaceInfo.storeCode, spaceInfo.spaceCode);
- //读取PLC获取货道信息:存放数量、在途数量
+ //刷新界面
+ RefreshScanMateriaCodeEvent?.Invoke(code, code.Substring(7, 10), taskInfo.spaceName, appConfig.foamStoreCode); //刷新界面扫码信息
- #region Add By wenjy 2023-10-30 13:44:00 通过PLC获取货道信息
- var item = taskHandleBusiness.ReadSpaceInfoByPlc(spaceInfo);
- spaceInfo.spaceStock = item.spaceStock;
- spaceInfo.onRouteAmount = item.onRouteAmount;
- //spaceInfo.spaceStatus = item.spaceStatus;
- #endregion
+
- if (spaceInfo.spaceStock == 0)
- {
- spaceInfo.materialType = string.Empty;
- }
+ }
+ else
+ {
+ //刷新界面
+ RefreshScanMateriaCodeEvent?.Invoke(code, code.Substring(7, 10), "", appConfig.foamStoreCode); //刷新界面扫码信息
- _spaceInfoService.UpdateSpaceInfo(spaceInfo);
- #region 添加出库记录
- RecordOutstore recordOutstore = new RecordOutstore();
- recordOutstore.storeCode = taskInfo.storeCode;
- recordOutstore.spaceCode = taskInfo.spaceCode;
- recordOutstore.materialCode = taskInfo.materialCode;
- recordOutstore.materialType = taskInfo.materialType;
- recordOutstore.materialName = GetMaterialName(taskInfo.materialType);
- recordOutstore.outStoreAmount = 1;
- recordOutstore.outStoreTime = DateTime.Now;
- _recordOutStoreService.InsertReocrdOutStoreService(recordOutstore);
- #endregion
- }
+ #region 根据创建时间删除没有型号的任务
+
+ #endregion
+ }
+ // _taskInfoService.DeleteTaskInfoByCode(taskInfo);
+ // 查询该型号的类型任务按照时间排序删除第一条, 清除任务信息
+ _taskInfoService.DeleteFirstTaskByStoreCode(appConfig.foamStoreCode, 2);
+ #region 添加出库记录
+ RecordOutstore recordOutstore = new RecordOutstore();
+ recordOutstore.storeCode = appConfig.foamStoreCode;
+ if (taskInfo != null)
+ {
+ recordOutstore.spaceCode = taskInfo.spaceCode;
+ }
+ recordOutstore.materialCode = code;
+ recordOutstore.materialType = code.Substring(7, 10);
+ recordOutstore.materialName = GetMaterialName(recordOutstore.materialType);
+ recordOutstore.outStoreAmount = 1;
+ recordOutstore.outStoreTime = DateTime.Now;
+ _recordOutStoreService.InsertReocrdOutStoreService(recordOutstore);
- //更新计划信息
- UpdatePlanInfo(taskInfo.planCode);
+ #endregion
- RefreshStoreStockEvent?.Invoke();
- //清除任务信息
- _taskInfoService.DeleteTaskInfo(taskCode, storeCode);
+ // 根据条码查询明细并删除
+ _spaceDetailService.DeleteSpaceDetailByMaterialCode(code);
- _spaceDetailService.DeleteSpaceDetailByMaterialCode(taskInfo.materialCode);
- //刷新界面
- RefreshScanMateriaCodeEvent?.Invoke(string.Empty, string.Empty, string.Empty, taskInfo.storeCode);
+ // 刷新任务页面
+ RefreshOutStoreTaskEvent?.Invoke();
+
+ #region 出库更新过点数据,插入记录到MATERIAL_COMPLETION表
+ if (!string.IsNullOrEmpty(code))
+ {
+ PrintBarCode print = _printBarCodeServices.query(code);
+ if (print != null)
+ {
+ // string planCode = _productPlanInfoServices.GetPlanCode(print.OrderCode, appConfig.stationCode);
+ MaterialCompletion completion = new MaterialCompletion();
+ completion.OrderCode = print.OrderCode;
+ completion.MaterialBarcode = code;
+ completion.MaterialCode = print.MaterialCode;
+ completion.MaterialName = print.MaterialName;
+ completion.StationName = appConfig.outstationCode;
+ completion.CompleteDate = DateTime.Now;
+ // completion.planCode = planCode;
+ _iMaterialCompletionServices.Add(completion);
+ }
}
+ #endregion
}
catch (Exception ex)
{
- PrintLogErrorMessage("出库完成逻辑处理异常", ex);
+ PrintLogErrorMessage("出库完成逻辑处理异常:"+ ex);
+ }
+ }
+
+
+ ///
+ /// 截条码类型
+ ///
+ ///
+ ///
+ private string SubStringMaterialCode(string materialCode)
+ {
+ string result = string.Empty;
+ if (!string.IsNullOrEmpty(materialCode))
+ {
+ result = materialCode.Substring(7, 10);
}
+
+ return result;
}
@@ -518,9 +590,11 @@ namespace Aucma.Scada.Business
{
try
{
+
var executeInfo = _executePlanInfoService.GetExecutePlanInfoByPlanCode(planCode);
if (executeInfo != null)
{
+
executeInfo.completeAmount += 1;
if (executeInfo.completeAmount == executeInfo.planAmount)
@@ -533,12 +607,16 @@ namespace Aucma.Scada.Business
var productInfo = _productPlanInfoService.GetProductPlanByPlanCode(executeInfo.productPlanCode);
if (productInfo != null)
{
+ if(productInfo.completeAmount==0)
+ {
+ productInfo.beginTime = DateTime.Now;
+ }
productInfo.completeAmount += 1;
- if (productInfo.completeAmount == productInfo.planAmount)
+ if (productInfo.completeAmount >= productInfo.planAmount)
{
productInfo.endTime = DateTime.Now;
}
-
+
_productPlanInfoService.UpdateProductPlanInfo(productInfo);
}
@@ -613,6 +691,16 @@ namespace Aucma.Scada.Business
return result;
}
+ ///
+ /// 泡后库出库删除所有任务信息
+ ///
+ ///
+ ///
+ public bool DeleteAllTaskByStoreCode(string storeCode, int taskType)
+ {
+ return _taskInfoService.DeleteAllTaskByStoreCode(storeCode, taskType);
+ }
+
///
/// 根据货道手动出一个
///
@@ -637,7 +725,7 @@ namespace Aucma.Scada.Business
else
{
// 不关联生产计划
- result = this.CreateOutStoreTask(spaceInfo, System.Guid.NewGuid().ToString("N").Substring(0, 10), System.Guid.NewGuid().ToString("N").Substring(0, 10), 1);
+ result = this.CreateOutStoreTask(spaceInfo, System.Guid.NewGuid().ToString("N").Substring(0, 7), System.Guid.NewGuid().ToString("N").Substring(0, 10), 1);
}
}
@@ -677,9 +765,9 @@ namespace Aucma.Scada.Business
#endregion
else
{
- for(int i = 1; i < spaceInfo.spaceStock; i++)
+ for(int i = 1; i <= spaceInfo.spaceStock; i++)
{
- result = this.CreateOutStoreTask(spaceInfo, System.Guid.NewGuid().ToString("N").Substring(0, 10), System.Guid.NewGuid().ToString("N").Substring(0, 10), 1);
+ result = this.CreateOutStoreTask(spaceInfo, System.Guid.NewGuid().ToString("N").Substring(0, 7), System.Guid.NewGuid().ToString("N").Substring(0, 10), 1);
if (!result)
{
return false;
@@ -707,7 +795,7 @@ namespace Aucma.Scada.Business
/// 日志输出,界面刷新同时记录文件
///
///
- private void PrintLogInfoMessage(string message)
+ public void PrintLogInfoMessage(string message)
{
RefreshLogMessageEvent?.Invoke(message);
logHelper.Info(message);
@@ -754,12 +842,12 @@ namespace Aucma.Scada.Business
return materialName;
}
- /// 通过PLC读取货道信息(在库数量、货道状态)
+ /// 出库找货道
///
///
///
///
- private BaseSpaceInfo GetSpaceInfoByMaterialType(string storeCode, string materialType)
+ public BaseSpaceInfo GetSpaceInfoByMaterialType(string storeCode, string materialType)
{
BaseSpaceInfo result = null;
@@ -767,32 +855,22 @@ namespace Aucma.Scada.Business
{
List info = _spaceInfoService.GetBaseSpaceInfosByMaterialType(storeCode, materialType,2);
- if (info != null)
+ if (info != null && info.Count>0)
{
- if (info.Count > 0)
- {
- foreach (BaseSpaceInfo item in info)
- {
- var spaceInfo = taskHandleBusiness.ReadSpaceInfoByPlc(item);
- item.spaceStock = spaceInfo.spaceStock;
- item.onRouteAmount = spaceInfo.onRouteAmount;
- // item.spaceStatus = spaceInfo.spaceStatus;
- }
-
- //result = info.Where(x => x.spaceStatus == 1 && x.spaceStock > 0).OrderBy(x => x.spaceStock).OrderBy(x => x.spaceCode).First();
-
- var list = info.Where(x => x.spaceStatus == 1 && x.spaceStock > 0).ToList();
-
- if (list.Count > 0)
- {
- result = info.OrderBy(x => x.spaceStock).First();
- }
- else
- {
- PrintLogInfoMessage("未获取到匹配的货道,请排查货道库存及货道状态是否可用");
- }
-
- }
+
+ foreach (BaseSpaceInfo item in info)
+ {
+ var spaceInfo = taskHandleBusiness.ReadSpaceInfoByPlc(item);
+ item.spaceStock = spaceInfo.spaceStock;
+ item.onRouteAmount = spaceInfo.onRouteAmount;
+ }
+
+ result = info.OrderByDescending(x => x.spaceStock).First();
+
+ }
+ else
+ {
+ PrintLogInfoMessage("未获取到匹配的货道,请排查货道库存及货道状态是否可用");
}
}
catch (Exception ex)
diff --git a/Aucma.Scada.Business/RegisterServices.cs b/Aucma.Scada.Business/RegisterServices.cs
index 080ce289..0e9d21d4 100644
--- a/Aucma.Scada.Business/RegisterServices.cs
+++ b/Aucma.Scada.Business/RegisterServices.cs
@@ -62,6 +62,8 @@ namespace Aucma.Scada.Business
services.AddSingleton();
services.AddSingleton();
services.AddSingleton();
+ services.AddSingleton();
+
}
public T GetService()
diff --git a/Aucma.Scada.Business/bin/Debug/Aucma.Scada.Business.dll b/Aucma.Scada.Business/bin/Debug/Aucma.Scada.Business.dll
index fb07c654..d5cdd4c8 100644
Binary files a/Aucma.Scada.Business/bin/Debug/Aucma.Scada.Business.dll and b/Aucma.Scada.Business/bin/Debug/Aucma.Scada.Business.dll differ
diff --git a/Aucma.Scada.Business/bin/Debug/Aucma.Scada.Business.pdb b/Aucma.Scada.Business/bin/Debug/Aucma.Scada.Business.pdb
index 34c85797..5837f72e 100644
Binary files a/Aucma.Scada.Business/bin/Debug/Aucma.Scada.Business.pdb and b/Aucma.Scada.Business/bin/Debug/Aucma.Scada.Business.pdb differ
diff --git a/Aucma.Scada.Business/bin/Debug/Aucma.Scada.HikRobot.dll b/Aucma.Scada.Business/bin/Debug/Aucma.Scada.HikRobot.dll
index a7dfae52..4ffd9364 100644
Binary files a/Aucma.Scada.Business/bin/Debug/Aucma.Scada.HikRobot.dll and b/Aucma.Scada.Business/bin/Debug/Aucma.Scada.HikRobot.dll differ
diff --git a/Aucma.Scada.Business/bin/Debug/Aucma.Scada.HikRobot.pdb b/Aucma.Scada.Business/bin/Debug/Aucma.Scada.HikRobot.pdb
index 9eb5297e..8b269176 100644
Binary files a/Aucma.Scada.Business/bin/Debug/Aucma.Scada.HikRobot.pdb and b/Aucma.Scada.Business/bin/Debug/Aucma.Scada.HikRobot.pdb differ
diff --git a/Aucma.Scada.Business/bin/Debug/HighWayIot.Config.dll b/Aucma.Scada.Business/bin/Debug/HighWayIot.Config.dll
index af8b6891..7ea4be2e 100644
Binary files a/Aucma.Scada.Business/bin/Debug/HighWayIot.Config.dll and b/Aucma.Scada.Business/bin/Debug/HighWayIot.Config.dll differ
diff --git a/Aucma.Scada.Business/bin/Debug/HighWayIot.Config.pdb b/Aucma.Scada.Business/bin/Debug/HighWayIot.Config.pdb
index 09e45895..757a1df0 100644
Binary files a/Aucma.Scada.Business/bin/Debug/HighWayIot.Config.pdb and b/Aucma.Scada.Business/bin/Debug/HighWayIot.Config.pdb differ
diff --git a/Aucma.Scada.Business/bin/Debug/HighWayIot.Repository.dll b/Aucma.Scada.Business/bin/Debug/HighWayIot.Repository.dll
index 30ddf598..3ff90882 100644
Binary files a/Aucma.Scada.Business/bin/Debug/HighWayIot.Repository.dll and b/Aucma.Scada.Business/bin/Debug/HighWayIot.Repository.dll differ
diff --git a/Aucma.Scada.Business/bin/Debug/HighWayIot.Repository.pdb b/Aucma.Scada.Business/bin/Debug/HighWayIot.Repository.pdb
index 45fcb3f9..da13abbc 100644
Binary files a/Aucma.Scada.Business/bin/Debug/HighWayIot.Repository.pdb and b/Aucma.Scada.Business/bin/Debug/HighWayIot.Repository.pdb differ
diff --git a/Aucma.Scada.Business/obj/Debug/Aucma.Scada.Business.csproj.AssemblyReference.cache b/Aucma.Scada.Business/obj/Debug/Aucma.Scada.Business.csproj.AssemblyReference.cache
index 61383a78..44273513 100644
Binary files a/Aucma.Scada.Business/obj/Debug/Aucma.Scada.Business.csproj.AssemblyReference.cache and b/Aucma.Scada.Business/obj/Debug/Aucma.Scada.Business.csproj.AssemblyReference.cache differ
diff --git a/Aucma.Scada.Business/obj/Debug/Aucma.Scada.Business.dll b/Aucma.Scada.Business/obj/Debug/Aucma.Scada.Business.dll
index fb07c654..d5cdd4c8 100644
Binary files a/Aucma.Scada.Business/obj/Debug/Aucma.Scada.Business.dll and b/Aucma.Scada.Business/obj/Debug/Aucma.Scada.Business.dll differ
diff --git a/Aucma.Scada.Business/obj/Debug/Aucma.Scada.Business.pdb b/Aucma.Scada.Business/obj/Debug/Aucma.Scada.Business.pdb
index 34c85797..5837f72e 100644
Binary files a/Aucma.Scada.Business/obj/Debug/Aucma.Scada.Business.pdb and b/Aucma.Scada.Business/obj/Debug/Aucma.Scada.Business.pdb differ
diff --git a/Aucma.Scada.HikRobot/MvCodeHelper.cs b/Aucma.Scada.HikRobot/MvCodeHelper.cs
index 68a09bee..d09a3d3c 100644
--- a/Aucma.Scada.HikRobot/MvCodeHelper.cs
+++ b/Aucma.Scada.HikRobot/MvCodeHelper.cs
@@ -20,12 +20,18 @@ namespace Aucma.Core.Scanner
private static AppConfig appConfig = AppConfig.Instance;
public static bool m_bGrabbing = true;
private static string SheellLastCode;
- // 箱壳扫码器ip
+ private static string LinerLastCode;
+
+ // 入库扫码器ip
private static string ShellScannerIp = appConfig.foamHikRobotIp;
+
+ // 出库扫码器ip
+ private static string LinerScannerIp = appConfig.foamOutHikRobotIp;
+
#region 全局变量定义
public static DateTime ShellLiveTime = DateTime.Now;
-
+ public static DateTime LinerLiveTime = DateTime.Now;
#endregion
#region 委托事件
@@ -35,16 +41,23 @@ namespace Aucma.Core.Scanner
///
///
///
- public delegate void RefreshState(bool flag);
+ public delegate void RefreshState(string ip, bool flag);
public static event RefreshState RefreshStateEvent;
//NoRead事件通知
public delegate void MessageNoRead();
public static event MessageNoRead MessageNoReadEvent;
-
+ //入库扫码
public delegate void RefreshMaterialCodeStr(string materialCodeStr);
public static event RefreshMaterialCodeStr RefreshMaterialCodeStrEvent;
+
+
+ //出库扫码
+ public delegate void OutMaterialCodeStr(string materialCodeStr);
+ public static event OutMaterialCodeStr OutMaterialCodeStrEvent;
+
+
///
/// 日志信息刷新
///
@@ -64,8 +77,8 @@ namespace Aucma.Core.Scanner
{
//更新扫码器存活时间
ShellLiveTime = DateTime.Now;
- Console.WriteLine("箱壳No Read 处理");
- MessageNoReadEvent();
+ Console.WriteLine("入库No Read 处理");
+ MessageNoReadEvent?.Invoke();
}
for (Int32 i = 0; i < stBcrResult.nCodeNum; i++)
@@ -79,7 +92,7 @@ namespace Aucma.Core.Scanner
else
{
string strCode = Encoding.GetEncoding("GB2312").GetString(stBcrResult.stBcrInfoEx2[i].chCode);
- Console.WriteLine(DateTime.Now + ":箱壳扫码器==>Get CodeNum: " + "CodeNum[" + i.ToString() + "], CodeString[" + strCode.Trim().TrimEnd('\0') + "]");
+ Console.WriteLine(DateTime.Now + ":入库扫码器==>Get CodeNum: " + "CodeNum[" + i.ToString() + "], CodeString[" + strCode.Trim().TrimEnd('\0') + "]");
if (string.IsNullOrEmpty(SheellLastCode) || SheellLastCode != strCode.Trim().TrimEnd('\0'))
{
@@ -90,7 +103,59 @@ namespace Aucma.Core.Scanner
}
if (SheellLastCode == strCode.Trim().TrimEnd('\0'))
{
- Console.WriteLine("箱壳和上次扫描结果一样,不作处理");
+ Console.WriteLine("入库和上次扫描结果一样,不作处理");
+ }
+
+ }
+ }
+
+ MvCodeReader.MV_CODEREADER_OCR_INFO_LIST stOcrInfo = (MvCodeReader.MV_CODEREADER_OCR_INFO_LIST)Marshal.PtrToStructure(stFrameInfo.UnparsedOcrList.pstOcrList, typeof(MvCodeReader.MV_CODEREADER_OCR_INFO_LIST));
+
+ for (int i = 0; i < stOcrInfo.nOCRAllNum; i++)
+ {
+ string strOcrCharCode = Encoding.UTF8.GetString(stOcrInfo.stOcrRowInfo[i].chOcr);
+ Console.WriteLine("Get OcrInfo:" + "ocrNum[" + i.ToString() + "], ocrLen[" + Convert.ToString(stOcrInfo.stOcrRowInfo[i].nOcrLen) + "], ocrChar[" + strOcrCharCode.Trim().TrimEnd('\0') + "]");
+ }
+ }
+
+
+ public static void LinerImageCallbackFunc(IntPtr pData, IntPtr pstFrameInfoEx2, IntPtr pUser)
+ {
+ var stFrameInfo = (MvCodeReader.MV_CODEREADER_IMAGE_OUT_INFO_EX2)Marshal.PtrToStructure(pstFrameInfoEx2, typeof(MvCodeReader.MV_CODEREADER_IMAGE_OUT_INFO_EX2));
+
+ MvCodeReader.MV_CODEREADER_RESULT_BCR_EX2 stBcrResult = (MvCodeReader.MV_CODEREADER_RESULT_BCR_EX2)Marshal.PtrToStructure(stFrameInfo.UnparsedBcrList.pstCodeListEx2, typeof(MvCodeReader.MV_CODEREADER_RESULT_BCR_EX2));
+
+ // Console.WriteLine("CodeNum[" + Convert.ToString(stBcrResult.nCodeNum) + "]");
+ if (stBcrResult.nCodeNum == 0)
+ {
+ // 更新存活时间
+ LinerLiveTime = DateTime.Now;
+ Console.WriteLine("出库No Read 处理");
+ MessageNoReadEvent();
+ }
+ for (Int32 i = 0; i < stBcrResult.nCodeNum; i++)
+ {
+ bool bIsValidUTF8 = IsTextUTF8(stBcrResult.stBcrInfoEx2[i].chCode);
+ if (bIsValidUTF8)
+ {
+ string strCode = Encoding.UTF8.GetString(stBcrResult.stBcrInfoEx2[i].chCode);
+ Console.WriteLine("Get CodeNum: " + "CodeNum[" + i.ToString() + "], CodeString[" + strCode.Trim().TrimEnd('\0') + "]");
+ }
+ else
+ {
+ string strCode = Encoding.GetEncoding("GB2312").GetString(stBcrResult.stBcrInfoEx2[i].chCode);
+ Console.WriteLine(DateTime.Now + ":出库扫码器==>Get CodeNum: " + "CodeNum[" + i.ToString() + "], CodeString[" + strCode.Trim().TrimEnd('\0') + "]");
+
+ if (string.IsNullOrEmpty(LinerLastCode) || LinerLastCode != strCode.Trim().TrimEnd('\0'))
+ {
+ // 更新存活时间
+ LinerLiveTime = DateTime.Now;
+ OutMaterialCodeStrEvent?.Invoke(strCode.Trim().TrimEnd('\0'));
+ LinerLastCode = strCode.Trim().TrimEnd('\0');
+ }
+ if (LinerLastCode == strCode.Trim().TrimEnd('\0'))
+ {
+ Console.WriteLine("出库和上次扫描一样,不作处理");
}
}
@@ -98,6 +163,7 @@ namespace Aucma.Core.Scanner
MvCodeReader.MV_CODEREADER_OCR_INFO_LIST stOcrInfo = (MvCodeReader.MV_CODEREADER_OCR_INFO_LIST)Marshal.PtrToStructure(stFrameInfo.UnparsedOcrList.pstOcrList, typeof(MvCodeReader.MV_CODEREADER_OCR_INFO_LIST));
+ Console.WriteLine("ocrAllNum[" + Convert.ToString(stOcrInfo.nOCRAllNum) + "]");
for (int i = 0; i < stOcrInfo.nOCRAllNum; i++)
{
string strOcrCharCode = Encoding.UTF8.GetString(stOcrInfo.stOcrRowInfo[i].chOcr);
@@ -123,9 +189,9 @@ namespace Aucma.Core.Scanner
if (MvCodeReader.MV_CODEREADER_OK != nRet)
{
// 刷新扫码器状态
- RefreshStateEvent?.Invoke(false);
+ RefreshStateEvent?.Invoke("入库",false);
- RefreshStateEvent?.Invoke(false);
+ RefreshStateEvent?.Invoke("入库", false);
Thread.Sleep(1000 * 10);
Console.WriteLine("Enum device failed:{0:x8}", nRet);
break;
@@ -134,9 +200,9 @@ namespace Aucma.Core.Scanner
if (0 == stDevList.nDeviceNum)
{
// 刷新扫码器状态
- RefreshStateEvent?.Invoke(false);
+ RefreshStateEvent?.Invoke("入库", false);
- RefreshStateEvent?.Invoke(false);
+ RefreshStateEvent?.Invoke("入库", false);
Thread.Sleep(1000 * 10);
break;
@@ -169,9 +235,9 @@ namespace Aucma.Core.Scanner
}
if (nDevIndex < 0)
{
- Console.WriteLine("未找到箱壳扫码器");
+ Console.WriteLine("未找到入库扫码器");
// 刷新扫码器状态
- RefreshStateEvent?.Invoke(false);
+ RefreshStateEvent?.Invoke("入库", false);
Thread.Sleep(1000 * 30);
break;
}
@@ -183,7 +249,7 @@ namespace Aucma.Core.Scanner
{
Console.WriteLine("Create device failed:{0:x8}", nRet);
// 刷新扫码器状态
- RefreshStateEvent?.Invoke(false);
+ RefreshStateEvent?.Invoke("入库", false);
break;
}
@@ -194,12 +260,12 @@ namespace Aucma.Core.Scanner
{
Console.WriteLine("Open device failed:{0:x8}", nRet);
// 刷新扫码器状态
- RefreshStateEvent?.Invoke(false);
+ RefreshStateEvent?.Invoke("入库", false);
break;
}
// 刷新扫码器状态
- RefreshStateEvent?.Invoke(true);
+ RefreshStateEvent?.Invoke("入库", true);
// ch:注册回调函数 | en:Register image callback
ImageCallback = new MvCodeReader.cbOutputEx2delegate(ShellImageCallbackFunc);
nRet = device.MV_CODEREADER_RegisterImageCallBackEx2_NET(ImageCallback, IntPtr.Zero);
@@ -207,7 +273,7 @@ namespace Aucma.Core.Scanner
{
Console.WriteLine("Register image callback failed!");
// 刷新扫码器状态
- RefreshStateEvent?.Invoke(false);
+ RefreshStateEvent?.Invoke("入库", false);
break;
}
@@ -217,7 +283,7 @@ namespace Aucma.Core.Scanner
{
Console.WriteLine("Start grabbing failed:{0:x8}", nRet);
// 刷新扫码器状态
- RefreshStateEvent?.Invoke(false);
+ RefreshStateEvent?.Invoke("入库", false);
break;
}
@@ -231,16 +297,15 @@ namespace Aucma.Core.Scanner
TimeSpan timeSpan = dateTime.Subtract(ShellLiveTime);
if (timeSpan.TotalMinutes >= 10)
{
- Console.WriteLine("箱壳扫码器超时");
- //CloseShell();
- //Shell();
+ Console.WriteLine("入库扫码器超时");
+
break;
}
}
// Console.ReadLine();
// 刷新扫码器状态
- RefreshStateEvent?.Invoke(false);
+ RefreshStateEvent?.Invoke("入库", false);
// ch:停止抓图 | en:Stop grabbing
nRet = device.MV_CODEREADER_StopGrabbing_NET();
if (MvCodeReader.MV_CODEREADER_OK != nRet)
@@ -270,6 +335,170 @@ namespace Aucma.Core.Scanner
}
+ public static void Liner()
+ {
+ LinerLiveTime = DateTime.Now;
+ MvCodeReader.cbOutputEx2delegate ImageCallback;
+
+ MvCodeReader.MV_CODEREADER_IMAGE_OUT_INFO_EX2 stFrameInfo = new MvCodeReader.MV_CODEREADER_IMAGE_OUT_INFO_EX2();
+ MvCodeReader device = new MvCodeReader();
+ int nRet = MvCodeReader.MV_CODEREADER_OK;
+
+ do
+ {
+ // ch:枚举设备 | en:Enum device
+ MvCodeReader.MV_CODEREADER_DEVICE_INFO_LIST stDevList = new MvCodeReader.MV_CODEREADER_DEVICE_INFO_LIST();
+ nRet = MvCodeReader.MV_CODEREADER_EnumDevices_NET(ref stDevList, MvCodeReader.MV_CODEREADER_GIGE_DEVICE);
+ if (MvCodeReader.MV_CODEREADER_OK != nRet)
+ {
+ // 刷新扫码器状态
+ RefreshStateEvent?.Invoke("入库", false);
+
+ RefreshStateEvent?.Invoke("出库", false);
+ Thread.Sleep(1000 * 10);
+ Console.WriteLine("Enum device failed:{0:x8}", nRet);
+ break;
+ }
+ Console.WriteLine("Enum device count : " + Convert.ToString(stDevList.nDeviceNum));
+ if (0 == stDevList.nDeviceNum)
+ {
+ // 刷新扫码器状态
+ RefreshStateEvent?.Invoke("入库", false);
+
+ RefreshStateEvent?.Invoke("出库", false);
+ Thread.Sleep(1000 * 10);
+ break;
+ }
+
+ MvCodeReader.MV_CODEREADER_DEVICE_INFO stDevInfo; // 通用设备信息
+ Int32 nDevIndex = -1;
+ // ch:打印设备信息 | en:Print device info
+ for (Int32 i = 0; i < stDevList.nDeviceNum; i++)
+ {
+ stDevInfo = (MvCodeReader.MV_CODEREADER_DEVICE_INFO)Marshal.PtrToStructure(stDevList.pDeviceInfo[i], typeof(MvCodeReader.MV_CODEREADER_DEVICE_INFO));
+
+ if (MvCodeReader.MV_CODEREADER_GIGE_DEVICE == stDevInfo.nTLayerType)
+ {
+ MvCodeReader.MV_CODEREADER_GIGE_DEVICE_INFO stGigEDeviceInfo = (MvCodeReader.MV_CODEREADER_GIGE_DEVICE_INFO)MvCodeReader.ByteToStruct(stDevInfo.SpecialInfo.stGigEInfo, typeof(MvCodeReader.MV_CODEREADER_GIGE_DEVICE_INFO));
+ uint nIp1 = ((stGigEDeviceInfo.nCurrentIp & 0xff000000) >> 24);
+ uint nIp2 = ((stGigEDeviceInfo.nCurrentIp & 0x00ff0000) >> 16);
+ uint nIp3 = ((stGigEDeviceInfo.nCurrentIp & 0x0000ff00) >> 8);
+ uint nIp4 = (stGigEDeviceInfo.nCurrentIp & 0x000000ff);
+ // Console.WriteLine("\n" + i.ToString() + ": [GigE] User Define Name : " + stGigEDeviceInfo.chUserDefinedName);
+ string ip = ((stGigEDeviceInfo.nCurrentIp & 0xff000000) >> 24) + "." + ((stGigEDeviceInfo.nCurrentIp & 0x00ff0000) >> 16) + "." + ((stGigEDeviceInfo.nCurrentIp & 0x0000ff00) >> 8) + "." + (stGigEDeviceInfo.nCurrentIp & 0x000000ff);
+ string ipStr = nIp1 + "." + nIp2 + "." + nIp3 + "." + nIp4;
+ if (ipStr == LinerScannerIp)
+ {
+ Console.WriteLine("device IP :" + ipStr);
+ nDevIndex = i;
+ }
+ }
+ }
+ if (nDevIndex < 0)
+ {
+ Console.WriteLine("未找到出库扫码器");
+ // 刷新扫码器状态
+ RefreshStateEvent?.Invoke("出库", false);
+ Thread.Sleep(1000 * 30);
+ break;
+ }
+
+ stDevInfo = (MvCodeReader.MV_CODEREADER_DEVICE_INFO)Marshal.PtrToStructure(stDevList.pDeviceInfo[nDevIndex], typeof(MvCodeReader.MV_CODEREADER_DEVICE_INFO));
+
+ // ch:创建设备 | en:Create device
+ nRet = device.MV_CODEREADER_CreateHandle_NET(ref stDevInfo);
+ if (MvCodeReader.MV_CODEREADER_OK != nRet)
+ {
+ Console.WriteLine("Create device failed:{0:x8}", nRet);
+ break;
+ }
+
+ // ch:打开设备 | en:Open device
+ nRet = device.MV_CODEREADER_OpenDevice_NET();
+ if (MvCodeReader.MV_CODEREADER_OK != nRet)
+ {
+ Console.WriteLine("Open device failed:{0:x8}", nRet);
+ // 刷新扫码器状态
+ RefreshStateEvent?.Invoke("出库", false);
+ break;
+ }
+ // 刷新扫码器状态
+ RefreshStateEvent?.Invoke("出库", true);
+
+ // ch:注册回调函数 | en:Register image callback
+ ImageCallback = new MvCodeReader.cbOutputEx2delegate(LinerImageCallbackFunc);
+ nRet = device.MV_CODEREADER_RegisterImageCallBackEx2_NET(ImageCallback, IntPtr.Zero);
+ if (MvCodeReader.MV_CODEREADER_OK != nRet)
+ {
+ Console.WriteLine("Register image callback failed!");
+ break;
+ }
+
+ // ch:开启抓图 || en: start grab image
+ nRet = device.MV_CODEREADER_StartGrabbing_NET();
+ if (MvCodeReader.MV_CODEREADER_OK != nRet)
+ {
+ Console.WriteLine("Start grabbing failed:{0:x8}", nRet);
+ break;
+ }
+
+ Console.WriteLine("Press enter to exit");
+ Console.WriteLine(DateTime.Now.ToString());
+ while (true)
+ {
+ Thread.Sleep(1000 * 60);
+ DateTime dateTime = DateTime.Now;
+ TimeSpan timeSpan = dateTime.Subtract(LinerLiveTime);
+ if (timeSpan.TotalMinutes >= 10)
+ {
+ Console.WriteLine("出库扫码器超时");
+ //CloseShell();
+ //Shell();
+ break;
+ }
+
+ }
+ //Console.ReadLine();
+
+ // ch:停止抓图 | en:Stop grabbing
+ nRet = device.MV_CODEREADER_StopGrabbing_NET();
+ if (MvCodeReader.MV_CODEREADER_OK != nRet)
+ {
+ Console.WriteLine("Stop grabbing failed{0:x8}", nRet);
+ break;
+ }
+
+ // ch:关闭设备 | en:Close device
+ nRet = device.MV_CODEREADER_CloseDevice_NET();
+ if (MvCodeReader.MV_CODEREADER_OK != nRet)
+ {
+ Console.WriteLine("Close device failed{0:x8}", nRet);
+ break;
+ }
+
+ // ch:销毁设备 | en:Destroy device
+ nRet = device.MV_CODEREADER_DestroyHandle_NET();
+ if (MvCodeReader.MV_CODEREADER_OK != nRet)
+ {
+ Console.WriteLine("Destroy device failed:{0:x8}", nRet);
+ break;
+ }
+
+ } while (false);
+
+ if (MvCodeReader.MV_CODEREADER_OK != nRet)
+ {
+ // ch:销毁设备 | en:Destroy device
+ nRet = device.MV_CODEREADER_DestroyHandle_NET();
+ if (MvCodeReader.MV_CODEREADER_OK != nRet)
+ {
+ Console.WriteLine("Destroy device failed:{0:x8}", nRet);
+ }
+ }
+ Thread.Sleep(1000);
+ Liner();
+
+ }
diff --git a/Aucma.Scada.HikRobot/bin/Debug/Aucma.Scada.HikRobot.dll b/Aucma.Scada.HikRobot/bin/Debug/Aucma.Scada.HikRobot.dll
index a7dfae52..4ffd9364 100644
Binary files a/Aucma.Scada.HikRobot/bin/Debug/Aucma.Scada.HikRobot.dll and b/Aucma.Scada.HikRobot/bin/Debug/Aucma.Scada.HikRobot.dll differ
diff --git a/Aucma.Scada.HikRobot/bin/Debug/Aucma.Scada.HikRobot.pdb b/Aucma.Scada.HikRobot/bin/Debug/Aucma.Scada.HikRobot.pdb
index 9eb5297e..8b269176 100644
Binary files a/Aucma.Scada.HikRobot/bin/Debug/Aucma.Scada.HikRobot.pdb and b/Aucma.Scada.HikRobot/bin/Debug/Aucma.Scada.HikRobot.pdb differ
diff --git a/Aucma.Scada.HikRobot/bin/Debug/HighWayIot.Config.dll b/Aucma.Scada.HikRobot/bin/Debug/HighWayIot.Config.dll
index af8b6891..7ea4be2e 100644
Binary files a/Aucma.Scada.HikRobot/bin/Debug/HighWayIot.Config.dll and b/Aucma.Scada.HikRobot/bin/Debug/HighWayIot.Config.dll differ
diff --git a/Aucma.Scada.HikRobot/bin/Debug/HighWayIot.Config.pdb b/Aucma.Scada.HikRobot/bin/Debug/HighWayIot.Config.pdb
index 09e45895..757a1df0 100644
Binary files a/Aucma.Scada.HikRobot/bin/Debug/HighWayIot.Config.pdb and b/Aucma.Scada.HikRobot/bin/Debug/HighWayIot.Config.pdb differ
diff --git a/Aucma.Scada.HikRobot/obj/Debug/Aucma.Scada.HikRobot.csproj.AssemblyReference.cache b/Aucma.Scada.HikRobot/obj/Debug/Aucma.Scada.HikRobot.csproj.AssemblyReference.cache
index 9ce4470a..50965c0a 100644
Binary files a/Aucma.Scada.HikRobot/obj/Debug/Aucma.Scada.HikRobot.csproj.AssemblyReference.cache and b/Aucma.Scada.HikRobot/obj/Debug/Aucma.Scada.HikRobot.csproj.AssemblyReference.cache differ
diff --git a/Aucma.Scada.HikRobot/obj/Debug/Aucma.Scada.HikRobot.dll b/Aucma.Scada.HikRobot/obj/Debug/Aucma.Scada.HikRobot.dll
index a7dfae52..4ffd9364 100644
Binary files a/Aucma.Scada.HikRobot/obj/Debug/Aucma.Scada.HikRobot.dll and b/Aucma.Scada.HikRobot/obj/Debug/Aucma.Scada.HikRobot.dll differ
diff --git a/Aucma.Scada.HikRobot/obj/Debug/Aucma.Scada.HikRobot.pdb b/Aucma.Scada.HikRobot/obj/Debug/Aucma.Scada.HikRobot.pdb
index 9eb5297e..8b269176 100644
Binary files a/Aucma.Scada.HikRobot/obj/Debug/Aucma.Scada.HikRobot.pdb and b/Aucma.Scada.HikRobot/obj/Debug/Aucma.Scada.HikRobot.pdb differ
diff --git a/Aucma.Scada.Model/obj/Debug/Aucma.Scada.Model.csproj.AssemblyReference.cache b/Aucma.Scada.Model/obj/Debug/Aucma.Scada.Model.csproj.AssemblyReference.cache
index 487f0c6c..85122cca 100644
Binary files a/Aucma.Scada.Model/obj/Debug/Aucma.Scada.Model.csproj.AssemblyReference.cache and b/Aucma.Scada.Model/obj/Debug/Aucma.Scada.Model.csproj.AssemblyReference.cache differ
diff --git a/Aucma.Scada.UI/App.xaml.cs b/Aucma.Scada.UI/App.xaml.cs
index 8de79928..6b90355d 100644
--- a/Aucma.Scada.UI/App.xaml.cs
+++ b/Aucma.Scada.UI/App.xaml.cs
@@ -40,7 +40,7 @@ namespace Aucma.Scada.UI
else
{
mainBusiness.InitPlc();
- mainBusiness.InitHikRobot();
+ // mainBusiness.InitHikRobot();
}
}
private void Application_Exit(object sender, ExitEventArgs e)
diff --git a/Aucma.Scada.UI/MainWindow.xaml b/Aucma.Scada.UI/MainWindow.xaml
index 6763e243..36d15979 100644
--- a/Aucma.Scada.UI/MainWindow.xaml
+++ b/Aucma.Scada.UI/MainWindow.xaml
@@ -116,6 +116,12 @@
+
+
+
+
+
+
diff --git a/Aucma.Scada.UI/Page/AssemblyPlan/AssemblyPlanControl.xaml b/Aucma.Scada.UI/Page/AssemblyPlan/AssemblyPlanControl.xaml
index 6b2fe8a1..17b7eb9a 100644
--- a/Aucma.Scada.UI/Page/AssemblyPlan/AssemblyPlanControl.xaml
+++ b/Aucma.Scada.UI/Page/AssemblyPlan/AssemblyPlanControl.xaml
@@ -9,7 +9,7 @@
mc:Ignorable="d" FontFamily="Microsoft YaHei" Background="#1152AC"
d:DesignHeight="750" d:DesignWidth="1920" >
-
+