public bool CAM_connect()
        {
            try
            {
                //server名称
                int    ServerCount = SapManager.GetServerCount();
                int    ServerIndex = ServerCount - 1;
                string ServerName  = SapManager.GetServerName(ServerIndex);
                //设备Index
                int CameraCount   = SapManager.GetResourceCount(ServerName, SapManager.ResourceType.AcqDevice);
                int ResourceIndex = CameraCount - 1;
                //if (CameraCount == 0) MessageBox.Show("没有相机。");

                loc = new SapLocation(ServerName, ResourceIndex);

                //配置文件
                string   ConfigFileName;
                string   ConfigPath      = Environment.GetEnvironmentVariable("SAPERADIR") + "\\camFiles\\User\\";
                string[] ccffiles        = Directory.GetFiles(ConfigPath, "*.ccf");
                int      configFileCount = ccffiles.Length;
                ConfigFileName = ccffiles[0];
                //创建对象
                if (SapManager.GetResourceCount(ServerName, SapManager.ResourceType.AcqDevice) > 0)
                {
                    AcqDevice = new SapAcqDevice(loc, ConfigFileName);
                    Buffers   = new SapBuffer(1, AcqDevice, SapBuffer.MemoryType.ScatterGather);
                    Xfer      = new SapAcqDeviceToBuf(AcqDevice, Buffers);
                    if (!AcqDevice.Create())
                    {
                        return(false);
                    }
                }

                if (!Buffers.Create())
                {
                    return(false);
                }
                if (!Xfer.Create())
                {
                    return(false);
                }


                ////ManagedBusManager busMgr = new ManagedBusManager();
                ////uint numCameras = busMgr.GetNumOfCameras();
                ////ManagedPGRGuid guid = busMgr.GetCameraFromIndex(0);
                ////m_camera = new ManagedCamera();
                ////m_camera.Connect(guid);
                //m_camera.IsConnected()
                //CameraInfo camInfo = m_camera.GetCameraInfo();
            }
            catch (FC2Exception ex)//要修改
            {
                MessageBox.Show("相机连接失败。");
                MessageBox.Show("Failed to load form successfully: " + ex.Message);
                return(false);
            }
            return(true);
        }
Beispiel #2
0
            public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
            {
                var serverNames = new string[SapManager.GetServerCount(SapManager.ResourceType.AcqDevice)];

                for (int i = 0; i < serverNames.Length; i++)
                {
                    serverNames[i] = SapManager.GetServerName(i, SapManager.ResourceType.AcqDevice);
                }

                return(new StandardValuesCollection(serverNames));
            }
Beispiel #3
0
        public void Initialize()
        {

            for (int i = 0; i < SapManager.GetServerCount(); i++)
            {
                // Does this server support "Acq" (frame-grabber) or "AcqDevice" (camera)?
                lsoServerName = SapManager.GetServerName(i);
            }

            octCamera.Initialize();
            lsoCamera.Initialize();
        }
Beispiel #4
0
        private bool InitServerCombo()
        {
            comboBox_Server.Items.Clear();
            for (int i = 0; i < SapManager.GetServerCount(); i++)
            {
                // Does this server support "Acq" (frame-grabber) or "AcqDevice" (camera)?
                bool bAcq = (m_ServerCategory == ServerCategory.ServerAcq || m_ServerCategory == ServerCategory.ServerAll) &&
                            (SapManager.GetResourceCount(i, SapManager.ResourceType.Acq) > 0);
                bool bAcqDevice = (m_ServerCategory == ServerCategory.ServerAcqDevice || m_ServerCategory == ServerCategory.ServerAll) &&
                                  (SapManager.GetResourceCount(i, SapManager.ResourceType.AcqDevice) > 0);

                if (bAcq)
                {
                    string serverName = SapManager.GetServerName(i);
                    comboBox_Server.Items.Add(new MyListBoxItem(serverName, true));
                }
                else if (bAcqDevice)
                {
                    string serverName = SapManager.GetServerName(i);
                    if (serverName.Contains("CameraLink_") == false)
                    {
                        comboBox_Server.Items.Add(new MyListBoxItem(serverName, false));
                    }
                }
            }
            if (comboBox_Server.Items.Count <= 0)
            {
                return(false);
            }
            else
            {
                if (string.IsNullOrEmpty(m_ServerName) || comboBox_Server.FindString(m_ServerName, 0) == -1)
                {
                    comboBox_Server.SelectedIndex = 0;
                    m_ServerName = comboBox_Server.SelectedItem.ToString();
                }
                else
                {
                    comboBox_Server.SelectedIndex = comboBox_Server.FindString(m_ServerName, 0);
                }

                InitResourceCombo();
                return(true);
            }
        }
Beispiel #5
0
        //////// Ask questions to user to select acquisition board/device and config file ////////
        static public bool GetOptionsFromQuestions(MyAcquisitionParams acqParams)
        {
            // Get total number of boards in the system
            string[] configFileNames = new string[MAX_CONFIG_FILES];
            int      serverCount     = SapManager.GetServerCount();

            //string configFileIndexToPrint;

            if (serverCount == 0)
            {
                Console.WriteLine("No device found!\n");
                return(false);
            }

            Console.WriteLine("\nSelect the acquisition server (or 'q' to quit)");
            Console.WriteLine("..............................................");

            // Scan the boards to find those that support acquisition
            int  serverIndex;
            bool serverFound = false;
            bool cameraFound = false;

            for (serverIndex = 0; serverIndex < serverCount; serverIndex++)
            {
                if (SapManager.GetResourceCount(serverIndex, SapManager.ResourceType.Acq) != 0)
                {
                    string serverName = SapManager.GetServerName(serverIndex);
                    Console.WriteLine(serverIndex.ToString() + ": " + serverName);
                    serverFound = true;
                }
                else if (SapManager.GetResourceCount(serverIndex, SapManager.ResourceType.AcqDevice) != 0)
                {
                    string serverName = SapManager.GetServerName(serverIndex);
                    Console.WriteLine(serverIndex.ToString() + ": " + serverName);
                    cameraFound = true;
                }
            }

            // At least one acquisition server must be available
            if (!serverFound && !cameraFound)
            {
                Console.WriteLine("No acquisition server found!\n");
                return(false);
            }

            ConsoleKeyInfo info = Console.ReadKey(true);
            char           key  = info.KeyChar;

            if (key == 'q')
            {
                return(false);
            }
            int serverNum = key - '0'; // char-to-int conversion

            if ((serverNum >= 1) && (serverNum < serverCount))
            {
                acqParams.ServerName = SapManager.GetServerName(serverNum);
            }
            else
            {
                Console.WriteLine("Invalid selection!\n");
                return(false);
            }

            // Scan all the acquisition devices on that server and show menu to user
            int deviceCount    = SapManager.GetResourceCount(acqParams.ServerName, SapManager.ResourceType.Acq);
            int cameraCount    = SapManager.GetResourceCount(acqParams.ServerName, SapManager.ResourceType.AcqDevice);
            int allDeviceCount = deviceCount + cameraCount;

            Console.WriteLine("\nSelect the acquisition device (or 'q' to quit)");
            Console.WriteLine("..............................................\n");

            for (int deviceIndex = 0; deviceIndex < deviceCount; deviceIndex++)
            {
                string deviceName = SapManager.GetResourceName(acqParams.ServerName, SapManager.ResourceType.Acq, deviceIndex);
                Console.WriteLine(((int)(deviceIndex + 1)).ToString() + ": " + deviceName);
            }

            if (deviceCount == 0)
            {
                for (int cameraIndex = 0; cameraIndex < cameraCount; cameraIndex++)
                {
                    string cameraName = SapManager.GetResourceName(acqParams.ServerName, SapManager.ResourceType.AcqDevice, cameraIndex);
                    Console.WriteLine(((int)(cameraIndex + 1)).ToString() + ": " + cameraName);
                }
            }

            info = Console.ReadKey(true);
            key  = info.KeyChar;
            if (key == 'q')
            {
                return(false);
            }
            int deviceNum = key - '0';

            if ((deviceNum >= 1) && (deviceNum <= allDeviceCount))
            {
                acqParams.ResourceIndex = deviceNum - 1;
            }
            else
            {
                Console.WriteLine("Invalid selection!\n");
                return(false);
            }

            ////////////////////////////////////////////////////////////

            // List all files in the config directory
            string configPath = Environment.GetEnvironmentVariable("SAPERADIR") + "\\CamFiles\\User\\";

            if (!Directory.Exists(configPath))
            {
                Console.WriteLine("Directory : {0} Does not exist", configPath);
                return(false);
            }
            string[] ccffiles        = Directory.GetFiles(configPath, "*.ccf");
            int      configFileCount = ccffiles.Length;

            if (configFileCount == 0)
            {
                if (cameraCount == 0)
                {
                    Console.WriteLine("No config file found.\nUse CamExpert to generate a config file before running this example.\n");
                    return(false);
                }
                else
                {
                    Console.WriteLine("\nSelect the config file (or 'q' to quit.)");
                    Console.WriteLine("\n........................................\n");
                    Console.WriteLine("1: No config File.\n");
                    configFileCount = 1;
                }
            }
            else
            {
                Console.WriteLine("\nSelect the config file (or 'q' to quit)");
                Console.WriteLine(".......................................\n");
                configFileCount = 0;
                if (deviceCount == 0 && cameraCount != 0)
                {
                    configFileCount = 1;
                    Console.WriteLine("1: No config File.");
                }

                int configFileShow = 0;
                foreach (string ccfFileName in ccffiles)
                {
                    string fileName = ccfFileName.Replace(configPath, "");
                    if (configFileCount < 9)
                    {
                        configFileShow = configFileCount + 1;
                        Console.WriteLine(configFileShow.ToString() + ": " + fileName);
                    }
                    else
                    {
                        configFileShow = configFileCount - 9 + 'a';
                        Console.WriteLine(Convert.ToChar(configFileShow) + ": " + fileName);
                    }
                    configFileNames[configFileCount] = ccfFileName;
                    configFileCount++;
                }
            }

            info = Console.ReadKey(true);
            key  = info.KeyChar;
            if (key == 'q')
            {
                return(false);
            }
            int configNum = 0;

            // Use numbers 0 to 9, then lowercase letters if there are more than 10 files
            if (key >= '1' && key <= '9')
            {
                configNum = key - '0'; // char-to-int conversion
            }
            else
            {
                configNum = key - 'a' + 10; // char-to-int conversion
            }
            if ((configNum >= 1) && (configNum <= configFileCount))
            {
                acqParams.ConfigFileName = configFileNames[configNum - 1];
            }
            else
            {
                Console.WriteLine("\nInvalid selection!\n");
                return(false);
            }

            Console.WriteLine("\n");
            return(true);
        }
Beispiel #6
0
        static public bool GetCorAcqDeviceOptionsFromQuestions(MyAcquisitionParams acqParams, bool showGigEOnly)
        {
            int       serverCount     = SapManager.GetServerCount();
            int       GenieIndex      = 0;
            ArrayList listServerNames = new System.Collections.ArrayList();

            if (serverCount == 0)
            {
                Console.WriteLine("No device found!\n");
                return(false);
            }

            bool cameraFound = false;

            for (int serverIndex = 0; serverIndex < serverCount; serverIndex++)
            {
                if (SapManager.GetResourceCount(serverIndex, SapManager.ResourceType.AcqDevice) != 0)
                {
                    string serverName = SapManager.GetServerName(serverIndex);
                    if (!showGigEOnly || (showGigEOnly && SapManager.GetResourceCount(serverIndex, SapManager.ResourceType.Acq) == 0))
                    {
                        listServerNames.Add(serverName);
                        GenieIndex++;
                        cameraFound = true;
                    }
                }
            }

            // At least one acquisition server must be available
            if (!cameraFound)
            {
                Console.WriteLine("No GigE camera found!\n");
                return(false);
            }
            #if GRAB_CAMERA_LINK
            Console.WriteLine("\nNote:\nOnly CameraLink cameras will work with this example !\nBehavior is undefined for any other devices.\n");
            #endif
            Console.WriteLine("\nSelect one of the camera(s) detected (or 'q' to quit)");

            int count = 1;
            foreach (string serverName in listServerNames)
            {
                Console.WriteLine("\n........................................");
                Console.WriteLine(Convert.ToString(count) + ": " + serverName);

                string deviceName = SapManager.GetResourceName(serverName, SapManager.ResourceType.AcqDevice, 0);
                Console.WriteLine("User defined Name : " + deviceName);
                Console.Write("........................................\n");
                count++;
            }

            ConsoleKeyInfo info = Console.ReadKey(true);
            char           key  = info.KeyChar;
            if (key == 'q')
            {
                return(false);
            }
            int serverNum = key - '0'; // char-to-int conversion
            if ((serverNum >= 1) && (serverNum <= GenieIndex))
            {
                acqParams.ServerName    = Convert.ToString(listServerNames[serverNum - 1]);
                acqParams.ResourceIndex = 0;
            }
            else
            {
                Console.WriteLine("Invalid selection!\n");
                return(false);
            }

            Console.WriteLine("\n");
            return(true);
        }
Beispiel #7
0
        //////// Ask questions to user to select acquisition board/device and config file ////////
        static public bool GetOptionsFromQuestions(MyAcquisitionParams acqParams)
        {
            // Get total number of boards in the system
            string[] configFileNames = new string[MAX_CONFIG_FILES];
            int      serverCount     = SapManager.GetServerCount();

            //string configFileIndexToPrint;

            if (serverCount == 0)
            {
                MessageBox.Show("No device found!");
                return(false);
            }


            int serverIndex = serverCount - 1;


            // Scan the boards to find those that support acquisition
            bool serverFound = false;
            bool cameraFound = false;

            for (serverIndex = 0; serverIndex < serverCount; serverIndex++)
            {
                if (SapManager.GetResourceCount(serverIndex, SapManager.ResourceType.Acq) != 0)
                {
                    string serverName = SapManager.GetServerName(serverIndex);
                    serverFound = true;
                }
                if (SapManager.GetResourceCount(serverIndex, SapManager.ResourceType.AcqDevice) != 0)
                {
                    string serverName = SapManager.GetServerName(serverIndex);
                    cameraFound = true;
                }
            }

            // At least one acquisition server must be available
            if (!serverFound && !cameraFound)
            {
                MessageBox.Show("No acquisition server found!");
                return(false);
            }


            int serverNum = 1; // char-to-int conversion

            if ((serverNum >= 1) && (serverNum < serverCount))
            {
                acqParams.ServerName = SapManager.GetServerName(serverNum);
            }
            else
            {
                MessageBox.Show("Invalid selection!");
                return(false);
            }

            // Scan all the acquisition devices on that server and show menu to user
            int deviceCount    = SapManager.GetResourceCount(acqParams.ServerName, SapManager.ResourceType.Acq);
            int cameraCount    = SapManager.GetResourceCount(acqParams.ServerName, SapManager.ResourceType.AcqDevice);
            int allDeviceCount = deviceCount + cameraCount;



            for (int deviceIndex = 0; deviceIndex < deviceCount; deviceIndex++)
            {
                string deviceName = SapManager.GetResourceName(acqParams.ServerName, SapManager.ResourceType.Acq, deviceIndex);
            }

            for (int cameraIndex = 0; cameraIndex < cameraCount; cameraIndex++)
            {
                string cameraName = SapManager.GetResourceName(acqParams.ServerName, SapManager.ResourceType.AcqDevice, cameraIndex);
            }


            int deviceNum = 1;

            if ((deviceNum >= 1) && (deviceNum <= allDeviceCount))
            {
                acqParams.ResourceIndex = deviceNum - 1;
            }
            else
            {
                MessageBox.Show("Invalid selection!");
                return(false);
            }

            ////////////////////////////////////////////////////////////

            // List all files in the config directory
            if (!Directory.Exists(configPath))
            {
                MessageBox.Show("Îļþ²»´æÔÚ!");
                return(false);
            }
            string[] ccffiles        = Directory.GetFiles(configPath, "*.ccf");
            int      configFileCount = ccffiles.Length;

            if (configFileCount == 0)
            {
                if (cameraCount == 0)
                {
                    return(false);
                }
                else
                {
                    configFileCount = 1;
                }
            }
            else
            {
                if (cameraCount == 0)
                {
                    if (configFileCount >= 2)
                    {
                        Console.Write(" to ");
                        Console.Write(configFileCount.ToString());
                    }
                    configFileCount = 0;
                }
                else
                {
                    configFileCount += 1;

                    configFileCount = 1;
                }

                int configFileShow = 0;
                foreach (string ccfFileName in ccffiles)
                {
                    string fileName = ccfFileName.Replace(configPath, "");
                    if (configFileCount < 9)
                    {
                        configFileShow = configFileCount + 1;
                    }
                    else
                    {
                        configFileShow = configFileCount - 9 + 'a';
                    }
                    configFileNames[configFileCount] = ccfFileName;
                    configFileCount++;
                }
            }


            int configNum = 1;

            if ((configNum >= 1) && (configNum <= configFileCount))
            {
                acqParams.ConfigFileName = configFileNames[configNum - 1];
            }
            else
            {
                MessageBox.Show("Invalid selection!");
                return(false);
            }

            return(true);
        }
Beispiel #8
0
        static public bool GetCorAcquisitionOptionsFromQuestions(MyAcquisitionParams acqParams)
        {
            // Get total number of boards in the system
            string[] configFileNames = new string[MAX_CONFIG_FILES];
            int      serverCount     = SapManager.GetServerCount();
            int      GrabberIndex    = 0;

            if (serverCount == 0)
            {
                Console.WriteLine("No device found!\n");
                return(false);
            }

            // Scan the boards to find those that support acquisition
            bool serverFound = false;

            for (int serverIndex = 0; serverIndex < serverCount; serverIndex++)
            {
                if (SapManager.GetResourceCount(serverIndex, SapManager.ResourceType.Acq) != 0)
                {
                    GrabberIndex++;
                    serverFound = true;
                }
            }

            // At least one acquisition server must be available
            if (!serverFound)
            {
                Console.WriteLine("No acquisition server found!\n");
                return(false);
            }

            Console.Write("\nSelect the acquisition server: Press ");
            Console.Write("1");
            if (GrabberIndex >= 2)
            {
                Console.Write(" to ");
                Console.Write(GrabberIndex.ToString());
            }
            Console.Write(" or 'q' to quit.");
            Console.WriteLine("........................................");
            string serverName = "";

            for (int serverIndex = 0; serverIndex < serverCount; serverIndex++)
            {
                if (SapManager.GetResourceCount(serverIndex, SapManager.ResourceType.Acq) != 0)
                {
                    serverName = SapManager.GetServerName(serverIndex);
                    Console.WriteLine(serverIndex.ToString() + ": " + serverName);
                }
            }

            ConsoleKeyInfo info = Console.ReadKey(true);
            char           key  = info.KeyChar;

            if (key == 'q')
            {
                return(false);
            }
            int serverNum = key - '0'; // char-to-int conversion

            if ((serverNum >= 1) && (serverNum < serverCount))
            {
                acqParams.ServerName = SapManager.GetServerName(serverNum);
            }
            else
            {
                Console.WriteLine("Invalid selection!\n");
                return(false);
            }

            // Scan all the acquisition devices on that server and show menu to user
            int deviceCount = SapManager.GetResourceCount(acqParams.ServerName, SapManager.ResourceType.Acq);

            #if GRAB_CAMERA_LINK
            Console.Write("\nSelect the device you wish to use on this server: Press ");
            #else
            Console.Write("\nSelect the acquisition device: Press ");
            #endif

            if (deviceCount >= 2)
            {
                Console.Write(" to ");
                Console.Write(deviceCount.ToString());
            }
            Console.Write(" or 'q' to quit.");
            Console.WriteLine("........................................");
            string deviceName = "";
            for (int deviceIndex = 0; deviceIndex < deviceCount; deviceIndex++)
            {
                deviceName = SapManager.GetResourceName(acqParams.ServerName, SapManager.ResourceType.Acq, deviceIndex);
                Console.WriteLine(((int)(deviceIndex + 1)).ToString() + ": " + deviceName);
            }

            info = Console.ReadKey(true);
            key  = info.KeyChar;
            if (key == 'q')
            {
                return(false);
            }
            int deviceNum = key - '0';
            if ((deviceNum >= 1) && (deviceNum <= deviceCount))
            {
                acqParams.ResourceIndex = deviceNum - 1;
            }
            else
            {
                Console.WriteLine("Invalid selection!\n");
                return(false);
            }

            ////////////////////////////////////////////////////////////

            // List all files in the config directory


            if (!Directory.Exists(configPath))
            {
                Console.WriteLine("Directory : {0} Does not exist", configPath);
                return(false);
            }

            string[] ccffiles = Directory.GetFiles(configPath, "*.ccf");

            if (ccffiles.Length == 0)
            {
                Console.WriteLine("No config file found.\nUse CamExpert to generate a config file before running this example.\n");
                return(false);
            }
            else
            {
                Console.Write("\nSelect the config file: Press ");
                Console.Write("1");
                if (ccffiles.Length >= 2)
                {
                    Console.Write(" to ");
                    Console.Write(ccffiles.Length.ToString());
                }
                Console.Write(" or 'q' to quit.");
                Console.WriteLine("........................................");
                int configFileCount = 0;
                int configFileShow  = 0;
                foreach (string ccfFileName in ccffiles)
                {
                    string fileName = ccfFileName.Replace(configPath, "");
                    if (configFileCount < 9)
                    {
                        configFileShow = configFileCount + 1;
                        Console.WriteLine(configFileShow.ToString() + ": " + fileName);
                    }
                    else
                    {
                        configFileShow = configFileCount - 9 + 'a';
                        Console.WriteLine(Convert.ToChar(configFileShow) + ": " + fileName);
                    }
                    configFileNames[configFileCount] = ccfFileName;
                    configFileCount++;
                }

                info = Console.ReadKey(true);
                key  = info.KeyChar;
                if (key == 'q')
                {
                    return(false);
                }
                int configNum = 0;
                // Use numbers 0 to 9, then lowercase letters if there are more than 10 files
                if (key >= '1' && key <= '9')
                {
                    configNum = key - '0'; // char-to-int conversion
                }
                else
                {
                    configNum = key - 'a' + 10; // char-to-int conversion
                }
                if ((configNum >= 1) && (configNum <= configFileCount))
                {
                    acqParams.ConfigFileName = configFileNames[configNum - 1];
                }
                else
                {
                    Console.WriteLine("\nInvalid selection!\n");
                    return(false);
                }
            }
            Console.WriteLine("\n");
            return(true);
        }
Beispiel #9
0
        public override bool DoInit()
        {
            int DalsaCardCount = SapManager.GetServerCount(); //获取图像采集卡的数量

            for (int i = 0; i < DalsaCardCount; i++)
            {
                bool bAcq       = false;
                bool bAcqDevice = false;
                if (SapManager.GetResourceCount(i, SapManager.ResourceType.Acq) > 0)
                {
                    bAcq = true;                                                                     //卡的数量大于0
                }
                if (SapManager.GetResourceCount(i, SapManager.ResourceType.AcqDevice) > 0)
                {
                    bAcqDevice = true;                                                                    //相机数量大于0
                }
                if (bAcq)
                {
                    string ServerName = SapManager.GetServerName(i);
                    if (this.myCamPara.ServerName == ServerName)
                    {
                        bServerFound = true; //发现图像采集卡
                        string DeviceName = SapManager.GetResourceName(ServerName, SapManager.ResourceType.Acq, 0);
                        if (this.myCamPara.DeviceName != DeviceName)
                        {
                            Logger.PopError("采集卡上找到的相机名字和campara里的名字不同");
                            return(false);
                        }
                    }
                }
                else if (bAcqDevice) //没有采集卡,相机直接传给电脑
                {
                    CameraIsFound = true;
                    string serverName = SapManager.GetServerName(i);
                }
            }
            if (!bServerFound && !CameraIsFound)  //至少需要一张采集卡,或者相机装置
            {
                m_Buffers = new SapBuffer();
                return(false);
            }
            else
            {
                SapLocation location = new SapLocation(this.myCamPara.ServerName, 0);
                if (SapManager.GetResourceCount(this.myCamPara.ServerName, SapManager.ResourceType.Acq) > 0)
                {
                    m_Acquisition = new SapAcquisition(location, System.Windows.Forms.Application.StartupPath + "\\ccf\\" + this.myCamPara.CcfPath + ".ccf");
                    //m_AcqDevice = new SapAcqDevice(location, System.Windows.Forms.Application.StartupPath + "\\ccf\\" + this.myCamPara.CcfPath + ".ccf");
                    if (SapBuffer.IsBufferTypeSupported(location, SapBuffer.MemoryType.ScatterGather))
                    {
                        m_Buffers = new SapBuffer(m_RingBufCount, m_Acquisition, SapBuffer.MemoryType.ScatterGather); //buffer里有10段内存,用来循环存储从相机采集的图片
                    }
                    else
                    {
                        m_Buffers = new SapBufferWithTrash(m_RingBufCount, m_Acquisition, SapBuffer.MemoryType.ScatterGatherPhysical);
                    }
                    m_Xfer = new SapAcqToBuf(m_Acquisition, m_Buffers);
                    m_Xfer.Pairs[0].EventType = SapXferPair.XferEventType.EndOfFrame;
                    m_Xfer.XferNotify        += new SapXferNotifyHandler(AcqCallback1);
                    m_Xfer.XferNotifyContext  = this;
                    // event for signal status
                    if (!SeparaInterface_CreateObjects())
                    {
                        Logger.PopError(" 创建 相关的采集、传输、缓存对象失败");
                        this.SeparaInterface_DisposeObjects();
                        return(false);
                    }
                    this.FrameImgHei = this.SeparaInterface_GetImageHeight();
                    this.FrameImgWid = this.SeparaInterface_GetImageWidth();
                    return(true);
                }
            }
            return(false);
        }
Beispiel #10
0
        private void btn_findcamera_Click(object sender, EventArgs e)
        {
            Console.WriteLine(cb_cameraselect.SelectedIndex);
            switch (cb_cameraselect.SelectedIndex)
            {
            case 0:
                Console.WriteLine("\n\nCameras listed by User Defined Name:\n");

                for (int serverIndex = 0; serverIndex < serverCount; serverIndex++)
                {
                    if (SapManager.GetResourceCount(serverIndex, SapManager.ResourceType.AcqDevice) != 0)
                    {
                        SapLocation location = new SapLocation(SapManager.GetServerName(serverIndex), 0);
                        acqDevice = new SapAcqDevice(location);

                        // Create acquisition device object
                        bool status = acqDevice.Create();
                        if (status && acqDevice.FeatureCount > 0)
                        {
                            // Get User Defined Name Feature Value
                            status = acqDevice.GetFeatureValue("DeviceUserID", new SapLut(tx_commandparameter.Text.ToString()));
                            Console.WriteLine("{0}/ {1}", cameraIndex + 1, status ? userDefinedName : "N/A");
                            cameraIndex++;
                        }

                        // Destroy acquisition device object
                        acqDevice.Destroy();
                    }
                }
                if (cameraIndex == 0)
                {
                    Console.WriteLine("No camera found !");
                }
                if (acqDevice != null)
                {
                    acqDevice.Dispose();
                }
                break;

            case 1:
                Console.WriteLine("\n\nCameras listed by Serial Number:\n");
                string serialNumberName = "";

                for (int serverIndex = 0; serverIndex < serverCount; serverIndex++)
                {
                    if (SapManager.GetResourceCount(serverIndex, SapManager.ResourceType.AcqDevice) != 0)
                    {
                        SapLocation location = new SapLocation(SapManager.GetServerName(serverIndex), 0);
                        acqDevice = new SapAcqDevice(location);

                        // Create acquisition device object
                        bool status = acqDevice.Create();
                        if (status && acqDevice.FeatureCount > 0)
                        {
                            // Get Serial Number Feature Value
                            status = acqDevice.GetFeatureValue("DeviceID", out serialNumberName);
                            Console.WriteLine("{0}/ {1}", cameraIndex + 1, status ? serialNumberName : "N/A");
                            cameraIndex++;
                        }

                        // Destroy acquisition device object
                        acqDevice.Destroy();
                    }
                }
                if (cameraIndex == 0)
                {
                    Console.WriteLine("No camera found !");
                }
                if (acqDevice != null)
                {
                    acqDevice.Dispose();
                }
                break;

            case 2:
                Console.WriteLine("\n\nCameras listed by Server Name:\n");

                for (int serverIndex = 0; serverIndex < serverCount; serverIndex++)
                {
                    if (SapManager.GetResourceCount(serverIndex, SapManager.ResourceType.AcqDevice) != 0)
                    {
                        SapLocation location = new SapLocation(SapManager.GetServerName(serverIndex), 0);
                        acqDevice = new SapAcqDevice(location);

                        // Create acquisition device object
                        bool status = acqDevice.Create();
                        if (status && acqDevice.FeatureCount > 0)
                        {
                            // Get Server Name Value
                            Console.WriteLine("{0}/ {1}", cameraIndex + 1, SapManager.GetServerName(serverIndex));
                            cameraIndex++;
                        }

                        // Destroy acquisition device object
                        acqDevice.Destroy();
                    }
                }
                if (cameraIndex == 0)
                {
                    Console.WriteLine("No camera found !");
                }
                if (acqDevice != null)
                {
                    acqDevice.Dispose();
                }
                break;

            case 3:
                Console.WriteLine("\n\nCameras listed by Model Name:\n");
                string deviceModelName = "";

                for (int serverIndex = 0; serverIndex < serverCount; serverIndex++)
                {
                    if (SapManager.GetResourceCount(serverIndex, SapManager.ResourceType.AcqDevice) != 0)
                    {
                        SapLocation location = new SapLocation(SapManager.GetServerName(serverIndex), 0);
                        acqDevice = new SapAcqDevice(location);

                        // Create acquisition device object
                        bool status = acqDevice.Create();
                        if (status && acqDevice.FeatureCount > 0)
                        {
                            // Get Model Name Feature Value
                            status = acqDevice.GetFeatureValue("DeviceModelName", out deviceModelName);
                            Console.WriteLine("{0}/ {1}", cameraIndex + 1, status ? deviceModelName : "N/A");
                            cameraIndex++;
                        }

                        // Destroy acquisition device object
                        acqDevice.Destroy();
                    }
                }
                if (cameraIndex == 0)
                {
                    Console.WriteLine("No camera found !");
                }
                if (acqDevice != null)
                {
                    acqDevice.Dispose();
                }
                break;

            case 4:
                Console.WriteLine("Please type the user defined name:\n");
                userDefinedName = Console.ReadLine();
                serverName      = SapManager.GetServerName(userDefinedName);
                if (serverName.Length > 0)
                {
                    Console.WriteLine("\nServer name for {0} is {1}", userDefinedName, serverName);
                }
                else
                {
                    Console.WriteLine("\nNo server found for {0}", userDefinedName);
                }
                break;

            case 5:
                Console.Write("\nDetecting new CameraLink camera servers... ");
                if (SapManager.DetectAllServers(SapManager.DetectServerType.All))
                {
                    // let time for the detection to execute
                    Thread.Sleep(5000);

                    // get the new server count
                    serverCount = SapManager.GetServerCount();

                    Console.WriteLine("complete\n");
                }
                else
                {
                    Console.WriteLine("failed\n");
                }
                break;
            }
        }