|
|
@@ -40,7 +40,7 @@ namespace HKCardOUT.ViewModels |
|
|
|
this.Activated += RootViewModel_Activated; |
|
|
|
this.Closed += RootViewModel_Closed; |
|
|
|
|
|
|
|
//MainThread(); |
|
|
|
MainThread(); |
|
|
|
} |
|
|
|
/// <summary> |
|
|
|
/// 关闭页面 |
|
|
@@ -55,6 +55,7 @@ namespace HKCardOUT.ViewModels |
|
|
|
} |
|
|
|
|
|
|
|
System.Timers.Timer ti = new(); |
|
|
|
|
|
|
|
private void RootViewModel_Activated(object sender, ActivationEventArgs e) |
|
|
|
{ |
|
|
|
ReadFunc -= ReadCard; |
|
|
@@ -69,7 +70,7 @@ namespace HKCardOUT.ViewModels |
|
|
|
if (!UHF_RS485_Helper.GetInstance().GetSerialPortState()) |
|
|
|
{ |
|
|
|
HandyControl.Controls.Growl.InfoGlobal("串口打开失败"); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
//开启循环监听数据 |
|
|
|
ti.Interval = 500; |
|
|
@@ -92,19 +93,16 @@ namespace HKCardOUT.ViewModels |
|
|
|
if (res != null) |
|
|
|
{ |
|
|
|
if (!res.ResData.IsMatch(new Regex("0{20}"))) |
|
|
|
ReadFunc?.Invoke(res); |
|
|
|
ReadFunc?.Invoke(res); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
protected override void OnViewLoaded() |
|
|
|
{ |
|
|
|
ThreadManage.GetInstance().StartLong(() => |
|
|
|
{ |
|
|
|
Result = new ObservableCollection<SaleLog>(this.Container.Get<HKCore>().PullDaySaleLog()); |
|
|
|
Thread.Sleep(500); |
|
|
|
}, "消费记录查询", false); |
|
|
|
//广告初始化 |
|
|
|
var Init = DataBus.StoreInfo?.Devices.Join(DataBus.StoreInfo?.Stalls, t => t.GateId, x => x.Id, (t, x) => new AdDTO |
|
|
|
{ |
|
|
@@ -136,7 +134,7 @@ namespace HKCardOUT.ViewModels |
|
|
|
} |
|
|
|
#endregion |
|
|
|
|
|
|
|
#region 方法 这个可以不要了 |
|
|
|
#region 网络检查 |
|
|
|
private void MainThread() |
|
|
|
{ |
|
|
|
|
|
|
@@ -159,42 +157,6 @@ namespace HKCardOUT.ViewModels |
|
|
|
HandyControl.Controls.Growl.InfoGlobal(ex.Message); |
|
|
|
} |
|
|
|
}), "循环状态监测线程", false); |
|
|
|
try |
|
|
|
{ |
|
|
|
// 初始化 串口 |
|
|
|
UHF_RS485_Helper.GetInstance().Open(new SerialParam |
|
|
|
{ |
|
|
|
PortName = DataBus.COM, |
|
|
|
BaudRate = 57600, |
|
|
|
DataBits = 8 |
|
|
|
}); |
|
|
|
} |
|
|
|
catch (Exception) |
|
|
|
{ |
|
|
|
HandyControl.Controls.Growl.WarningGlobal("未接入相应设备"); |
|
|
|
} |
|
|
|
if (!UHF_RS485_Helper.GetInstance().GetSerialPortState()) |
|
|
|
HandyControl.Controls.Growl.InfoGlobal("串口打开失败"); |
|
|
|
DataBus.StoreInfo.Devices.ForEach(item => |
|
|
|
{ |
|
|
|
System.Timers.Timer timer = new System.Timers.Timer(500); |
|
|
|
timer.Enabled = true; |
|
|
|
timer.Elapsed += (sender, eve) => |
|
|
|
{ |
|
|
|
if (!UHF_RS485_Helper.GetInstance().GetSerialPortState()) |
|
|
|
return; |
|
|
|
else |
|
|
|
{ |
|
|
|
var res = UHF_RS485_Helper.GetInstance().ReadCard(item.Address.AsInt()).Result; |
|
|
|
if (res != null) |
|
|
|
{ |
|
|
|
if (!res.ResData.IsMatch(new Regex("0{20}"))) |
|
|
|
ReadFunc?.Invoke(res); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
timer.Start(); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@@ -234,9 +196,6 @@ namespace HKCardOUT.ViewModels |
|
|
|
|
|
|
|
#region 命令 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 广告位置 |
|
|
|
/// </summary> |
|
|
@@ -276,6 +235,7 @@ namespace HKCardOUT.ViewModels |
|
|
|
CardNo = input.ResData.Substring(1, input.ResData.Length - 1), |
|
|
|
Location = input.Address.AsInt().ToString() |
|
|
|
}); |
|
|
|
Result = new ObservableCollection<SaleLog>(this.Container.Get<HKCore>().PullDaySaleLog()); |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion |
|
|
|