diff --git a/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.AssemblyInfo.cs b/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.AssemblyInfo.cs index 2aa8fa0f..a0a51780 100644 --- a/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.AssemblyInfo.cs +++ b/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.AssemblyInfo.cs @@ -14,7 +14,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("Admin.Core.Common")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b14cee841cc126714bd9974bfb490340b0c3a348")] [assembly: System.Reflection.AssemblyProductAttribute("Admin.Core.Common")] [assembly: System.Reflection.AssemblyTitleAttribute("Admin.Core.Common")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.AssemblyInfoInputs.cache b/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.AssemblyInfoInputs.cache index b3b30e6b..90a3f1b9 100644 --- a/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.AssemblyInfoInputs.cache +++ b/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.AssemblyInfoInputs.cache @@ -1 +1 @@ -3c08b2a6f95957043123cba0d01dcd1675663fc7 +084e48044896d89835d97ecf2b6482131ddb1364494a27aefb0b1990a1319ddf diff --git a/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.GeneratedMSBuildEditorConfig.editorconfig b/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.GeneratedMSBuildEditorConfig.editorconfig index e43b7078..124dffb6 100644 --- a/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.GeneratedMSBuildEditorConfig.editorconfig +++ b/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.GeneratedMSBuildEditorConfig.editorconfig @@ -8,4 +8,6 @@ build_property.PlatformNeutralAssembly = build_property.EnforceExtendedAnalyzerRules = build_property._SupportedPlatformList = Linux,macOS,Windows build_property.RootNamespace = Admin.Core.Common -build_property.ProjectDir = E:\c#\AUCMA\new\Admin.Core.Common\ +build_property.ProjectDir = D:\Project\gitea\AUCMA\SCADA\Admin.Core.Common\ +build_property.EnableComHosting = +build_property.EnableGeneratedComInterfaceComImportInterop = diff --git a/Admin.Core.RealTimeService/Admin.Core.RealTimeService.csproj b/Admin.Core.RealTimeService/Admin.Core.RealTimeService.csproj index 0289941a..3d3e5455 100644 --- a/Admin.Core.RealTimeService/Admin.Core.RealTimeService.csproj +++ b/Admin.Core.RealTimeService/Admin.Core.RealTimeService.csproj @@ -38,8 +38,4 @@ - - - - diff --git a/Admin.Core.RealTimeService/Startup.cs b/Admin.Core.RealTimeService/Startup.cs index cad00ac8..6aa8ee29 100644 --- a/Admin.Core.RealTimeService/Startup.cs +++ b/Admin.Core.RealTimeService/Startup.cs @@ -57,11 +57,7 @@ namespace Admin.Core.RealTimeService //AutoMapper services.AddAutoMapperSetup(); //PLC - //services.AddPlcSetup(); - //任务调度 - //services.AddJobSetup(); - //任务 - services.AddTouchSocketSetup(); + services.AddPlcSetup(); //支持编码大全 例如:支持 System.Text.Encoding.GetEncoding("GB2312") System.Text.Encoding.GetEncoding("GB18030") Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); } @@ -82,11 +78,12 @@ namespace Admin.Core.RealTimeService /// /// /// - public void Configure(IApplicationBuilder app, ITouchSocketService socket) + public void Configure(IApplicationBuilder app, IRunPlcService runPlcService, ITouchSocketService socket) { // 使用静态文件 app.UseStaticFiles(); - app.UseTouchSocketMildd(socket); + //PLC + app.UsePlcMildd(runPlcService); } #region 注册服务 diff --git a/Admin.Core.RealTimeService/appsettings.json b/Admin.Core.RealTimeService/appsettings.json index 84b656bb..0f17711a 100644 --- a/Admin.Core.RealTimeService/appsettings.json +++ b/Admin.Core.RealTimeService/appsettings.json @@ -181,27 +181,19 @@ "PLCServer": [ { "Id": 1, - "EquipName": "MCPlc1", - "IP": "10.10.93.151", - "Port": 5002 - }, - { - "Id": 1, - "EquipName": "MCPlc2", - "IP": "10.10.93.152", - "Port": 5002 - }, - { - "Id": 1, - "EquipName": "MCPlc3", - "IP": "10.10.93.153", - "Port": 5002 + "EquipName": "foamLine1Plc", + "PlcType": "Siemens", + "Enabled": true, + "IP": "10.10.93.21", + "Port": 102 }, { - "Id": 1, - "EquipName": "MCPlc4", - "IP": "10.10.93.154", - "Port": 5002 + "Id": 2, + "EquipName": "foamLine2Plc", + "PlcType": "Siemens", + "Enabled": true, + "IP": "10.10.93.1", + "Port": 102 } ], "IpRateLimiting": { diff --git a/Aucma.Core.BoxFoam/Business/InStoreBusiness.cs b/Aucma.Core.BoxFoam/Business/InStoreBusiness.cs index a139d8ed..b6657db3 100644 --- a/Aucma.Core.BoxFoam/Business/InStoreBusiness.cs +++ b/Aucma.Core.BoxFoam/Business/InStoreBusiness.cs @@ -156,11 +156,16 @@ namespace Aucma.Core.BoxFoam.Business bool result= obj.plc.WriteString("DB200.132", materialCode);//鍐欏叆鐗╂枡鍙 if (result) { - Thread.Sleep(2500); - int space = obj.plc.ReadInt16("DB200.438");//璇诲彇璐ч亾鍙凤紝澶х害1.5s 鍙互鑾峰彇 - Console.WriteLine($"鐗╂枡MES鐮侊細{materialBarCode}锛屻嬪叆搴撹揣閬擄細{space}"); - logHelper.Info($"鐗╂枡MES鐮侊細{materialBarCode}锛屻嬪叆搴撹揣閬擄細{space}"); - LogDelegateEvent?.Invoke($"鐗╂枡MES鐮侊細{materialBarCode}锛屻嬬墿鏂欑爜锛歿materialCode}", "White"); + int space = 0; + do + { + space = obj.plc.ReadInt16("DB200.438");//璇诲彇璐ч亾鍙凤紝澶х害1.5s 鍙互鑾峰彇 + Console.WriteLine($"鐗╂枡鍏ュ簱璐ч亾锛歿space}"); + } while (space==0); + + Console.WriteLine($"鐗╂枡MES鐮侊細{materialBarCode}銆嬪叆搴撹揣閬擄細{space}"); + logHelper.Info($"鐗╂枡MES鐮侊細{materialBarCode}銆嬪叆搴撹揣閬擄細{space}"); + LogDelegateEvent?.Invoke($"鐗╂枡MES鐮侊細{materialBarCode}銆嬬墿鏂欑爜锛歿materialCode}", "White"); //鏇存柊璐ч亾鍏ュ簱 await EnterStore(materialBarCode, space); //鏇存柊杩囩偣鏁 diff --git a/Aucma.Core.BoxFoam/Business/TeamSwitchBusiness.cs b/Aucma.Core.BoxFoam/Business/TeamSwitchBusiness.cs index 0b226f43..bcf96c1c 100644 --- a/Aucma.Core.BoxFoam/Business/TeamSwitchBusiness.cs +++ b/Aucma.Core.BoxFoam/Business/TeamSwitchBusiness.cs @@ -159,7 +159,7 @@ namespace Aucma.Core.BoxFoam.Business var flag = obj1.plc.WriteBool("M6.0", true);//鎹㈢彮 鏁版嵁娓呯┖ Thread.Sleep(500); obj1.plc.WriteBool("M6.0", false);//鏁版嵁娓呯┖鍚庡浣 - Console.WriteLine($"鐝粍鍒囨崲娓呯┖1~6鍖轰骇閲忔暟鎹細{(flag == true ? "鎴愬姛" : "澶辫触")}"); + Console.WriteLine($"銆恵DateTime.Now}銆戠彮缁勫垏鎹㈡竻绌1~6鍖轰骇閲忔暟鎹細{(flag == true ? "鎴愬姛" : "澶辫触")}"); log.Warn($"鐝粍鍒囨崲娓呯┖1~6鍖轰骇閲忔暟鎹細{(flag == true ? "鎴愬姛" : "澶辫触")}"); } } @@ -171,7 +171,7 @@ namespace Aucma.Core.BoxFoam.Business bool flag = obj2.plc.WriteBool("M6.0", true);//鎹㈢彮 鏁版嵁娓呯┖ Thread.Sleep(500); obj2.plc.WriteBool("M6.0", false);//鏁版嵁娓呯┖鍚庡浣 - Console.WriteLine($"鐝粍鍒囨崲娓呯┖7~12鍖轰骇閲忔暟鎹細{(flag == true ? "鎴愬姛" : "澶辫触")}"); + Console.WriteLine($"銆恵DateTime.Now}銆戠彮缁勫垏鎹㈡竻绌7~12鍖轰骇閲忔暟鎹細{(flag == true ? "鎴愬姛" : "澶辫触")}"); log.Warn($"鐝粍鍒囨崲娓呯┖7~12鍖轰骇閲忔暟鎹細{(flag == true ? "鎴愬姛" : "澶辫触")}"); } } diff --git a/Aucma.Core.BoxFoam/ViewModels/MainWindowViewModel.cs b/Aucma.Core.BoxFoam/ViewModels/MainWindowViewModel.cs index aa44db6c..a10e728d 100644 --- a/Aucma.Core.BoxFoam/ViewModels/MainWindowViewModel.cs +++ b/Aucma.Core.BoxFoam/ViewModels/MainWindowViewModel.cs @@ -18,6 +18,7 @@ using System.Threading; using System.Threading.Tasks; using System.Windows; using System.Windows.Threading; +using static ICSharpCode.SharpZipLib.Zip.ExtendedUnixData; namespace Aucma.Core.BoxFoam.ViewModels { @@ -35,6 +36,7 @@ namespace Aucma.Core.BoxFoam.ViewModels MonitorPageView monitorPage = new MonitorPageView();//浠诲姟鐩戞帶 FoamMachinesPageView foamMachinesPageView = new FoamMachinesPageView(); bool startflag = true; + bool flag2 = true; public MainWindowViewModel() { UserContent = firstPage; @@ -46,6 +48,7 @@ namespace Aucma.Core.BoxFoam.ViewModels { await init(); await RefreshTeamTime();//鐝粍鏃堕棿 + await ClearProduct(); }); TeamSwitchBusiness teamSwitchBusiness = new TeamSwitchBusiness(); @@ -496,66 +499,6 @@ namespace Aucma.Core.BoxFoam.ViewModels { DateTime now = DateTime.Now; CurrentDateTime = now.ToString("yyyy-MM-dd HH:mm:ss"); - //DateTime scheduledTime = new DateTime(now.Year, now.Month, now.Day, 20, 00, 00); - //string date = scheduledTime.ToString("yyyy-MM-dd HH:mm:ss"); - //Console.WriteLine($"鐝粍鍒囨崲娓呯┖浜ч噺鏃堕棿澶滅彮锛歿CurrentDateTime.Equals(date)}"); - //if (CurrentDateTime.Equals(date)) - //{ - // var obj1 = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("foamLine1Plc")); - // if (obj1 != null) - // { - // if (obj1.plc.IsConnected) - // { - // var flag = obj1.plc.WriteBool("M6.0", true);//鎹㈢彮 鏁版嵁娓呯┖ - // Thread.Sleep(500); - // obj1.plc.WriteBool("M6.0", false);//鎹㈢彮 鏁版嵁娓呯┖ - // Console.WriteLine($"鐝粍鍒囨崲娓呯┖1~6鍖轰骇閲忔暟鎹細{(flag == true ? "鎴愬姛" : "澶辫触")}"); - // log.Warn($"鐝粍鍒囨崲娓呯┖1~6鍖轰骇閲忔暟鎹細{(flag == true ? "鎴愬姛" : "澶辫触")}"); - // } - // } - // var obj2 = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("foamLine2Plc")); - // if (obj2 != null) - // { - // if (obj2.plc.IsConnected) - // { - // bool flag = obj2.plc.WriteBool("M6.0", true);//鎹㈢彮 鏁版嵁娓呯┖ - // Thread.Sleep(500); - // obj2.plc.WriteBool("M6.0", false);//鎹㈢彮 鏁版嵁娓呯┖ - // Console.WriteLine($"鐝粍鍒囨崲娓呯┖7~12鍖轰骇閲忔暟鎹細{(flag == true ? "鎴愬姛" : "澶辫触")}"); - // log.Warn($"鐝粍鍒囨崲娓呯┖7~12鍖轰骇閲忔暟鎹細{(flag == true ? "鎴愬姛" : "澶辫触")}"); - // } - // } - //} - //DateTime scheduledTime2 = new DateTime(now.Year, now.Month, now.Day, 8, 00, 00); - //string date2 = scheduledTime2.ToString("yyyy-MM-dd HH:mm:ss"); - //Console.WriteLine($"鐝粍鍒囨崲娓呯┖浜ч噺鏃堕棿鐧界彮锛歿CurrentDateTime.Equals(date2)}"); - //if (CurrentDateTime.Equals(date2)) - //{ - // var obj1 = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("foamLine1Plc")); - // if (obj1 != null) - // { - // if (obj1.plc.IsConnected) - // { - // var flag = obj1.plc.WriteBool("M6.0", true);//鎹㈢彮 鏁版嵁娓呯┖ - // Thread.Sleep(500); - // obj1.plc.WriteBool("M6.0", false);//鎹㈢彮 鏁版嵁娓呯┖ - // Console.WriteLine($"鐝粍鍒囨崲娓呯┖浜ч噺鏃堕棿澶滅彮锛歿(flag == true ? "鎴愬姛" : "澶辫触")}"); - // log.Warn($"鐝粍鍒囨崲娓呯┖1~6鍖轰骇閲忔暟鎹細{(flag == true ? "鎴愬姛" : "澶辫触")}"); - // } - // } - // var obj2 = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("foamLine2Plc")); - // if (obj2 != null) - // { - // if (obj2.plc.IsConnected) - // { - // bool flag = obj2.plc.WriteBool("M6.0", true);//鎹㈢彮 鏁版嵁娓呯┖ - // Thread.Sleep(500); - // obj2.plc.WriteBool("M6.0", false);//鎹㈢彮 鏁版嵁娓呯┖ - // Console.WriteLine($"鐝粍鍒囨崲娓呯┖浜ч噺鏃堕棿澶滅彮锛歿(flag == true ? "鎴愬姛" : "澶辫触")}"); - // log.Warn($"鐝粍鍒囨崲娓呯┖7~12鍖轰骇閲忔暟鎹細{(flag == true ? "鎴愬姛" : "澶辫触")}"); - // } - // } - //} } catch (Exception ex) { @@ -572,23 +515,90 @@ namespace Aucma.Core.BoxFoam.ViewModels } #endregion - #region MyRegion - //private void Timer_Tick(object sender, EventArgs e) - //{ - // DateTime now = DateTime.Now; - - // // 鍒ゆ柇褰撳墠鏄惁鏄櫧鐝椂闂存 - // if (now.Hour >= 8 && now.Hour < 20) - // { - // ShiftStr = $"鐧界彮 08鐐-20鐐"; - // } - // else - // { - - // ShiftStr = $"澶滅彮 20鐐-08鐐"; - // } - // CurrentDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); - //} + #region 瀹氭椂娓呴櫎浜ч噺 + private Task ClearProduct() + { + while (true) + { + if (flag2) + { + flag2 = false; + try + { + DateTime now = DateTime.Now; + string date = now.ToString("yyyy-MM-dd HH:mm:ss"); + DateTime scheduledTime = new DateTime(now.Year, now.Month, now.Day, 20, 00, 00); + string sTime = scheduledTime.ToString("yyyy-MM-dd HH:mm:ss"); + Console.WriteLine($"瀹氭椂鐝粍鍒囨崲娓呯┖浜ч噺鏃堕棿澶滅彮锛歿sTime.Equals(date)}"); + if (sTime.Equals(date)) + { + var obj1 = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("foamLine1Plc")); + if (obj1 != null) + { + if (obj1.plc.IsConnected) + { + bool flag = obj1.plc.WriteBool("M6.0", true);//鎹㈢彮 鏁版嵁娓呯┖ + Thread.Sleep(500); + bool flag1 = obj1.plc.WriteBool("M6.0", false);//鎹㈢彮 鏁版嵁娓呯┖ + Console.WriteLine($"鐝粍鍒囨崲娓呯┖1~6鍖轰骇閲忔暟鎹細锛歿flag}:{flag1}"); + log.Warn($"瀹氭椂鐝粍鍒囨崲娓呯┖1~6鍖轰骇閲忔暟鎹細{(flag == true ? "鎴愬姛" : "澶辫触")}"); + } + } + var obj2 = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("foamLine2Plc")); + if (obj2 != null) + { + if (obj2.plc.IsConnected) + { + bool flag = obj2.plc.WriteBool("M6.0", true);//鎹㈢彮 鏁版嵁娓呯┖ + Thread.Sleep(500); + bool flag1 = obj2.plc.WriteBool("M6.0", false);//鎹㈢彮 鏁版嵁娓呯┖ + Console.WriteLine($"鐝粍鍒囨崲娓呯┖7~12鍖轰骇閲忔暟鎹細{flag}:{flag1}"); + log.Warn($"瀹氭椂鐝粍鍒囨崲娓呯┖7~12鍖轰骇閲忔暟鎹細{(flag == true ? "鎴愬姛" : "澶辫触")}"); + } + } + } + DateTime scheduledTime2 = new DateTime(now.Year, now.Month, now.Day, 8, 00, 00); + string date2 = scheduledTime2.ToString("yyyy-MM-dd HH:mm:ss"); + Console.WriteLine($"瀹氭椂鐝粍鍒囨崲娓呯┖浜ч噺鏃堕棿鐧界彮锛歿sTime.Equals(date2)}"); + if (sTime.Equals(date2)) + { + var obj1 = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("foamLine1Plc")); + if (obj1 != null) + { + if (obj1.plc.IsConnected) + { + var flag = obj1.plc.WriteBool("M6.0", true);//鎹㈢彮 鏁版嵁娓呯┖ + Thread.Sleep(500); + var flag1 = obj1.plc.WriteBool("M6.0", false);//鎹㈢彮 鏁版嵁娓呯┖ + Console.WriteLine($"鐝粍鍒囨崲娓呯┖浜ч噺鏃堕棿澶滅彮锛歿flag}:{flag1}"); + log.Warn($"瀹氭椂鐝粍鍒囨崲娓呯┖1~6鍖轰骇閲忔暟鎹細{(flag1 == true ? "鎴愬姛" : "澶辫触")}"); + } + } + var obj2 = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("foamLine2Plc")); + if (obj2 != null) + { + if (obj2.plc.IsConnected) + { + bool flag = obj2.plc.WriteBool("M6.0", true);//鎹㈢彮 鏁版嵁娓呯┖ + Thread.Sleep(500); + bool flag2 = obj2.plc.WriteBool("M6.0", false);//鎹㈢彮 鏁版嵁娓呯┖ + Console.WriteLine($"鐝粍鍒囨崲娓呯┖浜ч噺鏃堕棿澶滅彮锛歿flag}:{flag2}"); + log.Warn($"瀹氭椂鐝粍鍒囨崲娓呯┖7~12鍖轰骇閲忔暟鎹細{(flag == true ? "鎴愬姛" : "澶辫触")}"); + } + } + } + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + } + finally + { + startflag = true; + } + } + } + } #endregion } }