Ignore:
Timestamp:
04/22/09 10:46:59 (16 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Cosy/tcpip
Files:
4 edited

Legend:

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

    r8998 r9432  
    133133
    134134    const TString msg =
    135         MString::Format("%s "
     135        MString::Format("%s M%d "
    136136             "%02d %04d %02d %02d %02d %02d %02d %03d "
    137137             "%02d %04d %02d %02d %02d %02d %02d %03d "
    138              "%s\n", cmd,
     138             "%s\n", cmd, fTelescope,
    139139             fStatus,  y1, mon1, d1, h1, m1, s1, ms1,
    140140             fComStat, y2, mon2, d2, h2, m2, s2, ms2,
  • trunk/MagicSoft/Cosy/tcpip/MCeCoCom.h

    r8869 r9432  
    3333    int     fCCStatus;    // global status of CC
    3434
     35    Byte_t  fTelescope;
     36
    3537    ComStatus_t fComStat; // communication status
    3638
     
    4951public:
    5052    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),
     53        : MTcpIpIO(addr, tx, rx), fOut(out), fStatus(0),
     54        fTelescope(1), fComStat(kNoCmdReceived),
    5255        fHumidity(0), fTemperature(0), fWindSpeed(0), fSolarRadiation(-1),
    5356        fAlarmCounter(0)
     
    6063    bool SendRep(const char *cmd, const char *str, bool force);
    6164    void SetStatus(Byte_t s) { fStatus=s; }
     65
     66    void SetTelescope(Byte_t tel) { fTelescope = tel; }
    6267
    6368    Float_t GetHumidity() const { return fHumidity; }
  • trunk/MagicSoft/Cosy/tcpip/MTcpIpIO.cc

    r8869 r9432  
    1515
    1616#undef DEBUG
     17//#define DEBUG
    1718
    1819using namespace std;
     
    4041     */
    4142
    42 MTcpIpO::MTcpIpO(const char *addr, Int_t tx)
    43 {
     43MTcpIpO::MTcpIpO(const char *addr, Int_t tx) : fPortTx(tx)
     44{
     45    gLog << inf2 << "- Open send socket to " << addr << ":" << tx << endl;
    4446    fTxSocket = new TSocket(addr, tx);
    4547}
     
    147149bool MTcpIpO::Send(const char *msg, Int_t len)
    148150{
     151    if (!fTxSocket->IsValid())
     152    {
     153        const TInetAddress &a = fTxSocket->GetInetAddress();
     154        if (!a.IsValid())
     155            return false;
     156#ifdef DEBUG
     157        cout << "- Reopen send socket to " << a.GetHostAddress() << ":" << fPortTx << endl;
     158#endif
     159        delete fTxSocket;
     160        fTxSocket = new TSocket(a.GetHostAddress(), fPortTx);
     161    }
     162
    149163    return SendFrame(*fTxSocket, msg, len);
    150164}
     
    206220    fConnectionEstablished = kTRUE;
    207221
    208     MTimeout timeout;
     222    MTimeout timeout(fTimeout);
    209223
    210224    // Get connection on port fPortRx and redirected
     
    228242            if (timeout.HasTimedOut())
    229243            {
    230                 gLog << warn << MTime(-1) << " WARNING - Connection to " << MTcpIpO::GetSocketAddress(sock) << " timed out." << endl;
     244                gLog << warn << MTime(-1) << " WARNING - Connection to " << MTcpIpO::GetSocketAddress(sock) << " timed out after " << fTimeout << "ms." << endl;
    231245                return kFALSE;
    232246            }
     
    285299            fConnectionEstablished = kFALSE;
    286300
     301#ifdef DEBUG
     302        cout << "===> DEL SOCKET" << endl;
     303#endif
    287304        delete socket;
    288305    }
     
    314331        }
    315332
     333#ifdef DEBUG
     334        cout << "===> DEL SERVER" << endl;
     335#endif
    316336        delete server;
    317337
  • trunk/MagicSoft/Cosy/tcpip/MTcpIpIO.h

    r8865 r9432  
    4444    TSocket *fTxSocket;
    4545
     46    Int_t fPortTx;
     47
    4648public:
    4749    MTcpIpO(const char *addr, Int_t tx);
Note: See TracChangeset for help on using the changeset viewer.