|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
using GalaSoft.MvvmLight;
|
|
|
|
|
using GalaSoft.MvvmLight.Command;
|
|
|
|
|
using HslCommunication.Enthernet;
|
|
|
|
|
using HslCommunication.Secs.Types;
|
|
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
@ -21,12 +22,14 @@ using System.Diagnostics;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Security.Policy;
|
|
|
|
|
using System.ServiceModel.Channels;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
using TouchSocket.Sockets;
|
|
|
|
|
using static System.Net.Mime.MediaTypeNames;
|
|
|
|
|
|
|
|
|
|
namespace SlnMesnac.WPF.ViewModel
|
|
|
|
@ -37,7 +40,7 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
private GunHelper gunHelper = GunHelper.Instance;
|
|
|
|
|
public RelayCommand ResetCommand { get; set;}
|
|
|
|
|
//导入照片
|
|
|
|
|
public RelayCommand InputSourceCommand { get; set;}
|
|
|
|
|
public RelayCommand<string> InputSourceCommand { get; set;}
|
|
|
|
|
|
|
|
|
|
private LogoBusiness logoBusiness = null;
|
|
|
|
|
private LightHelper lightHelper = LightHelper.Instance;
|
|
|
|
@ -50,9 +53,13 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
private TcpServer? tcpServer;
|
|
|
|
|
private PlcPool plcPool = null;
|
|
|
|
|
|
|
|
|
|
private MyTcpClient pciClient = new MyTcpClient();
|
|
|
|
|
private MyTcpClient ocrClient = new MyTcpClient();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public IndexViewModel()
|
|
|
|
|
{
|
|
|
|
|
MyTcpClient.RefreshResultEvent += RefreshCheckResult;
|
|
|
|
|
logoIdentifyService = App.ServiceProvider.GetService<ILogoIdentifyService>();
|
|
|
|
|
LogoBusiness.RefreshMessageEvent += RefreshMessage;
|
|
|
|
|
LogoBusiness.RefreshBoxInfoEvent += RefreshBoxInfo;
|
|
|
|
@ -60,7 +67,7 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
LogoBusiness.RefreshDataGridEvent += RefreshDataGrid;
|
|
|
|
|
LightHelper.RefreshMessageEvent += RefreshMessage;
|
|
|
|
|
ResetCommand = new RelayCommand(Reset);
|
|
|
|
|
InputSourceCommand = new RelayCommand(InputSource);
|
|
|
|
|
InputSourceCommand = new RelayCommand<string>(InputSource);
|
|
|
|
|
RefreshDataGrid();
|
|
|
|
|
|
|
|
|
|
plcPool = App.ServiceProvider.GetService<PlcPool>();
|
|
|
|
@ -76,8 +83,26 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
// gunHelper.SendData("OK");
|
|
|
|
|
OKIsVis = Visibility.Hidden;
|
|
|
|
|
NGIsVis = Visibility.Hidden;
|
|
|
|
|
|
|
|
|
|
Init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Init()
|
|
|
|
|
{
|
|
|
|
|
Task.Run(async () =>
|
|
|
|
|
{
|
|
|
|
|
await ocrClient.StartAsync("127.0.0.1", "10001");
|
|
|
|
|
await pciClient.StartAsync("127.0.0.1", "9999");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RefreshCheckResult(string message)
|
|
|
|
|
{
|
|
|
|
|
RefreshMessage(message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 复位方法
|
|
|
|
|
/// 复位PLC放行,复位报警灯
|
|
|
|
@ -95,7 +120,7 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 导入按钮,导入图片进行OCR识别与验证
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void InputSource()
|
|
|
|
|
private void InputSource(string type)
|
|
|
|
|
{
|
|
|
|
|
OpenFileDialog openFileDialog = new OpenFileDialog();
|
|
|
|
|
openFileDialog.Filter = "图片文件|*.jpg;*.png;*.bmp";
|
|
|
|
@ -109,8 +134,16 @@ namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
string fileName = Path.GetFileName(selectedFilePath);
|
|
|
|
|
|
|
|
|
|
RefreshPicture(File.ReadAllBytes(selectedFilePath));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(type== "ocr")
|
|
|
|
|
{
|
|
|
|
|
ocrClient.sendMessage("ocr","hello world");
|
|
|
|
|
}
|
|
|
|
|
else if(type== "pci")
|
|
|
|
|
{
|
|
|
|
|
pciClient.sendMessage("pci",fileName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|