Changeset 7790 for trunk/MagicSoft


Ignore:
Timestamp:
07/14/06 13:19:54 (18 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Cosy
Files:
2 added
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Cosy/Changelog

    r7788 r7790  
    11                                                                  -*-*- END -*-*-
     2 2006/07/14 Thomas Bretz (La Palma)
     3
     4   * stargleds.txt:
     5     - changed positions slightly
     6
     7   * gui/GuiLinkDef.h, gui/Makefile:
     8     - added MGNumStars
     9
     10   * gui/MGStars.[h,cc]:
     11     - addde
     12
     13   * gui/MGAccuracy.[h,cc], gui/MGStarg.[h,cc]:
     14     - unified
     15     - slight changes to layout
     16
     17   * gui/MGCoordinate.[h,cc], MGCoordinated.[h,cc]:
     18     - added a new mode which allows to suppress the title
     19
     20   * gui/MGCosy.[h,cc]:
     21     - added new status box (armed) currently switched on by default
     22     - adapted to changes in MGAccuracy
     23     - disallow changing the size of the window
     24
     25   * main/MCaos.cc:
     26     - removed an obsolete Print()
     27
     28   * main/MCosy.cc:
     29     - fixed the name of the log-files (2006 instead of 06)
     30
     31   * main/MStarguider.[h,cc]:
     32     - implemented new socket to send triggers to Amc (port 7307)
     33     - changed standard limiting magnitude from 7.0 to 9.0
     34     - changed layout of display to implement new canvas
     35       displaying the number of detected and correlated stars
     36     - adapted to changes in MGStarg
     37     - added box to change cleaning level of starguider window
     38     - set default rotation angle to -0.4deg
     39     - disallow changing of window size
     40     - CalcTrackingError: check first the number of detected spots
     41       and afterwards the number of found catalog stars
     42     - CalcTrackingError: just try to correlate all spots with all stars
     43     - decreased box size of LED box in starguider mode
     44     - replaced circles around starguider pointing position by
     45       camara size hexagons
     46     - do not show the starguider pointing position if less than three
     47       stars could be correlated
     48
     49   * tcpip/MTcpIpIO.cc:
     50     - fixed a comparison between "signed and unsigned"
     51
     52   * videodev/FilterLed.[h,cc]:
     53     - implemented DrawHexagon based on MGMap::DrawHexagon
     54     - renamed *Circle to *Box
     55     - replaced old algorithm to find stars in starguider mode (and
     56       LEDs) by a new ClusterFinder class
     57     - needs more maintanance!
     58
     59
     60
    261 2006/07/11 Thomas Bretz (La Palma)
    362
  • trunk/MagicSoft/Cosy/gui/GuiLinkDef.h

    r4865 r7790  
    1515#pragma link C++ class MGSkyPosition+;
    1616#pragma link C++ class MGStarg+;
     17#pragma link C++ class MGNumStars+;
    1718
    1819#pragma link C++ class MGCosy+;
  • trunk/MagicSoft/Cosy/gui/MGAccuracy.cc

    r7788 r7790  
    1 //
    2 // This File contains the definition of the MGCoordinates-class
    3 //
    4 //   Author: Thomas Bretz
    5 //   Version: V1.0 (1-8-2000)
    6 
    71#include "MGAccuracy.h"
    82
     
    137#include <TText.h>
    148#include <TWbox.h>
    15 #include <TList.h>
    169#include <TGaxis.h>
    1710#include <TGraph.h>
     
    2417ClassImp(MGAccuracy);
    2518
    26 void MGAccuracy::DrawCoordinateSystem()
    27 {
    28     TWbox box;
    29     box.DrawWbox(-145*2, 145*2, -15*2, 120*2,  18,  2, 1);
     19void MGAccuracy::DrawText(const char *c1, const char *c2, const char *c3, const char*txt)
     20{
     21    fCanvas->SetEditable(kTRUE);
     22    fCanvas->cd();
    3023
    3124    TText text;
    3225    text.SetTextAlign(22);  // centered, centered (s.TAttText)
    33     text.DrawText(-80*2, 132.5*2, "Ctrl Deviation [min]");
    34 
     26    text.DrawText(-150, 265, txt);
     27
     28    text.SetTextAlign(11);  // left, bottom (s.TAttText)
     29    text.SetTextColor(3);
     30    text.DrawText(220, -220, c1);
     31
     32    text.SetTextColor(5);
     33    text.DrawText(220, -250, c2);
     34
     35    text.SetTextColor(2);
     36    text.DrawText(220, -280, c3);
     37
     38    fCanvas->SetEditable(kFALSE);
     39}
     40
     41void MGAccuracy::DrawCircles(Double_t rad)
     42{
     43    fCanvas->SetEditable(kTRUE);
     44    fCanvas->cd();
    3545
    3646    TArc arc;
     
    3949    arc.SetLineColor(3);     // green
    4050    arc.SetLineStyle(2);     // dashed  (s. TAttLine)
    41     arc.DrawArc(0, 0, 79.1/2.);        // 0.5se
     51    arc.DrawArc(0, 0, rad/2.);         // 0.5se
    4252
    4353    arc.SetLineColor(5);     // yellow
    44     arc.DrawArc(0, 0, 79.1);            // 1.0se
     54    arc.DrawArc(0, 0, rad);            // 1.0se
    4555
    4656    arc.SetLineColor(2);     // red
    47     arc.DrawArc(0, 0, 79.1*2.);         // 2.0se
    48 
    49 
    50     text.SetTextAlign(11);  // left, bottom (s.TAttText)
    51     text.SetTextColor(3);
    52     text.DrawText(220, -220, "0.5se");
    53 
    54     text.SetTextColor(5);
    55     text.DrawText(220, -250, "1.0se");
    56 
    57     text.SetTextColor(2);
    58     text.DrawText(220, -280, "2.0se");
    59 
    60 
    61     TLine line;
    62     line.DrawLine(-65*4,     0, 65*4,    0);
    63     line.DrawLine(    0, -65*4,    0, 65*4);
     57    arc.DrawArc(0, 0, rad*2.);         // 2.0se
     58
     59    fCanvas->SetEditable(kFALSE);
     60}
     61
     62void MGAccuracy::DrawCoordinateSystem()
     63{
     64    TWbox box;
     65    box.DrawWbox(-290, 290, -10, 240,  18,  2, 1);
     66
     67//    TLine line;
     68//    line.DrawLine(-65*4,     0, 65*4,    0);
     69//    line.DrawLine(    0, -65*4,    0, 65*4);
    6470
    6571    //
     
    122128
    123129MGAccuracy::MGAccuracy(const TGWindow* p, const UInt_t w)
    124 : MGEmbeddedCanvas("Accuracy", p, w, 300)
     130: MGEmbeddedCanvas("Accuracy", p, w, 300), fColorScale(360*60/16384)
    125131{
    126132    // FIXME: Overload MapWindow in newer Root versions to remove
     
    133139    fGraph->Draw("LP");
    134140    fList->Add(fGraph);
    135     //fGraph->SetNameTitle("AccVsT", "Accuracy vs Min of Time");
    136     //fGraph->Draw("APL");
    137     //fGraph->SetMarkerSize(2);
    138141
    139142    DrawCoordinateSystem();
     
    153156MGAccuracy::~MGAccuracy()
    154157{
    155     //    cout << "MGAccuracy destroyed." << endl;
    156158}
    157159
     
    172174
    173175    fBar->SetY2(dist*60); // [sec]
    174     if (dist*16384<1*360*60)
     176    if (dist<fColorScale) //1*360*60/16384
    175177        fBar->SetLineColor(kGreen);
    176178    else
    177         if (dist*16384<2*360*60)
     179        if (dist<2*fColorScale) //2*360*60/16384
    178180            fBar->SetLineColor(kYellow);
    179181        else
     
    227229
    228230    SetModified();
    229 
    230     //cout << "N1 == " << fGraph->GetN() << endl;
    231 
    232     //fGraph->GetHistogram()->SetXTitle("Time");
    233     //fGraph->GetHistogram()->SetYTitle("\\Delta [arcmin]");
    234     //fGraph->GetHistogram()->GetXaxis()->SetTimeFormat("%M %F1995-01-01 00:00:00");
    235     //fGraph->GetHistogram()->GetXaxis()->SetTimeDisplay(1);
    236     //fGraph->GetHistogram()->GetXaxis()->SetLabelSize(0.033);
    237231}
    238232
     
    248242{
    249243    //
    250     // calculate actual time for planet positions
    251     // acc [deg]
    252     //
    253244    // x["], y["]
    254245    //
  • trunk/MagicSoft/Cosy/gui/MGAccuracy.h

    r4076 r7790  
    1 #ifndef MGACCURACY_H
    2 #define MGACCURACY_H
     1#ifndef COSY_MGAccuracy
     2#define COSY_MGAccuracy
    33
    44//
     
    2020class MGAccuracy : public MGEmbeddedCanvas
    2121{
     22protected:
    2223    TLine  *fLin1;
    2324    TLine  *fLin2;
     
    3031
    3132    Double_t fTime;
     33    Double_t fColorScale;
    3234
    3335    void DrawCoordinateSystem();
     
    4648    ~MGAccuracy();
    4749
     50    void DrawText(const char *c1, const char *c2, const char *c3, const char *txt);
     51    void DrawCircles(Double_t rad=79.1);
     52
     53    void SetColorScale(Double_t scale=1) { fColorScale=scale; }
     54
    4855    void Update(ZdAz &pos, ZdAz &acc);
    4956
     
    5158};
    5259
    53 #endif // MGSKYPOSITION_H
     60#endif // COSY_MGAccuracy
  • trunk/MagicSoft/Cosy/gui/MGCoordinate.cc

    r7787 r7790  
    2626
    2727MGCoordinate::MGCoordinate(const TGWindow* p, const Int_t type=kETypeDeg,
    28                            const Bool_t flag, const char *txt,
     28                           const Int_t flag, const char *txt,
    2929                           const Int_t deg, const UInt_t min, const UInt_t sec)
    30 : TGFrame(p, 119, flag?76:46, kSunkenFrame|kFixedSize), fSign('+'), fDeg(deg), fMin(min), fSec(sec)
     30: TGFrame(p, 119, flag==1?76:46-(TString(txt).IsNull()?23:0), kSunkenFrame|kFixedSize), fSign('+'), fDeg(deg), fMin(min), fSec(sec), fLabel(0)
    3131{
    3232    fList = new MGList;
    3333
     34    const Int_t offset = TString(txt).IsNull() ? 23 : 0;
     35
    3436    // p = pointer to MainFrame (not owner)
    35     if (flag)
     37    if (flag==1)
    3638    {
    3739        fTextEntryDeg = new TGTextEntry(this, "****", IDM_kDeg);
     
    4143        // fTextEntryMin->SetAlignment(kTextCenterX);
    4244        // fTextEntrySec->SetAlignment(kTextCenterX);
    43         fTextEntryDeg->Move( 7, 26);
    44         fTextEntryMin->Move(47, 26);
    45         fTextEntrySec->Move(81, 26);
     45        fTextEntryDeg->Move( 7, 26-offset);
     46        fTextEntryMin->Move(47, 26-offset);
     47        fTextEntrySec->Move(81, 26-offset);
    4648        fTextEntryDeg->MapWindow();
    4749        fTextEntryMin->MapWindow();
     
    5658    }
    5759
    58     const int ypos = flag?56:26;
     60    const int ypos = (flag==1?56:26)-offset;
    5961
    6062    fLabelDeg = new TGLabel(this, "****");
     
    7880    Set(fLabelSec, fSec);
    7981
    80     fLabel = new TGLabel(this, txt);
    81     fLabel->SetTextJustify(kTextLeft);
    82     fLabel->Move(4, 4);
    83     fLabel->MapWindow();
    84     fList->Add(fLabel);
     82    if (!TString(txt).IsNull())
     83    {
     84        fLabel = new TGLabel(this, txt);
     85        fLabel->SetTextJustify(kTextLeft);
     86        fLabel->Move(4, 4);
     87        fLabel->MapWindow();
     88        fList->Add(fLabel);
     89    }
    8590
    8691    TGLabel *label;
     
    9095    const char *sec = type==kETypeDeg ? "\""   : "s";
    9196
    92     if (flag)
     97    if (flag==1)
    9398    {
    9499        label = new TGLabel(this, deg);
    95100        label->SetTextJustify(kTextLeft);
    96         label->Move(37, 29);
     101        label->Move(37, 29-offset);
    97102        label->MapWindow();
    98103        fList->Add(label);
     
    100105        label = new TGLabel(this, min);
    101106        label->SetTextJustify(kTextLeft);
    102         label->Move(71, 29);
     107        label->Move(71, 29-offset);
    103108        label->MapWindow();
    104109        fList->Add(label);
     
    106111        label = new TGLabel(this, sec);
    107112        label->SetTextJustify(kTextLeft);
    108         label->Move(107, 29);
     113        label->Move(107, 29-offset);
    109114        label->MapWindow();
    110115        fList->Add(label);
     
    146151void MGCoordinate::Print()
    147152{
    148     cout << fLabel->GetText()->GetString() << " " << fSign << fDeg << "\xb0 " << fMin << "' " << fSec << "\"" << endl;
     153    if (fLabel)
     154        cout << fLabel->GetText()->GetString() << " ";
     155    cout << fSign << fDeg << "\xb0 " << fMin << "' " << fSec << "\"" << endl;
    149156}
    150157
  • trunk/MagicSoft/Cosy/gui/MGCoordinate.h

    r1531 r7790  
    1 #ifndef MGCOORDINATE_H
    2 #define MGCOORDINATE_H
     1#ifndef COSY_MGCoordinate
     2#define COSY_MGCoordinate
    33
    44//
     
    4949public:
    5050    MGCoordinate(const TGWindow* p, const Int_t type=kETypeDeg,
    51                  const Bool_t flag=kTRUE, const char *txt="Coordinates:",
     51                 const Int_t flag=1, const char *txt="Coordinates:",
    5252                 const Int_t deg=0, const UInt_t min=0, const UInt_t sec=0);
    5353    ~MGCoordinate();
     
    6363};
    6464
    65 #endif // MGIMAGE_H
     65#endif // COSY_MGCoordinates
  • trunk/MagicSoft/Cosy/gui/MGCoordinates.cc

    r1111 r7790  
    1616MGCoordinates::MGCoordinates(const TGWindow* p,
    1717                             const Int_t type,
    18                              const Bool_t flag,
     18                             const Int_t flag,
    1919                             const Int_t deg1, const UInt_t min1, const UInt_t sec1,
    2020                             const Int_t deg2, const UInt_t min2, const UInt_t sec2)
     
    2323    const Int_t t    = type==kETypeZdAz ? kETypeDeg : kETypeH;
    2424    const char *txt1 = type==kETypeZdAz ? "Zenith Dist [\xb0]:" : "Right Ascension [h]:";
    25     const char *txt2 = type==kETypeZdAz ? "Azimuth [\xb0]:" : "Declination [\xb0]:";
     25    const char *txt2 = type==kETypeZdAz ? "Azimuth [\xb0]:"     : "Declination [\xb0]:";
    2626
    2727    // p = pointer to MainFrame (not owner)
    28     fX = new MGCoordinate(this, t, flag, txt1, deg1, min1, sec1);
     28    fX = new MGCoordinate(this, t, flag, flag>1?"":txt1, deg1, min1, sec1);
    2929    fX->Move(0, 0);
    3030
    31     fY = new MGCoordinate(this, kETypeDeg, flag, txt2, deg2, min2, sec2);
     31    fY = new MGCoordinate(this, kETypeDeg, flag, flag>1?"":txt2, deg2, min2, sec2);
    3232    fY->Move(125, 0);
    3333
  • trunk/MagicSoft/Cosy/gui/MGCoordinates.h

    r1111 r7790  
    1 #ifndef MGCOORDINATES_H
    2 #define MGCOORDINATES_H
     1#ifndef COSY_MGCoordinates
     2#define COSY_MGCoordinates
    33
    44//
     
    1515
    1616enum {
    17     kETypeZdAz,
    18     kETypeRaDec
     17    kETypeZdAz = BIT(0),
     18    kETypeRaDec= BIT(1),
     19    kETypeNone = BIT(3)
    1920};
    2021
     
    2829public:
    2930    MGCoordinates(const TGWindow* p, const Int_t type=kETypeZdAz,
    30                   const Bool_t flag=kTRUE,
     31                  const Int_t flag=1,
    3132                  const Int_t deg1=0, const UInt_t min1=0, const UInt_t sec1=0,
    3233                  const Int_t deg2=0, const UInt_t min2=0, const UInt_t sec2=0);
     
    4142};
    4243
    43 #endif // MGIMAGE_H
     44#endif // COSY_MGCoordinates
  • trunk/MagicSoft/Cosy/gui/MGCosy.cc

    r4104 r7790  
    247247    fList->Add(fAzSoll);
    248248
     249    fArmed     = new TGLabel(f, "Armed");
    249250    fError     = new TGLabel(f, "Error");
    250251    fMoving    = new TGLabel(f, "Moving");
     
    261262    ULong_t color;
    262263
     264    gClient->GetColorByName("Magenta", color);
     265    fArmed->SetBackgroundColor(color);
    263266    gClient->GetColorByName("Red", color);
    264267    fError->SetBackgroundColor(color);
     
    278281    fStopped->SetBackgroundColor(color);
    279282
    280     fError   ->MoveResize(10, 25, 60, 20);
    281     fMoving  ->MoveResize(10, 25+20, 60, 20);
    282     fTracking->MoveResize(10, 25+40, 60, 20);
    283     fStopping->MoveResize(10, 25+60, 60, 20);
    284     fStopped ->MoveResize(10, 25+80, 60, 20);
    285     fAvailMac1->MoveResize(10, 25+120, 60, 20);
    286     fAvailMac2->MoveResize(10, 25+140, 60, 20);
     283    fArmed   ->MoveResize(10,  25,        60, 20);
     284    fError   ->MoveResize(10,  25+25,     60, 20);
     285    fMoving  ->MoveResize(10,  25+25+20,  60, 20);
     286    fTracking->MoveResize(10,  25+25+40,  60, 20);
     287    fStopping->MoveResize(10,  25+25+60,  60, 20);
     288    fStopped ->MoveResize(10,  25+25+80,  60, 20);
     289    fAvailMac1->MoveResize(10, 25+25+120, 60, 20);
     290    fAvailMac2->MoveResize(10, 25+25+140, 60, 20);
    287291    //fAvailMac3->Move(10, 25+160);
    288     fAvailSe1->MoveResize(10, 25+200, 60, 20);
    289     fAvailSe2->MoveResize(10, 25+220, 60, 20);
    290     fAvailSe3->MoveResize(10, 25+180, 60, 20);
    291 
     292    fAvailSe1->MoveResize(10,  25+25+200, 60, 20);
     293    fAvailSe2->MoveResize(10,  25+25+220, 60, 20);
     294    fAvailSe3->MoveResize(10,  25+25+180, 60, 20);
     295
     296    fList->Add(fArmed);
    292297    fList->Add(fError);
    293298    fList->Add(fMoving);
     
    737742#endif
    738743    fAccuracy = new MGAccuracy(f1, 300);
     744    fAccuracy->DrawText("0.5se", "1.0se", "2.0se", "Ctrl Deviation [min]");
     745    fAccuracy->DrawCircles();
    739746#ifdef DEBUG
    740747    cout << "MGCosy: Creating MGVelocity" << endl;
     
    822829    const Int_t w = 1010;
    823830    const Int_t h =  700;
    824     SetWMSizeHints(w, h, 1280, 900, 10, 10);  // set the smallest and biggest size of the Main frame
     831    SetWMSizeHints(w, h, w, h, 1, 1);  // set the smallest and biggest size of the Main frame
    825832
    826833    SetWindowName("Cosy Main Window");
     
    10681075    SetLabelColor(fAvailSe2,  stat2&0x10);
    10691076    SetLabelColor(fAvailSe3,  stat2&0x20);
     1077
     1078    EnableLabel(fArmed, 1);//stat2&0x40);
    10701079
    10711080    if (stat&MDriveCom::kTracking)
  • trunk/MagicSoft/Cosy/gui/MGCosy.h

    r4104 r7790  
    8888    TGTab         *fTab;
    8989
     90    TGLabel *fArmed;
    9091    TGLabel *fError;
    9192    TGLabel *fMoving;
  • trunk/MagicSoft/Cosy/gui/MGStarg.cc

    r7788 r7790  
    11#include "MGStarg.h"
    22
    3 #include <iostream.h>  // cout
    4 
    5 #include <TArc.h>
    6 #include <TLine.h>
    7 #include <TText.h>
    8 #include <TWbox.h>
    9 #include <TList.h>
    10 #include <TGaxis.h>
    11 #include <TGraph.h>
    123#include <TCanvas.h>
    134
    145#include <MHexagon.h>
    156
    16 #include "coord.h"
    17 #include "MTime.h"
    18 #include "MAstro.h"
    19 
    207ClassImp(MGStarg);
    218
    22 void MGStarg::DrawCoordinateSystem()
     9void MGStarg::DrawHexagon()
    2310{
    24     TWbox box;
    25     box.DrawWbox(-145*2, 145*2, -15*2, 120*2,  18,  2, 1);
    26 
    27     TText text;
    28     text.SetTextAlign(22);  // centered, centered (s.TAttText)
    29     text.DrawText(-80*2, 132.5*2, "Misspointing [min]");
     11    fCanvas->SetEditable(kTRUE);
     12    fCanvas->cd();
    3013
    3114    MHexagon hex;
    32     hex.SetFillColor(39);
    3315    hex.SetFillStyle(4000);
    3416    hex.SetLineColor(17);
    35     hex.DrawHexagon(0,0,177.5*2);
     17    hex.DrawHexagon(0, 0, 177.5*2);
    3618
    37     text.SetTextAlign(11);  // left, bottom (s.TAttText)
    38     text.SetTextColor(3);
    39     text.DrawText(220, -220, "0.75'");
    40 
    41     text.SetTextColor(5);
    42     text.DrawText(220, -250, "1.50'");
    43 
    44     text.SetTextColor(2);
    45     text.DrawText(220, -280, "3.00'");
    46 
    47 
    48     TLine line;
    49     line.DrawLine(-65*4,     0, 65*4,    0);
    50     line.DrawLine(    0, -65*4,    0, 65*4);
    51 
    52     //
    53     // Can be replaced by TGaxis axe; in a later root version
    54     // than 3.01/06. I talked to Rene
    55     //
    56     TGaxis *axe;
    57     axe = new TGaxis(-60*4,   0, 60*4,  0,  -4, 4, 30204, "+-N");
    58     axe->SetTitle("Az"); // \xb0
    59     axe->SetBit(kCanDelete);
    60     axe->Draw();
    61 
    62     axe = new TGaxis(  0, -60*4,  0, 60*4,  -4, 4,   304, "+-N");
    63     axe->SetTitle("Zd"); // \xb0
    64     axe->SetLabelOffset(-0.02);
    65     axe->SetBit(kCanDelete);
    66     axe->Draw();
    67 }
    68 
    69 void MGStarg::InitText()
    70 {
    71     fTxt = new TText(280, 280, "0' / 0'");
    72     fTxt->SetTextAlign(33); // right, top
    73     fTxt->SetTextColor(10);
    74     fTxt->Draw();
    75 
    76     fList->Add(fTxt);
    77 }
    78 
    79 void MGStarg::InitBar()
    80 {
    81     fBar = new TLine(0, 0, 0, 0);
    82     fBar->SetLineColor(kBlack);
    83     fBar->SetLineStyle(1);
    84     fBar->SetLineWidth(5);
    85     fBar->Draw();
    86 
    87     fList->Add(fBar);
    88 }
    89 
    90 void MGStarg::InitCross()
    91 {
    92     fLin1 = new TLine(0, 0, 0, 0);
    93     fLin2 = new TLine(0, 0, 0, 0);
    94 
    95     fLin1->SetLineColor(10); // white (s. TAttFill)
    96     fLin2->SetLineColor(10); // white
    97     fLin1->SetLineStyle(1);  // solid (s. TAttLine)
    98     fLin2->SetLineStyle(1);
    99 
    100     fLin1->SetLineWidth(2);
    101     fLin2->SetLineWidth(2);
    102 
    103     fLin1->Draw();
    104     fLin2->Draw();
    105 
    106     fList->Add(fLin1);
    107     fList->Add(fLin2);
     19    fCanvas->SetEditable(kFALSE);
    10820}
    10921
    11022MGStarg::MGStarg(const TGWindow* p, const UInt_t w)
    111 : MGEmbeddedCanvas("Starg", p, w, 300)
     23: MGAccuracy(p, w)
    11224{
    113     // FIXME: Overload MapWindow in newer Root versions to remove
    114     //        the contents of the graph!
    115     fGraph = new TGraph;
    116     fGraph->SetPoint(0, 0, 0);
    117     fGraph->SetLineColor(kBlue);
    118     fGraph->SetMarkerColor(kBlue);
    119     fGraph->SetMarkerStyle(kFullDotMedium);
    120     fGraph->Draw("LP");
    121     fList->Add(fGraph);
    122     //fGraph->SetNameTitle("AccVsT", "Accuracy vs Min of Time");
    123     //fGraph->Draw("APL");
    124     //fGraph->SetMarkerSize(2);
    125 
    126     DrawCoordinateSystem();
    127 
    128     InitText();
    129     InitCross();
    130     InitBar();
    131 
    132     InitCanvas();
    133 
    134     SetNoContextMenu();
    135 
    136     MTime t(-1);
    137     fTime = t.GetAxisTime();
     25    SetColorScale(1.5);
    13826}
    139 
    140 MGStarg::~MGStarg()
    141 {
    142     //    cout << "MGStarg destroyed." << endl;
    143 }
    144 
    145 // dist [deg]
    146 void MGStarg::UpdateText(Float_t dist)
    147 {
    148     dist *= 3600.; // [sec]
    149 
    150     int rs = (int)floor(fmod(dist, 60.));
    151 
    152     dist /= 60.;   // [min]
    153     int rm = (int)dist;
    154 
    155     char txt[100];
    156     rm ? sprintf(txt, "%d'%02d\"", rm, rs) : sprintf(txt, "%d\"", rs);
    157 
    158     fTxt->SetText(fTxt->GetX(), fTxt->GetY(), txt);
    159 
    160     fBar->SetY2(dist*60); // [sec]
    161     if (dist<1.5)
    162         fBar->SetLineColor(kGreen);
    163     else
    164         if (dist<3)
    165             fBar->SetLineColor(kYellow);
    166         else
    167             fBar->SetLineColor(kRed);
    168 
    169     SetModified();
    170 }
    171 
    172 // dist [deg]
    173 void MGStarg::UpdateGraph(Float_t dist)
    174 {
    175     MTime t(-1);
    176     const Double_t dtime = t.GetAxisTime()-fTime; // range [-0.5h, 0h]
    177 
    178     dist *= 60; // min
    179 
    180     static int odist = -1;
    181     if (odist==(int)(dist*10*60) && dtime<10)
    182         return;
    183 
    184     odist = (int)(dist*10*60);
    185 
    186     fGraph->SetPoint(fGraph->GetN(), dtime, dist*60);
    187 
    188     const Double_t ntime = dtime;
    189     for (int i=0; i<fGraph->GetN(); i++)
    190     {
    191         Double_t x, y;
    192         fGraph->GetPoint(i, x,       y);
    193         fGraph->SetPoint(i, x-ntime, y);
    194         //cout << i << ":  " << x-ntime << " / " << y << endl;
    195     }
    196     while (fGraph->GetN()>0)
    197     {
    198         Double_t x, y;
    199         fGraph->GetPoint(0, x, y);
    200 
    201         if (x==-ntime && y==0)
    202         {
    203             fGraph->RemovePoint(0);
    204             continue;
    205         }
    206 
    207         if (x>-4.75*60)
    208             break;
    209 
    210         fGraph->RemovePoint(0);
    211     }
    212 
    213     fTime = t.GetAxisTime();
    214 
    215     SetModified();
    216 
    217 }
    218 
    219 void MGStarg::Update(Float_t pzd, Float_t azd, Float_t aaz)
    220 {
    221     const double dist = MAstro::GetDevAbs(pzd, azd, aaz);
    222 
    223     UpdateText(dist);
    224     UpdateGraph(dist);
    225 }
    226 
    227 void MGStarg::UpdateCross(Float_t x, Float_t y)
    228 {
    229     //
    230     // x["], y["]
    231     //
    232     static int X = ~0;
    233     static int Y = ~0;
    234 
    235     int pixx = (int)(x/fPix);  // [pix]
    236     int pixy = (int)(y/fPix);  // [pix]
    237 
    238     if (X==pixx && Y==pixy)
    239         return;
    240 
    241     X = pixx;
    242     Y = pixy;
    243 
    244     fLin1->SetX1(x-5.);
    245     fLin1->SetX2(x+5.);
    246 
    247     fLin2->SetX1(x-5.);
    248     fLin2->SetX2(x+5.);
    249 
    250     fLin1->SetY1(y-5.);
    251     fLin1->SetY2(y+5.);
    252 
    253     fLin2->SetY1(y+5.);
    254     fLin2->SetY2(y-5.);
    255 
    256     SetModified();
    257 }
    258 
    259 void MGStarg::Update(ZdAz &pos, ZdAz &dev)
    260 {
    261     // Estimate the distance in az direction on the camera plane
    262     const double daz = MAstro::GetDevAbs(pos.Zd(), 0, dev.Az())*3600.;
    263 
    264     //cout << "--> S: " << dev.Az()*60 << " " << dev.Zd()*60. << endl;
    265 
    266     UpdateCross(TMath::Sign(daz, dev.Az()), dev.Zd()*3600.);
    267     Update(pos.Zd(), dev.Zd(), dev.Az());
    268 
    269     UpdateCanvas();
    270 }
  • trunk/MagicSoft/Cosy/gui/MGStarg.h

    r4865 r7790  
    1 #ifndef MGSTARG_H
    2 #define MGSTARG_H
     1#ifndef COSY_MGStarg
     2#define COSY_MGStarg
    33
    4 #ifndef COSY_MGEmbeddedCanvas
    5 #include "MGEmbeddedCanvas.h"
     4#ifndef COSY_MGAccuracy
     5#include "MGAccuracy.h"
    66#endif
    77
     
    1212class ZdAz;
    1313
    14 class MGStarg : public MGEmbeddedCanvas
     14class MGStarg : public MGAccuracy
    1515{
    16     TLine  *fLin1;
    17     TLine  *fLin2;
     16//    TLine  *fLin1;
     17//    TLine  *fLin2;
    1818
    19     TText  *fTxt;
     19//    TText  *fTxt;
    2020
    21     TLine  *fBar;
     21//    TLine  *fBar;
    2222
    23     TGraph *fGraph;
     23//    TGraph *fGraph;
    2424
    25     Double_t fTime;
     25//    Double_t fTime;
    2626
    27     void DrawCoordinateSystem();
     27//    void InitText();
     28//    void InitCross();
     29//    void InitBar();
    2830
    29     void InitText();
    30     void InitCross();
    31     void InitBar();
     31//    void UpdateCross(Float_t x, Float_t y);
     32//    void UpdateText(Float_t dist);
     33//    void UpdateGraph(Float_t acc);
     34//    void Update(Float_t zd, Float_t x, Float_t y);
    3235
    33     void UpdateCross(Float_t x, Float_t y);
    34     void UpdateText(Float_t acc);
    35     void UpdateGraph(Float_t acc);
    36     void Update(Float_t zd, Float_t x, Float_t y);
    3736
    3837public:
    3938    MGStarg(const TGWindow* p, const UInt_t w);
    40     ~MGStarg();
     39//    ~MGStarg();
    4140
    42     void Update(ZdAz &pos, ZdAz &acc);
     41//    virtual void DrawText();
     42    void DrawHexagon();
     43
     44//    void Update(ZdAz &pos, ZdAz &acc);
    4345
    4446    ClassDef(MGStarg, 0)
    4547};
    4648
    47 #endif // MGSTARG_H
     49#endif // COSY_MGStarg
  • trunk/MagicSoft/Cosy/gui/Makefile

    r7787 r7790  
    4040           MGAccuracy.cc \
    4141           MGStarg.cc \
     42           MGNumStars.cc \
    4243           MGSkyPosition.cc
    4344 
  • trunk/MagicSoft/Cosy/main/MCaos.cc

    r4865 r7790  
    3434    cout << " Reading " << name << ":" << endl;
    3535    cout << "------------------------------" << endl;
    36 
    3736    while (1)
    3837    {
     
    336335    leds.Clear();
    337336
     337    /*
     338    //the following lines are just to test the new setup
     339    static int i=0;
     340    i++;
     341    i%=2;
     342    if (i==0)
     343        ReadResources("leds0.txt");
     344    else
     345        ReadResources("leds1.txt");
     346    cout << "LEDs " << i << " " << flush;
     347     */
     348
    338349    //          img  width height radius sigma
    339350    FilterLed f(img, 768, 576, box, cut);
     
    378389
    379390    const Ring &center = rings.GetCenter();
    380    
    381     center.Print();
     391
     392//uncommented for testing
     393//    center.Print();
    382394
    383395    // FIXME!
     
    423435    }
    424436
     437    /*
     438    //test - give number of rings
     439    cout << rings.GetEntries() << " " << flush;
     440    */
     441
    425442    if (printl)
    426443        leds.Print();
  • trunk/MagicSoft/Cosy/main/MCosy.cc

    r7788 r7790  
    15371537
    15381538        // This is the full qualified date which is part of the name
    1539         const TString clock = time.GetStringFmt("%y%m%d_%H%M%S");
     1539        const TString clock = time.GetStringFmt("%Y%m%d_%H%M%S");
    15401540
    15411541        // This gives the night in which the date belongs to
  • trunk/MagicSoft/Cosy/main/MStarguider.cc

    r7788 r7790  
    1313#include <TSystem.h>
    1414#include <TFile.h> // temp writeout of histos
     15#include <TSocket.h>
     16
    1517#include "MAstro.h"
    1618#include "MString.h"
     
    3133
    3234#include "MGStarg.h"
     35#include "MGNumStars.h"
    3336#include "TGFrame.h"
    3437
     
    9093    IDM_kPixSize,
    9194    IDM_kAngle,
     95    IDM_kCut,
    9296    IDM_kInterpol250,
    9397    IDM_kInterpol125,
     
    126130
    127131    fGStarg->Update(fPos, fD);   
     132    fGNumStars->Update(fNumStarsDetected, fNumStarsCorrelated);
    128133 
    129134    return kTRUE;
     
    237242    fLimMag->AddEntry("8", IDM_kLimMag8);
    238243    fLimMag->AddEntry("9", IDM_kLimMag9);
    239     fLimMag->CheckEntry(IDM_kLimMag8);
     244    fLimMag->CheckEntry(IDM_kLimMag9);
    240245    fLimMag->Associate(this);
    241246    fList->Add(fLimMag);
    242247
    243     fSao->SetLimitMag(7.0);
     248    fSao->SetLimitMag(9.0);
    244249
    245250    fInterpol = new MGPopupMenu(p);
     
    305310    fMenu->AddPopup("&WritePics",  fWritePictures,   NULL);
    306311    fMenu->AddPopup("&Setup",      fSetup,           NULL);
    307 
    308312    fMenu->AddPopup("&Operations", fOperations,      NULL);
    309313
     
    327331
    328332    fGStarg = new MGStarg(this, 235);
     333    fGStarg->DrawText("0.75'", "1.50'", "3.00'", "Misspointing [min]");
     334    fGStarg->DrawHexagon();
    329335    fGStarg->Move(530,596+5);
    330336    fList->Add(fGStarg);
     
    335341    fList->Add(fCRaDec);
    336342
    337     fCZdAz = new MGCoordinates(this, kETypeZdAz, kFALSE);
    338     fCZdAz->Move(240+12+28, fMenu->GetDefaultHeight()+581+20-4);
     343    fCZdAz = new MGCoordinates(this, kETypeZdAz, 2);
     344    fCZdAz->Move(240+12+28, fMenu->GetDefaultHeight()+597);
    339345    AddFrame(fCZdAz);
    340346    fList->Add(fCZdAz);
    341347
    342     fPZdAz = new MGCoordinates(this, kETypeZdAz, kFALSE);
    343     fPZdAz->Move(240+12+28, fMenu->GetDefaultHeight()+627+2*20-4);
     348    fPZdAz = new MGCoordinates(this, kETypeZdAz, 2);
     349    fPZdAz->Move(240+12+28, fMenu->GetDefaultHeight()+640);
    344350    AddFrame(fPZdAz);
    345351    fList->Add(fPZdAz);
    346352
    347     fDZdAz = new MGCoordinates(this, kETypeZdAz, kFALSE);
    348     fDZdAz->Move(240+12+28, fMenu->GetDefaultHeight()+673+3*20-4);
     353    fDZdAz = new MGCoordinates(this, kETypeZdAz, 2);
     354    fDZdAz->Move(240+12+28, fMenu->GetDefaultHeight()+683);
    349355    AddFrame(fDZdAz);
    350356    fList->Add(fDZdAz);
    351357
    352     fSZdAz = new MGCoordinates(this, kETypeZdAz, kFALSE);
    353     fSZdAz->Move(240+12+28, fMenu->GetDefaultHeight()+719+4*20-4);
     358    fSZdAz = new MGCoordinates(this, kETypeZdAz, 2);
     359    fSZdAz->Move(240+12+28, fMenu->GetDefaultHeight()+795);
    354360    AddFrame(fSZdAz);
    355361    fList->Add(fSZdAz);
    356362
     363    fGNumStars = new MGNumStars(this, 235);
     364    fGNumStars->DrawText("Number of stars");
     365    fGNumStars->Move(278, fMenu->GetDefaultHeight()+713);
     366    fList->Add(fGNumStars);
     367
    357368    fTPoint = new TGTextButton(this, "TPoint");
    358     fTPoint->Move(4, fMenu->GetDefaultHeight()+722+3*15+15);
     369    fTPoint->Move(4, fMenu->GetDefaultHeight()+785);
    359370    fTPoint->AllowStayDown(kTRUE);
    360371    AddFrame(fTPoint);
     
    362373
    363374    fStargTPoint = new TGTextButton(this, "StargTPoint");
    364     fStargTPoint->Move(240+12+28, fMenu->GetDefaultHeight()+785);
     375    fStargTPoint->Move(170, fMenu->GetDefaultHeight()+785);
    365376    fStargTPoint->AllowStayDown(kTRUE);
    366377    AddFrame(fStargTPoint);
     
    369380    fFps = new TGLabel(this, "---fps");
    370381    fFps->SetTextJustify(kTextRight);
    371     fFps->Move(650-495, fMenu->GetDefaultHeight()+619+13+60+20+2);
     382    fFps->Move(650-495, fMenu->GetDefaultHeight()+714+23);
    372383    AddFrame(fFps);
    373384    fList->Add(fFps);
     
    385396    fList->Add(fSkyBright);
    386397
    387     TGLabel *l = new TGLabel(this, "arcsec/pix");
     398    TGLabel *l = new TGLabel(this, "deg");
    388399    l->SetTextJustify(kTextLeft);
    389     l->Move(606-412, fMenu->GetDefaultHeight()+619+13+60);
     400    l->Move(606-412, fMenu->GetDefaultHeight()+669);
    390401    AddFrame(l);
    391402    fList->Add(l);
    392403
    393     l = new TGLabel(this, "deg");
     404    l = new TGLabel(this, "arcsec/pix");
    394405    l->SetTextJustify(kTextLeft);
    395     l->Move(606-412, fMenu->GetDefaultHeight()+619-10+60);
     406    l->Move(606-412, fMenu->GetDefaultHeight()+692);
    396407    AddFrame(l);
    397408    fList->Add(l);
    398409
    399     l = new TGLabel(this, "Telescope pointing at");
     410    l = new TGLabel(this, "sigma");
     411    l->SetTextJustify(kTextLeft);
     412    l->Move(606-412, fMenu->GetDefaultHeight()+715);
     413    AddFrame(l);
     414    fList->Add(l);
     415
     416    l = new TGLabel(this, "Zd/Az telescope pointing at");
    400417    l->SetTextJustify(kTextLeft);
    401418    l->Move(240+12+20+7, fMenu->GetDefaultHeight()+584-5);
     
    403420    fList->Add(l);
    404421
    405     l = new TGLabel(this, "Starguider position");
     422    l = new TGLabel(this, "Zd/Az starguider pointing at");
    406423    l->SetTextJustify(kTextLeft);
    407     l->Move(240+12+20+7, fMenu->GetDefaultHeight()+630+20-5);
     424    l->Move(240+12+20+7, fMenu->GetDefaultHeight()+630+20-5-23);
    408425    AddFrame(l);
    409426    fList->Add(l);
    410427
    411     l = new TGLabel(this, "Misspointing");
     428    l = new TGLabel(this, "Zd/Az misspointing");
    412429    l->SetTextJustify(kTextLeft);
    413     l->Move(240+12+20+7, fMenu->GetDefaultHeight()+676+2*20-5);
     430    l->Move(240+12+20+7, fMenu->GetDefaultHeight()+676+2*20-5-46);
    414431    AddFrame(l);
    415432    fList->Add(l);
     
    422439    fList->Add(l);
    423440#endif
     441
     442    // Set input box for rotation angle
     443    const Double_t angle = -0.4;
     444    fSao->SetRotationAngle(angle);
    424445   
     446    TString txt;
     447    txt += angle;
     448
     449    fAngle = new TGTextEntry(this, txt, IDM_kAngle);
     450    fAngle->SetAlignment(kTextCenterX);
     451    fAngle->Move(547-410, fMenu->GetDefaultHeight()+667);
     452    AddFrame(fAngle);
     453    fList->Add(fAngle);
     454
     455    // Set input box for pixel size
    425456    const Double_t pixsize = 48.8; // used to be 23.4
    426457
     
    428459    fSao->SetRotationAngle(0);
    429460
    430     TString txt;
     461    txt = "";
    431462    txt += pixsize;
    432463
    433464    fPixSize = new TGTextEntry(this, txt, IDM_kPixSize);
    434465    fPixSize->SetAlignment(kTextCenterX);
    435     fPixSize->Move(547-410, fMenu->GetDefaultHeight()+617+13+60);
     466    fPixSize->Move(547-410, fMenu->GetDefaultHeight()+690);
    436467    AddFrame(fPixSize);
    437468    fList->Add(fPixSize);
    438469
    439     const Double_t angle = -0.4;
    440     fSao->SetRotationAngle(angle);
     470    // Set input box for cleaning cut
     471    const Double_t cut = 3.0;
    441472
    442473    txt = "";
    443     txt += angle;
    444 
    445     fAngle = new TGTextEntry(this, txt, IDM_kAngle);
    446     fAngle->SetAlignment(kTextCenterX);
    447     fAngle->Move(547-410, fMenu->GetDefaultHeight()+617-10+60);
    448     AddFrame(fAngle);
    449     fList->Add(fAngle);
     474    txt += cut;
     475
     476    fCut = new TGTextEntry(this, txt, IDM_kCut);
     477    fCut->SetAlignment(kTextCenterX);
     478    fCut->Move(547-410, fMenu->GetDefaultHeight()+713);
     479    AddFrame(fCut);
     480    fList->Add(fCut);
    450481
    451482    // TGHorizontal3DLine *fLineSep = new TGHorizontal3DLine(this);
     
    467498    fList->Add(fImage);
    468499
     500    const Int_t w = 768;
     501    const Int_t h = 840;
     502    SetWMSizeHints(w, h, w, h, 1, 1);  // set the smallest and biggest size of the Main frame
     503
    469504    //
    470505    // Make everything visible
     
    477512    fStargTPoint->UnmapWindow();
    478513    fGStarg->UnmapWindow();
     514    fGNumStars->UnmapWindow();
    479515    fPZdAz->UnmapWindow();
    480516    fDZdAz->UnmapWindow();
     
    503539      fStatus(MDriveCom::kStandby)
    504540{
    505    
    506541    cout << " #### FIXME: Make MCaos Thread safe!" << endl;
     542
     543    fAmcSocket = new TSocket("amc", 7307);
    507544
    508545    fSao = new StarCatalog(obs);
     
    573610        delete fOutRq;
    574611
     612    delete fAmcSocket;
     613
    575614    cout << "Camera Display destroyed." << endl;
     615}
     616
     617bool MStarguider::SendAmcTrigger(const char *msg)
     618{
     619    if (!fAmcSocket->IsValid())
     620        return false;
     621
     622    TString txt("TRIGGER ");
     623    txt += msg;
     624
     625    const Int_t len = fAmcSocket->SendRaw(txt.Data(), txt.Length());
     626    if (len<0)
     627    {
     628        cout << "ERROR - Sending Trigger to Amc" << endl;
     629        return false;
     630    }
     631    if (len!=txt.Length())
     632    {
     633        cout << "Send wrong number (" << len << ") of Bytes to Amc." << endl;
     634        return false;
     635    }
     636
     637    return true;
    576638}
    577639
     
    648710        fDisplay->CheckEntry(IDM_kCatalog);
    649711        fGStarg->MapWindow();
     712        fGNumStars->MapWindow();
    650713
    651714        const Int_t ch0 =
     
    682745        fSkyBright->UnmapWindow();
    683746        fGStarg->UnmapWindow();
     747        fGNumStars->UnmapWindow();
    684748
    685749        fChannel->EnableEntry(IDM_kChannel2);
     
    730794    fStargTPoint->UnmapWindow();
    731795    fGStarg->UnmapWindow();
     796    fGNumStars->UnmapWindow();
    732797    fPZdAz->UnmapWindow();
    733798    fDZdAz->UnmapWindow();
     
    757822                    cout << "Rotation Angle changed to " << angle << "deg" << endl;
    758823                    fSao->SetRotationAngle(angle);
     824                    return kTRUE;
     825                }
     826            case IDM_kCut:
     827                {
     828                    const Float_t cut = atof(fCut->GetText());
     829                    cout << "Starguider cleaning level changed to " << cut << " sigma." << endl;
    759830                    return kTRUE;
    760831                }
     
    12921363                                     ZdAz &d, MTime &t, double &bright, Int_t &num)
    12931364{
    1294     const Int_t max = leds.GetEntries();
     1365    num = leds.GetEntries();
     1366    if (num < 3) //was 1
     1367    {
     1368        cout << "Sorry, less than 3 detected spot in FOV!" << endl;
     1369        if (fStargTPoint->IsDown())
     1370            fStargTPoint->SetDown(kFALSE);
     1371        return 0;
     1372    }
     1373
    12951374    if (stars.GetRealEntries() < 3)
    12961375    {
     
    13001379        return 0;
    13011380    }
    1302     if (max < 3) //was 1
    1303     {
    1304         cout << "Sorry, less than 3 detected spot in FOV!" << endl;
    1305         if (fStargTPoint->IsDown())
    1306             fStargTPoint->SetDown(kFALSE);
    1307         return 0;
    1308     }
    13091381
    13101382    stars.Sort(); // Sort by magnitude
     
    13201392    TArrayF x, y, mag;
    13211393
    1322     num = 0;
    1323 
    13241394    // FIXME: Is predefined value 3 a good idea?
    13251395
    13261396    MStar *star;
    13271397    MStarListIter NextStar(&stars);
    1328     while ((star=NextStar()) && num++<max+3)
     1398    while ((star=NextStar()))
    13291399    {
    13301400        TIter NextSp(&leds);
     
    14411511    *fOutStargTp << " " << d.Zd() << " " << d.Az();
    14421512    *fOutStargTp << " " << setprecision(11) << t.GetMjd();
    1443     *fOutStargTp << " " << max;
     1513    *fOutStargTp << " " << num;
    14441514    *fOutStargTp << " " << bright;
    14451515    *fOutStargTp << endl;
     
    15361606#endif
    15371607
    1538     // Convert from Pixel to millimeter (1pix=2.9mm)
     1608    // MAKE SURE THAT THIS VALUE CAN BE SETUP
     1609    // (Scalefactor describes the difference between the tpoint (=1)
     1610    //  and the starguider (!=1) camera
     1611    // Convert from Pixel to millimeter (1pix=2.6mm)
    15391612    x *= (2.58427 * scalefactor);
    15401613    y *= (2.58427 * scalefactor);
     
    15441617    y /= 1.0713;
    15451618
    1546     // Calculate Offset
     1619    // Convert offset from camera plane into local ccordinates
    15471620    Double_t dzd, daz;
    15481621    ac.GetDiffZdAz(x, y, dzd, daz);
     
    17191792    // Find Star at Center---for Tpoint Procedure
    17201793    if (fDisplay->IsEntryChecked(IDM_kFindStar))
     1794    {
     1795        // SCALE FACTOR ASSUMED TO BE 70
    17211796        FindStar(f, f2, center, t, 3.5, 70);
     1797        SendAmcTrigger("TPoint");
     1798    }
    17221799
    17231800    byte zimg[kZOOM*kZOOM];
     
    17511828            pos = fCosy->GetPointingPos();
    17521829
    1753         sgcenter = fStargCaos->Run(img, kFALSE, kFALSE, pos, t, 30, 3.0); // [px]
     1830        sgcenter = fStargCaos->Run(img, kFALSE, kFALSE, pos, t, 19, 3.0); // [px]
    17541831
    17551832        //const Float_t pixsize = atof(fPixSize->GetText()); // [arcsec/px]
     
    17751852#endif
    17761853            fSZdAz->SetCoordinates(star); // Misspointing found from Camera
     1854
     1855            SendAmcTrigger("Starguider");
    17771856        }
    17781857    }
     
    18911970
    18921971        // Next we evaluate the offset given by the LEDs. This we obtain
    1893         // in Zd/Az and add it to the tracking error.
     1972        // in Zd/Az and add it to the tracking error.
    18941973        if (fDisplay->IsEntryChecked(IDM_kStarguider))
    18951974        {
     1975            const Float_t cut = atof(fCut->GetText());
     1976
    18961977            Leds spots;
    18971978            f.SetBox(230);
    1898             f.SetCut(2.5);
     1979            f.SetCut(cut);
    18991980
    19001981            double bright;
    19011982            f.ExecuteAndMark(spots, 530, 292, bright);
    19021983
    1903             MString txt;
    1904             txt.Print("Sky Brightness: %.1f", bright);
    1905             fSkyBright->SetText(txt);
    1906 
    1907             const Bool_t brightnessisvalid = bright<1.75*fLastBright &&
    1908                 bright>30 && bright<110;
    1909 
    1910             fLastBright = bright;
    1911 
    19121984            ULong_t color;
    1913             gClient->GetColorByName("Green", color);   
     1985            gClient->GetColorByName("Green", color);
    19141986            if (bright> 60)
    19151987                gClient->GetColorByName("Yellow", color);
     
    19201992            fSkyBright->SetBackgroundColor(color);
    19211993
     1994            MString txt;
     1995            txt.Print("Sky Brightness: %.1f", bright);
     1996            fSkyBright->SetText(txt);
     1997
     1998            const Bool_t brightnessisvalid = bright<1.75*fLastBright &&
     1999                bright>30 && bright<110;
     2000
     2001            fLastBright = bright;
     2002
    19222003            Int_t numstars = 0;
    19232004            const Int_t rc = CalcTrackingError(spots, stars, fD, t, bright, numstars);
     
    19342015                                       fSao->GetZdAz(), sgcenter, /*sgcenterzdaz,*/
    19352016                                       star, bright, fPos, t);
     2017
     2018            fNumStarsDetected   = numstars;
     2019            fNumStarsCorrelated = rc;
    19362020
    19372021            if (fCosy)
     
    19452029        } //kStarguider
    19462030
    1947         if (centerisvalid)
     2031        if (centerisvalid && fNumStarsCorrelated>2)
    19482032        {
    1949             f2.DrawCircle(skycenter, 2.0, 0x0a);
    1950 
    1951             f2.DrawCircle(skycenter, 7.4, 0x0a); //0.1deg
    1952 
    1953             f2.DrawCircle(skycenter, 2.06*.5*74.0, 0x0a);
    1954             f2.DrawCircle(skycenter, 2.32*.5*74.0, 0x0a);
    1955             f2.DrawCircle(skycenter, 3.50*.5*74.0, 0x0a);
    1956             f2.DrawCircle(skycenter, 3.84*.5*74.0, 0x0a);
     2033            f2.DrawCircle(skycenter,   2.0,     0x0a);
     2034
     2035            const Double_t ap = fSao->GetPixSize()/3600; //[deg/pix]
     2036
     2037            f2.DrawCircle(skycenter,  0.10/ap, 0x0a); //0.1deg
     2038            f2.DrawHexagon(skycenter, 2.06/ap, 0x0a);
     2039            f2.DrawHexagon(skycenter, 3.50/ap, 0x0a);
     2040
     2041            /*
     2042             f2.DrawCircle(skycenter, 2.06*.5*74.0, 0x0a);
     2043             f2.DrawCircle(skycenter, 2.32*.5*74.0, 0x0a);
     2044             f2.DrawCircle(skycenter, 3.50*.5*74.0, 0x0a);
     2045             f2.DrawCircle(skycenter, 3.84*.5*74.0, 0x0a);
     2046             */
    19572047        }
    19582048
  • trunk/MagicSoft/Cosy/main/MStarguider.h

    r7785 r7790  
    2020class TGButton;
    2121class TString;
     22class TSocket;
    2223
    2324class TTimer;
     
    3839// class MStargLeds;
    3940class MStargHistograms;
     41class MGNumStars;
    4042class MGStarg;
    4143class FilterLed;
     
    5658
    5759    MGStarg       *fGStarg;
     60    MGNumStars    *fGNumStars;
    5861
    5962    MGPopupMenu   *fDisplay;
     
    8487    TGTextEntry   *fPixSize;
    8588    TGTextEntry   *fAngle;
     89    TGTextEntry   *fCut;
    8690
    8791    TGLabel       *fFps;
     
    9599    ZdAz          fD;
    96100    AltAz         fAltAzOffsetFromTp;
    97    
     101
     102    Double_t fNumStarsDetected;
     103    Double_t fNumStarsCorrelated;
     104
    98105    StarCatalog   *fSao;
    99106    MCosy         *fCosy;
    100107    MCaos         *fCaos;
    101108    MCaos         *fStargCaos;
    102     //    MStargLeds    *fStargLeds;
     109    TSocket       *fAmcSocket;
    103110    MStargHistograms *fStargHistograms;
    104111   
     
    145152    void InitGui(Int_t channel);
    146153
     154    bool SendAmcTrigger(const char *msg);
     155
    147156    //void OpenFile();
    148157
  • trunk/MagicSoft/Cosy/tcpip/MTcpIpIO.cc

    r4865 r7790  
    9191        return false;
    9292
    93     const UInt_t len = fTxSocket->SendRaw(msg, strlen(msg));
     93    const Int_t len = fTxSocket->SendRaw(msg, strlen(msg));
    9494    if (len<0)
    9595    {
     
    9797        return false;
    9898    }
    99     if (len!=strlen(msg))
     99    if (len!=(Int_t)strlen(msg))
    100100    {
    101101        cout << "Send wrong number (" << len << ") of Bytes." << endl;
  • trunk/MagicSoft/Cosy/videodev/FilterLed.cc

    r7788 r7790  
    4545}
    4646
     47void FilterLed::DrawHexagon(float cx, float cy, float r, byte col) const
     48{
     49    MGMap::DrawHexagon(fImg, 768, 576, cx, cy, r, col);
     50}
     51
    4752void FilterLed::DrawCircle(const Ring &l, byte col) const
    4853{
     
    5358{
    5459    DrawCircle(l.GetX(), l.GetY(), r, col);
     60}
     61
     62void FilterLed::DrawHexagon(const Ring &l, double r, byte col) const
     63{
     64    DrawHexagon(l.GetX(), l.GetY(), r, col);
    5565}
    5666
     
    121131}
    122132
    123 int FilterLed::GetMeanPositionCircle(const int x, const int y,
    124                                      const int box, float &mx,
    125                                      float &my, unsigned int &sum) const
     133int FilterLed::GetMeanPositionBox(const int x, const int y,
     134                                  const int box, float &mx,
     135                                  float &my, unsigned int &sum) const
    126136{
    127137    //-------------------------------
     
    188198}
    189199
    190 int FilterLed::GetMeanPositionCircle(const int x, const int y,
    191                                      const int box) const
     200int FilterLed::GetMeanPositionBox(const int x, const int y,
     201                                  const int box) const
    192202{
    193203    float mx, my;
    194204    unsigned int sum;
    195     return GetMeanPositionCircle(x, y, box, mx, my, sum);
     205    return GetMeanPositionBox(x, y, box, mx, my, sum);
    196206}
    197207
     
    334344}
    335345
     346class ClusterFinder
     347{
     348private:
     349    byte *fImg;
     350
     351    UInt_t fW;
     352    UInt_t fH;
     353
     354    Int_t fX0;
     355    Int_t fX1;
     356
     357    Int_t fY0;
     358    Int_t fY1;
     359
     360    UInt_t fCount;
     361    Float_t fSumX;
     362    Float_t fSumY;
     363
     364    Float_t FindCluster(Int_t x, Int_t y)
     365    {
     366        // if edge is touched stop finding cluster
     367        if (x<fX0 || x>=fX1 || y<fY0 || y>=fY1)
     368            return -1;
     369
     370        if (fCount>999)
     371            return -1;
     372
     373        // get the value
     374        Float_t val = fImg[y*fW+x];
     375
     376        // if its empty we have found the border of the cluster
     377        if (val==0)
     378            return 0;
     379
     380        // mark the point as processed
     381        fImg[y*fW+x] = 0;
     382
     383        fSumX += x*val; // sumx
     384        fSumY += y*val; // sumy
     385        fCount++;
     386
     387        Float_t rc[4];
     388        rc[0] = FindCluster(x+1, y  );
     389        rc[1] = FindCluster(x,   y+1);
     390        rc[2] = FindCluster(x-1, y  );
     391        rc[3] = FindCluster(x,   y-1);
     392
     393        for (int i=0; i<4; i++)
     394        {
     395            if (rc[i]<0) // check if edge is touched
     396                return -1;
     397
     398            val += rc[i];
     399        }
     400
     401        return val;
     402    }
     403public:
     404    ClusterFinder(byte *img, UInt_t w, UInt_t h)
     405    {
     406        fW = w;
     407        fH = h;
     408
     409        fImg = new byte[fW*fH];
     410
     411        memcpy(fImg, img, fW*fH);
     412    }
     413
     414    ~ClusterFinder()
     415    {
     416        delete fImg;
     417    }
     418    void FindCluster(Leds &leds, Int_t x0=0, Int_t y0=0, Int_t x1=0, Int_t y1=0)
     419    {
     420        fX0 = x0;
     421        fY0 = y0;
     422        fX1 = x1==0?fW:x1;
     423        fY1 = y1==0?fH:y1;
     424
     425        for (Int_t x=fX0; x<fX1; x++)
     426            for (Int_t y=fY0; y<fY1; y++)
     427            {
     428                const byte &b = fImg[y*fW+x];
     429                if (b==0)
     430                    continue;
     431
     432                fCount = 0;
     433                fSumX  = 0;
     434                fSumY  = 0;
     435
     436                const Float_t mag = FindCluster(x, y);
     437                if (fCount>999)
     438                {
     439                    cout << "ERROR - Spot with Size>999 detected..." << endl;
     440                    return;
     441                }
     442
     443                if (mag>0 && fCount>6)
     444                {
     445                    Float_t M = mag/0xff;
     446                    if (M>0xf0)
     447                        M=0xf0;
     448
     449                    leds.Add(fSumX/mag, fSumY/mag, 0, 0, 0xf0);
     450                }
     451            }
     452        leds.Compress();
     453    }
     454};
    336455
    337456void FilterLed::Execute(Leds &leds, int xc, int yc, double &bright) const
     
    353472            byte &b = fImg[y*fW+x];
    354473
     474            // Skip saturating pixels
     475            if (b>0xf0)
     476                continue;
     477
     478            sum += b;
     479            sq  += b*b;
     480        }
     481
     482    sum /= wx*hy;
     483    sq  /= wx*hy;
     484
     485    bright=sum;
     486
     487   
     488    // 254 because b<=max and not b<max
     489    const double sdev = TMath::Sqrt(sq-sum*sum);
     490    const byte   max  = sum+fCut*sdev>254 ? 254 : (byte)(sum+fCut*sdev);
     491
     492    //
     493    // clean image from noise
     494    // (FIXME: A lookup table could accelerate things...
     495    //
     496    for (int x=x0; x<x1; x++)
     497        for (int y=y0; y<y1; y++)
     498        {
     499            byte &b = fImg[y*fW+x];
     500            if (b<=max)
     501                b = 0;
     502        }
     503
     504    ClusterFinder find(fImg, fW, fH);
     505    find.FindCluster(leds, x0, y0, x1, y1);
     506}
     507
     508/*
     509void FilterLed::Execute(Leds &leds, int xc, int yc, double &bright) const
     510{
     511    const int x0 = TMath::Max(xc-fBox, 0);
     512    const int y0 = TMath::Max(yc-fBox, 0);
     513    const int x1 = TMath::Min(xc+fBox, fW);
     514    const int y1 = TMath::Min(yc+fBox, fH);
     515
     516    const int wx = x1-x0;
     517    const int hy = y1-y0;
     518
     519    double sum = 0;
     520    double sq  = 0;
     521
     522    for (int x=x0; x<x1; x++)
     523        for (int y=y0; y<y1; y++)
     524        {
     525            byte &b = fImg[y*fW+x];
     526
    355527            sum += b;
    356528            sq  += b*b;
     
    387559    byte mag[maxpnt]; // (Use 'new' instead for big numbers!)
    388560
     561    const int r = 5;
     562
    389563    int cnt = 0;
    390     for (int x=x0; x<x1; x++)
    391         for (int y=y0; y<y1; y++)
     564    for (int x=x0+r; x<x1-r; x++)
     565        for (int y=y0+r; y<y1-r; y++)
    392566        {
    393567            byte &b = fImg[y*fW+x];
     
    395569                continue;
    396570
    397             const int ipos = GetMeanPosition(x, y, 5);
     571            const int ipos = GetMeanPosition(x, y, r);
    398572
    399573            int j;
     
    402576                if (pos[j]==ipos)
    403577                {
    404                     if (mag[j] < 0xf0)
    405                         mag[j] += 0x10;
     578                    if (mag[j]<0xff)
     579                        mag[j]++;  // how often found (area)
    406580                    break;
    407581                }
     
    411585
    412586            pos[cnt] = ipos;
    413             mag[cnt] = 0x10;
     587            mag[cnt] = 1;
    414588
    415589            cnt++;
     
    428602    for (int i=0; i<cnt; i++)
    429603    {
    430         if (mag[i]<=0x80) // 0xa0
     604        if (mag[i]<=7)
    431605            continue;
    432606
    433607        Float_t mx, my;
    434608        unsigned int sum;
    435         GetMeanPosition(pos[i]%fW, pos[i]/fW, 5, mx, my, sum);
    436 
    437         leds.Add(mx, my, 0, 0, mag[i]);
    438     }
    439 
    440     RemoveTwinsInterpol(leds, first, 5);
    441 }
    442 
    443 void FilterLed::FindStar(Leds &leds, int xc, int yc, bool circle) const
     609        GetMeanPosition(pos[i]%fW, pos[i]/fW, r, mx, my, sum);
     610
     611        leds.Add(mx, my, 0, 0, 0);//mag[i]*10);
     612    }
     613
     614    RemoveTwinsInterpol(leds, first, r);
     615}
     616*/
     617void FilterLed::FindStar(Leds &leds, int xc, int yc, bool box) const
    444618{
    445619    // fBox: radius of the inner (signal) box
     
    535709    float mx, my;
    536710    unsigned int mag;
    537     int pos = circle ? GetMeanPositionCircle(xc, yc, fBox-1, mx, my, mag) : GetMeanPosition(xc, yc, fBox-1, mx, my, mag);
     711    int pos = box ? GetMeanPositionBox(xc, yc, fBox-1, mx, my, mag) : GetMeanPosition(xc, yc, fBox-1, mx, my, mag);
    538712
    539713    if (pos<0 || pos>=fW*fH || fImg[pos]<sum+fCut*sdev)
  • trunk/MagicSoft/Cosy/videodev/FilterLed.h

    r7788 r7790  
    2020    float fCut;
    2121
     22    Float_t FindCluster(int &cnt, float *sum, UInt_t x, UInt_t y,
     23                        UInt_t x0, UInt_t y0, UInt_t x1, UInt_t y1) const;
     24
    2225    void GetMinMax(const int offset, byte *min, byte *max) const;
    2326    int  GetMeanPosition(const int x, const int y, const int box) const;
     
    2528                         float &mx, float &my, unsigned int &sum) const;
    2629
    27     int  GetMeanPositionCircle(const int x, const int y,
    28                                const int box) const;
    29     int  GetMeanPositionCircle(const int x, const int y,
    30                                const int box, float &mx, float &my,
    31                                unsigned int &sum) const;
     30    int  GetMeanPositionBox(const int x, const int y,
     31                            const int box) const;
     32    int  GetMeanPositionBox(const int x, const int y,
     33                            const int box, float &mx, float &my,
     34                            unsigned int &sum) const;
    3235
    3336    void RemoveTwinsInterpol(Leds &leds, Int_t first, Double_t radius) const;
     
    6669    void DrawCircle(const Ring &c, byte col=0x40) const;
    6770    void DrawCircle(const Ring &c, double r, byte col) const;
     71    void DrawHexagon(float cx, float cy, float r, byte col=0x40) const;
     72    void DrawHexagon(const Ring &c, double r, byte col) const;
    6873
    6974    ClassDef(FilterLed, 0)
Note: See TracChangeset for help on using the changeset viewer.