Newer
Older
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
/*
* seqIDataMgr.cpp
*
* Created on: Mar 18, 2022
* Author: Fulvio Laudisio
*/
#include <pthread.h>
#include <ctime>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include "seqIDataMgr.hpp"
#include "base64.h" // from64tobits
SeqDataMgr * SeqDataMgr::m_pSeqDataMgr = NULL;
SeqDataMgr::SeqDataMgr(Ltcs::IifServiceWorkerInterfacePtr &_iif):
sashaSave(IProperty::Switch, "sasha_save", "enable_save"),
sashaObjName(IProperty::Text, "sasha", "OBJNAME"),
sashaNumSeqs(IProperty::Number, "sasha", "num_seqs"),
sashaSeqNum(IProperty::Number, "sasha", "seq_num"),
// sashaNumCoadds(IProperty::Number, "sasha", "acquire"),
sashaNumCoadds(IProperty::Number, "sasha", "num_coadds"),
sashaNumDrops(IProperty::Number, "sasha", "num_drops"),
sashaNumReads(IProperty::Number, "sasha", "num_reads"),
sashaNumGroups(IProperty::Number, "sasha", "num_groups"),
sashaNumResets(IProperty::Number, "sasha", "num_resets"),
sashaReadout(IProperty::Text, "sasha", "def_readout_region_name"),
sashaBlob(IProperty::Unknown, "sasha_save", "save_image"),
sashaLargestFileNumber(IProperty::Number, "sasha_save", "largest_filenum"),
sashaExposeProp(IProperty::Switch, "sasha", "start_acquire"),
sharknirTemperatureA(IProperty::Unknown, "sharknir_temp", "sensor"),
sharknirTemperatureB(IProperty::Unknown, "sharknir_temp", "sensor"),
sashaStop(IProperty::Switch, "sasha", "stop"),
sashaFrequencyMode(IProperty::Text, "sasha", "def_mode_name"),
sashaEnableCont(IProperty::Switch, "sasha" , "enable_cont" )
{
U6_LLOG(__FUNCTION__);
// m_ptrIc = boost::shared_ptr<indiClient>(new indiClient(*_ptrIoService, m_ptrSharedQueue, "127.0.0.1", "7624"));
// m_ptrIc2 = boost::shared_ptr<indiClient2>(new indiClient2(_ptrIoService, "193.206.241.72", "7624")); // TODO : UNHARDCODE sashaws IP and get it from obs_ctrl-ice.cfg
// m_ptrIc2 = boost::shared_ptr<indiClient2>(new indiClient2(_ptrIoService, _callback_register, "127.0.0.1", "7624"));
// D_LLOG("created pointer to indiClient2 object");
m_iif = _iif;
SeqDataMgr::m_pSeqDataMgr = this;
m_dataSaveDirectory = "/data/fits/";
// sashaBlob.add(IElement("file"));
sashaBlob.setBLOBEnable(IProperty::Never);
sashaNumCoadds.add(IElement("value"));
sashaNumCoadds["value"].setValue<int>(1);
m_sashaProps.insert(std::pair<std::string, IProperty & >("NDIT", sashaNumSeqs));
m_sashaProps.insert(std::pair<std::string, IProperty & >("NDITINDEX", sashaSeqNum));
m_sashaProps.insert(std::pair<std::string, IProperty & >("READOUT", sashaReadout));
m_sashaProps.insert(std::pair<std::string, IProperty & >("SAVE", sashaSave));
m_sashaProps.insert(std::pair<std::string, IProperty & >("OBJECTNAME", sashaObjName));
m_sashaProps.insert(std::pair<std::string, IProperty & >("NCOADDS", sashaNumCoadds));
m_sashaProps.insert(std::pair<std::string, IProperty & >("NDROPS", sashaNumDrops));
m_sashaProps.insert(std::pair<std::string, IProperty & >("NGROUPS", sashaNumGroups));
m_sashaProps.insert(std::pair<std::string, IProperty & >("NREADS", sashaNumReads));
m_sashaProps.insert(std::pair<std::string, IProperty & >("NRESETS", sashaNumResets));
m_sashaProps.insert(std::pair<std::string, IProperty & >("EXPOSE", sashaExposeProp));
m_sashaProps.insert(std::pair<std::string, IProperty & >("STOP", sashaStop));
m_sashaProps.insert(std::pair<std::string, IProperty & >("FREQUENCY", sashaFrequencyMode));
m_sashaProps.insert(std::pair<std::string, IProperty & >("CONTINUOUS", sashaEnableCont));
m_sashaProps.insert(std::pair<std::string, IProperty & >("LARGESTFILENUM", sashaLargestFileNumber));
m_sashaProps.insert(std::pair<std::string, IProperty & >("SENSORTEMPA", sharknirTemperatureA));
m_sashaProps.insert(std::pair<std::string, IProperty & >("SENSORTEMPB", sharknirTemperatureB));
m_sashaPropsSet["NDIT"] = true;
m_sashaPropsSet["NDITINDEX"] = true;
m_sashaPropsSet["READOUT"] = true;
m_sashaPropsSet["SAVE"] = true;
m_sashaPropsSet["OBJECTNAME"] = true;
m_sashaPropsSet["NCOADDS"] = true;
m_sashaPropsSet["NDROPS"] = true;
m_sashaPropsSet["NGROUPS"] = true;
m_sashaPropsSet["NREADS"] = true;
m_sashaPropsSet["NRESETS"] = true;
m_sashaPropsSet["EXPOSE"] = true;
m_sashaPropsSet["FREQUENCY"] = true;
m_sashaTiming["Full_Image"] = 4.2783f;
m_sashaTiming["Center"] = 2.6751f;
m_sashaTiming["Bottom"] = 1.0719f;
m_sashaTiming["Top"] = 1.0719f;
m_sashaTiming["256x256"] = 0.2745f;
m_sashaTiming["128x128"] = 0.0718f;
m_sashaTiming["1000x1000"] = 4.0481;
m_sashaTiming["coro_stripe"] = 0.1283;
m_getFitsAbortFlag = 0;
m_bReceivingFitsFile = false;
m_curInstMode = "GEN";
StartIndiClientThread();
//Flags
m_bFlagChanged = true;
m_bSaveOnlyExposedFiles = true;
m_bSaveIncomingBlob = false;
U8_LLOG("");
}
void SeqDataMgr::StartIndiClientThread()
{
pthread_create(&m_indi_tid, NULL, indi_client_thread, this);
}
SeqDataMgr::~SeqDataMgr()
{
}
#define OCS_FRAME_TIME_FULLIMAGE 4.2783f
#define OCS_FRAME_TIME_CENTER 2.6751f
#define OCS_FRAME_TIME_BOTTOM 1.0719f
#define OCS_FRAME_TIME_TOP 1.0719f
#define OCS_FRAME_TIME_256X256 0.2745f
#define OCS_FRAME_TIME_128X128 0.0718f
#define OCS_FRAME_TIME_1000X1000 4.0481f
#define OCS_FRAME_TIME_COROSTRIPE 0.1283f
#define OCS_NUM_MAX_FRAMES 25
void set_ramp(float exp_time, float frame_time, int num_max_frames, int ncoadds, int &groups, int &reads, int &drops)
{
float r = exp_time / (frame_time * ncoadds);
float eff_frame_time = frame_time * ncoadds;
if (r < num_max_frames)
{
groups = 1;
reads = (int) r;
if (r < 1.f)
reads = 1;
drops = 0;
}
else
{
groups = num_max_frames;
reads = 1;
float fpdrops = (exp_time - groups * eff_frame_time) / ((groups - 1) * eff_frame_time);
int floor_drops = (int) fpdrops;
float eff_exp_time = eff_frame_time * (groups * reads + (groups - 1) * floor_drops);
float extra_time = eff_frame_time * (groups - 1);
if (abs(exp_time - eff_exp_time) < abs(exp_time - (eff_exp_time + extra_time)))
{
drops = floor_drops;
}
else
{
drops = floor_drops + 1;
}
}
}
std::string get_current_wdir()
{
char buff[FILENAME_MAX];
getcwd(buff, FILENAME_MAX);
std::string curr_work_dir(buff);
return curr_work_dir;
}
int SeqDataMgr::SetWorkingDirectory()
{
time_t rawtime;
struct tm * time_info;
char buffer[80];
// __time_t prova;
// __TIME_T_TYPE prova2;
time(&rawtime);
rawtime -= (3600*8); // Next day start 8:00 in the morning;
time_info = localtime(&rawtime);
strftime(buffer, 80, "%Y-%m-%d", time_info);
m_currentSaveDirectory = buffer;
std::string to_set = m_dataSaveDirectory + m_currentSaveDirectory;
struct stat st = {0};
if(stat(to_set.c_str(), &st) == -1)
{
U9_LLOG("Creating directory : \"" << to_set << "\"")
mkdir(to_set.c_str(), 0775);
chown(to_set.c_str(), 1000, 1000);
}
return chdir(to_set.c_str());
}
Loading
Loading full blame...