Beispiel #1
0
        /// <summary>
        /// Connect to device.
        /// </summary>
        /// <param name="ipAddress">IP address.</param>
        public RaptorCam(string ipAddress)
        {
            calibrationADC = new double[2];
            calibrationDAC = new double[2];
            counts         = new int[numberOfImages, ccdImageSizeX, ccdImageSizeY];
            sysStatus      = new bool[8];
            fpgaStatus     = new bool[8];
            trigMode       = new bool[2];

            try
            {
                // Setup GigE device
                device = PvDevice.CreateAndConnect(ipAddress);
                stream = PvStream.CreateAndOpen(ipAddress);

                PvDeviceGEV deviceGEV = device as PvDeviceGEV;
                PvStreamGEV streamGEV = stream as PvStreamGEV;

                deviceGEV.NegotiatePacketSize();
                deviceGEV.SetStreamDestination(streamGEV.LocalIPAddress, streamGEV.LocalPort);

                // Setup camera serial comms
                serial = new PvDeviceSerialPort();
                serial.Open(device, PvDeviceSerial.Bulk0);

                // Setup pipeline
                pipeline = new PvPipeline(stream);

                SetCameraParameters();
                StartStreaming();
                StartAcquisition();
                Initialize();
            }
            catch
            {
                Disconnect();
                return;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Connects to the device from a device info
        /// </summary>
        /// <param name="aDI"></param>
        void Connect(PvDeviceInfo aDI)
        {
            // Just in case we came here still connected...
            Disconnect();

            if (aDI == null)
            {
                MessageBox.Show("GigE Vision devices not currently supported by this sample.", Text);
                return;
            }

            // Create and connect the device controller based on the selected device
            mDevice = PvDevice.CreateAndConnect("192.168.1.104");

            try
            {
                // Create and open stream
                mStream = PvStream.CreateAndOpen(aDI.ConnectionID);

                // GigE Vision specific connection steps
                if (aDI.Type == PvDeviceInfoType.GEV)
                {
                    PvDeviceGEV lDeviceGEV = mDevice as PvDeviceGEV;
                    PvStreamGEV lStreamGEV = mStream as PvStreamGEV;

                    // Negotiate packet size
                    lDeviceGEV.NegotiatePacketSize();

                    // Set stream destination to our stream object
                    lDeviceGEV.SetStreamDestination(lStreamGEV.LocalIPAddress, lStreamGEV.LocalPort);

                    // Setup camera serial comms
                    serial = new PvDeviceSerialPort();
                    serial.Open(lDeviceGEV, PvDeviceSerial.Bulk0);
                }

                // Create pipeline - requires stream
                mPipeline = new PvPipeline(mStream);
            }
            catch (PvException ex)
            {
                // Failure at some point, display and abort
                MessageBox.Show(ex.Message, Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                Disconnect();

                return;
            }

            // Register to all events of the parameters in the device's node map
            foreach (PvGenParameter lParameter in mDevice.Parameters)
            {
                lParameter.OnParameterUpdate += new OnParameterUpdateHandler(OnParameterChanged);
            }

            // Connect link disconnection handler
            mDevice.OnLinkDisconnected += new OnLinkDisconnectedHandler(OnLinkDisconnected);

            // Update device attributes
            UpdateAttributes(aDI);

            // Fill acquisition mode combo box
            modeComboBox.Items.Clear();
            PvGenEnum lMode = mDevice.Parameters.GetEnum("AcquisitionMode");

            if (lMode != null)
            {
                foreach (PvGenEnumEntry lEntry in lMode)
                {
                    if (lEntry.IsAvailable)
                    {
                        int lIndex = modeComboBox.Items.Add(lEntry.ValueString);
                        if (lEntry.ValueInt == lMode.ValueInt)
                        {
                            modeComboBox.SelectedIndex = lIndex;
                        }
                    }
                }
            }

            // Ready image reception
            StartStreaming();

            // Sync the UI with our new status
            EnableInterface();
        }