|
|
|
@ -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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|