增加二维码检测规则

develop
lhiven 3 months ago
parent 1378ca2d25
commit 5d14fa61f9

@ -0,0 +1,24 @@
using Rs.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace Rs.MotionPlat.Commom
{
public static class BarCodeHelper
{
public static bool CheckSnLength(string sn)
{
//string reg = "^[ABCDEFGHJKLMNPQRSTUVWXYZ 0-9 + -]+$";
string reg = "^[A-Z 0-9 + -]+$";
if (Regex.IsMatch(sn, reg))
{
return true;
}
return false;
}
}
}

@ -21,6 +21,7 @@ using System.Linq;
using System.Net.Http; using System.Net.Http;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
@ -383,9 +384,25 @@ namespace Rs.MotionPlat.Flow
{ {
if((ret!= null && ret.Result== EOneGrabSixteenResult.Ok) ||(ret!=null &&ret.Result== EOneGrabSixteenResult.LocationOkScanBarcodeFail && GlobalVar.EnableVirtualBarCode) || GlobalVar.RunSpace) if((ret!= null && ret.Result== EOneGrabSixteenResult.Ok) ||(ret!=null &&ret.Result== EOneGrabSixteenResult.LocationOkScanBarcodeFail && GlobalVar.EnableVirtualBarCode) || GlobalVar.RunSpace)
{ {
StockTakeFlow.Instance.Take( ETrayType.Input, takeSlotIndex, NozzleManager.GetIdelNozzle().NozzleIndex); if(BarCodeHelper.CheckSnLength(ret.SN)|| GlobalVar.RunSpace || (ret != null && ret.Result == EOneGrabSixteenResult.LocationOkScanBarcodeFail && GlobalVar.EnableVirtualBarCode))
takeSlotIndex++; {
flowStep = EDischargeFlowStep.; StockTakeFlow.Instance.Take(ETrayType.Input, takeSlotIndex, NozzleManager.GetIdelNozzle().NozzleIndex);
takeSlotIndex++;
flowStep = EDischargeFlowStep.;
}
else
{
LogHelper.Debug(GetClassName() + $"检测到二维码={ret.SN}长度和设置的长度={GlobalVar.BarcodeLength}不一致");
Nozzle idleNozzle = NozzleManager.GetIdelNozzle();
StockTakeFlow.Instance.Take(ETrayType.Input, ret.SlotIndex, idleNozzle.NozzleIndex);
if (NozzleManager.GetNozzle(idleNozzle.NozzleIndex).Product != null)
{
//NozzleManager.GetNozzle(idleNozzle.NozzleIndex).Product.SN = "SLK11111111PNK60X";
NozzleManager.GetNozzle(idleNozzle.NozzleIndex).Product.SN = ScanFailNGHelper.GetSn();
}
takeSlotIndex++;
flowStep = EDischargeFlowStep.;
}
} }
else else
{ {
@ -412,6 +429,7 @@ namespace Rs.MotionPlat.Flow
{ {
LogHelper.Debug(GetClassName() + $"{JsonConvert.SerializeObject(fixtureret)}"); LogHelper.Debug(GetClassName() + $"{JsonConvert.SerializeObject(fixtureret)}");
//if (fixtureret.SN.Length == GlobalVar.BarcodeLength) //if (fixtureret.SN.Length == GlobalVar.BarcodeLength)
if(BarCodeHelper.CheckSnLength(fixtureret.SN))
{ {
try try
{ {
@ -429,25 +447,35 @@ namespace Rs.MotionPlat.Flow
Msg.ShowError(ex.Message); Msg.ShowError(ex.Message);
} }
} }
//else else
//{ {
// try try
// { {
// LogHelper.Debug(GetClassName() + "检测到二维码长度和设置的长度不一致,弹框报警"); LogHelper.Debug(GetClassName() + $"检测到二维码={fixtureret.SN}长度和设置的长度={GlobalVar.BarcodeLength}不一致");
// //报警弹框 Nozzle idleNozzle = NozzleManager.GetIdelNozzle();
// alarmEntity = AlarmCollection.Get(AlarmConstID.二维码长度异常报警).Transform(ret.SlotIndex); StockTakeFlow.Instance.Take(ETrayType.Input, ret.SlotIndex, idleNozzle.NozzleIndex);
// EButtonType buttonSelect = Msgbox.ShowDialog(alarmEntity, EButtonType.Retry, true); if (NozzleManager.GetNozzle(idleNozzle.NozzleIndex).Product != null)
// if (buttonSelect == EButtonType.Retry) {
// { //NozzleManager.GetNozzle(idleNozzle.NozzleIndex).Product.SN = "SLK11111111PNK60X";
// logInfo = GetClassName() + "选择了重试"; NozzleManager.GetNozzle(idleNozzle.NozzleIndex).Product.SN = ScanFailNGHelper.GetSn();
// MessageQueue.Instance.Insert(logInfo); }
// } takeSlotIndex++;
// } exit = true;
// catch (Exception ex) flowStep = EDischargeFlowStep.;
// { ////报警弹框
// Msg.ShowError(ex.Message); //alarmEntity = AlarmCollection.Get(AlarmConstID.二维码长度异常报警).Transform(ret.SlotIndex);
// } //EButtonType buttonSelect = Msgbox.ShowDialog(alarmEntity, EButtonType.Retry, true);
//} //if (buttonSelect == EButtonType.Retry)
//{
// logInfo = GetClassName() + "选择了重试";
// MessageQueue.Instance.Insert(logInfo);
//}
}
catch (Exception ex)
{
Msg.ShowError(ex.Message);
}
}
} }
else if (fixtureret != null && fixtureret.Result == EOneGrabSixteenResult.LocationOkScanBarcodeFail) else if (fixtureret != null && fixtureret.Result == EOneGrabSixteenResult.LocationOkScanBarcodeFail)
{ {
@ -1198,5 +1226,4 @@ namespace Rs.MotionPlat.Flow
} }
} }
} }
} }

@ -278,14 +278,15 @@ namespace Rs.MotionPlat.Flow
if ((vProductResult != null && vProductResult.Result == EOneGrabSixteenResult.Ok) || GlobalVar.RunSpace) if ((vProductResult != null && vProductResult.Result == EOneGrabSixteenResult.Ok) || GlobalVar.RunSpace)
{ {
//if(vProductResult.SN.Length==GlobalVar.BarcodeLength) //if(vProductResult.SN.Length==GlobalVar.BarcodeLength)
if(BarCodeHelper.CheckSnLength(vProductResult.SN) || GlobalVar.RunSpace)
{ {
flowStep = EGrrFlowStep.; flowStep = EGrrFlowStep.;
} }
//else else
//{ {
// alarmEntity = AlarmCollection.Get(AlarmConstID.二维码长度异常报警); alarmEntity = AlarmCollection.Get(AlarmConstID.);
// Msgbox.ShowDialog(alarmEntity, EButtonType.Retry, true); Msgbox.ShowDialog(alarmEntity, EButtonType.Retry, true);
//} }
} }
else if (vProductResult != null && vProductResult.Result == EOneGrabSixteenResult.LocationOkScanBarcodeFail) else if (vProductResult != null && vProductResult.Result == EOneGrabSixteenResult.LocationOkScanBarcodeFail)
{ {

@ -31,6 +31,6 @@ using System.Runtime.InteropServices;
// //
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示: //通过使用 "*",如下所示:
[assembly: AssemblyVersion("20.25.38.1")] [assembly: AssemblyVersion("20.25.39.1")]
//[assembly: AssemblyVersion("1.0.0.0")] //[assembly: AssemblyVersion("1.0.0.0")]
//[assembly: AssemblyFileVersion("1.0.0.0")] //[assembly: AssemblyFileVersion("1.0.0.0")]

@ -135,6 +135,7 @@
<Compile Include="Commom\ActiveForms.cs" /> <Compile Include="Commom\ActiveForms.cs" />
<Compile Include="Commom\AxisAlias.cs" /> <Compile Include="Commom\AxisAlias.cs" />
<Compile Include="Commom\AxisPosPrint.cs" /> <Compile Include="Commom\AxisPosPrint.cs" />
<Compile Include="Commom\BarCodeHelper.cs" />
<Compile Include="Commom\BinManager.cs" /> <Compile Include="Commom\BinManager.cs" />
<Compile Include="Commom\BuzzerManager.cs" /> <Compile Include="Commom\BuzzerManager.cs" />
<Compile Include="Commom\DevLog.cs" /> <Compile Include="Commom\DevLog.cs" />

Loading…
Cancel
Save