コード例 #1
0
        public StoreItem GetProductById(string productId)
        {
            var item = repo.GetProductById(productId);
            var grab = new GrabService();

            return(grab.ExpandItem(item));
        }
コード例 #2
0
 public ParameterControlViewModel(GrabService grabService)
 {
     SetCommand = new DelegateCommand(() =>
     {
         grabService.SetParameter(ParameterType, _cameraParameter.Current);
     });
 }
コード例 #3
0
        public MainWindow()
        {
            InitializeComponent();

            CoreConfig config = new CoreConfig();

            var grabService = new GrabService();

            grabService.ImageGrabbed += ImageGrabbed;

            //var infos = grabService.GetDeviceInfos();
            //grabService.Connect(infos.First());
            //HostCommService service =
            //    new HostCommService(
            //        new InspectService(config),
            //        grabService,
            //        new LightControlService(config),
            //        config);

            //service.Connect();

            _grabCommand = new DelegateCommand(() =>
            {
                grabService.Grab();
            });

            this.DataContext = this;
            //textBlock.Text = "Test";
            //this.DataContext = this;
        }
コード例 #4
0
        public ImageViewModel(
            GrabService grabService,
            ZoomService zoomService,
            InspectService inspectService,
            StateStore stateStore,
            CoreConfig coreConfig,
            CancellationToken token)
        {
            StateStore  = stateStore;
            _coreConfig = coreConfig;

            SubResults = new ObservableCollection <SubResultWrapper>();
            BindingOperations.EnableCollectionSynchronization(SubResults, new object());

            grabService.ImageGrabbed += ImageGrabbed;

            ZoomService = zoomService;

            ZoomFitCommand = new DelegateCommand(ZoomFit);
            ZoomInCommand  = new DelegateCommand(ZoomIn);
            ZoomOutCommand = new DelegateCommand(ZoomOut);

            inspectService.Inspected += Inspected;

            _pipeLine = new SinglePipeLine <GrabInfo>(info => DrawImage(info), -1, true);
            _pipeLine.Run(token);
        }
コード例 #5
0
        public SettingCameraViewModel(GrabService grabService, StateStore stateStore, CoreConfig coreConfig)
        {
            CoreConfig = coreConfig;
            StateStore = stateStore;

            AutoValues = Enum.GetValues(typeof(ECameraAutoValue)).Cast <ECameraAutoValue>();

            CameraInfos = grabService.GetDeviceInfos();

            if (grabService.IsConnected())
            {
                ParameterInfo = grabService.GetParameterInfo();
            }

            grabService.ParameterChanged += (parameterInfo =>
            {
                ParameterInfo = parameterInfo;
            });

            RefreshCommand = new DelegateCommand(() =>
            {
                CameraInfos = grabService.GetDeviceInfos();
            });

            ConnectCommand = new DelegateCommand(() =>
            {
                if (CoreConfig.CameraInfo != null)
                {
                    if (grabService.Connect(CoreConfig.CameraInfo))
                    {
                        ParameterInfo = grabService.GetParameterInfo();
                    }
                }
            });

            DisconnectCommand = new DelegateCommand(() =>
            {
                grabService.Disconnect();
                ParameterInfo = null;
            });

            SetAutoCommand = new DelegateCommand <ECameraAutoType?>(type =>
            {
                if (type == null)
                {
                    return;
                }

                grabService.SetAuto(type.Value, ParameterInfo.AutoValues[type.Value]);
            });

            SetTriggerModeCommand = new DelegateCommand(() =>
            {
                grabService.SetTriggerMode(ParameterInfo.OnTriggerMode);
            });
        }
コード例 #6
0
        public CommunicationViewModel(
            GrabService grabService,
            LightControlService lightControlService,
            HostCommService hostCommService,
            InspectService inspectService,
            StateStore stateStore,
            CoreConfig coreConfig,
            CancellationToken token)
        {
            _stateStore = stateStore;

            Task.Run(async() =>
            {
                while (token.IsCancellationRequested == false)
                {
                    _stateStore.HostInfo      = GetConnectionInfo(hostCommService.IsConnected());
                    _stateStore.InspectorInfo = GetConnectionInfo(inspectService.IsConnected());
                    _stateStore.CameraInfo    = GetConnectionInfo(grabService.IsConnected());
                    _stateStore.LightInfo     = GetConnectionInfo(lightControlService.IsConnected());

                    await Task.Delay(coreConfig.CommCheckDelay).ConfigureAwait(false);
                }
            });
        }
コード例 #7
0
        public ControlViewModel(
            GrabService grabService,
            LightControlService lightControlService,
            InspectService inspectService,
            StateStore stateStore,
            CoreConfig coreConfig)
        {
            _stateStore = stateStore;

            GrabCommand = new DelegateCommand(async() =>
            {
                lightControlService.SetValue(coreConfig.LightValues);
                lightControlService.LightOn();

                var grabInfo = await grabService.Grab();
                lightControlService.LightOff();

                //if (grabInfo != null && coreConfig.UseInspector && stateStore.IsManualEnabled)
                //    inspectService.Inspect(grabInfo.Value);

                //if (lightControlService.SetValue(coreConfig.LightValues) && lightControlService.LightOn())
                //{
                //    var grabInfo = await grabService.Grab();
                //    lightControlService.LightOff();

                //    if (grabInfo != null && coreConfig.UseInspector && stateStore.IsManualEnabled)
                //        inspectService.Inspect(grabInfo.Value);
                //}
            });

            LiveCommand = new DelegateCommand(() =>
            {
                lightControlService.SetValue(coreConfig.LightValues);
                lightControlService.LightOn();
                grabService.StartGrab();

                //if (lightControlService.SetValue(coreConfig.LightValues) && lightControlService.LightOn())

                //if (inspectService.Inspected != null)
                //{
                //    List<SubResult> subResults = new List<SubResult>();
                //    subResults.Add(new SubResult(@"Pass, C:\Projects\KT_Interface_20210602\KT_Interface_20210602\KT_Interface\bin\Debug\Temp\1234_20210408120030.Bmp"));
                //    subResults.Add(new SubResult(@"Fail, C:\Projects\KT_Interface_20210602\KT_Interface_20210602\KT_Interface\bin\Debug\Temp\2345_20210408124853.Bmp"));
                //    inspectService.Inspected(new InspectResult(EJudgement.Pass, subResults));
                //}

                StateStore.IsLiveMode = true;
            });

            StopCommand = new DelegateCommand(() =>
            {
                grabService.Stop();

                lightControlService.LightOff();

                StateStore.IsLiveMode = false;
            });

            ExitCommand = new DelegateCommand(() =>
            {
                Application.Current.Shutdown();
            });
        }