forked from OpenPHDGuiding/phd2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cam_OSPL130.cpp
110 lines (96 loc) · 2.84 KB
/
cam_OSPL130.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
* cam_OSPL130.cpp
* PHD Guiding
*
* Created by Craig Stark.
* Copyright (c) 2006, 2007, 2008, 2009, 2010 Craig Stark.
* All rights reserved.
*
*/
#include "phd.h"
#include "camera.h"
#include "time.h"
#include "image_math.h"
#include "wx/stopwatch.h"
#if defined (OS_PL130)
#include "cam_OSPL130.h"
#include "cameras/OSPL130API.h"
static bool DLLExists(const wxString& DLLName)
{
wxStandardPathsBase& StdPaths = wxStandardPaths::Get();
if (wxFileExists(StdPaths.GetExecutablePath().BeforeLast(PATHSEPCH) + PATHSEPSTR + DLLName))
return true;
if (wxFileExists(StdPaths.GetExecutablePath().BeforeLast(PATHSEPCH) + PATHSEPSTR + ".." + PATHSEPSTR + DLLName))
return true;
if (wxFileExists(wxGetOSDirectory() + PATHSEPSTR + DLLName))
return true;
if (wxFileExists(wxGetOSDirectory() + PATHSEPSTR + "system32" + PATHSEPSTR + DLLName))
return true;
return false;
}
CameraOpticstarPL130::CameraOpticstarPL130()
{
Connected = false;
Name=_T("Opticstar PL-130M");
FullSize = wxSize(1280,1024);
m_hasGuideOutput = false;
HasGainControl = false;
Color = false;
}
wxByte CameraOpticstarPL130::BitsPerPixel()
{
return 16;
}
bool CameraOpticstarPL130::Connect(const wxString& camId)
{
// returns true on error
if (!DLLExists("OSPL130RT.dll"))
return CamConnectFailed(_("Cannot find OSPL130RT.dll"));
int retval = OSPL130_Initialize((int) Color, false, 0, 2);
if (retval)
return CamConnectFailed(_("Cannot init camera"));
//OSPL130_SetGain(6);
Connected = true;
return false;
}
bool CameraOpticstarPL130::Disconnect()
{
OSPL130_Finalize();
Connected = false;
return false;
}
bool CameraOpticstarPL130::Capture(int duration, usImage& img, int options, const wxRect& subframe)
{
bool still_going = true;
int mode = 3 * (int) Color;
if (img.Init(FullSize))
{
DisconnectWithAlert(CAPT_FAIL_MEMORY);
return true;
}
if (OSPL130_Capture(mode,duration)) {
pFrame->Alert(_("Cannot start exposure"));
return true;
}
if (duration > 100) {
wxMilliSleep(duration - 100); // wait until near end of exposure, nicely
wxGetApp().Yield();
// if (Abort) {
// MeadeCam->AbortImage();
// return true;
// }
}
while (still_going) { // wait for image to finish and d/l
wxMilliSleep(20);
OSPL130_IsExposing(&still_going);
wxGetApp().Yield();
}
// Download
OSPL130_GetRawImage(0,0,FullSize.GetWidth(),FullSize.GetHeight(), (void *) img.ImageData);
// byte swap
if (options & CAPTURE_SUBTRACT_DARK) SubtractDark(img);
if (Color && (options & CAPTURE_RECON))
QuickLRecon(img);
return false;
}
#endif