diff --git a/.vs/HighWayIot/FileContentIndex/1f3f919f-1cf2-49fa-9364-33aa2095d8ef.vsidx b/.vs/HighWayIot/FileContentIndex/1f3f919f-1cf2-49fa-9364-33aa2095d8ef.vsidx deleted file mode 100644 index 4a93049e..00000000 Binary files a/.vs/HighWayIot/FileContentIndex/1f3f919f-1cf2-49fa-9364-33aa2095d8ef.vsidx and /dev/null differ diff --git a/.vs/HighWayIot/FileContentIndex/40f19310-04eb-448e-b832-5aa0364abd39.vsidx b/.vs/HighWayIot/FileContentIndex/40f19310-04eb-448e-b832-5aa0364abd39.vsidx new file mode 100644 index 00000000..68ad685b Binary files /dev/null and b/.vs/HighWayIot/FileContentIndex/40f19310-04eb-448e-b832-5aa0364abd39.vsidx differ diff --git a/.vs/HighWayIot/FileContentIndex/418bae13-df2b-437a-8c1b-b025311227e4.vsidx b/.vs/HighWayIot/FileContentIndex/418bae13-df2b-437a-8c1b-b025311227e4.vsidx new file mode 100644 index 00000000..b84d8b97 Binary files /dev/null and b/.vs/HighWayIot/FileContentIndex/418bae13-df2b-437a-8c1b-b025311227e4.vsidx differ diff --git a/.vs/HighWayIot/FileContentIndex/75488deb-b8a0-4b6d-a2fd-9897844a8a00.vsidx b/.vs/HighWayIot/FileContentIndex/75488deb-b8a0-4b6d-a2fd-9897844a8a00.vsidx new file mode 100644 index 00000000..cb5e496f Binary files /dev/null and b/.vs/HighWayIot/FileContentIndex/75488deb-b8a0-4b6d-a2fd-9897844a8a00.vsidx differ diff --git a/.vs/HighWayIot/v17/.suo b/.vs/HighWayIot/v17/.suo index e8fa409e..6b1d57f3 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 f4be7a21..c70f676c 100644 --- a/Aucma.Scada.Business/AssemblyPlanBusiness.cs +++ b/Aucma.Scada.Business/AssemblyPlanBusiness.cs @@ -57,7 +57,7 @@ namespace Aucma.Scada.Business /// 下传执行计划 /// /// - public delegate void NextPassExecutePlanInfo(ExecutePlanInfo planInfo); + public delegate void NextPassExecutePlanInfo(ExecutePlanInfo planInfo,BaseSpaceInfo spaceInfo = null); public event NextPassExecutePlanInfo NextPassExecutePlanInfoEvent; #endregion @@ -121,7 +121,7 @@ namespace Aucma.Scada.Business /// /// /// - public bool PlanTransmitByProductPlan(string productPlanCode, int transmitAmount) + public bool PlanTransmitByProductPlan(string productPlanCode, int transmitAmount,BaseSpaceInfo spaceInfo = null) { bool result = false; try @@ -147,7 +147,7 @@ namespace Aucma.Scada.Business GetEexecutePlanInfosByProductLineCode(); // 直接下达 2023-12-20 - ExecutePlanInfo_NextPass(executePlanInfo.executePlanCode, ""); + ExecutePlanInfo_NextPass(executePlanInfo.executePlanCode, "",spaceInfo); } } } @@ -233,7 +233,7 @@ namespace Aucma.Scada.Business /// 下传计划 /// /// - public ExecutePlanInfo ExecutePlanInfo_NextPass(string planCode, string nowPlanCode) + public ExecutePlanInfo ExecutePlanInfo_NextPass(string planCode, string nowPlanCode,BaseSpaceInfo spaceInfo = null) { ExecutePlanInfo planInfo = null; try @@ -254,7 +254,7 @@ namespace Aucma.Scada.Business if (planInfo != null) { //传给出库 - NextPassExecutePlanInfoEvent?.Invoke(planInfo); + NextPassExecutePlanInfoEvent?.Invoke(planInfo,spaceInfo); planInfo.executeStatus = 2; planInfo.beginTime = DateTime.Now; diff --git a/Aucma.Scada.Business/InStoreBusiness.cs b/Aucma.Scada.Business/InStoreBusiness.cs index ea7ce686..c0e0fdc7 100644 --- a/Aucma.Scada.Business/InStoreBusiness.cs +++ b/Aucma.Scada.Business/InStoreBusiness.cs @@ -120,15 +120,21 @@ namespace Aucma.Scada.Business MvCodeHelper.RefreshLogMessageEvent += PrintLogInfoMessage; StartPassDown(); + //Task.Run(() => //{ - // Thread.Sleep(6000); + // Thread.Sleep(3000); // for (int i = 1; i < 2; i++) // { - // InStore("B24010181060282920010"); + // // 8302501181 8302500586 9 + // InStore("B2401018302500586001" + i); // Thread.Sleep(1000); // } - //}); + + // InStore("B2401018302501181001" + 1); + // Thread.Sleep(1000); + // InStore("B2401018302500889001" + 1); + // }); } #region delete 2024-01-04出库时堵塞入库 ,不需要堵塞整个库 @@ -344,7 +350,8 @@ namespace Aucma.Scada.Business } else { - PrintLogInfoMessage("未获取到需要下发的泡后入库任务"); + logHelper.Info("未获取到需要下发的泡后入库任务"); + // PrintLogInfoMessage("未获取到需要下发的泡后入库任务"); } } catch (Exception ex) @@ -436,11 +443,11 @@ namespace Aucma.Scada.Business RecordInstore recordInstore = new RecordInstore(); recordInstore.storeCode = taskInfo.storeCode; recordInstore.spaceCode = taskInfo.spaceCode; - recordInstore.materialCode = taskInfo.materialCode; - recordInstore.materialType = taskInfo.materialType; + recordInstore.materialCode = taskInfo.materialCode; + recordInstore.materialType = taskInfo.materialType; recordInstore.materialName = GetMaterialName(taskInfo.materialType); recordInstore.inStoreAmount = 1; - recordInstore.inStoreTime = DateTime.Now; + recordInstore.inStoreTime = DateTime.Now; recordInstore.barcodeCode = taskInfo.materialCode; _recordInStoreService.InsertRecordInStore(recordInstore); #endregion @@ -575,7 +582,7 @@ namespace Aucma.Scada.Business } catch (Exception ex) { - PrintLogErrorMessage("货道信息读取异常", ex); + PrintLogErrorMessage("货道信息plc读取异常", ex); } return result; diff --git a/Aucma.Scada.Business/InStoreTaskHandle.cs b/Aucma.Scada.Business/InStoreTaskHandle.cs index 35e4987e..34133d0c 100644 --- a/Aucma.Scada.Business/InStoreTaskHandle.cs +++ b/Aucma.Scada.Business/InStoreTaskHandle.cs @@ -1,10 +1,12 @@ using Aucma.Scada.Model.domain; +using HighWayIot.Common; using HighWayIot.Config; using HighWayIot.Log4net; using HighWayIot.Plc; using HighWayIot.Repository.service; using System; using System.Collections.Generic; +using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -39,6 +41,13 @@ namespace Aucma.Scada.Business private RegisterServices registerServices = RegisterServices.Instance; + private JsonChange json = JsonChange.Instance; + + /// + /// 已下传的任务信息 + /// + private List foamRearTaskInfos ; + /// /// 实时任务 /// @@ -48,7 +57,7 @@ namespace Aucma.Scada.Business #region 私有变量 private Dictionary _plcDictionary = new Dictionary(); - + private Dictionary foamRearKeyValuePairs = new Dictionary(); /// /// 泡后任务编号,PLC反馈后进行赋值 /// @@ -78,11 +87,52 @@ namespace Aucma.Scada.Business { _taskInfoService = registerServices.GetService(); _plcDictionary = _pool.GetAll(); - List taskList = _taskInfoService.GetTaskInfosForInstore(appConfig.foamStoreCode, appConfig.instoreTaskType, 2); - RealReadFinish(); + // 程序启动查询数据库 + foamRearTaskInfos = _taskInfoService.GetTaskInfosForInstore(appConfig.foamStoreCode, appConfig.instoreTaskType, 2); + foamRearTaskInfos = new List(); + + RealReadPlcSpace(); + SendHeart(); + // RealReadFinish(); change-入库完成信号改回监测在途数 + // test(); } + //public void test() + //{ + // Task.Run(() => + // { + // while (true) + // { + // List taskList = _taskInfoService.GetTaskInfosByStoreCode(new string[] { appConfig.foamStoreCode }, appConfig.instoreTaskType); + // Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} ======》 打印数据:{json.ModeToJson(taskList)}"); + // //Thread.Sleep(500); + // } + // }); + //} + + /// + /// 心跳 + /// + private void SendHeart() + { + Task.Run(() => + { + Thread.Sleep(3000); + IPlc _plc = _plcDictionary[appConfig.foamStoreCode]; - #region 判断入库是否完成 + if (_plc != null) + { + while (true) + { + _plc.writeInt32ByAddress("D7020",1); + Thread.Sleep(1000); + _plc.writeInt32ByAddress("D7020", 0); + Thread.Sleep(1000); + } + } + + }); + } + #region 判断入库是否完成 delete20240224-入库完成信号改回监测在途数 /// /// 实时读取入库完成信号 /// @@ -126,7 +176,9 @@ namespace Aucma.Scada.Business /// /// public void JudgeIsFinish(RealTaskInfo taskInfo,IPlc _plc,SpaceAddress spaceAddress) - { + { + // 测试方法,模拟plc,正式启用删除 + // _plc.writeInt32ByAddress(spaceAddress.inStoreFinish, 1); //读取入库完成反馈信号 if (_plc.readInt32ByAddress(spaceAddress.inStoreFinish) == 1) { @@ -134,10 +186,82 @@ namespace Aucma.Scada.Business InStoreFinsihEvent(taskInfo.taskCode); } } - #endregion + #endregion + + #region 监测PLC在途数量变化,完成入库任务 - #region 泡后入库任务下发处理 - public int SendFoamTask_InStore(RealTaskInfo taskInfo) + private void RealReadPlcSpace() + { + Thread.Sleep(5000); + Task.Run(() => + { + while (true) + { + RealReadShellPlcSpace(); + + Thread.Sleep(500); + } + }); + + } + + /// + /// 读取箱壳已下发任务的货道信息,读取后将货道编号及在途数量写入Dictionary进行比较,在途数减少则入库完成 + /// + private void RealReadShellPlcSpace() + { + if (foamRearTaskInfos != null && foamRearTaskInfos.Count>0) + { + + List spaceCodes = foamRearTaskInfos.Select(x => x.spaceCode).Distinct().ToList(); + + for (int i = 0; i < spaceCodes.Count; i++) + { + + string spaceCode = spaceCodes[i]; + + BaseSpaceInfo spaceInfo = new BaseSpaceInfo() { storeCode = appConfig.foamStoreCode, spaceCode = spaceCode }; + + spaceInfo = ReadSpaceInfoByPlc(spaceInfo); + + if (foamRearKeyValuePairs.ContainsKey(spaceInfo.spaceCode)) + { + foamRearKeyValuePairs.TryGetValue(spaceInfo.spaceCode, out int value); + //判断前次读取的数据和当前数据,如果前次数据大于当前数据则代表入库完成,然后筛选任务中对应货道的首个任务进行完成 + //如果前次数据不大于当前数据则更新字典中存放的数据 + if (value > spaceInfo.onRouteAmount) + { + //筛选任务 + var list = foamRearTaskInfos.Where(x => x.spaceCode == spaceInfo.spaceCode).ToList(); + if (list.Count > 0) + { + RealTaskInfo taskInfo = list.OrderBy(x => x.createTime).First(); + + InStoreFinsihEvent?.Invoke(taskInfo.taskCode); + + foamRearTaskInfos.Remove(taskInfo); + } + foamRearKeyValuePairs.Remove(spaceInfo.spaceCode); + } + else + { + foamRearKeyValuePairs[spaceInfo.spaceCode] = spaceInfo.onRouteAmount; + } + + } + else + { + foamRearKeyValuePairs.Add(spaceInfo.spaceCode, spaceInfo.onRouteAmount); + } + } + + } + } + #endregion + + + #region 泡后入库任务下发处理 + public int SendFoamTask_InStore(RealTaskInfo taskInfo) { int result = 0; try @@ -147,7 +271,9 @@ namespace Aucma.Scada.Business if (_plc != null) { if (_plc.IsConnected) - { + { + // 测试方法,模拟plc,正式启用删除 + // _plc.writeInt32ByAddress(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))); @@ -207,6 +333,8 @@ namespace Aucma.Scada.Business { do { + // 测试方法,模拟plc,正式启用删除 + // _plc.writeInt32ByAddress(plcConfig.in_foam_answer, 2); //读取PLC应答字为2时,上位机清空写入的入库内容 if (_plc.readInt32ByAddress(plcConfig.in_foam_answer) == 2) { @@ -217,7 +345,7 @@ namespace Aucma.Scada.Business // _plc.writeInt32ByAddress(plcConfig.in_foam_answer, 0); isFlag = false; - + foamRearTaskInfos.Add(taskInfo); InStoreAnswerEvent?.Invoke(appConfig.foamStoreCode, taskInfo.taskCode); } @@ -255,12 +383,11 @@ namespace Aucma.Scada.Business if (_plc != null) { - if (_plc.IsConnected) - { + spaceInfo.spaceStock = _plc.readInt32ByAddress(spaceAddress.onStore); spaceInfo.onRouteAmount = _plc.readInt32ByAddress(spaceAddress.onRoute); // spaceInfo.spaceStatus = _plc.readInt32ByAddress(spaceAddress.spaceStatus); - } + } return spaceInfo; diff --git a/Aucma.Scada.Business/OutStoreBusiness.cs b/Aucma.Scada.Business/OutStoreBusiness.cs index 2b69e98d..dba650a8 100644 --- a/Aucma.Scada.Business/OutStoreBusiness.cs +++ b/Aucma.Scada.Business/OutStoreBusiness.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; +using System.Windows.Forms; using static Aucma.Scada.Business.OutStoreTaskHandle; namespace Aucma.Scada.Business @@ -125,7 +126,7 @@ namespace Aucma.Scada.Business /// 接收下达的组装计划,根据BOM获取需要出库的泡后、内胆物料信息 /// /// - private void PlanHandle(ExecutePlanInfo planInfo) + private void PlanHandle(ExecutePlanInfo planInfo,BaseSpaceInfo spaceInfo = null) { lock (string.Empty) { @@ -143,7 +144,7 @@ namespace Aucma.Scada.Business 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); + OutStore(appConfig.foamStoreCode, bomInfo, planInfo.executePlanCode, taskCode,spaceInfo); Thread.Sleep(500); } } @@ -157,7 +158,7 @@ namespace Aucma.Scada.Business /// /// /// - private void OutStore(string storeCode, BaseBomInfo bomInfo, string planCode, string taskCode) + private void OutStore(string storeCode, BaseBomInfo bomInfo, string planCode, string taskCode,BaseSpaceInfo spaceInfo = null) { try { @@ -165,7 +166,10 @@ namespace Aucma.Scada.Business #region Delete By wenjy 2023-10-30 11:41:00 取消通过数据库获取货道数量、在途量,改为通过PLC获取货道信息 //BaseSpaceInfo spaceInfo = _spaceInfoService.OutStoreGetSpaceInfoByMaterialCode(storeCode, bomInfo.materialCode); #endregion - BaseSpaceInfo spaceInfo = GetSpaceInfoByMaterialType(storeCode, bomInfo.materialCode); + if(spaceInfo == null) + { + spaceInfo = GetSpaceInfoByMaterialType(storeCode, bomInfo.materialCode); + } if (spaceInfo != null) { PrintLogInfoMessage($"匹配货道:{spaceInfo.spaceName}"); @@ -208,6 +212,7 @@ namespace Aucma.Scada.Business { #region 出库任务赋值 RealTaskInfo realTaskInfo = new RealTaskInfo(); + // 执行计划编号 realTaskInfo.planCode = planCode; realTaskInfo.taskType = 2; realTaskInfo.taskCode = taksCode; @@ -249,6 +254,7 @@ namespace Aucma.Scada.Business return result; } + /// /// 根据创建时间获取第一个货道明细 /// @@ -337,14 +343,14 @@ namespace Aucma.Scada.Business if (taskInfo != null) { - PrintLogInfoMessage($"下发泡后出库任务:{taskInfo.taskCode};仓库{taskInfo.storeCode};货道:{taskInfo.spaceCode}"); + // PrintLogInfoMessage($"下发泡后出库任务:{taskInfo.taskCode};仓库{taskInfo.storeCode};货道:{taskInfo.spaceCode}"); int result = taskHandleBusiness.SendFoamTask_OutStore(taskInfo); if (result==1) { - PrintLogInfoMessage($"泡后出库任务:{taskInfo.taskCode};下发成功,等待PLC执行反馈"); + PrintLogInfoMessage($"出库任务:{taskInfo.taskCode};下发成功,等待PLC执行反馈"); semaphore.Wait();//一直堵塞直到信号量释放 - PrintLogInfoMessage($"泡后出库任务:{taskInfo.taskCode};开始执行"); + PrintLogInfoMessage($"出库任务:{taskInfo.taskCode};开始执行"); taskInfo.taskStatus = 2; _taskInfoService.UpdateTaskInfo(taskInfo); @@ -616,7 +622,19 @@ namespace Aucma.Scada.Business BaseSpaceInfo spaceInfo = _spaceInfoService.GetSpaceInfoBySpaceCode(storeCode, spaceCode); if (spaceInfo.spaceStock > 0) { - result = this.CreateOutStoreTask(spaceInfo, System.Guid.NewGuid().ToString("N").Substring(0, 10), System.Guid.NewGuid().ToString("N").Substring(0, 10), 1); + #region 创建mes执行任务关联生产计划 + var productPlanInfo = _productPlanInfoService.GetProductPlanInfosByMaterialCode(spaceInfo.materialType); + if(productPlanInfo != null) + { + result = assemblyPlanBusiness.PlanTransmitByProductPlan(productPlanInfo.planCode, 1,spaceInfo); + } + #endregion + else + { + // 不关联生产计划 + result = this.CreateOutStoreTask(spaceInfo, System.Guid.NewGuid().ToString("N").Substring(0, 10), System.Guid.NewGuid().ToString("N").Substring(0, 10), 1); + } + } else { @@ -630,6 +648,56 @@ namespace Aucma.Scada.Business return result; } + + /// + /// 整道出 + /// + /// + /// + /// + public bool OutAllBySpaceCode(string storeCode, string spaceCode) + { + bool result = false; + try + { + BaseSpaceInfo spaceInfo = _spaceInfoService.GetSpaceInfoBySpaceCode(storeCode, spaceCode); + if (spaceInfo.spaceStock > 0) + { + #region 创建mes执行任务关联生产计划 + var productPlanInfo = _productPlanInfoService.GetProductPlanInfosByMaterialCode(spaceInfo.materialType); + if (productPlanInfo != null) + { + result = assemblyPlanBusiness.PlanTransmitByProductPlan(productPlanInfo.planCode, spaceInfo.spaceStock); + } + #endregion + else + { + 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); + if (!result) + { + return false; + } + } + + } + + } + else + { + PrintLogInfoMessage($"仓库:{storeCode};货道:{spaceCode};出库失败:库存不足"); + } + } + catch (Exception ex) + { + logHelper.Error("根据货道出一个异常", ex); + + } + return result; + } + + /// /// 日志输出,界面刷新同时记录文件 /// diff --git a/Aucma.Scada.Business/OutStoreTaskHandle.cs b/Aucma.Scada.Business/OutStoreTaskHandle.cs index 400515fa..329d0487 100644 --- a/Aucma.Scada.Business/OutStoreTaskHandle.cs +++ b/Aucma.Scada.Business/OutStoreTaskHandle.cs @@ -145,6 +145,7 @@ namespace Aucma.Scada.Business #endregion + #region 泡后出库任务下发处理 /// /// 泡后出库任务下发 diff --git a/Aucma.Scada.Business/bin/Debug/Aucma.Scada.Business.dll b/Aucma.Scada.Business/bin/Debug/Aucma.Scada.Business.dll index 0fa82115..0dfbd025 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 5bd10de3..a351dcac 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 938e998d..60979f25 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 dd2a0cce..13d2fe71 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.Repository.dll b/Aucma.Scada.Business/bin/Debug/HighWayIot.Repository.dll index 0dc4089b..27d32506 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 5cc39dda..c2debb65 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 19d347f8..8e70a908 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 0fa82115..0dfbd025 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 5bd10de3..a351dcac 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 a0b895c0..543d8bf1 100644 --- a/Aucma.Scada.HikRobot/MvCodeHelper.cs +++ b/Aucma.Scada.HikRobot/MvCodeHelper.cs @@ -14,6 +14,7 @@ namespace Aucma.Core.Scanner { public class MvCodeHelper { + private static LogHelper logHelper = LogHelper.Instance; private static AppConfig appConfig = AppConfig.Instance; public static bool m_bGrabbing = true; #region 委托事件 @@ -40,19 +41,27 @@ namespace Aucma.Core.Scanner /// public static bool ConnectionStatus(string ip) { - // 遍历所有已打开相机 - foreach (KeyValuePair hashmap in m_cMyDevices) + try { - if (ip.Equals(hashmap.Value)) + // 遍历所有已打开相机 + foreach (KeyValuePair hashmap in m_cMyDevices) { - return true; + if (ip.Equals(hashmap.Value)) + { + return true; + } } + // 没有连接上,重新获取并创建设备 + Task.Run(() => + { + DeviceListAcq(); + }); + } - // 没有连接上,重新获取并创建设备 - Task.Run(() => + catch (Exception ex) { - DeviceListAcq(); - }); + logHelper.Error(ex.Message.ToString()); + } return false; } #endregion @@ -65,21 +74,26 @@ namespace Aucma.Core.Scanner { try { - RefreshLogMessageEvent?.Invoke("获取扫码器设备列表,进入DeviceListAcq()方法"); - + // RefreshLogMessageEvent?.Invoke("获取扫码器设备列表,进入DeviceListAcq()方法"); + // 扫码器ip + string scannerIp = appConfig.foamHikRobotIp; + if (string.IsNullOrEmpty(scannerIp)) return; System.GC.Collect(); m_stDeviceList.nDeviceNum = 0; // 获取设备列表 int nRet = MvCodeReader.MV_CODEREADER_EnumDevices_NET(ref m_stDeviceList, MvCodeReader.MV_CODEREADER_GIGE_DEVICE); if (0 != nRet) { + logHelper.Info("获取扫码器列表失败,扫码器错误码:" + nRet); RefreshLogMessageEvent?.Invoke("获取扫码器列表失败,扫码器错误码:" + nRet); + return; } if (0 == m_stDeviceList.nDeviceNum) { - RefreshLogMessageEvent?.Invoke("获取扫码器数量为0,请检查扫码器连接:"); + + // RefreshLogMessageEvent?.Invoke("获取扫码器数量为0,请检查扫码器连接:"); return; } @@ -96,14 +110,14 @@ namespace Aucma.Core.Scanner // 获取ip string ip = ((stGigEDeviceInfo.nCurrentIp & 0xff000000) >> 24) + "." + ((stGigEDeviceInfo.nCurrentIp & 0x00ff0000) >> 16) + "." + ((stGigEDeviceInfo.nCurrentIp & 0x0000ff00) >> 8) + "." + (stGigEDeviceInfo.nCurrentIp & 0x000000ff); - // Console.WriteLine($"打印扫码设备信息,下标:{i};IP:{ip}"); - Console.Write("扫码器设备[" + i + "],ip:" + ip); - // 创建第i个设备 - stDevInfo = (MvCodeReader.MV_CODEREADER_DEVICE_INFO)Marshal.PtrToStructure(m_stDeviceList.pDeviceInfo[i], typeof(MvCodeReader.MV_CODEREADER_DEVICE_INFO)); + // 只连接配置的扫码器 + if (!scannerIp.Equals(ip)) continue; + // 创建第i个设备 + stDevInfo = (MvCodeReader.MV_CODEREADER_DEVICE_INFO)Marshal.PtrToStructure(m_stDeviceList.pDeviceInfo[i], typeof(MvCodeReader.MV_CODEREADER_DEVICE_INFO)); nRet = m_cMyDevice.MV_CODEREADER_CreateHandle_NET(ref stDevInfo);//创建设备 if (MvCodeReader.MV_CODEREADER_OK != nRet) { - Console.WriteLine("创建第" + i + "个扫码器设备失败,ip:" + ip); + // Console.WriteLine("创建第" + i + "个扫码器设备失败,ip:" + ip); return; } // 打开设备 @@ -111,15 +125,15 @@ namespace Aucma.Core.Scanner if (MvCodeReader.MV_CODEREADER_OK != nRet) { m_cMyDevice.MV_CODEREADER_DestroyHandle_NET(); - Console.WriteLine("Device open fail!"); + // Console.WriteLine("Device open fail!"); return; } - RefreshLogMessageEvent?.Invoke("创建并打开第" + i + "个扫码器设备成功,ip:" + ip); + // RefreshLogMessageEvent?.Invoke("创建并打开第" + i + "个扫码器设备成功,ip:" + ip); //设置触发模式 nRet = m_cMyDevice.MV_CODEREADER_SetEnumValue_NET("TriggerMode", (uint)MvCodeReader.MV_CODEREADER_TRIGGER_MODE.MV_CODEREADER_TRIGGER_MODE_ON); if (MvCodeReader.MV_CODEREADER_OK != nRet) { - Console.WriteLine("设置触发模式失败"); + // Console.WriteLine("设置触发模式失败"); return; } //添加到集合 @@ -129,7 +143,7 @@ namespace Aucma.Core.Scanner } catch (Exception ex) { - Console.WriteLine("获取和创建设备异常:" + ex); + logHelper.Error("获取和创建扫码器设备异常:" + ex.Message.ToString()); } } #endregion @@ -178,10 +192,11 @@ namespace Aucma.Core.Scanner Array.Copy(stBcrResult.stBcrInfoEx2[i].chCode, buffer, 22); } string strCode = Encoding.GetEncoding("UTF-8").GetString(buffer).Trim().TrimEnd('\0'); - RefreshLogMessageEvent?.Invoke("相机ip:" + hashmap.Value + " Get CodeNum: " + "CodeNum[" + i.ToString() + "], CodeString[" + strCode + "]"); + // RefreshLogMessageEvent?.Invoke("相机ip:" + hashmap.Value + " Get CodeNum: " + "CodeNum[" + i.ToString() + "], CodeString[" + strCode + "]"); if (!string.IsNullOrEmpty(strCode)) { - // 获取到条码处理业务 + logHelper.Info("扫码器扫描到条码:"+strCode); + // 获取到条码处理业务 RefreshMaterialCodeStrEvent?.Invoke(strCode); } diff --git a/Aucma.Scada.HikRobot/bin/Debug/Aucma.Scada.HikRobot.dll b/Aucma.Scada.HikRobot/bin/Debug/Aucma.Scada.HikRobot.dll index 938e998d..60979f25 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 dd2a0cce..13d2fe71 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/obj/Debug/Aucma.Scada.HikRobot.csproj.AssemblyReference.cache b/Aucma.Scada.HikRobot/obj/Debug/Aucma.Scada.HikRobot.csproj.AssemblyReference.cache index bf972b7b..9ce4470a 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 938e998d..60979f25 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 dd2a0cce..13d2fe71 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.UI/MainWindow.xaml b/Aucma.Scada.UI/MainWindow.xaml index 0e8d1f04..6763e243 100644 --- a/Aucma.Scada.UI/MainWindow.xaml +++ b/Aucma.Scada.UI/MainWindow.xaml @@ -56,14 +56,19 @@ - + + + + + + + + diff --git a/Aucma.Scada.UI/Page/AssemblyPlan/AssemblyPlanControl.xaml b/Aucma.Scada.UI/Page/AssemblyPlan/AssemblyPlanControl.xaml index dc0ab637..6b2fe8a1 100644 --- a/Aucma.Scada.UI/Page/AssemblyPlan/AssemblyPlanControl.xaml +++ b/Aucma.Scada.UI/Page/AssemblyPlan/AssemblyPlanControl.xaml @@ -248,9 +248,9 @@ - + - + @@ -364,9 +364,9 @@ - + - + diff --git a/Aucma.Scada.UI/Page/AssemblyPlan/PlanInfoEditWindow.xaml b/Aucma.Scada.UI/Page/AssemblyPlan/PlanInfoEditWindow.xaml index 7ccc0c28..2d5b0a73 100644 --- a/Aucma.Scada.UI/Page/AssemblyPlan/PlanInfoEditWindow.xaml +++ b/Aucma.Scada.UI/Page/AssemblyPlan/PlanInfoEditWindow.xaml @@ -6,7 +6,7 @@ xmlns:local="clr-namespace:Aucma.Scada.UI.Page.AssemblyPlan" xmlns:local1="clr-namespace:Aucma.Scada.UI.Converter.AssemblyPlan" mc:Ignorable="d" - Title="MES生产计划" Height="650" Width="900" Name="window" WindowStartupLocation="CenterScreen" FontFamily="Microsoft YaHei" Background="#1152AC" + Title="MES生产计划" Height="650" Width="1000" Name="window" WindowStartupLocation="CenterScreen" FontFamily="Microsoft YaHei" Background="#1152AC" ResizeMode="NoResize" >