From ac7cbd1a528a4de7e0557105681e24111876a089 Mon Sep 17 00:00:00 2001 From: liuwf Date: Fri, 8 Dec 2023 13:58:51 +0800 Subject: [PATCH 1/3] change. --- Admin.Core.Extensions/ServiceExtensions/SqlsugarSetup.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Admin.Core.Extensions/ServiceExtensions/SqlsugarSetup.cs b/Admin.Core.Extensions/ServiceExtensions/SqlsugarSetup.cs index 85475618..3a36e163 100644 --- a/Admin.Core.Extensions/ServiceExtensions/SqlsugarSetup.cs +++ b/Admin.Core.Extensions/ServiceExtensions/SqlsugarSetup.cs @@ -1,5 +1,7 @@ 锘縰sing Admin.Core.Common; +using Admin.Core.Model; using Microsoft.Extensions.DependencyInjection; +using NPOI.SS.Formula.Functions; using SqlSugar; using System; using System.Collections.Generic; @@ -67,7 +69,9 @@ namespace Admin.Core.Extensions } ); }); - return new SqlSugarClient(listConfig); + SqlSugarClient client = new SqlSugarClient(listConfig); + // var childA = client.GetConnection("aucma_mes").Ado.SqlQuery("select * from BASE_BOMINFO where OBJ_ID='1'"); + return client; }); } From c162566b27b6092c8bcb243a72a0bfa0df8db760 Mon Sep 17 00:00:00 2001 From: liuwf Date: Fri, 8 Dec 2023 16:37:31 +0800 Subject: [PATCH 2/3] =?UTF-8?q?change=20-=20=E6=95=B0=E6=8D=AE=E5=BA=93,pl?= =?UTF-8?q?c,=E6=89=AB=E7=A0=81=E5=99=A8=E7=8A=B6=E6=80=81=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Aucma.Core.BoxFoam/Startup.cs | 8 +- .../ViewModels/MainWindowViewModel.cs | 225 +++++++++++++++-- Aucma.Core.BoxFoam/Views/MainWindow.xaml | 22 +- Aucma.Core.BoxFoam/appsettings.json | 17 +- .../ViewModels/MainWindowViewModel.cs | 10 +- Aucma.Core.DoorFoam/Startup.cs | 14 +- .../ViewModels/MainWindowViewModel.cs | 226 ++++++++++++++++-- Aucma.Core.DoorFoam/Views/MainWindow.xaml | 22 +- Aucma.Core.DoorFoam/appsettings.json | 26 +- Aucma.Core.Palletiz/Startup.cs | 7 +- .../ViewModels/MainWindowViewModel.cs | 224 +++++++++++++++-- Aucma.Core.Palletiz/Views/MainWindow.xaml | 24 +- Aucma.Core.Palletiz/appsettings.json | 17 +- .../ViewModels/MainWindowViewModel.cs | 2 +- 14 files changed, 724 insertions(+), 120 deletions(-) diff --git a/Aucma.Core.BoxFoam/Startup.cs b/Aucma.Core.BoxFoam/Startup.cs index 7b358d95..9346970d 100644 --- a/Aucma.Core.BoxFoam/Startup.cs +++ b/Aucma.Core.BoxFoam/Startup.cs @@ -8,6 +8,7 @@ using Admin.Core.Repository; using Admin.Core.Service; using Admin.Core.Tasks; using Aucma.Core.RunPlc; +using Aucma.Core.Scanner; using Autofac; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; @@ -61,6 +62,9 @@ namespace Aucma.Core.BoxFoam //注册业务服务 AddServices(services); + //扫码器 + services.AddScannerSetup(); + //任务调度 services.AddJobSetup(); //PLC @@ -85,7 +89,7 @@ namespace Aucma.Core.BoxFoam /// /// /// - public void Configure(IApplicationBuilder app, ISysTasksQzService tasksQzService, ISchedulerCenter schedulerCenter, IRunPlcService runPlcService)// + public void Configure(IApplicationBuilder app, ISysTasksQzService tasksQzService, ISchedulerCenter schedulerCenter, IRunPlcService runPlcService,IScannerService scannerService)// { // 使用静态文件 app.UseStaticFiles(); @@ -96,6 +100,8 @@ namespace Aucma.Core.BoxFoam app.UseQuartzJobMildd(tasksQzService, schedulerCenter); //PLC app.UsePlcMildd(runPlcService); + //开启扫码服务 + app.UseScannerMildd(scannerService); } #region 注册服务 diff --git a/Aucma.Core.BoxFoam/ViewModels/MainWindowViewModel.cs b/Aucma.Core.BoxFoam/ViewModels/MainWindowViewModel.cs index 11b3f847..c46e4f88 100644 --- a/Aucma.Core.BoxFoam/ViewModels/MainWindowViewModel.cs +++ b/Aucma.Core.BoxFoam/ViewModels/MainWindowViewModel.cs @@ -6,6 +6,10 @@ using System; using log4net; using System.Diagnostics; using System.Threading; +using Admin.Core.Common; +using Aucma.Core.PLc; +using Aucma.Core.Scanner; +using System.Linq; namespace Aucma.Core.BoxFoam.ViewModels { @@ -19,12 +23,82 @@ namespace Aucma.Core.BoxFoam.ViewModels private FoamPlanPageView foamPlanPageView = new FoamPlanPageView(); FoamMonitorPageView foamMonitorPageView = new FoamMonitorPageView(); FoamMachinesPageView foamMachinesPageView = new FoamMachinesPageView(); - + public MainWindowViewModel() { UserContent = firstPage; + init(); + } + public void init() + { + // 璁惧鐘舵佸埛鏂板畾鏃跺櫒 + System.Timers.Timer timer = new System.Timers.Timer(1000 * 5); + timer.Elapsed += new System.Timers.ElapsedEventHandler(RefreshStatus); + timer.AutoReset = true; + timer.Enabled = true; + timer.Start(); + } + + #region 璁惧鐘舵佸埛鏂 + /// + /// 璁惧鐘舵佸埛鏂 + /// + /// + /// + public void RefreshStatus(object sender, System.Timers.ElapsedEventArgs e) + { + RefreshMesDb(); + RefreshPlc(); + RefreshScanner(); + + } + /// + /// 鏁版嵁搴撶姸鎬佸埛鏂 + /// + /// + /// + public void RefreshMesDb() + { + MesDbState(true); } + + /// + /// plc鐘舵佸埛鏂 + /// + /// + /// + public void RefreshPlc() + { + var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("娉″墠搴揚lc")); + if (obj != null) + { + if (obj.plc.IsConnected) + { + PlcState(true); + } + else + { + PlcState(false); + } + } + else + { + PlcState(false); + } + } + /// + /// 鎵爜鍣ㄧ姸鎬佸埛鏂 + /// + /// + /// + public void RefreshScanner() + { + string ip1 = Appsettings.app("Middleware", "Scanner1", "Ip"); + bool flag1 = MvCodeHelper.ConnectionStatus(ip1); + Scanner1State(flag1); + } + #endregion #region 鏇存崲鐣岄潰 public System.Windows.Controls.UserControl _content; @@ -142,19 +216,70 @@ namespace Aucma.Core.BoxFoam.ViewModels break; } } - #endregion + #endregion + + #region MES鏁版嵁搴撶姸鎬 + /// + /// MES鏁版嵁搴-鏂囧瓧 + /// + public string _mesDbUIStatusWb; + public string MesDbUIStatusWb + { + get => _mesDbUIStatusWb; + set => SetProperty(ref _mesDbUIStatusWb, value); + } + /// + /// MES鏁版嵁搴-棰滆壊 + /// + public string _mesDbUIColor; + public string MesDbUIColor + { + get => _mesDbUIColor; + set => SetProperty(ref _mesDbUIColor, value); + } + /// + /// MES鏁版嵁搴-鍥炬爣 + /// + public string _mesUIIcon; + public string MesUIIcon + { + get => _mesUIIcon; + set => SetProperty(ref _mesUIIcon, value); + } + + /// + /// MES鏁版嵁搴撹繛鎺ョ姸鎬 + /// + /// + public void MesDbState(bool type) + { + Application.Current.Dispatcher.Invoke(() => + { + if (type) + { + MesDbUIStatusWb = "MES鏁版嵁搴撹繛鎺ユ垚鍔"; + MesDbUIColor = "Green"; + MesUIIcon = "Assets/Images/Green.png"; + } + else + { + MesDbUIStatusWb = "MES鏁版嵁搴撳紓甯"; + MesDbUIColor = "Red"; + MesUIIcon = "Assets/Images/Red.png"; + } + }); + } + #endregion #region plc 鐘舵 /// /// UI plc 灞曠ず鐘舵-鏂囧瓧 /// - public string _plcUIStatus; + public string _plcUIStatusWb; public string PlcUIStatusWb { - //get { return plcUIStatusWb; } - //set { plcUIStatusWb = value; RaisePropertyChanged("PlcUIStatusWb"); } - get => _plcUIStatus; - set => SetProperty(ref _plcUIStatus, value); + get => _plcUIStatusWb; + set => SetProperty(ref _plcUIStatusWb, value); } /// /// UI plc 灞曠ず鐘舵-棰滆壊 @@ -162,8 +287,6 @@ namespace Aucma.Core.BoxFoam.ViewModels public string _plcUIColor; public string PlcUIColor { - //get { return plcUIColor; } - //set { plcUIColor = value; RaisePropertyChanged("PlcUIColor"); } get => _plcUIColor; set => SetProperty(ref _plcUIColor, value); } @@ -173,8 +296,6 @@ namespace Aucma.Core.BoxFoam.ViewModels public string _plcUIIcon; public string PlcUIIcon { - //get { return plcUIIcon; } - //set { plcUIIcon = value; RaisePropertyChanged("plcUIIcon"); } get => _plcUIIcon; set => SetProperty(ref _plcUIIcon, value); } @@ -185,18 +306,80 @@ namespace Aucma.Core.BoxFoam.ViewModels /// public void PlcState(bool type) { - if (type) + Application.Current.Dispatcher.Invoke(() => { - PlcUIStatusWb = "PLC杩炴帴鎴愬姛"; - PlcUIColor = "White"; - PlcUIIcon = "Assets/Images/姝e父.png"; - } - else + if (type) + { + PlcUIStatusWb = "PLC杩炴帴鎴愬姛"; + PlcUIColor = "Green"; + PlcUIIcon = "Assets/Images/Green.png"; + } + else + { + PlcUIStatusWb = "PLC鐘舵佸紓甯"; + PlcUIColor = "Red"; + PlcUIIcon = "Assets/Images/Red.png"; + } + }); + } + #endregion + + #region 鎵爜鍣1鐘舵 + /// + /// UI 灞曠ず鐘舵-鏂囧瓧 + /// + public string _scanner1UIStatusWb; + public string Scanner1UIStatusWb + { + //get { return plcUIStatusWb; } + //set { plcUIStatusWb = value; RaisePropertyChanged("PlcUIStatusWb"); } + get => _scanner1UIStatusWb; + set => SetProperty(ref _scanner1UIStatusWb, value); + } + /// + /// UI 灞曠ず鐘舵-棰滆壊 + /// + public string _scanner1UIColor; + public string Scanner1UIColor + { + //get { return plcUIColor; } + //set { plcUIColor = value; RaisePropertyChanged("PlcUIColor"); } + get => _scanner1UIColor; + set => SetProperty(ref _scanner1UIColor, value); + } + /// + /// UI 灞曠ず鐘舵-鍥炬爣 + /// + public string _scanner1UIIcon; + public string Scanner1UIIcon + { + //get { return plcUIIcon; } + //set { plcUIIcon = value; RaisePropertyChanged("plcUIIcon"); } + get => _scanner1UIIcon; + set => SetProperty(ref _scanner1UIIcon, value); + } + + /// + /// 鎵爜鍣1杩炴帴鐘舵-true:杩炴帴鎴愬姛锛沠alse:澶辫触 + /// + /// + public void Scanner1State(bool type) + { + Application.Current.Dispatcher.Invoke(() => { - PlcUIStatusWb = "PLC鐘舵佸紓甯"; - PlcUIColor = "Red"; - PlcUIIcon = "Assets/Images/澶辫触-01.png"; - } + if (type) + { + Scanner1UIStatusWb = "鎵爜鍣1杩炴帴鎴愬姛"; + Scanner1UIColor = "Green"; + Scanner1UIIcon = "Assets/Images/Green.png"; + } + else + { + Scanner1UIStatusWb = "鎵爜鍣1鐘舵佸紓甯"; + Scanner1UIColor = "Red"; + Scanner1UIIcon = "Assets/Images/Red.png"; + } + }); } #endregion } diff --git a/Aucma.Core.BoxFoam/Views/MainWindow.xaml b/Aucma.Core.BoxFoam/Views/MainWindow.xaml index 9fde5a44..f5a5bd01 100644 --- a/Aucma.Core.BoxFoam/Views/MainWindow.xaml +++ b/Aucma.Core.BoxFoam/Views/MainWindow.xaml @@ -8,7 +8,7 @@ Title="婢虫煰鐜涚浣撳彂娉℃帶鍒剁郴缁" d:DesignHeight="1080" d:DesignWidth="1920" FontFamily="Microsoft YaHei" - WindowStyle="ToolWindow" WindowState="Maximized" + WindowStyle="None" WindowState="Maximized" WindowStartupLocation="CenterScreen" > @@ -59,10 +59,7 @@ - - - - + public static void OpenOsk() { - Process proc = new Process(); + Process proc = new Process(); proc.StartInfo.FileName = @"C:\Windows\System32\osk.exe"; proc.StartInfo.UseShellExecute = true; proc.StartInfo.Verb = "runas"; proc.Start(); } #endregion - #region 鐣岄潰鍒囨崲 /// /// 鐣岄潰鍒囨崲 diff --git a/Aucma.Core.SheetMetal/ViewModels/MainWindowViewModel.cs b/Aucma.Core.SheetMetal/ViewModels/MainWindowViewModel.cs index 5353f367..04719c97 100644 --- a/Aucma.Core.SheetMetal/ViewModels/MainWindowViewModel.cs +++ b/Aucma.Core.SheetMetal/ViewModels/MainWindowViewModel.cs @@ -10,6 +10,9 @@ using System.Windows.Interop; using System.Collections.ObjectModel; using Admin.Core.Common; using System.IO; +using Aucma.Core.PLc; +using Aucma.Core.Scanner; +using System.Linq; namespace Aucma.Core.SheetMetal.ViewModels { @@ -19,12 +22,91 @@ namespace Aucma.Core.SheetMetal.ViewModels private IndexPageView firstPage = new IndexPageView();//棣栭〉 private LogPageView logPage = new LogPageView();//鏃ュ織 private StatisticsPageView statisticsPage = new StatisticsPageView();//缁熻 - + public MainWindowViewModel() { UserContent = firstPage; + init(); } + public void init() + { + // 璁惧鐘舵佸埛鏂板畾鏃跺櫒 + System.Timers.Timer timer = new System.Timers.Timer(1000 * 5); + timer.Elapsed += new System.Timers.ElapsedEventHandler(RefreshStatus); + timer.AutoReset = true; + timer.Enabled = true; + timer.Start(); + } + + #region 璁惧鐘舵佸埛鏂 + /// + /// 璁惧鐘舵佸埛鏂 + /// + /// + /// + public void RefreshStatus(object sender, System.Timers.ElapsedEventArgs e) + { + RefreshMesDb(); + RefreshPlc(); + + + } + /// + /// 鏁版嵁搴撶姸鎬佸埛鏂 + /// + /// + /// + public void RefreshMesDb() + { + MesDbState(true); + } + + + /// + /// plc鐘舵佸埛鏂 + /// + /// + /// + public void RefreshPlc() + { + // 鍚庢澘plc + var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("鍚庢澘Plc")); + if (obj != null) + { + if (obj.plc.IsConnected) + { + PlcState(true); + } + else + { + PlcState(false); + } + } + else + { + PlcState(false); + } + // u澹硃lc + var obj2 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("U澹砅LC")); + if (obj2 != null) + { + if (obj2.plc.IsConnected) + { + Plc2State(true); + } + else + { + Plc2State(false); + } + } + else + { + Plc2State(false); + } + } + + #endregion #region 鏇存崲鐣岄潰 public System.Windows.Controls.UserControl _content; @@ -130,19 +212,69 @@ namespace Aucma.Core.SheetMetal.ViewModels break; } } - #endregion + #endregion + #region MES鏁版嵁搴撶姸鎬 + /// + /// MES鏁版嵁搴-鏂囧瓧 + /// + public string _mesDbUIStatusWb; + public string MesDbUIStatusWb + { + get => _mesDbUIStatusWb; + set => SetProperty(ref _mesDbUIStatusWb, value); + } + /// + /// MES鏁版嵁搴-棰滆壊 + /// + public string _mesDbUIColor; + public string MesDbUIColor + { + get => _mesDbUIColor; + set => SetProperty(ref _mesDbUIColor, value); + } + /// + /// MES鏁版嵁搴-鍥炬爣 + /// + public string _mesUIIcon; + public string MesUIIcon + { + get => _mesUIIcon; + set => SetProperty(ref _mesUIIcon, value); + } - #region plc 鐘舵 + /// + /// MES鏁版嵁搴撹繛鎺ョ姸鎬 + /// + /// + public void MesDbState(bool type) + { + Application.Current.Dispatcher.Invoke(() => + { + if (type) + { + MesDbUIStatusWb = "MES鏁版嵁搴撹繛鎺ユ垚鍔"; + MesDbUIColor = "Green"; + MesUIIcon = "Assets/Images/Green.png"; + } + else + { + MesDbUIStatusWb = "MES鏁版嵁搴撳紓甯"; + MesDbUIColor = "Red"; + MesUIIcon = "Assets/Images/Red.png"; + } + }); + } + #endregion + + #region 鍚庢澘plc 鐘舵 /// /// UI plc 灞曠ず鐘舵-鏂囧瓧 /// - public string _plcUIStatus; + public string _plcUIStatusWb; public string PlcUIStatusWb { - //get { return plcUIStatusWb; } - //set { plcUIStatusWb = value; RaisePropertyChanged("PlcUIStatusWb"); } - get => _plcUIStatus; - set => SetProperty(ref _plcUIStatus, value); + get => _plcUIStatusWb; + set => SetProperty(ref _plcUIStatusWb, value); } /// /// UI plc 灞曠ず鐘舵-棰滆壊 @@ -150,8 +282,6 @@ namespace Aucma.Core.SheetMetal.ViewModels public string _plcUIColor; public string PlcUIColor { - //get { return plcUIColor; } - //set { plcUIColor = value; RaisePropertyChanged("PlcUIColor"); } get => _plcUIColor; set => SetProperty(ref _plcUIColor, value); } @@ -161,30 +291,85 @@ namespace Aucma.Core.SheetMetal.ViewModels public string _plcUIIcon; public string PlcUIIcon { - //get { return plcUIIcon; } - //set { plcUIIcon = value; RaisePropertyChanged("plcUIIcon"); } get => _plcUIIcon; set => SetProperty(ref _plcUIIcon, value); } /// - /// PLC杩炴帴鐘舵-true:杩炴帴鎴愬姛锛沠alse:澶辫触 + /// 鍚庢澘PLC杩炴帴鐘舵-true:杩炴帴鎴愬姛锛沠alse:澶辫触 /// /// public void PlcState(bool type) { - if (type) + Application.Current.Dispatcher.Invoke(() => { - PlcUIStatusWb = "PLC杩炴帴鎴愬姛"; - PlcUIColor = "White"; - PlcUIIcon = "Assets/Images/姝e父.png"; - } - else + if (type) + { + PlcUIStatusWb = "鍚庢澘PLC杩炴帴鎴愬姛"; + PlcUIColor = "Green"; + PlcUIIcon = "Assets/Images/Green.png"; + } + else + { + PlcUIStatusWb = "鍚庢澘PLC鐘舵佸紓甯"; + PlcUIColor = "Red"; + PlcUIIcon = "Assets/Images/Red.png"; + } + }); + } + #endregion + + + #region U澹砅LC鐘舵 + /// + /// UI plc 灞曠ず鐘舵-鏂囧瓧 + /// + public string _plc2UIStatusWb; + public string Plc2UIStatusWb + { + get => _plc2UIStatusWb; + set => SetProperty(ref _plc2UIStatusWb, value); + } + /// + /// UI plc 灞曠ず鐘舵-棰滆壊 + /// + public string _plc2UIColor; + public string Plc2UIColor + { + get => _plc2UIColor; + set => SetProperty(ref _plc2UIColor, value); + } + /// + /// UI plc 灞曠ず鐘舵-鍥炬爣 + /// + public string _plc2UIIcon; + public string Plc2UIIcon + { + get => _plc2UIIcon; + set => SetProperty(ref _plc2UIIcon, value); + } + + /// + /// PLC杩炴帴鐘舵-true:杩炴帴鎴愬姛锛沠alse:澶辫触 + /// + /// + public void Plc2State(bool type) + { + Application.Current.Dispatcher.Invoke(() => { - PlcUIStatusWb = "PLC鐘舵佸紓甯"; - PlcUIColor = "Red"; - PlcUIIcon = "Assets/Images/澶辫触-01.png"; - } + if (type) + { + Plc2UIStatusWb = "U澹砅LC杩炴帴鎴愬姛"; + Plc2UIColor = "Green"; + Plc2UIIcon = "Assets/Images/Green.png"; + } + else + { + Plc2UIStatusWb = "U澹砅LC鐘舵佸紓甯"; + Plc2UIColor = "Red"; + Plc2UIIcon = "Assets/Images/Red.png"; + } + }); } #endregion } diff --git a/Aucma.Core.SheetMetal/Views/MainWindow.xaml b/Aucma.Core.SheetMetal/Views/MainWindow.xaml index 54875b0e..161341a9 100644 --- a/Aucma.Core.SheetMetal/Views/MainWindow.xaml +++ b/Aucma.Core.SheetMetal/Views/MainWindow.xaml @@ -60,10 +60,7 @@ - - - - +