|
|
|
@ -13,14 +13,13 @@ using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Threading;
|
|
|
|
|
using Admin.Core.Common;
|
|
|
|
|
using Aucma.Core.Scanner;
|
|
|
|
|
using Admin.Core.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(); // 统计页面
|
|
|
|
@ -29,22 +28,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels
|
|
|
|
|
public MainWindowViewModel()
|
|
|
|
|
{
|
|
|
|
|
UserContent = firstPage;
|
|
|
|
|
|
|
|
|
|
MesDbState(true);
|
|
|
|
|
PlcState(true);
|
|
|
|
|
Scanner1State(true);
|
|
|
|
|
Scanner2State(true);
|
|
|
|
|
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();
|
|
|
|
|
Job_AllState_Quartz.RefreshStateEvent += RefreshStatus;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -52,15 +36,15 @@ namespace Aucma.Core.ProductOffLine.ViewModels
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 设备状态刷新
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
public void RefreshStatus(object sender, System.Timers.ElapsedEventArgs e)
|
|
|
|
|
public Task RefreshStatus(bool mesState, bool plcState, bool scanner1, bool scanner2)
|
|
|
|
|
{
|
|
|
|
|
RefreshMesDb();
|
|
|
|
|
RefreshPlc();
|
|
|
|
|
RefreshScanner();
|
|
|
|
|
|
|
|
|
|
MesDbState(mesState);
|
|
|
|
|
PlcState(plcState);
|
|
|
|
|
Scanner1State(scanner1);
|
|
|
|
|
Scanner2State(scanner2);
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 数据库状态刷新
|
|
|
|
|
/// </summary>
|
|
|
|
@ -257,14 +241,14 @@ namespace Aucma.Core.ProductOffLine.ViewModels
|
|
|
|
|
Application.Current.Dispatcher.Invoke(() =>
|
|
|
|
|
{
|
|
|
|
|
if (type)
|
|
|
|
|
{
|
|
|
|
|
MesDbUIStatusWb = "MES数据库连接成功";
|
|
|
|
|
{
|
|
|
|
|
MesDbUIStatusWb = "MES数据库";
|
|
|
|
|
MesDbUIColor = "Green";
|
|
|
|
|
MesUIIcon = "Assets/Images/Green.png";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MesDbUIStatusWb = "MES数据库异常";
|
|
|
|
|
MesDbUIStatusWb = "MES数据库";
|
|
|
|
|
MesDbUIColor = "Red";
|
|
|
|
|
MesUIIcon = "Assets/Images/Red.png";
|
|
|
|
|
}
|
|
|
|
@ -311,13 +295,13 @@ namespace Aucma.Core.ProductOffLine.ViewModels
|
|
|
|
|
{
|
|
|
|
|
if (type)
|
|
|
|
|
{
|
|
|
|
|
PlcUIStatusWb = "PLC连接成功";
|
|
|
|
|
PlcUIStatusWb = "PLC状态";
|
|
|
|
|
PlcUIColor = "Green";
|
|
|
|
|
PlcUIIcon = "Assets/Images/Green.png";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PlcUIStatusWb = "PLC状态异常";
|
|
|
|
|
PlcUIStatusWb = "PLC状态";
|
|
|
|
|
PlcUIColor = "Red";
|
|
|
|
|
PlcUIIcon = "Assets/Images/Red.png";
|
|
|
|
|
}
|
|
|
|
@ -370,13 +354,13 @@ namespace Aucma.Core.ProductOffLine.ViewModels
|
|
|
|
|
{
|
|
|
|
|
if (type)
|
|
|
|
|
{
|
|
|
|
|
Scanner1UIStatusWb = "扫码器1连接成功";
|
|
|
|
|
Scanner1UIStatusWb = "扫码器1状态";
|
|
|
|
|
Scanner1UIColor = "Green";
|
|
|
|
|
Scanner1UIIcon = "Assets/Images/Green.png";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Scanner1UIStatusWb = "扫码器1状态异常";
|
|
|
|
|
Scanner1UIStatusWb = "扫码器1状态";
|
|
|
|
|
Scanner1UIColor = "Red";
|
|
|
|
|
Scanner1UIIcon = "Assets/Images/Red.png";
|
|
|
|
|
}
|
|
|
|
@ -429,13 +413,13 @@ namespace Aucma.Core.ProductOffLine.ViewModels
|
|
|
|
|
{
|
|
|
|
|
if (type)
|
|
|
|
|
{
|
|
|
|
|
Scanner2UIStatusWb = "扫码器2连接成功";
|
|
|
|
|
Scanner2UIStatusWb = "扫码器2状态";
|
|
|
|
|
Scanner2UIColor = "Green";
|
|
|
|
|
Scanner2UIIcon = "Assets/Images/Green.png";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Scanner2UIStatusWb = "扫码器2状态异常";
|
|
|
|
|
Scanner2UIStatusWb = "扫码器2状态";
|
|
|
|
|
Scanner2UIColor = "Red";
|
|
|
|
|
Scanner2UIIcon = "Assets/Images/Red.png";
|
|
|
|
|
}
|
|
|
|
|