1.0.6
This commit is contained in:
@@ -10,14 +10,15 @@ namespace PackstrasseBarcodeReader
|
||||
public class PackstrasseBarcodeReaderModule : IVisionBuilderModule
|
||||
{
|
||||
private readonly PackstrasseBarcodeReaderSettings _settings;
|
||||
private readonly IRecognitionControl _recognitionControl;
|
||||
private readonly SingleCameraVM _singleCameraVm;
|
||||
private SerialPort _port;
|
||||
|
||||
|
||||
public PackstrasseBarcodeReaderModule(PackstrasseBarcodeReaderSettings settings, IRecognitionControl recognitionControl)
|
||||
public PackstrasseBarcodeReaderModule(PackstrasseBarcodeReaderSettings settings, SingleCameraVM singleCameraVm)
|
||||
{
|
||||
_settings = settings;
|
||||
_recognitionControl = recognitionControl;
|
||||
_singleCameraVm = singleCameraVm;
|
||||
|
||||
}
|
||||
|
||||
private void _port_DataReceived(object sender, SerialDataReceivedEventArgs e)
|
||||
@@ -26,7 +27,8 @@ namespace PackstrasseBarcodeReader
|
||||
byte[] buffer = new byte[_port.BytesToRead];
|
||||
_port.Read(buffer, 0, _port.BytesToRead);
|
||||
var data = Encoding.ASCII.GetString(buffer).Trim();
|
||||
var recipes = _recognitionControl.GetRecipesData();
|
||||
var vm = _singleCameraVm.GetRecipeSelectionVm();
|
||||
|
||||
|
||||
string searchString = data;
|
||||
if (_settings.BarcodeRecipeMappings.Any(x=>x.Barcode==searchString))
|
||||
@@ -34,14 +36,17 @@ namespace PackstrasseBarcodeReader
|
||||
searchString = _settings.BarcodeRecipeMappings.First(x => x.Barcode == searchString).RecipeName;
|
||||
}
|
||||
|
||||
var existingRecipe=recipes.FirstOrDefault(x => x.RecipeName == searchString);
|
||||
var existingRecipe= vm.Recipes.FirstOrDefault(x => x.RecipeName == searchString);
|
||||
if (existingRecipe == null)
|
||||
{
|
||||
Log.Warning("No matching recipe found for data: {Data}", data);
|
||||
return;
|
||||
}
|
||||
|
||||
_recognitionControl.SetRecipe(existingRecipe);
|
||||
vm.SelectedRecipe = vm.Recipes.FirstOrDefault(r => r.RecipeName == existingRecipe.RecipeName);
|
||||
_singleCameraVm.SynchronizationContext!.Post((_) =>
|
||||
{
|
||||
_singleCameraVm.ProcessRecipeSelectionVm(vm);
|
||||
}, null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user