| 1 | #include "MGCosy.h"
|
|---|
| 2 |
|
|---|
| 3 | #include <iomanip.h>
|
|---|
| 4 | #include <iostream.h>
|
|---|
| 5 |
|
|---|
| 6 | #include "msgqueue.h"
|
|---|
| 7 | #include "coord.h"
|
|---|
| 8 | #include "slalib.h"
|
|---|
| 9 |
|
|---|
| 10 | #include <TROOT.h>
|
|---|
| 11 |
|
|---|
| 12 | #include <TGTab.h> // TGTab
|
|---|
| 13 | #include <TGMenu.h> // TGPopupMenu
|
|---|
| 14 | #include <TGFrame.h> // TGGroupFrame
|
|---|
| 15 | #include <TSystem.h> // gSystem
|
|---|
| 16 | #include <TGLabel.h> // TGLabel
|
|---|
| 17 | #include <TG3DLine.h> // TGHorizontal3DLine (TGSplitter)
|
|---|
| 18 | #include <TGButton.h> // TGButton
|
|---|
| 19 | #include <TGTextView.h> // TGTextView
|
|---|
| 20 | #include <TGComboBox.h> // TGComboBox
|
|---|
| 21 | #include <TGTextEntry.h> // TGTextEntry
|
|---|
| 22 | #include <TApplication.h> // gApplication
|
|---|
| 23 |
|
|---|
| 24 | //#include "timer.h" // Timer
|
|---|
| 25 |
|
|---|
| 26 | #include "MCosy.h"
|
|---|
| 27 | #include "MGList.h"
|
|---|
| 28 | #include "MGAccuracy.h"
|
|---|
| 29 | #include "MGCoordinates.h"
|
|---|
| 30 | #include "MGSkyPosition.h"
|
|---|
| 31 | #include "MGVelocity.h"
|
|---|
| 32 |
|
|---|
| 33 | #include "SlaStars.h"
|
|---|
| 34 |
|
|---|
| 35 | #undef DEBUG
|
|---|
| 36 | #define EXPERT
|
|---|
| 37 |
|
|---|
| 38 | ClassImp(MGCosy);
|
|---|
| 39 |
|
|---|
| 40 | #define IDM_EXIT 1
|
|---|
| 41 | #define IDM_TEXT 2
|
|---|
| 42 | #define IDM_ASPECT 3
|
|---|
| 43 |
|
|---|
| 44 | enum
|
|---|
| 45 | {
|
|---|
| 46 | kPB_POSITION,
|
|---|
| 47 | kPB_TRACK,
|
|---|
| 48 | kPB_STOP,
|
|---|
| 49 | kPB_TRACKPOS,
|
|---|
| 50 | kPB_CALCALTAZ,
|
|---|
| 51 | kPB_TPOINT,
|
|---|
| 52 | kPB_START,
|
|---|
| 53 | kPB_DISPLAY1,
|
|---|
| 54 | kPB_DISPLAY2,
|
|---|
| 55 | kPB_RAp,
|
|---|
| 56 | kPB_RAm,
|
|---|
| 57 | kPB_DECp,
|
|---|
| 58 | kPB_DECm,
|
|---|
| 59 | kPB_ZDp,
|
|---|
| 60 | kPB_ZDm,
|
|---|
| 61 | kPB_AZp,
|
|---|
| 62 | kPB_AZm,
|
|---|
| 63 | kPB_LoadBending,
|
|---|
| 64 | kPB_ResetBending,
|
|---|
| 65 | kPB_CALIBSE,
|
|---|
| 66 | kCB_PredefPos,
|
|---|
| 67 | kCB_StarList,
|
|---|
| 68 | kPB_SavePreDef,
|
|---|
| 69 | kPB_SaveStar,
|
|---|
| 70 |
|
|---|
| 71 | // kLog
|
|---|
| 72 | kLogCopy, kLogClear, kLogSelect, kLogSearch, kLogSave, kLogAppend
|
|---|
| 73 | };
|
|---|
| 74 |
|
|---|
| 75 | void MGCosy::CreateMenu()
|
|---|
| 76 | {
|
|---|
| 77 | TGLayoutHints *laymenubar = new TGLayoutHints (kLHintsNormal | kLHintsExpandX);
|
|---|
| 78 | TGLayoutHints *laymenuitem = new TGLayoutHints (kLHintsNormal, 0, 4, 0, 0);
|
|---|
| 79 | fList->Add(laymenubar);
|
|---|
| 80 | fList->Add(laymenuitem);
|
|---|
| 81 |
|
|---|
| 82 | //
|
|---|
| 83 | // crate the menu bar
|
|---|
| 84 | //
|
|---|
| 85 | TGPopupMenu *filemenu = new TGPopupMenu(gClient->GetRoot());
|
|---|
| 86 | filemenu->AddEntry("Set Aspect", IDM_ASPECT);
|
|---|
| 87 | filemenu->AddEntry("Exit", IDM_EXIT);
|
|---|
| 88 | filemenu->Associate(this);
|
|---|
| 89 | fList->Add(filemenu);
|
|---|
| 90 |
|
|---|
| 91 | //
|
|---|
| 92 | // Log Menu
|
|---|
| 93 | //
|
|---|
| 94 | TGPopupMenu *logmenu = new TGPopupMenu(gClient->GetRoot());
|
|---|
| 95 | logmenu->AddEntry("&Copy Selected", kLogCopy);
|
|---|
| 96 | logmenu->AddEntry("&Select All", kLogSelect);
|
|---|
| 97 | logmenu->AddSeparator();
|
|---|
| 98 | logmenu->AddEntry("Clear &all", kLogClear);
|
|---|
| 99 | /*
|
|---|
| 100 | logmenu->AddSeparator();
|
|---|
| 101 | logmenu->AddEntry("Search", kLogSearch);
|
|---|
| 102 | */
|
|---|
| 103 | logmenu->AddSeparator();
|
|---|
| 104 | logmenu->AddEntry("Sa&ve", kLogSave);
|
|---|
| 105 | logmenu->AddEntry("Save a&ppend", kLogAppend);
|
|---|
| 106 | logmenu->Associate(this);
|
|---|
| 107 |
|
|---|
| 108 | //
|
|---|
| 109 | // the button messages are handled by main frame (this)
|
|---|
| 110 | //
|
|---|
| 111 | TGMenuBar *menubar = new TGMenuBar(this, 1, 1, kHorizontalFrame);
|
|---|
| 112 | menubar->AddPopup("File", filemenu, laymenuitem);
|
|---|
| 113 | menubar->AddPopup("Lo&g", logmenu, laymenuitem);
|
|---|
| 114 | AddFrame(menubar, laymenubar);
|
|---|
| 115 | fList->Add(menubar);
|
|---|
| 116 |
|
|---|
| 117 | //
|
|---|
| 118 | // Seperator beyond menubar
|
|---|
| 119 | //
|
|---|
| 120 | TGHorizontal3DLine *linesep = new TGHorizontal3DLine(this);
|
|---|
| 121 | AddFrame(linesep, laymenubar);
|
|---|
| 122 | fList->Add(linesep);
|
|---|
| 123 | }
|
|---|
| 124 |
|
|---|
| 125 | void MGCosy::CreateLabel(TGCompositeFrame *f)
|
|---|
| 126 | {
|
|---|
| 127 | const int x = 180;
|
|---|
| 128 | const int y = 25;
|
|---|
| 129 |
|
|---|
| 130 | TGLabel *l;
|
|---|
| 131 |
|
|---|
| 132 | l = new TGLabel(f, "UTC:");
|
|---|
| 133 | l->Move(x-60, y);
|
|---|
| 134 | fList->Add(l);
|
|---|
| 135 |
|
|---|
| 136 | l = new TGLabel(f, "Mjd:");
|
|---|
| 137 | l->Move(x-60, y+17);
|
|---|
| 138 | fList->Add(l);
|
|---|
| 139 |
|
|---|
| 140 | fUtc = new TGLabel(f, "0000/00/00 00:00:00.0");
|
|---|
| 141 | fMjd = new TGLabel(f, "00000.000000");
|
|---|
| 142 | fUtc->Move(x-25, y);
|
|---|
| 143 | fMjd->Move(x-25, y+17);
|
|---|
| 144 | fList->Add(fUtc);
|
|---|
| 145 | fList->Add(fMjd);
|
|---|
| 146 |
|
|---|
| 147 | l = new TGLabel(f, "SE-Az:");
|
|---|
| 148 | l->Move(x-60, y+40);
|
|---|
| 149 | fList->Add(l);
|
|---|
| 150 |
|
|---|
| 151 | l = new TGLabel(f, "SE-Zd1:");
|
|---|
| 152 | l->Move(x-60, y+57);
|
|---|
| 153 | fList->Add(l);
|
|---|
| 154 |
|
|---|
| 155 | l = new TGLabel(f, "SE-Zd2:");
|
|---|
| 156 | l->Move(x-60, y+74);
|
|---|
| 157 | fList->Add(l);
|
|---|
| 158 |
|
|---|
| 159 | fLabel1 = new TGLabel(f, "00000"); // Max: 16384
|
|---|
| 160 | fLabel2 = new TGLabel(f, "00000");
|
|---|
| 161 | fLabel3 = new TGLabel(f, "00000");
|
|---|
| 162 | fLabel1->SetTextJustify(kTextRight);
|
|---|
| 163 | fLabel2->SetTextJustify(kTextRight);
|
|---|
| 164 | fLabel3->SetTextJustify(kTextRight);
|
|---|
| 165 | fLabel1->Move(x, y+40);
|
|---|
| 166 | fLabel2->Move(x, y+57);
|
|---|
| 167 | fLabel3->Move(x, y+74);
|
|---|
| 168 | fList->Add(fLabel1);
|
|---|
| 169 | fList->Add(fLabel2);
|
|---|
| 170 | fList->Add(fLabel3);
|
|---|
| 171 | /*
|
|---|
| 172 | l = new TGLabel(f, "Offset-Zd:");
|
|---|
| 173 | l->Move(x-60, y+102);
|
|---|
| 174 | fList->Add(l);
|
|---|
| 175 |
|
|---|
| 176 | l = new TGLabel(f, "Offset-Az:");
|
|---|
| 177 | l->Move(x-60, y+119);
|
|---|
| 178 | fList->Add(l);
|
|---|
| 179 |
|
|---|
| 180 | fOffsetZd = new TGLabel(f, "000000000");
|
|---|
| 181 | fOffsetAz = new TGLabel(f, "000000000");
|
|---|
| 182 | fOffsetZd->SetTextJustify(kTextRight);
|
|---|
| 183 | fOffsetAz->SetTextJustify(kTextRight);
|
|---|
| 184 | fOffsetZd->Move(x+15, y+102);
|
|---|
| 185 | fOffsetAz->Move(x+15, y+119);
|
|---|
| 186 | fList->Add(fOffsetZd);
|
|---|
| 187 | fList->Add(fOffsetAz);
|
|---|
| 188 | */
|
|---|
| 189 | l = new TGLabel(f, "Ra (estimated):");
|
|---|
| 190 | l->Move(x-60, y+142-20);
|
|---|
| 191 | fList->Add(l);
|
|---|
| 192 |
|
|---|
| 193 | l = new TGLabel(f, "Ra (nominal):");
|
|---|
| 194 | l->Move(x-60, y+159-20);
|
|---|
| 195 | fList->Add(l);
|
|---|
| 196 |
|
|---|
| 197 | l = new TGLabel(f, "Dec (estimated):");
|
|---|
| 198 | l->Move(x-60, y+182-20);
|
|---|
| 199 | fList->Add(l);
|
|---|
| 200 |
|
|---|
| 201 | l = new TGLabel(f, "Dec (nominal):");
|
|---|
| 202 | l->Move(x-60, y+199-20);
|
|---|
| 203 | fList->Add(l);
|
|---|
| 204 |
|
|---|
| 205 | l = new TGLabel(f, "Zd (nominal):");
|
|---|
| 206 | l->Move(x-60, y+222);
|
|---|
| 207 | fList->Add(l);
|
|---|
| 208 |
|
|---|
| 209 | l = new TGLabel(f, "Az (nominal):");
|
|---|
| 210 | l->Move(x-60, y+239);
|
|---|
| 211 | fList->Add(l);
|
|---|
| 212 |
|
|---|
| 213 | fRaEst = new TGLabel(f, "+000h 00.0m");
|
|---|
| 214 | fDecEst = new TGLabel(f, "+000h 00.0m");
|
|---|
| 215 | fRaSoll = new TGLabel(f, "+000h 00.0m");
|
|---|
| 216 | fDecSoll = new TGLabel(f, "+000h 00.0m");
|
|---|
| 217 | fZdSoll = new TGLabel(f, "+000h 00.0m");
|
|---|
| 218 | fAzSoll = new TGLabel(f, "+000h 00.0m");
|
|---|
| 219 | fRaEst->SetTextJustify(kTextRight);
|
|---|
| 220 | fDecEst->SetTextJustify(kTextRight);
|
|---|
| 221 | fRaSoll->SetTextJustify(kTextRight);
|
|---|
| 222 | fDecSoll->SetTextJustify(kTextRight);
|
|---|
| 223 | fZdSoll->SetTextJustify(kTextRight);
|
|---|
| 224 | fAzSoll->SetTextJustify(kTextRight);
|
|---|
| 225 | fRaEst->Move(x+30, y+142-20);
|
|---|
| 226 | fRaSoll->Move(x+30, y+159-20);
|
|---|
| 227 | fDecEst->Move(x+30, y+182-20);
|
|---|
| 228 | fDecSoll->Move(x+30, y+199-20);
|
|---|
| 229 | fZdSoll->Move(x+30, y+222);
|
|---|
| 230 | fAzSoll->Move(x+30, y+239);
|
|---|
| 231 | fList->Add(fRaEst);
|
|---|
| 232 | fList->Add(fDecEst);
|
|---|
| 233 | fList->Add(fRaSoll);
|
|---|
| 234 | fList->Add(fDecSoll);
|
|---|
| 235 | fList->Add(fZdSoll);
|
|---|
| 236 | fList->Add(fAzSoll);
|
|---|
| 237 |
|
|---|
| 238 | fError = new TGLabel(f, "Error");
|
|---|
| 239 | fMoving = new TGLabel(f, "Moving");
|
|---|
| 240 | fTracking = new TGLabel(f, "Tracking");
|
|---|
| 241 | fStopping = new TGLabel(f, "Stopping");
|
|---|
| 242 | fStopped = new TGLabel(f, "Stopped");
|
|---|
| 243 | fAvailMac1 = new TGLabel(f, "- MAC1 -");
|
|---|
| 244 | fAvailMac2 = new TGLabel(f, "- MAC2 -");
|
|---|
| 245 | //fAvailMac3 = new TGLabel(f, "- MAC3 -");
|
|---|
| 246 | fAvailSe1 = new TGLabel(f, "-SE/Zd1-");
|
|---|
| 247 | fAvailSe2 = new TGLabel(f, "-SE/Zd2-");
|
|---|
| 248 | fAvailSe3 = new TGLabel(f, "- SE/Az -");
|
|---|
| 249 |
|
|---|
| 250 | ULong_t color;
|
|---|
| 251 |
|
|---|
| 252 | gClient->GetColorByName("Red", color);
|
|---|
| 253 | fError->SetBackgroundColor(color);
|
|---|
| 254 | fAvailMac1->SetBackgroundColor(color);
|
|---|
| 255 | fAvailMac2->SetBackgroundColor(color);
|
|---|
| 256 | //fAvailMac3->SetBackgroundColor(color);
|
|---|
| 257 | fAvailSe1->SetBackgroundColor(color);
|
|---|
| 258 | fAvailSe2->SetBackgroundColor(color);
|
|---|
| 259 | fAvailSe3->SetBackgroundColor(color);
|
|---|
| 260 | gClient->GetColorByName("LightBlue", color);
|
|---|
| 261 | fMoving->SetBackgroundColor(color);
|
|---|
| 262 | gClient->GetColorByName("Blue", color);
|
|---|
| 263 | fTracking->SetBackgroundColor(color);
|
|---|
| 264 | gClient->GetColorByName("Orange", color);
|
|---|
| 265 | fStopping->SetBackgroundColor(color);
|
|---|
| 266 | gClient->GetColorByName("Green", color);
|
|---|
| 267 | fStopped->SetBackgroundColor(color);
|
|---|
| 268 |
|
|---|
| 269 | fError ->Move(10, 25);
|
|---|
| 270 | fMoving ->Move(10, 25+20);
|
|---|
| 271 | fTracking->Move(10, 25+40);
|
|---|
| 272 | fStopping->Move(10, 25+60);
|
|---|
| 273 | fStopped ->Move(10, 25+80);
|
|---|
| 274 | fAvailMac1->Move(10, 25+120);
|
|---|
| 275 | fAvailMac2->Move(10, 25+140);
|
|---|
| 276 | //fAvailMac3->Move(10, 25+160);
|
|---|
| 277 | fAvailSe1->Move(10, 25+180);
|
|---|
| 278 | fAvailSe2->Move(10, 25+200);
|
|---|
| 279 | fAvailSe3->Move(10, 25+220);
|
|---|
| 280 |
|
|---|
| 281 | fError ->Resize(60, 20);
|
|---|
| 282 | fMoving ->Resize(60, 20);
|
|---|
| 283 | fTracking->Resize(60, 20);
|
|---|
| 284 | fStopping->Resize(60, 20);
|
|---|
| 285 | fStopped ->Resize(60, 20);
|
|---|
| 286 | fAvailMac1->Resize(60, 20);
|
|---|
| 287 | fAvailMac2->Resize(60, 20);
|
|---|
| 288 | //fAvailMac3->Resize(60, 20);
|
|---|
| 289 | fAvailSe1->Resize(60, 20);
|
|---|
| 290 | fAvailSe2->Resize(60, 20);
|
|---|
| 291 | fAvailSe3->Resize(60, 20);
|
|---|
| 292 |
|
|---|
| 293 | fList->Add(fError);
|
|---|
| 294 | fList->Add(fMoving);
|
|---|
| 295 | fList->Add(fTracking);
|
|---|
| 296 | fList->Add(fStopping);
|
|---|
| 297 | fList->Add(fStopped);
|
|---|
| 298 | fList->Add(fAvailMac1);
|
|---|
| 299 | fList->Add(fAvailMac2);
|
|---|
| 300 | //fList->Add(fAvailMac3);
|
|---|
| 301 | fList->Add(fAvailSe1);
|
|---|
| 302 | fList->Add(fAvailSe2);
|
|---|
| 303 | fList->Add(fAvailSe3);
|
|---|
| 304 | }
|
|---|
| 305 |
|
|---|
| 306 | void MGCosy::CreatePredefinedPos(TGCompositeFrame *tf1)
|
|---|
| 307 | {
|
|---|
| 308 | TGComboBox *box = new TGComboBox(tf1, kCB_PredefPos);
|
|---|
| 309 | box->Resize(120, 20);
|
|---|
| 310 | box->Associate(this);
|
|---|
| 311 |
|
|---|
| 312 | TGLayoutHints *lay = new TGLayoutHints(kLHintsLeft|kLHintsTop,
|
|---|
| 313 | 27, 0, 200, 0);
|
|---|
| 314 | tf1->AddFrame(box, lay);
|
|---|
| 315 |
|
|---|
| 316 | fList->Add(box);
|
|---|
| 317 | fList->Add(lay);
|
|---|
| 318 |
|
|---|
| 319 | ifstream fin("prepos.txt");
|
|---|
| 320 | if (!fin)
|
|---|
| 321 | {
|
|---|
| 322 | cout << "ERROR: Predifined positions in 'prepos.txt' not found." << endl;
|
|---|
| 323 | return;
|
|---|
| 324 | }
|
|---|
| 325 |
|
|---|
| 326 | int i=0;
|
|---|
| 327 | while (1)
|
|---|
| 328 | {
|
|---|
| 329 | Double_t zd, az;
|
|---|
| 330 | fin >> zd >> az;
|
|---|
| 331 |
|
|---|
| 332 | TString str;
|
|---|
| 333 | str.ReadLine(fin);
|
|---|
| 334 | if (!fin)
|
|---|
| 335 | break;
|
|---|
| 336 |
|
|---|
| 337 | box->AddEntry(str, i++);
|
|---|
| 338 | fPreDefList.Add(zd, az);
|
|---|
| 339 | }
|
|---|
| 340 | }
|
|---|
| 341 |
|
|---|
| 342 | void MGCosy::CreateStarList(TGCompositeFrame *tf1)
|
|---|
| 343 | {
|
|---|
| 344 | TGComboBox *box = new TGComboBox(tf1, kCB_StarList);
|
|---|
| 345 | box->Resize(170, 20);
|
|---|
| 346 | box->Associate(this);
|
|---|
| 347 |
|
|---|
| 348 | TGLayoutHints *lay = new TGLayoutHints(kLHintsLeft|kLHintsTop,
|
|---|
| 349 | 27, 0, 70, 0);
|
|---|
| 350 | tf1->AddFrame(box, lay);
|
|---|
| 351 |
|
|---|
| 352 | fList->Add(box);
|
|---|
| 353 | fList->Add(lay);
|
|---|
| 354 |
|
|---|
| 355 | ifstream fin("stars.txt");
|
|---|
| 356 | if (!fin)
|
|---|
| 357 | {
|
|---|
| 358 | cout << "ERROR: Star List 'stars.txt' not found." << endl;
|
|---|
| 359 | return;
|
|---|
| 360 | }
|
|---|
| 361 |
|
|---|
| 362 | int i=0;
|
|---|
| 363 | while (1)
|
|---|
| 364 | {
|
|---|
| 365 | Int_t h, m, s, d, am, as;
|
|---|
| 366 | fin >> h >> m >> s >> d >> am >> as;
|
|---|
| 367 |
|
|---|
| 368 | TString str;
|
|---|
| 369 | str.ReadLine(fin);
|
|---|
| 370 | if (!fin)
|
|---|
| 371 | break;
|
|---|
| 372 |
|
|---|
| 373 | box->AddEntry(str, i++);
|
|---|
| 374 |
|
|---|
| 375 | fStarList.Add(Slalib::Hms2Hor(h, m, s), Slalib::Dms2Deg(d, am, as));
|
|---|
| 376 | }
|
|---|
| 377 | }
|
|---|
| 378 |
|
|---|
| 379 | void MGCosy::CreateTabs()
|
|---|
| 380 | {
|
|---|
| 381 | TGCompositeFrame *tf1 = fTab->AddTab("Position");
|
|---|
| 382 | TGCompositeFrame *tf2 = fTab->AddTab("Track");
|
|---|
| 383 | TGCompositeFrame *tf4 = fTab->AddTab("Calib");
|
|---|
| 384 | #ifdef EXPERT
|
|---|
| 385 | TGCompositeFrame *tf5 = fTab->AddTab("Test SE");
|
|---|
| 386 | TGCompositeFrame *tf6 = fTab->AddTab("Gear");
|
|---|
| 387 | #endif
|
|---|
| 388 | /*TGCompositeFrame *tf3 =*/// fTab->AddTab("Demo");
|
|---|
| 389 |
|
|---|
| 390 | fCZdAz = new MGCoordinates(tf1, kETypeZdAz);
|
|---|
| 391 | fCZdAz->Move(27, 105);
|
|---|
| 392 | fList->Add(fCZdAz);
|
|---|
| 393 |
|
|---|
| 394 | CreatePredefinedPos(tf1);
|
|---|
| 395 | CreateStarList(tf4);
|
|---|
| 396 |
|
|---|
| 397 | fCRaDec = new MGCoordinates(tf2, kETypeRaDec);
|
|---|
| 398 | fCRaDec->Move(27, 105);
|
|---|
| 399 | fList->Add(fCRaDec);
|
|---|
| 400 |
|
|---|
| 401 | fCCalib = new MGCoordinates(tf4, kETypeRaDec);
|
|---|
| 402 | fCCalib->Move(27, 105);
|
|---|
| 403 | fList->Add(fCCalib);
|
|---|
| 404 |
|
|---|
| 405 | const int x=15;
|
|---|
| 406 | const int y=12;
|
|---|
| 407 | const int h=16;
|
|---|
| 408 |
|
|---|
| 409 | TGLabel *l1 = new TGLabel(tf1, "Move the telescope to a position given in");
|
|---|
| 410 | TGLabel *l2 = new TGLabel(tf1, "local coordinates. The given coordinates");
|
|---|
| 411 | TGLabel *l3 = new TGLabel(tf1, "are pointing coordinates. Enter the coordinates");
|
|---|
| 412 | TGLabel *l4 = new TGLabel(tf1, "manually or choose a predefined position");
|
|---|
| 413 | TGLabel *l5 = new TGLabel(tf1, "from the combobox below.");
|
|---|
| 414 | l1->Move(x, y);
|
|---|
| 415 | l2->Move(x, y+h);
|
|---|
| 416 | l3->Move(x, y+2*h);
|
|---|
| 417 | l4->Move(x, y+3*h);
|
|---|
| 418 | l5->Move(x, y+4*h);
|
|---|
| 419 | fList->Add(l1);
|
|---|
| 420 | fList->Add(l2);
|
|---|
| 421 | fList->Add(l3);
|
|---|
| 422 | fList->Add(l4);
|
|---|
| 423 | fList->Add(l5);
|
|---|
| 424 |
|
|---|
| 425 | l1 = new TGLabel(tf2, "Track a position given in sky coordinates.");
|
|---|
| 426 | l2 = new TGLabel(tf2, "Right Ascension and declination must be given");
|
|---|
| 427 | l3 = new TGLabel(tf2, "in the FK5, J2000 coordinate system.");
|
|---|
| 428 | l1->Move(x, y);
|
|---|
| 429 | l2->Move(x, y+h);
|
|---|
| 430 | l3->Move(x, y+2*h);
|
|---|
| 431 | fList->Add(l1);
|
|---|
| 432 | fList->Add(l2);
|
|---|
| 433 | fList->Add(l3);
|
|---|
| 434 |
|
|---|
| 435 | l1 = new TGLabel(tf4, "Start the calibration using the Start button.");
|
|---|
| 436 | l2 = new TGLabel(tf4, "Write a coordinate pair to a TPoint file using");
|
|---|
| 437 | l3 = new TGLabel(tf4, "the TPoint button.");
|
|---|
| 438 | //l3 = new TGLabel(tf4, "the TPoint button. To set the Shaftencoder offset");
|
|---|
| 439 | //l4 = new TGLabel(tf4, "use the Calib SE button.");
|
|---|
| 440 | l1->Move(x, y);
|
|---|
| 441 | l2->Move(x, y+h);
|
|---|
| 442 | l3->Move(x, y+2*h);
|
|---|
| 443 | l4->Move(x, y+3*h);
|
|---|
| 444 | fList->Add(l1);
|
|---|
| 445 | fList->Add(l2);
|
|---|
| 446 | fList->Add(l3);
|
|---|
| 447 | fList->Add(l4);
|
|---|
| 448 |
|
|---|
| 449 | #ifdef EXPERT
|
|---|
| 450 | l1 = new TGLabel(tf5, "START starts histograming the differences of");
|
|---|
| 451 | l2 = new TGLabel(tf5, "the two shaftencoders at the elevation axis.");
|
|---|
| 452 | l3 = new TGLabel(tf5, "Use STOP to stop histograming and display the");
|
|---|
| 453 | l4 = new TGLabel(tf5, "results on the screen.");
|
|---|
| 454 | l1->Move(x, y);
|
|---|
| 455 | l2->Move(x, y+h);
|
|---|
| 456 | l3->Move(x, y+2*h);
|
|---|
| 457 | l4->Move(x, y+3*h);
|
|---|
| 458 | fList->Add(l1);
|
|---|
| 459 | fList->Add(l2);
|
|---|
| 460 | fList->Add(l3);
|
|---|
| 461 | fList->Add(l4);
|
|---|
| 462 |
|
|---|
| 463 | l1 = new TGLabel(tf6, "FIXME Text missing / Only one axis?");
|
|---|
| 464 | l1->Move(x, y);
|
|---|
| 465 | fList->Add(l1);
|
|---|
| 466 | #endif
|
|---|
| 467 |
|
|---|
| 468 | //
|
|---|
| 469 | // light green: 3 light red: 2 blue?: 2
|
|---|
| 470 | // dark green: 8 dark red: 50 dark blue?: 1
|
|---|
| 471 |
|
|---|
| 472 | //
|
|---|
| 473 | // blue: 0-7, 9, 10,11, 14, 15, 18, 19, 22, 23, 27, 31, 33-39, 41-43
|
|---|
| 474 | // 46, 47
|
|---|
| 475 | // green: 8, 12,13, 16, 17, 20, 21, 24, 25, 26, 28, 29, 30, 40, 44
|
|---|
| 476 | // 45, 48
|
|---|
| 477 | // gray: 31, 113-
|
|---|
| 478 | // red: 164, 192, 224, 232
|
|---|
| 479 | //
|
|---|
| 480 | TGTextButton *but;
|
|---|
| 481 |
|
|---|
| 482 | but= new TGTextButton(tf2, "Ra -", kPB_RAm);
|
|---|
| 483 | but->Resize(50, 25);
|
|---|
| 484 | but->Move(25, 210);
|
|---|
| 485 | but->SetToolTipText("Right ascension -= 1'");
|
|---|
| 486 | but->Associate(this);
|
|---|
| 487 | fList->Add(but);
|
|---|
| 488 | but= new TGTextButton(tf2, "RA +", kPB_RAp);
|
|---|
| 489 | but->Resize(50, 25);
|
|---|
| 490 | but->Move(90, 210);
|
|---|
| 491 | but->SetToolTipText("Right ascension += 1'");
|
|---|
| 492 | but->Associate(this);
|
|---|
| 493 | fList->Add(but);
|
|---|
| 494 | but= new TGTextButton(tf2, "DEC +", kPB_DECp);
|
|---|
| 495 | but->Resize(50, 25);
|
|---|
| 496 | but->Move(55, 185);
|
|---|
| 497 | but->SetToolTipText("Declination += 1'");
|
|---|
| 498 | but->Associate(this);
|
|---|
| 499 | fList->Add(but);
|
|---|
| 500 | but= new TGTextButton(tf2, "DEC -", kPB_DECm);
|
|---|
| 501 | but->Resize(50, 25);
|
|---|
| 502 | but->Move(55, 235);
|
|---|
| 503 | but->SetToolTipText("Declination -= 1'");
|
|---|
| 504 | but->Associate(this);
|
|---|
| 505 | fList->Add(but);
|
|---|
| 506 |
|
|---|
| 507 | but = new TGTextButton(tf1, "Move'n'Track", kPB_TRACKPOS);
|
|---|
| 508 | but->Resize(100, 25);
|
|---|
| 509 | but->Move(25, 242);
|
|---|
| 510 | but->SetToolTipText("Move telescope to a Zd/Az position and start tracking.");
|
|---|
| 511 | but->Associate(this);
|
|---|
| 512 | fList->Add(but);
|
|---|
| 513 |
|
|---|
| 514 | but= new TGTextButton(tf2, "Calc Zd/Az", kPB_CALCALTAZ);
|
|---|
| 515 | but->Resize(80, 25);
|
|---|
| 516 | but->Move(165, 197);
|
|---|
| 517 | but->SetToolTipText("Calculate Zd/Az corresponding to Ra/Dec.");
|
|---|
| 518 | but->Associate(this);
|
|---|
| 519 | fList->Add(but);
|
|---|
| 520 |
|
|---|
| 521 | but = new TGTextButton(tf4, "TPoint", kPB_TPOINT);
|
|---|
| 522 | but->Resize(50, 25);
|
|---|
| 523 | but->Move(176/*231*/, 213);
|
|---|
| 524 | but->SetToolTipText("Trigger writing a tpoint coordinate pair.");
|
|---|
| 525 | but->Associate(this);
|
|---|
| 526 | fList->Add(but);
|
|---|
| 527 |
|
|---|
| 528 | #ifdef EXPERT
|
|---|
| 529 | but= new TGTextButton(tf1, "New Position", kPB_SavePreDef);
|
|---|
| 530 | but->Resize(80, 25);
|
|---|
| 531 | but->Move(165, 197);
|
|---|
| 532 | but->SetToolTipText("Save new predefined position.");
|
|---|
| 533 | but->Associate(this);
|
|---|
| 534 | fList->Add(but);
|
|---|
| 535 |
|
|---|
| 536 | but= new TGTextButton(tf4, "New", kPB_SaveStar);
|
|---|
| 537 | but->Resize(60, 23);
|
|---|
| 538 | but->Move(211, 69);
|
|---|
| 539 | but->SetToolTipText("Save new Source position.");
|
|---|
| 540 | but->Associate(this);
|
|---|
| 541 | fList->Add(but);
|
|---|
| 542 |
|
|---|
| 543 | but = new TGTextButton(tf5, "Display", kPB_DISPLAY1);
|
|---|
| 544 | but->Resize(80, 25);
|
|---|
| 545 | but->Move(160, 197);
|
|---|
| 546 | but->SetToolTipText("Display Histogram.");
|
|---|
| 547 | but->Associate(this);
|
|---|
| 548 | fList->Add(but);
|
|---|
| 549 |
|
|---|
| 550 | but = new TGTextButton(tf6, "Display", kPB_DISPLAY2);
|
|---|
| 551 | but->Resize(80, 25);
|
|---|
| 552 | but->Move(160, 197);
|
|---|
| 553 | but->SetToolTipText("Display Histogram.");
|
|---|
| 554 | but->Associate(this);
|
|---|
| 555 | fList->Add(but);
|
|---|
| 556 |
|
|---|
| 557 | but = new TGTextButton(tf4, "Load", kPB_LoadBending);
|
|---|
| 558 | but->Resize(50, 25);
|
|---|
| 559 | but->Move(151, 185);
|
|---|
| 560 | but->SetToolTipText("Load bending corrections from file 'bending.txt'");
|
|---|
| 561 | but->Associate(this);
|
|---|
| 562 | fList->Add(but);
|
|---|
| 563 |
|
|---|
| 564 | but = new TGTextButton(tf4, "Reset", kPB_ResetBending);
|
|---|
| 565 | but->Resize(50, 25);
|
|---|
| 566 | but->Move(206, 185);
|
|---|
| 567 | but->SetToolTipText("Reset bending correction (coefficients=0)");
|
|---|
| 568 | but->Associate(this);
|
|---|
| 569 | fList->Add(but);
|
|---|
| 570 |
|
|---|
| 571 | but= new TGTextButton(tf4, "Zd -", kPB_ZDm);
|
|---|
| 572 | but->Resize(50, 25);
|
|---|
| 573 | but->Move(25, 210);
|
|---|
| 574 | but->SetToolTipText("Zenith Distance -= 1SE");
|
|---|
| 575 | but->Associate(this);
|
|---|
| 576 | fList->Add(but);
|
|---|
| 577 | but= new TGTextButton(tf4, "Zd +", kPB_ZDp);
|
|---|
| 578 | but->Resize(50, 25);
|
|---|
| 579 | but->Move(90, 210);
|
|---|
| 580 | but->SetToolTipText("Zenith Distance += 1SE");
|
|---|
| 581 | but->Associate(this);
|
|---|
| 582 | fList->Add(but);
|
|---|
| 583 | but= new TGTextButton(tf4, "Az +", kPB_AZp);
|
|---|
| 584 | but->Resize(50, 25);
|
|---|
| 585 | but->Move(55, 185);
|
|---|
| 586 | but->SetToolTipText("Azimuth += 1SE");
|
|---|
| 587 | but->Associate(this);
|
|---|
| 588 | fList->Add(but);
|
|---|
| 589 | but= new TGTextButton(tf4, "Az -", kPB_AZm);
|
|---|
| 590 | but->Resize(50, 25);
|
|---|
| 591 | but->Move(55, 235);
|
|---|
| 592 | but->SetToolTipText("Azimuth -= 1SE");
|
|---|
| 593 | but->Associate(this);
|
|---|
| 594 | fList->Add(but);
|
|---|
| 595 | #endif
|
|---|
| 596 |
|
|---|
| 597 | ULong_t color;
|
|---|
| 598 |
|
|---|
| 599 | but = new TGTextButton(this, "Start", kPB_START);
|
|---|
| 600 | gClient->GetColorByName("Green", color);
|
|---|
| 601 | but->SetBackgroundColor(color);
|
|---|
| 602 | but->Move(147, 295);
|
|---|
| 603 | but->Resize(62, 25);
|
|---|
| 604 | but->SetToolTipText("Start a telescope movement.");
|
|---|
| 605 | fList->Add(but);
|
|---|
| 606 |
|
|---|
| 607 | but = new TGTextButton(this, "Stop", kPB_STOP);
|
|---|
| 608 |
|
|---|
| 609 | gClient->GetColorByName("Red", color);
|
|---|
| 610 | but->SetBackgroundColor(color);
|
|---|
| 611 | but->Move(212, 295);
|
|---|
| 612 | but->Resize(62, 25);
|
|---|
| 613 | but->SetToolTipText("Stop any movement of telescope.");
|
|---|
| 614 | fList->Add(but);
|
|---|
| 615 |
|
|---|
| 616 | /*
|
|---|
| 617 | const Double_t ca = 0; // Left-Right Collimation Error
|
|---|
| 618 | const Double_t an = 0; // Azimuth Axis Misalignment (N-S)
|
|---|
| 619 | const Double_t aw = 0; // Azimuth Axis Misalignment (E-W)
|
|---|
| 620 | const Double_t npae = 0; // Az-El Nonperpendicularity
|
|---|
| 621 | const Double_t nrx = 0; // Nasmyth rotator displacement, horizontan
|
|---|
| 622 | const Double_t nry = 0; // Nasmyth rotator displacement, vertical
|
|---|
| 623 | const Double_t crx = 0; // Alt/Az Coude Displacement (N-S)
|
|---|
| 624 | const Double_t cry = 0; // Alt/Az Coude Displacement (E-W)
|
|---|
| 625 | l1 = new TGLabel(tf5, "CA");
|
|---|
| 626 | l1->SetTextJustify(kTextLeft);
|
|---|
| 627 | l1->Move(x, y+2*h*1.5);
|
|---|
| 628 | l1->MapWindow();
|
|---|
| 629 | fList->Add(l1);
|
|---|
| 630 | l1 = new TGLabel(tf5, "AN");
|
|---|
| 631 | l1->SetTextJustify(kTextLeft);
|
|---|
| 632 | l1->Move(x, y+3*h*1.5);
|
|---|
| 633 | l1->MapWindow();
|
|---|
| 634 | fList->Add(l1);
|
|---|
| 635 | l1 = new TGLabel(tf5, "AW");
|
|---|
| 636 | l1->SetTextJustify(kTextLeft);
|
|---|
| 637 | l1->Move(x, y+4*h*1.5);
|
|---|
| 638 | l1->MapWindow();
|
|---|
| 639 | fList->Add(l1);
|
|---|
| 640 | l1 = new TGLabel(tf5, "NPAE");
|
|---|
| 641 | l1->SetTextJustify(kTextLeft);
|
|---|
| 642 | l1->Move(x, y+5*h*1.5);
|
|---|
| 643 | l1->MapWindow();
|
|---|
| 644 | fList->Add(l1);
|
|---|
| 645 | l1 = new TGLabel(tf5, "NRX");
|
|---|
| 646 | l1->SetTextJustify(kTextLeft);
|
|---|
| 647 | l1->Move(x, y+6*h*1.5);
|
|---|
| 648 | l1->MapWindow();
|
|---|
| 649 | fList->Add(l1);
|
|---|
| 650 | l1 = new TGLabel(tf5, "NRY");
|
|---|
| 651 | l1->SetTextJustify(kTextLeft);
|
|---|
| 652 | l1->Move(x, y+7*h*1.5);
|
|---|
| 653 | l1->MapWindow();
|
|---|
| 654 | fList->Add(l1);
|
|---|
| 655 | l1 = new TGLabel(tf5, "CRX");
|
|---|
| 656 | l1->SetTextJustify(kTextLeft);
|
|---|
| 657 | l1->Move(x, y+8*h*1.5);
|
|---|
| 658 | l1->MapWindow();
|
|---|
| 659 | fList->Add(l1);
|
|---|
| 660 | l1 = new TGLabel(tf5, "CRY");
|
|---|
| 661 | l1->SetTextJustify(kTextLeft);
|
|---|
| 662 | l1->Move(x, y+9*h*1.5);
|
|---|
| 663 | l1->MapWindow();
|
|---|
| 664 | fList->Add(l1);
|
|---|
| 665 | const Double_t ie = 0; // Index Error in Elevation
|
|---|
| 666 | const Double_t ia = 0; // Index Error in Azimuth
|
|---|
| 667 | const Double_t eces = 0; // Elevation Centering Error (sin)
|
|---|
| 668 | const Double_t ecec = 0; // Elevation Centering Error (cos)
|
|---|
| 669 | const Double_t aces = 0; // Azimuth Centering Error (sin)
|
|---|
| 670 | const Double_t acec = 0; // Azimuth Centering Error (cos)
|
|---|
| 671 | l1 = new TGLabel(tf5, "IE");
|
|---|
| 672 | l1->SetTextJustify(kTextLeft);
|
|---|
| 673 | l1->Move(x+150, y+3*h*1.5);
|
|---|
| 674 | l1->MapWindow();
|
|---|
| 675 | fList->Add(l1);
|
|---|
| 676 | l1 = new TGLabel(tf5, "IA");
|
|---|
| 677 | l1->SetTextJustify(kTextLeft);
|
|---|
| 678 | l1->Move(x+150, y+4*h*1.5);
|
|---|
| 679 | l1->MapWindow();
|
|---|
| 680 | fList->Add(l1);
|
|---|
| 681 | l1 = new TGLabel(tf5, "ECES");
|
|---|
| 682 | l1->SetTextJustify(kTextLeft);
|
|---|
| 683 | l1->Move(x+150, y+5*h*1.5);
|
|---|
| 684 | l1->MapWindow();
|
|---|
| 685 | fList->Add(l1);
|
|---|
| 686 | l1 = new TGLabel(tf5, "ECEC");
|
|---|
| 687 | l1->SetTextJustify(kTextLeft);
|
|---|
| 688 | l1->Move(x+150, y+6*h*1.5);
|
|---|
| 689 | l1->MapWindow();
|
|---|
| 690 | fList->Add(l1);
|
|---|
| 691 | l1 = new TGLabel(tf5, "ACES");
|
|---|
| 692 | l1->SetTextJustify(kTextLeft);
|
|---|
| 693 | l1->Move(x+150, y+4*h*1.5);
|
|---|
| 694 | l1->MapWindow();
|
|---|
| 695 | fList->Add(l1);
|
|---|
| 696 | l1 = new TGLabel(tf5, "IA");
|
|---|
| 697 | l1->SetTextJustify(kTextLeft);
|
|---|
| 698 | l1->Move(x+150, y+4*h*1.5);
|
|---|
| 699 | l1->MapWindow();
|
|---|
| 700 | fList->Add(l1);
|
|---|
| 701 |
|
|---|
| 702 |
|
|---|
| 703 | TGTextEntry *entry = new TGTextEntry(tf5, "****", kEF_BendIE);
|
|---|
| 704 | entry->Associate(this);
|
|---|
| 705 | entry->Move(x+50, y+2*h*1.5);
|
|---|
| 706 | entry->MapWindow();
|
|---|
| 707 | fList->Add(entry);
|
|---|
| 708 |
|
|---|
| 709 | entry = new TGTextEntry(tf5, "*****", kEF_BendIA);
|
|---|
| 710 | entry->Associate(this);
|
|---|
| 711 | entry->Move(x+50, y+3*h*1.5);
|
|---|
| 712 | entry->MapWindow();
|
|---|
| 713 | fList->Add(entry);
|
|---|
| 714 | */
|
|---|
| 715 | }
|
|---|
| 716 |
|
|---|
| 717 | MGCosy::MGCosy(MObservatory::LocationName_t key, MsgQueue *q, const TGWindow *p, UInt_t w, UInt_t h)
|
|---|
| 718 | : TGMainFrame(p, w, h), fObservatory(key), fQueue(q)
|
|---|
| 719 | {
|
|---|
| 720 | fList = new MGList;
|
|---|
| 721 |
|
|---|
| 722 | fFont = gVirtualX->LoadQueryFont("7x13bold");
|
|---|
| 723 |
|
|---|
| 724 | #ifdef DEBUG
|
|---|
| 725 | cout << "MGCosy: Creating Menu" << endl;
|
|---|
| 726 | #endif
|
|---|
| 727 | CreateMenu();
|
|---|
| 728 |
|
|---|
| 729 | #ifdef DEBUG
|
|---|
| 730 | cout << "MGCosy: Creating TGCompositeFrame" << endl;
|
|---|
| 731 | #endif
|
|---|
| 732 | TGHorizontalFrame *f1 = new TGHorizontalFrame(this, 0, 0);
|
|---|
| 733 | TGHorizontalFrame *f2 = new TGHorizontalFrame(this, 0, 0);
|
|---|
| 734 | fList->Add(f1);
|
|---|
| 735 | fList->Add(f2);
|
|---|
| 736 |
|
|---|
| 737 | #ifdef DEBUG
|
|---|
| 738 | cout << "MGCosy: Creating TGTab" << endl;
|
|---|
| 739 | #endif
|
|---|
| 740 | fTab = new TGTab(f1, 300, 300);
|
|---|
| 741 | fList->Add(fTab);
|
|---|
| 742 |
|
|---|
| 743 | #ifdef DEBUG
|
|---|
| 744 | cout << "MGCosy: Creating MGSkyPosition" << endl;
|
|---|
| 745 | #endif
|
|---|
| 746 | fSkyPosition = new MGSkyPosition(fObservatory, f1, 300);
|
|---|
| 747 | #ifdef DEBUG
|
|---|
| 748 | cout << "MGCosy: Creating MGAccuracy" << endl;
|
|---|
| 749 | #endif
|
|---|
| 750 | fAccuracy = new MGAccuracy(f1, 300);
|
|---|
| 751 | #ifdef DEBUG
|
|---|
| 752 | cout << "MGCosy: Creating MGVelocity" << endl;
|
|---|
| 753 | #endif
|
|---|
| 754 | fVelocity = new MGVelocity(f2, "Velocity [\"/min]", 300);
|
|---|
| 755 | // fOffset = new MGVelocity (f, "Offset se-re [']", 300);
|
|---|
| 756 |
|
|---|
| 757 | fList->Add(fSkyPosition);
|
|---|
| 758 | fList->Add(fAccuracy);
|
|---|
| 759 | fList->Add(fVelocity);
|
|---|
| 760 | // fList->Add(fOffset);
|
|---|
| 761 |
|
|---|
| 762 | #ifdef DEBUG
|
|---|
| 763 | cout << "MGCosy: Creating TGGroupFrame" << endl;
|
|---|
| 764 | #endif
|
|---|
| 765 | TGGroupFrame *frame = new TGGroupFrame(f2, "Status");
|
|---|
| 766 | fList->Add(frame);
|
|---|
| 767 |
|
|---|
| 768 | #ifdef DEBUG
|
|---|
| 769 | cout << "MGCosy: Creating TGTextView" << endl;
|
|---|
| 770 | #endif
|
|---|
| 771 | fLog = new TGTextView(f2, 300, 300);
|
|---|
| 772 | if (fFont)
|
|---|
| 773 | fLog->SetFont(fFont);
|
|---|
| 774 | fList->Add(fLog);
|
|---|
| 775 |
|
|---|
| 776 | TGLayoutHints *hints1 = new TGLayoutHints(kLHintsNormal | kLHintsExpandX|kLHintsExpandY, 6, 6, 6, 3);
|
|---|
| 777 | TGLayoutHints *hints2 = new TGLayoutHints(kLHintsNormal | kLHintsExpandX|kLHintsExpandY, 6, 6, 3, 6);
|
|---|
| 778 | TGLayoutHints *hints1a = new TGLayoutHints(kLHintsLeft | kLHintsTop |kLHintsExpandX|kLHintsExpandY);
|
|---|
| 779 | TGLayoutHints *hints2a = new TGLayoutHints(kLHintsCenterY | kLHintsTop |kLHintsExpandX|kLHintsExpandY, 6, 6);
|
|---|
| 780 | TGLayoutHints *hints3a = new TGLayoutHints(kLHintsRight | kLHintsTop |kLHintsExpandX|kLHintsExpandY);
|
|---|
| 781 | TGLayoutHints *hints1b = new TGLayoutHints(kLHintsLeft | kLHintsBottom|kLHintsExpandX|kLHintsExpandY);
|
|---|
| 782 | TGLayoutHints *hints2b = new TGLayoutHints(kLHintsCenterY | kLHintsBottom|kLHintsExpandX|kLHintsExpandY, 6, 6);
|
|---|
| 783 | TGLayoutHints *hints3b = new TGLayoutHints(kLHintsRight | kLHintsBottom|kLHintsExpandX|kLHintsExpandY);
|
|---|
| 784 |
|
|---|
| 785 | fList->Add(hints1);
|
|---|
| 786 | fList->Add(hints2);
|
|---|
| 787 | fList->Add(hints1a);
|
|---|
| 788 | fList->Add(hints2a);
|
|---|
| 789 | fList->Add(hints3a);
|
|---|
| 790 | fList->Add(hints1b);
|
|---|
| 791 | fList->Add(hints2b);
|
|---|
| 792 | fList->Add(hints3b);
|
|---|
| 793 |
|
|---|
| 794 | // Layout upper frame
|
|---|
| 795 | f1->AddFrame(fTab, hints1a);
|
|---|
| 796 | f1->AddFrame(fSkyPosition, hints2a);
|
|---|
| 797 | f1->AddFrame(fAccuracy, hints3a);
|
|---|
| 798 |
|
|---|
| 799 | // Layout upper frame
|
|---|
| 800 | f2->AddFrame(frame, hints1b);
|
|---|
| 801 | f2->AddFrame(fVelocity, hints2b);
|
|---|
| 802 | f2->AddFrame(fLog, hints3b);
|
|---|
| 803 |
|
|---|
| 804 | // Layout window
|
|---|
| 805 | AddFrame(f1, hints1);
|
|---|
| 806 | AddFrame(f2, hints2);
|
|---|
| 807 |
|
|---|
| 808 | #ifdef DEBUG
|
|---|
| 809 | cout << "MGCosy: Creating Tabs" << endl;
|
|---|
| 810 | #endif
|
|---|
| 811 | CreateTabs();
|
|---|
| 812 | #ifdef DEBUG
|
|---|
| 813 | cout << "MGCosy: Creating Label" << endl;
|
|---|
| 814 | #endif
|
|---|
| 815 | CreateLabel(frame);
|
|---|
| 816 |
|
|---|
| 817 | //
|
|---|
| 818 | // Map the window, set up the layout, etc.
|
|---|
| 819 | //
|
|---|
| 820 | #ifdef DEBUG
|
|---|
| 821 | cout << "MGCosy: Setting Size" << endl;
|
|---|
| 822 | #endif
|
|---|
| 823 | const Int_t w = 940;
|
|---|
| 824 | const Int_t h = 660;
|
|---|
| 825 | SetWMSizeHints(w, h, 1280, 900, 10, 10); // set the smallest and biggest size of the Main frame
|
|---|
| 826 |
|
|---|
| 827 | SetWindowName("Cosy Main Window");
|
|---|
| 828 | SetIconName("Cosy");
|
|---|
| 829 |
|
|---|
| 830 | #ifdef DEBUG
|
|---|
| 831 | cout << "MGCosy: Map Window" << endl;
|
|---|
| 832 | #endif
|
|---|
| 833 | MapSubwindows();
|
|---|
| 834 | Resize(w, h); //GetDefaultSize());
|
|---|
| 835 | MapWindow();
|
|---|
| 836 | }
|
|---|
| 837 |
|
|---|
| 838 | // ======================================================================
|
|---|
| 839 |
|
|---|
| 840 | MGCosy::~MGCosy()
|
|---|
| 841 | {
|
|---|
| 842 | #ifdef DEBUG
|
|---|
| 843 | cout << "MGCosy::~MGCosy called." << endl;
|
|---|
| 844 | #endif
|
|---|
| 845 | delete fList;
|
|---|
| 846 | #ifdef DEBUG
|
|---|
| 847 | cout << "Deleting MGCosy::fFont" << endl;
|
|---|
| 848 | #endif
|
|---|
| 849 | if (fFont)
|
|---|
| 850 | gVirtualX->DeleteFont(fFont);
|
|---|
| 851 | #ifdef DEBUG
|
|---|
| 852 | cout << "MGCosy::~MGCosy done." << endl;
|
|---|
| 853 | #endif
|
|---|
| 854 | }
|
|---|
| 855 |
|
|---|
| 856 | void MGCosy::SetLabelColor(TGLabel *label, Bool_t col)
|
|---|
| 857 | {
|
|---|
| 858 | ULong_t red, green;
|
|---|
| 859 |
|
|---|
| 860 | gClient->GetColorByName("Red", red);
|
|---|
| 861 | gClient->GetColorByName("Green", green);
|
|---|
| 862 |
|
|---|
| 863 | if (col && label->TestBit(BIT(14)))
|
|---|
| 864 | return;
|
|---|
| 865 |
|
|---|
| 866 | if (!col && !label->TestBit(BIT(14)))
|
|---|
| 867 | return;
|
|---|
| 868 |
|
|---|
| 869 | col ? label->SetBit(BIT(14)) : label->ResetBit(BIT(14));
|
|---|
| 870 |
|
|---|
| 871 | label->UnmapWindow();
|
|---|
| 872 | label->SetBackgroundColor(col ? green : red);
|
|---|
| 873 | label->MapWindow();
|
|---|
| 874 | }
|
|---|
| 875 |
|
|---|
| 876 | // ======================================================================
|
|---|
| 877 | void MGCosy::EnableLabel(TGLabel *label, Bool_t stat)
|
|---|
| 878 | {
|
|---|
| 879 | stat ? label->MapWindow() : label->UnmapWindow();
|
|---|
| 880 |
|
|---|
| 881 | /*
|
|---|
| 882 | TGGC *fRedTextGC(TGButton::GetDefaultGC())
|
|---|
| 883 | // Set foreground color in graphics context for drawing of
|
|---|
| 884 | // TGlabel and TGButtons with text in red.
|
|---|
| 885 | ULong_t red;
|
|---|
| 886 | gClient->GetColorByName("red", red);
|
|---|
| 887 | fRedTextGC.SetForeground(red);
|
|---|
| 888 | */
|
|---|
| 889 | }
|
|---|
| 890 |
|
|---|
| 891 | void MGCosy::UpdateRaDec(ZdAz &pos, double mjd, RaDec &radec)
|
|---|
| 892 | {
|
|---|
| 893 | static Int_t rai=~0;
|
|---|
| 894 | static Int_t deci=~0;
|
|---|
| 895 | static Int_t ras=~0;
|
|---|
| 896 | static Int_t decs=~0;
|
|---|
| 897 |
|
|---|
| 898 | static SlaStars sla(fObservatory);
|
|---|
| 899 | sla.SetMjd(mjd);
|
|---|
| 900 |
|
|---|
| 901 | RaDec rd = sla.CalcRaDec(pos*2*TMath::Pi()/360);
|
|---|
| 902 |
|
|---|
| 903 | char text[64];
|
|---|
| 904 |
|
|---|
| 905 | UShort_t h, d;
|
|---|
| 906 | Double_t hm, dm;
|
|---|
| 907 | Char_t sh, sd;
|
|---|
| 908 |
|
|---|
| 909 | // Calculate Display values
|
|---|
| 910 | Slalib::Rad2Hm(rd.Ra(), sh, h, hm);
|
|---|
| 911 | Slalib::Rad2Dm(rd.Dec(), sd, d, dm);
|
|---|
| 912 |
|
|---|
| 913 | rd.Ra(rd.Ra() * 12/TMath::Pi());
|
|---|
| 914 | rd.Dec(rd.Dec()*180/TMath::Pi());
|
|---|
| 915 |
|
|---|
| 916 | RaDec test = rd*600;
|
|---|
| 917 | if (rai!=(int)test.Ra())
|
|---|
| 918 | {
|
|---|
| 919 | rai = (int)test.Ra();
|
|---|
| 920 | //sprintf(text, "%c%dh %.1fm", rd.Ra()<0?'-':'+', abs((int)rd.Ra()), 0.1*(abs((int)test.Ra())%600));
|
|---|
| 921 | sprintf(text, "%c%dh %.1fm", sh, h, hm);
|
|---|
| 922 | fRaEst->SetText(new TGString(text));
|
|---|
| 923 | }
|
|---|
| 924 | if (deci!=(int)test.Dec())
|
|---|
| 925 | {
|
|---|
| 926 | deci = (int)test.Dec();
|
|---|
| 927 | //sprintf(text, "%c%dd %.1fm", rd.Dec()<0?'-':'+' , abs((int)rd.Dec()), 0.1*(abs((int)test.Dec())%600));
|
|---|
| 928 | sprintf(text, "%c%dh %.1fm", sd, d, dm);
|
|---|
| 929 | fDecEst->SetText(new TGString(text));
|
|---|
| 930 | }
|
|---|
| 931 |
|
|---|
| 932 | // Align RaDec
|
|---|
| 933 | radec.Ra(radec.Ra() * 12/TMath::Pi());
|
|---|
| 934 | radec.Dec(radec.Dec()*180/TMath::Pi());
|
|---|
| 935 | if (radec.Dec()>90|| radec.Dec()<-90)
|
|---|
| 936 | {
|
|---|
| 937 | radec.Ra(radec.Ra()+12);
|
|---|
| 938 | radec.Dec(180-radec.Dec());
|
|---|
| 939 | }
|
|---|
| 940 | radec.Ra(fmod((radec.Ra()+48), 24));
|
|---|
| 941 |
|
|---|
| 942 | // Calculate display values
|
|---|
| 943 | Slalib::Hor2Hm(radec.Ra(), sh, h, hm);
|
|---|
| 944 | Slalib::Deg2Dm(radec.Dec(), sd, d, dm);
|
|---|
| 945 |
|
|---|
| 946 | test = radec*600;
|
|---|
| 947 | if (ras!=(int)test.Ra())
|
|---|
| 948 | {
|
|---|
| 949 | ras = (int)test.Ra();
|
|---|
| 950 | //sprintf(text, "%c%dh %.1fm", radec.Ra()<0?'-':'+', abs((int)radec.Ra()), 0.1*(abs((int)test.Ra())%600));
|
|---|
| 951 | sprintf(text, "%c%dh %.1fm", sh, h, hm);
|
|---|
| 952 | fRaSoll->SetText(new TGString(text));
|
|---|
| 953 | }
|
|---|
| 954 | if (decs!=(int)test.Dec())
|
|---|
| 955 | {
|
|---|
| 956 | decs = (int)test.Dec();
|
|---|
| 957 | //sprintf(text, "%c%dd %.1fm", radec.Dec()<0?'-':'+' , abs((int)radec.Dec()), 0.1*(abs((int)test.Dec())%600));
|
|---|
| 958 | sprintf(text, "%c%dh %.1fm", sd, d, dm);
|
|---|
| 959 | fDecSoll->SetText(new TGString(text));
|
|---|
| 960 | }
|
|---|
| 961 | }
|
|---|
| 962 | /*
|
|---|
| 963 | void MGCosy::UpdateOffset(ZdAz &off)
|
|---|
| 964 | {
|
|---|
| 965 | static Int_t zd=~0;
|
|---|
| 966 | static Int_t az=~0;
|
|---|
| 967 |
|
|---|
| 968 | char text[21];
|
|---|
| 969 |
|
|---|
| 970 | if (zd!=(Int_t)off.Zd())
|
|---|
| 971 | {
|
|---|
| 972 | zd = (Int_t)off.Zd();
|
|---|
| 973 | sprintf(text, "%dre", zd);
|
|---|
| 974 | fOffsetZd->SetText(new TGString(text));
|
|---|
| 975 | }
|
|---|
| 976 | if (az!=(Int_t)off.Az())
|
|---|
| 977 | {
|
|---|
| 978 | az = (Int_t)off.Az();
|
|---|
| 979 | sprintf(text, "%dre", az);
|
|---|
| 980 | fOffsetAz->SetText(new TGString(text));
|
|---|
| 981 | }
|
|---|
| 982 | }
|
|---|
| 983 | */
|
|---|
| 984 | void MGCosy::UpdateZdAz(ZdAz &soll)
|
|---|
| 985 | {
|
|---|
| 986 | soll *= 360/2/TMath::Pi();
|
|---|
| 987 |
|
|---|
| 988 | static Int_t zd=~0;
|
|---|
| 989 | static Int_t az=~0;
|
|---|
| 990 |
|
|---|
| 991 | char text[21];
|
|---|
| 992 |
|
|---|
| 993 | ZdAz test = soll*600;
|
|---|
| 994 |
|
|---|
| 995 | if (zd!=(int)test.Zd())
|
|---|
| 996 | {
|
|---|
| 997 | zd = (int)test.Zd();
|
|---|
| 998 | sprintf(text, "%c%dd %.1fm", soll.Zd()<0?'-':'+', abs((int)soll.Zd()), 0.1*(abs((int)test.Zd())%600));
|
|---|
| 999 | fZdSoll->SetText(new TGString(text));
|
|---|
| 1000 | }
|
|---|
| 1001 | if (az!=(int)test.Az())
|
|---|
| 1002 | {
|
|---|
| 1003 | az = (int)test.Az();
|
|---|
| 1004 | sprintf(text, "%c%dd %.1fm", soll.Az()<0?'-':'+' , abs((int)soll.Az()), 0.1*(abs((int)test.Az())%600));
|
|---|
| 1005 | fAzSoll->SetText(new TGString(text));
|
|---|
| 1006 | }
|
|---|
| 1007 | }
|
|---|
| 1008 |
|
|---|
| 1009 | double MGCosy::UpdateTime()
|
|---|
| 1010 | {
|
|---|
| 1011 | Timer time;
|
|---|
| 1012 | time.Now();
|
|---|
| 1013 |
|
|---|
| 1014 | static char oldtxt[256];
|
|---|
| 1015 |
|
|---|
| 1016 | char text[256];
|
|---|
| 1017 |
|
|---|
| 1018 | strcpy(text, time.GetTimeStr());
|
|---|
| 1019 |
|
|---|
| 1020 | char *dot = strrchr(text, '.');
|
|---|
| 1021 |
|
|---|
| 1022 | if (dot)
|
|---|
| 1023 | dot[2] = 0;
|
|---|
| 1024 |
|
|---|
| 1025 | if (strcmp(oldtxt, text))
|
|---|
| 1026 | {
|
|---|
| 1027 | fUtc->SetText(new TGString(text));
|
|---|
| 1028 | strcpy(oldtxt, text);
|
|---|
| 1029 | }
|
|---|
| 1030 |
|
|---|
| 1031 | static long oldmjd;
|
|---|
| 1032 | double mjd = time.GetMjd();
|
|---|
| 1033 |
|
|---|
| 1034 | if (oldmjd != 1000000*mjd)
|
|---|
| 1035 | {
|
|---|
| 1036 | sprintf(text, "%12.6f", mjd);
|
|---|
| 1037 | fMjd->SetText(new TGString(text));
|
|---|
| 1038 |
|
|---|
| 1039 | oldmjd = (long)(1000000*mjd);
|
|---|
| 1040 | }
|
|---|
| 1041 |
|
|---|
| 1042 | return mjd;
|
|---|
| 1043 | }
|
|---|
| 1044 |
|
|---|
| 1045 | void MGCosy::Update(ZdAz pos, ZdAz acc, ZdAz vel, /*ZdAz off,*/ RaDec radec,
|
|---|
| 1046 | ZdAz soll, UInt_t stat, UInt_t stat2)
|
|---|
| 1047 | {
|
|---|
| 1048 | // acc [rad]
|
|---|
| 1049 | acc *= kRad2Deg; // [deg]
|
|---|
| 1050 |
|
|---|
| 1051 | double mjd = UpdateTime();
|
|---|
| 1052 | fSkyPosition->Update(pos, mjd);
|
|---|
| 1053 | //UpdateOffset(off);
|
|---|
| 1054 | UpdateRaDec(pos, mjd, radec);
|
|---|
| 1055 | UpdateZdAz(soll);
|
|---|
| 1056 |
|
|---|
| 1057 | #define kError 0x01
|
|---|
| 1058 | #define kMoving 0x02
|
|---|
| 1059 | #define kTracking 0x04
|
|---|
| 1060 | #define kStopping 0x08
|
|---|
| 1061 | #define kStopped 0x10
|
|---|
| 1062 |
|
|---|
| 1063 | EnableLabel(fError, stat&kError);
|
|---|
| 1064 | EnableLabel(fMoving, stat&kMoving);
|
|---|
| 1065 | EnableLabel(fTracking, stat&kTracking);
|
|---|
| 1066 | EnableLabel(fStopping, stat&kStopping);
|
|---|
| 1067 | EnableLabel(fStopped, stat&kStopped);
|
|---|
| 1068 | EnableLabel(fRaSoll, stat&kTracking);
|
|---|
| 1069 | EnableLabel(fDecSoll, stat&kTracking);
|
|---|
| 1070 | EnableLabel(fZdSoll, stat&kMoving);
|
|---|
| 1071 | EnableLabel(fAzSoll, stat&kMoving);
|
|---|
| 1072 |
|
|---|
| 1073 | SetLabelColor(fAvailMac1, stat2&0x01);
|
|---|
| 1074 | SetLabelColor(fAvailMac2, stat2&0x02);
|
|---|
| 1075 | //SetLabelColor(fAvailMac3, stat2&0x04);
|
|---|
| 1076 | SetLabelColor(fAvailSe1, stat2&0x08);
|
|---|
| 1077 | SetLabelColor(fAvailSe2, stat2&0x10);
|
|---|
| 1078 | SetLabelColor(fAvailSe3, stat2&0x20);
|
|---|
| 1079 |
|
|---|
| 1080 | if (stat&kTracking)
|
|---|
| 1081 | {
|
|---|
| 1082 | fAccuracy->Update(pos, acc);
|
|---|
| 1083 | fVelocity->Update(vel);
|
|---|
| 1084 | fAccuracy->MapWindow();
|
|---|
| 1085 | fVelocity->MapWindow();
|
|---|
| 1086 | }
|
|---|
| 1087 | else
|
|---|
| 1088 | {
|
|---|
| 1089 | fAccuracy->UnmapWindow();
|
|---|
| 1090 | fVelocity->UnmapWindow();
|
|---|
| 1091 | }
|
|---|
| 1092 | // stat&kTracking ? fOffset->MapWindow() : fOffset->UnmapWindow();
|
|---|
| 1093 |
|
|---|
| 1094 | /*
|
|---|
| 1095 | if (fLog->TestBit(kHasChanged))
|
|---|
| 1096 | {
|
|---|
| 1097 | fLog->MapSubwindows();
|
|---|
| 1098 | fLog->Layout();
|
|---|
| 1099 | fLog->ResetBit(kHasChanged);
|
|---|
| 1100 | }*/
|
|---|
| 1101 | }
|
|---|
| 1102 | // ======================================================================
|
|---|
| 1103 |
|
|---|
| 1104 | void MGCosy::CloseWindow()
|
|---|
| 1105 | {
|
|---|
| 1106 | // Got close message for this MainFrame. Calls parent CloseWindow()
|
|---|
| 1107 | // (which destroys the window) and terminate the application.
|
|---|
| 1108 | // The close message is generated by the window manager when its close
|
|---|
| 1109 | // window menu item is selected.
|
|---|
| 1110 |
|
|---|
| 1111 | // gSystem->ExitLoop();
|
|---|
| 1112 | // gSystem->DispatchOneEvent(kTRUE);
|
|---|
| 1113 |
|
|---|
| 1114 | // TGMainFrame::CloseWindow();
|
|---|
| 1115 | cout << "Closing window - waiting until all nodes are stopped." << endl;
|
|---|
| 1116 | fQueue->PostMsg(WM_QUIT, 0, 0);
|
|---|
| 1117 | cout << "Closing window - done." << endl;
|
|---|
| 1118 | // gApplication->Terminate(0);
|
|---|
| 1119 | }
|
|---|
| 1120 |
|
|---|
| 1121 | void MGCosy::StartTrack(bool track)
|
|---|
| 1122 | {
|
|---|
| 1123 | cout << "Start tracking." << endl;
|
|---|
| 1124 |
|
|---|
| 1125 | XY xy0 = fCRaDec->GetCoordinates();
|
|---|
| 1126 | XY xy1 = track ? xy0 : fCCalib->GetCoordinates();
|
|---|
| 1127 |
|
|---|
| 1128 | RaDec dest0(xy0.X()*15., xy0.Y()); // xy.X() [h]->[ø]
|
|---|
| 1129 | RaDec dest1(xy1.X()*15., xy1.Y()); // xy.X() [h]->[ø]
|
|---|
| 1130 |
|
|---|
| 1131 | cout << "TrackPos: " << dest0.Ra() << "h " << dest0.Dec() << "\xb0" << endl;
|
|---|
| 1132 | cout << "CalibPos: " << dest1.Ra() << "h " << dest1.Dec() << "\xb0" << endl;
|
|---|
| 1133 |
|
|---|
| 1134 | RaDec dest[2] = { dest0, dest1 };
|
|---|
| 1135 |
|
|---|
| 1136 | fQueue->PostMsg(WM_TRACK, &dest, sizeof(dest));
|
|---|
| 1137 |
|
|---|
| 1138 | cout << "PostMsg (WM_Track) returned." << endl;
|
|---|
| 1139 | }
|
|---|
| 1140 |
|
|---|
| 1141 | void MGCosy::StartTrackPos(Long_t mp1)
|
|---|
| 1142 | {
|
|---|
| 1143 | cout << "Start tracking Zd/Az pos." << endl;
|
|---|
| 1144 |
|
|---|
| 1145 | const XY &xy = fCZdAz->GetCoordinates();
|
|---|
| 1146 |
|
|---|
| 1147 | ZdAz za(xy.X(), xy.Y());
|
|---|
| 1148 |
|
|---|
| 1149 | switch (mp1)
|
|---|
| 1150 | {
|
|---|
| 1151 | case kPB_ZDm:
|
|---|
| 1152 | za.Zd(za.Zd()-360/16384.);
|
|---|
| 1153 | break;
|
|---|
| 1154 | case kPB_ZDp:
|
|---|
| 1155 | za.Zd(za.Zd()+360/16384.);
|
|---|
| 1156 | break;
|
|---|
| 1157 | case kPB_AZm:
|
|---|
| 1158 | za.Az(za.Az()-360/16384.);
|
|---|
| 1159 | break;
|
|---|
| 1160 | case kPB_AZp:
|
|---|
| 1161 | za.Az(za.Az()+360/16384.);
|
|---|
| 1162 | break;
|
|---|
| 1163 | }
|
|---|
| 1164 |
|
|---|
| 1165 | cout << za.Zd() << "\xb0 " << za.Az() << "\xb0" << endl;
|
|---|
| 1166 |
|
|---|
| 1167 | fQueue->PostMsg(WM_TRACKPOS, &za, sizeof(za));
|
|---|
| 1168 |
|
|---|
| 1169 | cout << "PostMsg (WM_TrackPos) returned." << endl;
|
|---|
| 1170 | }
|
|---|
| 1171 |
|
|---|
| 1172 | void MGCosy::StartPos()
|
|---|
| 1173 | {
|
|---|
| 1174 | cout << "Start positioning." << endl;
|
|---|
| 1175 |
|
|---|
| 1176 | XY xy = fCZdAz->GetCoordinates();
|
|---|
| 1177 | ZdAz dest(xy.X(), xy.Y());
|
|---|
| 1178 |
|
|---|
| 1179 | cout << dest.Zd() << kDEG << " " << dest.Az() << kDEG << endl;
|
|---|
| 1180 |
|
|---|
| 1181 | fQueue->PostMsg(WM_POSITION, &dest, sizeof(dest));
|
|---|
| 1182 |
|
|---|
| 1183 | cout << "PostMsg (WM_Position) returned." << endl;
|
|---|
| 1184 | }
|
|---|
| 1185 |
|
|---|
| 1186 | //
|
|---|
| 1187 | // ************************** For demo purpose **********************
|
|---|
| 1188 | //
|
|---|
| 1189 | /*
|
|---|
| 1190 | #include <TRandom.h>
|
|---|
| 1191 | class MDemo : public MThread
|
|---|
| 1192 | {
|
|---|
| 1193 | private:
|
|---|
| 1194 | MsgQueue *fQueue;
|
|---|
| 1195 | TRandom fRand;
|
|---|
| 1196 |
|
|---|
| 1197 | public:
|
|---|
| 1198 | MDemo() : MThread(false) {}
|
|---|
| 1199 |
|
|---|
| 1200 | void SetQueue(MsgQueue *q) { fQueue = q; }
|
|---|
| 1201 |
|
|---|
| 1202 | virtual void *Thread()
|
|---|
| 1203 | {
|
|---|
| 1204 | while (1)
|
|---|
| 1205 | {
|
|---|
| 1206 | Timer tm;
|
|---|
| 1207 | tm.Now();
|
|---|
| 1208 |
|
|---|
| 1209 | //fQueue->PostMsg(WM_STOP, 0, 0);
|
|---|
| 1210 |
|
|---|
| 1211 | ZdAz dest1((float)fRand.Integer(120)-60., 0);//fRand.Integer(25)+90);
|
|---|
| 1212 |
|
|---|
| 1213 | cout << "Demo: Zd=" << dest1.Zd() << "° Az=" << dest1.Az() << "°" << endl;
|
|---|
| 1214 |
|
|---|
| 1215 | fQueue->PostMsg(WM_POSITION, &dest1, sizeof(dest1));
|
|---|
| 1216 |
|
|---|
| 1217 | int i = 0;
|
|---|
| 1218 | while (!HasStopFlag() && i++<5) // 30s
|
|---|
| 1219 | usleep(1000000);
|
|---|
| 1220 | if (HasStopFlag())
|
|---|
| 1221 | break;
|
|---|
| 1222 |
|
|---|
| 1223 | //ZdAz dest2(5, 30);
|
|---|
| 1224 | //fQueue->PostMsg(WM_POSITION, &dest2, sizeof(dest2));
|
|---|
| 1225 | //if (HasStopFlag())
|
|---|
| 1226 | // break;
|
|---|
| 1227 | }
|
|---|
| 1228 | cout << "Demo Thread: done." << endl;
|
|---|
| 1229 | return NULL;
|
|---|
| 1230 | }
|
|---|
| 1231 | };
|
|---|
| 1232 |
|
|---|
| 1233 | MDemo demo;
|
|---|
| 1234 |
|
|---|
| 1235 | void MGCosy::StartDemo()
|
|---|
| 1236 | {
|
|---|
| 1237 | cout << "Start Demo." << endl;
|
|---|
| 1238 |
|
|---|
| 1239 | demo.SetQueue(fQueue);
|
|---|
| 1240 | demo.Start();
|
|---|
| 1241 |
|
|---|
| 1242 | cout << "PostMsg (WM_Demo) returned." << endl;
|
|---|
| 1243 | }
|
|---|
| 1244 |
|
|---|
| 1245 | void StopDemo()
|
|---|
| 1246 | {
|
|---|
| 1247 | cout << "Stopping demo." << endl;
|
|---|
| 1248 | demo.Stop();
|
|---|
| 1249 | }
|
|---|
| 1250 | */
|
|---|
| 1251 | /*
|
|---|
| 1252 | void MGCosy::StartCalib()
|
|---|
| 1253 | {
|
|---|
| 1254 | cout << "Start Calibration." << endl;
|
|---|
| 1255 |
|
|---|
| 1256 | XY xy = fCCalib->GetCoordinates();
|
|---|
| 1257 | RaDec pos(xy.X()*360/24, xy.Y());
|
|---|
| 1258 |
|
|---|
| 1259 | fQueue->PostMsg(WM_CALIB, &pos, sizeof(pos));
|
|---|
| 1260 |
|
|---|
| 1261 | cout << "PostMsg (WM_Calib) returned." << endl;
|
|---|
| 1262 | }
|
|---|
| 1263 | */
|
|---|
| 1264 | void MGCosy::StartTPoint()
|
|---|
| 1265 | {
|
|---|
| 1266 | cout << "Start writing tpoint pair." << endl;
|
|---|
| 1267 |
|
|---|
| 1268 | XY xy = fCCalib->GetCoordinates();
|
|---|
| 1269 | RaDec pos(xy.X()*360/24, xy.Y());
|
|---|
| 1270 |
|
|---|
| 1271 | //fQueue->PostMsg(WM_TPOINT, &pos, sizeof(pos));
|
|---|
| 1272 | fQueue->Proc(WM_TPOINT, &pos);
|
|---|
| 1273 |
|
|---|
| 1274 | cout << "PostMsg (WM_TPoint) returned." << endl;
|
|---|
| 1275 | }
|
|---|
| 1276 | //
|
|---|
| 1277 | // ******************************************************************
|
|---|
| 1278 | //
|
|---|
| 1279 |
|
|---|
| 1280 | Bool_t MGCosy::ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2)
|
|---|
| 1281 | {
|
|---|
| 1282 | //
|
|---|
| 1283 | // This processing is serialized!
|
|---|
| 1284 | //
|
|---|
| 1285 | switch (GET_MSG(msg))
|
|---|
| 1286 | {
|
|---|
| 1287 | case kC_COMMAND:
|
|---|
| 1288 | switch (GET_SUBMSG(msg))
|
|---|
| 1289 | {
|
|---|
| 1290 | case kCM_COMBOBOX:
|
|---|
| 1291 | switch (mp1)
|
|---|
| 1292 | {
|
|---|
| 1293 | case kCB_PredefPos:
|
|---|
| 1294 | {
|
|---|
| 1295 | MStar *pos = fPreDefList[mp2];
|
|---|
| 1296 | if (pos)
|
|---|
| 1297 | fCZdAz->SetCoordinates(ZdAz(pos->GetX(), pos->GetY()));
|
|---|
| 1298 | return kTRUE;
|
|---|
| 1299 | }
|
|---|
| 1300 | case kCB_StarList:
|
|---|
| 1301 | {
|
|---|
| 1302 | MStar *pos = fStarList[mp2];
|
|---|
| 1303 | if (pos)
|
|---|
| 1304 | fCCalib->SetCoordinates(RaDec(pos->GetX(), pos->GetY()));
|
|---|
| 1305 | return kTRUE;
|
|---|
| 1306 | }
|
|---|
| 1307 | }
|
|---|
| 1308 | return kTRUE;
|
|---|
| 1309 |
|
|---|
| 1310 | case kCM_TAB:
|
|---|
| 1311 | //cout << "Tab: " << mp1 << endl;
|
|---|
| 1312 | return kTRUE;
|
|---|
| 1313 |
|
|---|
| 1314 | case kCM_BUTTON:
|
|---|
| 1315 |
|
|---|
| 1316 | switch (mp1)
|
|---|
| 1317 | {
|
|---|
| 1318 | /*
|
|---|
| 1319 | case kPB_POSITION:
|
|---|
| 1320 | Start(0);
|
|---|
| 1321 | return kTRUE;
|
|---|
| 1322 |
|
|---|
| 1323 | case kPB_TRACK:
|
|---|
| 1324 | Start(1);
|
|---|
| 1325 | return kTRUE;
|
|---|
| 1326 | */
|
|---|
| 1327 | case kPB_START:
|
|---|
| 1328 | switch (fTab->GetCurrent())
|
|---|
| 1329 | {
|
|---|
| 1330 | case 0:
|
|---|
| 1331 | StartPos();
|
|---|
| 1332 | return kTRUE;
|
|---|
| 1333 | case 1:
|
|---|
| 1334 | StartTrack(true);
|
|---|
| 1335 | return kTRUE;
|
|---|
| 1336 | case 2:
|
|---|
| 1337 | fCRaDec->SetCoordinates(fCCalib->GetCoordinates());
|
|---|
| 1338 | StartTrack(false);
|
|---|
| 1339 | return kTRUE;
|
|---|
| 1340 | case 3:
|
|---|
| 1341 | fQueue->Proc(WM_TESTSE, (void*)1);
|
|---|
| 1342 | return kTRUE;
|
|---|
| 1343 | case 4:
|
|---|
| 1344 | fQueue->Proc(WM_GEAR, (void*)1);
|
|---|
| 1345 | return kTRUE;
|
|---|
| 1346 | /*
|
|---|
| 1347 | case 5:
|
|---|
| 1348 | StartDemo();
|
|---|
| 1349 | return kTRUE;
|
|---|
| 1350 | */
|
|---|
| 1351 | }
|
|---|
| 1352 | return kTRUE;
|
|---|
| 1353 |
|
|---|
| 1354 | case kPB_STOP:
|
|---|
| 1355 | cout << "Sending stop movement msg." << endl;
|
|---|
| 1356 | //StopDemo();
|
|---|
| 1357 | fQueue->PostMsg(WM_STOP, 0, 0);
|
|---|
| 1358 | if (fTab->GetCurrent()==3)
|
|---|
| 1359 | fQueue->Proc(WM_TESTSE, NULL);
|
|---|
| 1360 | if (fTab->GetCurrent()==4)
|
|---|
| 1361 | fQueue->Proc(WM_GEAR, NULL);
|
|---|
| 1362 | cout << "PostMsg (WM_Stop) returned." << endl;
|
|---|
| 1363 | return kTRUE;
|
|---|
| 1364 |
|
|---|
| 1365 | case kPB_CALCALTAZ:
|
|---|
| 1366 | {
|
|---|
| 1367 | XY xy = fCRaDec->GetCoordinates();
|
|---|
| 1368 | fQueue->Proc(WM_CALCALTAZ, &xy);
|
|---|
| 1369 | }
|
|---|
| 1370 | return kTRUE;
|
|---|
| 1371 |
|
|---|
| 1372 | case kPB_SavePreDef:
|
|---|
| 1373 | {
|
|---|
| 1374 | ofstream fout("prepos.txt", ios::app);
|
|---|
| 1375 | XY za = fCZdAz->GetCoordinates();
|
|---|
| 1376 | fout << setprecision(7) << za.X() << " \t" << za.Y();
|
|---|
| 1377 | fout << " New Position" << endl;
|
|---|
| 1378 | }
|
|---|
| 1379 | return kTRUE;
|
|---|
| 1380 | case kPB_SaveStar:
|
|---|
| 1381 | {
|
|---|
| 1382 | ofstream fout("stars.txt", ios::app);
|
|---|
| 1383 | XY za = fCCalib->GetCoordinates();
|
|---|
| 1384 |
|
|---|
| 1385 | UShort_t d, m, s;
|
|---|
| 1386 | Char_t sgn;
|
|---|
| 1387 | Slalib::Deg2Dms(za.X(), sgn, d, m, s);
|
|---|
| 1388 | if (sgn=='-') fout << sgn;
|
|---|
| 1389 | fout << d << " " << m << " " << s << " \t";
|
|---|
| 1390 | Slalib::Deg2Dms(za.Y(), sgn, d, m, s);
|
|---|
| 1391 | if (sgn=='-') fout << sgn;
|
|---|
| 1392 | fout << d << " " << m << " " << s << " \t";
|
|---|
| 1393 | fout << " New Star/Source" << endl;
|
|---|
| 1394 | }
|
|---|
| 1395 | return kTRUE;
|
|---|
| 1396 |
|
|---|
| 1397 | case kPB_RAp:
|
|---|
| 1398 | case kPB_RAm:
|
|---|
| 1399 | case kPB_DECp:
|
|---|
| 1400 | case kPB_DECm:
|
|---|
| 1401 | {
|
|---|
| 1402 | XY xy = fCRaDec->GetCoordinates();
|
|---|
| 1403 | switch (mp1)
|
|---|
| 1404 | {
|
|---|
| 1405 | case kPB_RAp:
|
|---|
| 1406 | xy.X(xy.X()+1./60);
|
|---|
| 1407 | break;
|
|---|
| 1408 | case kPB_RAm:
|
|---|
| 1409 | xy.X(xy.X()-1./60);
|
|---|
| 1410 | break;
|
|---|
| 1411 | case kPB_DECp:
|
|---|
| 1412 | xy.Y(xy.Y()+1./60);
|
|---|
| 1413 | break;
|
|---|
| 1414 | case kPB_DECm:
|
|---|
| 1415 | xy.Y(xy.Y()-1./60);
|
|---|
| 1416 | break;
|
|---|
| 1417 | }
|
|---|
| 1418 | fCRaDec->SetCoordinates(xy);
|
|---|
| 1419 | StartTrack(false);
|
|---|
| 1420 | /*
|
|---|
| 1421 | RaDec dest(xy.X()*15., xy.Y()); // xy.X() [h]->[ø]
|
|---|
| 1422 | fQueue->PostMsg(WM_TRACK, &dest, sizeof(dest));
|
|---|
| 1423 | //fQueue->Proc(WM_NEWTRACK, &dest);
|
|---|
| 1424 | */
|
|---|
| 1425 | //cout << "New Ra/Dec: " << dest.Ra() << "h " << dest.Dec() << "\xb0" << endl;
|
|---|
| 1426 | }
|
|---|
| 1427 | return kTRUE;
|
|---|
| 1428 |
|
|---|
| 1429 | case kPB_ZDp:
|
|---|
| 1430 | case kPB_ZDm:
|
|---|
| 1431 | case kPB_AZp:
|
|---|
| 1432 | case kPB_AZm:
|
|---|
| 1433 | StartTrackPos(mp1);
|
|---|
| 1434 | return kTRUE;
|
|---|
| 1435 |
|
|---|
| 1436 | case kPB_TPOINT:
|
|---|
| 1437 | StartTPoint();
|
|---|
| 1438 | return kTRUE;
|
|---|
| 1439 | /*
|
|---|
| 1440 | case kPB_CALIBSE:
|
|---|
| 1441 | StartCalib();
|
|---|
| 1442 | return kTRUE;
|
|---|
| 1443 | */
|
|---|
| 1444 | case kPB_LoadBending:
|
|---|
| 1445 | fQueue->Proc(WM_LOADBENDING, NULL);
|
|---|
| 1446 | return kTRUE;
|
|---|
| 1447 | case kPB_ResetBending:
|
|---|
| 1448 | fQueue->Proc(WM_RESETBENDING, NULL);
|
|---|
| 1449 | return kTRUE;
|
|---|
| 1450 | /*
|
|---|
| 1451 | case kPB_HOME:
|
|---|
| 1452 | fQueue->PostMsg(WM_HOME, 0, 0);
|
|---|
| 1453 | return kTRUE;
|
|---|
| 1454 | */
|
|---|
| 1455 | case kPB_TRACKPOS:
|
|---|
| 1456 | StartTrackPos();
|
|---|
| 1457 | return kTRUE;
|
|---|
| 1458 | case kPB_DISPLAY1:
|
|---|
| 1459 | case kPB_DISPLAY2:
|
|---|
| 1460 | fQueue->PostMsg(WM_DISPLAY, 0, 0);
|
|---|
| 1461 | return kTRUE;
|
|---|
| 1462 |
|
|---|
| 1463 | default:
|
|---|
| 1464 | return kTRUE;
|
|---|
| 1465 | }
|
|---|
| 1466 | return kTRUE;
|
|---|
| 1467 |
|
|---|
| 1468 | case kCM_MENU:
|
|---|
| 1469 |
|
|---|
| 1470 | switch (mp1)
|
|---|
| 1471 | {
|
|---|
| 1472 | case IDM_EXIT:
|
|---|
| 1473 | cout << "IDM_EXIT: Posting WM_QUIT." << endl;
|
|---|
| 1474 | fQueue->PostMsg(WM_QUIT, 0, 0);
|
|---|
| 1475 | cout << "IDM_EXIT: WM_QUIT done." << endl;
|
|---|
| 1476 | //cout << "Idm_Exit." << endl;
|
|---|
| 1477 | //CloseWindow();
|
|---|
| 1478 | return kTRUE;
|
|---|
| 1479 | case IDM_ASPECT:
|
|---|
| 1480 | {
|
|---|
| 1481 | Int_t w = GetWidth();
|
|---|
| 1482 | Int_t h = GetHeight();
|
|---|
| 1483 | if (w>940*h/660)
|
|---|
| 1484 | w = 940*h/660;
|
|---|
| 1485 | else
|
|---|
| 1486 | h = 660*w/940;
|
|---|
| 1487 | Resize(w, h);
|
|---|
| 1488 | }
|
|---|
| 1489 | return kTRUE;
|
|---|
| 1490 | case kLogClear:
|
|---|
| 1491 | fLog->Clear();
|
|---|
| 1492 | return kTRUE;
|
|---|
| 1493 | case kLogCopy:
|
|---|
| 1494 | fLog->Copy();
|
|---|
| 1495 | return kTRUE;
|
|---|
| 1496 | case kLogSelect:
|
|---|
| 1497 | fLog->SelectAll();
|
|---|
| 1498 | return kTRUE;
|
|---|
| 1499 | case kLogSearch:
|
|---|
| 1500 | //virtual Bool_t Search(const char *string, Bool_t direction, Bool_t caseSensitive);
|
|---|
| 1501 | return kTRUE;
|
|---|
| 1502 | case kLogSave:
|
|---|
| 1503 | cout << "Saving log... " << flush;
|
|---|
| 1504 | if (fLog->GetText()->Save("cosylog.txt"))
|
|---|
| 1505 | cout << "done." << endl;
|
|---|
| 1506 | else
|
|---|
| 1507 | cout << "failed!" << endl;
|
|---|
| 1508 | return kTRUE;
|
|---|
| 1509 |
|
|---|
| 1510 | case kLogAppend:
|
|---|
| 1511 | cout << "Appending log... " << flush;
|
|---|
| 1512 | if (fLog->GetText()->Append("cosylog.txt"))
|
|---|
| 1513 | cout << "done." << endl;
|
|---|
| 1514 | else
|
|---|
| 1515 | cout << "failed!" << endl;
|
|---|
| 1516 | return kTRUE;
|
|---|
| 1517 | }
|
|---|
| 1518 | return kTRUE;
|
|---|
| 1519 | }
|
|---|
| 1520 | }
|
|---|
| 1521 |
|
|---|
| 1522 | //
|
|---|
| 1523 | // Start a thread to process the message.
|
|---|
| 1524 | //
|
|---|
| 1525 | // fQueue->PostMsg(msg, mp1, mp2);
|
|---|
| 1526 | return kTRUE;
|
|---|
| 1527 |
|
|---|
| 1528 | }
|
|---|