using VisionBuilder.UI.Common;
using VisionBuilder.UI.Common.Processing;

namespace PralinenPLC;

public class PralinenModule:IVisionBuilderModule
{
    private readonly IRecognitionControl _recognitionControl;
    private NetworkResultInformer _networkResultInformer;

    public PralinenModule(IRecognitionControl recognitionControl)
    {
        _recognitionControl = recognitionControl;
    }

    public void InitializeModule()
    {
        _networkResultInformer = new NetworkResultInformer();
        _recognitionControl.ImageProcessed += _recognitionControl_ImageProcessed;
    }

    private void _recognitionControl_ImageProcessed(VisionBuilder.UI.Common.Commands.ImageProcessedEvent obj)
    {
        if (obj.HasError)
        {
            _networkResultInformer.SignalBad();
        }
        else
        {
            _networkResultInformer.Reset();
        }
    }
}