Ignore:
Timestamp:
10/15/03 17:28:35 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Cosy/tcpip
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Cosy/tcpip/MCeCoCom.cc

    r2379 r2384  
    4141
    4242        // skip solar_irr_Wm2, wind_speed, UPS
    43         float zd, az, dec, ra, temp, hum;
     43                float zd, az, dec, ra, temp, hum;
    4444        n=sscanf(str.Data(),
    4545                 "%f %f %f %f %f %*f %*f %f %*f %n",
  • trunk/MagicSoft/Cosy/tcpip/MCeCoCom.h

    r2379 r2384  
    3434
    3535    bool InterpreteStr(TString str);
    36     bool Send(const char *str);
    3736
    3837public:
    39     MCeCoCom::MCeCoCom(const char *cmd)
    40         : MTcpIpIO(), fCommand(cmd), fStatus(0), fComStat(kNoCmdReceived)
     38    MCeCoCom::MCeCoCom(const char *cmd, MLog &out=gLog)
     39        : MTcpIpIO(out), fCommand(cmd), fStatus(0), fComStat(kNoCmdReceived)
    4140    {
    4241    }
    4342
     43    bool Send(const char *str);
    4444    void SetStatus(Byte_t s) { fStatus=s; }
    4545};
  • trunk/MagicSoft/Cosy/tcpip/MDriveCom.cc

    r2379 r2384  
    22
    33#include <iostream>
     4
     5#include "coord.h"
     6#include "Slalib.h"
    47
    58using namespace std;
     
    3134    return false;
    3235}
     36
     37void MDriveCom::Print(TString &str, Double_t deg) const
     38{
     39    Char_t sgn;
     40    UShort_t d, m, s;
     41
     42    Slalib::Deg2Dms(deg, sgn, d, m, s);
     43
     44    str += Form("%c %03d %02d %03d ", sgn, d, m, s);
     45}
     46
     47bool MDriveCom::SendReport(UInt_t stat, RaDec rd, ZdAz so, ZdAz is, ZdAz er)
     48{
     49    // so [rad]
     50    // is [deg]
     51    // er [rad]
     52
     53    so *= kRad2Deg;
     54    er *= kRad2Deg;
     55
     56    // Set status flag
     57    if (stat&kError)
     58        SetStatus(0);
     59    if (stat&kStopped)
     60        SetStatus(1);
     61    if (stat&kStopping || stat&kMoving)
     62        SetStatus(3);
     63    if (stat&kTracking)
     64        SetStatus(4);
     65
     66    Timer t;
     67    t.Now();
     68
     69    TString str;
     70    Print(str, rd.Ra());    // Ra
     71    Print(str, rd.Dec());   // Dec
     72    Print(str, 0);          // HA
     73    str += Form("%12.6f ", t.GetMjd()); // mjd
     74    Print(str, so.Zd());
     75    Print(str, so.Az());
     76    Print(str, is.Zd());
     77    Print(str, is.Az());
     78    str += Form("%08.3f ", er.Zd());
     79    str += Form("%08.3f", er.Az());
     80
     81    return Send(str);
     82}
  • trunk/MagicSoft/Cosy/tcpip/MDriveCom.h

    r2379 r2384  
    66#endif
    77
     8class RaDec;
     9class ZdAz;
     10
    811class MDriveCom : public MCeCoCom
    912{
    1013private:
    1114    bool InterpreteCmd(TString cmd, TString str);
     15    void Print(TString &str, Double_t deg) const;
    1216
    1317public:
    14     MDriveCom() : MCeCoCom("DRIVE-REPORT") {}
     18    enum
     19    {
     20        kError    = 0x01,
     21        kMoving   = 0x02,
     22        kTracking = 0x04,
     23        kStopping = 0x08,
     24        kStopped  = 0x10
     25    };
     26
     27    MDriveCom(MLog &out=gLog) : MCeCoCom("DRIVE-REPORT", out) {}
     28
     29    bool SendReport(UInt_t stat, RaDec rd, ZdAz so, ZdAz is, ZdAz er);
    1530};
    1631
  • trunk/MagicSoft/Cosy/tcpip/MTcpIpIO.cc

    r2379 r2384  
    3131     */
    3232
    33 MTcpIpIO::MTcpIpIO() : MThread(false), fRxSocket(NULL), fServSock(NULL)
     33MTcpIpIO::MTcpIpIO(MLog &out) : MThread(false), Log(out), fRxSocket(NULL), fServSock(NULL)
    3434{
    3535    fTxSocket = new TSocket("ceco", 7304);
     
    3838MTcpIpIO::~MTcpIpIO()
    3939{
     40    cout << "Delete TxSocket..." << flush;
    4041    delete fTxSocket;
     42    cout << "Done." << endl;
     43    if (fServSock)
     44    {
     45        cout << "Delete ServSock..." << flush;
     46        delete fServSock;
     47        cout << "Done." << endl;
     48    }
     49    if (fRxSocket)
     50    {
     51        cout << "Delete RxSocket..." << flush;
     52        delete fRxSocket;
     53        cout << "Done." << endl;
     54    }
    4155}
    4256
     
    6882}
    6983
     84void MTcpIpIO::Clear()
     85{
     86    char c;
     87    while (fRxSocket->RecvRaw(&c, 1)>0 && !HasStopFlag())
     88        usleep(1);
     89}
     90
    7091void *MTcpIpIO::Thread()
    7192{
     
    87108            }
    88109            delete fServSock;
     110            fServSock=NULL;
    89111            usleep(5000000);
    90112            continue;
     
    105127        {
    106128            delete fServSock;
     129            fServSock=NULL;
    107130            continue;
    108131        }
     
    113136            delete fServSock;
    114137            delete fRxSocket;
     138            fServSock = NULL;
     139            fRxSocket = NULL;
    115140            continue;
    116141        }
     
    119144
    120145        fRxSocket->SetOption(kNoBlock, 1);
     146
     147        Clear();
    121148
    122149        TString str;
     
    160187        delete fServSock;
    161188        delete fRxSocket;
     189        fServSock = NULL;
     190        fRxSocket = NULL;
    162191    }
    163192
  • trunk/MagicSoft/Cosy/tcpip/MTcpIpIO.h

    r2379 r2384  
    55#include "MThread.h"
    66#endif
     7#ifndef COSY_Log
     8#include "log.h"
     9#endif
    710
    811class TString;
     
    1013class TServerSocket;
    1114
    12 class MTcpIpIO : public MThread
     15class MTcpIpIO : public MThread, public Log
    1316{
    1417private:
     
    1720    TServerSocket *fServSock;
    1821
     22    void Clear();
     23
    1924public:
    20     MTcpIpIO();
     25    MTcpIpIO(MLog &out=gLog);
    2126    ~MTcpIpIO();
    2227
  • trunk/MagicSoft/Cosy/tcpip/Makefile

    r2379 r2384  
    2020# @endcode
    2121
    22 INCLUDES = -I. -I../base
     22INCLUDES = -I. -I../base -I../catalog
    2323
    2424# @code
Note: See TracChangeset for help on using the changeset viewer.