1 #include "VisAOIClient.h"
15 VisAOIClient::VisAOIClient( std::string name,
const std::string &conffile)
throw (AOException):
MagAOIClient(name, conffile), VisAOApp_base()
20 void VisAOIClient::Create() throw (AOException)
22 std::string visao_root, fifoin, fifoout;
29 visao_root = getenv(
"VISAO_ROOT");
32 fifoin = visao_root +
"/" +
fifo_path +
"/" + wollaston_process +
"_com_remote_in";
33 fifoout = visao_root +
"/" +
fifo_path +
"/" + wollaston_process +
"_com_remote_out";
37 fifoin = visao_root +
"/" +
fifo_path +
"/" + focus_process +
"_com_remote_in";
38 fifoout = visao_root +
"/" +
fifo_path +
"/" + focus_process +
"_com_remote_out";
42 fifoin = visao_root +
"/" +
fifo_path +
"/" + gimbal_process +
"_com_remote_in";
43 fifoout = visao_root +
"/" +
fifo_path +
"/" + gimbal_process +
"_com_remote_out";
51 _logger->log(Logger::LOG_LEV_ERROR,
"Could not create status board.");
57 strncpy(bsb->appname, MyFullName().c_str(), 25);
67 data_log_time_length = (double)(ConfigDictionary())[
"data_log_time_length"];
69 catch(Config_File_Exception)
71 data_log_time_length = 120.;
73 _logger->log(Logger::LOG_LEV_INFO,
"Set logger file length to (data_log_time_length): %f secs", data_log_time_length);
77 data_save_path = (std::string)(ConfigDictionary())[
"data_save_path"];
79 catch(Config_File_Exception)
81 data_save_path =
"data/syslogs";
83 _logger->log(Logger::LOG_LEV_INFO,
"Set data save path to (data_save_path): %s", data_save_path.c_str());
85 data_file_prefix =
"aosys";
87 pthread_mutex_init(&threadMutex, 0);
95 fifo_path = (std::string) ConfigDictionary()[
"fifo_path"];
97 catch (Config_File_Exception &e)
105 wollaston_process = (std::string)(ConfigDictionary())[
"wollaston_process"];
106 _logger->log(Logger::LOG_LEV_INFO,
"Wollaston process name (wollaston_process) set to %s.", wollaston_process.c_str());
108 catch(Config_File_Exception)
110 wollaston_process =
"wollastonstatus";
111 _logger->log(Logger::LOG_LEV_INFO,
"Wollaston process name (wollaston_process) set to default %s.",
112 wollaston_process.c_str());
119 focus_process = (std::string)(ConfigDictionary())[
"focus_process"];
120 _logger->log(Logger::LOG_LEV_INFO,
"Focus control name (focus_process) set to %s.", focus_process.c_str());
122 catch(Config_File_Exception)
124 focus_process =
"focusmotor";
125 _logger->log(Logger::LOG_LEV_INFO,
"Focus control process name (focus_process) set to default %s.",
126 focus_process.c_str());
132 gimbal_process = (std::string)(ConfigDictionary())[
"gimbal_process"];
133 _logger->log(Logger::LOG_LEV_INFO,
"Gimbal control name (gimbal_process) set to %s.", gimbal_process.c_str());
135 catch(Config_File_Exception)
137 gimbal_process =
"gimbal";
138 _logger->log(Logger::LOG_LEV_INFO,
"Gimbal control process name (gimbal_process) set to default %s.",
139 gimbal_process.c_str());
144 orient_useel = (
int)(ConfigDictionary())[
"orient_useel"];
145 orient_usepa = (
int)(ConfigDictionary())[
"orient_usepa"];
147 catch(Config_File_Exception)
151 _logger->log(Logger::LOG_LEV_INFO,
"Orientation params set to defaults.");
157 void VisAOIClient::SetupVars()
159 MagAOIClient::SetupVars();
164 wollaston_status = RTDBvar( wollaston_process,
"L.STATUS", NO_DIR, INT_VARIABLE, 1,1);
165 wollaston_cmode_cur = RTDBvar( wollaston_process,
"L.ConMode", CUR_VAR, INT_VARIABLE, 1,1);
166 wollaston_cmode_req = RTDBvar( wollaston_process,
"L.ConMode", REQ_VAR, INT_VARIABLE, 1,1);
167 Notify(wollaston_cmode_req, WollCModeReqChanged);
169 wollaston_state_cur = RTDBvar( wollaston_process,
"L.state", CUR_VAR, INT_VARIABLE, 1,1);
170 wollaston_state_req = RTDBvar( wollaston_process,
"L.state", REQ_VAR, INT_VARIABLE, 1,1);
171 Notify(wollaston_state_req, WollStateReqChanged);
175 _logger->log(Logger::LOG_LEV_FATAL,
"Error creating wollaston status variables.");
182 focus_cmode_cur = RTDBvar( focus_process,
"L.ConMode", CUR_VAR, INT_VARIABLE, 1,1);
183 focus_cmode_req = RTDBvar( focus_process,
"L.ConMode", REQ_VAR, INT_VARIABLE, 1,1);
184 Notify(focus_cmode_req, FocusCModeReqChanged);
186 focus_pos_cur = RTDBvar( focus_process,
"L.pos", CUR_VAR, REAL_VARIABLE, 1,1);
187 focus_pos_req = RTDBvar( focus_process,
"L.pos", REQ_VAR, REAL_VARIABLE, 1,1);
188 Notify(focus_pos_req, FocusPosReqChanged);
190 focus_abort_req = RTDBvar( focus_process,
"L.abort", REQ_VAR, INT_VARIABLE, 1,1);
191 Notify(focus_abort_req, FocusAbortReqChanged);
193 focus_preset_req = RTDBvar( focus_process,
"L.preset", REQ_VAR, INT_VARIABLE, 1,1);
194 Notify(focus_preset_req, FocusPresetReqChanged);
196 focus_status = RTDBvar( focus_process,
"L.STATUS", NO_DIR, INT_VARIABLE, 1,1);
197 focus_limsw_cur = RTDBvar( focus_process,
"L.limsw", CUR_VAR, INT_VARIABLE, 1,1);
201 _logger->log(Logger::LOG_LEV_FATAL,
"Error creating focus status variables.");
208 gimbal_xpos_cur = RTDBvar( gimbal_process,
"L.xpos", CUR_VAR, REAL_VARIABLE, 1,1);
209 gimbal_ypos_cur = RTDBvar( gimbal_process,
"L.ypos", CUR_VAR, REAL_VARIABLE, 1,1);
210 gimbal_cmode_cur = RTDBvar( gimbal_process,
"L.ConMode", CUR_VAR, INT_VARIABLE, 1,1);
211 gimbal_cmode_req = RTDBvar( gimbal_process,
"L.ConMode", REQ_VAR, INT_VARIABLE, 1,1);
212 Notify(gimbal_cmode_req, GimbalCModeReqChanged);
214 gimbal_center_req = RTDBvar( gimbal_process,
"L.center", REQ_VAR, INT_VARIABLE, 1,1);
215 gimbal_dark_req = RTDBvar( gimbal_process,
"L.dark", REQ_VAR, INT_VARIABLE, 1,1);
216 Notify(gimbal_center_req, GimbalCenterReqChanged);
217 Notify(gimbal_dark_req, GimbalDarkReqChanged);
219 gimbal_status = RTDBvar( gimbal_process,
"L.STATUS", NO_DIR, INT_VARIABLE, 1,1);
223 _logger->log(Logger::LOG_LEV_FATAL,
"Error creating gimbal status variables.");
230 var_masterremote_req = RTDBvar( MyFullName(),
"Master.Remote", REQ_VAR, INT_VARIABLE, 1,1);
234 ccd47_cmode_req = RTDBvar(
"ccd47.L",
"ConMode", REQ_VAR, INT_VARIABLE, 1,1);
235 shutter_cmode_req = RTDBvar(
"shutterremote.L",
"ConMode", REQ_VAR, INT_VARIABLE, 1, 1);
236 fw2_cmode_req = RTDBvar(
"filterwheel2.L",
"ConMode", REQ_VAR, INT_VARIABLE, 1,1);
237 fw3_cmode_req = RTDBvar(
"filterwheel3.L",
"ConMode", REQ_VAR, INT_VARIABLE, 1,1);
239 var_avgwfe = RTDBvar(
"visao",
"avgwfe", NO_DIR, REAL_VARIABLE, 1,1);
240 var_stdwfe = RTDBvar(
"visao",
"stdwfe", NO_DIR, REAL_VARIABLE, 1,1);
241 var_instwfe = RTDBvar(
"visao",
"instwfe", NO_DIR, REAL_VARIABLE, 1,1);
245 _logger->log(Logger::LOG_LEV_FATAL,
"Error creating Master Remote variables.");
250 int VisAOIClient::WollStateReqChanged(
void *pt, Variable *msgb __attribute__((unused)))
254 pthread_mutex_lock(&threadMutex);
256 newstate = msgb->Value.Lv[0];
258 if(newstate == 1) stat = ((VisAOIClient *)pt)->send_wollaston_command(
"up");
259 if(newstate == -1) stat = ((VisAOIClient *)pt)->send_wollaston_command(
"down");
260 if(newstate == -2) stat = ((VisAOIClient *)pt)->send_wollaston_command(
"ignore");
262 pthread_mutex_unlock(&threadMutex);
266 int VisAOIClient::WollCModeReqChanged(
void *pt, Variable *msgb)
270 pthread_mutex_lock(&threadMutex);
272 newcmode = msgb->Value.Lv[0];
274 if(newcmode == 1) stat = ((VisAOIClient *)pt)->send_wollaston_command(
"REMOTE");
275 if(newcmode == 10) stat = ((VisAOIClient *)pt)->send_wollaston_command(
"XREMOTE");
276 if(newcmode == 0) stat = ((VisAOIClient *)pt)->send_wollaston_command(
"~REMOTE");
278 pthread_mutex_unlock(&threadMutex);
282 int VisAOIClient::send_wollaston_command(std::string com)
287 if(resp[0] != 0)
return -1;
292 int VisAOIClient::update_wollaston()
297 pthread_mutex_lock(&threadMutex);
299 pthread_mutex_unlock(&threadMutex);
301 int status, cmode, pos, prompt;
302 if(resp ==
"" || resp.length() <= 2)
304 status = STATE_NOCONNECTION;
310 if(resp.length() > 2)
312 status = STATE_READY;
334 pos = atoi(resp.substr(2,2).c_str());
336 prompt = atoi(resp.substr(4,resp.length()-4).c_str());
339 wollaston_status.Set(status, 0, CHECK_SEND);
340 wollaston_cmode_cur.Set(cmode, 0, CHECK_SEND);
342 if(prompt) pos += 10;
344 wollaston_state_cur.Set(pos, 0, CHECK_SEND);
349 int VisAOIClient::FocusPosReqChanged(
void *pt, Variable *msgb)
357 newpos = msgb->Value.Dv[0];
359 snprintf(posstr, 20,
"pos %0.4f\n", newpos);
361 pthread_mutex_lock(&threadMutex);
363 stat = ((VisAOIClient *)pt)->send_focus_command(posstr);
365 pthread_mutex_unlock(&threadMutex);
369 int VisAOIClient::FocusAbortReqChanged(
void *pt, Variable *msgb __attribute__((unused)))
373 pthread_mutex_lock(&threadMutex);
375 stat = ((VisAOIClient *)pt)->send_focus_command(
"abort");
377 pthread_mutex_unlock(&threadMutex);
382 int VisAOIClient::FocusCModeReqChanged(
void *pt, Variable *msgb)
386 pthread_mutex_lock(&threadMutex);
388 newcmode = msgb->Value.Lv[0];
390 if(newcmode == 1) stat = ((VisAOIClient *)pt)->send_focus_command(
"REMOTE");
391 if(newcmode == 10) stat = ((VisAOIClient *)pt)->send_focus_command(
"XREMOTE");
392 if(newcmode == 0) stat = ((VisAOIClient *)pt)->send_focus_command(
"~REMOTE");
394 pthread_mutex_unlock(&threadMutex);
398 int VisAOIClient::FocusPresetReqChanged(
void *pt, Variable *msgb __attribute__((unused)))
401 pthread_mutex_lock(&threadMutex);
403 stat = ((VisAOIClient *)pt)->send_focus_command(
"preset");
405 pthread_mutex_unlock(&threadMutex);
409 int VisAOIClient::send_focus_command(std::string com)
414 if(resp[0] != 0)
return -1;
419 int VisAOIClient::update_focus()
424 pthread_mutex_lock(&threadMutex);
426 pthread_mutex_unlock(&threadMutex);
428 int connected, cmode, enabled, is_moving, homing, neg_limit, pos_limit, power, pos_limit_disabled;
429 double pos, remaining;
431 if(resp.length() < 16)
464 pos = strtod(resp.substr(2,12).c_str(),0);
466 enabled = atoi(resp.substr(15,1).c_str());
468 power = atoi(resp.substr(17,1).c_str());
470 is_moving = atoi(resp.substr(19,1).c_str());
472 homing = atoi(resp.substr(21,1).c_str());
474 neg_limit = atoi(resp.substr(23,1).c_str());
475 pos_limit = atoi(resp.substr(27,1).c_str());
477 remaining = strtod(resp.substr(29,12).c_str(),0);
479 pos_limit_disabled = atoi(resp.substr(42,1).c_str());
483 focus_cmode_cur.Set(cmode, 0, CHECK_SEND);
489 focus_status.Set(STATE_OFF, 0, CHECK_SEND);
491 else focus_status.Set(STATE_NOCONNECTION, 0, CHECK_SEND);
493 focus_pos_cur.Set(pos, 0, CHECK_SEND);
494 focus_limsw_cur.Set(0, 0, CHECK_SEND);
498 if(is_moving && !homing) focus_status.Set(STATE_OPERATING, 0, CHECK_SEND);
499 else if(homing) focus_status.Set(STATE_HOMING, 0, CHECK_SEND);
500 else focus_status.Set(STATE_READY, 0, CHECK_SEND);
502 if(neg_limit && pos_limit) focus_limsw_cur.Set(-10, 0, CHECK_SEND);
503 else if(pos_limit_disabled) focus_limsw_cur.Set(-5, 0, CHECK_SEND);
506 if(neg_limit && !pos_limit) focus_limsw_cur.Set(-1, 0, CHECK_SEND);
507 else if(!neg_limit && pos_limit) focus_limsw_cur.Set(1, 0, CHECK_SEND);
508 else focus_limsw_cur.Set(0, 0, CHECK_SEND);
511 focus_pos_cur.Set(pos, 0, CHECK_SEND);
517 int VisAOIClient::GimbalCModeReqChanged(
void *pt, Variable *msgb)
521 pthread_mutex_lock(&threadMutex);
523 newcmode = msgb->Value.Lv[0];
525 if(newcmode == 1) stat = ((VisAOIClient *)pt)->send_gimbal_command(
"REMOTE");
526 if(newcmode == 10) stat = ((VisAOIClient *)pt)->send_gimbal_command(
"XREMOTE");
527 if(newcmode == 0) stat = ((VisAOIClient *)pt)->send_gimbal_command(
"~REMOTE");
529 pthread_mutex_unlock(&threadMutex);
533 int VisAOIClient::GimbalCenterReqChanged(
void *pt, Variable *msgb __attribute__((unused)))
536 pthread_mutex_lock(&threadMutex);
538 stat = ((VisAOIClient *)pt)->send_gimbal_command(
"center");
540 pthread_mutex_unlock(&threadMutex);
544 int VisAOIClient::GimbalDarkReqChanged(
void *pt, Variable *msgb __attribute__((unused)))
547 pthread_mutex_lock(&threadMutex);
549 stat = ((VisAOIClient *)pt)->send_gimbal_command(
"dark");
551 pthread_mutex_unlock(&threadMutex);
555 int VisAOIClient::send_gimbal_command(std::string com)
560 if(resp[0] != 0)
return -1;
565 int VisAOIClient::update_gimbal()
567 std::string resp, tmp;
570 pthread_mutex_lock(&threadMutex);
572 pthread_mutex_unlock(&threadMutex);
576 int connected, cmode, is_moving, curState, pwrState, xMoving, yMoving;
581 if(resp !=
"" && resp.length() < 5)
588 if(resp ==
"" || resp.length()<5)
622 spos = resp.find(
',', 0);
623 epos = resp.find(
',', spos+1);
625 tmp = resp.substr(spos+1, epos-spos-1);
629 curState = atoi(tmp.c_str());
631 spos = resp.find(
',', epos);
632 epos = resp.find(
',', spos+1);
634 pwrState = atoi(tmp.c_str());
636 spos = resp.find(
',', epos);
637 epos = resp.find(
',', spos+1);
639 tmp = resp.substr(spos+1, epos-spos-1);
643 xMoving = atoi(tmp.c_str());
645 spos = resp.find(
',', epos);
646 epos = resp.find(
',', spos+1);
648 tmp = resp.substr(spos+1, epos-spos-1);
651 xPos = strtod(tmp.c_str(),0);
654 spos = resp.find(
',', epos);
655 epos = resp.find(
',', spos+1);
657 tmp = resp.substr(spos+1, epos-spos-1);
659 yMoving = atoi(tmp.c_str());
661 is_moving = yMoving + xMoving;
664 spos = resp.find(
',', epos);
665 epos = resp.find(
',', spos+1);
666 if(epos == -1) epos = resp.length();
668 tmp = resp.substr(spos+1, epos-spos-1);
670 yPos = strtod(tmp.c_str(),0);
673 spos = resp.find(
',', epos);
674 epos = resp.find(
',', spos+1);
675 if(epos == -1) epos = resp.length();
677 tmp = resp.substr(spos+1, epos-spos-1);
684 gimbal_cmode_cur.Set(cmode, 0, CHECK_SEND);
690 gimbal_status.Set(STATE_NOCONNECTION, 0, CHECK_SEND);
695 if(is_moving) gimbal_status.Set(STATE_OPERATING, 0, CHECK_SEND);
696 else gimbal_status.Set(STATE_READY, 0, CHECK_SEND);
698 gimbal_xpos_cur.Set(xPos, 0, CHECK_SEND);
699 gimbal_ypos_cur.Set(yPos, 0, CHECK_SEND);
711 pthread_mutex_lock(&threadMutex);
713 newcmode = msgb->Value.Lv[0];
718 pthread_mutex_unlock(&threadMutex);
726 send_gimbal_command(
"REMOTE");
727 send_focus_command(
"REMOTE");
731 send_gimbal_command(
"XREMOTE");
732 send_focus_command(
"XREMOTE");
736 send_gimbal_command(
"~REMOTE");
737 send_focus_command(
"~REMOTE");
740 ccd47_cmode_req.Set(cmode, 0, FORCE_SEND);
741 shutter_cmode_req.Set(cmode, 0, FORCE_SEND);
742 fw2_cmode_req.Set(cmode, 0, FORCE_SEND);
743 fw3_cmode_req.Set(cmode, 0, FORCE_SEND);
748 void VisAOIClient::Run()
750 _logger->log( Logger::LOG_LEV_INFO,
"Running...");
756 signal(SIGIO, SIG_IGN);
775 catch (AOException &e)
777 _logger->log( Logger::LOG_LEV_ERROR,
"Caught exception (at %s:%d): %s", __FILE__, __LINE__, e.what().c_str());
785 void VisAOIClient::post_update_DD_var(DD_RTDBVar &var)
832 if(var.RTVar.complete_name() ==
"optloopdiag.L.COUNTS")
834 aosb->wfs_counts = aoi.side.wfs1.counts;
839 if(var.RTVar.complete_name() ==
"wfsarb.L.FSM_STATE")
844 if(var.RTVar.complete_name() ==
"MagAOI.cmds.NodRaDec.InProgress@M_ADSEC")
846 aosb->nodInProgress = aoi.nodInProgress;
847 std::cout <<
"nodInProgress: " << aosb->nodInProgress <<
"\n";
852 void VisAOIClient::update_loopon()
854 int old_loop_on = aosb->loop_on;
856 if(aoi.side.wfs1.status ==
"LoopClosed") aosb->loop_on = 1;
857 else if(aoi.side.wfs1.status ==
"LoopPaused") aosb->loop_on = 2;
858 else aosb->loop_on = 0;
860 if (aosb->loop_on == 1)
863 if(aosb->loop_gain_tt == 0.0000) aosb->loop_on = 2;
866 if(old_loop_on == 1 && aosb->loop_on != 1) aosb->loop_open_counter++;
869 gettimeofday(&tv, 0);
874 void VisAOIClient::init_statusboard()
880 aosb->dateobs[0] =
'\0';
885 aosb->az = aoi.az.position;
886 aosb->el = aoi.el.position;
892 aosb->filter1_pos = 0.;
893 aosb->filter1_reqpos = 0.;
895 aosb->correctedmodes = aoi.side.ao.correctedmodes;
896 strncpy(aosb->filter1_name, aoi.side.wfs1.filter1.c_str(), 256);
900 aosb->tt_amp[i] = aoi.side.ao.tt_amp[i];
901 aosb->tt_freq[i] = aoi.side.ao.tt_freq[i];
902 aosb->tt_offset[i] = aoi.side.ao.tt_offset[i];
909 aosb->ccd39_freq = aoi.side.wfs1.ccdfreq;
910 aosb->ccd39_bin = aoi.side.wfs1.ccdbin;
911 std::cout <<
"-------> " << aoi.side.ao.loop_gains << std::endl;
912 int p = aoi.side.ao.loop_gains.find(
"g_tt_", 0);
913 if(p < 0 || p > (
int)aoi.side.ao.loop_gains.length() - 4)
915 aosb->loop_gain_tt = 0.;
919 aosb->loop_gain_tt = strtod(aoi.side.ao.loop_gains.substr(p+5, 4).c_str(), 0);
920 p = aoi.side.ao.loop_gains.find(
"_ho1_", p);
921 if(p < 0 || p > (
int) aoi.side.ao.loop_gains.length() - 4)
923 aosb->loop_gain_ho1 = 0.;
927 aosb->loop_gain_ho1 = strtod(aoi.side.ao.loop_gains.substr(p+5, 4).c_str(), 0);
929 p = aoi.side.ao.loop_gains.find(
"_ho2_", p);
930 if(p < 0 || p > (
int) aoi.side.ao.loop_gains.length() - 5)
932 aosb->loop_gain_ho2 = 0.;
936 aosb->loop_gain_ho2 = strtod(aoi.side.ao.loop_gains.substr(p+5, 4).c_str(), 0);
942 aosb->wfs_counts = aoi.side.wfs1.counts;
944 aosb->loop_open_counter = 0;
950 std::string parse_for_fits(std::string & path)
952 int fitstart = path.rfind(
".fits");
954 int slash = path.rfind(
"/", fitstart);
955 std::cout << path <<
"\n";
956 std::cout << fitstart <<
" " << slash <<
"\n";
958 if(slash > -1)
return path.substr(slash+1);
968 strncpy(aosb->dateobs, aoi.dateobs.c_str(), 256);
970 aosb->epoch = aoi.epoch;
973 aosb->az = aoi.az.position;
974 aosb->el = aoi.el.position;
981 aosb->istracking = aoi.istracking;
982 aosb->isguiding = aoi.isguiding;
983 aosb->isslewing = aoi.isslewing;
984 aosb->guider_ismoving = aoi.guider_ismoving;
986 aosb->catra = aoi.cat.ra;
987 aosb->catdec = aoi.cat.dec;
988 aosb->catep = aoi.cat.epoch;
989 aosb->catro = aoi.cat.rotOff;
991 strncpy(aosb->catrm, aoi.cat.rotMode.c_str(), 256);
992 strncpy(aosb->catobj, aoi.cat.obj.c_str(), 256);
994 strncpy(aosb->obsinst, aoi.cat.obsinst.c_str(), 256);
995 strncpy(aosb->obsname, aoi.cat.obsname.c_str(), 256);
997 aosb->rotang = aoi.rotator.angle;
998 aosb->rotoffset = aoi.rotator.offset;
999 aosb->rotfollowing = aoi.rotator.following;
1001 aosb->wxtemp = aoi.environ.wxtemp;
1002 aosb->wxpres = aoi.environ.wxpres;
1003 aosb->wxhumid = aoi.environ.wxhumid;
1004 aosb->wxwind = aoi.environ.wxwind;
1005 aosb->wxwdir = aoi.environ.wxwdir;
1006 aosb->wxdewpoint = aoi.environ.wxdewpoint;
1007 aosb->wxpwvest = aoi.environ.wxpwvest;
1008 aosb->ttruss = aoi.environ.ttruss;
1009 aosb->tcell = aoi.environ.tcell;
1010 aosb->tseccell = aoi.environ.tseccell;
1011 aosb->tambient = aoi.environ.tambient;
1012 aosb->dimmfwhm = aoi.environ.dimmfwhm;
1013 aosb->dimmtime = aoi.environ.dimmtime;
1014 aosb->mag1fwhm = aoi.environ.mag1fwhm;
1015 aosb->mag1time = aoi.environ.mag1time;
1017 aosb->baysidex = aoi.side.wfs1.baysidex;
1018 aosb->baysidex_enabled = aoi.side.wfs1.baysidex_enabled;
1019 aosb->baysidey = aoi.side.wfs1.baysidey;
1020 aosb->baysidey_enabled = aoi.side.wfs1.baysidey_enabled;
1021 aosb->baysidez = aoi.side.wfs1.baysidez;
1022 aosb->baysidez_enabled = aoi.side.wfs1.baysidez_enabled;
1024 aosb->filter1_pos = aoi.side.wfs1.filter1_pos;
1026 if(aoi.side.wfs1.filter1_reqpos == aoi.side.wfs1.filter1_homingpos)
1028 aosb->filter1_reqpos = aoi.side.wfs1.filter1_startpos;
1030 else if(aoi.side.wfs1.filter1_reqpos == aoi.side.wfs1.filter1_abortpos)
1032 aosb->filter1_reqpos = aoi.side.wfs1.filter1_pos;
1036 aosb->filter1_reqpos = aoi.side.wfs1.filter1_reqpos;
1040 strncpy(aosb->filter1_name, aoi.side.wfs1.filter1.c_str(), 256);
1043 aosb->correctedmodes = aoi.side.ao.correctedmodes;
1044 strncpy(aosb->filter1_name, aoi.side.wfs1.filter1.c_str(), 256);
1046 aosb->n_modes = aoi.side.ao.nmodes;
1047 aosb->homiddle = aoi.side.ao.homiddle;
1048 aosb->loop_gain_tt = aoi.side.ao.gain_tt;
1049 aosb->loop_gain_ho1 = aoi.side.ao.gain_ho1;
1050 aosb->loop_gain_ho2 = aoi.side.ao.gain_ho2;
1052 for(
int i=0;i<3;i++)
1054 aosb->tt_amp[i] = aoi.side.ao.tt_amp[i];
1055 aosb->tt_freq[i] = aoi.side.ao.tt_freq[i];
1056 aosb->tt_offset[i] = aoi.side.ao.tt_offset[i];
1060 aosb->ccd39_freq = aoi.side.wfs1.ccdfreq;
1061 aosb->ccd39_bin = aoi.side.wfs1.ccdbin;
1063 strncpy(aosb->reconstructor,parse_for_fits(aoi.side.ao.reconstructor).c_str(), 256);
1065 aosb->orient_useel = orient_useel;
1066 aosb->orient_usepa = orient_usepa;
1077 void VisAOIClient::dump_statusboard()
1081 std::cout <<
"VisAOIClient ao status board\n";
1082 std::cout <<
"Tgt:\t" << aosb->catobj <<
"\n";
1083 std::cout <<
"Tracking:\t" << aosb->istracking <<
"\n";
1084 std::cout <<
"Guiding:\t" << aosb->isguiding <<
"\n\n";
1085 std::cout <<
"DATEOBS:\t" << aosb->dateobs <<
"\n";
1086 std::cout <<
"UT:\t" << aosb->ut <<
"\n";
1087 std::cout <<
"EPOCH:\t" << aosb->epoch <<
"\n";
1088 std::cout <<
"RA:\t" << aosb->ra <<
"\n";
1089 std::cout <<
"DEC:\t" << aosb->dec <<
"\n";
1090 std::cout <<
"AZ:\t" << aosb->az <<
"\n";
1091 std::cout <<
"EL:\t" << aosb->el <<
"\n";
1092 std::cout <<
"AM:\t" << aosb->am <<
"\n";
1093 std::cout <<
"PA:\t" << aosb->pa <<
"\n";
1094 std::cout <<
"HA:\t" << aosb->ha <<
"\n";
1095 std::cout <<
"ZD:\t" << aosb->zd <<
"\n";
1096 std::cout <<
"ST:\t" << aosb->st <<
"\n";
1098 std::cout <<
"Rot-ang:\t" << aosb->rotang <<
"\n";
1099 std::cout <<
"Rot-offset:\t" << aosb->rotoffset <<
"\n";
1100 std::cout <<
"Rot-following:\t" << aosb->rotfollowing <<
"\n";
1102 std::cout <<
"obsinst:\t" << aosb->obsinst <<
"\n";
1103 std::cout <<
"obsname:\t" << aosb->obsname <<
"\n";
1105 std::cout <<
"wxtemp:\t" << aosb->wxtemp <<
"\n";
1106 std::cout <<
"wxpres:\t" << aosb->wxpres <<
"\n";
1107 std::cout <<
"wxhumid:\t" << aosb->wxhumid <<
"\n";
1108 std::cout <<
"wxwind:\t" << aosb->wxwind <<
"\n";
1109 std::cout <<
"wxwdir:\t" << aosb->wxwdir <<
"\n";
1110 std::cout <<
"ttruss:\t" << aosb->ttruss <<
"\n";
1111 std::cout <<
"tcell:\t" << aosb->tcell <<
"\n";
1112 std::cout <<
"tseccell:\t" << aosb->tseccell <<
"\n";
1113 std::cout <<
"tambient:\t" << aosb->tambient <<
"\n";
1114 std::cout <<
"dimmfwhm:\t" << aosb->dimmfwhm <<
"\n";
1116 std::cout <<
"baysidex:\t" << aosb->baysidex <<
"\n";
1117 std::cout <<
"baysidex_enabled:\t" << aosb->baysidex_enabled <<
"\n";
1118 std::cout <<
"baysidey:\t" << aosb->baysidey <<
"\n";
1119 std::cout <<
"baysidey_enabled:\t" << aosb->baysidey_enabled <<
"\n";
1120 std::cout <<
"baysidez:\t" << aosb->baysidez <<
"\n";
1121 std::cout <<
"baysidez_enabled:\t" << aosb->baysidez_enabled <<
"\n";
1123 std::cout <<
"FW 1:\t" << aosb->filter1_pos <<
" " << aosb->filter1_name <<
"\n";
1124 std::cout <<
"FW 1 REQ:\t" << aosb->filter1_reqpos <<
"\n";
1126 std::cout <<
"Reconstructor:\t" << aosb->reconstructor <<
"\n";
1127 std::cout <<
"Modes:\t" << aosb->correctedmodes <<
"\n";
1128 std::cout <<
"TT offset\t freq \t amp\n";
1129 for(
int i=0;i<3;i++) std::cout <<
"\t" << aosb->tt_offset[i] <<
"\t" << aosb->tt_freq[i] <<
"\t" << aosb->tt_amp[i] <<
"\n";
1130 std::cout <<
"Loop: " << aosb->loop_on <<
"\n";
1131 std::cout <<
"Modes: " << aosb->correctedmodes <<
"\n";
1132 std::cout <<
"Speed: " << aosb->ccd39_freq <<
"\n";
1133 std::cout <<
"Bin: " << aosb->ccd39_bin <<
"\n";
1134 std::cout <<
"Gainset nmodes: " << aosb->n_modes <<
"\n";
1135 std::cout <<
"Gainset homiddle: " << aosb->homiddle <<
"\n";
1136 std::cout <<
"Gains: " << aosb->loop_gain_tt <<
" " << aosb->loop_gain_ho1 <<
" " << aosb->loop_gain_ho2 <<
"\n";
1137 std::cout <<
"Counts: " << aosb->wfs_counts <<
"\n";
1139 std::cout << std::endl;
1142 void VisAOIClient::update_recon()
1157 var_instwfe.Set(rsb->
inst_wfe,0, FORCE_SEND);
1161 var_avgwfe.Set(-1.,0, FORCE_SEND);
1162 var_stdwfe.Set(-1.,0, FORCE_SEND);
1163 var_instwfe.Set(-1.,0, FORCE_SEND);
1174 checkDataFileOpen();
1176 dataof << tv.tv_sec <<
" " << tv.tv_usec <<
" " << aosb->loop_on;
1179 else dataof <<
" " << -1.0 <<
" " << -1.0;
1184 Logger::get()->log(Logger::LOG_LEV_ERROR,
"Error in AOsystem data file. AO system data may not be logged correctly");
int update_statusboard()
Update the status board.
fifo_list * global_fifo_list
The global fifo_list, for signal handling.
double get_curr_time(void)
Gets the current CLOCK_REALTIME time, returns it in seconds to double precision.
double inst_wfe
Instantaneous WFE.
double wait_to
The timeout for waiting on responses from FIFOs in seconds.
#define STATUS_reconstructor
Shared memory key for the reconstructor status board.
void * statusboard_shmemptr
The pointer to the shared memory block for the statusboard.
virtual int update_statusboard()
Update the status board.
int setup_fifo_list(int nfifos)
Allocate the fifo_list.
double stdwfe_1_sec
1 second std dev of WFE
key_t statusboard_shmemkey
The key used to lookup the shared memory.
virtual void dataLogger(timeval tv)
Log data at intervals.
int TimeToDie
Global set by SIGTERM.
void * attach_shm(size_t *sz, key_t mkey, int shmemid)
Attach to a shared memory buffer and get its size.
fifo_list fl
The list of named-pipe fifos used for inter-process comms.
The base class for VisAO applications.
double pause_time
Time to pause during application main loop.
static int MasterRemoteReqChanged(void *pt, Variable *msgb)
When notified, VisAOIClient changes the control mode of the entire VisAO Camera.
int create_statusboard(size_t sz)
Creates and attaches to the statusboard shared memory.
std::string fifo_path
The path to the fifos, relative to VISAO_ROOT.
pthread_mutex_t threadMutex
Mutex to lock out other threads during complex operations.
int connect_fifo_list()
Connect the fifo_list with exclusive locking.
double ts_to_curr_time(struct timespec *tsp)
Convert a timespec structure to double seconds.
int LoadConfig()
Load the configuration details from the file.
The namespace of VisAO software.
int setMasterRemote(int cmode)
Change control of Gimbal, Focus, F/W2, F/W3, CCD47.
double avgwfe_1_sec
1 second average WFE
#define RWBUFF_SZ
The size of the i/o buffer.
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.
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.