|
|
|
|
@ -50,6 +50,7 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage
|
|
|
|
|
private RealReadDataService dataService = RealReadDataService.Instance;
|
|
|
|
|
|
|
|
|
|
private real_readdata NowReadData;
|
|
|
|
|
private bool IsAuto = false;
|
|
|
|
|
|
|
|
|
|
#region 关联属性
|
|
|
|
|
|
|
|
|
|
@ -61,7 +62,6 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage
|
|
|
|
|
get { return _QueryIsCheck; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_QueryIsCheck = value;
|
|
|
|
|
if (_QueryIsCheck != value)
|
|
|
|
|
{
|
|
|
|
|
SetProperty(ref _QueryIsCheck, value);
|
|
|
|
|
@ -69,6 +69,19 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string _AutoWriteName = "自动写入";
|
|
|
|
|
public string AutoWriteName
|
|
|
|
|
{
|
|
|
|
|
get { return _AutoWriteName; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (_AutoWriteName != value)
|
|
|
|
|
{
|
|
|
|
|
SetProperty(ref _AutoWriteName, value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 准备写入的列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
@ -253,6 +266,8 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage
|
|
|
|
|
appConfig = App.ServiceProvider.GetService<AppConfig>();
|
|
|
|
|
rfidList = App.ServiceProvider.GetRequiredService<List<RfidAbsractFactory>>();
|
|
|
|
|
|
|
|
|
|
AutoWriteName = "自动写入";
|
|
|
|
|
|
|
|
|
|
rfidList.ForEach(rfid =>
|
|
|
|
|
{
|
|
|
|
|
rfid._Action += RecvIdentifyData_Instance;
|
|
|
|
|
@ -353,11 +368,44 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage
|
|
|
|
|
/// <param name="obj"></param>
|
|
|
|
|
private void AutoWrite(object obj)
|
|
|
|
|
{
|
|
|
|
|
//获取设备编号
|
|
|
|
|
if (string.IsNullOrEmpty(QueryIsCheck.ToString().Trim()))
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("请选择产线!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
|
|
|
|
//获取设备编号
|
|
|
|
|
if (string.IsNullOrEmpty(QueryIsCheck.ToString().Trim()))
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("请选择产线!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<DeviceInfoConfig> DeviceInfos = appConfig.deviceInfoConfig.Where(x => x.Collectid == appConfig.StationCode && x.Name == QueryIsCheck.ToString().Trim() && x.Deleteflag == 0).ToList();
|
|
|
|
|
|
|
|
|
|
if (!IsAuto)
|
|
|
|
|
{
|
|
|
|
|
var data = PreparedWriteList.FirstOrDefault(x => x.writestatus == "等待");
|
|
|
|
|
if (data == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("无待写入数据", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
IsAuto = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NowReadData = data;
|
|
|
|
|
|
|
|
|
|
rfidList.FirstOrDefault(x => x.deviceid == DeviceInfos[0].Deviceid).Set_BeginIdentify().GetAwaiter().GetResult();
|
|
|
|
|
IsAuto = true;
|
|
|
|
|
AutoWriteName = "停止写入";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
IsAuto = false;
|
|
|
|
|
rfidList.FirstOrDefault(x => x.deviceid == DeviceInfos[0].Deviceid).Set_StopIdentify();
|
|
|
|
|
AutoWriteName = "自动写入";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Log.Error($"自动写入异常:{ex.Message}");
|
|
|
|
|
MessageBox.Show($"自动写入异常:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -376,6 +424,8 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IsAuto = false;
|
|
|
|
|
|
|
|
|
|
real_readdata? data;
|
|
|
|
|
if (obj is real_readdata)
|
|
|
|
|
{
|
|
|
|
|
@ -395,6 +445,7 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Log.Error($"手动写入异常:{ex.Message}");
|
|
|
|
|
MessageBox.Show($"手动写入异常:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -443,7 +494,7 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage
|
|
|
|
|
NowReadData.rfidepc = tagInfos[0].EPCstring;
|
|
|
|
|
NowReadData.writetime = DateTime.Now;
|
|
|
|
|
NowReadData.writestatus = "已写入";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NowReadData.objid = Guid.NewGuid().ToString();
|
|
|
|
|
dataService.Helper.Insert(NowReadData);
|
|
|
|
|
|
|
|
|
|
@ -457,6 +508,12 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage
|
|
|
|
|
|
|
|
|
|
NowReadData = null!;
|
|
|
|
|
LastWriteState = "成功";
|
|
|
|
|
|
|
|
|
|
//连续写入就读完紧接着开启下一条盘点
|
|
|
|
|
if (IsAuto)
|
|
|
|
|
{
|
|
|
|
|
rfidList.FirstOrDefault(x => x.deviceid == iCombineId).Set_BeginIdentify().GetAwaiter().GetResult();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
|