Example #1
0
 public bool GetExposure(ref byte[] imgdata)
 {
     if (imgdata == null)
     {
         var mem_len = QhyCcdDll.GetQHYCCDMemLength(_handle);
         imgdata = new byte[mem_len];
     }
     if (_useLive)
     {
         var res = QhyCcdDll.GetQHYCCDLiveFrame(_handle, ref _width, ref _height, ref _bpp, ref _channels, imgdata);
         if (res == uint.MaxValue)
         {
             return(false);
         }
         else if (res == 0)
         {
             return(true);
         }
         else
         {
             throw new Exception($"Unknown error in GetQHYCCDLiveFrame: {res}");
         }
     }
     else
     {
         Check(QhyCcdDll.GetQHYCCDSingleFrame(_handle, ref _width, ref _height, ref _bpp, ref _channels, imgdata));
         ExpSingleFrame();
         return(true);
     }
 }
Example #2
0
        public static string CameraName(int index)
        {
            var builder = new StringBuilder(512);

            Check(QhyCcdDll.GetQHYCCDId(index, builder));
            return(builder.ToString());
        }
Example #3
0
 public void StartExposure()
 {
     if (_useLive)
     {
         Check(QhyCcdDll.BeginQHYCCDLive(_handle));
     }
     else
     {
         ExpSingleFrame();
     }
 }
Example #4
0
        private void ExpSingleFrame()
        {
            var res = QhyCcdDll.ExpQHYCCDSingleFrame(_handle);

            if (res == 0x2001)
            {
                // QHYCCD_READ_DIRECTLY = 0x2001
                return;
            }
            Check(res);
        }
Example #5
0
 public void StopExposure()
 {
     if (_useLive)
     {
         Check(QhyCcdDll.StopQHYCCDLive(_handle));
     }
     else
     {
         Check(QhyCcdDll.CancelQHYCCDExposing(_handle));
     }
 }
Example #6
0
 private void Init()
 {
     Check(QhyCcdDll.SetQHYCCDStreamMode(_handle, _useLive ? 1U : 0U)); // 0 == single, 1 == stream
     Check(QhyCcdDll.InitQHYCCD(_handle));
     Check(QhyCcdDll.GetQHYCCDChipInfo(_handle, ref _chipWidth, ref _chipHeight, ref _width, ref _height, ref _pixelWidth, ref _pixelHeight, ref _bpp));
     Console.WriteLine($"chip name: {_name}, chip width: {_chipWidth}, chip height: {_chipHeight}, image width: {_width}, image height: {_height}, pixel width: {_pixelWidth}, pixel height: {_pixelHeight}, bits per pixel: {_bpp}");
     Check(QhyCcdDll.IsQHYCCDControlAvailable(_handle, CONTROL_ID.CONTROL_TRANSFERBIT));
     Check(QhyCcdDll.SetQHYCCDBitsMode(_handle, 16));
     _bpp = 16;
     Check(QhyCcdDll.SetQHYCCDBinMode(_handle, 1, 1));
     Check(QhyCcdDll.SetQHYCCDResolution(_handle, 0, 0, _width, _height));
 }
Example #7
0
        public QhyCcd(bool useLive, int index)
        {
            var num = NumCameras();

            if (index >= num)
            {
                throw new Exception($"Camera index out of range: {index} >= {num}");
            }
            var builder = new StringBuilder(512);

            Check(QhyCcdDll.GetQHYCCDId(index, builder));
            _name    = builder.ToString();
            _handle  = QhyCcdDll.OpenQHYCCD(builder);
            _useLive = useLive;
            Init();
            _controls = ((CONTROL_ID[])Enum.GetValues(typeof(CONTROL_ID))).Select(x => Control.Make(_handle, x)).Where(x => x != null).ToArray();
        }
Example #8
0
 public static uint NumCameras() => QhyCcdDll.ScanQHYCCD();
Example #9
0
 static QhyCcd()
 {
     Check(QhyCcdDll.InitQHYCCDResource());
 }
Example #10
0
 private Control(IntPtr cameraHandle, CONTROL_ID id)
 {
     _cameraHandle = cameraHandle;
     _id           = id;
     QhyCcdDll.GetQHYCCDParamMinMaxStep(cameraHandle, id, ref _min, ref _max, ref _step);
 }
Example #11
0
 public void Dispose() => Check(QhyCcdDll.CloseQHYCCD(_handle));