Beispiel #1
0
        private async void InitCameraAndInspector()
        {
            if (MachineConfig.MV_SimulationAcquisitionEnabled)
            {
                _camera = new SimCamera(MachineConfigProvider.MachineConfig.MV_SimulationImageFileNames);
            }
            else
            {
                _camera = new JaiCamera();
            }

            if (!MachineConfig.MV_SimulationInspectorEnabled)
            {
                _inspectionSchema     = InspectionController.GetInspectionSchema();
                _inspectionController = new InspectionController();
            }

            bool isSuccessful;

            isSuccessful = await Task.Run(() => _camera.Init());

            if (!isSuccessful)
            {
                throw new Exception("Camera cannot init");
            }
        }
        private void StartButton_OnClick(object sender, RoutedEventArgs e)
        {
            Save();

            var ret = MessageBox.Show("Are you sure to start? ", "Warning", MessageBoxButton.YesNo);

            if (ret != MessageBoxResult.Yes)
            {
                return;
            }



            List <string> workedDir = new List <string>();

            foreach (var directory in Directories)
            {
                if (string.IsNullOrEmpty(directory.DirectoryPath))
                {
                    //MessageBox.Show("ImageDir is null: " + directory.DirectoryPath);
                    continue;
                }

                workedDir.Add(directory.DirectoryPath);

                // Init
                InspectionSchema schema = null;

                try
                {
                    if (!File.Exists(InspectionSchemaTextBox.Text))
                    {
                        MessageBox.Show("InspectionSchema file is not exist!");
                        return;
                    }

                    //                schema = InspectionSchemaTextBox.Text.LoadFromFile();
                    //schema = InspectionSchemaExtensions.LoadFromFile(InspectionSchemaTextBox.Text);
                    schema = InspectionController.GetInspectionSchema();
                }
                catch (Exception exception)
                {
                    MessageBox.Show("InspectionSchema loading error!");
                    return;
                }

                Run(directory.DirectoryPath, schema.DeepClone());
            }

            string dirs = string.Empty;

            foreach (var dir in workedDir)
            {
                dirs += dir + "\n";
            }

            MessageBox.Show("Directories exported:\n\n" + dirs);
        }
        private void Refresh()
        {
            InspectionSchema schema;

            try
            {
                schema = InspectionController.GetInspectionSchema();
            }
            catch (Exception e)
            {
                MessageBox.Show("GetInspectionSchema filed.\n\n" + e.Message);
                return;
            }

            Inspect(schema);
        }