Changeset 8869 for trunk/MagicSoft/Cosy


Ignore:
Timestamp:
02/21/08 22:03:06 (17 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Cosy
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Cosy/Changelog

    r8865 r8869  
    11                                                                  -*-*- END -*-*-
     2
     3 2008/02/21 Thomas Bretz (La Palma)
     4
     5   * cosy.cc:
     6     - moved instantisation of MDriveCom out of MCosy
     7     - adde options to set the ceco ports
     8
     9   * candrv/canopen.cc:
     10     - changed logging output
     11
     12   * devdrv/macs.cc:
     13     - added some more DKC errors
     14     - SetZombie if not armed
     15     - added some debug output
     16
     17   * devdrv/shaftencoder.cc:
     18     - added some initialisations as suggested by valgrind
     19
     20   * main/MSlewing.h:
     21     - removed obsolete base class MLog
     22
     23   * main/MTracking.[h,cc]:
     24     - replaced some fixed numbers by variables
     25     - added forward declaration for MLog
     26
     27   * tcpip/MCeCoCom.[h,cc]:
     28     - moved fixed port numbers out of the constructor
     29
     30   * tcpip/MDriveCom.[h,cc]:
     31     - secured called to fQueue with if-conditions
     32     - added Dummy for TPOIN command
     33     - implemented ARM command
     34     - added arm status to drive report
     35     - added summy for sending TPOINT-REPORT
     36
     37   * tcpip/MTcpIpIO.cc:
     38     - added time to connection messages
     39     - added 0 as backlog for opening the TServerSocket.
     40       This seems to be necessary (why?)
     41
     42   * videodev/Camera.cc:
     43     - added initialisation of fChannel which was missing
     44
     45   * videodev/FilterLed.cc:
     46     - changed a detele to an array delete as suggested by valgrind
     47
     48   * videodev/MVideo.cc:
     49     - initialize qctrl as suggested by valgrind
     50
     51
    252
    353 2008/02/20 Thomas Bretz (La Palma)
  • trunk/MagicSoft/Cosy/candrv/canopen.cc

    r8864 r8869  
    276276    if (ms && t.HasTimedOut())
    277277    {
    278         cout << "WaitForSdos timed out." << endl;
     278        gLog << inf << "- CanOpen::WaitForSdos timed out." << endl;
    279279        rc = false;
    280280    }
     
    312312    if (ms && t.HasTimedOut())
    313313    {
    314         cout << "WaitForSdo Node #" << (int)node << " " << idx << "/" << (int)subidx << " timed out." << endl;
     314        //cout << "WaitForSdo Node #" << (int)node << " " << idx << "/" << (int)subidx << " timed out." << endl;
    315315        rc = false;
    316316    }
  • trunk/MagicSoft/Cosy/cosy.cc

    r8864 r8869  
    1414#include "MCosy.h"
    1515#include "MTime.h"
     16#include "MDriveCom.h"
    1617
    1718#include "MLogManip.h"
     
    9293    const TString sps           = arg.GetStringAndRemove("--sps=", "sps");
    9394    const TString ceco          = arg.GetStringAndRemove("--cc=", "ceco"); // ceco
     95    const Int_t   ceco_tx       = arg.GetIntAndRemove("--cc-tx=", 7314);//7304);
     96    const Int_t   ceco_rx       = arg.GetIntAndRemove("--cc-rx=", 7414);//7404);
    9497    const TString pointing      = arg.GetStringAndRemove("--pointing-model=", "bending2.txt"); // ceco
    9598    const TString kConfig       = arg.GetStringAndRemove("--config=", ".cosyrc"); // ceco
     
    191194            break;
    192195        }
    193 */
    194     MCosy *cosy = new MCosy(env, ceco, pointing);
     196        */
     197
     198    MDriveCom com(ceco, ceco_tx, ceco_rx);
     199
     200    MCosy *cosy = new MCosy(env, &com, pointing);
     201
     202    com.SetMsgQueue(cosy);
    195203
    196204    Interface *interface = new Ethernet(sps, 5357, 5358, cosy);
     
    211219        gLog << all << "- Starting Camera." << endl;
    212220        client=new MStarguider(MObservatory::kMagic1, channel);
     221        //client.SetDriveCom(&com);
    213222        cosy->SetStarguider(client);
    214223        client->SetCosy(cosy);
     
    239248    gLog << all << "Deleting cosy at " << MTime(-1) << endl;
    240249
     250    //com.SetMsgQueue(NULL);
     251
    241252    delete cosy;
    242253
  • trunk/MagicSoft/Cosy/devdrv/macs.cc

    r8866 r8869  
    8585    case 0xc500: return "Error reset";
    8686    case 0xe225: return "Motor overload";
     87    case 0xe249: return "Positioning command velocity exceeds limit bipolar";
    8788    case 0xe250: return "Drive overtemp warning";
    8889    case 0xe251: return "Motor overtemp warning";
     
    108109    case 0xf630: return "Negative sw end-switch";
    109110    case 0xf634: return "Emergency-Stop";
    110     case 0xf643: return "Positive hw end-switch";
    111     case 0xf644: return "Negative hw end-switch";
    112     case 0xf870: return "24V DC error.";
     111    case 0xf643: return "Positive hardware end-switch activated";
     112    case 0xf644: return "Negative hardware end-switch activated";
     113    case 0xf870: return "24V DC error";
    113114    case 0xf878: return "Velocity loop error";
    114115    }
     
    514515
    515516    // REMOVE THIS AND LET CC START THE NODE
    516     //StartNode();
     517    StartNode();
    517518
    518519    gLog << inf2 << "- " << GetNodeName() << ": Checking armed status." << endl;
     
    638639    {
    639640        gLog << err << GetNodeName() << ": ERROR - Moving without being armed is not allowed." << endl;
    640         return;
    641     }
    642 
    643     gLog << dbg << GetNodeName() << ": Starting abolsute positioning to " << (LWORD_t)pos << " ticks." << endl;
     641        SetZombie();
     642        return;
     643    }
     644
     645    gLog << dbg << GetNodeName() << ": Starting abolsute positioning to " << (LWORDS_t)pos << " ticks." << endl;
    644646    SendSDO(0x6004, 1, (LWORD_t)pos);
    645647    fPosActive = kTRUE; // Make sure that the status is set correctly already before the first PDO
     
    651653    {
    652654        gLog << err << GetNodeName() << ": ERROR - Moving without being armed is not allowed." << endl;
    653         return;
    654     }
    655 
    656     gLog << dbg << GetNodeName() << ": Starting relative positioning by " << (LWORD_t)pos << " ticks." << endl;
     655        SetZombie();
     656        return;
     657    }
     658
     659    gLog << dbg << GetNodeName() << ": Starting relative positioning by " << (LWORDS_t)pos << " ticks." << endl;
    657660    SendSDO(0x6004, 0, (LWORD_t)pos);
    658661    fPosActive = kTRUE; // Make sure that the status is set correctly already before the first PDO
  • trunk/MagicSoft/Cosy/devdrv/shaftencoder.cc

    r8863 r8869  
    1515ShaftEncoder::ShaftEncoder(const BYTE_t nodeid, const char *name)
    1616    : NodeDrv(nodeid, name),
    17     fPos(0), fVel(0), fAcc(0), fTurn(0), fTicks(0),
     17    fPos(0), fVel(0), fAcc(0), fTurn(0), fTicks(0), fTurns(0),
    1818    fDirection(kUndefined), fHysteresisPos(0), fHysteresisNeg(0),
    1919    fLabel(NULL), fUpdPos(0),
    2020    fPosHasChanged(false), fDirHasChanged(false),
    21     fReport(NULL), fMotor(0), fOffset(0), fDirChangedPos(0)
     21    fReport(NULL), fMotor(NULL),
     22    fOffset(0), fDirChangedPos(0), fDirChangedOffset(0)
    2223{
    2324}
  • trunk/MagicSoft/Cosy/main/MSlewing.h

    r8815 r8869  
    22#define COSY_MSlewing
    33
    4 #ifndef MARS_MLog
    5 #include "MLog.h"
     4#ifndef ROOT_TROOT
     5#include <TROOT.h>
    66#endif
    77
     
    1010class ZdAz;
    1111
    12 class MSlewing : public MLog
     12class MSlewing
    1313{
    1414protected:
  • trunk/MagicSoft/Cosy/main/MTracking.cc

    r8825 r8869  
    269269     const Int_t paz  = fCosy->fAz->GetPos();
    270270
     271     const Int_t res1 = fCosy->fZd1->GetPhysRes();
     272     const Int_t res2 = fCosy->fZd2->GetPhysRes();
     273
    271274     // Get current shaftencoder position of the telescope
    272      Double_t seposzd1 = ((pzd1+8192)%16384)*re.X();
    273      Double_t seposzd2 = ((pzd2+8192)%16384)*re.X();
    274      Double_t seposaz  =   paz              *re.Y();
     275     Double_t seposzd1 = ((pzd1+res1/2)%res1)*re.X();
     276     Double_t seposzd2 = ((pzd2+res2/2)%res2)*re.X();
     277     //Double_t seposzd1 = pzd1*re.X();
     278     //Double_t seposzd2 = pzd2*re.X();
     279     Double_t seposaz  = paz *re.Y();
    275280
    276281     // distance between (To+dt) and To [re]
  • trunk/MagicSoft/Cosy/main/MTracking.h

    r8847 r8869  
    1010#endif
    1111
     12class MLog;
    1213class RaDec;
    1314class SlaStars;
  • trunk/MagicSoft/Cosy/tcpip/MCeCoCom.h

    r8862 r8869  
    4848
    4949public:
    50     MCeCoCom(const char *addr, MLog *out)
    51         : MTcpIpIO(addr, 7304, 7404), fOut(out), fStatus(0), fComStat(kNoCmdReceived),
     50    MCeCoCom(const char *addr, const int tx=7304, const int rx=7404, MLog *out=NULL)
     51        : MTcpIpIO(addr, tx, rx), fOut(out), fStatus(0), fComStat(kNoCmdReceived),
    5252        fHumidity(0), fTemperature(0), fWindSpeed(0), fSolarRadiation(-1),
    5353        fAlarmCounter(0)
     
    5555    }
    5656    //virtual bool SendMsg(const char *msg, bool force);
     57
     58    void SetOutRep(MLog *out) { fOut = out; }
    5759
    5860    bool SendRep(const char *cmd, const char *str, bool force);
  • trunk/MagicSoft/Cosy/tcpip/MDriveCom.cc

    r8847 r8869  
    6161
    6262    //cout << "MDriveCom - TRACK... start." << endl;
    63     fQueue->PostMsg(WM_TRACK, &rd, sizeof(rd));
     63    if (fQueue)
     64        fQueue->PostMsg(WM_TRACK, &rd, sizeof(rd));
    6465    //cout << "MDriveCom - TRACK... done." << endl;
    6566    return true;
     
    8788
    8889    //cout << "MDriveCom - TRACK... start." << endl;
    89     fQueue->PostMsg(WM_GRB, &rd, sizeof(rd));
     90    if (fQueue)
     91        fQueue->PostMsg(WM_GRB, &rd, sizeof(rd));
    9092    //cout << "MDriveCom - TRACK... done." << endl;
    9193    return true;
     
    112114
    113115    //cout << "MDriveCom - POSITION... start." << endl;
    114     fQueue->PostMsg(WM_POSITION, &za, sizeof(za));
     116    if (fQueue)
     117        fQueue->PostMsg(WM_POSITION, &za, sizeof(za));
    115118    //cout << "MDriveCom - POSITION... done." << endl;
    116119    return true;
     
    136139
    137140    //cout << "MDriveCom - TRACK... start." << endl;
    138     fQueue->PostMsg(WM_PREPS, (void*)str.Data(), str.Length()+1);
     141    if (fQueue)
     142        fQueue->PostMsg(WM_PREPS, (void*)str.Data(), str.Length()+1);
    139143    //cout << "MDriveCom - TRACK... done." << endl;
     144    return true;
     145}
     146
     147bool MDriveCom::CommandTPOINT(TString &str)
     148{
     149    cout << "CC-COMMAND " << MTime(-1) << " TPOIN " << str << endl;
    140150    return true;
    141151}
     
    166176    bool lock = str=="lock";
    167177
    168     fQueue->PostMsg(WM_ARM, &lock, sizeof(lock));
     178    if (fQueue)
     179        fQueue->PostMsg(WM_ARM, &lock, sizeof(lock));
    169180    return true;
    170181}
     
    176187        //cout << "MDriveCom - WAIT... start." << endl;
    177188        cout << "CC-COMMAND " << MTime(-1) << " WAIT" << endl;
    178         fQueue->PostMsg(WM_WAIT);
     189        if (fQueue)
     190            fQueue->PostMsg(WM_WAIT);
    179191        //cout << "MDriveCom - WAIT... done." << endl;
    180192        return true;
     
    185197        //cout << "MDriveCom - STOP!... start." << endl;
    186198        cout << "CC-COMMAND " << MTime(-1) << " STOP!" << endl;
    187         fQueue->PostMsg(WM_STOP);
     199        if (fQueue)
     200            fQueue->PostMsg(WM_STOP);
    188201        //cout << "MDriveCom - STOP!... done." << endl;
    189202        return true;
     
    202215        return CommandPREPS(str);
    203216
     217    if (cmd==(TString)"TPOIN")
     218        return CommandTPOINT(str);
     219
     220    if (cmd==(TString)"ARM")
     221        return CommandARM(str);
     222
    204223    if (cmd.IsNull() && str.IsNull())
    205224    {
     
    223242}
    224243
    225 bool MDriveCom::SendReport(UInt_t stat, RaDec rd, ZdAz so, ZdAz is, ZdAz er)
     244bool MDriveCom::SendReport(UInt_t stat, RaDec rd, ZdAz so, ZdAz is, ZdAz er, Bool_t armed)
    226245{
    227246    // rd [rad]
     
    259278    Print(str, is.Az());
    260279    str += txt.Print("%08.3f ", er.Zd());
    261     str += txt.Print("%08.3f", er.Az());
     280    str += txt.Print("%08.3f ", er.Az());
     281    str += armed ? "1 " : "0 ";
    262282
    263283    return SendRep("DRIVE-REPORT", str, kFALSE);
     
    303323    return SendRep("STARG-REPORT", str, kTRUE);
    304324}
     325
     326bool MDriveCom::SendTPoint(UInt_t stat)
     327{
     328    /*
     329    // miss   [deg]
     330    // nompos [deg]
     331    const MTime t(-1);
     332
     333    miss *= 60;        // [arcmin]
     334
     335    // Set status flag
     336    if (stat&kError)
     337        SetStatus(0);
     338    if (stat&kStandby)
     339        SetStatus(2);
     340    if (stat&kMonitoring)
     341        SetStatus(4);
     342   
     343    MString txt;
     344
     345    TString str;
     346    str += txt.Print("%05.3f ", miss.Zd());       //[arcmin]
     347    str += txt.Print("%05.3f ", miss.Az());       //[arcmin]
     348    Print(str, nompos.Zd());                      //[deg]
     349    Print(str, nompos.Az());                      //[deg]
     350    str += txt.Print("%05.1f ",   center.GetX()); //number
     351    str += txt.Print("%05.1f ",   center.GetY()); //number
     352    str += txt.Print("%04d ",   n);               //number of correleated stars
     353    str += txt.Print("%03.1f ",  bright);
     354    str += txt.Print("%12.6f ", t.GetMjd());      // mjd
     355    str += txt.Print("%.1f ", x);
     356    str += txt.Print("%.1f ", y);
     357    str += txt.Print("%04d ", num);               //number of detected stars
     358    */
     359
     360    return SendRep("TPOINT-REPORT", "", kTRUE);
     361}
  • trunk/MagicSoft/Cosy/tcpip/MDriveCom.h

    r8862 r8869  
    2828    bool CommandPREPS(TString &str);
    2929    bool CommandARM(TString &str);
     30    bool CommandTPOINT(TString &str);
    3031
    3132public:
     
    4142    };
    4243
    43     MDriveCom(MsgQueue *q, const char *addr, MLog *out) : MCeCoCom(addr, out), fQueue(q) {}
     44    MDriveCom(MsgQueue *q, const char *addr, const int tx, const int rx, MLog *out=NULL) : MCeCoCom(addr, tx, rx, out), fQueue(q) {}
     45    MDriveCom(const char *addr, const int tx, const int rx, MLog *out=NULL) : MCeCoCom(addr, tx, rx, out), fQueue(NULL) {}
    4446
    45     bool SendReport(UInt_t stat, RaDec rd, ZdAz so, ZdAz is, ZdAz er);
     47    void SetMsgQueue(MsgQueue *q) { fQueue = q; }
     48
     49
     50    bool SendReport(UInt_t stat, RaDec rd, ZdAz so, ZdAz is, ZdAz er, Bool_t armed);
    4651    bool SendStargReport(UInt_t stat, ZdAz miss, ZdAz nompos, Ring center, Int_t num, Int_t n, Double_t bright, Double_t mjd, Double_t x, Double_t y);
     52    bool SendTPoint(UInt_t stat);
    4753    bool SendStatus(const char *stat);
    4854};
  • trunk/MagicSoft/Cosy/tcpip/MTcpIpIO.cc

    r8865 r8869  
    217217            if (!ReadSocket(sock))
    218218            {
    219                 gLog << warn << "WARNING - Connection lost to " << MTcpIpO::GetSocketAddress(sock) << endl;
     219                gLog << warn << MTime(-1) << " WARNING - Connection lost to " << MTcpIpO::GetSocketAddress(sock) << endl;
    220220                return kFALSE;
    221221            }
     
    228228            if (timeout.HasTimedOut())
    229229            {
    230                 gLog << warn << "WARNING - Connection to " << MTcpIpO::GetSocketAddress(sock) << " timed out." << endl;
     230                gLog << warn << MTime(-1) << " WARNING - Connection to " << MTcpIpO::GetSocketAddress(sock) << " timed out." << endl;
    231231                return kFALSE;
    232232            }
     
    245245void MTcpIpI::WaitForConnection(TServerSocket &server)
    246246{
    247     gLog << all << " Wait for connection" << endl;
    248 
    249247    while (!IsThreadCanceled())
    250248    {
    251         gLog << all << "Listening for new connection on port " << fPortRx << "..." << endl;
     249        gLog << all << MTime(-1) << " Listening for new connection on port " << fPortRx << "..." << endl;
    252250
    253251        // Check for a connection request (reminder: we are in non-blocking mode)
     
    256254        while (!IsThreadCanceled())
    257255        {
     256            //cout << (int) IsThreadCanceled() << endl;
    258257            // Wait for a new connection on RX port
    259258            socket = server.Accept();
     
    281280            return;
    282281
    283         gLog << all << "Connection established to " << MTcpIpO::GetSocketAddress(*socket) << "..." << endl;
     282        gLog << all << MTime(-1) << " Connection established to " << MTcpIpO::GetSocketAddress(*socket) << "..." << endl;
    284283
    285284        if (!WaitForData(*socket))
     
    296295    while (!IsThreadCanceled())
    297296    {
    298         TServerSocket *server=new TServerSocket(fPortRx, kTRUE);
     297        TServerSocket *server=new TServerSocket(fPortRx, kTRUE, 0);
    299298        server->SetOption(kNoBlock, 1);
    300299
  • trunk/MagicSoft/Cosy/videodev/Camera.cc

    r8860 r8869  
    3434using namespace std;
    3535
    36 Camera::Camera(PixClient &client, Int_t nch) : MThread("Camera"), fClient(client), fVideo(0), fNumFrame(0)
     36Camera::Camera(PixClient &client, Int_t nch) : MThread("Camera"), fClient(client), fVideo(0), fNumFrame(0), fChannel(nch)
    3737{
    3838    fVideo = new MVideo;
  • trunk/MagicSoft/Cosy/videodev/FilterLed.cc

    r8811 r8869  
    9292    ~ClusterFinder()
    9393    {
    94         delete fImg;
     94        delete [] fImg;
    9595    }
    9696    Double_t GetSumX() const { return fSumX; }
  • trunk/MagicSoft/Cosy/videodev/MVideo.cc

    r8862 r8869  
    185185{
    186186    struct v4l2_queryctrl qctrl;
     187    memset(&qctrl, 0, sizeof(qctrl));
    187188    qctrl.id = id;
    188189
Note: See TracChangeset for help on using the changeset viewer.