The VisAO Camera
reconstructor.cpp
Go to the documentation of this file.
1 /************************************************************
2  * reconstructor.cpp
3  *
4  * Author: Jared R. Males (jrmales@email.arizona.edu)
5  *
6  * Definitions for a class to perform real-time reconstruction of wavefronts.
7  *
8  * Developed as part of the Magellan Adaptive Optics system.
9  ************************************************************/
10 
11 /** \file reconstructor.cpp
12  * \author Jared R. Males
13  * \brief Definitions for a class to perform real-time reconstruction of wavefronts.
14  *
15  *
16  */
17 
18 #include "reconstructor.h"
19 
20 
21 namespace VisAO
22 {
23 
24 reconstructor * global_reconstructor;
25 
26 reconstructor::reconstructor(int argc, char **argv) throw (AOException) : VisAOApp_standalone(argc, argv)
27 {
28  Create();
29 }
30 
31 reconstructor::reconstructor(std::string name, const std::string &conffile) throw (AOException) : VisAOApp_standalone(name, conffile)
32 {
33  Create();
34 }
35 
37 {
38  valid_recmat = 0;
39 
40  std::string pathtmp;
41 
42  std::string visao_root = getenv("VISAO_ROOT");
43 
44  //Set up the ping_fifo_path
45  try
46  {
47  pathtmp = (std::string)(ConfigDictionary())["ping_fifo_path"];
48  }
49  catch(Config_File_Exception)
50  {
51  pathtmp = "fifos";
52  }
53  ping_fifo_path = visao_root + "/" + pathtmp +"/";
54  _logger->log(Logger::LOG_LEV_INFO, "Set ping_fifo_path: %s", ping_fifo_path.c_str());
55 
56  setup_fifo_list(4);
57  setup_baseApp(0, 1, 1, 0, false); //local and script fifos
58 
59  std::string pingin = ping_fifo_path + "reconstructor39_ping_in";
60  std::string pingout = ping_fifo_path + "reconstructor39_ping_out";
61  set_fifo_list_channel(&fl, PING_IN_FIFO, RWBUFF_SZ, pingin.c_str(), pingout.c_str(), 0, (void *)this);
62 
63  pingin = ping_fifo_path + "frameselector_ping_in";
64  pingout = ping_fifo_path + "frameselector_ping_out";
65  set_fifo_list_channel(&fl, FS_PING_FIFO, RWBUFF_SZ, pingout.c_str(), pingin.c_str(), 0, (void *)this);
66 
67  try
68  {
69  slopes_shmem_key = (int)(ConfigDictionary())["bcu39_shmem_key"];
70  }
71  catch(Config_File_Exception)
72  {
74  }
75  _logger->log(Logger::LOG_LEV_INFO, "Set the shared memory key for slopes (bcu39_shmem_key): %i", slopes_shmem_key);
76 
77  try
78  {
79  strehls_shmem_key = (int)(ConfigDictionary())["strehls_shmem_key"];
80  }
81  catch(Config_File_Exception)
82  {
84  }
85  _logger->log(Logger::LOG_LEV_INFO, "Set the shared memory key for strehls (strehls_shmem_key): %i", strehls_shmem_key);
86 
87  try
88  {
89  num_strehls = (int)(ConfigDictionary())["num_strehls"];
90  }
91  catch(Config_File_Exception)
92  {
93  num_strehls = 2500;
94  }
95  _logger->log(Logger::LOG_LEV_INFO, "Set the number of strehls in circular buffer to (num_strehls): %i", num_strehls);
96 
97  pthread_mutex_init(&reconMutex, NULL);
98 
99  //Init the status board
100  rsb = 0;
102  if(create_statusboard(sizeof(basic_status_board)) != 0)
103  {
105  _logger->log(Logger::LOG_LEV_ERROR, "Could not create status board.");
106  }
107  else
108  {
110  strncpy(bsb->appname, MyFullName().c_str(), 25);
111  bsb->max_update_interval = pause_time;
113  }
114 
115 #ifdef REC_USE_GPU
116  try
117  {
118  rmat.rec_tech = (int)(ConfigDictionary())["rec_tech"];
119  }
120  catch(Config_File_Exception)
121  {
122  rmat.rec_tech = REC_ATLAS;
123  }
124  _logger->log(Logger::LOG_LEV_INFO, "Set the reconstruction technique to (rec_tech): %i", rmat.rec_tech);
125 #endif
126 
127  try
128  {
129  rmat.tel_diam = (double)(ConfigDictionary())["tel_diam"];
130  rmat.median_r0 = (double)(ConfigDictionary())["median_r0"];
131  rmat.median_r0_lam = (double)(ConfigDictionary())["median_r0_lam"];
132  rmat.fitting_A = (double)(ConfigDictionary())["fitting_A"];
133  rmat.fitting_B = (double)(ConfigDictionary())["fitting_B"];
134  rmat.reflection_gain = (double)(ConfigDictionary())["reflection_gain"];
135  }
136  catch(Config_File_Exception)
137  {
138  rmat.tel_diam = 6.5;
139  rmat.median_r0 = 18.;
140  rmat.median_r0_lam = .55;
141  rmat.fitting_A = 0.232555;
142  rmat.fitting_B = -0.840466;
143  rmat.reflection_gain = 2.;
144  }
145 
146 
147 
148  FSPing_enabled = 1;
149 
150  //Set a default lambda
151  set_lambda(765.);
152 
153  strehldata = 0;
154  wfedata = 0;
155  cal_a = 1.0;
156  cal_b = 0.0;
157 
158 
159 
160  rmsAccum.resize(5,330.);
161 
162 }
163 
164 int reconstructor::set_matint(std::string fname)
165 {
166  std::string dir = getenv("VISAO_ROOT");
167 
168  if(fname == "none" || fname == "") return -1;
169 
170  recFileName = fname;
171 
172  dir += "/calib/visao/reconstructor/RecMats/";
173  dir += fname;
174 
175  pthread_mutex_lock(&reconMutex);
176 
177  if(rmat.load_recmat_LBT(dir) == 0)
178  {
179  valid_recmat = 1;
180 
181  logss.str("");
182  logss << "set recmat: " << dir;
183  _logger->log(Logger::LOG_LEV_INFO, logss.str().c_str());
184 
185  n_modes = rmat.n_modes;
186  ho_middle = 200;
187  if(n_modes <= 200) ho_middle = 150;
188  if(n_modes <= 100) ho_middle = 66;
189 
190  std::cout << "n_modes = " << n_modes << "\n";
191  std::cout << "ho_middle = " << ho_middle << "\n";
192  pthread_mutex_unlock(&reconMutex);
193  return 0;
194  }
195  else
196  {
197  std::cout << "setting invalid recmat\n";
198  valid_recmat = 0;
199 
200  logss.str("");
201  logss << "failed to set recmat: " << dir;
202  _logger->log(Logger::LOG_LEV_ERROR, logss.str().c_str());
203 
204  n_modes = 0;
205  ho_middle = 0;
206 
207  std::cout << n_modes << "\n";
208  std::cout << ho_middle << "\n";
209 
210  pthread_mutex_unlock(&reconMutex);
211  return -1;
212  }
213 
214 }
215 
216 int reconstructor::set_lambda(float lam)
217 {
218  lambda = lam;
219 
220  lamgain = -pow(2.*3.14159/lam,2);
221 
222  logss.str("");
223  logss << "set lambda: " << lambda;
224  _logger->log(Logger::LOG_LEV_INFO, logss.str().c_str());
225 
226  return 0;
227 }
228 
229 int reconstructor::set_filter(std::string fname)
230 {
231  filter_name = fname;
232 
233  fir.read_coef_file(fname);
234 
235  fir.print_filter();
236  if(strehldata == 0) delete[] strehldata;
237  strehldata = new float[fir.get_order()];
238 
239  if(wfedata == 0) delete[] wfedata;
240  wfedata = new float[fir.get_order()];
241 
242  for(int i=0; i< fir.get_order(); i++)
243  {
244  wfedata[i] = 0;
245  strehldata[i] = 0;
246  }
247 
248  logss.str("");
249  logss << "set filter: " << fname;
250  _logger->log(Logger::LOG_LEV_INFO, logss.str().c_str());
251 
252  return 0;
253 }
254 
255 int reconstructor::set_cal_a(float a)
256 {
257  cal_a = a;
258 
259  logss.str("");
260  logss << "set cal_a: " << cal_a;
261  _logger->log(Logger::LOG_LEV_INFO, logss.str().c_str());
262 
263  return 0;
264 }
265 
266 int reconstructor::set_cal_b(float b)
267 {
268  cal_b = b;
269 
270  logss.str("");
271  logss << "set cal_b: " << cal_b;
272  _logger->log(Logger::LOG_LEV_INFO, logss.str().c_str());
273 
274  return 0;
275 }
276 
277 int reconstructor::reconstruct()
278 {
279  float sumvar;
280  static int last_image = -1;
281  int curr_image;
282 
283  if(pthread_mutex_trylock(&reconMutex) != 0)
284  {
285  return -1;
286  }
287 
288  if(!valid_recmat)
289  {
290  pthread_mutex_unlock(&reconMutex);
291  return -1;
292  }
293 
294  curr_image = slopes_sis.get_last_image();
295 
296  if(curr_image == last_image || curr_image < -1)
297  {
298  pthread_mutex_unlock(&reconMutex);
299  return 0;
300  }
301 
302  slopes_sim = slopes_sis.get_image(curr_image);
303  last_image = curr_image;
304 
305  slopes = (float *) (slopes_sim.imdata+12832);
306 
307  rmat.reconstruct(slopes);
308 
309  //We check here because there could be time differences between when
310  //gainSetter updates are received and when Arbitrator updates are received
311  //Future: have the recmat be based on gainSet, and guarantee that they are synched.
312  if(aosb)
313  ho_middle = aosb->homiddle;
314  if(ho_middle == 0)
315  ho_middle = n_modes;
316 
317  rmat.calc_sumvar(&sumvar);
318  //rmat.calc_sumvar(&tt_wfe, 0, 2, false);
319  rmat.calc_sumvar(&ho1_wfe, 2, ho_middle, false);
320  rmat.calc_sumvar(&ho2_wfe, ho_middle, -1, false);
321 
322  //Calculate RMS values
323  std::vector<float> forRms(5);
324  forRms[0] = sqrt(sumvar);
325  forRms[1] = rmat.amp[0]*rmat.reflection_gain*rmat.unit_conversion;
326  forRms[2] = rmat.amp[1]*rmat.reflection_gain*rmat.unit_conversion;;
327  forRms[3] = sqrt(ho1_wfe);
328  forRms[4] = sqrt(ho2_wfe);
329  rmsAccum.addValues(forRms);
330  rmsAccum.calcRmss();
331 
332  rawstrehl = exp(lamgain * sumvar);
333  float filtstrehl, filtwfe;
334  //Cycle strehldata
335  if(fir.get_order() > 0)
336  {
337  for(int i=0;i<fir.get_order()-1;i++)
338  {
339  wfedata[i] = wfedata[i+1];
340  strehldata[i] = strehldata[i+1];
341  }
342  wfedata[fir.get_order()-1] = sqrt(sumvar);
343  strehldata[fir.get_order()-1] = rawstrehl;
344 
345  filtstrehl = fir.apply_filter(strehldata, fir.get_order());
346  filtwfe = fir.apply_filter(wfedata, fir.get_order());
347 
348  }
349  else filtstrehl = rawstrehl;
350 
352  strehl_sim->depth = 32;
353  strehl_sim->frameNo = slopes_sim.frameNo;
354 
355  strehl_sim->frame_time = slopes_sim.frame_time;
356 
357  strehl_sim->imdata[0] = sumvar;
358  strehl_sim->imdata[1] = filtwfe;
359  strehl_sim->imdata[2] = rmat.amp[0]*rmat.reflection_gain*rmat.unit_conversion;;
360  strehl_sim->imdata[3] = rmat.amp[1]*rmat.reflection_gain*rmat.unit_conversion;;
361  strehl_sim->imdata[4] = rawstrehl;
362  strehl_sim->imdata[5] = rawstrehl*cal_a + cal_b;
363  strehl_sim->imdata[6] = filtstrehl;
364  strehl_sim->imdata[7] = filtstrehl*cal_a + cal_b;
365 
366  strehl_sim->imdata[10] = ho1_wfe;
367  strehl_sim->imdata[12] = ho2_wfe;
368 
369  strehl_sim->imdata[14] = rmsAccum.rmss[0];
370  strehl_sim->imdata[15] = rmsAccum.rmss[1];
371  strehl_sim->imdata[16] = rmsAccum.rmss[2];
372  strehl_sim->imdata[17] = rmsAccum.rmss[3];
373  strehl_sim->imdata[18] = rmsAccum.rmss[4];
374 
375  if(rsb)
376  {
377  if(sumvar > 0) rsb->inst_wfe = -1;//sqrt(sumvar);
378  else rsb->inst_wfe = -1.;
379  }
380 
382 
383  if(FSPing_enabled) write_fifo_channel(FS_PING_FIFO, "1", 2, 0);
384 
385  pthread_mutex_unlock(&reconMutex);
386  return 0;
387 
388 }//void reconstructor::reconstruct()
389 
390 
392 {
393 
394  //set_matint("/home/aosup/visao/calib/visao/reconstructor/RecMats/Rec_20111125_165625.fits");
395  set_matint("Rec_20130329_210902.fits");
396 
398  {
399  ERROR_REPORT("Error attaching to shared memory for slopes. Waiting and trying again.");
401  {
402  sleep(1);
403  if(TimeToDie) return -1;
404  }
405  }
406 
407  if(strehl_sis.create_shm(strehls_shmem_key, num_strehls, sizeof(sharedim_stack_header) + num_strehls*sizeof(intptr_t) + (num_strehls)*(sizeof(sharedim<float>) + REC_TELEM_N*sizeof(float))) != 0)
408  {
409  ERROR_REPORT("Error attaching to shared memory for sharedim_stack.");
410  return -1;
411  }
412 
413  strehl_sis.header->save_sequence = 0;
414 
415  //Install the main thread handler
417  {
418  ERROR_REPORT("Error installing main thread catcher.");
419  return -1;
420  }
421 
422  signal(SIGIO, SIG_IGN);
423 
424  //Startup the I/O signal handling thread
425  if(start_signal_catcher() != 0)
426  {
427  ERROR_REPORT("Error starting signal catching thread.");
428  return -1;
429  }
430  sleep(1);
431  //Now Block all I/O signals in this thread.
432  if(block_sigio() != 0)
433  {
434  ERROR_REPORT("Error starting signal catching thread.");
435  return -1;
436  }
437 
438  LOG_INFO("starting up . . .");
439 
440  //Setup to catch the ping in this high priority thread
441  //The low priority signal catcher will block it.
442  global_reconstructor = this;
443 
444  fcntl(fl.fifo_ch[PING_IN_FIFO].fd_in, F_SETOWN, getpid());
445 
446  int rv = fcntl(fl.fifo_ch[PING_IN_FIFO].fd_in, F_SETSIG, RTSIGPING);
447  if(rv < 0)
448  {
449  std::cerr << "Error changing signal.\n";
450  perror("reconstructor");
451  }
452 
453  struct sigaction act;
454  sigset_t sset;
455 
456  act.sa_sigaction = &frame_ready;
457  act.sa_flags = SA_SIGINFO;
458  sigemptyset(&sset);
459  act.sa_mask = sset;
460 
461  errno = 0;
462 
463  if(sigaction(RTSIGPING, &act, 0) < 0)
464  {
465  logss.str("");
466  logss << "Error setting signal handler for RTSIGPING. Errno says: " << strerror(errno) << ".";
467  error_report(Logger::LOG_LEV_ERROR, logss.str());
468  return -1;
469  }
470 
471  //wait for VisAOI to become available
472 
473  aosb = 0;
474  size_t sz;
475 
476  while(!TimeToDie && !aosb)
477  {
478  aosb = (VisAO::aosystem_status_board*) attach_shm(&sz, STATUS_aosystem, 0);
479  sleep(1);
480  }
481 
482  int last_loop_on = -1;
483 
484 
485  while(!TimeToDie)
486  {
487  sleep(1);
488  read_fifo_channel(&fl.fifo_ch[PING_IN_FIFO]);
489 
490  if(recFileName != aosb->reconstructor)
491  {
492  set_matint(aosb->reconstructor);
493  }
494  }
495 
496  pthread_join(signal_thread, 0);
497 
498  return 0;
499 
500 }//int reconstructor::Run()
501 
502 std::string reconstructor::local_command(std::string com)
503 {
504  std::string resp;
505  _logger->log(Logger::LOG_LEV_TRACE, "Received local command: %s.", com.c_str());
506  resp = common_command(com, CMODE_LOCAL);
507  _logger->log(Logger::LOG_LEV_TRACE, "Response to local command: %s.", resp.c_str());
508  return resp;
509 }
510 
511 std::string reconstructor::script_command(std::string com)
512 {
513  std::string resp;
514  _logger->log(Logger::LOG_LEV_TRACE, "Received local command: %s.", com.c_str());
515  resp = common_command(com, CMODE_LOCAL);
516  _logger->log(Logger::LOG_LEV_TRACE, "Response to local command: %s.", resp.c_str());
517  return resp;
518 }
519 
520 std::string reconstructor::common_command(std::string com, int cmode)
521 {
522  char resp[50];
523 
524 
525  if(com == "recmat?")
526  {
527  if(rmat.get_filePath() == "") return " ";//empty string is a fifo error
528  return recFileName;
529  }
530 
531  if(com == "cal_a?")
532  {
533  snprintf(resp, 50, "%f\n", cal_a);
534  return resp;
535  }
536  if(com == "cal_b?")
537  {
538  snprintf(resp, 50, "%f\n", cal_b);
539  return resp;
540  }
541 
542  if(com == "lambda?")
543  {
544  snprintf(resp, 50, "%f\n", lambda);
545  return resp;
546  }
547 
548  if(com == "filter?")
549  {
550  if(filter_name == "") return " "; //empty string is a fifo error
551  return filter_name;
552  }
553 
554  if(com.length() > 5)
555  {
556  if(com.substr(0, 5) == "cal_a")
557  {
558  if(cmode == control_mode)
559  {
560  std::string a = com.substr(5, com.length()-4);
561  if(set_cal_a(strtod(a.c_str(),0)) == 0) return "0\n";
562  else return "-1\n";
563  }
564  else
565  {
566  return control_mode_response();
567  }
568  }
569  if(com.substr(0, 5) == "cal_b")
570  {
571  if(cmode == control_mode)
572  {
573  std::string b = com.substr(5, com.length()-4);
574  if(set_cal_b(strtod(b.c_str(),0)) == 0) return "0\n";
575  else return "-1\n";
576  }
577  else
578  {
579  return control_mode_response();
580  }
581  }
582 
583  }
584 
585  if(com.length() > 6)
586  {
587  if(com.substr(0, 6)== "recmat")
588  {
589  if(cmode == control_mode)
590  {
591  std::string newmat = com.substr(6, com.length()-5);
592  if(set_matint(newmat) == 0) return "0\n";
593  else return "-1\n";
594  }
595  else
596  {
597  return control_mode_response();
598  }
599  }
600 
601  if(com.substr(0, 6)== "lambda")
602  {
603  if(cmode == control_mode)
604  {
605  std::string newlam = com.substr(6, com.length()-5);
606  if(set_lambda(strtod(newlam.c_str(),0)) == 0) return "0\n";
607  else return "-1\n";
608  }
609  else
610  {
611  return control_mode_response();
612  }
613  }
614 
615  if(com.substr(0, 6)== "filter")
616  {
617  if(cmode == control_mode)
618  {
619  std::string newfil = com.substr(7, com.length()-6);
620  if(set_filter(newfil) == 0) return "0\n";
621  else return "-1\n";
622  }
623  else
624  {
625  return control_mode_response();
626  }
627  }
628 
629  if(com.substr(0, 6) == "select")
630  {
631  if(cmode == control_mode)
632  {
633  int s = atoi(com.substr(6, com.length()-6).c_str());
634 
635  if(s) FSPing_enabled = 1;
636  else FSPing_enabled = 0;
637  return "0\n";
638  }
639  else
640  {
641  return control_mode_response();
642  }
643  }
644  }
645  return "UNKOWN COMMAND?";
646 }//std::string reconstructor::common_command(std::string com, int cmode)
647 
649 {
651  {
653 
654 
655  int startn = strehl_sis.get_last_image();
656  if(startn < 1) return 0;
657 
658 
659  strehl_simavg = strehl_sis.get_image(startn-1);
660  double t0, t1;
661 
662  t0 = tv_to_curr_time(&strehl_simavg.frame_time);
663  t1 = t0;
664 
665  double avgwfe=0, avgwfe2 = 0;
666  double n = 0;
667  double tmpwfe2;
668  while(fabs(t0 - t1) < 1.0 )
669  {
670 
671  tmpwfe2 = strehl_simavg.imdata[0];
672  if(tmpwfe2 < 1e8 && !isnan(tmpwfe2))
673  {
674  avgwfe2 += tmpwfe2;
675  avgwfe += sqrt(tmpwfe2);
676  n++;
677  }
678  startn--;
679  if(startn < 1) startn = strehl_sis.get_n_images()-1;
680 
681 
683 
684  t1 = tv_to_curr_time(&strehl_simavg.frame_time);
685 
686  }
687 
688  avgwfe /= n;
689  avgwfe2 /= n;
690 
691  rsb->avgwfe_1_sec = avgwfe;
692 
693  if(avgwfe2 >= avgwfe*avgwfe) rsb->stdwfe_1_sec = sqrt(avgwfe2 - avgwfe*avgwfe);
694  else rsb->stdwfe_1_sec = -1;
695 
696  std::cout << "homiddle: " << ho_middle << "\n";
697 
698  }
699  return 0;
700 }//int reconstructor::update_statusboard()
701 
702 
703 
704 void frame_ready(int signum __attribute__((unused)), siginfo_t *siginf, void *ucont __attribute__((unused)))
705 {
706  if(siginf->si_code == POLL_IN && !TimeToDie)
707  {
708  global_reconstructor->reconstruct();
709  }
710 }
711 
712 } //namespace VisAO
int enable_next_image()
Increments last_image.
double inst_wfe
Instantaneous WFE.
Definition: statusboard.h:145
#define DATA_strehls
Shared memory key for reconstructed strehl data.
Definition: statusboard.h:35
virtual int start_signal_catcher(bool inherit_sched=true)
Starts the signal catching loop.
int strehls_shmem_key
Pointer to the slopes vector.
int read_fifo_channel(fifo_channel *fc)
Read data from the input fifo channel.
Definition: fifoutils.c:246
#define STATUS_reconstructor
Shared memory key for the reconstructor status board.
Definition: statusboard.h:49
int rec_tech
Which reconstructor technique to use, either REC_ATLAS or REC_CPU.
Definition: recmat.h:64
std::ostringstream logss
Conveninence string stream for building log messages.
void * statusboard_shmemptr
The pointer to the shared memory block for the statusboard.
virtual void error_report(int LogLevel, std::string emsg)
Report an error. Also calls log_msg.
sharedim_stack_header * header
Convenient pointer to the stack header, has same value as shmemptr.
virtual int Run()
The application main loop, to be re-implemented in derived classes.
virtual int update_statusboard()
Update the status board.
virtual int update_statusboard()
Update the reconstructor Status Board shared memory.
virtual int setup_baseApp(bool usethreads=false)
Install fifo channels.
float unit_conversion
Factor to convert variances to nanometers.
Definition: recmat.h:62
fifo_channel * fifo_ch
An array of fifo_channels.
Definition: fifoutils.h:207
int setup_fifo_list(int nfifos)
Allocate the fifo_list.
float * amp
The reconstructed amplitudes, a vector of length n_modes.
Definition: recmat.h:68
sharedim< IMDATA_TYPE > * set_next_image(int nx, int ny)
Sets the next image, and returns a pointer to it, but does not increment last_image.
double stdwfe_1_sec
1 second std dev of WFE
Definition: statusboard.h:144
sharedim< float > * strehl_sim
Shared memory image, from ring buffer, for strehl data.
void Create()
Processes the config file.
sharedim_stack< float > strehl_sis
Shared memory ring buffer for strehl data.
Convenience structure for the stack header.
pthread_t signal_thread
Identifier for the separate signal handling thread.
key_t statusboard_shmemkey
The key used to lookup the shared memory.
int calc_sumvar(float *sumvar, int m0=2, int m1=-1, bool fiterr=true)
Calculate the sum of the variances, e.g. the dot product of the amplitude vector. ...
Definition: recmat.cpp:196
int n_modes
The number of modes, and the rows in the reconstructor matrix.
Definition: recmat.h:55
virtual int block_sigio()
Sets the signal mask to block SIGIO and RTSIGIO.
int TimeToDie
Global set by SIGTERM.
#define REC_TELEM_N
The size of each telemetry vector.
Definition: reconstructor.h:33
sharedim< unsigned char > slopes_sim
Shared memory image of slopes (a vector actually)
int attach_shm(key_t mkey)
Attachess the shared memory. A Reader process should start here.
std::string control_mode_response()
Convenience function to return the control type response string, e.g. "A\n".
void * attach_shm(size_t *sz, key_t mkey, int shmemid)
Attach to a shared memory buffer and get its size.
Definition: libvisaoc.c:90
fifo_list fl
The list of named-pipe fifos used for inter-process comms.
double pause_time
Time to pause during application main loop.
Definition: VisAOApp_base.h:84
sharedim< IMDATA_TYPE > get_image(int imno)
Gets an image, as a sharedim structure, with the imdata pointer properly set for the calling process...
#define DATA_framegrabber39
Shared memory key for BCU39 data.
Definition: statusboard.h:28
int create_statusboard(size_t sz)
Creates and attaches to the statusboard shared memory.
sharedim_stack< unsigned char > slopes_sis
The shared memory ring buffer for slopes storage.
std::string local_command(std::string com)
Called by __local_command after control state logic.
static int control_mode
The current control mode.
Declarations for a class to perform real-time reconstruction of wavefronts.
virtual int install_sig_mainthread_catcher()
Install the SIG_MAINTHREAD signal catcher.
int create_shm(key_t mkey, size_t sz)
For the writer process, creates then attaches the shared memory.
float apply_filter(float *data, int len)
Apply the filter to the data fector of length len.
Definition: fir_filter.cpp:75
std::string script_command(std::string com)
Called by __script_command after control state logic.
int reconstruct(float *slopes)
Given a new slopes vector, reconstruct the amplitudes.
Definition: recmat.cpp:177
The namespace of VisAO software.
float reflection_gain
Factor to apply to reconstructed amplitudes to account for mirror reflection.
Definition: recmat.h:61
int get_n_images()
Returns the value of n_images currently in the header.
int get_last_image()
Returns the value of last_image currently in the header.
double avgwfe_1_sec
1 second average WFE
Definition: statusboard.h:143
int slopes_shmem_key
The key for the shared memory for slopes.
double tv_to_curr_time(struct timeval *tvp)
Convert a timeval structure to double seconds.
Definition: libvisaoc.c:35
#define RWBUFF_SZ
The size of the i/o buffer.
Definition: fifoutils.h:43
int set_fifo_list_channel(fifo_list *fl, int nch, int buffsz, const char *fin, const char *fout, int(*inp_hand)(fifo_channel *), void *adata)
Set the details of one channel in the list.
Definition: fifoutils.c:373
int write_fifo_channel(int ch, const char *com, int comlen, std::string *resp)
Write data to a fifo_channel, and get a response if desired.
sharedim< float > strehl_simavg
Shared memory image, from ring buffer, for strehl data.