|
|
@ -54,10 +54,10 @@ namespace Aucma.Core.CodeBinding.ViewModels
|
|
|
|
// 过点数据表,物料完成记录MaterialCompletion
|
|
|
|
// 过点数据表,物料完成记录MaterialCompletion
|
|
|
|
private readonly IMaterialCompletionServices? _iMaterialCompletionServices;
|
|
|
|
private readonly IMaterialCompletionServices? _iMaterialCompletionServices;
|
|
|
|
// 静态变量存code1
|
|
|
|
// 静态变量存code1
|
|
|
|
private static string code1Str = string.Empty;
|
|
|
|
// private static string code1Str = string.Empty;
|
|
|
|
|
|
|
|
|
|
|
|
// 静态变量存code2
|
|
|
|
// 静态变量存code2
|
|
|
|
private static string code2Str = string.Empty;
|
|
|
|
// private static string code2Str = string.Empty;
|
|
|
|
//配置文件扫码器列表
|
|
|
|
//配置文件扫码器列表
|
|
|
|
private static List<ScannerModel> allScanners = Appsettings.app<ScannerModel>("ScannerServer").ToList();
|
|
|
|
private static List<ScannerModel> allScanners = Appsettings.app<ScannerModel>("ScannerServer").ToList();
|
|
|
|
public IndexPageViewModel()
|
|
|
|
public IndexPageViewModel()
|
|
|
@ -70,9 +70,11 @@ namespace Aucma.Core.CodeBinding.ViewModels
|
|
|
|
|
|
|
|
|
|
|
|
_printBarCodeServices = App.ServiceProvider.GetService<IPrintBarCodeServices>();
|
|
|
|
_printBarCodeServices = App.ServiceProvider.GetService<IPrintBarCodeServices>();
|
|
|
|
_iMaterialCompletionServices = App.ServiceProvider.GetService<IMaterialCompletionServices>();
|
|
|
|
_iMaterialCompletionServices = App.ServiceProvider.GetService<IMaterialCompletionServices>();
|
|
|
|
Business.MvCodeHelper.BindingReceiveCodeEvent += ReceiveCode;
|
|
|
|
Business.MvCodeHelper.ReceiveCodeEvent += ReceiveCode;
|
|
|
|
GunBusiness.RefreshMaterialCodeStrEvent += ReceiveCode;
|
|
|
|
Business.MvCodeHelper.BindingCodeEvent += BindingCode;
|
|
|
|
Business.MvCodeHelper.NoReadEvent += ReceiveNoRead;
|
|
|
|
Business.MvCodeHelper.NoReadEvent += ReceiveNoRead;
|
|
|
|
|
|
|
|
GunBusiness.BindingReceiveCodeEvent += BindingCode;
|
|
|
|
|
|
|
|
GunBusiness.RefreshMaterialCodeStrEvent += ReceiveCode;
|
|
|
|
|
|
|
|
|
|
|
|
LoadData();
|
|
|
|
LoadData();
|
|
|
|
|
|
|
|
|
|
|
@ -104,29 +106,29 @@ namespace Aucma.Core.CodeBinding.ViewModels
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string tempCode1 ;
|
|
|
|
string tempCode1 ;
|
|
|
|
string tempCode2;
|
|
|
|
string tempCode2;
|
|
|
|
// 实时绑定条码
|
|
|
|
//// 实时绑定条码
|
|
|
|
Task.Run(() =>
|
|
|
|
//Task.Run(() =>
|
|
|
|
{
|
|
|
|
//{
|
|
|
|
while(true)
|
|
|
|
// while(true)
|
|
|
|
{
|
|
|
|
// {
|
|
|
|
try
|
|
|
|
// try
|
|
|
|
{
|
|
|
|
// {
|
|
|
|
if (!string.IsNullOrEmpty(code1Str) && !string.IsNullOrEmpty(code2Str))
|
|
|
|
// if (!string.IsNullOrEmpty(code1Str) && !string.IsNullOrEmpty(code2Str))
|
|
|
|
{
|
|
|
|
// {
|
|
|
|
tempCode1 = code1Str;
|
|
|
|
// tempCode1 = code1Str;
|
|
|
|
tempCode2 = code2Str;
|
|
|
|
// tempCode2 = code2Str;
|
|
|
|
code1Str = string.Empty;
|
|
|
|
// code1Str = string.Empty;
|
|
|
|
code2Str = string.Empty;
|
|
|
|
// code2Str = string.Empty;
|
|
|
|
BindingCode(tempCode1, tempCode2);
|
|
|
|
// BindingCode(tempCode1, tempCode2);
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
catch (Exception ex)
|
|
|
|
// catch (Exception ex)
|
|
|
|
{
|
|
|
|
// {
|
|
|
|
Console.WriteLine(ex.ToString());
|
|
|
|
// Console.WriteLine(ex.ToString());
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
Thread.Sleep(500);
|
|
|
|
// Thread.Sleep(500);
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
});
|
|
|
|
//});
|
|
|
|
|
|
|
|
|
|
|
|
// 心跳线程
|
|
|
|
// 心跳线程
|
|
|
|
Task.Run(() =>
|
|
|
|
Task.Run(() =>
|
|
|
@ -449,11 +451,11 @@ namespace Aucma.Core.CodeBinding.ViewModels
|
|
|
|
{
|
|
|
|
{
|
|
|
|
log.Info("MES条码NoRead:");
|
|
|
|
log.Info("MES条码NoRead:");
|
|
|
|
// 全局变量赋值
|
|
|
|
// 全局变量赋值
|
|
|
|
code1Str = string.Empty ;
|
|
|
|
// code1Str = string.Empty ;
|
|
|
|
code2Str = string.Empty;
|
|
|
|
// code2Str = string.Empty;
|
|
|
|
// 页面扫码信息清空
|
|
|
|
// 页面扫码信息清空
|
|
|
|
Code1 = code1Str;
|
|
|
|
Code1 = string.Empty;
|
|
|
|
Code2 = code2Str;
|
|
|
|
Code2 = string.Empty;
|
|
|
|
Code1Time = string.Empty ;
|
|
|
|
Code1Time = string.Empty ;
|
|
|
|
Code2Time = string.Empty ;
|
|
|
|
Code2Time = string.Empty ;
|
|
|
|
SendPlcStop();
|
|
|
|
SendPlcStop();
|
|
|
@ -462,11 +464,11 @@ namespace Aucma.Core.CodeBinding.ViewModels
|
|
|
|
else if(model.Id == 2)
|
|
|
|
else if(model.Id == 2)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
RefreshAndWriteLog("SN条码未扫描到,NoRead报警,线体停止,请重新扫描!");
|
|
|
|
RefreshAndWriteLog("SN条码未扫描到,NoRead报警,线体停止,请重新扫描!");
|
|
|
|
code1Str = string.Empty;
|
|
|
|
// code1Str = string.Empty;
|
|
|
|
code2Str = string.Empty;
|
|
|
|
// code2Str = string.Empty;
|
|
|
|
// 页面扫码信息清空
|
|
|
|
// 页面扫码信息清空
|
|
|
|
Code1 = code1Str;
|
|
|
|
Code1 = string.Empty;
|
|
|
|
Code2 = code2Str;
|
|
|
|
Code2 = string.Empty;
|
|
|
|
Code1Time = string.Empty;
|
|
|
|
Code1Time = string.Empty;
|
|
|
|
Code2Time = string.Empty;
|
|
|
|
Code2Time = string.Empty;
|
|
|
|
SendPlcStop();
|
|
|
|
SendPlcStop();
|
|
|
@ -487,7 +489,7 @@ namespace Aucma.Core.CodeBinding.ViewModels
|
|
|
|
{
|
|
|
|
{
|
|
|
|
log.Info("扫描到MES条码:" + codeStr);
|
|
|
|
log.Info("扫描到MES条码:" + codeStr);
|
|
|
|
// 全局变量赋值,SN码扫描后使用
|
|
|
|
// 全局变量赋值,SN码扫描后使用
|
|
|
|
code1Str = codeStr;
|
|
|
|
// code1Str = codeStr;
|
|
|
|
RefreshCode1(codeStr);
|
|
|
|
RefreshCode1(codeStr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -495,7 +497,7 @@ namespace Aucma.Core.CodeBinding.ViewModels
|
|
|
|
log.Info("扫描到成品条码:" + codeStr);
|
|
|
|
log.Info("扫描到成品条码:" + codeStr);
|
|
|
|
// 1.刷新界面条码信息
|
|
|
|
// 1.刷新界面条码信息
|
|
|
|
// 全局变量赋值,mes条码扫描后使用
|
|
|
|
// 全局变量赋值,mes条码扫描后使用
|
|
|
|
code2Str = codeStr;
|
|
|
|
// code2Str = codeStr;
|
|
|
|
RefreshCode2(codeStr);
|
|
|
|
RefreshCode2(codeStr);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -554,8 +556,8 @@ namespace Aucma.Core.CodeBinding.ViewModels
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 条码绑定
|
|
|
|
/// 条码绑定
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="code1"></param>
|
|
|
|
/// <param name="code1">MES码</param>
|
|
|
|
/// <param name="code2"></param>
|
|
|
|
/// <param name="code2">SN码</param>
|
|
|
|
public void BindingCode(string code1,string code2)
|
|
|
|
public void BindingCode(string code1,string code2)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
@ -656,8 +658,8 @@ namespace Aucma.Core.CodeBinding.ViewModels
|
|
|
|
}
|
|
|
|
}
|
|
|
|
finally
|
|
|
|
finally
|
|
|
|
{
|
|
|
|
{
|
|
|
|
code1Str = string.Empty;
|
|
|
|
// code1Str = string.Empty;
|
|
|
|
code2Str = string.Empty;
|
|
|
|
// code2Str = string.Empty;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -705,7 +707,7 @@ namespace Aucma.Core.CodeBinding.ViewModels
|
|
|
|
var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("条码绑定Plc"));
|
|
|
|
var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("条码绑定Plc"));
|
|
|
|
if (obj != null)
|
|
|
|
if (obj != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
log.Info("停止信号D7102写1");
|
|
|
|
log.Info("下发放行,停止信号D7102写0");
|
|
|
|
// 停止信号复位
|
|
|
|
// 停止信号复位
|
|
|
|
obj.plc.WriteInt16("D7102", "0");
|
|
|
|
obj.plc.WriteInt16("D7102", "0");
|
|
|
|
// 报警信号复位
|
|
|
|
// 报警信号复位
|
|
|
|