-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathAcqThread.h
More file actions
186 lines (149 loc) · 6.8 KB
/
AcqThread.h
File metadata and controls
186 lines (149 loc) · 6.8 KB
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
/*
AcqThread.h
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*
* This file is part of: freeture
*
* Copyright: (C) 2014-2016 Yoan Audureau, Chiara Marmo -- FRIPON-GEOPS-UPSUD
*
* License: GNU General Public License
*
* FreeTure is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* FreeTure is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with FreeTure. If not, see <http://www.gnu.org/licenses/>.
*
* Last modified: 03/10/2016
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
/**
* \file AcqThread.h
* \author Yoan Audureau, Chiara Marmo -- FRIPON-GEOPS-UPSUD
* \version 1.0
* \date 03/10/2016
* \brief Acquisition thread.
*/
#ifndef ACQTHREAD_H
#define ACQTHREAD_H
#include "config.h"
#ifdef LINUX
#define BOOST_LOG_DYN_LINK 1
#endif
#include "ECamPixFmt.h"
#include "EImgFormat.h"
#include "DetThread.h"
#include "StackThread.h"
#include "Device.h"
#include "ExposureControl.h"
#include "ImgProcessing.h"
#include "Ephemeris.h"
#include "Fits2D.h"
#include "SParam.h"
//#include "SpriteThread.h"
//#include "SpriteReader.h"
using namespace cv;
using namespace std;
class AcqThread {
private :
static boost::log::sources::severity_logger< LogSeverityLevel > logger;
static class Init {
public:
Init() {
logger.add_attribute("ClassName", boost::log::attributes::constant<std::string>("AcqThread"));
}
}initializer;
bool mMustStop; // Signal to stop thread.
boost::mutex mMustStopMutex;
boost::thread *mThread; // Acquisition thread.
bool mThreadTerminated; // Terminated status of the thread.
Device *mDevice; // Device used for acquisition.
int mDeviceID; // Index of the device to use.
scheduleParam mNextAcq; // Next scheduled acquisition.
int mNextAcqIndex;
DetThread *pDetection; // Pointer on detection thread in order to stop it or reset it when a regular capture occurs.
StackThread *pStack; // Pointer on stack thread in order to save and reset a stack when a regular capture occurs.
ExposureControl *pExpCtrl; // Pointer on exposure time control object while sunrise and sunset.
string mOutputDataPath; // Dynamic location where to save data (regular captures etc...).
string mCurrentDate;
int mStartSunriseTime; // In seconds.
int mStopSunriseTime; // In seconds.
int mStartSunsetTime; // In seconds.
int mStopSunsetTime; // In seconds.
int mCurrentTime; // In seconds.
// Parameters from configuration file.
stackParam msp;
stationParam mstp;
detectionParam mdtp;
cameraParam mcp;
dataParam mdp;
fitskeysParam mfkp;
framesParam mfp;
videoParam mvp;
// Communication with the shared framebuffer.
boost::condition_variable *frameBuffer_condition;
boost::mutex *frameBuffer_mutex;
boost::circular_buffer<Frame> *frameBuffer;
//boost::circular_buffer<Frame> *frameSprite;
//vector<Frame> *frameSprite;
// Communication with DetThread.
bool *stackSignal;
boost::mutex *stackSignal_mutex;
boost::condition_variable *stackSignal_condition;
// Communication with StackThread.
bool *detSignal;
boost::mutex *detSignal_mutex;
boost::condition_variable *detSignal_condition;
//SPRITE
/*SpriteThread *sprite;
SpriteReader spr_reader;
mutex *mut_sprite;*/
public :
AcqThread( boost::circular_buffer<Frame> *fb,
//boost::circular_buffer<Frame> *frame_sprite,
//vector<Frame> *frame_sprite,
boost::mutex *fb_m,
boost::condition_variable *fb_c,
bool *sSignal,
boost::mutex *sSignal_m,
boost::condition_variable *sSignal_c,
bool *dSignal,
boost::mutex *dSignal_m,
boost::condition_variable *dSignal_c,
DetThread *detection,
StackThread *stack,
int cid,
dataParam dp,
stackParam sp,
stationParam stp,
detectionParam dtp,
cameraParam acq,
framesParam fp,
videoParam vp,
fitskeysParam fkp);
~AcqThread(void);
void operator()();
void stopThread();
bool startThread();
// Return activity status.
bool getThreadStatus();
private :
// Compute in seconds the sunrise start/stop times and the sunset start/stop times.
bool computeSunTimes();
// Build the directory where the data will be saved.
bool buildAcquisitionDirectory(string YYYYMMDD);
// Analyse the scheduled acquisition list to find the next one according to the current time.
void selectNextAcquisitionSchedule(TimeDate::Date date);
// Save a capture on disk.
void saveImageCaptured(Frame &img, int imgNum, ImgFormat outputType, string imgPrefix);
// Run a regular or scheduled acquisition.
void runImageCapture(int imgNumber, int imgExposure, int imgGain, CamPixFmt imgFormat, ImgFormat imgOutput, string imgPrefix);
// Prepare the device for a continuous acquisition.
bool prepareAcquisitionOnDevice();
};
#endif