Exemplo n.º 1
0
        private void RunOffline(int x)
        {
            UiMainForm.LogMessage(string.Format("Ccd{0}开始离线运行", CcdId));
            string        vppHome = Path.GetDirectoryName(VppFileName);
            DirectoryInfo diImage = new DirectoryInfo(Path.Combine(vppHome, "image"));

            if (!diImage.Exists)
            {
                diImage.Create();
            }

            int imageCount = 1;
            var toolBlock  = MyCogToolBlock;

            VisionRoi roi = new VisionRoi(CcdId);

            int offlineImageCycle = x;

            if (offlineImageCycle == 0)
            {
                CogIPOneImageTool[] myCogIPOneImageTools = toolBlock.Tools.OfType <CogIPOneImageTool>().ToArray();
                for (int i = 0; i < imageCount; i++)
                {
                    CogImage8Grey inputImage  = myCogIPOneImageTools[i].OutputImage as CogImage8Grey;
                    var           outputImage = roi.Trim(inputImage);
                    CcdTerminalIn vtIn        = new CcdTerminalIn(CcdId, outputImage, i);
                    VtInBlock.Post(vtIn);
                }

                return;
            }
            else
            {
                for (int i = 0; i < imageCount; i++)
                {
                    var imageName = string.Format("{0}-{1}-{2}.bmp", CcdId, offlineImageCycle, i + 1).Trim('-');
                    var imageFile = Path.Combine(diImage.FullName, imageName);
                    if (File.Exists(imageFile))
                    {
                        Bitmap        bmpFile     = new Bitmap(imageFile);
                        CogImage8Grey inputImage  = new CogImage8Grey(bmpFile);
                        var           outputImage = roi.Trim(inputImage);
                        CcdTerminalIn vtIn        = new CcdTerminalIn(CcdId, outputImage, i);
                        VtInBlock.Post(vtIn);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void OnGrabImage(int x)
        {
            var grabBlobk  = RunParams.CcdGrabBlock[CcdId];
            int imageIndex = x;

            UiMainForm.LogMessage(string.Format("Ccd{0}开始拍照", CcdId));

            var vIo = VirtualIo.GetDevice(CcdId);

            if (imageIndex == 0)
            {
                for (int i = 1; i < 3; i++)
                {
                    vIo.ResetPort(i);
                }
            }
            double        exposure = DbScheme.GetCcdParams(CcdId, BrandId, x, "Exposure");
            CcdTerminalIn vtIn     = GrabImage(imageIndex, exposure);

            VtInBlock.Post(vtIn);
        }