|
@@ -57,20 +57,21 @@ namespace SCADA_DAQ.Customer
|
|
|
/// <summary>
|
|
|
/// 条形码的索引
|
|
|
/// </summary>
|
|
|
- int Barcode;
|
|
|
+ int BarcodeIndx;
|
|
|
|
|
|
/// <summary>
|
|
|
/// 长的索引
|
|
|
/// </summary>
|
|
|
- int Long;
|
|
|
+ int LongIndx;
|
|
|
|
|
|
/// <summary>
|
|
|
/// 宽的索引
|
|
|
/// </summary>
|
|
|
- int Wide;
|
|
|
+ int WideIndx;
|
|
|
/// <summary>
|
|
|
- /// /
|
|
|
+ /// /条码
|
|
|
/// </summary>
|
|
|
+ string Barcode;
|
|
|
public UctFrmMain()
|
|
|
{
|
|
|
InitializeComponent();
|
|
@@ -79,30 +80,53 @@ namespace SCADA_DAQ.Customer
|
|
|
if (BarcodeReader1 != null)
|
|
|
{
|
|
|
BarcodeReader1.BarCodeReceived += BarcodeReader1_BarCodeReceived;
|
|
|
+ Log.Info("获取到读码器实例");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void BarcodeReader1_BarCodeReceived(object sender, SCADA.BarcodeReader.BarcodeReceivedEventArgs e)
|
|
|
{
|
|
|
- if (e.Barcode == null || e.Barcode == "" || e.Barcode == "NoRead")
|
|
|
+ string barCode = null;
|
|
|
+ if (e.Barcode.Substring(0, 6) == "QRCode")
|
|
|
{
|
|
|
+ barCode = e.Barcode.Substring(6, e.Barcode.Length - 6).Trim();
|
|
|
+ Log.Info($"收到条码{barCode}");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ barCode = e.Barcode.Trim();
|
|
|
+ Log.Info($"收到条码{barCode}");
|
|
|
+ }
|
|
|
+ if (barCode == null || barCode == "" || barCode == "NoRead" || barCode == this.Barcode
|
|
|
+ || BarcodeInfo.Count == 0 || !BarcodeInfo.ContainsKey(barCode))
|
|
|
+ {
|
|
|
+ if(barCode == this.Barcode)
|
|
|
+ {
|
|
|
+ Log.Info($"重复读码{barCode}");
|
|
|
+ }
|
|
|
+ else if(!BarcodeInfo.ContainsKey(barCode))
|
|
|
+ {
|
|
|
+ Log.Info($"Ecexl表中无此条码{barCode}信息");
|
|
|
+ }
|
|
|
return;
|
|
|
}
|
|
|
- var _long = BarcodeInfo[e.Barcode]?.Long;
|
|
|
- var _wide = BarcodeInfo[e.Barcode]?.Wide;
|
|
|
+ var _long = BarcodeInfo[barCode].Long;
|
|
|
+ var _wide = BarcodeInfo[barCode].Wide;
|
|
|
if (_long == null || _wide == null)
|
|
|
{
|
|
|
+ Log.Info($"Excel表中此条码{Barcode}的长宽信息不完善");
|
|
|
return;
|
|
|
}
|
|
|
var _string = $"{_long}#{_wide}";
|
|
|
- Log.Info(_string);
|
|
|
+ Log.Info($"收到条码信息{barCode},发送长宽信息{_string}");
|
|
|
var _byte = ASCIIEncoding.ASCII.GetBytes(_string);
|
|
|
Dispatcher.Invoke(() =>
|
|
|
{
|
|
|
- TextContent.Text = e.Barcode;
|
|
|
+ TextContent.Text = barCode;
|
|
|
TextContentTime.Text = e.TimeStamp.ToLongTimeString();
|
|
|
//ASCIICode.Text = Encoding.UTF8.GetString(_byte);
|
|
|
- ASCIICode.Text = string.Join(" ",Encoding.UTF8.GetString(_byte));
|
|
|
+ LongAndWide.Text = string.Join("", ASCIIEncoding.ASCII.GetString(_byte));
|
|
|
+ ASCIICode.Text = string.Join(" ", _byte);
|
|
|
});
|
|
|
using (var serialcomm = new SerialPort()
|
|
|
{
|
|
@@ -119,6 +143,7 @@ namespace SCADA_DAQ.Customer
|
|
|
{
|
|
|
serialcomm.Open();
|
|
|
serialcomm.Write(_byte, 0, _byte.Count());
|
|
|
+ this.Barcode = barCode;
|
|
|
}
|
|
|
catch
|
|
|
{
|
|
@@ -165,15 +190,15 @@ namespace SCADA_DAQ.Customer
|
|
|
ExcelData.Columns.Add(col);
|
|
|
if (cellValue == "条形码")
|
|
|
{
|
|
|
- Barcode = i;
|
|
|
+ BarcodeIndx = i;
|
|
|
}
|
|
|
- if (cellValue == "长")
|
|
|
+ if (cellValue == "开料长")
|
|
|
{
|
|
|
- Long = i;
|
|
|
+ LongIndx = i;
|
|
|
}
|
|
|
- if (cellValue == "宽")
|
|
|
+ if (cellValue == "开料宽")
|
|
|
{
|
|
|
- Wide = i;
|
|
|
+ WideIndx = i;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -199,19 +224,19 @@ namespace SCADA_DAQ.Customer
|
|
|
if (row.GetCell(j) != null)
|
|
|
{
|
|
|
dr[j] = row.GetCell(j).ToString();
|
|
|
- if (j == Barcode)
|
|
|
+ if (j == BarcodeIndx)
|
|
|
{
|
|
|
var barcode = row.GetCell(j).ToString();
|
|
|
barcodeInfo.Barcode = barcode;
|
|
|
key = barcode;
|
|
|
BarcodeInfo.Add(key, new BarcodeInformation() { Barcode = barcode });
|
|
|
}
|
|
|
- if (j == Long)
|
|
|
+ if (j == LongIndx)
|
|
|
{
|
|
|
barcodeInfo.Long = row.GetCell(j).ToString();
|
|
|
BarcodeInfo[key].Long = row.GetCell(j).ToString();
|
|
|
}
|
|
|
- if (j == Wide)
|
|
|
+ if (j == WideIndx)
|
|
|
{
|
|
|
barcodeInfo.Wide = row.GetCell(j).ToString();
|
|
|
BarcodeInfo[key].Wide = row.GetCell(j).ToString();
|