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); } }
public static string CameraName(int index) { var builder = new StringBuilder(512); Check(QhyCcdDll.GetQHYCCDId(index, builder)); return(builder.ToString()); }
public void StartExposure() { if (_useLive) { Check(QhyCcdDll.BeginQHYCCDLive(_handle)); } else { ExpSingleFrame(); } }
private void ExpSingleFrame() { var res = QhyCcdDll.ExpQHYCCDSingleFrame(_handle); if (res == 0x2001) { // QHYCCD_READ_DIRECTLY = 0x2001 return; } Check(res); }
public void StopExposure() { if (_useLive) { Check(QhyCcdDll.StopQHYCCDLive(_handle)); } else { Check(QhyCcdDll.CancelQHYCCDExposing(_handle)); } }
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)); }
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(); }
public static uint NumCameras() => QhyCcdDll.ScanQHYCCD();
static QhyCcd() { Check(QhyCcdDll.InitQHYCCDResource()); }
private Control(IntPtr cameraHandle, CONTROL_ID id) { _cameraHandle = cameraHandle; _id = id; QhyCcdDll.GetQHYCCDParamMinMaxStep(cameraHandle, id, ref _min, ref _max, ref _step); }
public void Dispose() => Check(QhyCcdDll.CloseQHYCCD(_handle));