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