change-扫码器,扫码枪逻辑修改

dev
liuwf 1 year ago
parent 3e65a0f8e4
commit d72e8d9ede

@ -359,7 +359,7 @@ namespace Aucma.Core.BoxFoam.ViewModels
foreach (var item in list) foreach (var item in list)
{ {
if (item.Status == 1) StatusColor.Add("Green"); if (item.Status == 1) StatusColor.Add("Green");
if (item.Status == 2) StatusColor.Add("Red"); if (item.Status == 3) StatusColor.Add("Red");
if (!string.IsNullOrEmpty(item.FixtureBoxType)) FixtureName.Add(item.FixtureBoxType); if (!string.IsNullOrEmpty(item.FixtureBoxType)) FixtureName.Add(item.FixtureBoxType);
if (!string.IsNullOrEmpty(item.Yield.ToString())) Production.Add(item.Yield.ToString()); if (!string.IsNullOrEmpty(item.Yield.ToString())) Production.Add(item.Yield.ToString());
// if (!string.IsNullOrEmpty(item.InternalTemperature.ToString())) InternalTemperature.Add(item.InternalTemperature.ToString()); // if (!string.IsNullOrEmpty(item.InternalTemperature.ToString())) InternalTemperature.Add(item.InternalTemperature.ToString());

@ -50,7 +50,7 @@ namespace Aucma.Core.CodeBinding.Business
//忽略null字节 //忽略null字节
serialPort.DiscardNull = true; serialPort.DiscardNull = true;
//接收事件 //接收事件
serialPort.DataReceived += serialPort_DataReceived; serialPort.DataReceived += new SerialDataReceivedEventHandler(serialPort_DataReceived);
//开启串口 //开启串口
serialPort.Open(); serialPort.Open();
} }
@ -73,13 +73,19 @@ namespace Aucma.Core.CodeBinding.Business
SerialPort serialPort = (SerialPort)sender; SerialPort serialPort = (SerialPort)sender;
//开启接收数据线程 string code = serialPort.ReadExisting();
Thread threadReceiveSub = new Thread(new ParameterizedThreadStart(ReceiveData));
threadReceiveSub.Start(serialPort); if (string.IsNullOrEmpty(code))
{
return;
}
//业务处理
Console.WriteLine("获取数据:" + code.Trim());
} }
catch (Exception ex) catch (Exception ex)
{ {
throw; Console.Write(ex.ToString());
} }
} }
private static void ReceiveData(object serialPortobj) private static void ReceiveData(object serialPortobj)

@ -74,6 +74,7 @@ namespace Aucma.Core.Scanner
// (成功创建)连接上的设备和其ip(string)集合 // (成功创建)连接上的设备和其ip(string)集合
public static Dictionary<MvCodeReader, string> m_cMyDevices = new Dictionary<MvCodeReader, string>(); public static Dictionary<MvCodeReader, string> m_cMyDevices = new Dictionary<MvCodeReader, string>();
private static string lastCodeStr = string.Empty;
#region 设备连接状态 #region 设备连接状态
/// <summary> /// <summary>
@ -342,11 +343,15 @@ namespace Aucma.Core.Scanner
} }
string strCode = Encoding.GetEncoding("UTF-8").GetString(buffer).Trim().TrimEnd('\0'); string strCode = Encoding.GetEncoding("UTF-8").GetString(buffer).Trim().TrimEnd('\0');
log.Info("相机ip:" + hashmap.Value + " Get CodeNum: " + "CodeNum[" + i.ToString() + "], CodeString[" + strCode + "]"); log.Info("相机ip:" + hashmap.Value + " Get CodeNum: " + "CodeNum[" + i.ToString() + "], CodeString[" + strCode + "]");
if (!string.IsNullOrEmpty(strCode)) if (!string.IsNullOrEmpty(strCode) && !strCode.Equals(lastCodeStr))
{ {
DoorReceiveCodeDelegateEvent?.Invoke(strCode);//箱门匹配扫码器 // DoorReceiveCodeDelegateEvent?.Invoke(strCode);//箱门匹配扫码器
// 获取到条码处理业务 // 获取到条码处理业务
Console.WriteLine(strCode,hashmap.Value); Console.WriteLine(strCode,hashmap.Value);
// 泡前库业务处理
// PQKReceiveCodeEvent(strCode);
lastCodeStr = strCode;
} }
} }
} }

Loading…
Cancel
Save