简单的修改
This commit is contained in:
@@ -19,12 +19,17 @@ namespace FATrace.OEMApp.Services
|
||||
|
||||
public PLCDataService()
|
||||
{
|
||||
|
||||
|
||||
PLCLinkInitial();
|
||||
StartPlcScan();
|
||||
|
||||
PadCodeAddress= ConfigHelper.GetStringOrDefault("PDAScanCode", "D1050");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PAD地址
|
||||
/// </summary>
|
||||
private string PadCodeAddress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 扫码事件
|
||||
/// </summary>
|
||||
@@ -53,11 +58,11 @@ namespace FATrace.OEMApp.Services
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
PlcConnectedEventHandler.Invoke(this, "OK");
|
||||
if (PlcConnectedEventHandler != null) PlcConnectedEventHandler.Invoke(this, "OK");
|
||||
}
|
||||
else
|
||||
{
|
||||
PlcConnectedEventHandler.Invoke(this, "NG");
|
||||
if (PlcConnectedEventHandler != null) PlcConnectedEventHandler.Invoke(this, "NG");
|
||||
}
|
||||
_PlcConnected = value;
|
||||
}
|
||||
@@ -65,6 +70,37 @@ namespace FATrace.OEMApp.Services
|
||||
}
|
||||
|
||||
|
||||
private string _ScanCode = string.Empty;
|
||||
/// <summary>
|
||||
/// 扫描结果
|
||||
/// </summary>
|
||||
public string ScanCode
|
||||
{
|
||||
get { return _ScanCode; }
|
||||
set
|
||||
{
|
||||
if (_ScanCode != value)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
if (ScanCodeEventHandler != null) ScanCodeEventHandler.Invoke(this, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Error($"PLC条码数据为空: 数据改变但是数据为空");
|
||||
}
|
||||
|
||||
_ScanCode = value;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 扫描结果
|
||||
/// </summary>
|
||||
private OperateResult<string> OperateResultPDAScanCode { get; set; }
|
||||
|
||||
// 扫描控制
|
||||
private CancellationTokenSource? _plcScanCts;
|
||||
private Task? _plcScanTask;
|
||||
@@ -175,6 +211,12 @@ namespace FATrace.OEMApp.Services
|
||||
PLCLinkInitial();
|
||||
}
|
||||
|
||||
//内包扫码
|
||||
OperateResultPDAScanCode = KeyencePlcMcNet!.ReadString(PadCodeAddress, 40);
|
||||
if (OperateResultPDAScanCode.IsSuccess)
|
||||
{
|
||||
ScanCode = RevData(OperateResultPDAScanCode.Content).Replace("\r", "").Replace("\n", "").Trim();
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user