|
|
|
@ -10,6 +10,8 @@ using NPOI.HSSF.Record;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Aucma.Core.PLc;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using Admin.Core.Common;
|
|
|
|
|
using Aucma.Core.Scanner;
|
|
|
|
|
|
|
|
|
|
namespace Aucma.Core.CodeBinding.ViewModels
|
|
|
|
|
{
|
|
|
|
@ -30,26 +32,40 @@ namespace Aucma.Core.CodeBinding.ViewModels
|
|
|
|
|
public MainWindowViewModel()
|
|
|
|
|
{
|
|
|
|
|
UserContent = firstPage;
|
|
|
|
|
PlcState(false);
|
|
|
|
|
PlcState(true);
|
|
|
|
|
Scanner1State(true);
|
|
|
|
|
Scanner2State(true);
|
|
|
|
|
init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void init()
|
|
|
|
|
{
|
|
|
|
|
// plc状态刷新定时器
|
|
|
|
|
// 设备状态刷新定时器
|
|
|
|
|
System.Timers.Timer timer = new System.Timers.Timer(1000 * 5);
|
|
|
|
|
timer.Elapsed += new System.Timers.ElapsedEventHandler(RefreshPlcStatus);
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
RefreshPlc();
|
|
|
|
|
RefreshScanner();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// plc状态刷新
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
public void RefreshPlcStatus(object sender, System.Timers.ElapsedEventArgs e)
|
|
|
|
|
public void RefreshPlc()
|
|
|
|
|
{
|
|
|
|
|
var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("条码绑定Plc"));
|
|
|
|
|
if (obj != null)
|
|
|
|
@ -67,10 +83,23 @@ namespace Aucma.Core.CodeBinding.ViewModels
|
|
|
|
|
{
|
|
|
|
|
PlcState(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 扫码器状态刷新
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
public void RefreshScanner()
|
|
|
|
|
{
|
|
|
|
|
string ip1 = Appsettings.app("Middleware", "Scanner1", "Ip");
|
|
|
|
|
string ip2 = Appsettings.app("Middleware", "Scanner2", "Ip");
|
|
|
|
|
bool flag1 = MvCodeHelper.ConnectionStatus(ip1);
|
|
|
|
|
bool flag2 = MvCodeHelper.ConnectionStatus(ip2);
|
|
|
|
|
Scanner1State(flag1);
|
|
|
|
|
Scanner2State(flag2);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
#region 更换界面
|
|
|
|
|
|
|
|
|
|
public System.Windows.Controls.UserControl _content;
|
|
|
|
@ -80,9 +109,9 @@ namespace Aucma.Core.CodeBinding.ViewModels
|
|
|
|
|
get => _content;
|
|
|
|
|
set => SetProperty(ref _content, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 窗口操作
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 窗口操作
|
|
|
|
@ -232,9 +261,125 @@ namespace Aucma.Core.CodeBinding.ViewModels
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
#region 扫码器2状态
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// UI 展示状态-文字
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string _scanner2UIStatusWb;
|
|
|
|
|
public string Scanner2UIStatusWb
|
|
|
|
|
{
|
|
|
|
|
//get { return plcUIStatusWb; }
|
|
|
|
|
//set { plcUIStatusWb = value; RaisePropertyChanged("PlcUIStatusWb"); }
|
|
|
|
|
get => _scanner2UIStatusWb;
|
|
|
|
|
set => SetProperty(ref _scanner2UIStatusWb, value);
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// UI 展示状态-颜色
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string _scanner2UIColor;
|
|
|
|
|
public string Scanner2UIColor
|
|
|
|
|
{
|
|
|
|
|
//get { return plcUIColor; }
|
|
|
|
|
//set { plcUIColor = value; RaisePropertyChanged("PlcUIColor"); }
|
|
|
|
|
get => _scanner2UIColor;
|
|
|
|
|
set => SetProperty(ref _scanner2UIColor, value);
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// UI 展示状态-图标
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string _scanner2UIIcon;
|
|
|
|
|
public string Scanner2UIIcon
|
|
|
|
|
{
|
|
|
|
|
//get { return plcUIIcon; }
|
|
|
|
|
//set { plcUIIcon = value; RaisePropertyChanged("plcUIIcon"); }
|
|
|
|
|
get => _scanner2UIIcon;
|
|
|
|
|
set => SetProperty(ref _scanner2UIIcon, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 扫码器2连接状态-true:连接成功;false:失败
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="type"></param>
|
|
|
|
|
public void Scanner2State(bool type)
|
|
|
|
|
{
|
|
|
|
|
Application.Current.Dispatcher.Invoke(() =>
|
|
|
|
|
{
|
|
|
|
|
if (type)
|
|
|
|
|
{
|
|
|
|
|
Scanner2UIStatusWb = "扫码器2连接成功";
|
|
|
|
|
Scanner2UIColor = "Green";
|
|
|
|
|
Scanner2UIIcon = "Assets/Images/Green.png";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Scanner2UIStatusWb = "扫码器2状态异常";
|
|
|
|
|
Scanner2UIColor = "Red";
|
|
|
|
|
Scanner2UIIcon = "Assets/Images/Red.png";
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|