diff --git a/Aucma.Core.ProductOffLine/Aucma.Core.ProductOffLine.csproj b/Aucma.Core.ProductOffLine/Aucma.Core.ProductOffLine.csproj index b28cabd9..a4376349 100644 --- a/Aucma.Core.ProductOffLine/Aucma.Core.ProductOffLine.csproj +++ b/Aucma.Core.ProductOffLine/Aucma.Core.ProductOffLine.csproj @@ -73,6 +73,12 @@ + + + ..\dll\MvCodeReaderSDK.Net.dll + + + Code diff --git a/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs index 597f2066..0fba87a8 100644 --- a/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs +++ b/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs @@ -142,8 +142,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels Random random = new Random(); for (int i = 0; i < 5; i++) { - achievement.Add(random.Next(60, 100)); - + achievement.Add(random.Next(60, 100)); } var column = new ColumnSeries(); diff --git a/Aucma.Core.ProductOffLine/ViewModels/MainWindowViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/MainWindowViewModel.cs index f0571269..6fb3dff5 100644 --- a/Aucma.Core.ProductOffLine/ViewModels/MainWindowViewModel.cs +++ b/Aucma.Core.ProductOffLine/ViewModels/MainWindowViewModel.cs @@ -7,11 +7,17 @@ using log4net; using System.Diagnostics; using System.Threading; using NPOI.HSSF.Record; +using Aucma.Core.PLc; +using System.Linq; +using System.Threading.Tasks; namespace Aucma.Core.ProductOffLine.ViewModels { public partial class MainWindowViewModel : ObservableObject { + #region plc状态刷新 + + #endregion private static readonly log4net.ILog log = LogManager.GetLogger(typeof(MainWindowViewModel)); private IndexPageView firstPage = new IndexPageView();//首页 private StatisticsPageView recordPage = new StatisticsPageView(); @@ -19,6 +25,60 @@ namespace Aucma.Core.ProductOffLine.ViewModels public MainWindowViewModel() { UserContent = firstPage; + PlcState(true); + // test(); + + } + public async void test() + { + Task.Run(() => + { + //Thread.Sleep(4000); + //PlcState(false); + Thread.Sleep(10000); + var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("成品下线Plc")); + if (obj != null) + { + obj.plc.Read("M100"); + if (obj.plc.IsConnected) + { + PlcState(true); + } + else + { + PlcState(false); + } + } + else + { + PlcState(false); + } + + Thread.Sleep(5000); + var obj1 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("成品下线Plc")); + obj.plc.Read("M100"); + if (obj1.plc.IsConnected) + { + PlcState(true); + } + else + { + PlcState(false); + } + + + Thread.Sleep(5000); + var obj2 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("成品下线Plc")); + obj.plc.Read("M100"); + if (obj2.plc.IsConnected) + { + PlcState(true); + } + else + { + PlcState(false); + } + }); } #region 更换界面 @@ -168,17 +228,18 @@ namespace Aucma.Core.ProductOffLine.ViewModels if (type) { PlcUIStatusWb = "PLC连接成功"; - PlcUIColor = "White"; - PlcUIIcon = "Assets/Images/正常.png"; + PlcUIColor = "Greed"; + PlcUIIcon = "Assets/Images/Green.png"; } else { PlcUIStatusWb = "PLC状态异常"; PlcUIColor = "Red"; - PlcUIIcon = "Assets/Images/失败-01.png"; + PlcUIIcon = "Assets/Images/Red.png"; } } #endregion + } } diff --git a/Aucma.Core.ProductOffLine/Views/MainWindow.xaml b/Aucma.Core.ProductOffLine/Views/MainWindow.xaml index 556617dc..7591d393 100644 --- a/Aucma.Core.ProductOffLine/Views/MainWindow.xaml +++ b/Aucma.Core.ProductOffLine/Views/MainWindow.xaml @@ -71,10 +71,10 @@ - + - +