Changeset 19564 for trunk/FACT++


Ignore:
Timestamp:
07/19/19 19:25:26 (5 years ago)
Author:
tbretz
Message:
Make an entry in the Alert DB if a broken GCN package is received (broken means different formatting than what we expect)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/gcn.cc

    r19554 r19564  
    11#include <functional>
    22#include <boost/algorithm/string/join.hpp>
     3
     4#include "Database.h"
    35
    46#include "Dim.h"
     
    4143    bool fDebugRx;
    4244
     45    string fUri;
     46
    4347    uint32_t     fRxSize;
    4448    vector<char> fRxData;
     
    7983    {
    8084        if (root.isNull())
    81             return -1;
     85            return -255;
    8286
    8387        const string role = root.attribute("role", "").toStdString();
     
    9397                const QDomElement time = root.firstChildElement("TimeStamp");
    9498                if (orig.isNull() || time.isNull())
    95                     return -1;
     99                    return -254;
    96100
    97101                fLastKeepAlive = Time(time.text().toStdString());
     
    126130            //const QDomElement ref  = root.firstChildElement("Reference");
    127131            if (who.isNull() || what.isNull() || when.isNull())
    128                 return -1;
     132                return -253;
    129133
    130134            const auto ptype = GetType(what);
     
    149153
    150154            const auto &id = ptype->first;
     155
     156            if (id==0)
     157            {
     158                Warn("Packet ID = 0");
     159                return -252;
     160            }
    151161
    152162            // Gravitational wave event
     
    187197            {
    188198                Warn("Missing elements: "+boost::algorithm::join(missing, ", "));
    189                 return -1;
     199                return -id;
    190200            }
    191201
     
    468478            Out() << fRxData.data() << '\n';
    469479            Out() << "------------------------------------------------------" << endl;
    470             PostClose(false);
     480            PostClose(true);
    471481            return;
    472482        }
     
    482492            Out() << fRxData.data() << '\n';
    483493            Out() << "------------------------------------------------------" << endl;
    484             PostClose(false);
     494            //PostClose(false);
     495
     496            try
     497            {
     498                auto db = Database(fUri);
     499
     500                // Make an entry in the alter databse to issue a call
     501                const string query =
     502                    "INSERT FlareTriggers SET\n"
     503                    " fTriggerInserted=Now(),\n"
     504                    " fNight="+to_string(Time().NightAsInt())+",\n"
     505                    " fRunID="+to_string(-rc)+",\n"
     506                    " fTriggerType=8";
     507
     508                auto q = db.query(query);
     509                q.execute();
     510                if (!q.info().empty())
     511                    Info(q.info());
     512            }
     513            catch (const mysqlpp::ConnectionFailed &e)
     514            {
     515                Error(e.what());
     516            }
     517
    485518            return;
    486519        }
     
    525558        fDebugRx = b;
    526559        Connection::SetVerbose(b);
     560    }
     561
     562    void SetURI(const string &uri)
     563    {
     564        fUri = uri;
    527565    }
    528566
     
    680718        fGCN.SetEndPoints(conf.Vec<string>("addr"));
    681719
     720        fGCN.SetURI(conf.Get<string>("schedule-database"));
     721
    682722        return -1;
    683723    }
     
    701741        ("addr,a",        vars<string>(),  "Network addresses of GCN server")
    702742        ("quiet,q",       po_bool(true),  "Disable printing contents of all received messages (except dynamic data) in clear text.")
     743        ("schedule-database", var<string>(), "Database link as in\n\tuser:password@server[:port]/database[?compress=0|1].")
    703744        ;
    704745
Note: See TracChangeset for help on using the changeset viewer.