Example #1
0
        private void CalcBeamCentroid()
        {
            double beamCentroidX, beamCentroidY, beamDiameterX, beamDiameterY;

            instrument.CalcBeamCentroidDia(out beamCentroidX, out beamCentroidY, out beamDiameterX, out beamDiameterY);

            Console.WriteLine("\nInput beam is measured to:");
            Console.WriteLine("CentroidX = " + beamCentroidX.ToString("F3") + " mm");
            Console.WriteLine("CentroidY = " + beamCentroidY.ToString("F3") + " mm");
            Console.WriteLine("DiameterX = " + beamDiameterX.ToString("F3") + " mm");
            Console.WriteLine("DiameterY = " + beamDiameterY.ToString("F3") + " mm");
        }
Example #2
0
        //------------------------------------------------ METHOD FUNCTION 1 ------------------------------------------------
        public void CameraConnectionAndSetup(double exposure)
        {
            //int selectedInstrId = 0;//I believe this is a handler index in the situation that there would be mulitple SHA's connected to the computer.
            string resourceName = default(string);//Just creating a string initially set to null.

            //These two lines are also constructors, but creating StringBuilders. They create strings up to a specified size (WFS.BufferSize, in this case).
            StringBuilder camDriverRev = new StringBuilder(WFS.BufferSize);
            StringBuilder wfsDriverRev = new StringBuilder(WFS.BufferSize);

            //This function comes from the WFS class, which means this structure can be used in the future as a reference (of how to write the code).
            instrument.revision_query(wfsDriverRev, camDriverRev);//Checks for the current revision of computer (installed) and camera (installed) drivers.

            //This chuck writes the driver information to the console.
            Console.WriteLine("");
            Console.Write("WFS instrument driver version : ");
            Console.WriteLine(wfsDriverRev.ToString(), camDriverRev.ToString());
            Console.WriteLine();

            //Calls the helper function, which uses functions from the namespace find connected WFS, get information on the connected WFS, allow the user to select one.
            SelectInstrument(out selectedInstrId, out resourceName);

            //Error Handling, checking that the selected WFS isn't a negative index.
            if (0 > selectedInstrId)
            {
                return;
            }

            //Yields resource name of connected sensor.
            Console.Write("\nResource name of selected WFS: ");
            Console.WriteLine(resourceName.ToString());
            Console.WriteLine();

            Console.WriteLine("\n-----------------------------------------------------------\n");
            Console.WriteLine(">> Initialize Device <<");

            //Not totally sure what is going on here. Having trouble gaining insight into this constructor.
            instrument = new WFS(resourceName, false, false);

            //Fairly straightforward. Getting information about the selected WFS. From the ThorLabs namespace.
            Console.WriteLine(">> Get Device Info <<");
            StringBuilder manufacturerName = new StringBuilder(WFS.BufferSize);
            StringBuilder instrumentName   = new StringBuilder(WFS.BufferSize);
            StringBuilder serialNumberWfs  = new StringBuilder(WFS.BufferSize);
            StringBuilder serialNumberCam  = new StringBuilder(WFS.BufferSize);

            //If this line succeeds, the connection was successful, as we access unit-specific information.
            instrument.GetInstrumentInfo(manufacturerName, instrumentName, serialNumberWfs, serialNumberCam);

            //Writing unit-specific information to the console for verification.
            Console.WriteLine(">> Opened Instrument <<");
            Console.Write("Manufacturer           : ");
            Console.WriteLine(manufacturerName);
            Console.Write("Instrument Name        : ");
            Console.WriteLine(instrumentName);
            Console.Write("Serial Number WFS      : ");
            Console.WriteLine(serialNumberWfs);

            //---NOTE--- This will need to be configured such that it can take in the exposure time and set this (as well as the gain) without console input (for automation).
            // select a microlens array, WFS kits can operate 2 or more MLAs
            SelectMla();

            // Configure the camera resolution to a pre-defined setting
            Console.WriteLine("\n>> Configure Device, use pre-defined settings <<");
            ConfigureDevice(selectedInstrId);

            // set camera exposure time and gain if you don't want to use auto exposure
            // use functions GetExposureTimeRange, SetExposureTime, GetMasterGainRange, SetMasterGain

            double actualGain = 0;

            // set WFS internal reference plane
            Console.WriteLine("\nSet WFS to internal reference plane.\n");
            instrument.SetReferencePlane(InternalRefPlane); // Good. Set to use the internal reference plane to the MLA.
            instrument.SetMasterGain(gain, out actualGain);

            Console.WriteLine("Actual Gain Set to SHA: " + Convert.ToString(actualGain));
            //To define the pupil, I want to just use the beam width. To do this, I first need to find the beam dimensions, and then input them to DefinePupil.
            double beamCentroidX, beamCentroidY, beamDiameterX, beamDiameterY;

            instrument.CalcBeamCentroidDia(out beamCentroidX, out beamCentroidY, out beamDiameterX, out beamDiameterY);

            instrument.SetPupil(beamCentroidX, beamCentroidY, beamDiameterX, beamDiameterY);
        }