forked from OpenPHDGuiding/phd2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cam_INDI.cpp
704 lines (645 loc) · 21.2 KB
/
cam_INDI.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
/*
* cam_INDI.cpp
* PHD Guiding
*
* Created by Geoffrey Hausheer.
* Copyright (c) 2009 Geoffrey Hausheer.
* All rights reserved.
*
* Redraw for libindi/baseclient by Patrick Chevalley
* Copyright (c) 2014 Patrick Chevalley
* All rights reserved.
*
* This source code is distributed under the following "BSD" license
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of Craig Stark, Stark Labs nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "phd.h"
#ifdef INDI_CAMERA
#include <iostream>
#include <fstream>
#include "config_INDI.h"
#include "camera.h"
#include "time.h"
#include "image_math.h"
#include "cam_INDI.h"
Camera_INDIClass::Camera_INDIClass()
{
ClearStatus();
// load the values from the current profile
INDIhost = pConfig->Profile.GetString("/indi/INDIhost", _T("localhost"));
INDIport = pConfig->Profile.GetLong("/indi/INDIport", 7624);
INDICameraName = pConfig->Profile.GetString("/indi/INDIcam", _T("INDI Camera"));
INDICameraCCD = pConfig->Profile.GetLong("/indi/INDIcam_ccd", 0);
INDICameraPort = pConfig->Profile.GetString("/indi/INDIcam_port",_T(""));
Name = INDICameraName;
SetCCDdevice();
PropertyDialogType = PROPDLG_ANY;
FullSize = wxSize(640,480);
HasSubframes = true;
m_bitsPerPixel = 0;
}
Camera_INDIClass::~Camera_INDIClass()
{
disconnectServer();
}
void Camera_INDIClass::ClearStatus()
{
// reset properties pointer
expose_prop = NULL;
frame_prop = NULL;
frame_type_prop = NULL;
ccdinfo_prop = NULL;
binning_prop = NULL;
video_prop = NULL;
camera_port = NULL;
camera_device = NULL;
pulseGuideNS_prop = NULL;
pulseGuideEW_prop = NULL;
// gui self destroy on lost connection
gui = NULL;
// reset connection status
has_blob = false;
Connected = false;
ready = false;
m_hasGuideOutput = false;
PixSizeX = PixelSize;
PixSizeY = PixelSize;
}
void Camera_INDIClass::CheckState()
{
// Check if the device has all the required properties for our usage.
if(has_blob && Connected && (expose_prop || video_prop)) {
if (! ready) {
//printf("Camera is ready\n");
ready = true;
if (modal) {
modal = false;
}
}
}
}
void Camera_INDIClass::newDevice(INDI::BaseDevice *dp)
{
if (strcmp(dp->getDeviceName(), INDICameraName.mb_str(wxConvUTF8)) == 0) {
// The camera object, maybe this can be useful in the future
camera_device = dp;
}
}
void Camera_INDIClass::newSwitch(ISwitchVectorProperty *svp)
{
// we go here every time a Switch state change
//printf("Camera Receving Switch: %s = %i\n", svp->name, svp->sp->s);
if (strcmp(svp->name, "CONNECTION") == 0) {
ISwitch *connectswitch = IUFindSwitch(svp,"CONNECT");
if (connectswitch->s == ISS_ON) {
Connected = true;
}
else {
if (ready) Disconnect();
}
}
}
void Camera_INDIClass::newMessage(INDI::BaseDevice *dp, int messageID)
{
// we go here every time the camera driver send a message
//printf("Camera Receving message: %s\n", dp->messageQueue(messageID));
}
void Camera_INDIClass::newNumber(INumberVectorProperty *nvp)
{
// we go here every time a Number value change
//printf("Camera Receving Number: %s = %g\n", nvp->name, nvp->np->value);
if (nvp == ccdinfo_prop) {
PixelSize = IUFindNumber(ccdinfo_prop,"CCD_PIXEL_SIZE")->value;
PixSizeX = IUFindNumber(ccdinfo_prop,"CCD_PIXEL_SIZE_X")->value;
PixSizeY = IUFindNumber(ccdinfo_prop,"CCD_PIXEL_SIZE_Y")->value;
m_maxSize.x = IUFindNumber(ccdinfo_prop,"CCD_MAX_X")->value;
m_maxSize.y = IUFindNumber(ccdinfo_prop,"CCD_MAX_Y")->value;
FullSize = wxSize(m_maxSize.x / Binning, m_maxSize.y / Binning);
m_bitsPerPixel = IUFindNumber(ccdinfo_prop, "CCD_BITSPERPIXEL")->value;
}
if (nvp == binning_prop) {
MaxBinning = wxMin(binning_x->max, binning_y->max);
Binning = wxMin(binning_x->value, binning_y->value);
if (Binning > MaxBinning)
Binning = MaxBinning;
m_curBinning = Binning;
FullSize = wxSize(m_maxSize.x / Binning, m_maxSize.y / Binning);
}
}
void Camera_INDIClass::newText(ITextVectorProperty *tvp)
{
// we go here every time a Text value change
//printf("Camera Receving Text: %s = %s\n", tvp->name, tvp->tp->text);
}
void Camera_INDIClass::newBLOB(IBLOB *bp)
{
// we go here every time a new blob is available
// this is normally the image from the camera
//printf("Got camera blob %s \n",bp->name);
if (expose_prop) {
if (strcmp(bp->name,INDICameraBlobName)==0){
cam_bp = bp;
modal = false;
}
}
else if (video_prop){
cam_bp = bp;
// TODO : cumulate the frames received during exposure
}
}
void Camera_INDIClass::newProperty(INDI::Property *property)
{
// Here we receive a list of all the properties after the connection
// Updated values are not received here but in the newTYPE() functions above.
// We keep the vector for each interesting property to send some data later.
//const char* DeviName = property->getDeviceName();
const char* PropName = property->getName();
#ifdef INDI_PRE_1_1_0
INDI_TYPE Proptype = property->getType();
#else
INDI_PROPERTY_TYPE Proptype = property->getType();
#endif
//printf("Camera Property: %s\n",PropName);
if (Proptype == INDI_BLOB) {
//printf("Found BLOB property for %s %s\n", DeviName, PropName);
has_blob = 1;
}
else if ((strcmp(PropName, INDICameraCCDCmd+"EXPOSURE") == 0) && Proptype == INDI_NUMBER) {
//printf("Found CCD_EXPOSURE for %s %s\n", DeviName, PropName);
expose_prop = property->getNumber();
}
else if ((strcmp(PropName, INDICameraCCDCmd+"FRAME") == 0) && Proptype == INDI_NUMBER) {
//printf("Found CCD_FRAME for %s %s\n", DeviName, PropName);
frame_prop = property->getNumber();
frame_x = IUFindNumber(frame_prop,"X");
frame_y = IUFindNumber(frame_prop,"Y");
frame_width = IUFindNumber(frame_prop,"WIDTH");
frame_height = IUFindNumber(frame_prop,"HEIGHT");
}
else if ((strcmp(PropName, INDICameraCCDCmd+"FRAME_TYPE") == 0) && Proptype == INDI_SWITCH) {
//printf("Found CCD_FRAME_TYPE for %s %s\n", DeviName, PropName);
frame_type_prop = property->getSwitch();
}
else if ((strcmp(PropName, INDICameraCCDCmd+"BINNING") == 0) && Proptype == INDI_NUMBER) {
//printf("Found CCD_BINNING for %s %s\n",DeviName, PropName);
binning_prop = property->getNumber();
binning_x = IUFindNumber(binning_prop,"HOR_BIN");
binning_y = IUFindNumber(binning_prop,"VER_BIN");
newNumber(binning_prop);
}
else if ((strcmp(PropName, "VIDEO_STREAM") == 0) && Proptype == INDI_SWITCH) {
//printf("Found Video %s %s\n",DeviName, PropName);
video_prop = property->getSwitch();
}
else if (strcmp(PropName, "DEVICE_PORT") == 0 && Proptype == INDI_TEXT) {
//printf("Found device port for %s \n",DeviName);
camera_port = property->getText();
}
else if (strcmp(PropName, "CONNECTION") == 0 && Proptype == INDI_SWITCH) {
//printf("Found CONNECTION for %s %s\n",DeviName, PropName);
// Check the value here in case the device is already connected
ISwitch *connectswitch = IUFindSwitch(property->getSwitch(),"CONNECT");
Connected = (connectswitch->s == ISS_ON);
}
else if ((strcmp(PropName, "TELESCOPE_TIMED_GUIDE_NS") == 0) && Proptype == INDI_NUMBER){
pulseGuideNS_prop = property->getNumber();
pulseN_prop = IUFindNumber(pulseGuideNS_prop,"TIMED_GUIDE_N");
pulseS_prop = IUFindNumber(pulseGuideNS_prop,"TIMED_GUIDE_S");
}
else if ((strcmp(PropName, "TELESCOPE_TIMED_GUIDE_WE") == 0) && Proptype == INDI_NUMBER){
pulseGuideEW_prop = property->getNumber();
pulseW_prop = IUFindNumber(pulseGuideEW_prop,"TIMED_GUIDE_W");
pulseE_prop = IUFindNumber(pulseGuideEW_prop,"TIMED_GUIDE_E");
}
else if (strcmp(PropName, INDICameraCCDCmd+"INFO") == 0 && Proptype == INDI_NUMBER) {
ccdinfo_prop = property->getNumber();
newNumber(ccdinfo_prop);
}
CheckState();
}
bool Camera_INDIClass::Connect(const wxString& camId)
{
// If not configured open the setup dialog
if (strcmp(INDICameraName,"INDI Camera")==0) CameraSetup();
// define server to connect to.
setServer(INDIhost.mb_str(wxConvUTF8), INDIport);
// Receive messages only for our camera.
watchDevice(INDICameraName.mb_str(wxConvUTF8));
// Connect to server.
if (connectServer()) {
return !ready;
}
else {
// last chance to fix the setup
CameraSetup();
setServer(INDIhost.mb_str(wxConvUTF8), INDIport);
watchDevice(INDICameraName.mb_str(wxConvUTF8));
if (connectServer()) {
return !ready;
}
else {
return true;
}
}
}
wxByte Camera_INDIClass::BitsPerPixel()
{
return m_bitsPerPixel;
}
bool Camera_INDIClass::Disconnect()
{
// Disconnect from server
if (disconnectServer()){
return false;
}
else return true;
}
void Camera_INDIClass::serverConnected()
{
// After connection to the server
// set option to receive blob and messages for the selected CCD
setBLOBMode(B_ALSO, INDICameraName.mb_str(wxConvUTF8), INDICameraBlobName.mb_str(wxConvUTF8));
modal = true;
// wait for the device port property
wxLongLong msec;
msec = wxGetUTCTimeMillis();
while ((!camera_port) && wxGetUTCTimeMillis() - msec < 1 * 1000) {
::wxSafeYield();
}
// Set the port, this must be done before to try to connect the device
if (camera_port && INDICameraPort.Length()) { // the camera port is not mandatory
char* porttext = (const_cast<char*>((const char*)INDICameraPort.mb_str()));
camera_port->tp->text = porttext;
sendNewText(camera_port);
}
// Connect the camera device
connectDevice(INDICameraName.mb_str(wxConvUTF8));
msec = wxGetUTCTimeMillis();
while (modal && wxGetUTCTimeMillis() - msec < 5 * 1000) {
::wxSafeYield();
}
modal = false;
// In case we not get all the required properties or connection to the device failed
if(ready)
{
Connected = true;
m_hasGuideOutput = (pulseGuideNS_prop && pulseGuideEW_prop);
}
else {
pFrame->Alert(_("Cannot connect to camera ")+INDICameraName);
Connected = false;
Disconnect();
}
}
void Camera_INDIClass::serverDisconnected(int exit_code)
{
// in case the connection lost we must reset the client socket
Disconnect();
// after disconnection we reset the connection status and the properties pointers
ClearStatus();
}
void Camera_INDIClass::ShowPropertyDialog()
{
if (Connected) {
// show the devices INDI dialog
CameraDialog();
}
else {
// show the server and device configuration
CameraSetup();
}
}
void Camera_INDIClass::CameraDialog()
{
if (gui) {
gui->Show();
}
else {
gui = new IndiGui();
gui->child_window = true;
gui->allow_connect_disconnect = false;
gui->ConnectServer(INDIhost, INDIport);
gui->Show();
}
}
void Camera_INDIClass::CameraSetup()
{
// show the server and device configuration
INDIConfig *indiDlg = new INDIConfig(wxGetActiveWindow(),TYPE_CAMERA);
indiDlg->INDIhost = INDIhost;
indiDlg->INDIport = INDIport;
indiDlg->INDIDevName = INDICameraName;
indiDlg->INDIDevCCD = INDICameraCCD;
indiDlg->INDIDevPort = INDICameraPort;
// initialize with actual values
indiDlg->SetSettings();
// try to connect to server
indiDlg->Connect();
if (indiDlg->ShowModal() == wxID_OK) {
// if OK save the values to the current profile
indiDlg->SaveSettings();
INDIhost = indiDlg->INDIhost;
INDIport = indiDlg->INDIport;
INDICameraName = indiDlg->INDIDevName;
INDICameraCCD = indiDlg->INDIDevCCD;
INDICameraPort = indiDlg->INDIDevPort;
pConfig->Profile.SetString("/indi/INDIhost", INDIhost);
pConfig->Profile.SetLong("/indi/INDIport", INDIport);
pConfig->Profile.SetString("/indi/INDIcam", INDICameraName);
pConfig->Profile.SetLong("/indi/INDIcam_ccd",INDICameraCCD);
pConfig->Profile.SetString("/indi/INDIcam_port",INDICameraPort);
Name = INDICameraName;
SetCCDdevice();
}
indiDlg->Disconnect();
indiDlg->Destroy();
delete indiDlg;
}
void Camera_INDIClass::SetCCDdevice()
{
if (INDICameraCCD == 0) {
INDICameraBlobName = "CCD1";
INDICameraCCDCmd = "CCD_";
}
else {
INDICameraBlobName = "CCD2";
INDICameraCCDCmd = "GUIDER_";
}
}
bool Camera_INDIClass::ReadFITS(usImage& img, bool takeSubframe, const wxRect& subframe)
{
int xsize, ysize;
fitsfile *fptr; // FITS file pointer
int status = 0; // CFITSIO status value MUST be initialized to zero!
int hdutype, naxis;
int nhdus=0;
long fits_size[2];
long fpixel[3] = {1,1,1};
size_t bsize = static_cast<size_t>(cam_bp->bloblen);
// load blob to CFITSIO
if (fits_open_memfile(&fptr,
"",
READONLY,
&(cam_bp->blob),
&bsize,
0,
NULL,
&status) )
{
pFrame->Alert(_("Unsupported type or read error loading FITS file"));
return true;
}
if (fits_get_hdu_type(fptr, &hdutype, &status) || hdutype != IMAGE_HDU) {
pFrame->Alert(_("FITS file is not of an image"));
PHD_fits_close_file(fptr);
return true;
}
// Get HDUs and size
fits_get_img_dim(fptr, &naxis, &status);
fits_get_img_size(fptr, 2, fits_size, &status);
xsize = (int) fits_size[0];
ysize = (int) fits_size[1];
fits_get_num_hdus(fptr,&nhdus,&status);
if ((nhdus != 1) || (naxis != 2)) {
pFrame->Alert(_("Unsupported type or read error loading FITS file"));
PHD_fits_close_file(fptr);
return true;
}
if (takeSubframe) {
if (img.Init(FullSize)) {
pFrame->Alert(_("Memory allocation error"));
PHD_fits_close_file(fptr);
return true;
}
img.Clear();
img.Subframe = subframe;
unsigned short *rawdata = new unsigned short[xsize*ysize];
if (fits_read_pix(fptr, TUSHORT, fpixel, xsize*ysize, NULL, rawdata, NULL, &status) ) {
pFrame->Alert(_("Error reading data"));
PHD_fits_close_file(fptr);
return true;
}
int i = 0;
for (int y = 0; y < subframe.height; y++)
{
unsigned short *dataptr = img.ImageData + (y + subframe.y) * img.Size.GetWidth() + subframe.x;
memcpy(dataptr, &rawdata[i], subframe.width * sizeof(unsigned short));
i += subframe.width;
}
delete[] rawdata;
}
else {
if (img.Init(xsize,ysize)) {
pFrame->Alert(_("Memory allocation error"));
PHD_fits_close_file(fptr);
return true;
}
// Read image
if (fits_read_pix(fptr, TUSHORT, fpixel, xsize*ysize, NULL, img.ImageData, NULL, &status) ) {
pFrame->Alert(_("Error reading data"));
PHD_fits_close_file(fptr);
return true;
}
}
PHD_fits_close_file(fptr);
return false;
}
bool Camera_INDIClass::ReadStream(usImage& img)
{
int xsize, ysize;
unsigned char *inptr;
unsigned short *outptr;
if (! frame_prop) {
pFrame->Alert(_("No CCD_FRAME property, failed to determine image dimensions"));
return true;
}
if (! (frame_width)) {
pFrame->Alert(_("No WIDTH value, failed to determine image dimensions"));
return true;
}
xsize = frame_width->value;
if (! (frame_height)) {
pFrame->Alert(_("No HEIGHT value, failed to determine image dimensions"));
return true;
}
ysize = frame_height->value;
// allocate image
if (img.Init(xsize,ysize)) {
pFrame->Alert(_("CCD stream: memory allocation error"));
return true;
}
// copy image
outptr = img.ImageData;
inptr = (unsigned char *) cam_bp->blob;
for (int i = 0; i < xsize * ysize; i++)
*outptr ++ = *inptr++;
return false;
}
bool Camera_INDIClass::Capture(int duration, usImage& img, int options, const wxRect& subframeArg)
{
if (Connected) {
bool takeSubframe = UseSubframes;
wxRect subframe(subframeArg);
// we can set the exposure time directly in the camera
if (expose_prop) {
if (Binning != m_curBinning)
{
FullSize = wxSize(m_maxSize.x / Binning, m_maxSize.y / Binning);
binning_x->value = Binning;
binning_y->value = Binning;
sendNewNumber(binning_prop);
m_curBinning = Binning;
}
if (subframe.width <= 0 || subframe.height <= 0)
{
takeSubframe = false;
}
// Program the size
if (!takeSubframe)
{
subframe = wxRect(0, 0, FullSize.GetWidth(), FullSize.GetHeight());
}
if (subframe != m_roi)
{
frame_x->value = subframe.x*Binning;
frame_y->value = subframe.y*Binning;
frame_width->value = subframe.width*Binning;
frame_height->value = subframe.height*Binning;
sendNewNumber(frame_prop);
m_roi = subframe;
}
//printf("Exposing for %d(ms)\n", duration);
// set the exposure time, this immediately start the exposure
expose_prop->np->value = (double)duration/1000;
sendNewNumber(expose_prop);
modal = true; // will be reset when the image blob is received
unsigned long loopwait = duration > 100 ? 10 : 1;
CameraWatchdog watchdog(duration, GetTimeoutMs());
while (modal) {
wxMilliSleep(loopwait);
if (WorkerThread::TerminateRequested())
return true;
if (watchdog.Expired())
{
DisconnectWithAlert(CAPT_FAIL_TIMEOUT);
return true;
}
}
}
// for video camera without exposure time setting
else if (video_prop){
takeSubframe = false;
//printf("Enabling video capture\n");
ISwitch *v_on = IUFindSwitch(video_prop,"ON");
ISwitch *v_off = IUFindSwitch(video_prop,"OFF");
v_on->s = ISS_ON;
v_off->s = ISS_OFF;
// start capture, every video frame is received as a blob
sendNewSwitch(video_prop);
// wait the required time
wxMilliSleep(duration); // TODO : add the frames received during exposure
//printf("Stop video capture\n");
v_on->s = ISS_OFF;
v_off->s = ISS_ON;
sendNewSwitch(video_prop);
}
else {
return true;
}
//printf("Exposure end\n");
if (strcmp(cam_bp->format, ".fits") == 0) {
//printf("Processing fits file\n");
// for CCD camera
if ( ! ReadFITS(img,takeSubframe,subframe) ) {
if (options & CAPTURE_SUBTRACT_DARK) {
//printf("Subtracting dark\n");
SubtractDark(img);
}
if (options & CAPTURE_RECON) {
if (PixSizeX != PixSizeY) SquarePixels(img, PixSizeX, PixSizeY);
}
return false;
} else {
return true;
}
} else if (strcmp(cam_bp->format, ".stream") == 0) {
//printf("Processing stream file\n");
// for video camera
return ReadStream(img);
} else {
pFrame->Alert(_("Unknown image format: ") + wxString::FromAscii(cam_bp->format));
return true;
}
}
else {
// in case the camera is not connected
return true;
}
// we must never go here
return true;
}
bool Camera_INDIClass::HasNonGuiCapture(void)
{
return true;
}
// Camera ST4 port
bool Camera_INDIClass::ST4HasNonGuiMove(void)
{
return true;
}
bool Camera_INDIClass::ST4PulseGuideScope(int direction, int duration)
{
if (pulseGuideNS_prop && pulseGuideEW_prop) {
switch (direction) {
case EAST:
pulseE_prop->value = duration;
pulseW_prop->value = 0;
sendNewNumber(pulseGuideEW_prop);
break;
case WEST:
pulseE_prop->value = 0;
pulseW_prop->value = duration;
sendNewNumber(pulseGuideEW_prop);
break;
case NORTH:
pulseN_prop->value = duration;
pulseS_prop->value = 0;
sendNewNumber(pulseGuideNS_prop);
break;
case SOUTH:
pulseN_prop->value = 0;
pulseS_prop->value = duration;
sendNewNumber(pulseGuideNS_prop);
break;
case NONE:
printf("error CameraINDI::Guide NONE\n");
break;
}
wxMilliSleep(duration);
return false;
}
else return true;
}
#endif