Exemplo n.º 1
0
        public static bool IsConnected()
        {
            bool isConnected = false;
            log.Debug("IsConnected: Attempting to retrieve list of connected UC480 cameras...");

            try
            {
                ThorlabDevice tempCam = new ThorlabDevice();

                ThorlabDevice.UC480_CAMERA_LIST camList = new ThorlabDevice.UC480_CAMERA_LIST();
                int list = tempCam.GetCameraList(ref camList);

                // if camera count is larger than 0 there is a UC camera connected..
                if (camList.dwCount > 0)
                {
                    log.Info("IsConnected: Detected " + camList.dwCount.ToString() + " UC480 camera(s) - ThorlabCamera.IsConnected will return 'true' - Thorlabs camera detected");
                    isConnected = true;
                }
                else
                {
                    log.Info("IsConnected: Detected no UC480 camera(s) - ThorlabCamera.IsConnected will return 'false', i.e. No Thorlabs detected");
                }

                tempCam = null; // it's not started or anything, just a reference for the method call above
            }
            catch (Exception ex)
            {
                log.Warn("IsConnected: Exception occurred whilst trying to detect Thorlabs camera (" + ex.Message + "), IsConnected will return 'false', i.e. No Thorlabs detected. Stack trace is: " + ex.StackTrace);
            }

            return isConnected;
        }