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