|
|
|
@ -7,6 +7,10 @@ using log4net;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using NPOI.HSSF.Record;
|
|
|
|
|
using Admin.Core.Common;
|
|
|
|
|
using Aucma.Core.PLc;
|
|
|
|
|
using Aucma.Core.Scanner;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace Aucma.Core.DoorFoam.ViewModels
|
|
|
|
|
{
|
|
|
|
@ -15,12 +19,82 @@ namespace Aucma.Core.DoorFoam.ViewModels
|
|
|
|
|
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(MainWindowViewModel));
|
|
|
|
|
private IndexPageView firstPage = new IndexPageView();//首页
|
|
|
|
|
private StatisticsPageView recordPage = 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 设备状态刷新
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 设备状态刷新
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
public void RefreshStatus(object sender, System.Timers.ElapsedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
RefreshMesDb();
|
|
|
|
|
RefreshPlc();
|
|
|
|
|
RefreshScanner();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 数据库状态刷新
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
public void RefreshMesDb()
|
|
|
|
|
{
|
|
|
|
|
MesDbState(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// plc状态刷新
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
public void RefreshPlc()
|
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 扫码器状态刷新
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
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;
|
|
|
|
@ -122,19 +196,70 @@ namespace Aucma.Core.DoorFoam.ViewModels
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region MES数据库状态
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// MES数据库-文字
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string _mesDbUIStatusWb;
|
|
|
|
|
public string MesDbUIStatusWb
|
|
|
|
|
{
|
|
|
|
|
get => _mesDbUIStatusWb;
|
|
|
|
|
set => SetProperty(ref _mesDbUIStatusWb, value);
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// MES数据库-颜色
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string _mesDbUIColor;
|
|
|
|
|
public string MesDbUIColor
|
|
|
|
|
{
|
|
|
|
|
get => _mesDbUIColor;
|
|
|
|
|
set => SetProperty(ref _mesDbUIColor, value);
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// MES数据库-图标
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string _mesUIIcon;
|
|
|
|
|
public string MesUIIcon
|
|
|
|
|
{
|
|
|
|
|
get => _mesUIIcon;
|
|
|
|
|
set => SetProperty(ref _mesUIIcon, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// MES数据库连接状态
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="type"></param>
|
|
|
|
|
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 状态
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// UI plc 展示状态-文字
|
|
|
|
|
/// </summary>
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// UI plc 展示状态-颜色
|
|
|
|
@ -142,8 +267,6 @@ namespace Aucma.Core.DoorFoam.ViewModels
|
|
|
|
|
public string _plcUIColor;
|
|
|
|
|
public string PlcUIColor
|
|
|
|
|
{
|
|
|
|
|
//get { return plcUIColor; }
|
|
|
|
|
//set { plcUIColor = value; RaisePropertyChanged("PlcUIColor"); }
|
|
|
|
|
get => _plcUIColor;
|
|
|
|
|
set => SetProperty(ref _plcUIColor, value);
|
|
|
|
|
}
|
|
|
|
@ -153,8 +276,6 @@ namespace Aucma.Core.DoorFoam.ViewModels
|
|
|
|
|
public string _plcUIIcon;
|
|
|
|
|
public string PlcUIIcon
|
|
|
|
|
{
|
|
|
|
|
//get { return plcUIIcon; }
|
|
|
|
|
//set { plcUIIcon = value; RaisePropertyChanged("plcUIIcon"); }
|
|
|
|
|
get => _plcUIIcon;
|
|
|
|
|
set => SetProperty(ref _plcUIIcon, value);
|
|
|
|
|
}
|
|
|
|
@ -165,20 +286,81 @@ namespace Aucma.Core.DoorFoam.ViewModels
|
|
|
|
|
/// <param name="type"></param>
|
|
|
|
|
public void PlcState(bool type)
|
|
|
|
|
{
|
|
|
|
|
if (type)
|
|
|
|
|
Application.Current.Dispatcher.Invoke(() =>
|
|
|
|
|
{
|
|
|
|
|
PlcUIStatusWb = "PLC连接成功";
|
|
|
|
|
PlcUIColor = "White";
|
|
|
|
|
PlcUIIcon = "Assets/Images/正常.png";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PlcUIStatusWb = "PLC状态异常";
|
|
|
|
|
PlcUIColor = "Red";
|
|
|
|
|
PlcUIIcon = "Assets/Images/失败-01.png";
|
|
|
|
|
}
|
|
|
|
|
if (type)
|
|
|
|
|
{
|
|
|
|
|
PlcUIStatusWb = "PLC连接成功";
|
|
|
|
|
PlcUIColor = "Green";
|
|
|
|
|
PlcUIIcon = "Assets/Images/Green.png";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PlcUIStatusWb = "PLC状态异常";
|
|
|
|
|
PlcUIColor = "Red";
|
|
|
|
|
PlcUIIcon = "Assets/Images/Red.png";
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 扫码器1状态
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// UI 展示状态-文字
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string _scanner1UIStatusWb;
|
|
|
|
|
public string Scanner1UIStatusWb
|
|
|
|
|
{
|
|
|
|
|
//get { return plcUIStatusWb; }
|
|
|
|
|
//set { plcUIStatusWb = value; RaisePropertyChanged("PlcUIStatusWb"); }
|
|
|
|
|
get => _scanner1UIStatusWb;
|
|
|
|
|
set => SetProperty(ref _scanner1UIStatusWb, value);
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// UI 展示状态-颜色
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string _scanner1UIColor;
|
|
|
|
|
public string Scanner1UIColor
|
|
|
|
|
{
|
|
|
|
|
//get { return plcUIColor; }
|
|
|
|
|
//set { plcUIColor = value; RaisePropertyChanged("PlcUIColor"); }
|
|
|
|
|
get => _scanner1UIColor;
|
|
|
|
|
set => SetProperty(ref _scanner1UIColor, value);
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// UI 展示状态-图标
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string _scanner1UIIcon;
|
|
|
|
|
public string Scanner1UIIcon
|
|
|
|
|
{
|
|
|
|
|
//get { return plcUIIcon; }
|
|
|
|
|
//set { plcUIIcon = value; RaisePropertyChanged("plcUIIcon"); }
|
|
|
|
|
get => _scanner1UIIcon;
|
|
|
|
|
set => SetProperty(ref _scanner1UIIcon, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 扫码器1连接状态-true:连接成功;false:失败
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="type"></param>
|
|
|
|
|
public void Scanner1State(bool type)
|
|
|
|
|
{
|
|
|
|
|
Application.Current.Dispatcher.Invoke(() =>
|
|
|
|
|
{
|
|
|
|
|
if (type)
|
|
|
|
|
{
|
|
|
|
|
Scanner1UIStatusWb = "扫码器1连接成功";
|
|
|
|
|
Scanner1UIColor = "Green";
|
|
|
|
|
Scanner1UIIcon = "Assets/Images/Green.png";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Scanner1UIStatusWb = "扫码器1状态异常";
|
|
|
|
|
Scanner1UIColor = "Red";
|
|
|
|
|
Scanner1UIIcon = "Assets/Images/Red.png";
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|