Changeset 19452 for trunk/FACT++


Ignore:
Timestamp:
03/28/19 18:40:40 (5 years ago)
Author:
tbretz
Message:
This implements changes which are required for follow-up observations. Note that up to date these are untested and will be rolled out and debugged in La Palam in the next days.
Location:
trunk/FACT++
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/scripts/Main.js

    r19014 r19452  
    194194// ================================================================
    195195
    196 function OpenLid()
     196function OpenLid(fast)
    197197{
    198198    /*
     
    227227        dim.log("Camera response: "+ret.data.replace(/\n/g,"/")+" ["+ret.rc+"]");
    228228    }
     229
     230    if (!fast)
     231        return;
     232
    229233    dim.wait("LID_CONTROL", "Open", 30000);
    230234
     
    15081512        //  ...no drs calibration was done yet
    15091513        var drscal = (run%4==0 && (remaining>15 && diff>70)) || diff==null;
    1510    
     1514
    15111515        if (point)
    15121516        {
     
    15451549        }
    15461550
    1547         if (drscal)
     1551        if (drscal && !obs[sub].nodrs)
    15481552        {
    15491553            doDrsCalibration("data");  // will turn voltage off
     
    15621566            continue;
    15631567
    1564         OpenLid();
    1565 
    1566         // This is now th right time to wait for th drive to be stable
    1567         dim.wait("DRIVE_CONTROL", "OnTrack", 150000); // 110s for turning and 30s for stabilizing
     1568        OpenLid(obs[sub].grb);
     1569
     1570        // This is now the right time to wait for the drive to be stable
     1571        if (!obs[sub].grb)
     1572            dim.wait("DRIVE_CONTROL", "OnTrack", 150000); // 110s for turning and 30s for stabilizing
     1573        else
     1574            v8.timeout(150000, function() { if (dim.state("DRIVE_CONTROL").name=="Approaching" || dim.state("DRIVE_CONTROL").name=="Tracking" || dim.state("DRIVE_CONTROL").name=="OnTrack") return true; });
    15681575
    15691576        // Now check the voltage... (do not start a lot of stuff just to do nothing)
     
    15781585        // and wait for the feedback to get stable
    15791586        service_feedback.voltageOn();
    1580         service_feedback.waitForVoltageOn();
     1587        if (!obs[sub].grb)
     1588            service_feedback.waitForVoltageOn();
     1589
     1590        // For the first run to be taken (ratecontrol)
     1591        // Lid must be != Closed
     1592        // Drive must be >= Moving
     1593        // Setting the threshold can take 2-3 seconds
     1594
     1595        if (obs[sub].grb && run==0)
     1596        {
     1597            // Instead of a pedestal run, we take a very short grb mode run
     1598            // which is a classical data run but does not change the thresholds
     1599            // This gives the voltages (typ. 5s) and currents (typ. 3s) time to
     1600            // stabilize and threshold setting for the next run will be
     1601            // reliable and fast but we have data already
     1602            dim.log("Starting GRB mode.");
     1603
     1604            // Whatever we do... it does not make sense to start with a closed lid
     1605            // If the lid is not yet open, wait for the lid to be open and
     1606            // go on as usual.
     1607            if (dim.state("LID_CONTROL")!="Open")
     1608            {
     1609                dim.wait("LID_CONTROL", "Open", 30000);
     1610                service_feedback.waitForVoltageOn();
     1611            }
     1612
     1613            // Doing this manually makes it more flexible but turns off
     1614            // automatic Critical mode checking of the feedback and
     1615            // automatic reconnect
     1616            var nextrun = sub_startrun.get().obj['next'];
     1617            dim.log("Take run %3d".$(nextrun)+" [grb-mode]");
     1618
     1619            dim.send("MCP/START", -1, -1, "grb"); // Use previous threshold settings if ratecontrol "InProgress"
     1620            dim.wait("MCP", "TakingData", 15000);
     1621
     1622            dim.wait("FEEDBACK",      "InProgress",  45000); // This is most likely the first to happen
     1623            dim.wait("DRIVE_CONTROL", "Tracking",   150000); // 110s for turning and 30s for stabilizing
     1624
     1625            v8.wait(1000); // By now we should have collected the required three current events in FEEDBACK
     1626            // Current are averaged over 10s. So by now we should have a reasonable idea of the brightness of the sky
     1627            // Individual pixels might still suffer wrong settings
     1628            // Starting a new run takes less than 2s (for 60s runs this is 3%)
     1629        }
    15811630
    15821631        // If pointing had changed, do calibration
    1583         if (!irq && point)
     1632        if (!irq && point && !obs[sub].grb)
    15841633        {
    15851634            dim.log("Starting calibration.");
     
    16031652        var twilight = Sun.horizon(-16).isUp;
    16041653
    1605         if (twilight)
     1654        if (twilight || obs[sub].grb)
    16061655        {
    16071656            for (var i=0; i<5 && !irq; i++)
  • trunk/FACT++/src/gcn.cc

    r19429 r19452  
    11#include <functional>
     2#include <boost/algorithm/string/join.hpp>
    23
    34#include "Dim.h"
     
    1617
    1718#include "HeadersGCN.h"
     19#include "HeadersToO.h"
    1820
    1921#include <QtXml/QDomDocument>
     
    4446    Time fLastKeepAlive;
    4547
    46     GCN::PaketType_t GetType(const QDomElement &what)
     48    QString GetParamValue(const QDomElement &what, const string &name)
    4749    {
    4850        const QDomNodeList param = what.elementsByTagName("Param");
     
    5052        {
    5153            const QDomElement elem = param.at(i).toElement();
    52             if (elem.attribute("name").toStdString()!="Packet_Type")
    53                 continue;
    54 
    55             const uint16_t val = elem.attribute("value").toUInt();
    56             const auto it = fTypes.find(val);
    57             if (it!=fTypes.end())
    58                 return it->second;
    59 
    60             Warn("Unknown paket type "+to_string(val)+".");
    61         }
    62 
     54            if (elem.attribute("name").toStdString()==name)
     55                return elem.attribute("value");
     56        }
     57
     58        return "";
     59    }
     60
     61    GCN::PaketType_t GetType(const QDomElement &what)
     62    {
     63        const auto value = GetParamValue(what, "Packet_Type");
     64        if (value.isEmpty())
     65            return { -1, "", "" };
     66
     67        const uint16_t val = value.toUInt();
     68        const auto it = fTypes.find(val);
     69        if (it!=fTypes.end())
     70            return it->second;
     71
     72        Warn("Unknown paket type "+to_string(val)+".");
    6373        return { -1, "", "" };
    6474    }
    65 
    6675
    6776    int ProcessXml(const QDomElement &root)
     
    117126                return -1;
    118127
     128            const GCN::PaketType_t ptype = GetType(what);
     129
    119130            const QDomElement date   = who.firstChildElement("Date");
    120131            const QDomElement author = who.firstChildElement("Author");
     
    135146            const QDomElement errad  = pos2d.firstChildElement("Error2Radius");
    136147
    137             if (date.isNull()   || author.isNull() || sname.isNull() || //desc.isNull() ||
    138                 obsdat.isNull() || obsloc.isNull() || coord.isNull() || time.isNull() ||
    139                 pos2d.isNull()  || name1.isNull()  || name2.isNull() || val2.isNull() ||
    140                 c1.isNull()     || c2.isNull()     || errad.isNull())
     148            const bool is_gw = ptype.type==150 || ptype.type==151 || ptype.type==153;
     149
     150            vector<string> missing;
     151            if (date.isNull())
     152                missing.emplace_back("Date");
     153            if (author.isNull())
     154                missing.emplace_back("Author");
     155            if (sname.isNull() && !is_gw)
     156                missing.emplace_back("shortName");
     157            if (obsdat.isNull())
     158                missing.emplace_back("ObsDataLocation");
     159            if (obsloc.isNull())
     160                missing.emplace_back("ObservationLocation");
     161            if (coord.isNull())
     162                missing.emplace_back("AstroCoords");
     163            if (time.isNull())
     164                missing.emplace_back("Time/TimeInstant/ISOTime");
     165            if (pos2d.isNull() && !is_gw)
     166                missing.emplace_back("Position2D");
     167            if (name1.isNull() && !is_gw)
     168                missing.emplace_back("Name1");
     169            if (name1.isNull() && !is_gw)
     170                missing.emplace_back("Name2");
     171            if (val2.isNull() && !is_gw)
     172                missing.emplace_back("Value2");
     173            if (c1.isNull() && !is_gw)
     174                missing.emplace_back("C1");
     175            if (c2.isNull() && !is_gw)
     176                missing.emplace_back("C2");
     177            if (errad.isNull() && !is_gw)
     178                missing.emplace_back("Error2Radius");
     179
     180            if (!missing.empty())
     181            {
     182                Warn("Missing elements: "+boost::algorithm::join(missing, ", "));
    141183                return -1;
    142 
    143             const GCN::PaketType_t ptype = GetType(what);
     184            }
    144185
    145186            //  59/31: Konus LC / IPN raw         [observation]
     
    195236            const string unit = pos2d.attribute("unit").toStdString();
    196237
    197             const double ra  = c1.text().toDouble();
    198             const double dec = c2.text().toDouble();
    199             const double err = errad.text().toDouble();
     238            const uint32_t trig  = GetParamValue(what, "TrigID").toUInt();
     239            const double   ra    = c1.text().toDouble();
     240            const double   dec   = c2.text().toDouble();
     241            const double   err   = errad.text().toDouble();
    200242
    201243            const string n1 = name1.text().toStdString();
     
    212254            Out() << "  " << setw(5) << "ERR"  << "= " << err << unit << '\n';
    213255
    214             if (n1=="RA" && n2=="Dec" && unit=="deg")
     256            const bool has_coordinates = n1=="RA" && n2=="Dec" && unit=="deg";
     257
     258            if (has_coordinates)
    215259            {
     260                const ToO::DataGRB data =
     261                {
     262                    .type   = ptype.type,
     263                    .trigid = trig,
     264                    .ra     = ra,
     265                    .dec    = dec,
     266                    .err    = err,
     267                };
     268
     269                Info("Sending ToO #"+to_string(trig)+" ["+role+"]");
     270                Dim::SendCommandNB("TARGET_OF_OPPORTUNITY/SCHEDULE_GCN", data);
     271
     272/*
    216273                const double jd = Time().JD();
    217274
     
    244301                    Out() << '\n';
    245302                }
     303*/
    246304            }
    247305
Note: See TracChangeset for help on using the changeset viewer.